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
9 10 11 12 13 14 15 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 9 def act_from_context if (act_id = params["act_id"]) Act.find(act_id) || raise(Card::NotFound, "act not found") else card.last_action.act end end |
#act_list_starting_seq(acts) ⇒ Object
71 72 73 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 71 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
30 31 32 33 34 35 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 30 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 }
39 40 41 42 43 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 39 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
83 84 85 86 87 88 89 90 91 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 83 def action_icon action_type, extra_class=nil icon = case action_type when :create then :create_action when :update then :update_action when :delete then :delete_action when :draft then :draft end icon_tag icon, extra_class end |
#acts_for_accordion(acts, context) ⇒ Object
45 46 47 48 49 50 51 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 45 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
22 23 24 25 26 27 28 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 22 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
79 80 81 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 79 def acts_page_from_params @acts_page_from_params ||= params["page"].present? ? params["page"].to_i : 1 end |
#acts_per_page ⇒ Object
75 76 77 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 75 def acts_per_page @acts_per_page ||= Card.config.acts_per_page || 10 end |
#clean_acts(acts) ⇒ Object
61 62 63 64 65 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 61 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
57 58 59 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 57 def current_act_seq acts @act_seq = @act_seq ? (@act_seq -= 1) : act_list_starting_seq(acts) end |
#current_page_acts(acts) ⇒ Object
67 68 69 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 67 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
53 54 55 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 53 def with_act_seq context, acts yield(context == :absolute ? nil : current_act_seq(acts)) end |