DG IZ moving friends is now ajaxy
This commit is contained in:
parent
b80d75c382
commit
e588d7ab6a
6 changed files with 22 additions and 49 deletions
|
|
@ -79,10 +79,10 @@ class AspectsController < ApplicationController
|
||||||
end
|
end
|
||||||
if aspect = current_user.aspect_by_id(params[:to][:to])
|
if aspect = current_user.aspect_by_id(params[:to][:to])
|
||||||
flash[:notice] = "You are now showing your friend a different aspect of yourself."
|
flash[:notice] = "You are now showing your friend a different aspect of yourself."
|
||||||
respond_with aspect
|
render :nothing => true
|
||||||
else
|
else
|
||||||
flash[:notice] = "You are now showing your friend a different aspect of yourself."
|
flash[:error] = "Invalid aspect id!"
|
||||||
respond_with current_user.visible_person_by_id(params[:friend_id])
|
render aspects_manage_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,4 @@
|
||||||
%div{:id => "add_request_pane_#{aspect.id}"}
|
%div{:id => "add_request_pane_#{aspect.id}"}
|
||||||
= render "requests/new_request", :aspect => aspect
|
= render "requests/new_request", :aspect => aspect
|
||||||
|
|
||||||
%p
|
|
||||||
%br
|
|
||||||
= link_to 'Update Aspects', '#', :class => 'button', :id => "move_friends_link"
|
|
||||||
|
|
||||||
#content_bottom
|
#content_bottom
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#aspect_nav
|
#aspect_nav
|
||||||
%ul
|
%ul
|
||||||
- for aspect in @aspects
|
- for aspect in @aspects
|
||||||
%li{:id => aspect.id, :class => ("selected" if current_aspect?(aspect))}
|
%li{:class => ("selected" if current_aspect?(aspect))}
|
||||||
= link_for_aspect aspect
|
= link_for_aspect aspect
|
||||||
|
|
||||||
%ul{ :style => "position:absolute;right:0;bottom:0.01em;"}
|
%ul{ :style => "position:absolute;right:0;bottom:0.01em;"}
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,11 @@ Diaspora::Application.routes.draw do
|
||||||
resources :photos, :except => [:index]
|
resources :photos, :except => [:index]
|
||||||
resources :albums
|
resources :albums
|
||||||
|
|
||||||
match 'aspects/manage', :to => 'aspects#manage'
|
|
||||||
resources :aspects, :except => [:edit]
|
|
||||||
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
|
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
|
||||||
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
||||||
|
match 'aspects/manage', :to => 'aspects#manage'
|
||||||
|
resources :aspects, :except => [:edit]
|
||||||
|
|
||||||
|
|
||||||
match 'warzombie', :to => "dev_utilities#warzombie"
|
match 'warzombie', :to => "dev_utilities#warzombie"
|
||||||
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspect_by_id( id )
|
def aspect_by_id( id )
|
||||||
id = id.to_id
|
self.aspects.find( id )
|
||||||
aspects.detect{|x| x.id == id }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def album_by_id( id )
|
def album_by_id( id )
|
||||||
|
|
|
||||||
|
|
@ -20,28 +20,6 @@ function decrementRequestsCounter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
|
||||||
$('#move_friends_link').live( 'click', function(){
|
|
||||||
$.post(
|
|
||||||
'/aspects/move_friends',
|
|
||||||
{ 'moves' : $('#aspect_list').data() },
|
|
||||||
function() {
|
|
||||||
$('#aspect_title').html("Groups edited successfully!");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// should the following logic be moved into the $.post() callback?
|
|
||||||
$("#aspect_list").removeData();
|
|
||||||
|
|
||||||
$(".person")
|
|
||||||
.css('background-color','none')
|
|
||||||
.attr('from_aspect_id', function() {
|
|
||||||
return $(this).parent().attr('id')
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Multiple classes here won't work
|
// Multiple classes here won't work
|
||||||
$("ul .person").draggable({
|
$("ul .person").draggable({
|
||||||
revert: true
|
revert: true
|
||||||
|
|
@ -65,24 +43,23 @@ $(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
};
|
||||||
var $aspect_list = $('#aspect_list'),
|
var dropzone = $(this)[0];
|
||||||
move = {};
|
|
||||||
|
|
||||||
// This is poor implementation
|
if ($(this)[0].id == ui.draggable[0].getAttribute('from_aspect_id')){
|
||||||
move[ 'friend_id' ] = ui.draggable[0].id; // ui.draggable.attr('id')
|
|
||||||
move[ 'to' ] = $(this)[0].id;// $(this).attr('id');
|
|
||||||
move[ 'from' ] = ui.draggable[0].getAttribute('from_aspect_id'); // ui.draggable.attr('from_aspect_id')
|
|
||||||
|
|
||||||
// if created custom attr's - should be using `data-foo`
|
|
||||||
|
|
||||||
|
|
||||||
if (move['to'] == move['from']){
|
|
||||||
$aspect_list.data( ui.draggable[0].id, []);
|
|
||||||
ui.draggable.css('background-color','#eee');
|
ui.draggable.css('background-color','#eee');
|
||||||
} else {
|
} else {
|
||||||
$aspect_list.data( ui.draggable[0].id, move);
|
|
||||||
ui.draggable.css('background-color','orange');
|
ui.draggable.css('background-color','orange');
|
||||||
|
$.ajax({
|
||||||
|
url: "/aspects/move_friend/",
|
||||||
|
data: {"friend_id" : ui.draggable[0].id,
|
||||||
|
"from" : ui.draggable[0].getAttribute('from_aspect_id'),
|
||||||
|
"to" : { "to" : dropzone.id }},
|
||||||
|
success: function(data){
|
||||||
|
ui.draggable.attr('from_aspect_id', dropzone.id);
|
||||||
|
ui.draggable.css('background','none');
|
||||||
|
}});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(this).closest("ul").append(ui.draggable);
|
$(this).closest("ul").append(ui.draggable);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue