From cee320bb58433feeb7160a75fd0d1459d6951db0 Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Tue, 23 May 2017 22:30:00 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20Reset=20publish=20date=20in?= =?UTF-8?q?=20PSM=20when=20leaving=20menu=20(#708)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- ghost/admin/app/components/gh-publishmenu-scheduled.js | 7 +++++-- ghost/admin/app/components/gh-publishmenu.js | 6 ++++++ ghost/admin/app/templates/components/gh-publishmenu.hbs | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/gh-publishmenu-scheduled.js b/ghost/admin/app/components/gh-publishmenu-scheduled.js index ee8375bf36..21cf4ea5cf 100644 --- a/ghost/admin/app/components/gh-publishmenu-scheduled.js +++ b/ghost/admin/app/components/gh-publishmenu-scheduled.js @@ -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(); + } } } }); diff --git a/ghost/admin/app/components/gh-publishmenu.js b/ghost/admin/app/components/gh-publishmenu.js index 8b81607b7c..1d199ce8dc 100644 --- a/ghost/admin/app/components/gh-publishmenu.js +++ b/ghost/admin/app/components/gh-publishmenu.js @@ -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; } } diff --git a/ghost/admin/app/templates/components/gh-publishmenu.hbs b/ghost/admin/app/templates/components/gh-publishmenu.hbs index 66b29ada9c..32bb8d43ae 100644 --- a/ghost/admin/app/templates/components/gh-publishmenu.hbs +++ b/ghost/admin/app/templates/components/gh-publishmenu.hbs @@ -13,6 +13,7 @@ {{gh-publishmenu-scheduled post=post saveType=saveType + isClosing=isClosing setSaveType=(action "setSaveType")}} {{else}}