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

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

Instance Method Summary collapse

Instance Method Details

#current_rule_form(success_view: :overlay_rule, form_type: :overlay) ⇒ Object



28
29
30
31
# File 'tmpsets/set/mod022-rules/rule/rule_form.rb', line 28

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

#edit_rule_form(success_view, &block) ⇒ Object



49
50
51
52
53
54
# File 'tmpsets/set/mod022-rules/rule/rule_form.rb', line 49

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

#edit_rule_success(view = "overlay_rule") ⇒ Object



60
61
62
63
# File 'tmpsets/set/mod022-rules/rule/rule_form.rb', line 60

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

#form_typeObject



24
25
26
# File 'tmpsets/set/mod022-rules/rule/rule_form.rb', line 24

def form_type
  @form_type || :overlay
end

#rule_form(success_view, rule_context, form_type = :overlay) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'tmpsets/set/mod022-rules/rule/rule_form.rb', line 33

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

#rule_form_argsObject



56
57
58
# File 'tmpsets/set/mod022-rules/rule/rule_form.rb', line 56

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

#validate_form_type(form_type) ⇒ Object



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

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