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

Version Path
express_admin-2.0.0.b app/components/express_admin/command_button_list.rb
express_admin-2.0.0.a app/components/express_admin/command_button_list.rb
express_admin-1.8.1 app/components/express_admin/command_button_list.rb
express_admin-1.8.0 app/components/express_admin/command_button_list.rb
express_admin-1.7.32 app/components/express_admin/command_button_list.rb
express_admin-1.7.31 app/components/express_admin/command_button_list.rb
express_admin-1.7.30 app/components/express_admin/command_button_list.rb
express_admin-1.7.29 app/components/express_admin/command_button_list.rb
express_admin-1.7.28 app/components/express_admin/command_button_list.rb
express_admin-1.7.27 app/components/express_admin/command_button_list.rb
express_admin-1.7.26 app/components/express_admin/command_button_list.rb
express_admin-1.7.25 app/components/express_admin/command_button_list.rb
express_admin-1.7.24 app/components/express_admin/command_button_list.rb
express_admin-1.7.23 app/components/express_admin/command_button_list.rb
express_admin-1.7.22 app/components/express_admin/command_button_list.rb