From 93e8dd39d18d89c707d02e7a6735ff12aa01ac29 Mon Sep 17 00:00:00 2001 From: vagrant Date: Mon, 12 Sep 2022 15:19:48 +0000 Subject: [PATCH] pkp/pkp-lib#7165 Issue datePublished can be set when adding an issue --- classes/controllers/grid/issues/IssueGridHandler.php | 6 +++++- controllers/grid/issues/IssueGridRow.php | 8 ++++---- controllers/grid/issues/form/IssueForm.php | 9 ++++++++- locale/en_US/editor.po | 3 +++ templates/controllers/grid/issues/form/issueForm.tpl | 5 ++--- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/classes/controllers/grid/issues/IssueGridHandler.php b/classes/controllers/grid/issues/IssueGridHandler.php index ffeec182327..553c4c9c507 100644 --- a/classes/controllers/grid/issues/IssueGridHandler.php +++ b/classes/controllers/grid/issues/IssueGridHandler.php @@ -547,7 +547,11 @@ public function publishIssue($args, $request) } $issue->setPublished(1); - $issue->setDatePublished(Core::getCurrentDate()); + + // If no datePublished was given, use current date + if (!$issue->getData('datePublished')) { + $issue->setDatePublished(Core::getCurrentDate()); + } // If subscriptions with delayed open access are enabled then // update open access date according to open access delay policy diff --git a/controllers/grid/issues/IssueGridRow.php b/controllers/grid/issues/IssueGridRow.php index 7111da852ad..0d18ef34227 100644 --- a/controllers/grid/issues/IssueGridRow.php +++ b/controllers/grid/issues/IssueGridRow.php @@ -61,16 +61,16 @@ public function initialize($request, $template = null) $dispatcher = $request->getDispatcher(); $this->addAction( new LinkAction( - $issue->getDatePublished() ? 'viewIssue' : 'previewIssue', + $issue->getPublished() ? 'viewIssue' : 'previewIssue', new OpenWindowAction( $dispatcher->url($request, PKPApplication::ROUTE_PAGE, null, 'issue', 'view', [$issueId]) ), - __($issue->getDatePublished() ? 'grid.action.viewIssue' : 'grid.action.previewIssue'), + __($issue->getPublished() ? 'grid.action.viewIssue' : 'grid.action.previewIssue'), 'information' ) ); - if ($issue->getDatePublished()) { + if ($issue->getPublished()) { $this->addAction( new LinkAction( 'unpublish', @@ -109,7 +109,7 @@ public function initialize($request, $template = null) $currentIssue = Repo::issue()->getCurrent($issue->getJournalId()); $isCurrentIssue = $currentIssue != null && $issue->getId() == $currentIssue->getId(); - if ($issue->getDatePublished() && !$isCurrentIssue) { + if ($issue->getPublished() && !$isCurrentIssue) { $this->addAction( new LinkAction( 'setCurrentIssue', diff --git a/controllers/grid/issues/form/IssueForm.php b/controllers/grid/issues/form/IssueForm.php index fc51f41fd93..231a4a18f93 100644 --- a/controllers/grid/issues/form/IssueForm.php +++ b/controllers/grid/issues/form/IssueForm.php @@ -241,9 +241,16 @@ public function execute(...$functionArgs) $issue->setVolume(empty($volume) ? null : $volume); $issue->setNumber(empty($number) ? null : $number); $issue->setYear(empty($year) ? null : $year); - if (!$isNewIssue) { + + // If issue is not published, allow empty datePublished + if (!$this->getData('datePublished') && !$issue->getPublished()) { + $issue->setDatePublished(null); + } + + if ($this->getData('datePublished')) { $issue->setDatePublished($this->getData('datePublished')); } + $issue->setDescription($this->getData('description'), null); // Localized $issue->setShowVolume((int) $this->getData('showVolume')); $issue->setShowNumber((int) $this->getData('showNumber')); diff --git a/locale/en_US/editor.po b/locale/en_US/editor.po index 723b6b9ca4a..fb6d5e1b1d1 100644 --- a/locale/en_US/editor.po +++ b/locale/en_US/editor.po @@ -120,6 +120,9 @@ msgstr "Unpublished" msgid "editor.issues.datePublished" msgstr "Date Published" +msgid "editor.issues.datePublished.notPublished.description" +msgstr "Leave this empty and it will be set automatically when the issue is published." + msgid "editor.issues.volumeRequired" msgstr "Volume is required and must be a positive, numeric value." diff --git a/templates/controllers/grid/issues/form/issueForm.tpl b/templates/controllers/grid/issues/form/issueForm.tpl index aa4d0f8c72f..45a6ef9b3ce 100644 --- a/templates/controllers/grid/issues/form/issueForm.tpl +++ b/templates/controllers/grid/issues/form/issueForm.tpl @@ -41,16 +41,15 @@ {assign var=issuePublished value=false} {/if} - {if $issuePublished} {fbvFormArea id="datePublishedArea" title="editor.issues.datePublished"} {fbvFormSection} {if $issuePublished} {fbvElement type="text" id="datePublished" value=$datePublished size=$fbvStyles.size.SMALL class="datepicker"} + {else} + {fbvElement type="text" id="datePublished" value=$datePublished size=$fbvStyles.size.SMALL class="datepicker" label="editor.issues.datePublished.notPublished.description"} {/if} {/fbvFormSection} {/fbvFormArea} - {/if} - {fbvFormArea id="identificationArea" title="editor.issues.identification"} {fbvFormSection}