Sha256: 9f0d1ef586c5a49e3ebeb211057801f95e9a1ffbedf83600b9ffe6f0a9f240a6

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

format :html do
  #### DEPRECATED

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

  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

  def related_set_formgroup
    related_sets = related_sets_in_context
    return "" unless related_sets&.present?

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

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

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

  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-mod-rules-0.11.4 set/rule/rule_form/form_elements.rb
card-mod-rules-0.11.3 set/rule/rule_form/form_elements.rb
card-mod-rules-0.11.2 set/rule/rule_form/form_elements.rb
card-mod-rules-0.11.1 set/rule/rule_form/form_elements.rb
card-mod-rules-0.11.0 set/rule/rule_form/form_elements.rb