Skip to content

Commit

Permalink
Merge pull request #6 from IQSS/submission_checklist_update
Browse files Browse the repository at this point in the history
Submission checklist update + email variables in activity log
  • Loading branch information
abujeda authored May 23, 2024
2 parents f0271c9 + b2a7bb3 commit 8f4444c
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 49 deletions.
9 changes: 9 additions & 0 deletions pprOjsPlugin/css/iqss.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ div.pkpPublication__header div.pkpHeader__actions{
/**
SUBMISSION
*/
#ppr_start_submissionChecklist label {
cursor: default;
}

#ppr_start_submissionChecklist ul {
list-style: revert;
padding: revert;
}

#ppr_confirmation_submissionChecklist {
font-size: .875rem;
line-height: 1.5rem;
Expand Down
1 change: 1 addition & 0 deletions pprOjsPlugin/services/PPRTemplateOverrideService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function __construct($plugin) {
}

if ($this->pprPlugin->getPluginSettings()->submissionConfirmationChecklistEnabled()) {
$this->overriddenTemplates[] = 'lib/pkp/templates/submission/form/step1.tpl';
$this->overriddenTemplates[] = 'lib/pkp/templates/submission/form/step4.tpl';
}

Expand Down
6 changes: 5 additions & 1 deletion pprOjsPlugin/services/email/PPRFirstNameEmailService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PPRFirstNameEmailService {
private $pprPlugin;
private $pprObjectFactory;

function __construct($plugin, $pprObjectFactory = null) {
public function __construct($plugin, $pprObjectFactory = null) {
$this->pprPlugin = $plugin;
$this->pprObjectFactory = $pprObjectFactory ?: new PPRObjectFactory();
$this->pprPlugin->import('util.PPRMissingUser');
Expand Down Expand Up @@ -91,7 +91,11 @@ function addPPRStageParticipantGridHandler($hookName, $hookArgs) {
function addFirstNamesToEmailTemplate($hookName, $arguments) {
$emailTemplate = $arguments[0];
if ($emailTemplate instanceof SubmissionMailTemplate && $this->isEmailSupported($emailTemplate->emailKey)) {
error_log("PPR[PPRFirstNameEmailService] processing emailTemplate={$emailTemplate->emailKey}");
$this->pprObjectFactory->firstNamesManagementService()->addFirstNamesToEmailTemplate($emailTemplate);
} else {
$emailKey = $emailTemplate->emailKey ?? 'N/A';
error_log("PPR[PPRFirstNameEmailService] notSupported emailTemplate={$emailKey}");
}

return false;
Expand Down
116 changes: 116 additions & 0 deletions pprOjsPlugin/templates/submission/form/step1.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{**
* templates/submission/form/step1.tpl
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* Step 1 of author submission process.
*}
<script type="text/javascript">
$(function() {ldelim}
// Attach the form handler.
$('#submitStep1Form').pkpHandler('$.pkp.pages.submission.SubmissionStep1FormHandler');
{rdelim});
</script>

<form class="pkp_form" id="submitStep1Form" method="post" action="{url op="saveStep" path=$submitStep}">
{csrf}
{if $submissionId}<input type="hidden" name="submissionId" value="{$submissionId|escape}"/>{/if}
<input type="hidden" name="submissionChecklist" value="1"/>

{include file="controllers/notification/inPlaceNotification.tpl" notificationId="submitStep1FormNotification"}

{fbvFormArea id="submissionStep1"}

{$additionalFormContent1}

{include file="submission/submissionLocale.tpl"}

{$additionalFormContent2}

{include file="submission/form/categories.tpl"}

{* PPR SUBMISSION CHECKLIST OVERRIDE *}
{* REMOVE CHECKBOXES => JUST DISPLAY THE CHECKLIST *}
{if $currentContext->getLocalizedData('submissionChecklist')}
{fbvFormSection list="true" label="submission.submit.submissionChecklist" description="submission.submit.submissionChecklistDescription" id="ppr_start_submissionChecklist"}
{foreach name=checklist from=$currentContext->getLocalizedData('submissionChecklist') key=checklistId item=checklistItem}
<li>
<label>{$checklistItem.content|nl2br}</label>
</li>
{* CHECKLIST ITEMS ARE COMPULSORY AND VALIDATED IN THE BACKEND *}
{fbvElement type="hidden" id="checklist-$checklistId" value=1}
{/foreach}
{/fbvFormSection}
{/if}
{* PPR SUBMISSION CHECKLIST OVERRIDE END *}

{* Cover Note To Editor*}
{fbvFormSection for="commentsToEditor" title="submission.submit.coverNote"}
{fbvElement type="textarea" name="commentsToEditor" id="commentsToEditor" value=$commentsToEditor rich=true}
{/fbvFormSection}

{* Submitting in which role? *}
{if $noExistingRoles}
{if count($userGroupOptions) > 1}
{fbvFormSection label="submission.submit.availableUserGroups" description="submission.submit.availableUserGroupsDescription" list=true required=true}
{foreach from=$userGroupOptions key="userGroupId" item="userGroupName"}
{if $defaultGroup->getId() == $userGroupId}{assign var="checked" value=true}{else}{assign var="checked" value=false}{/if}
{fbvElement type="radio" id="userGroup"|concat:$userGroupId name="userGroupId" value=$userGroupId checked=$checked label=$userGroupName translate=false}
{/foreach}
{/fbvFormSection}
{else}
{foreach from=$userGroupOptions key="userGroupId" item="userGroupName"}
{capture assign="onlyUserGroupId"}{$userGroupId}{/capture}
{/foreach}
{fbvFormSection label="submission.submit.contactConsent" list=true required=true}
{fbvElement type="checkbox" id="userGroupId" required=true value=$onlyUserGroupId label="submission.submit.contactConsentDescription"}
{/fbvFormSection}
{/if}

{* If user has existing roles, show available roles or automatically select single role *}
{else}
{if count($userGroupOptions) > 1}
{fbvFormSection label="submission.submit.availableUserGroups" list=true required=true}
{if $managerGroups}
{translate key='submission.submit.userGroupDescriptionManagers' managerGroups=$managerGroups}
{else}
{translate key='submission.submit.userGroupDescription'}
{/if}
{foreach from=$userGroupOptions key="userGroupId" item="userGroupName"}
{if $defaultGroup->getId() == $userGroupId}{assign var="checked" value=true}{else}{assign var="checked" value=false}{/if}
{fbvElement type="radio" id="userGroup"|concat:$userGroupId name="userGroupId" value=$userGroupId checked=$checked label=$userGroupName translate=false}
{/foreach}
{/fbvFormSection}
{elseif count($userGroupOptions) == 1}
{foreach from=$userGroupOptions key="userGroupId" item="authorUserGroupName"}{assign var=userGroupId value=$userGroupId}{/foreach}
{fbvElement type="hidden" id="userGroupId" value=$userGroupId}
{/if}
{/if}

{if $copyrightNotice}
{fbvFormSection title="submission.submit.copyrightNoticeAgreementLabel"}
{$copyrightNotice}
{fbvFormSection list="true"}
{fbvElement type="checkbox" id="copyrightNoticeAgree" required=true value=1 label="submission.submit.copyrightNoticeAgree" checked=$submissionId}
{/fbvFormSection}
{/fbvFormSection}
{/if}

{* Privacy Statement *}
{if $hasPrivacyStatement}
{fbvFormSection list="true"}
{capture assign="privacyUrl"}{url router=$smarty.const.ROUTE_PAGE page="about" op="privacy"}{/capture}
{capture assign="privacyLabel"}{translate key="user.register.form.privacyConsent" privacyUrl=$privacyUrl}{/capture}
{fbvElement type="checkbox" id="privacyConsent" required=true value=1 label=$privacyLabel translate=false checked=$privacyConsent}
{/fbvFormSection}
{/if}

{* Buttons *}
{fbvFormButtons id="step1Buttons" submitText="common.saveAndContinue"}

<p><span class="formRequired">{translate key="common.requiredField"}</span></p>
{/fbvFormArea}

</form>
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function test_expected_overridden_templates_for_each_setting() {
];

$expectedTemplatesForSetting['submissionConfirmationChecklistEnabled'] = [
'lib/pkp/templates/submission/form/step1.tpl',
'lib/pkp/templates/submission/form/step4.tpl',
];

Expand Down
40 changes: 30 additions & 10 deletions pprOjsPlugin/tests/src/util/PPRFirstNamesManagementServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ public function test_getReviewer_should_use_authorized_object_when_all_others_ar
$this->assertEquals($reviewer, $result);
}

public function test_getReviewer_should_not_break_when_request_handler_is_null() {
$submissionUtil = $this->createMock(PPRSubmissionUtil::class);
$this->getRequestMock()->method('getUserVar')->withConsecutive(['reviewerId'], ['reviewAssignmentId'])
->willReturnOnConsecutiveCalls(null, null);

$requestMock = $this->createMock(Request::class);
$router = $this->createMock(PKPRouter::class);
$router->expects($this->once())->method('getHandler')->willReturn(null);
$requestMock->method('getRouter')->willReturn($router);
Registry::set('request', $requestMock);

$target = new PPRFirstNamesManagementService($submissionUtil);
$result = $target->getReviewer(null);
$this->assertEquals(PPRMissingUser::defaultMissingUser(), $result);
}

public function test_getContributorsNames_should_return_author_first_name_when_emailContributors_is_null() {
$author = $this->getTestUtil()->createAuthor($this->getRandomId(), 'AuthorName', 'AuthorName');
$submission = $this->getTestUtil()->createSubmissionWithAuthors('PrimaryAuthorName', ['PrimaryAuthorName', 'ContributorName']);
Expand Down Expand Up @@ -161,16 +177,17 @@ public function test_addFirstNamesToEmailTemplate_should_not_update_mail_templat
public function test_addFirstNamesToEmailTemplate_should_add_author_editor_reviewer_names() {
$submissionUtil = $this->createMock(PPRSubmissionUtil::class);
$mailTemplate = $this->createSubmissionEmailTemplate();
$mailTemplate->expects($this->once())->method('getBody')->willReturn($this->createTextToReplace());
$mailTemplate->expects($this->once())->method('getSubject')->willReturn($this->createTextToReplace());

$this->addEditorAndAuthor($submissionUtil);
$reviewerId = $this->getRandomId();
$mailTemplate->method('getData')->with('reviewerId')->willReturn($reviewerId);
$this->addReviewer($submissionUtil, $reviewerId);

$mailTemplate->expects($this->exactly(11))->method('addPrivateParam')
->withConsecutive(
['{$authorName}', 'authorFullName'], ['{$authorFullName}', 'authorFullName'], ['{$authorFirstName}', 'authorFirstName'], ['{$contributorsNames}', 'authorFirstName'],
['{$editorName}', 'editorFullName'], ['{$editorFullName}', 'editorFullName'], ['{$editorFirstName}', 'editorFirstName'],
['{$reviewerName}', 'reviewerFullName'], ['{$reviewerFullName}', 'reviewerFullName'], ['{$reviewerFirstName}', 'reviewerFirstName'], ['{$firstNameOnly}', 'reviewerFirstName']);
$expectedText = 'Author: authorFullName - authorFullName - authorFirstName - authorFirstName, Editor: editorFullName - editorFullName - editorFirstName, Reviewer: reviewerFullName - reviewerFullName - reviewerFirstName - reviewerFirstName';
$mailTemplate->expects($this->once())->method('setBody')->with($expectedText);
$mailTemplate->expects($this->once())->method('setSubject')->with($expectedText);

$target = new PPRFirstNamesManagementService($submissionUtil);
$target->addFirstNamesToEmailTemplate($mailTemplate);
Expand All @@ -179,14 +196,17 @@ public function test_addFirstNamesToEmailTemplate_should_add_author_editor_revie
public function test_addFirstNamesToEmailTemplate_should_handle_missing_author_editor_and_reviewer() {
$submissionUtil = $this->createMock(PPRSubmissionUtil::class);
$mailTemplate = $this->createSubmissionEmailTemplate();
$mailTemplate->expects($this->once())->method('getBody')->willReturn($this->createTextToReplace());
$mailTemplate->expects($this->once())->method('getSubject')->willReturn($this->createTextToReplace());

$this->addEditorAndAuthor($submissionUtil, true);

$missingName = __('ppr.user.missing.name');
$mailTemplate->expects($this->exactly(11))->method('addPrivateParam')
->withConsecutive(
['{$authorName}', $missingName], ['{$authorFullName}', $missingName], ['{$authorFirstName}', $missingName], ['{$contributorsNames}', $missingName],
['{$editorName}', $missingName], ['{$editorFullName}', $missingName], ['{$editorFirstName}', $missingName],
['{$reviewerName}', $missingName], ['{$reviewerFullName}', $missingName], ['{$reviewerFirstName}', $missingName], ['{$firstNameOnly}', $missingName]);
$expectedText = sprintf('Author: %s - %s - %s - %s, Editor: %s - %s - %s, Reviewer: %s - %s - %s - %s',
$missingName, $missingName, $missingName, $missingName, $missingName, $missingName, $missingName, $missingName, $missingName, $missingName, $missingName);

$mailTemplate->expects($this->once())->method('setBody')->with($expectedText);
$mailTemplate->expects($this->once())->method('setSubject')->with($expectedText);

$target = new PPRFirstNamesManagementService($submissionUtil);
$target->addFirstNamesToEmailTemplate($mailTemplate);
Expand Down
Loading

0 comments on commit 8f4444c

Please sign in to comment.