Class: Views::Lists::Show

Inherits:
Base
  • Object
show all
Defined in:
app/views/lists/show.rb

Instance Method Summary collapse

Constructor Details

#initialize(list:) ⇒ Show

Returns a new instance of Show.



4
5
6
# File 'app/views/lists/show.rb', line 4

def initialize(list:)
  @list = list
end

Instance Method Details

#before_template ⇒ Object



8
9
10
# File 'app/views/lists/show.rb', line 8

def before_template
  @title = @list.special ? t(@list.name) : t("views.lists.show.title", name: @list.name)
end

#view_template ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/views/lists/show.rb', line 12

def view_template
  PageTitle title: @title, breadcrumbs: {
    t("views.lists.index.title") => lists_path
  }
  p { t("views.lists.show.description") } unless @list.special
  table class: "table table-striped" do
    tr do
      th { Model.model_name.human }
      th { ListItem.human_attribute_name(:created_at) } # i18n-tasks-use t("activerecord.attributes.list_item.created_at")
    end
    @list.list_items.each do |item|
      next unless item.listable.is_a? Model
      tr do
        td { link_to item.listable.name, model_path(item.listable) }
        td { item.created_at.to_fs(:long_ordinal) }
      end
    end
  end
  GoButton label: t("views.lists.edit.title"), href: edit_list_path(@list), icon: "pencil", variant: :primary
end