diff --git a/client/app.js b/client/app.js index d9ba283ba..cf0ed98de 100644 --- a/client/app.js +++ b/client/app.js @@ -151,7 +151,8 @@ if (Meteor.is_client) { var Router = new SimpleRouter(); Meteor.startup(function() { - Backbone.history.start({pushState: true}); + if(!Backbone.history._hasPushState) + Backbone.history.start({pushState: true}); }); } diff --git a/client/templates/user_edit.html b/client/templates/user_edit.html index ba8279ca4..267962fff 100644 --- a/client/templates/user_edit.html +++ b/client/templates/user_edit.html @@ -8,19 +8,31 @@ {{/if}}

Account

+ {{#if username}}
-
+
+ +
+
+ {{/if}} + +
+ +
+ +
-
- -
-
-
- -
+
+ +
diff --git a/client/templates/user_edit.js b/client/templates/user_edit.js index 85b0a6356..ab51a8cfc 100644 --- a/client/templates/user_edit.js +++ b/client/templates/user_edit.js @@ -1,23 +1,21 @@ -(function(){ - Template.user_edit.events = { 'submit form': function(e){ e.preventDefault(); - if(!Meteor.user()) throw 'You must be logged in.'; + $target=$(e.target); + if(!Meteor.user()) throwError('You must be logged in.'); var user=window.selected_user_id? Meteor.users.findOne(window.selected_user_id) : Meteor.user(); var update = { - "profile.name": $(e.target).find('[name=name]').val(), - "profile.bio": $(e.target).find('[name=bio]').val() + "profile.name": $target.find('[name=email]').val() }; // TODO: enable change email var email = $(e.target).find('[name=email]').val(); - var old_password = $(e.target).find('[name=old_password]').val(); - var new_password = $(e.target).find('[name=new_password]').val(); + var old_password = $target.find('[name=old_password]').val(); + var new_password = $target.find('[name=new_password]').val(); - // XXX we should do something if there is an eeror updating these things + // XXX we should do something if there is an error updating these things if(old_password && new_password){ Meteor.changePassword(old_password, new_password); } @@ -36,7 +34,7 @@ Template.user_edit.events = { }; Template.user_edit.profileIncomplete = function() { - return !this.loading && !userProfileComplete(this); + return Meteor.user() && !this.loading && !userProfileComplete(this); } Template.user_edit.user = function(){ @@ -46,6 +44,4 @@ Template.user_edit.user = function(){ }else{ return current_user; } -} - -})(); \ No newline at end of file +} \ No newline at end of file diff --git a/client/templates/user_email.html b/client/templates/user_email.html new file mode 100644 index 000000000..180cb8e96 --- /dev/null +++ b/client/templates/user_email.html @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/client/templates/user_email.js b/client/templates/user_email.js new file mode 100644 index 000000000..5fe5bf744 --- /dev/null +++ b/client/templates/user_email.js @@ -0,0 +1,39 @@ +Template.user_edit.events = { + 'submit form': function(e){ + e.preventDefault(); + if(!Meteor.user()) throwError('You must be logged in.'); + + var user=window.selected_user_id? Meteor.users.findOne(window.selected_user_id) : Meteor.user(); + var update = { + "profile.name": $(e.target).find('[name=name]').val(), + "profile.bio": $(e.target).find('[name=bio]').val() + }; + + // TODO: enable change email + var email = $(e.target).find('[name=email]').val(); + + Meteor.users.update(user._id, { + $set: update + }, function(error){ + if(error){ + throwError(error.reason); + } else { + throwError('Profile updated'); + } + }); + } + +}; + +Template.user_edit.profileIncomplete = function() { + return Meteor.user() && !this.loading && !userProfileComplete(this); +} + +Template.user_edit.user = function(){ + var current_user=Meteor.user(); + if(window.selected_user_id && !current_user.loading && current_user.isAdmin){ + return Meteor.users.findOne(window.selected_user_id); + }else{ + return current_user; + } +} \ No newline at end of file