fixed aspect sorting, added minimal jquery ui, added test
This commit is contained in:
parent
4c13fd2b42
commit
cee4f1c3cd
6 changed files with 31 additions and 10 deletions
1
Gemfile
1
Gemfile
|
|
@ -86,6 +86,7 @@ gem "entypo-rails", "2.2.2"
|
|||
gem "backbone-on-rails", "1.1.2"
|
||||
gem "handlebars_assets", "0.20.1"
|
||||
gem "jquery-rails", "3.1.2"
|
||||
gem "jquery-ui-rails", "5.0.3"
|
||||
gem "js_image_paths", "0.0.2"
|
||||
gem "js-routes", "1.0.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -739,6 +739,7 @@ DEPENDENCIES
|
|||
jasmine (= 2.2.0)
|
||||
jasmine-jquery-rails (= 2.0.3)
|
||||
jquery-rails (= 3.1.2)
|
||||
jquery-ui-rails (= 5.0.3)
|
||||
js-routes (= 1.0.0)
|
||||
js_image_paths (= 0.0.2)
|
||||
jshintrb (= 0.3.0)
|
||||
|
|
|
|||
|
|
@ -4,15 +4,14 @@
|
|||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#aspect_nav.left_nav .all_aspects .sub_nav').sortable({
|
||||
items: "li[data-aspect_id]",
|
||||
$('#aspect_nav .nav').sortable({
|
||||
items: "li.aspect[data-aspect-id]",
|
||||
update: function(event, ui) {
|
||||
var order = $(this).sortable("toArray", {attribute: "data-aspect_id"}),
|
||||
obj = { 'reorder_aspects': order, '_method': 'put' };
|
||||
$.ajax('/user', { type: 'post', dataType: 'script', data: obj });
|
||||
var order = $(this).sortable("toArray", {attribute: "data-aspect-id"}),
|
||||
obj = { 'aspect_order': order };
|
||||
$.ajax('/user', { type: 'put', dataType: 'text', data: obj });
|
||||
},
|
||||
revert: true,
|
||||
helper: 'clone'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
//= require jquery-idletimer/dist/idle-timer
|
||||
//= require jquery.infinitescroll-custom
|
||||
//= require jquery.autocomplete-custom
|
||||
//= require jquery-ui
|
||||
//= require jquery-ui/core
|
||||
//= require jquery-ui/widget
|
||||
//= require jquery-ui/mouse
|
||||
//= require jquery-ui/sortable
|
||||
//= require keycodes
|
||||
//= require fileuploader-custom
|
||||
//= require handlebars.runtime
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ class UsersController < ApplicationController
|
|||
password_changed = false
|
||||
@user = current_user
|
||||
|
||||
if u = user_params
|
||||
if aspect_order = params[:aspect_order]
|
||||
@user.reorder_aspects(aspect_order)
|
||||
elsif u = user_params
|
||||
|
||||
# change email notifications
|
||||
if u[:email_preferences]
|
||||
|
|
@ -70,8 +72,6 @@ class UsersController < ApplicationController
|
|||
flash[:error] = I18n.t 'users.update.follow_settings_not_changed'
|
||||
end
|
||||
end
|
||||
elsif aspect_order = params[:reorder_aspects]
|
||||
@user.reorder_aspects(aspect_order)
|
||||
end
|
||||
set_email_preferences
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,23 @@ describe UsersController, :type => :controller do
|
|||
expect(response.status).to eq(204)
|
||||
end
|
||||
|
||||
describe 'aspect_order' do
|
||||
it 'updates the aspect order' do
|
||||
aspect_order = []
|
||||
@user.aspects.each do |aspect|
|
||||
aspect.update_attributes({ :order_id => nil })
|
||||
aspect_order.push(aspect.id)
|
||||
end
|
||||
|
||||
put(:update, :id => @user.id, :aspect_order => aspect_order)
|
||||
|
||||
@user.reload
|
||||
@user.aspects.each do |aspect|
|
||||
expect(aspect.order_id).not_to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'password updates' do
|
||||
let(:password_params) do
|
||||
{:current_password => 'bluepin7',
|
||||
|
|
|
|||
Loading…
Reference in a new issue