diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index 824814f89a5f02c79def2568c84656b626dc9c47..3fdedbad90d95d427af544f705947841972e2e77 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -60,7 +60,7 @@ -else -for person in aspect.people - %li.person{:id => person.id, :from_aspect_id => aspect.id} + %li.person{:id => person.id, :class => person.id, :from_aspect_id => aspect.id} = person_image_tag(person) .name = link_to person.real_name, person diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index dc0d1cd39f796453e957cceb28c4bfed85761ace..825433e0efc4b1e05f2404cbc6932742de7ed07b 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -89,28 +89,36 @@ $(function() { } - $(ui.draggable[0]).fadeOut('slow'); // ui.draggable.fadeOut('slow') + $(ui.draggable[0]).fadeOut('slow'); + $(ui.draggable[0]).remove(); } }); $(".aspect_remove ul").droppable({ hoverClass: 'active', drop: function(event, ui) { + if ($( "." + ui.draggable[0].id).length == 1) { + alert("You can not remove the person from the last aspect"); + } else { + if (!$(ui.draggable[0]).hasClass('requested_person')){ + var aspect = ui.draggable[0].getAttribute('from_aspect_id') + var person_id = ui.draggable[0].id + $.ajax({ + type: "POST", + url: "/aspects/remove_from_aspect", + data:{ + 'friend_id' : person_id, + 'aspect_id' : aspect + } + }); + } + $(ui.draggable[0]).fadeOut('slow'); + $(ui.draggable[0]).remove(); + - if (!$(ui.draggable[0]).hasClass('requested_person')){ - var aspect = ui.draggable[0].getAttribute('from_aspect_id') - var person_id = ui.draggable[0].id - $.ajax({ - type: "POST", - url: "/aspects/remove_from_aspect", - data:{ - 'friend_id' : person_id, - 'aspect_id' : aspect - } - }); } - $(ui.draggable[0]).fadeOut('slow'); // ui.draggable.fadeOut('slow') + } });