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.



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

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

Instance Attribute Details

#bulk_actionsObject (readonly)

Returns the value of attribute bulk_actions.



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

def bulk_actions
  @bulk_actions
end

#collection_actionsObject (readonly)

Returns the value of attribute collection_actions.



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

def collection_actions
  @collection_actions
end

#member_actionsObject (readonly)

Returns the value of attribute member_actions.



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

def member_actions
  @member_actions
end

Instance Method Details

#action(name, **options) ⇒ Object



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

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



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

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



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

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