Sha256: 6ba81f77e29fc37d64afb49ea64f6a032f25f64734a963861fe16476c3d209e8

Contents?: true

Size: 772 Bytes

Versions: 4

Compression:

Stored size: 772 Bytes

Contents

module ExpressAdmin
  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, disabled: !available?(command))
        }
      end
    }

    def resource_name
      config[:resource_name]
    end

    def available?(command)
      resource.available_commands.include?(command)
    end

    def commands
      resource.commands
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
express_admin-1.6.3 app/components/express_admin/command_button_list.rb
express_admin-1.6.2 app/components/express_admin/command_button_list.rb
express_admin-1.6.1 app/components/express_admin/command_button_list.rb
express_admin-1.6.0 app/components/express_admin/command_button_list.rb