mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 17:52:45 +08:00
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import RestrictedUserRoute from "discourse/routes/restricted-user";
|
|
|
|
export default RestrictedUserRoute.extend({
|
|
model: function() {
|
|
return this.modelFor('user');
|
|
},
|
|
|
|
renderTemplate: function() {
|
|
this.render({ into: 'user' });
|
|
},
|
|
|
|
setupController: function(controller, model) {
|
|
controller.setProperties({ model, newBio: model.get('bio_raw') });
|
|
},
|
|
|
|
// A bit odd, but if we leave to /preferences we need to re-render that outlet
|
|
deactivate: function() {
|
|
this._super();
|
|
this.render('preferences', { into: 'user', controller: 'preferences' });
|
|
},
|
|
|
|
actions: {
|
|
changeAbout: function() {
|
|
var route = this;
|
|
var controller = route.controllerFor('preferences/about');
|
|
|
|
controller.setProperties({ saving: true });
|
|
return controller.get('model').save().then(function() {
|
|
controller.set('saving', false);
|
|
route.transitionTo('user.index');
|
|
}, function() {
|
|
// model failed to save
|
|
controller.set('saving', false);
|
|
alert(I18n.t('generic_error'));
|
|
});
|
|
}
|
|
}
|
|
|
|
});
|