Merge pull request #2814 from stwf/aspects-javascript-fixes
update aspect name in aspects listing after editing.
This commit is contained in:
commit
f5ef1e8c14
3 changed files with 13 additions and 1 deletions
|
|
@ -107,7 +107,7 @@ class AspectsController < ApplicationController
|
||||||
else
|
else
|
||||||
flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name
|
flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name
|
||||||
end
|
end
|
||||||
render :json => { :name => @aspect.name }
|
render :json => { :id => @aspect.id, :name => @aspect.name }
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle_contact_visibility
|
def toggle_contact_visibility
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ function updateAspectName(new_name) {
|
||||||
$('#aspect_name_title .name').html(new_name);
|
$('#aspect_name_title .name').html(new_name);
|
||||||
$('input#aspect_name').val(new_name);
|
$('input#aspect_name').val(new_name);
|
||||||
}
|
}
|
||||||
|
function updatePageAspectName( an_id, new_name) {
|
||||||
|
$('ul#aspect_nav [data-guid="'+an_id+'"]').html(new_name);
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#rename_aspect_link').live('click', function(){
|
$('#rename_aspect_link').live('click', function(){
|
||||||
|
|
@ -20,6 +23,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$('form.edit_aspect').live('ajax:success', function(evt, data, status, xhr) {
|
$('form.edit_aspect').live('ajax:success', function(evt, data, status, xhr) {
|
||||||
updateAspectName(data['name']);
|
updateAspectName(data['name']);
|
||||||
|
updatePageAspectName( data['id'], data['name'] );
|
||||||
toggleAspectTitle();
|
toggleAspectTitle();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,14 @@ describe AspectsController do
|
||||||
put('update', :id => @alices_aspect_1.id, "aspect" => params)
|
put('update', :id => @alices_aspect_1.id, "aspect" => params)
|
||||||
Aspect.find(@alices_aspect_1.id).user_id.should == alice.id
|
Aspect.find(@alices_aspect_1.id).user_id.should == alice.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return the name and id of the updated item" do
|
||||||
|
params = {"name" => "Bruisers"}
|
||||||
|
put('update', :id => @alices_aspect_1.id, "aspect" => params)
|
||||||
|
|
||||||
|
puts( response.inspect )
|
||||||
|
response.body.should == { :id => @alices_aspect_1.id, :name => "Bruisers" }.to_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#edit' do
|
describe '#edit' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue