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_accordion(acts, context, &block) ⇒ Object
-
#act_from_context ⇒ Object
-
#act_list(acts, 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 }.
-
#act_paging(acts, context) ⇒ Object
-
#act_paging_opts(context) ⇒ Object
-
#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
-
#limited_paging?(context) ⇒ Boolean
-
#with_act_seq(context, acts) {|context == :absolute ? nil : current_act_seq(acts)| ... } ⇒ Object
Instance Method Details
#act_accordion(acts, context, &block) ⇒ Object
52 53 54 55 56 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 52 def act_accordion acts, context, &block accordion do acts_for_accordion(acts, context, &block).join end end |
#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(acts, context) ⇒ Object
30 31 32 33 34 35 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 30 def act_list acts, context act_accordion acts, context do |act, seq| fmt = context == :relative ? self : act.card.format(:html) fmt.act_listing act, seq, context end end |
#act_list_starting_seq(acts) ⇒ Object
84 85 86 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 84 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
37 38 39 40 41 42 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 37 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 }
46 47 48 49 50 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 46 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 |
#act_paging(acts, context) ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 96 def act_paging acts, context return unless controller.request # paginate requires a request wrap_with :div, class: "slotter btn-sm" do # normally we let method_missing handle the action_view stuff, # but that doesn't handle **arguments yet action_view.send :paginate, current_page_acts(acts), **act_paging_opts(context) end end |
#act_paging_opts(context) ⇒ Object
106 107 108 109 110 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 106 def act_paging_opts context { remote: true, theme: "twitter-bootstrap-4" }.tap do |opts| opts[:total_pages] = 10 if limited_paging? context end end |
#action_icon(action_type, extra_class = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 116 def action_icon action_type, extra_class=nil icon = case action_type when :create then :add_circle when :update then :pencil when :delete then :remove_circle when :draft then :wrench end icon_tag icon, extra_class end |
#acts_for_accordion(acts, context) ⇒ Object
58 59 60 61 62 63 64 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 58 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
92 93 94 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 92 def acts_page_from_params @acts_page_from_params ||= params["page"].present? ? params["page"].to_i : 1 end |
#acts_per_page ⇒ Object
88 89 90 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 88 def acts_per_page @acts_per_page ||= Card.config.acts_per_page || 10 end |
#clean_acts(acts) ⇒ Object
74 75 76 77 78 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 74 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
70 71 72 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 70 def current_act_seq acts @act_seq = @act_seq ? (@act_seq -= 1) : act_list_starting_seq(acts) end |
#current_page_acts(acts) ⇒ Object
80 81 82 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 80 def current_page_acts acts acts.page(acts_page_from_params).per acts_per_page end |
#limited_paging?(context) ⇒ Boolean
112 113 114 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 112 def limited_paging? context context == :absolute && Act.count > 1000 end |
#with_act_seq(context, acts) {|context == :absolute ? nil : current_act_seq(acts)| ... } ⇒ Object
66 67 68 |
# File 'platypus/tmp/set/gem-defaults/mod015-history/all/history/act_listing.rb', line 66 def with_act_seq context, acts yield(context == :absolute ? nil : current_act_seq(acts)) end |