diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d0cc22f9a..3df25cdb2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 4.1.0 (unreleased) +* Remove pleaseWait overlay from links with GET requests [#1343](https://github.com/AlchemyCMS/alchemy_cms/pull/1343) by [tvdeyen](https://github.com/tvdeyen) * Removed fixed table headers from admin resource tables [#1339](https://github.com/AlchemyCMS/alchemy_cms/pull/1339) by [tvdeyen](https://github.com/tvdeyen) * Removed Bourbon Sass library [#1339](https://github.com/AlchemyCMS/alchemy_cms/pull/1339) by [tvdeyen](https://github.com/tvdeyen) diff --git a/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee b/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee index b65e277863..0b5989d54d 100644 --- a/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +++ b/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee @@ -18,7 +18,6 @@ $.extend Alchemy, window.onbeforeunload = @pageUnload pageUnload: -> - Alchemy.pleaseWaitOverlay(false) Alchemy.t('page_dirty_notice') setElementClean: (element) -> @@ -41,10 +40,11 @@ $.extend Alchemy, $form = $("
") $form.append $(element).find("input") $form.appendTo "body" + Alchemy.pleaseWaitOverlay() $form.submit() else if $(element).is("a") callback = -> - window.location.href = element.pathname + Turbolinks.visit(element.pathname) if Alchemy.isPageDirty() Alchemy.openConfirmDialog Alchemy.t('page_dirty_notice'), title: Alchemy.t('warning') @@ -52,7 +52,6 @@ $.extend Alchemy, cancel_label: Alchemy.t('cancel') on_ok: -> window.onbeforeunload = undefined - Alchemy.pleaseWaitOverlay() callback() false else diff --git a/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee b/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee index 2da07f0d97..d171c355ab 100644 --- a/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +++ b/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee @@ -15,11 +15,9 @@ Alchemy.Initializer = -> Alchemy.Growler.fade() # Add observer for please wait overlay. - $('.please_wait, #main_navi a, .button_with_label form :submit, .locked_page a, .pagination a') - .not('*[data-alchemy-confirm], .locked_page button') - .click -> - unless Alchemy.isPageDirty() - Alchemy.pleaseWaitOverlay() + $('.please_wait, .button_with_label form :submit') + .not('*[data-alchemy-confirm]') + .click Alchemy.pleaseWaitOverlay # Hack for enabling tab focus for 's styled as button. $('a.button').attr({tabindex: 0}) @@ -28,17 +26,16 @@ Alchemy.Initializer = -> $('select#change_locale').on 'change', (e) -> url = window.location.pathname delimiter = if url.match(/\?/) then '&' else '?' - window.location.href = "#{url}#{delimiter}admin_locale=#{$(this).val()}" + Turbolinks.visit "#{url}#{delimiter}admin_locale=#{$(this).val()}" # Site select handler $('select#change_site').on 'change', (e) -> url = window.location.pathname delimiter = if url.match(/\?/) then '&' else '?' - window.location.href = "#{url}#{delimiter}site_id=#{$(this).val()}" + Turbolinks.visit "#{url}#{delimiter}site_id=#{$(this).val()}" # Submit forms of selects with `data-autosubmit="true"` $('select[data-auto-submit="true"]').on 'change', (e) -> - Alchemy.pleaseWaitOverlay() $(this.form).submit() # Attaches the image loader on all images diff --git a/app/controllers/alchemy/admin/contents_controller.rb b/app/controllers/alchemy/admin/contents_controller.rb index 4da61ca67c..295496dfda 100644 --- a/app/controllers/alchemy/admin/contents_controller.rb +++ b/app/controllers/alchemy/admin/contents_controller.rb @@ -7,11 +7,6 @@ class ContentsController < Alchemy::Admin::BaseController authorize_resource class: Alchemy::Content - def new - @element = Element.find(params[:element_id]) - @content = @element.contents.build - end - def create @element = Element.find(params[:content][:element_id]) @content = Content.create_from_scratch(@element, content_params) @@ -26,11 +21,6 @@ def create end end - def update - @content = Content.find(params[:id]) - @content.update_essence(content_params) - end - def order Content.transaction do params[:content_ids].each_with_index do |id, idx| @@ -40,13 +30,6 @@ def order @notice = Alchemy.t("Successfully saved content position") end - def destroy - @content = Content.find(params[:id]) - @content_dom_id = @content.dom_id - @notice = Alchemy.t("Successfully deleted content", content: @content.name_for_label) - @content.destroy - end - private def content_params diff --git a/app/helpers/alchemy/admin/base_helper.rb b/app/helpers/alchemy/admin/base_helper.rb index a0cecffb43..d5a6dd0de7 100644 --- a/app/helpers/alchemy/admin/base_helper.rb +++ b/app/helpers/alchemy/admin/base_helper.rb @@ -267,7 +267,7 @@ def toolbar_button(options = {}) active: false, link_options: {}, dialog_options: {}, - loading_indicator: true + loading_indicator: false }.merge(options.symbolize_keys) button = render( 'alchemy/admin/partials/toolbar_button', diff --git a/app/helpers/alchemy/admin/tags_helper.rb b/app/helpers/alchemy/admin/tags_helper.rb index 1e586fe60f..c2d8686f65 100644 --- a/app/helpers/alchemy/admin/tags_helper.rb +++ b/app/helpers/alchemy/admin/tags_helper.rb @@ -22,8 +22,7 @@ def render_tag_list(class_name) tagged_with: tags_for_filter(current: tag).presence ) ), - remote: request.xhr?, - class: 'please_wait' + remote: request.xhr? ) end end.join.html_safe diff --git a/app/views/alchemy/admin/attachments/_filter_bar.html.erb b/app/views/alchemy/admin/attachments/_filter_bar.html.erb index c26d0a42bd..d9df5ccfbf 100644 --- a/app/views/alchemy/admin/attachments/_filter_bar.html.erb +++ b/app/views/alchemy/admin/attachments/_filter_bar.html.erb @@ -20,9 +20,8 @@ if ($this.data('remote') === true) { $.get(url, {file_type: $this.val()}, null, 'script'); } else { - Alchemy.pleaseWaitOverlay(); delimiter = url.match(/\?/) ? '&' : '?'; - window.location = url + delimiter + 'file_type=' + encodeURIComponent($this.val()); + Turbolinks.visit(url + delimiter + 'file_type=' + encodeURIComponent($this.val())); } return false; }); diff --git a/app/views/alchemy/admin/attachments/_replace_button.html.erb b/app/views/alchemy/admin/attachments/_replace_button.html.erb index da60f2c2fb..9ff3696017 100644 --- a/app/views/alchemy/admin/attachments/_replace_button.html.erb +++ b/app/views/alchemy/admin/attachments/_replace_button.html.erb @@ -17,8 +17,7 @@ selector: '#replace_<%= dom_id(object) %>', file_types: '<%= file_types.join("|") %>', complete: function() { - Alchemy.pleaseWaitOverlay(); - window.location.href = '<%= redirect_url.html_safe %>'; + Turbolinks.visit('<%= redirect_url.html_safe %>'); } }; Alchemy.Uploader(options); diff --git a/app/views/alchemy/admin/attachments/_tag_list.html.erb b/app/views/alchemy/admin/attachments/_tag_list.html.erb index f711d6f496..3fd2b78744 100644 --- a/app/views/alchemy/admin/attachments/_tag_list.html.erb +++ b/app/views/alchemy/admin/attachments/_tag_list.html.erb @@ -9,7 +9,7 @@ render_icon('delete-small') + Alchemy.t('Remove tag filter'), url_for(search_filter_params.except(:tagged_with)), remote: request.xhr?, - class: 'button small with_icon please_wait' + class: 'button small with_icon' ) %> <% end %> <% end %> diff --git a/app/views/alchemy/admin/attachments/destroy.js.erb b/app/views/alchemy/admin/attachments/destroy.js.erb index 14bccc7405..6296a81d27 100644 --- a/app/views/alchemy/admin/attachments/destroy.js.erb +++ b/app/views/alchemy/admin/attachments/destroy.js.erb @@ -1 +1 @@ -window.location.href = '<%= @url %>'; +Turbolinks.visit('<%= @url %>'); diff --git a/app/views/alchemy/admin/contents/destroy.js.erb b/app/views/alchemy/admin/contents/destroy.js.erb deleted file mode 100644 index caa71ae4b2..0000000000 --- a/app/views/alchemy/admin/contents/destroy.js.erb +++ /dev/null @@ -1,4 +0,0 @@ -$('#<%= @content_dom_id %>').remove(); -Alchemy.growl('<%= j @notice %>'); -Alchemy.reloadPreview(); -Alchemy.pleaseWaitOverlay(false); diff --git a/app/views/alchemy/admin/pages/index.html.erb b/app/views/alchemy/admin/pages/index.html.erb index e06270d115..29ff5d1d6e 100644 --- a/app/views/alchemy/admin/pages/index.html.erb +++ b/app/views/alchemy/admin/pages/index.html.erb @@ -21,7 +21,7 @@ render_icon(:sort), alchemy.sort_admin_pages_path, method: :get, - class: 'icon_button please_wait', + class: 'icon_button', title: Alchemy.t('Sort pages') ) %> diff --git a/app/views/alchemy/admin/pictures/_filter_bar.html.erb b/app/views/alchemy/admin/pictures/_filter_bar.html.erb index 0ad4c73253..69bae8b56e 100644 --- a/app/views/alchemy/admin/pictures/_filter_bar.html.erb +++ b/app/views/alchemy/admin/pictures/_filter_bar.html.erb @@ -21,9 +21,8 @@ if ($this.data('remote') === true) { $.get(url, {filter: $this.val()}, null, 'script'); } else { - Alchemy.pleaseWaitOverlay(); delimiter = url.match(/\?/) ? '&' : '?'; - window.location = url + delimiter + 'filter=' + $this.val(); + Turbolinks.visit(url + delimiter + 'filter=' + $this.val()); } return false; }); diff --git a/app/views/alchemy/admin/pictures/_tag_list.html.erb b/app/views/alchemy/admin/pictures/_tag_list.html.erb index 55fdd0ec0e..03b2080119 100644 --- a/app/views/alchemy/admin/pictures/_tag_list.html.erb +++ b/app/views/alchemy/admin/pictures/_tag_list.html.erb @@ -9,7 +9,7 @@ render_icon('delete-small') + Alchemy.t('Remove tag filter'), url_for(search_filter_params.except(:tagged_with)), remote: request.xhr?, - class: 'button small with_icon please_wait' + class: 'button small with_icon' ) %> <% end %> <% end %> diff --git a/app/views/alchemy/admin/pictures/flush.js.erb b/app/views/alchemy/admin/pictures/flush.js.erb deleted file mode 100644 index 2aae5e9533..0000000000 --- a/app/views/alchemy/admin/pictures/flush.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -Alchemy.growl('<%= @notice %>'); -Alchemy.pleaseWaitOverlay(false); diff --git a/app/views/alchemy/admin/pictures/index.html.erb b/app/views/alchemy/admin/pictures/index.html.erb index b38bbf2ae4..1104f1c398 100644 --- a/app/views/alchemy/admin/pictures/index.html.erb +++ b/app/views/alchemy/admin/pictures/index.html.erb @@ -16,7 +16,7 @@ render_icon('zoom-out'), alchemy.admin_pictures_path(size: "small", q: params[:q]), title: Alchemy.t(:small_thumbnails), - class: "icon_button please_wait" + class: "icon_button" ) %>
@@ -24,7 +24,7 @@ render_icon('zoom-equal'), alchemy.admin_pictures_path(size: "medium", q: params[:q]), title: Alchemy.t(:medium_thumbnails), - class: "icon_button please_wait" + class: "icon_button" ) %>
@@ -32,7 +32,7 @@ render_icon('zoom-in'), alchemy.admin_pictures_path(size: "large", q: params[:q]), title: Alchemy.t(:big_thumbnails), - class: "icon_button please_wait" + class: "icon_button" ) %>
diff --git a/app/views/alchemy/admin/pictures/index.js.erb b/app/views/alchemy/admin/pictures/index.js.erb index ffa5e7176e..3f9bc0becc 100644 --- a/app/views/alchemy/admin/pictures/index.js.erb +++ b/app/views/alchemy/admin/pictures/index.js.erb @@ -1,3 +1,2 @@ -Alchemy.pleaseWaitOverlay(false); $('#archive_all').html('<%= j render("archive") %>'); $('#filter_bar').replaceWith('<%= j render("filter_bar") %>'); diff --git a/app/views/alchemy/admin/resources/_filter_bar.html.erb b/app/views/alchemy/admin/resources/_filter_bar.html.erb index fda3e6d02c..6bbb1e1f8e 100644 --- a/app/views/alchemy/admin/resources/_filter_bar.html.erb +++ b/app/views/alchemy/admin/resources/_filter_bar.html.erb @@ -19,9 +19,8 @@ if ($this.data('remote') === true) { $.get(url, {filter: $this.val()}, null, 'script'); } else { - Alchemy.pleaseWaitOverlay(); delimiter = url.match(/\?/) ? '&' : '?'; - window.location = url + delimiter + 'filter=' + encodeURIComponent($this.val()); + Turbolinks.visit(url + delimiter + 'filter=' + encodeURIComponent($this.val())); } return false; }); diff --git a/app/views/alchemy/admin/resources/_tag_list.html.erb b/app/views/alchemy/admin/resources/_tag_list.html.erb index 3a7d696c79..eefbae19d5 100644 --- a/app/views/alchemy/admin/resources/_tag_list.html.erb +++ b/app/views/alchemy/admin/resources/_tag_list.html.erb @@ -9,7 +9,7 @@ render_icon('delete-small') + Alchemy.t('Remove tag filter'), url_for(search_filter_params.except(:tagged_with)), remote: request.xhr?, - class: 'button small with_icon please_wait' + class: 'button small with_icon' ) %> <% end %> diff --git a/app/views/alchemy/admin/resources/index.html.erb b/app/views/alchemy/admin/resources/index.html.erb index 52e215800d..d89028bbae 100644 --- a/app/views/alchemy/admin/resources/index.html.erb +++ b/app/views/alchemy/admin/resources/index.html.erb @@ -20,7 +20,6 @@ label: Alchemy.t(:download_csv), title: Alchemy.t(:download_csv), dialog: false, - loading_indicator: false, if_permitted_to: [:index, resource_model] } ] diff --git a/app/views/alchemy/admin/uploader/_button.html.erb b/app/views/alchemy/admin/uploader/_button.html.erb index 335fa82ef6..1675bc8349 100644 --- a/app/views/alchemy/admin/uploader/_button.html.erb +++ b/app/views/alchemy/admin/uploader/_button.html.erb @@ -27,8 +27,7 @@ <% if local_assigns[:in_dialog] %> $.get(url, null, null, 'script'); <% else %> - Alchemy.pleaseWaitOverlay(); - window.location.href = url; + Turbolinks.visit(url); <% end %> } }; diff --git a/app/views/alchemy/base/permission_denied.js.erb b/app/views/alchemy/base/permission_denied.js.erb index 9624c840e6..2a573f2f67 100644 --- a/app/views/alchemy/base/permission_denied.js.erb +++ b/app/views/alchemy/base/permission_denied.js.erb @@ -1,3 +1,3 @@ Alchemy.closeCurrentDialog(function() { - window.location.href = '<%= Alchemy.login_path %>'; + Turbolinks.visit('<%= Alchemy.login_path %>'); }); diff --git a/app/views/alchemy/base/redirect.js.erb b/app/views/alchemy/base/redirect.js.erb index 193ca11cbe..ef09c4c443 100644 --- a/app/views/alchemy/base/redirect.js.erb +++ b/app/views/alchemy/base/redirect.js.erb @@ -1,8 +1,7 @@ (function() { var dialog = Alchemy.currentDialog(); var callback = function() { - Alchemy.pleaseWaitOverlay(); - window.location.href = '<%= url_for(@redirect_url) %>'; + Turbolinks.visit('<%= url_for(@redirect_url) %>'); }; if (dialog) { Alchemy.closeCurrentDialog(callback); diff --git a/config/routes.rb b/config/routes.rb index 029d1f577d..b932c72916 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,7 @@ end namespace :admin, {path: Alchemy.admin_path, constraints: Alchemy.admin_constraints} do - resources :contents do + resources :contents, only: [:create] do collection do post :order end diff --git a/spec/requests/alchemy/admin/contents_controller_spec.rb b/spec/requests/alchemy/admin/contents_controller_spec.rb index 95c1a37126..8d4f5a8f95 100644 --- a/spec/requests/alchemy/admin/contents_controller_spec.rb +++ b/spec/requests/alchemy/admin/contents_controller_spec.rb @@ -58,20 +58,6 @@ module Alchemy end end - describe '#update' do - let(:content) { create(:alchemy_content) } - - before do - expect(Content).to receive(:find).and_return(content) - end - - it "should update a content via ajax" do - expect { - patch admin_content_path(id: content.id, content: {ingredient: 'Peters Petshop'}, format: :js) - }.to change { content.ingredient }.to 'Peters Petshop' - end - end - describe "#order" do context "with content_ids in params" do let(:element) do