Ghost/core/client/routes/application.js
Fabian Becker a4f8088697 Implement Notifications for Ember
closes #2417
- Adds Notification(s)Component
- Render notifications in application.hbs
- Adds handleError in application route
2014-04-09 00:36:15 +00:00

36 lines
1.1 KiB
JavaScript

var ApplicationRoute = Ember.Route.extend({
actions: {
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;