🐛 Reset publish date in PSM when leaving menu (#708)

closes TryGhost/Ghost#8360
- when changing the publish time of an already scheduled post in the publish menu and leaving the menu with clicking outside of the menu, the time wouldn't reset properly and be shown in the PSM. With the usage of an `isClosing` property which is passed to the underlying `gh-publishmenu-scheduling` component, we prevent the changed time from being saved and reset it properly instead.
This commit is contained in:
Aileen Nowak 2017-05-23 22:30:00 +09:00 committed by Kevin Ansfield
parent 177c693af8
commit cee320bb58
3 changed files with 12 additions and 2 deletions

View File

@ -8,6 +8,7 @@ export default Component.extend({
post: null,
saveType: null,
isClosing: null,
// used to set minDate in datepicker
_minDate: null,
@ -60,8 +61,10 @@ export default Component.extend({
setTime(time) {
let post = this.get('post');
post.set('publishedAtBlogTime', time);
return post.validate();
if (!this.get('isClosing')) {
post.set('publishedAtBlogTime', time);
return post.validate();
}
}
}
});

View File

@ -13,6 +13,8 @@ export default Component.extend({
_publishedAtBlogTZ: null,
isClosing: null,
forcePublishedMenu: reads('post.pastScheduledTime'),
postState: computed('post.{isPublished,isScheduled}', 'forcePublishedMenu', function () {
@ -91,6 +93,7 @@ export default Component.extend({
open() {
this._cachePublishedAtBlogTZ();
this.set('isClosing', false);
this.get('post.errors').clear();
if (this.get('onOpen')) {
this.get('onOpen')();
@ -113,6 +116,9 @@ export default Component.extend({
if (this.get('onClose')) {
this.get('onClose')();
}
this.set('isClosing', true);
return true;
}
}

View File

@ -13,6 +13,7 @@
{{gh-publishmenu-scheduled
post=post
saveType=saveType
isClosing=isClosing
setSaveType=(action "setSaveType")}}
{{else}}