From 144386d140df00c415676ddf2ae52d9c5c027ecd Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sat, 25 Jul 2020 23:54:02 +0200 Subject: [PATCH 1/2] Remove usage of deprecated toolbar helper --- .../alchemy/admin/dashboard/index.html.erb | 29 +++++++++---------- app/views/alchemy/admin/tags/index.html.erb | 29 +++++++++---------- app/views/alchemy/base/500.html.erb | 24 +++++++-------- 3 files changed, 38 insertions(+), 44 deletions(-) diff --git a/app/views/alchemy/admin/dashboard/index.html.erb b/app/views/alchemy/admin/dashboard/index.html.erb index b2a4be1d94..7fdca1e35b 100644 --- a/app/views/alchemy/admin/dashboard/index.html.erb +++ b/app/views/alchemy/admin/dashboard/index.html.erb @@ -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 %>

diff --git a/app/views/alchemy/admin/tags/index.html.erb b/app/views/alchemy/admin/tags/index.html.erb index 44dc1d8d7b..b7542c5d2e 100644 --- a/app/views/alchemy/admin/tags/index.html.erb +++ b/app/views/alchemy/admin/tags/index.html.erb @@ -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 %>
<%= render 'alchemy/admin/resources/table_header' %> diff --git a/app/views/alchemy/base/500.html.erb b/app/views/alchemy/base/500.html.erb index 86a91c7d78..74bdcc89c4 100644 --- a/app/views/alchemy/base/500.html.erb +++ b/app/views/alchemy/base/500.html.erb @@ -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' } %> From 213b7088c570a6d7052cbd8f5ea8c45f7c5389dc Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sat, 25 Jul 2020 23:56:16 +0200 Subject: [PATCH 2/2] Remove deprecated toolbar helper Use `content_for :toolbar` and the `toolbar_button` helper instead. --- app/helpers/alchemy/admin/base_helper.rb | 44 ------------------------ 1 file changed, 44 deletions(-) diff --git a/app/helpers/alchemy/admin/base_helper.rb b/app/helpers/alchemy/admin/base_helper.rb index 8bf34e5518..496f68f0c3 100644 --- a/app/helpers/alchemy/admin/base_helper.rb +++ b/app/helpers/alchemy/admin/base_helper.rb @@ -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]