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

More admin cleanup #1343

Merged
merged 4 commits into from
Jan 16, 2018
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions app/assets/javascripts/alchemy/alchemy.dirty.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ $.extend Alchemy,
window.onbeforeunload = @pageUnload

pageUnload: ->
Alchemy.pleaseWaitOverlay(false)
Alchemy.t('page_dirty_notice')

setElementClean: (element) ->
Expand All @@ -41,18 +40,18 @@ $.extend Alchemy,
$form = $("<form action=\"#{element.action}\" method=\"POST\" style=\"display: none\" />")
$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')
ok_label: Alchemy.t('ok')
cancel_label: Alchemy.t('cancel')
on_ok: ->
window.onbeforeunload = undefined
Alchemy.pleaseWaitOverlay()
callback()
false
else
Expand Down
13 changes: 5 additions & 8 deletions app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a>'s styled as button.
$('a.button').attr({tabindex: 0})
Expand All @@ -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
Expand Down
17 changes: 0 additions & 17 deletions app/controllers/alchemy/admin/contents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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|
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/alchemy/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions app/helpers/alchemy/admin/tags_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/attachments/_filter_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/attachments/_replace_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/attachments/_tag_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/attachments/destroy.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
window.location.href = '<%= @url %>';
Turbolinks.visit('<%= @url %>');
4 changes: 0 additions & 4 deletions app/views/alchemy/admin/contents/destroy.js.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
) %>
<label><%= Alchemy.t('Sort pages') %></label>
Expand Down
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/pictures/_filter_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pictures/_tag_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
2 changes: 0 additions & 2 deletions app/views/alchemy/admin/pictures/flush.js.erb

This file was deleted.

6 changes: 3 additions & 3 deletions app/views/alchemy/admin/pictures/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
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"
) %>
</div>
<div class="button_with_label">
<%= link_to(
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"
) %>
</div>
<div class="button_with_label">
<%= link_to(
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"
) %>
</div>
<label><%= Alchemy.t('Image size') %></label>
Expand Down
1 change: 0 additions & 1 deletion app/views/alchemy/admin/pictures/index.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Alchemy.pleaseWaitOverlay(false);
$('#archive_all').html('<%= j render("archive") %>');
$('#filter_bar').replaceWith('<%= j render("filter_bar") %>');
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/resources/_filter_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/resources/_tag_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</div>
1 change: 0 additions & 1 deletion app/views/alchemy/admin/resources/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
]
Expand Down
3 changes: 1 addition & 2 deletions app/views/alchemy/admin/uploader/_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/base/permission_denied.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Alchemy.closeCurrentDialog(function() {
window.location.href = '<%= Alchemy.login_path %>';
Turbolinks.visit('<%= Alchemy.login_path %>');
});
3 changes: 1 addition & 2 deletions app/views/alchemy/base/redirect.js.erb
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions spec/requests/alchemy/admin/contents_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down