Module: GroupsHelper

Defined in:
app/helpers/groups_helper.rb

Instance Method Summary collapse

Instance Method Details

#cached_groups_of_user_table(user) ⇒ Object



35
36
37
# File 'app/helpers/groups_helper.rb', line 35

def cached_groups_of_user_table(user)
  Rails.cache.fetch([user, 'groups_of_user_table'], expires_in: 1.week) { groups_of_user_table(user) }
end

#groups_of_user_table(user) ⇒ Object



3
4
5
6
7
8
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
# File 'app/helpers/groups_helper.rb', line 3

def groups_of_user_table( user )
   :table, :class => "user_groups" do
     :tr do
      
      # first column:
      c =  :td do
         :ul do
          
          corporation_groups = user.current_corporations
          if corporation_groups
            corporation_groups.collect do |group|
              sub_group_membership_lis( user: user, group: group, indent: 0, max_indent: 3 )
            end.join.html_safe
          end
          
        end
      end

      # second column:
      c += ( :td ) do
         :ul do
          
          Group.find_non_corporations_branch_groups_of( user ).collect do |group|
            membership_li( user, group )
          end.join.html_safe
          
        end
      end
    end
  end.html_safe
end