Class: Views::Groups::Index

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

Instance Method Summary collapse

Constructor Details

#initialize(creator:, groups:) ⇒ Index

Returns a new instance of Index.



4
5
6
7
# File 'app/views/groups/index.rb', line 4

def initialize(creator:, groups:)
  @creator = creator
  @groups = groups
end

Instance Method Details

#view_template ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/views/groups/index.rb', line 9

def view_template
  PageTitle title: t("views.groups.index.title"), breadcrumbs: {
    Creator.model_name.human(count: 100) => creators_path,
    @creator.name => creator_path(@creator)
  }
  p { t("views.groups.index.description") }
  table class: "table table-striped" do
    tr do
      th { Group.human_attribute_name :name } # i18n-tasks-use t("activerecord.attributes.group.name")
      th { Group.human_attribute_name :memberships } # i18n-tasks-use t("activerecord.attributes.group.memberships")
      th { Group.human_attribute_name :invitations } # i18n-tasks-use t("activerecord.attributes.group.invitations")
      th { Group.human_attribute_name :description } # i18n-tasks-use t("activerecord.attributes.group.description")
      th { Group.human_attribute_name :typed_id } # i18n-tasks-use t("activerecord.attributes.group.typed_id")
      th
    end
    @groups.each do |group|
      tr do
        td { group.name }
        td { t("views.groups.index.member_count", count: group.members.active.count) }
        td { t("views.groups.index.invite_count", count: group.members.invited.count) if group.members.invited.any? }
        td { group.description }
        td { CopyableText text: group.typed_id, label: t("views.groups.index.copy") }
        td { GoButton label: t("views.groups.edit.title"), href: edit_creator_group_path(@creator, group), icon: "pencil", variant: :primary }
      end
    end
  end
  GoButton href: new_creator_group_path(@creator), label: t("views.groups.new.title"), variant: :primary
end