Class: Spree::Admin::Table::BulkAction

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model, Visibility
Defined in:
app/models/spree/admin/table/bulk_action.rb

Constant Summary collapse

METHODS =
%i[get post put patch delete].freeze

Instance Method Summary collapse

Methods included from Visibility

#visible?

Constructor Details

#initialize(attributes = {}) ⇒ BulkAction

Returns a new instance of BulkAction.



31
32
33
34
35
36
37
# File 'app/models/spree/admin/table/bulk_action.rb', line 31

def initialize(attributes = {})
  # Handle :if as alias for :condition
  attributes[:condition] = attributes.delete(:if) if attributes.key?(:if)
  super
  self.key = key.to_sym if key.is_a?(String)
  self.method = self.method.to_sym if self.method.is_a?(String)
end

Instance Method Details

#deep_cloneBulkAction

Deep clone the action

Returns:



68
69
70
# File 'app/models/spree/admin/table/bulk_action.rb', line 68

def deep_clone
  self.class.new(**attributes.symbolize_keys.merge(condition: condition))
end

#inspectObject



72
73
74
# File 'app/models/spree/admin/table/bulk_action.rb', line 72

def inspect
  "#<Spree::Admin::Table::BulkAction key=#{key}>"
end

#resolve_bodyString

Resolve body for modal dialog (handles i18n keys)

Returns:

  • (String)


55
56
57
# File 'app/models/spree/admin/table/bulk_action.rb', line 55

def resolve_body
  resolve_i18n_attribute(body, "#{key}.body")
end

#resolve_button_textString

Resolve button text for modal dialog (handles i18n keys) Falls back to ‘Confirm’ if not set

Returns:

  • (String)


62
63
64
# File 'app/models/spree/admin/table/bulk_action.rb', line 62

def resolve_button_text
  resolve_i18n_attribute(button_text, "#{key}.button") || Spree.t(:confirm)
end

#resolve_labelString

Resolve label (handles i18n keys)

Returns:

  • (String)


41
42
43
# File 'app/models/spree/admin/table/bulk_action.rb', line 41

def resolve_label
  resolve_i18n_attribute(label || key, key.to_s) || key.to_s.humanize
end

#resolve_titleString

Resolve title for modal dialog (handles i18n keys) Falls back to label if title is not set

Returns:

  • (String)


48
49
50
51
# File 'app/models/spree/admin/table/bulk_action.rb', line 48

def resolve_title
  resolve_i18n_attribute(title, "#{key}.title") ||
    resolve_i18n_attribute(label, key.to_s)
end