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

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb

Instance Method Summary collapse

Instance Method Details

#delete_button(opts = {}) ⇒ Object



60
61
62
63
64
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 60

def delete_button opts={}
  return unless card.real?

  link_to "Delete", delete_button_opts(opts)
end

#delete_button_opts(opts = {}) ⇒ Object



66
67
68
69
70
71
72
73
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 66

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

#delete_confirm(opts) ⇒ Object



75
76
77
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 75

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

#delete_success(opts) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 79

def delete_success opts
  if opts[:success]
    opts.delete :success
  elsif main?
    { redirect: true, mark: "*previous" }
  else
    { view: :just_deleted }
  end
end

#edit_cancel_buttonObject



52
53
54
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 52

def edit_cancel_button
  modal_cancel_button
end


48
49
50
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 48

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

#new_cancel_buttonObject



56
57
58
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 56

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

#standard_cancel_button(args = {}) ⇒ Object



43
44
45
46
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 43

def standard_cancel_button args={}
  args.reverse_merge! class: "cancel-button ms-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



33
34
35
36
37
38
39
40
41
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 33

def standard_save_and_close_button opts={}
  close = opts.delete(:close) || :modal
  text = opts[:text] || "Save and Close"
  add_class opts, "submit-button me-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 = {}) ⇒ String

Generates a standard save button with optional parameters.

Examples:

standard_save_button(text: "Update")

Parameters:

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

    The options for the save button.

Options Hash (opts):

  • :text (String) — default: "Save"

    The text displayed on the button.

Returns:

  • (String)

    The HTML code for the standard save button.



22
23
24
25
26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 22

def standard_save_button opts={}
  return if voo&.hide?(:save_button)

  add_class opts, "submit-button me-3 _update-history-pills"
  opts[:text] ||= "Save"
  opts["data-cy"] = "save"
  submit_button opts
end

#standard_submit_buttonObject



9
10
11
# File 'platypus/tmp/set/gem-defaults/mod011-edit/all/form_buttons.rb', line 9

def standard_submit_button
  output [standard_save_button, standard_save_and_close_button]
end