mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Notification cleanup
Closes #666. * Adding new error notifications (removed post name, cleaned up statuses) when creating/updating a post * Removing scheduled from the maps and changing the text of publish-on * Made temporary "Scheduled publishing is not supported yet." message display in a proper error container, plus a slight grammar fix. * Removed ; from the start of validation errors on post error, as the previous sentence finishes with a .
This commit is contained in:
parent
56620635db
commit
38ae87524d
1 changed files with 13 additions and 15 deletions
|
@ -76,8 +76,13 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
notificationMap: {
|
notificationMap: {
|
||||||
'draft': 'saved as a draft',
|
'draft': 'has been saved as a draft',
|
||||||
'published': 'published'
|
'published': 'has been published'
|
||||||
|
},
|
||||||
|
|
||||||
|
errorMap: {
|
||||||
|
'draft': 'could not be saved as a draft',
|
||||||
|
'published': 'could not be published'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
@ -119,7 +124,7 @@
|
||||||
status: 'passive'
|
status: 'passive'
|
||||||
});
|
});
|
||||||
}, function (xhr) {
|
}, function (xhr) {
|
||||||
var status = keys[newIndex];
|
var status = this.errorMap[newIndex];
|
||||||
// Show a notification about the error
|
// Show a notification about the error
|
||||||
self.reportSaveError(xhr, model, status);
|
self.reportSaveError(xhr, model, status);
|
||||||
});
|
});
|
||||||
|
@ -174,20 +179,17 @@
|
||||||
updatePost: function (status) {
|
updatePost: function (status) {
|
||||||
var self = this,
|
var self = this,
|
||||||
model = this.model,
|
model = this.model,
|
||||||
prevStatus = model.get('status'),
|
prevStatus = model.get('status');
|
||||||
notificationMap = this.notificationMap;
|
|
||||||
|
|
||||||
// Default to same status if not passed in
|
// Default to same status if not passed in
|
||||||
status = status || prevStatus;
|
status = status || prevStatus;
|
||||||
|
|
||||||
model.trigger('willSave');
|
|
||||||
|
|
||||||
this.savePost({
|
this.savePost({
|
||||||
status: status
|
status: status
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: ['Your post has been ', notificationMap[status], '.'].join(''),
|
message: ['Your post ', this.notificationMap[status], '.'].join(''),
|
||||||
status: 'passive'
|
status: 'passive'
|
||||||
});
|
});
|
||||||
// Refresh publish button and all relevant controls with updated status.
|
// Refresh publish button and all relevant controls with updated status.
|
||||||
|
@ -198,7 +200,7 @@
|
||||||
// Set appropriate button status
|
// Set appropriate button status
|
||||||
self.setActiveStatus(status, self.statusMap[status], prevStatus);
|
self.setActiveStatus(status, self.statusMap[status], prevStatus);
|
||||||
// Show a notification about the error
|
// Show a notification about the error
|
||||||
self.reportSaveError(xhr, model, status);
|
self.reportSaveError(xhr, model, self.errorMap[status]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -207,8 +209,6 @@
|
||||||
this.model.unset(item);
|
this.model.unset(item);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var saved = this.model.save(_.extend({
|
var saved = this.model.save(_.extend({
|
||||||
title: $('#entry-title').val(),
|
title: $('#entry-title').val(),
|
||||||
// TODO: The content_raw getter here isn't great, shouldn't rely on currentView.
|
// TODO: The content_raw getter here isn't great, shouldn't rely on currentView.
|
||||||
|
@ -224,16 +224,14 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
reportSaveError: function (response, model, status) {
|
reportSaveError: function (response, model, status) {
|
||||||
var title = model.get('title') || '[Untitled]',
|
var message = 'Your post ' + status + '.';
|
||||||
notificationStatus = this.notificationMap[status],
|
|
||||||
message = 'Your post: ' + title + ' has not been ' + notificationStatus;
|
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
// Get message from response
|
// Get message from response
|
||||||
message = Ghost.Views.Utils.getRequestErrorMessage(response);
|
message = Ghost.Views.Utils.getRequestErrorMessage(response);
|
||||||
} else if (model.validationError) {
|
} else if (model.validationError) {
|
||||||
// Grab a validation error
|
// Grab a validation error
|
||||||
message += "; " + model.validationError;
|
message += " " + model.validationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
|
|
Loading…
Reference in a new issue