66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
/**
|
|
The route for editing a user's "About Me" bio.
|
|
|
|
@class PreferencesAboutRoute
|
|
@extends Discourse.RestrictedUserRoute
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.PreferencesAboutRoute = Discourse.RestrictedUserRoute.extend({
|
|
model: function() {
|
|
return this.modelFor('user');
|
|
},
|
|
|
|
renderTemplate: function() {
|
|
this.render({ into: 'user', outlet: 'userOutlet' });
|
|
},
|
|
|
|
setupController: function(controller, model) {
|
|
controller.setProperties({ model: model, newBio: model.get('bio_raw') });
|
|
},
|
|
|
|
// A bit odd, but if we leave to /preferences we need to re-render that outlet
|
|
exit: function() {
|
|
this._super();
|
|
this.render('preferences', { into: 'user', outlet: 'userOutlet', controller: 'preferences' });
|
|
},
|
|
|
|
events: {
|
|
changeAbout: function() {
|
|
var route = this;
|
|
var controller = route.controllerFor('preferencesAbout');
|
|
|
|
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'));
|
|
});
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
This controller supports actions related to updating your "About Me" bio
|
|
|
|
@class PreferencesAboutController
|
|
@extends Discourse.ObjectController
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.PreferencesAboutController = Discourse.ObjectController.extend({
|
|
saving: false,
|
|
|
|
saveButtonText: function() {
|
|
if (this.get('saving')) return I18n.t("saving");
|
|
return I18n.t("user.change");
|
|
}.property('saving'),
|
|
|
|
|
|
}); |