mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 00:11:49 +03:00
699111b01a
no issue - Fixes the editor view so that the layout is correct - Remove default title - Fixes a couple of scoping issues with notifications
61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
var ApplicationRoute = Ember.Route.extend({
|
|
actions: {
|
|
signedIn: function (user) {
|
|
// Update the user on all routes and controllers
|
|
this.container.unregister('user:current');
|
|
this.container.register('user:current', user, { instantiate: false });
|
|
|
|
this.container.injection('route', 'user', 'user:current');
|
|
this.container.injection('controller', 'user', 'user:current');
|
|
|
|
this.set('user', user);
|
|
this.set('controller.user', user);
|
|
},
|
|
|
|
signedOut: function () {
|
|
// Nullify the user on all routes and controllers
|
|
this.container.unregister('user:current');
|
|
this.container.register('user:current', null, { instantiate: false });
|
|
|
|
this.container.injection('route', 'user', 'user:current');
|
|
this.container.injection('controller', 'user', 'user:current');
|
|
|
|
this.set('user', null);
|
|
this.set('controller.user', null);
|
|
},
|
|
|
|
openModal: function (modalName, model) {
|
|
modalName = 'modals/' + modalName;
|
|
// We don't always require a modal to have a controller
|
|
// so we're skipping asserting if one exists
|
|
if (this.controllerFor(modalName, true)) {
|
|
this.controllerFor(modalName).set('model', model);
|
|
}
|
|
return this.render(modalName, {
|
|
into: 'application',
|
|
outlet: 'modal'
|
|
});
|
|
},
|
|
|
|
closeModal: function () {
|
|
return this.disconnectOutlet({
|
|
outlet: 'modal',
|
|
parentView: 'application'
|
|
});
|
|
},
|
|
|
|
handleErrors: function (errors) {
|
|
var self = this;
|
|
this.notifications.clear();
|
|
errors.forEach(function (errorObj) {
|
|
self.notifications.showError(errorObj.message || errorObj);
|
|
|
|
if (errorObj.hasOwnProperty('el')) {
|
|
errorObj.el.addClass('input-error');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default ApplicationRoute; |