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.



541
542
543
544
545
# File 'lib/admin/base/resource.rb', line 541

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

Instance Attribute Details

#bulk_actionsObject (readonly)

Returns the value of attribute bulk_actions.



539
540
541
# File 'lib/admin/base/resource.rb', line 539

def bulk_actions
  @bulk_actions
end

#collection_actionsObject (readonly)

Returns the value of attribute collection_actions.



539
540
541
# File 'lib/admin/base/resource.rb', line 539

def collection_actions
  @collection_actions
end

#member_actionsObject (readonly)

Returns the value of attribute member_actions.



539
540
541
# File 'lib/admin/base/resource.rb', line 539

def member_actions
  @member_actions
end

Instance Method Details

#action(name, **options) ⇒ Object



547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/admin/base/resource.rb', line 547

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



573
574
575
576
577
578
579
580
581
582
583
# File 'lib/admin/base/resource.rb', line 573

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



561
562
563
564
565
566
567
568
569
570
571
# File 'lib/admin/base/resource.rb', line 561

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