Sha256: 29ca1dac00a5d5cf3d11f27fa4eae654ec5a3816f33aa7589f4a84d55bf0d7b7

Contents?: true

Size: 1.98 KB

Versions: 9

Compression:

Stored size: 1.98 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (FormButtons)
#
module FormButtons;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/edit/set/all/form_buttons.rb"; end
module HtmlFormat; parent.send :register_set_format, Card::Format::HtmlFormat, self; extend Card::Set::AbstractFormat
  def standard_submit_button
    output [standard_save_button, standard_save_and_close_button]
  end

  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

  # @param opts [Hash]
  # @option close [:modal, :overlay]
  #
  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

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

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

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

  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

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

  def delete_success opts
    opts.delete(:success) || (main? ? "REDIRECT: *previous" : { view: :just_deleted })
  end
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/edit/set/all/form_buttons.rb ~~

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-1.99.4 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.99.3 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.99.2 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.99.1 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.99.0 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.98.3 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.98.2 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.98.1 tmpsets/set/mod023-edit/all/form_buttons.rb
card-1.98.0 tmpsets/set/mod023-edit/all/form_buttons.rb