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

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod023-edit/all/form_buttons.rb

Instance Method Summary collapse

Instance Method Details

#delete_button(opts = {}) ⇒ Object



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

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

#delete_button_opts(opts = {}) ⇒ Object



47
48
49
50
51
52
53
# File 'tmpsets/set/mod023-edit/all/form_buttons.rb', line 47

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, success: delete_success(opts) }
  opts[:remote] = true
  opts
end

#delete_confirm(opts) ⇒ Object



55
56
57
# File 'tmpsets/set/mod023-edit/all/form_buttons.rb', line 55

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

#delete_success(opts) ⇒ Object



59
60
61
# File 'tmpsets/set/mod023-edit/all/form_buttons.rb', line 59

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

#edit_cancel_buttonObject



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

def edit_cancel_button
  modal_close_button "Cancel", situation: "secondary", class: "btn-sm"
end

#standard_cancel_button(args = {}) ⇒ Object



34
35
36
37
# File 'tmpsets/set/mod023-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 'tmpsets/set/mod023-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-#{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 'tmpsets/set/mod023-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"
  opts[:text] ||= "Save"
  opts["data-cy"] = "save"
  submit_button opts
end

#standard_submit_buttonObject



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

def standard_submit_button
  output [standard_save_button, standard_save_and_close_button]
end