Remove minor notifications; Close persistent notifications even on error

Closes #3105, Closes #3175

- Removed notification on successful post's `page` status change
- Removed notification on successful post `featured` status change
- Added `closePassive()` notifications on error in the post-settings-menu
- Persistent notifications will close whether their `DELETE` request was
  successful or not.

 #### Misc
- Added `name` attribute to `post-setting-menu.hbs` inputs to facilitate testing
- Removed `return <Promise>` from action in `PostSettingsMenuController`. Actions should only return `true`
- Toggling `post.featured` won't fire NProgress.
This commit is contained in:
Matt Enlow 2014-07-14 22:02:34 -06:00
parent 7cc818d262
commit f80f2e1a24
4 changed files with 12 additions and 19 deletions

View File

@ -77,19 +77,16 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
},
actions: {
togglePage: function () {
var value = this.toggleProperty('page'),
self = this;
var self = this;
this.toggleProperty('page');
// If this is a new post. Don't save the model. Defer the save
// to the user pressing the save button
if (this.get('isNew')) {
return;
}
return this.get('model').save(this.get('saveOptions')).then(function () {
self.showSuccess('Successfully converted to ' + (value ? 'static page' : 'post'));
return value;
}).catch(function (errors) {
this.get('model').save(this.get('saveOptions')).catch(function (errors) {
self.showErrors(errors);
self.get('model').rollback();
});
@ -205,10 +202,7 @@ var PostSettingsMenuController = Ember.ObjectController.extend({
return;
}
this.get('model').save(this.get('saveOptions')).then(function () {
self.showSuccess('Publish date successfully changed to <strong>' +
formatDate(self.get('published_at')) + '</strong>.');
}).catch(function (errors) {
this.get('model').save(this.get('saveOptions')).catch(function (errors) {
self.showErrors(errors);
self.get('model').rollback();
});

View File

@ -4,13 +4,11 @@ var PostController = Ember.ObjectController.extend({
actions: {
toggleFeatured: function () {
var featured = this.toggleProperty('featured'),
var options = {disableNProgress: true},
self = this;
this.get('model').save().then(function () {
self.notifications.closePassive();
self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.');
}).catch(function (errors) {
this.toggleProperty('featured');
this.get('model').save(options).catch(function (errors) {
self.notifications.closePassive();
self.notifications.showErrors(errors);
});

View File

@ -6,7 +6,7 @@
<label for="url">URL</label>
</td>
<td class="post-setting-field">
{{gh-blur-input class="post-setting-slug" id="url" value=slugValue action="updateSlug" placeholder=slugPlaceholder selectOnClick="true"}}
{{gh-blur-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" action="updateSlug" placeholder=slugPlaceholder selectOnClick="true"}}
</td>
</tr>
<tr class="post-setting">
@ -14,7 +14,7 @@
<label for="pub-date">Pub Date</label>
</td>
<td class="post-setting-field">
{{gh-blur-input class="post-setting-date" value=publishedAtValue action="setPublishedAt" placeholder=publishedAtPlaceholder}}
{{gh-blur-input class="post-setting-date" value=publishedAtValue name="post-setting-date" action="setPublishedAt" placeholder=publishedAtPlaceholder}}
</td>
</tr>
<tr class="post-setting">

View File

@ -68,6 +68,7 @@ var Notifications = Ember.ArrayProxy.extend({
message: message
}, delayed);
},
// @Todo this function isn't referenced anywhere. Should it be removed?
showWarn: function (message, delayed) {
this.handleNotification({
type: 'warn',
@ -87,7 +88,7 @@ var Notifications = Ember.ArrayProxy.extend({
if (notification instanceof Notification) {
notification.deleteRecord();
notification.save().then(function () {
notification.save().finally(function () {
self.removeObject(notification);
});
} else {