This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/routes/preferences-about.js.es6
2019-01-19 10:05:51 +01:00

47 lines
1.2 KiB
JavaScript

import RestrictedUserRoute from "discourse/routes/restricted-user";
export default RestrictedUserRoute.extend({
showFooter: true,
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(...arguments);
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);
bootbox.alert(I18n.t("generic_error"));
}
);
}
}
});