Sha256: 1d462af62c5e068c76b048df46a0cfb46f31b07658c50b9ba8ddf76555a34532
Contents?: true
Size: 1.14 KB
Versions: 15
Compression:
Stored size: 1.14 KB
Contents
module ExpressAdmin module Components module Navigation class CommandButtonList < ExpressTemplates::Components::Configurable include ExpressTemplates::Components::Capabilities::Resourceful tag :ul has_argument :id, "The name of the resource for this command. Eg. 'person' for like_person_path()", as: :resource_name, type: :symbol # has_option :exclude, "Exclude some buttons" # has_option :only, "only some buttons" contains -> { commands.each do |command| li { command_button(command[:name], command_button_options(command)) } end } def resource_name config[:resource_name] end def available?(command) resource.available_commands.include?(command[:name]) end def commands resource.commands end private def command_button_options(command) options = {} options = { confirm: command[:confirm] } if command[:confirm] options.merge({ disabled: !available?(command) }) end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems