Before, users needed to navigate to the list of groups in order to add, edit or delete a group. Also, they need to navigate to the list of groups first, and then to the list of headings for that group in order to add, edit or delete a heading. Now, it's possible to do all these actions for any group or heading from the participatory budget view to bring simplicity and to reduce the number of clicks from a user perspective. Co-Authored-By: Javi Martín <javim@elretirao.net>
46 lines
848 B
Ruby
46 lines
848 B
Ruby
class Admin::TableActionsComponent < ApplicationComponent
|
|
attr_reader :record, :options
|
|
|
|
def initialize(record, **options)
|
|
@record = record
|
|
@options = options
|
|
end
|
|
|
|
def action(action_name, **args)
|
|
render Admin::ActionComponent.new(action_name, record, "aria-label": true, **args)
|
|
end
|
|
|
|
private
|
|
|
|
def actions
|
|
options[:actions] || [:edit, :destroy]
|
|
end
|
|
|
|
def edit_text
|
|
options[:edit_text]
|
|
end
|
|
|
|
def edit_path
|
|
options[:edit_path]
|
|
end
|
|
|
|
def edit_options
|
|
options[:edit_options] || {}
|
|
end
|
|
|
|
def destroy_text
|
|
options[:destroy_text]
|
|
end
|
|
|
|
def destroy_path
|
|
options[:destroy_path]
|
|
end
|
|
|
|
def destroy_options
|
|
{
|
|
method: :delete,
|
|
confirm: options[:destroy_confirmation] || true
|
|
}.merge(options[:destroy_options] || {})
|
|
end
|
|
end
|