ajax form on the getting started
This commit is contained in:
parent
80216cb024
commit
bfd2d440d1
3 changed files with 42 additions and 26 deletions
|
|
@ -38,30 +38,30 @@ class ProfilesController < ApplicationController
|
||||||
:id => params[:photo_id]).first if params[:photo_id]
|
:id => params[:photo_id]).first if params[:photo_id]
|
||||||
|
|
||||||
if current_user.update_profile params[:profile]
|
if current_user.update_profile params[:profile]
|
||||||
flash[:notice] = I18n.t 'profiles.update.updated'
|
respond_to do |format|
|
||||||
if current_user.getting_started?
|
format.js { render :nothing => true, :status => 200 }
|
||||||
respond_to do |format|
|
format.html {
|
||||||
format.js { render :nothing => true, :status => 200 }
|
flash[:notice] = I18n.t 'profiles.update.updated'
|
||||||
format.html { redirect_to getting_started_path }
|
if current_user.getting_started?
|
||||||
end
|
|
||||||
else
|
redirect_to getting_started_path
|
||||||
respond_to do |format|
|
else
|
||||||
format.js { render :nothing => true, :status => 200 }
|
redirect_to edit_profile_path
|
||||||
format.html { redirect_to edit_profile_path }
|
end
|
||||||
end
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
flash[:error] = I18n.t 'profiles.update.failed'
|
respond_to do |format|
|
||||||
if params[:getting_started]
|
format.js { render :nothing => true, :status => 200 }
|
||||||
respond_to do |format|
|
format.html {
|
||||||
format.js { render :nothing => true, :status => 409 }
|
flash[:error] = I18n.t 'profiles.update.failed'
|
||||||
format.html { redirect_to getting_started_path(:step => params[:getting_started]) }
|
if params[:getting_started]
|
||||||
end
|
redirect_to getting_started_path(:step => params[:getting_started])
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
redirect_to edit_profile_path
|
||||||
format.js { render :nothing => true, :status => 409 }
|
end
|
||||||
format.html { redirect_to edit_profile_path }
|
}
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,17 @@
|
||||||
to Diaspora. We can pull your name and photo, and enable cross-positng.
|
to Diaspora. We can pull your name and photo, and enable cross-positng.
|
||||||
|
|
||||||
.span-12
|
.span-12
|
||||||
= form_for current_user.person.profile do |profile|
|
/= form_for(current_user.person.profile, :remote => true) do |profile|
|
||||||
|
|
||||||
|
= form_tag profile_path, :method => :put, :remote => true, :id => 'edit_profile' do |profile|
|
||||||
.span-5
|
.span-5
|
||||||
= profile.text_field :first_name, :placeholder => t('profiles.edit.first_name')
|
= text_field_tag 'profile[first_name]', current_user.person.profile.first_name, :placeholder => t('profiles.edit.first_name')
|
||||||
%br
|
= image_tag 'ajax-loader.gif', :id => "form_spinner", :class => "hidden"
|
||||||
= profile.submit "Save"
|
%span.saved{:class => "hidden"}
|
||||||
|
Saved!
|
||||||
|
|
||||||
|
/%br
|
||||||
|
/= submit_tag "Save"
|
||||||
|
|
||||||
.span-7.last
|
.span-7.last
|
||||||
= render 'photos/new_profile_photo', :aspect => :getting_started, :person => current_user.person
|
= render 'photos/new_profile_photo', :aspect => :getting_started, :person => current_user.person
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,15 @@ Diaspora.Pages.UsersGettingStarted = function() {
|
||||||
this.subscribe("page/ready", function(evt, body) {
|
this.subscribe("page/ready", function(evt, body) {
|
||||||
self.peopleSearch = self.instantiate("Search", body.find("form.people.search_form"));
|
self.peopleSearch = self.instantiate("Search", body.find("form.people.search_form"));
|
||||||
self.tagSearch = self.instantiate("Search", body.find("form.tag_input.search_form"));
|
self.tagSearch = self.instantiate("Search", body.find("form.tag_input.search_form"));
|
||||||
|
|
||||||
|
$("#profile_first_name").bind("change", function(){
|
||||||
|
$('#edit_profile').bind('ajax:success', function(evt, data, status, xhr){
|
||||||
|
$('#form_spinner').addClass("hidden");
|
||||||
|
$('.profile .saved').removeClass("hidden");
|
||||||
|
$('.profile .saved').fadeOut(2000);
|
||||||
|
});
|
||||||
|
$('#edit_profile').submit();
|
||||||
|
$('#form_spinner').removeClass("hidden");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue