Class: Alchemy::Admin::ToolbarButton
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Alchemy::Admin::ToolbarButton
- Defined in:
- app/components/alchemy/admin/toolbar_button.rb
Overview
Renders a toolbar button for the Alchemy toolbar
Example
<%= render Alchemy::Admin::ToolbarButton.new(
url: new_resource_path,
icon: :plus,
label: 'Create Resource',
hotkey: 'alt+n',
dialog_options: {
title: 'Create Resource',
size: "430x400"
},
if_permitted_to: [:create, resource_model]
) %>
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#dialog ⇒ Object
readonly
Returns the value of attribute dialog.
-
#dialog_options ⇒ Object
readonly
Returns the value of attribute dialog_options.
-
#hotkey ⇒ Object
readonly
Returns the value of attribute hotkey.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#icon_style ⇒ Object
readonly
Returns the value of attribute icon_style.
-
#if_permitted_to ⇒ Object
readonly
Returns the value of attribute if_permitted_to.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#link_options ⇒ Object
readonly
Returns the value of attribute link_options.
-
#skip_permission_check ⇒ Object
readonly
Returns the value of attribute skip_permission_check.
-
#tooltip_placement ⇒ Object
readonly
Returns the value of attribute tooltip_placement.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url:, icon:, label:, hotkey: nil, title: nil, dialog: true, dialog_options: {}, skip_permission_check: false, if_permitted_to: [], active: false, link_options: {}, icon_style: "line", tooltip_placement: "top-start") ⇒ ToolbarButton
constructor
A new instance of ToolbarButton.
- #render? ⇒ Boolean
Constructor Details
#initialize(url:, icon:, label:, hotkey: nil, title: nil, dialog: true, dialog_options: {}, skip_permission_check: false, if_permitted_to: [], active: false, link_options: {}, icon_style: "line", tooltip_placement: "top-start") ⇒ ToolbarButton
Returns a new instance of ToolbarButton.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 63 def initialize( url:, icon:, label:, hotkey: nil, title: nil, dialog: true, dialog_options: {}, skip_permission_check: false, if_permitted_to: [], active: false, link_options: {}, icon_style: "line", tooltip_placement: "top-start" ) @url = url @icon = icon @label = label @hotkey = hotkey @dialog = dialog @dialog_options = @skip_permission_check = @if_permitted_to = if_permitted_to @active = active @link_options = @icon_style = icon_style @tooltip_placement = tooltip_placement end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def active @active end |
#dialog ⇒ Object (readonly)
Returns the value of attribute dialog.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def dialog @dialog end |
#dialog_options ⇒ Object (readonly)
Returns the value of attribute dialog_options.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def @dialog_options end |
#hotkey ⇒ Object (readonly)
Returns the value of attribute hotkey.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def hotkey @hotkey end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def icon @icon end |
#icon_style ⇒ Object (readonly)
Returns the value of attribute icon_style.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def icon_style @icon_style end |
#if_permitted_to ⇒ Object (readonly)
Returns the value of attribute if_permitted_to.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def if_permitted_to @if_permitted_to end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def label @label end |
#link_options ⇒ Object (readonly)
Returns the value of attribute link_options.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def @link_options end |
#skip_permission_check ⇒ Object (readonly)
Returns the value of attribute skip_permission_check.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def @skip_permission_check end |
#tooltip_placement ⇒ Object (readonly)
Returns the value of attribute tooltip_placement.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def tooltip_placement @tooltip_placement end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
50 51 52 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 50 def url @url end |
Instance Method Details
#render? ⇒ Boolean
92 93 94 |
# File 'app/components/alchemy/admin/toolbar_button.rb', line 92 def render? || can?(*) end |