mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 00:11:49 +03:00
84c15ac4c4
Ref #2699 - Introduce ember data dependency - Add loadInitializers and refactor most initializers into one combined - Add Post ember data model - Refactor generateSlug to use title of post and ghostPaths - Refactor post controller to not reference model.property everywhere - Use RESTAdapter for posts, users and tags - Setup author and tag relations in Post model - Fix broken API calls by adding CSRF header - Add initiaizer for csrf value - Use actual User model for current user initializer - Add action for setting featured post, test with actual api call - Fix the sending of UUID's up to the server - Refactor current-user to use ember-data store - If a user is preloaded in the application, use pushPayload to put it in the store - Do a lookup on the store to get an actual User model for injection - Fix posts/post controllerName in route/new.js - Alter signup process to push user into ember data store
60 lines
2.0 KiB
JavaScript
60 lines
2.0 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) {
|
|
this.notifications.clear();
|
|
errors.forEach(function (errorObj) {
|
|
this.notifications.showError(errorObj.message || errorObj);
|
|
|
|
if (errorObj.hasOwnProperty('el')) {
|
|
errorObj.el.addClass('input-error');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default ApplicationRoute; |