mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #677 from jfi/666
This commit is contained in:
commit
a42acd486b
1 changed files with 17 additions and 18 deletions
|
@ -76,8 +76,13 @@
|
|||
},
|
||||
|
||||
notificationMap: {
|
||||
'draft': 'saved as a draft',
|
||||
'published': 'published'
|
||||
'draft': 'Your post has been saved as a draft.',
|
||||
'published': 'Your post has been published.'
|
||||
},
|
||||
|
||||
errorMap: {
|
||||
'draft': 'Your post could not be saved as a draft.',
|
||||
'published': 'Your post could not be published.'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
|
@ -104,22 +109,23 @@
|
|||
model = self.model,
|
||||
prevStatus = model.get('status'),
|
||||
currentIndex = keys.indexOf(prevStatus),
|
||||
newIndex;
|
||||
newIndex,
|
||||
status;
|
||||
|
||||
newIndex = currentIndex + 1 > keys.length - 1 ? 0 : currentIndex + 1;
|
||||
status = keys[newIndex];
|
||||
|
||||
this.setActiveStatus(keys[newIndex], this.statusMap[keys[newIndex]], prevStatus);
|
||||
this.setActiveStatus(keys[newIndex], this.statusMap[status], prevStatus);
|
||||
|
||||
this.savePost({
|
||||
status: keys[newIndex]
|
||||
}).then(function () {
|
||||
Ghost.notifications.addItem({
|
||||
type: 'success',
|
||||
message: 'Your post has been ' + self.notificationMap[newIndex] + '.',
|
||||
message: self.notificationMap[status],
|
||||
status: 'passive'
|
||||
});
|
||||
}, function (xhr) {
|
||||
var status = keys[newIndex];
|
||||
// Show a notification about the error
|
||||
self.reportSaveError(xhr, model, status);
|
||||
});
|
||||
|
@ -174,20 +180,17 @@
|
|||
updatePost: function (status) {
|
||||
var self = this,
|
||||
model = this.model,
|
||||
prevStatus = model.get('status'),
|
||||
notificationMap = this.notificationMap;
|
||||
prevStatus = model.get('status');
|
||||
|
||||
// Default to same status if not passed in
|
||||
status = status || prevStatus;
|
||||
|
||||
model.trigger('willSave');
|
||||
|
||||
this.savePost({
|
||||
status: status
|
||||
}).then(function () {
|
||||
Ghost.notifications.addItem({
|
||||
type: 'success',
|
||||
message: ['Your post has been ', notificationMap[status], '.'].join(''),
|
||||
message: self.notificationMap[status],
|
||||
status: 'passive'
|
||||
});
|
||||
// Refresh publish button and all relevant controls with updated status.
|
||||
|
@ -207,8 +210,6 @@
|
|||
this.model.unset(item);
|
||||
}, this);
|
||||
|
||||
|
||||
|
||||
var saved = this.model.save(_.extend({
|
||||
title: $('#entry-title').val(),
|
||||
// TODO: The content_raw getter here isn't great, shouldn't rely on currentView.
|
||||
|
@ -224,16 +225,14 @@
|
|||
},
|
||||
|
||||
reportSaveError: function (response, model, status) {
|
||||
var title = model.get('title') || '[Untitled]',
|
||||
notificationStatus = this.notificationMap[status],
|
||||
message = 'Your post: ' + title + ' has not been ' + notificationStatus;
|
||||
var message = this.errorMap[status];
|
||||
|
||||
if (response) {
|
||||
// Get message from response
|
||||
message = Ghost.Views.Utils.getRequestErrorMessage(response);
|
||||
message += " " + Ghost.Views.Utils.getRequestErrorMessage(response);
|
||||
} else if (model.validationError) {
|
||||
// Grab a validation error
|
||||
message += "; " + model.validationError;
|
||||
message += " " + model.validationError;
|
||||
}
|
||||
|
||||
Ghost.notifications.addItem({
|
||||
|
|
Loading…
Add table
Reference in a new issue