Class: Faalis::Dashboard::DSL::Index
- Defined in:
- lib/faalis/dashboard/dsl/index.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#tool_buttons ⇒ Object
readonly
Returns the value of attribute tool_buttons.
Attributes inherited from Base
#action_buttons, #default_scope, #fields, #model
Instance Method Summary collapse
-
#attributes(*fields_name, **options, &block) ⇒ Object
(also: #table_fields)
Allow user to specify an array of model attributes to be used in respected section.
-
#tool_button(**options, &block) ⇒ Object
Define a new tool on the ‘tool` place of the index section options: Is a hash which contains the tool button properties.
Methods inherited from Base
#action_button, #initialize, #scope
Constructor Details
This class inherits a constructor from Faalis::Dashboard::DSL::Base
Instance Attribute Details
#tool_buttons ⇒ Object (readonly)
Returns the value of attribute tool_buttons.
5 6 7 |
# File 'lib/faalis/dashboard/dsl/index.rb', line 5 def @tool_buttons end |
Instance Method Details
#attributes(*fields_name, **options, &block) ⇒ Object Also known as: table_fields
Allow user to specify an array of model attributes to be used in respected section. For example attributes to show as header columns in index section
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/faalis/dashboard/dsl/index.rb', line 10 def attributes(*fields_name, **, &block) if .include? :except @fields = resolve_model_reflections.reject do |field| [:except].include? field.to_sym end elsif .include? :append @fields += [:append] else # set new value for fields @fields = fields_name.map(&:to_s) unless fields_name.empty? end @fields.concat(block.call.map(&:to_s)) if block_given? end |
#tool_button(**options, &block) ⇒ Object
Define a new tool on the ‘tool` place of the index section options: Is a hash which contains the tool button properties.
‘name`: name of the button. used as identifier `class`: classes of the button. `icon_class`: font awesome icon to use in button. `remote`: whether
You have to provide a block for this method which returns a string to be used as the href for the link
35 36 37 38 39 40 41 |
# File 'lib/faalis/dashboard/dsl/index.rb', line 35 def (**, &block) fail 'You have to provide a block for `tool_button`' if !block_given? [:block] = block @tool_buttons ||= {} @tool_buttons[[:name]] = end |