Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove toolbar helper #1909

Merged
merged 2 commits into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions app/helpers/alchemy/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,50 +272,6 @@ def toolbar_button(options = {})
end
end

# Renders the toolbar shown on top of the records.
#
# == Example
#
# <% label_title = Alchemy.t("Create #{resource_name}", default: Alchemy.t('Create')) %>
# <% toolbar(
# buttons: [
# {
# icon: :plus,
# label: label_title,
# url: new_resource_path,
# title: label_title,
# hotkey: 'alt+n',
# dialog_options: {
# title: label_title,
# size: "430x400"
# },
# if_permitted_to: [:create, resource_model]
# }
# ]
# ) %>
#
# @option options [Array] :buttons ([])
# Pass an Array with button options. They will be passed to {#toolbar_button} helper.
# @option options [Boolean] :search (true)
# Show searchfield.
#
def toolbar(options = {})
defaults = {
buttons: [],
search: true,
}
options = defaults.merge(options)
content_for(:toolbar) do
content = <<-CONTENT.strip_heredoc
#{options[:buttons].map { |button_options| toolbar_button(button_options) }.join}
#{render("alchemy/admin/partials/search_form", url: options[:search_url]) if options[:search]}
CONTENT
content.html_safe
end
end

deprecate toolbar: "Please use `content_for(:toolbar)` instead", deprecator: Alchemy::Deprecation

# (internal) Used by upload form
def new_asset_path_with_session_information(asset_type)
session_key = Rails.application.config.session_options[:key]
Expand Down
29 changes: 13 additions & 16 deletions app/views/alchemy/admin/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<%= toolbar(
buttons: [
{
icon: 'info-circle',
label: Alchemy.t(:info),
url: alchemy.dashboard_info_path,
<%= content_for :toolbar do %>
<%= toolbar_button(
icon: 'info-circle',
label: Alchemy.t(:info),
url: alchemy.dashboard_info_path,
title: Alchemy.t(:info),
dialog_options: {
title: Alchemy.t(:info),
dialog_options: {
title: Alchemy.t(:info),
size: "420x435"
},
if_permitted_to: [:info, :alchemy_admin_dashboard],
hotkey: 'alt+i'
}
],
search: false
) %>
size: "420x435"
},
if_permitted_to: [:info, :alchemy_admin_dashboard],
hotkey: 'alt+i'
) %>
<% end %>

<div id="dashboard">
<h1>
Expand Down
29 changes: 14 additions & 15 deletions app/views/alchemy/admin/tags/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<%= toolbar(
buttons: [
{
icon: :plus,
label: Alchemy.t('New Tag'),
url: alchemy.new_admin_tag_path,
<% content_for :toolbar do %>
<%= toolbar_button(
icon: :plus,
label: Alchemy.t('New Tag'),
url: alchemy.new_admin_tag_path,
title: Alchemy.t('New Tag'),
hotkey: 'alt+n',
dialog_options: {
title: Alchemy.t('New Tag'),
hotkey: 'alt+n',
dialog_options: {
title: Alchemy.t('New Tag'),
size: '310x180'
},
if_permitted_to: [:create, Alchemy::Tag]
}
]
) %>
size: '310x180'
},
if_permitted_to: [:create, Alchemy::Tag]
) %>
<%= render 'alchemy/admin/partials/search_form' %>
<% end %>

<div id="archive_all" class="resources-table-wrapper">
<%= render 'alchemy/admin/resources/table_header' %>
Expand Down
24 changes: 11 additions & 13 deletions app/views/alchemy/base/500.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<%= toolbar(
buttons: [
{
icon: 'angle-double-left',
url: request.referer || alchemy.admin_dashboard_path,
label: Alchemy.t(:back),
title: Alchemy.t(:back),
hotkey: 'alt+z',
dialog: false,
skip_permission_check: true
}
], search: false
) %>
<%= content_for :toolbar do %>
<%= toolbar_button(
icon: 'angle-double-left',
url: request.referer || alchemy.admin_dashboard_path,
label: Alchemy.t(:back),
title: Alchemy.t(:back),
hotkey: 'alt+z',
dialog: false,
skip_permission_check: true
) %>
<% end %>

<% content_for(:alchemy_body_class) { 'error' } %>

Expand Down