Module: Effective::EffectiveDatatable::Dsl
- Included in:
- Datatable
- Defined in:
- app/models/effective/effective_datatable/dsl.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #actions_column(options = {}, proc = nil, &block) ⇒ Object
- #array_column(name, options = {}, proc = nil, &block) ⇒ Object
- #default_entries(entries) ⇒ Object
-
#default_order(name, direction = :asc) ⇒ Object
Instance Methods inside the datatable do ..
- #table_column(name, options = {}, proc = nil, &block) ⇒ Object
Instance Method Details
#actions_column(options = {}, proc = nil, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/effective/effective_datatable/dsl.rb', line 38 def actions_column( = {}, proc = nil, &block) show = .fetch(:show, (EffectiveDatatables.actions_column[:show] rescue false)) edit = .fetch(:edit, (EffectiveDatatables.actions_column[:edit] rescue false)) destroy = .fetch(:destroy, (EffectiveDatatables.actions_column[:destroy] rescue false)) unarchive = .fetch(:unarchive, (EffectiveDatatables.actions_column[:unarchive] rescue false)) name = .fetch(:name, 'actions') opts = { sortable: false, filter: false, responsivePriority: 0, partial_local: :resource, partial_locals: { show_action: show, edit_action: edit, destroy_action: destroy, unarchive_action: unarchive } }.merge() opts[:partial] ||= '/effective/datatables/actions_column' unless (block_given? || proc.present?) table_column(name, opts, proc, &block) end |
#array_column(name, options = {}, proc = nil, &block) ⇒ Object
34 35 36 |
# File 'app/models/effective/effective_datatable/dsl.rb', line 34 def array_column(name, = {}, proc = nil, &block) table_column(name, .merge!(array_column: true), proc, &block) end |
#default_entries(entries) ⇒ Object
18 19 20 |
# File 'app/models/effective/effective_datatable/dsl.rb', line 18 def default_entries(entries) @default_entries = entries end |
#default_order(name, direction = :asc) ⇒ Object
Instance Methods inside the datatable do .. end block
14 15 16 |
# File 'app/models/effective/effective_datatable/dsl.rb', line 14 def default_order(name, direction = :asc) @default_order = {name => direction} end |
#table_column(name, options = {}, proc = nil, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/effective/effective_datatable/dsl.rb', line 22 def table_column(name, = {}, proc = nil, &block) if block_given? raise "You cannot use partial: ... with the block syntax" if [:partial] raise "You cannot use proc: ... with the block syntax" if [:proc] [:block] = block end raise "You cannot use both partial: ... and proc: ..." if [:partial] && [:proc] self.class.send(:attr_accessor, name) (@table_columns ||= HashWithIndifferentAccess.new())[name] = end |