Sha256: b04db701b2727746ac13b90a01723aea44e1de1788f9a90faa69477cd4565758

Contents?: true

Size: 1.37 KB

Versions: 16

Compression:

Stored size: 1.37 KB

Contents

format :html do
  view :rule_form, cache: :never, unknown: true do
    @success_view ||= :open
    @rule_context ||= card
    @form_type ||= :overlay

    wrap do
      edit_rule_form @success_view do
        [
          hidden_tags(success: @edit_rule_success),
          haml(:rule_form)
        ].join
      end
    end
  end

  def form_type
    @form_type || :overlay
  end

  def current_rule_form success_view: :overlay_rule, form_type: :overlay
    current_rule_format = subformat current_rule
    current_rule_format.rule_form success_view, card, form_type
  end

  def rule_form success_view, rule_context, form_type=:overlay
    validate_form_type form_type

    @rule_context = rule_context
    @form_type = form_type
    @success_view = success_view

    render_rule_form
  end

  def validate_form_type form_type
    return if form_type.in? %i[overlay modal]

    raise "invalid rule_form type: #{form_type}; has to be overlay or modal"
  end

  def edit_rule_form success_view, &block
    @rule_context ||= card
    @edit_rule_success = edit_rule_success(success_view)
    action_args = { action: :update, no_mark: true }
    card_form action_args, rule_form_args, &block
  end

  def rule_form_args
    { class: "card-rule-form", "data-slotter-mode": "update-origin" }
  end

  def edit_rule_success view="overlay_rule"
    { id: @rule_context.name.url_key,
      view: view }
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
card-mod-rules-0.11.3 set/rule/rule_form.rb
card-mod-rules-0.11.2 set/rule/rule_form.rb
card-mod-rules-0.11.1 set/rule/rule_form.rb
card-mod-rules-0.11.0 set/rule/rule_form.rb
card-1.100.0 mod/rules/set/rule/rule_form.rb
card-1.99.6 mod/rules/set/rule/rule_form.rb
card-1.99.5 mod/rules/set/rule/rule_form.rb
card-1.99.4 mod/rules/set/rule/rule_form.rb
card-1.99.3 mod/rules/set/rule/rule_form.rb
card-1.99.2 mod/rules/set/rule/rule_form.rb
card-1.99.1 mod/rules/set/rule/rule_form.rb
card-1.99.0 mod/rules/set/rule/rule_form.rb
card-1.98.3 mod/rules/set/rule/rule_form.rb
card-1.98.2 mod/rules/set/rule/rule_form.rb
card-1.98.1 mod/rules/set/rule/rule_form.rb
card-1.98.0 mod/rules/set/rule/rule_form.rb