Sha256: 51f3f2c5a0f696a6817aa694ae918c693a602ba4aa57847b2a0c454b3de481c8
Contents?: true
Size: 1.54 KB
Versions: 15
Compression:
Stored size: 1.54 KB
Contents
module ExpressAdmin module Components module Navigation class CommandButton < ExpressTemplates::Components::Configurable include ExpressTemplates::Components::Capabilities::Resourceful has_argument :id, "The command name. Invoked as an action on the resource.", as: :command, type: :symbol has_option :disabled, "Disables the button", type: :boolean has_option :confirm, "Prompt with the question specified." has_option :resource_name, "The name of the resource for this command. Eg. 'person' for like_person_path()" before_build -> { config[:command] = config[:command].debang add_class(config[:command]) } contains -> { button_to config[:command].to_s.titleize, action, button_to_options } def resource_name config[:resource_name] || parent_command_button_list.resource_name end def button_to_options options = {} options = { data: { confirm: config[:confirm] } } if config[:confirm] options.merge({ disabled: config[:disabled] }) end def action helpers.send "#{config[:command]}_#{resource_path_helper}", resource.to_param end def parent_command_button_list @parent_button_list ||= parent until @parent_button_list.nil? || @parent_button_list.kind_of?(CommandButtonList) @parent_button_list = @parent_button_list.parent end return @parent_button_list end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems