Skip to content

Commit

Permalink
pkp#4787 added an ugly work around to fix tinymce content flicker add…
Browse files Browse the repository at this point in the history
…ing existing reviewer from side panel
  • Loading branch information
touhidurabir committed Dec 24, 2024
1 parent 8c1a966 commit fc868dc
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function rules(): array
],
'familyName' => [
'required',
// 'multilingual:en,fr_CA', // Alternative way to do multilingual validation
// 'multilingual:en,fr_CA', // Alternative way to do multilingual validation, do not use HasMultilingualRule trait with this approach
],
'givenName' => [
'required',
Expand Down
4 changes: 2 additions & 2 deletions classes/core/ValidationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @class ValidationServiceProvider
*
* @brief Register session driver, manager and related services
* @brief Extends the core validation service provider
*/

namespace PKP\core;
Expand All @@ -29,7 +29,7 @@ class ValidationServiceProvider extends \Illuminate\Validation\ValidationService
* Boot service provider
*
* A good place to add any custom validation rules which will be availbale once the
* Service provider get registered
* service provider get registered
*
* @return void
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ public function fetch($request, $template = null, $display = false)
// Used to determine the right email template
$templateMgr->assign('lastRoundReviewerIds', $lastRoundReviewerIds);

if ($this->reviewerSuggestion?->existingReviewerRole) {
$templateMgr->assign('reviewerName', $this->reviewerSuggestion->existingUser->getFullName());
}

$selectReviewerListPanel->set([
'items' => $selectReviewerListPanel->getItems($request),
'itemsMax' => $selectReviewerListPanel->getItemsMax(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/**
* @file js/controllers/AdvancedReviewerSearchHandler.js
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class AdvancedReviewerSearchHandler
Expand Down Expand Up @@ -46,7 +46,7 @@
this.initializeTinyMCE();
this.handleReviewerAssign_($container, options, {
id: $container.find('input#reviewerId').val(),
fullName: 'some name'
fullName: options.reviewerName
});
}
};
Expand All @@ -69,7 +69,7 @@
*/
$.pkp.controllers.grid.users.reviewer.AdvancedReviewerSearchHandler.prototype.
handleRefresh_ = function(sourceElement, event, content) {

if (content) {
this.replaceWith(content);
}
Expand All @@ -87,7 +87,8 @@
$templateInput,
$templateOption,
editor,
templateKey;
templateKey,
templateContent;

if ($textarea.val()) {
return; // The message is already set; shouldn't happen
Expand All @@ -100,22 +101,31 @@
$templateOption = $('#reviewerFormFooter select[name="template"]');

editor = tinyMCE.EditorManager.get($textarea.attr('id'));
// console.log(editor);
templateKey = '';

if (options.lastRoundReviewerIds.includes(reviewer.id)) {
templateKey = 'REVIEW_REQUEST_SUBSEQUENT';
editor.setContent(options.reviewerMessages[templateKey]);
templateContent = options.reviewerMessages[templateKey];
editor.setContent(templateContent);
$templateInput.val(templateKey);
$templateOption.find('[value="REVIEW_REQUEST"]').remove();
} else {
templateKey = 'REVIEW_REQUEST';
// console.log(options.reviewerMessages[templateKey]);
editor.setContent(options.reviewerMessages[templateKey]);
templateContent = options.reviewerMessages[templateKey];
editor.setContent(templateContent);
$templateInput.val(templateKey);
$templateOption.find('[value="REVIEW_REQUEST_SUBSEQUENT"]').remove();
}

// TODO : an ugly work around to handle the empty editor issue after a flicker,
// need some help to figure it out.
setTimeout(() => {
console.log(editor.getContent().length);
if (!editor.getContent().length) {
editor.setContent(templateContent);
}
}, 2000);

// Select the right template option to correspond
// the one, which is set in TinyMCE
$templateOption.find('[value="' + templateKey + '"]').prop('selected', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
'$.pkp.controllers.grid.users.reviewer.AdvancedReviewerSearchHandler',
{ldelim}
lastRoundReviewerIds: {$lastRoundReviewerIds|json_encode},
reviewerMessages: {$reviewerMessages|json_encode}
reviewerMessages: {$reviewerMessages|json_encode},
reviewerName : {$reviewerName|json_encode}
{rdelim}
);
{rdelim});
</script>

<div id="advancedReviewerSearch" class="pkp_form pkp_form_advancedReviewerSearch">
{if isset($reviewerId) }
{include file="controllers/grid/users/reviewer/form/advancedSearchReviewerAssignmentForm.tpl"}
{else}
{if !isset($reviewerId) }
<div id="searchGridAndButton">
{assign var="uuid" value=""|uniqid|escape}
<div id="select-reviewer-{$uuid}">
Expand All @@ -43,26 +42,28 @@
{/foreach}
{/fbvFormSection}
</div>
{/if}

<div id="regularReviewerForm" class="pkp_reviewer_form">
{** Display the name of the selected reviewer **}
<div class="selected_reviewer">
<div class="label">
{translate key="editor.submission.selectedReviewer"}
</div>
<div class="value">
<span id="selectedReviewerName" class="name"></span>
<div id="regularReviewerForm" class="pkp_reviewer_form">
{** Display the name of the selected reviewer **}
<div class="selected_reviewer">
<div class="label">
{translate key="editor.submission.selectedReviewer"}
</div>
<div class="value">
<span id="selectedReviewerName" class="name"></span>
{if !isset($reviewerId) }
<span class="actions">
{foreach from=$reviewerActions item=action}
{if $action->getId() == 'advancedSearch'}
{include file="linkAction/linkAction.tpl" action=$action contextId="createReviewerForm"}
{/if}
{/foreach}
</span>
</div>
{/if}
</div>

{include file="controllers/grid/users/reviewer/form/advancedSearchReviewerAssignmentForm.tpl"}
</div>
{/if}

{include file="controllers/grid/users/reviewer/form/advancedSearchReviewerAssignmentForm.tpl"}
</div>
</div>

0 comments on commit fc868dc

Please sign in to comment.