mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Clear notifications before adding new ones
closes #783 - I think there's probably a nicer solution than putting clearEverything() everywhere, but that would also probably involve significant refactoring.
This commit is contained in:
parent
60bb02ad6a
commit
00b60a7a74
4 changed files with 17 additions and 19 deletions
|
@ -44,6 +44,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Ghost.Validate.handleErrors = function () {
|
Ghost.Validate.handleErrors = function () {
|
||||||
|
Ghost.notifications.clearEverything();
|
||||||
_.each(Ghost.Validate._errors, function (errorObj) {
|
_.each(Ghost.Validate._errors, function (errorObj) {
|
||||||
|
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
|
|
|
@ -193,15 +193,7 @@
|
||||||
this.renderItem(item);
|
this.renderItem(item);
|
||||||
},
|
},
|
||||||
clearEverything: function () {
|
clearEverything: function () {
|
||||||
var height = this.$('.js-notification').outerHeight(true),
|
this.$el.find('.js-notification.notification-passive').remove();
|
||||||
self = this;
|
|
||||||
this.$el.css({height: height});
|
|
||||||
this.$el.find('.js-notification.notification-passive').fadeOut(250, function () {
|
|
||||||
$(this).remove();
|
|
||||||
self.$el.slideUp(250, function () {
|
|
||||||
$(this).show().css({height: "auto"});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
removeItem: function (e) {
|
removeItem: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -120,11 +120,7 @@
|
||||||
this.savePost({
|
this.savePost({
|
||||||
status: keys[newIndex]
|
status: keys[newIndex]
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
Ghost.notifications.addItem({
|
self.reportSaveSuccess(status);
|
||||||
type: 'success',
|
|
||||||
message: self.notificationMap[status],
|
|
||||||
status: 'passive'
|
|
||||||
});
|
|
||||||
}, function (xhr) {
|
}, function (xhr) {
|
||||||
// Show a notification about the error
|
// Show a notification about the error
|
||||||
self.reportSaveError(xhr, model, status);
|
self.reportSaveError(xhr, model, status);
|
||||||
|
@ -188,11 +184,7 @@
|
||||||
this.savePost({
|
this.savePost({
|
||||||
status: status
|
status: status
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
Ghost.notifications.addItem({
|
self.reportSaveSuccess(status);
|
||||||
type: 'success',
|
|
||||||
message: self.notificationMap[status],
|
|
||||||
status: 'passive'
|
|
||||||
});
|
|
||||||
// Refresh publish button and all relevant controls with updated status.
|
// Refresh publish button and all relevant controls with updated status.
|
||||||
self.render();
|
self.render();
|
||||||
}, function (xhr) {
|
}, function (xhr) {
|
||||||
|
@ -224,6 +216,15 @@
|
||||||
return $.Deferred().reject();
|
return $.Deferred().reject();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
reportSaveSuccess: function (status) {
|
||||||
|
Ghost.notifications.clearEverything();
|
||||||
|
Ghost.notifications.addItem({
|
||||||
|
type: 'success',
|
||||||
|
message: this.notificationMap[status],
|
||||||
|
status: 'passive'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
reportSaveError: function (response, model, status) {
|
reportSaveError: function (response, model, status) {
|
||||||
var message = this.errorMap[status];
|
var message = this.errorMap[status];
|
||||||
|
|
||||||
|
@ -235,6 +236,7 @@
|
||||||
message += " " + model.validationError;
|
message += " " + model.validationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ghost.notifications.clearEverything();
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: message,
|
message: message,
|
||||||
|
|
|
@ -116,6 +116,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveSuccess: function (model, response, options) {
|
saveSuccess: function (model, response, options) {
|
||||||
|
Ghost.notifications.clearEverything();
|
||||||
// TODO: better messaging here?
|
// TODO: better messaging here?
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
@ -124,6 +125,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveError: function (model, xhr) {
|
saveError: function (model, xhr) {
|
||||||
|
Ghost.notifications.clearEverything();
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
|
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
|
||||||
|
@ -131,6 +133,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
validationError: function (message) {
|
validationError: function (message) {
|
||||||
|
Ghost.notifications.clearEverything();
|
||||||
Ghost.notifications.addItem({
|
Ghost.notifications.addItem({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: message,
|
message: message,
|
||||||
|
|
Loading…
Add table
Reference in a new issue