Class: Admin::Base::Resource::ActionsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/admin/base/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActionsConfig

Returns a new instance of ActionsConfig.



490
491
492
493
494
# File 'lib/admin/base/resource.rb', line 490

def initialize
  @member_actions = []
  @collection_actions = []
  @bulk_actions = []
end

Instance Attribute Details

#bulk_actionsObject (readonly)

Returns the value of attribute bulk_actions.



488
489
490
# File 'lib/admin/base/resource.rb', line 488

def bulk_actions
  @bulk_actions
end

#collection_actionsObject (readonly)

Returns the value of attribute collection_actions.



488
489
490
# File 'lib/admin/base/resource.rb', line 488

def collection_actions
  @collection_actions
end

#member_actionsObject (readonly)

Returns the value of attribute member_actions.



488
489
490
# File 'lib/admin/base/resource.rb', line 488

def member_actions
  @member_actions
end

Instance Method Details

#action(name, **options) ⇒ Object



496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/admin/base/resource.rb', line 496

def action(name, **options)
  @member_actions << ActionDefinition.new(
    name: name,
    method: options[:method] || :post,
    confirm: options[:confirm],
    type: options[:type] || :button,
    label: options[:label] || name.to_s.humanize,
    icon: options[:icon],
    color: options[:color],
    if_condition: options[:if],
    unless_condition: options[:unless]
  )
end

#bulk_action(name, **options) ⇒ Object



522
523
524
525
526
527
528
529
530
531
532
# File 'lib/admin/base/resource.rb', line 522

def bulk_action(name, **options)
  @bulk_actions << ActionDefinition.new(
    name: name,
    method: options[:method] || :post,
    confirm: options[:confirm],
    type: options[:type] || :button,
    label: options[:label] || name.to_s.humanize,
    icon: options[:icon],
    color: options[:color]
  )
end

#collection_action(name, **options) ⇒ Object



510
511
512
513
514
515
516
517
518
519
520
# File 'lib/admin/base/resource.rb', line 510

def collection_action(name, **options)
  @collection_actions << ActionDefinition.new(
    name: name,
    method: options[:method] || :post,
    confirm: options[:confirm],
    type: options[:type] || :button,
    label: options[:label] || name.to_s.humanize,
    icon: options[:icon],
    color: options[:color]
  )
end