Module: Card::Set::All::FormButtons::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb,
card/tmpsets/set/mod011-card-mod-edit/all/form_buttons.rb

Instance Method Summary collapse

Instance Method Details

#delete_button(opts = {}) ⇒ Object



51
52
53
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 51

def delete_button opts={}
  link_to "Delete", delete_button_opts(opts)
end

#delete_button_opts(opts = {}) ⇒ Object



55
56
57
58
59
60
61
62
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 55

def delete_button_opts opts={}
  add_class opts,  "slotter btn btn-outline-danger ml-auto btn-sm"
  opts["data-confirm"] = delete_confirm opts
  opts[:path] = { action: :delete }
  opts[:path][:success] = delete_success(opts) unless opts.delete(:no_success)
  opts[:remote] = true
  opts
end

#delete_confirm(opts) ⇒ Object



64
65
66
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 64

def delete_confirm opts
  opts.delete(:confirm) || "Are you sure you want to delete #{safe_name}?"
end

#delete_success(opts) ⇒ Object



68
69
70
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 68

def delete_success opts
  opts.delete(:success) || (main? ? "REDIRECT: *previous" : { view: :just_deleted })
end

#edit_cancel_buttonObject



43
44
45
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 43

def edit_cancel_button
  modal_cancel_button
end


39
40
41
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 39

def modal_cancel_button
  modal_close_button "Cancel", situation: "secondary", class: "btn-sm cancel-button"
end

#new_cancel_buttonObject



47
48
49
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 47

def new_cancel_button
  voo.show?(:cancel_button) && modal_cancel_button
end

#standard_cancel_button(args = {}) ⇒ Object



34
35
36
37
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 34

def standard_cancel_button args={}
  args.reverse_merge! class: "cancel-button ml-4", href: path, "data-cy": "cancel"
  cancel_button args
end

#standard_save_and_close_button(opts = {}) ⇒ Object

Parameters:

  • opts (Hash) (defaults to: {})
  • close (Hash)

    a customizable set of options



24
25
26
27
28
29
30
31
32
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 24

def standard_save_and_close_button opts={}
  close = opts.delete(:close) || :modal
  text = opts[:text] || "Save and Close"
  add_class opts, "submit-button btn-sm mr-3 _close-on-success"
  add_class opts, "_update-origin" unless opts[:no_origin_update]
  opts.reverse_merge! text: text, "data-cy": "submit-#{close}"

  submit_button opts
end

#standard_save_button(opts = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 13

def standard_save_button opts={}
  return if voo&.hide?(:save_button)
  add_class opts, "submit-button btn-sm mr-3 _update-history-pills"
  opts[:text] ||= "Save"
  opts["data-cy"] = "save"
  submit_button opts
end

#standard_submit_buttonObject



9
10
11
# File 'card/tmpsets/set/mod012-card-mod-edit/all/form_buttons.rb', line 9

def standard_submit_button
  output [standard_save_button, standard_save_and_close_button]
end