Class: Spree::Admin::Table::BulkAction
- Inherits:
-
Object
- Object
- Spree::Admin::Table::BulkAction
- 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
-
#deep_clone ⇒ BulkAction
Deep clone the action.
-
#initialize(attributes = {}) ⇒ BulkAction
constructor
A new instance of BulkAction.
- #inspect ⇒ Object
-
#resolve_body ⇒ String
Resolve body for modal dialog (handles i18n keys).
-
#resolve_button_text ⇒ String
Resolve button text for modal dialog (handles i18n keys) Falls back to ‘Confirm’ if not set.
-
#resolve_label ⇒ String
Resolve label (handles i18n keys).
-
#resolve_title ⇒ String
Resolve title for modal dialog (handles i18n keys) Falls back to label if title is not set.
Methods included from Visibility
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_clone ⇒ BulkAction
Deep clone the action
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 |
#inspect ⇒ Object
72 73 74 |
# File 'app/models/spree/admin/table/bulk_action.rb', line 72 def inspect "#<Spree::Admin::Table::BulkAction key=#{key}>" end |
#resolve_body ⇒ String
Resolve body for modal dialog (handles i18n keys)
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_text ⇒ String
Resolve button text for modal dialog (handles i18n keys) Falls back to ‘Confirm’ if not set
62 63 64 |
# File 'app/models/spree/admin/table/bulk_action.rb', line 62 def resolve_i18n_attribute(, "#{key}.button") || Spree.t(:confirm) end |
#resolve_label ⇒ String
Resolve label (handles i18n keys)
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_title ⇒ String
Resolve title for modal dialog (handles i18n keys) Falls back to label if title is not set
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 |