From e69a9359827926b56b8f8430f133e2d637ba592c Mon Sep 17 00:00:00 2001 From: ValenberghsSven Date: Fri, 19 Mar 2021 12:09:53 +0100 Subject: [PATCH] KAS-2160 fix translation date not selectable --- app/pods/publications/publication/controller.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/pods/publications/publication/controller.js b/app/pods/publications/publication/controller.js index 39352b2ae4..1146b795a6 100644 --- a/app/pods/publications/publication/controller.js +++ b/app/pods/publications/publication/controller.js @@ -177,7 +177,13 @@ export default class PublicationController extends Controller { return true; } } - const end = moment(this.model.publicationFlow.get('publishBefore')); + // If there is no publishBefore, allow all future dates + const publishBefore = this.model.publicationFlow.get('publishBefore'); + if (!publishBefore && moment(date).isSameOrAfter(moment())) { + return true; + } + // If there is a publishbefore, only allow dates between now and that date + const end = moment(publishBefore); if (moment(date).isSameOrBefore(end) && moment(date).isSameOrAfter(moment())) { return true; } @@ -312,7 +318,7 @@ export default class PublicationController extends Controller { set(this, 'showTranslationDatePicker', false); const date = moment(new Date(event)); const translateBefore = this.model.publicationFlow.get('translateBefore'); - if (typeof translateBefore !== undefined && !moment(translateBefore).isSameOrBefore(date, 'minutes')) { + if (translateBefore !== undefined && !moment(translateBefore).isSameOrBefore(date, 'minutes')) { this.publicationNotAfterTranslationForPublication = true; this.toaster.error(this.intl.t('publication-date-after-translation-date'), this.intl.t('warning-title'), { timeOut: 5000, @@ -351,7 +357,7 @@ export default class PublicationController extends Controller { set(this, 'showTranslationDatePicker', false); const date = moment(new Date(event)); const publishBefore = this.model.publicationFlow.get('publishBefore'); - if (typeof publishBefore !== undefined && !moment(date).isSameOrBefore(publishBefore)) { + if (publishBefore !== undefined && !moment(date).isSameOrBefore(publishBefore)) { this.publicationNotAfterTranslationForTranslation = true; this.toaster.error(this.intl.t('publication-date-after-translation-date'), this.intl.t('warning-title'), { timeOut: 5000,