Module: Card::Set::Type::Set::RulesFilter::HtmlFormat

Extended by:
AbstractFormat
Defined in:
card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb,
card/tmpsets/set/mod037-card-mod-rules/type/set/rules_filter.rb

Instance Method Summary collapse

Instance Method Details

#filter_textObject



35
36
37
38
39
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 35

def filter_text
  wrap_with :span, class: "mx-2 small" do
    "rules that apply to #{_render_set_label.downcase}" # LOCALIZE
  end
end


62
63
64
65
66
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 62

def related_set_options
  card.related_sets(true).map do |name, label|
    [label, name.to_name.url_key]
  end
end

#rules_filter(view, selected_setting = nil, set_options = nil, path_opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 9

def rules_filter view, selected_setting=nil, set_options=nil, path_opts={}
  form_tag path(path_opts.merge(view: view)),
           remote: true, method: "get", role: "filter",
           "data-slot-selector": ".card-slot.rule-list",
           class: classy("nodblclick slotter form-inline slim-select2 m-2") do
    output [
      label_tag(:view, icon_tag("filter_list"), class: "mr-2"),
      setting_select(selected_setting),
      set_select(set_options)
    ].flatten
  end
end

#selected_setObject



48
49
50
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 48

def selected_set
  params[:set]
end

#set_select(set_options) ⇒ Object



22
23
24
25
26
27
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 22

def set_select set_options
  return filter_text.html_safe unless set_options

  [(:span, "rules that apply to set ...", class: "mx-2 small"),
   set_select_tag(set_options)]
end

#set_select_options(set_options) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 52

def set_select_options set_options
  options =
    if set_options == :related
      related_set_options
    else
      [[card.label, card.name.url_key]]
    end
  options_for_select(options, selected_set)
end

#set_select_tag(set_options = :related) ⇒ Object



41
42
43
44
45
46
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 41

def set_select_tag set_options=:related
  select_tag(:mark, set_select_options(set_options),
             class: "_submit-on-select form-control _close-rule-overlay-on-select",
             "data-minimum-results-for-search": "Infinity",
             "data-select2-id": "#{unique_id}-#{Time.now.to_i}")
end

#setting_select(selected = nil) ⇒ Object



29
30
31
32
33
# File 'card/tmpsets/set/mod036-card-mod-rules/type/set/rules_filter.rb', line 29

def setting_select selected=nil
  select_tag(:group, grouped_options_for_select(setting_options, selected),
             class: "_submit-on-select form-control",
             "data-select2-id": "#{unique_id}-#{Time.now.to_i}")
end