Module: Card::Set::Rule::RuleForm::FormElements::HtmlFormat

Extended by:
AbstractFormat
Defined in:
tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb

Instance Method Summary collapse

Instance Method Details

#option_list(title) ⇒ Object



42
43
44
45
46
47
48
# File 'tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb', line 42

def option_list title
  formgroup title, editor: "set", class: "col-xs-6", help: false do
    wrap_with :ul do
      wrap_each_with(:li, class: "radio") { yield }
    end
  end
end


50
51
52
53
54
55
56
57
58
# File 'tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb', line 50

def related_rule_radios related_sets, tag
  related_sets.map do |set_name, _label|
    rule_name = "#{set_name}+#{tag}"
    state = Card.exists?(rule_name) ? :exists : nil
    rule_radio set_name, state do
      radio_button :name, rule_name
    end
  end
end


27
28
29
30
31
32
33
34
35
# File 'tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb', line 27

def related_set_formgroup
  related_sets = related_sets_in_context
  return "" unless related_sets && !related_sets.empty?

  tag = @rule_context.rule_user_setting_name
  option_list "related set" do
    related_rule_radios related_sets, tag
  end
end


37
38
39
40
# File 'tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb', line 37

def related_sets_in_context
  set_context = @rule_context.rule_set_name
  set_context && Card.fetch(set_context).prototype.related_sets
end

#rule_set_formgroupObject



17
18
19
20
21
22
23
24
25
# File 'tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb', line 17

def rule_set_formgroup
  tag = @rule_context.rule_user_setting_name
  narrower = []
  option_list "set" do
    rule_set_options.map do |set_name, state|
      rule_set_radio_button set_name, tag, state, narrower
    end
  end
end

#rule_set_selectionObject

DEPRECATED



11
12
13
14
15
# File 'tmpsets/set/mod022-rules/rule/rule_form/form_elements.rb', line 11

def rule_set_selection
  wrap_with :div, class: "set-list" do
    [rule_set_formgroup, related_set_formgroup]
  end
end