Module: Card::Set::All::History::ActListing::HtmlFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb
Instance Method Summary collapse
-
#act_from_context ⇒ Object
-
#act_list_starting_seq(acts) ⇒ Object
-
#act_listing(act, seq = nil, context = nil) ⇒ Object
-
#act_listing_opts_from_params(seq) ⇒ Object
TODO: consider putting all these under one top-level param, eg: act: { seq: X, diff: [show/hide], action_view: Y }.
-
#action_icon(action_type, extra_class = nil) ⇒ Object
-
#acts_for_accordion(acts, context) ⇒ Object
-
#acts_layout(acts, context, draft_legend = :hide) ⇒ Object
used (by history and recent)for rendering act lists with legend and paging.
-
#acts_page_from_params ⇒ Object
-
#acts_per_page ⇒ Object
-
#clean_acts(acts) ⇒ Object
-
#current_act_seq(acts) ⇒ Object
-
#current_page_acts(acts) ⇒ Object
-
#with_act_seq(context, acts) {|context == :absolute ? nil : current_act_seq(acts)| ... } ⇒ Object
Instance Method Details
#act_from_context ⇒ Object
16 17 18 19 20 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 16 def act_from_context return card.last_action.act unless (act_id = params["act_id"]) Act.find(act_id) || raise(Card::NotFound, "act not found") end |
#act_list_starting_seq(acts) ⇒ Object
76 77 78 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 76 def act_list_starting_seq acts acts.size - ((acts_page_from_params - 1) * acts_per_page) end |
#act_listing(act, seq = nil, context = nil) ⇒ Object
35 36 37 38 39 40 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 35 def act_listing act, seq=nil, context=nil opts = act_listing_opts_from_params(seq) opts[:slot_class] = "revision-#{act.id} history-slot list-group-item" context ||= (params[:act_context] || :absolute).to_sym act_renderer(context).new(self, act, opts).render end |
#act_listing_opts_from_params(seq) ⇒ Object
TODO: consider putting all these under one top-level param, eg: act: { seq: X, diff: [show/hide], action_view: Y }
44 45 46 47 48 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 44 def act_listing_opts_from_params seq { act_seq: seq || params["act_seq"], action_view: (params["action_view"] || "summary").to_sym, hide_diff: params["hide_diff"].to_s.strip == "true" } end |
#action_icon(action_type, extra_class = nil) ⇒ Object
88 89 90 91 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 88 def action_icon action_type, extra_class=nil icon = ACTION_ICONS[action_type] icon_tag icon, extra_class end |
#acts_for_accordion(acts, context) ⇒ Object
50 51 52 53 54 55 56 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 50 def acts_for_accordion acts, context clean_acts(current_page_acts(acts)).map do |act| with_act_seq(context, acts) do |seq| yield act, seq end end end |
#acts_layout(acts, context, draft_legend = :hide) ⇒ Object
used (by history and recent)for rendering act lists with legend and paging
27 28 29 30 31 32 33 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 27 def acts_layout acts, context, draft_legend=:hide bs_layout container: false, fluid: false do html _render_act_legend(draft_legend => :draft_legend) row(12) { act_list acts, context } # row(12) { act_paging acts, context } end end |
#acts_page_from_params ⇒ Object
84 85 86 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 84 def acts_page_from_params @acts_page_from_params ||= params["page"].present? ? params["page"].to_i : 1 end |
#acts_per_page ⇒ Object
80 81 82 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 80 def acts_per_page @acts_per_page ||= Card.config.acts_per_page || 10 end |
#clean_acts(acts) ⇒ Object
66 67 68 69 70 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 66 def clean_acts acts # FIXME: if we get rid of bad act data, this will not be necessary # The current acts.select(&:card) end |
#current_act_seq(acts) ⇒ Object
62 63 64 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 62 def current_act_seq acts @act_seq = @act_seq ? (@act_seq -= 1) : act_list_starting_seq(acts) end |
#current_page_acts(acts) ⇒ Object
72 73 74 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 72 def current_page_acts acts acts.page(acts_page_from_params).per acts_per_page end |
#with_act_seq(context, acts) {|context == :absolute ? nil : current_act_seq(acts)| ... } ⇒ Object
58 59 60 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 58 def with_act_seq context, acts yield(context == :absolute ? nil : current_act_seq(acts)) end |