class Card class Act class ActRenderer def initialize format, act, args @format = format @act = act @act_card = act.card @args = args @card = @format.card @context = @args[:act_context] end include ::Bootstrapper def method_missing method_name, *args, &block if block_given? @format.send(method_name, *args, &block) else @format.send(method_name, *args) end end def respond_to_missing? method_name, _include_private=false @format.respond_to? method_name end def render return "" unless @act_card act_accordion end def header #::Bootstrap.new(self).render do bs_layout do row 10, 2 do column do html title tag(:span, "text-muted pl-1 badge") { summary } end column act_links, class: "text-right" end end # end end def absolute_title accordion_expand_link(@act_card.name) end def details approved_actions[0..20].map do |action| Action::ActionRenderer.new(@format, action, action_header?, :summary).render end.join end def summary %i[create update delete draft].map do |type| next unless count_types[type] > 0 "#{@format.action_icon type} #{count_types[type]}" end.compact.join " | " end def act_links [ link_to_history, (link_to_act_card unless @act_card.trash) ].compact.join " " end def link_to_act_card link_to_card @act_card, icon_tag(:new_window), class: "_stop_propagation" end def link_to_history link_to_card @act_card, icon_tag(:history), path: { view: :history, look_in_trash: true }, class: "_stop_propagation", rel: "nofollow" end def approved_actions @approved_actions ||= actions #.select { |a| a.card && a.card.ok?(:read) } # FIXME: should not need to test for presence of card here. end def action_header? true # @action_header ||= approved_actions.size != 1 || # approved_actions[0].card_id != @format.card.id end def count_types @count_types ||= approved_actions.each_with_object( Hash.new { |h, k| h[k] = 0 } ) do |action, type_cnt| type_cnt[action.action_type] += 1 end end def edited_ago return "" unless @act.acted_at "#{time_ago_in_words(@act.acted_at)} ago" end def collapse_id "act-id-#{@act.id}" end def accordion_expand_link text <<-HTML #{text} HTML end # TODO: change accordion API in bootstrap/helper.rb so that it can be used # here. The problem is that here we have extra links in the title # that are not supposed to expand the accordion def act_accordion context = @act.main_action.draft ? :warning : :default <<-HTML