Class: CmAdmin::Models::Action
- Inherits:
-
Object
- Object
- CmAdmin::Models::Action
- Includes:
- CmAdmin::Models::Actions::Blocks
- Defined in:
- lib/cm_admin/models/action.rb
Direct Known Subclasses
Constant Summary collapse
- VALID_SORT_DIRECTION =
Set[:asc, :desc].freeze
Instance Attribute Summary collapse
-
#action_type ⇒ Object
Returns the value of attribute action_type.
-
#child_records ⇒ Object
Returns the value of attribute child_records.
-
#code_block ⇒ Object
Returns the value of attribute code_block.
-
#display_if ⇒ Object
Returns the value of attribute display_if.
-
#display_type ⇒ Object
Returns the value of attribute display_type.
-
#icon_name ⇒ Object
Returns the value of attribute icon_name.
-
#is_nested_field ⇒ Object
Returns the value of attribute is_nested_field.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#layout_type ⇒ Object
Returns the value of attribute layout_type.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nested_table_name ⇒ Object
Returns the value of attribute nested_table_name.
-
#page_description ⇒ Object
Returns the value of attribute page_description.
-
#page_title ⇒ Object
Returns the value of attribute page_title.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#partial ⇒ Object
Returns the value of attribute partial.
-
#path ⇒ Object
Returns the value of attribute path.
-
#redirection_url ⇒ Object
Returns the value of attribute redirection_url.
-
#route_type ⇒ Object
Returns the value of attribute route_type.
-
#sort_column ⇒ Object
Returns the value of attribute sort_column.
-
#sort_direction ⇒ Object
Returns the value of attribute sort_direction.
-
#verb ⇒ Object
Returns the value of attribute verb.
Class Method Summary collapse
Instance Method Summary collapse
- #controller_action_name ⇒ Object
-
#initialize(attributes = {}, &block) ⇒ Action
constructor
A new instance of Action.
- #set_default_values ⇒ Object
- #set_values(page_title, page_description, partial) ⇒ Object
Methods included from CmAdmin::Models::Actions::Blocks
#set_layout, #set_partial, #set_title
Constructor Details
#initialize(attributes = {}, &block) ⇒ Action
Returns a new instance of Action.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cm_admin/models/action.rb', line 13 def initialize(attributes = {}, &block) if attributes[:layout_type].present? && attributes[:layout].nil? && attributes[:partial].nil? case attributes[:layout_type] when 'cm_association_index' attributes[:layout] = '/cm_admin/main/associated_index' attributes[:partial] = '/cm_admin/main/associated_table' when 'cm_association_show' attributes[:layout] = '/cm_admin/main/associated_show' end end set_default_values attributes.each do |key, value| self.send("#{key.to_s}=", value) end self.send("code_block=", block) if block_given? end |
Instance Attribute Details
#action_type ⇒ Object
Returns the value of attribute action_type.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def action_type @action_type end |
#child_records ⇒ Object
Returns the value of attribute child_records.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def child_records @child_records end |
#code_block ⇒ Object
Returns the value of attribute code_block.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def code_block @code_block end |
#display_if ⇒ Object
Returns the value of attribute display_if.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def display_if @display_if end |
#display_type ⇒ Object
Returns the value of attribute display_type.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def display_type @display_type end |
#icon_name ⇒ Object
Returns the value of attribute icon_name.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def icon_name @icon_name end |
#is_nested_field ⇒ Object
Returns the value of attribute is_nested_field.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def is_nested_field @is_nested_field end |
#layout ⇒ Object
Returns the value of attribute layout.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def layout @layout end |
#layout_type ⇒ Object
Returns the value of attribute layout_type.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def layout_type @layout_type end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def name @name end |
#nested_table_name ⇒ Object
Returns the value of attribute nested_table_name.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def nested_table_name @nested_table_name end |
#page_description ⇒ Object
Returns the value of attribute page_description.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def page_description @page_description end |
#page_title ⇒ Object
Returns the value of attribute page_title.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def page_title @page_title end |
#parent ⇒ Object
Returns the value of attribute parent.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def parent @parent end |
#partial ⇒ Object
Returns the value of attribute partial.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def partial @partial end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def path @path end |
#redirection_url ⇒ Object
Returns the value of attribute redirection_url.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def redirection_url @redirection_url end |
#route_type ⇒ Object
Returns the value of attribute route_type.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def route_type @route_type end |
#sort_column ⇒ Object
Returns the value of attribute sort_column.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def sort_column @sort_column end |
#sort_direction ⇒ Object
Returns the value of attribute sort_direction.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def sort_direction @sort_direction end |
#verb ⇒ Object
Returns the value of attribute verb.
7 8 9 |
# File 'lib/cm_admin/models/action.rb', line 7 def verb @verb end |
Class Method Details
.find_by(model, search_hash) ⇒ Object
57 58 59 |
# File 'lib/cm_admin/models/action.rb', line 57 def find_by(model, search_hash) model.available_actions.find { |i| i.name == search_hash[:name] } end |
Instance Method Details
#controller_action_name ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/cm_admin/models/action.rb', line 46 def controller_action_name if self.action_type == :custom 'cm_custom_method' elsif self.parent 'cm_' + self.parent else 'cm_' + name end end |
#set_default_values ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/cm_admin/models/action.rb', line 30 def set_default_values self.is_nested_field = false self.display_if = lambda { |arg| return true } self.display_type = :button self.action_type = :default self.sort_column = :created_at self.sort_direction = :desc self.icon_name = 'fa fa-th-large' end |
#set_values(page_title, page_description, partial) ⇒ Object
40 41 42 43 44 |
# File 'lib/cm_admin/models/action.rb', line 40 def set_values(page_title, page_description, partial) self.page_title = page_title self.page_description = page_description self.partial = partial end |