flash the user whether or not that person was moved to a different aspect
This commit is contained in:
parent
eea5b0a748
commit
c23811e1ab
3 changed files with 22 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ class AspectsController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
|
||||
respond_to :html
|
||||
respond_to :json, :only => :show
|
||||
respond_to :json, :only => [:show, :move_contact]
|
||||
respond_to :js
|
||||
|
||||
def index
|
||||
|
|
@ -113,16 +113,21 @@ class AspectsController < ApplicationController
|
|||
@from_aspect = current_user.aspects.where(:id => params[:from]).first
|
||||
@to_aspect = current_user.aspects.where(:id => params[:to][:to]).first
|
||||
|
||||
response = { }
|
||||
|
||||
unless current_user.move_contact( @person, @to_aspect, @from_aspect)
|
||||
flash[:error] = I18n.t 'aspects.move_contact.error',:inspect => params.inspect
|
||||
end
|
||||
if aspect = current_user.aspects.where(:id => params[:to][:to]).first
|
||||
flash[:notice] = I18n.t 'aspects.move_contact.success'
|
||||
render :nothing => true
|
||||
response[:notice] = I18n.t 'aspects.move_contact.success'
|
||||
response[:success] = true
|
||||
else
|
||||
flash[:notice] = I18n.t 'aspects.move_contact.failure'
|
||||
render aspects_manage_path
|
||||
response[:notice] = I18n.t 'aspects.move_contact.failure'
|
||||
response[:success] = false
|
||||
end
|
||||
|
||||
|
||||
respond_with response
|
||||
end
|
||||
|
||||
def add_to_aspect
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ var AspectEdit = {
|
|||
if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing contact does
|
||||
dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) {
|
||||
$.ajax({
|
||||
url: "/aspects/move_contact/",
|
||||
url: "/aspects/move_contact.json",
|
||||
data: {
|
||||
"person_id": person.attr('data-guid'),
|
||||
"from": person.attr('data-aspect_id'),
|
||||
|
|
@ -70,8 +70,8 @@ var AspectEdit = {
|
|||
"to": dropzone.attr('data-aspect_id')
|
||||
}
|
||||
},
|
||||
success: function() {
|
||||
AspectEdit.onMovePersonSuccess(person, dropzone);
|
||||
success: function(data) {
|
||||
AspectEdit.onMovePersonSuccess(person, dropzone, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -85,7 +85,8 @@ var AspectEdit = {
|
|||
person.removeAttr('data-person_id');
|
||||
},
|
||||
|
||||
onMovePersonSuccess: function(person, dropzone) {
|
||||
onMovePersonSuccess: function(person, dropzone, data) {
|
||||
View.flashes.render(data);
|
||||
person.attr('data-aspect_id', dropzone.attr('data-aspect_id'));
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,13 @@ var View = {
|
|||
top: -100
|
||||
}, $this.remove)
|
||||
},
|
||||
render: function(result) {
|
||||
$("<div/>")
|
||||
.attr("id", (result.success) ? "flash_notice" : "flash_error")
|
||||
.prependTo(document.body)
|
||||
.html(result.notice);
|
||||
View.flashes.animate();
|
||||
},
|
||||
selector: "#flash_notice, #flash_error, #flash_alert"
|
||||
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue