From 1af5eb624869f1b5d1330f99f843c78c86b69add Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Wed, 25 Jun 2014 16:56:09 +0000 Subject: [PATCH] Close notifications on user action properly. fixes #3105, refs #3012 - Add additional closeAll() calls where users interact with data --- core/client/controllers/posts/post.js | 3 +++ core/client/controllers/settings/app.js | 5 +++++ core/client/controllers/signin.js | 6 ++++-- core/client/controllers/signup.js | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/client/controllers/posts/post.js b/core/client/controllers/posts/post.js index 4e9a708a5f..75327d8fe2 100644 --- a/core/client/controllers/posts/post.js +++ b/core/client/controllers/posts/post.js @@ -7,6 +7,9 @@ var PostController = Ember.ObjectController.extend({ var featured = this.toggleProperty('featured'), self = this; + // @TODO This should call closePassive() to only close passive notifications + self.notifications.closeAll(); + this.get('model').save().then(function () { self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.'); }).catch(function (errors) { diff --git a/core/client/controllers/settings/app.js b/core/client/controllers/settings/app.js index 19c92d706c..360011edd7 100644 --- a/core/client/controllers/settings/app.js +++ b/core/client/controllers/settings/app.js @@ -9,9 +9,11 @@ var AppStates = { var SettingsAppController = Ember.ObjectController.extend({ appState: AppStates.active, buttonText: '', + setAppState: function () { this.set('appState', this.get('active') ? AppStates.active : AppStates.inactive); }.on('init'), + buttonTextSetter: function () { switch (this.get('appState')) { case AppStates.active: @@ -25,12 +27,15 @@ var SettingsAppController = Ember.ObjectController.extend({ break; } }.observes('appState').on('init'), + activeClass: function () { return this.appState === AppStates.active ? true : false; }.property('appState'), + inactiveClass: function () { return this.appState === AppStates.inactive ? true : false; }.property('appState'), + actions: { toggleApp: function (app) { var self = this; diff --git a/core/client/controllers/signin.js b/core/client/controllers/signin.js index 14347d4ad0..048b6e149f 100644 --- a/core/client/controllers/signin.js +++ b/core/client/controllers/signin.js @@ -19,6 +19,10 @@ var SigninController = Ember.ObjectController.extend(ValidationEngine, { loginTransition = appController.get('loginTransition'); this.toggleProperty('submitting'); + + // @TODO This should call closePassive() to only close passive notifications + self.notifications.closeAll(); + this.validate({ format: false }).then(function () { ajax({ url: self.get('ghostPaths').adminUrl('signin'), @@ -38,7 +42,6 @@ var SigninController = Ember.ObjectController.extend(ValidationEngine, { return self.store.find('user', response.userData.id); }).then(function (user) { self.send('signedIn', user); - self.notifications.clear(); if (loginTransition) { appController.set('loginTransition', null); loginTransition.retry(); @@ -51,7 +54,6 @@ var SigninController = Ember.ObjectController.extend(ValidationEngine, { }); }).catch(function (errors) { self.toggleProperty('submitting'); - self.notifications.clear(); self.notifications.showErrors(errors); }); } diff --git a/core/client/controllers/signup.js b/core/client/controllers/signup.js index 7e582ac236..85c052d5fa 100644 --- a/core/client/controllers/signup.js +++ b/core/client/controllers/signup.js @@ -14,6 +14,9 @@ var SignupController = Ember.ObjectController.extend(ValidationEngine, { signup: function () { var self = this; + // @TODO This should call closePassive() to only close passive notifications + self.notifications.closeAll(); + this.toggleProperty('submitting'); this.validate({ format: false }).then(function () { ajax({ @@ -29,7 +32,6 @@ var SignupController = Ember.ObjectController.extend(ValidationEngine, { self.store.pushPayload({ users: [resp.userData]}); self.store.find('user', resp.userData.id).then(function (user) { self.send('signedIn', user); - self.notifications.clear(); self.transitionToRoute('posts'); }); } else {