collapsed remove from aspect and remove person into one function on aspects#manage
This commit is contained in:
parent
7d125e68e9
commit
be916384a1
2 changed files with 11 additions and 18 deletions
|
|
@ -28,12 +28,6 @@
|
||||||
.circle
|
.circle
|
||||||
= person_image_tag(request.person)
|
= person_image_tag(request.person)
|
||||||
|
|
||||||
%h3 Remove from Aspect
|
|
||||||
.aspect_remove
|
|
||||||
%ul.dropzone
|
|
||||||
.draggable_info
|
|
||||||
Drag to remove person from aspect
|
|
||||||
|
|
||||||
= render 'shared/invitations', :invites => @invites
|
= render 'shared/invitations', :invites => @invites
|
||||||
|
|
||||||
.span-19.last
|
.span-19.last
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,6 @@ var AspectEdit = {
|
||||||
drop: AspectEdit.onDropMove
|
drop: AspectEdit.onDropMove
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".aspect_remove ul").droppable({
|
|
||||||
hoverClass: 'active',
|
|
||||||
drop: AspectEdit.onDropDelete
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".delete").live("click", AspectEdit.deletePerson);
|
$(".delete").live("click", AspectEdit.deletePerson);
|
||||||
$(".aspect h3").live('focus', AspectEdit.changeName);
|
$(".aspect h3").live('focus', AspectEdit.changeName);
|
||||||
},
|
},
|
||||||
|
|
@ -57,6 +52,7 @@ var AspectEdit = {
|
||||||
data: {"accept" : true, "aspect_id" : dropzone.attr('data-aspect_id') },
|
data: {"accept" : true, "aspect_id" : dropzone.attr('data-aspect_id') },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
AspectEdit.decrementRequestsCounter();
|
AspectEdit.decrementRequestsCounter();
|
||||||
|
person.removeClass('request');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -75,10 +71,11 @@ var AspectEdit = {
|
||||||
dropzone.closest("ul").append(person);
|
dropzone.closest("ul").append(person);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDropDelete: function(event, ui) {
|
deletePersonFromAspect: function(person) {
|
||||||
var person = ui.draggable;
|
|
||||||
|
|
||||||
if (person.attr('data-guid').length == 1) {
|
var person_id = person.attr('data-guid');
|
||||||
|
|
||||||
|
if( $(".person[data-guid='"+ person_id +"']").length == 1) {
|
||||||
alert("You can not remove the person from the last aspect");
|
alert("You can not remove the person from the last aspect");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -88,7 +85,7 @@ var AspectEdit = {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/aspects/remove_from_aspect",
|
url: "/aspects/remove_from_aspect",
|
||||||
data:{
|
data:{
|
||||||
'friend_id' : person.attr('data-guid'),
|
'friend_id' : person_id,
|
||||||
'aspect_id' : person.attr('data-aspect_id') }
|
'aspect_id' : person.attr('data-aspect_id') }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -139,16 +136,18 @@ var AspectEdit = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (confirm("Remove this person from all aspects?")) {
|
if (confirm("Also remove this person from all aspects?")) {
|
||||||
var person_id = $(this).closest("li.person").attr('data-guid');
|
var person_id = $(this).closest("li.person").attr('data-guid');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
url: "/people/" + person_id,
|
url: "/people/" + person_id,
|
||||||
success: function() {
|
success: function() {
|
||||||
person.fadeOut(200);
|
$(".person[data-guid='"+ person_id +"']").fadeOut(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
AspectEdit.deletePersonFromAspect(person);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -170,4 +169,4 @@ var AspectEdit = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(AspectEdit.initialize);
|
$(document).ready(AspectEdit.initialize);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue