Skip to content

Commit

Permalink
#5885 removed unnecessary fields and controls with field range compon…
Browse files Browse the repository at this point in the history
…ent enhancement
  • Loading branch information
touhidurabir committed Mar 14, 2024
1 parent 5d18012 commit c2a1432
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 150 deletions.
67 changes: 0 additions & 67 deletions classes/components/forms/FieldCheckbox.php

This file was deleted.

66 changes: 59 additions & 7 deletions classes/components/forms/FieldRangeSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class FieldRangeSlider extends Field
*/
public $disable = false;

/**
* Should the range slider be disable if input field value set to NULL on render
*
* @var bool
*/
public $disableOnNull = true;

/**
* Range min value
*
Expand All @@ -53,6 +60,13 @@ class FieldRangeSlider extends Field
*/
public $step = 1;

/**
* Range value on reset
*
* @var int|float|null
*/
public $onResetValue;

/**
* Range input size
*
Expand Down Expand Up @@ -81,6 +95,27 @@ class FieldRangeSlider extends Field
*/
public $valuePositionInUpdateLabel = 'before';

/**
* Allow the slider range disbale/enable ability
*
* @var bool
*/
public $allowStateToggle = true;

/**
* Show the label text when range slider is disable
*
* @var string
*/
public $controlLabelOnDisable;

/**
* Show the label text when range slider is disable
*
* @var string
*/
public $controlLabelOnEnable;

/**
* @copydoc Field::getConfig()
*/
Expand Down Expand Up @@ -108,14 +143,31 @@ public function getConfig()

$config = parent::getConfig();

if (!isset($this->controlLabelOnDisable)) {
$this->controlLabelOnDisable = __('common.enable');
}

if (!isset($this->controlLabelOnEnable)) {
$this->controlLabelOnEnable = __('common.disable');
}

if (!isset($this->onResetValue)) {
$this->onResetValue = $this->value ?? $this->default ?? null;
}

return array_merge($config, [
'disable' => $this->disable,
'options' => $this->options,
'max' => $this->max,
'min' => $this->min,
'size' => $this->size,
'step' => $this->step,
'updateLabel' => $this->updateLabel,
'disable' => $this->disable,
'disableOnNull' => $this->disableOnNull,
'options' => $this->options,
'max' => $this->max,
'min' => $this->min,
'size' => $this->size,
'step' => $this->step,
'onResetValue' => $this->onResetValue,
'updateLabel' => $this->updateLabel,
'allowStateToggle' => $this->allowStateToggle,
'controlLabelOnDisable' => $this->controlLabelOnDisable,
'controlLabelOnEnable' => $this->controlLabelOnEnable,
]);
}
}
59 changes: 22 additions & 37 deletions classes/components/forms/context/PKPReviewSetupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace PKP\components\forms\context;

use PKP\components\forms\FieldCheckbox;
use PKP\components\forms\FieldHTML;
use PKP\context\Context;
use PKP\components\forms\FieldOptions;
Expand All @@ -41,6 +40,7 @@ class PKPReviewSetupForm extends FormComponent

public const MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS = 1;
public const MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS = 14;
public const DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS = 7;

/**
* Constructor
Expand All @@ -60,6 +60,9 @@ public function __construct($action, $locales, $context)
->addReminderDisbaleNoticeField($context);
}

/**
* Add the default review control fields
*/
protected function addDefaultFields(Context $context): static
{
$this
Expand Down Expand Up @@ -121,6 +124,9 @@ protected function addDefaultFields(Context $context): static
return $this;
}

/**
* Add the review reminder control fields
*/
protected function addReminderFields(Context $context): static
{
if (!Config::getVar('general', 'scheduled_tasks')) {
Expand All @@ -145,33 +151,21 @@ protected function addReminderFields(Context $context): static
'value' => $context->getData('numDaysBeforeReviewResponseReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'size' => 'normal',
'onResetValue' => $context->getData('numDaysBeforeReviewResponseReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.before.days'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldCheckbox('enableBeforeReviewResponseReminder', [
'label' => __('manager.setup.reviewOptions.reminders.disable'),
'value' => (bool)$context->getData('enableBeforeReviewResponseReminder'),
'viewAsButton' => true,
'checkedLabel' => __('manager.setup.reviewOptions.reminders.disable'),
'uncheckedLabel' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldRangeSlider('numDaysAfterReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.description.after'),
'value' => $context->getData('numDaysAfterReviewResponseReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'size' => 'normal',
'onResetValue' => $context->getData('numDaysAfterReviewResponseReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.after.days'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldCheckbox('enableAfterReviewResponseReminder', [
'label' => __('manager.setup.reviewOptions.reminders.disable'),
'value' => (bool)$context->getData('enableAfterReviewResponseReminder'),
'viewAsButton' => true,
'checkedLabel' => __('manager.setup.reviewOptions.reminders.disable'),
'uncheckedLabel' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldHTML('submissionReviewResponseReminder', [
Expand All @@ -183,39 +177,30 @@ protected function addReminderFields(Context $context): static
'value' => $context->getData('numDaysBeforeReviewSubmitReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'size' => 'normal',
'onResetValue' => $context->getData('numDaysBeforeReviewSubmitReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.before.days'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldCheckbox('enableBeforeReviewSubmitReminder', [
'label' => __('manager.setup.reviewOptions.reminders.disable'),
'value' => (bool)$context->getData('enableBeforeReviewSubmitReminder'),
'viewAsButton' => true,
'checkedLabel' => __('manager.setup.reviewOptions.reminders.disable'),
'uncheckedLabel' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldRangeSlider('numDaysAfterReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.description.after'),
'value' => $context->getData('numDaysAfterReviewSubmitReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'size' => 'normal',
'onResetValue' => $context->getData('numDaysAfterReviewSubmitReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.after.days'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldCheckbox('enableAfterReviewSubmitReminder', [
'label' => __('manager.setup.reviewOptions.reminders.disable'),
'value' => (bool)$context->getData('enableAfterReviewSubmitReminder'),
'viewAsButton' => true,
'checkedLabel' => __('manager.setup.reviewOptions.reminders.disable'),
'uncheckedLabel' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]));

return $this;
}

/**
* Add a html note section instructing how to enable review reminder control fields
*/
protected function addReminderDisbaleNoticeField(Context $context): static
{
if (Config::getVar('general', 'scheduled_tasks')) {
Expand Down
17 changes: 4 additions & 13 deletions classes/task/ReviewReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public function executeActions()
unset($context);
$context = $contextDao->getById($submission->getData('contextId'));

$enableBeforeReviewResponseReminder = $context->getData('enableBeforeReviewResponseReminder');
$enableAfterReviewResponseReminder = $context->getData('enableAfterReviewResponseReminder');
$enableBeforeReviewSubmitReminder = $context->getData('enableBeforeReviewSubmitReminder');
$enableAfterReviewSubmitReminder = $context->getData('enableAfterReviewSubmitReminder');

$numDaysBeforeReviewResponseReminderDue = $context->getData('numDaysBeforeReviewResponseReminderDue');
$numDaysAfterReviewResponseReminderDue = $context->getData('numDaysAfterReviewResponseReminderDue');
$numDaysBeforeReviewSubmitReminderDue = $context->getData('numDaysBeforeReviewSubmitReminderDue');
Expand All @@ -98,8 +93,7 @@ public function executeActions()
if ($reviewAssignment->getDateReminded() === null) {
// There has not been any reminder sent yet
// need to check should we sent a BEFORE REVIEW REQUEST RESPONSE reminder
if ($enableBeforeReviewResponseReminder &&
$numDaysBeforeReviewResponseReminderDue &&
if ($numDaysBeforeReviewResponseReminderDue &&
$dateResponseDue->gt($currentDate) &&
$dateResponseDue->diffInDays($currentDate) <= $numDaysBeforeReviewResponseReminderDue) {

Expand All @@ -112,8 +106,7 @@ public function executeActions()

$dateReminded = Carbon::parse($reviewAssignment->getDateReminded());

if ($enableAfterReviewResponseReminder &&
$numDaysAfterReviewResponseReminderDue &&
if ($numDaysAfterReviewResponseReminderDue &&
$currentDate->gt($dateResponseDue) &&
$dateReminded->lt($dateResponseDue) &&
$currentDate->diffInDays($dateResponseDue) >= $numDaysAfterReviewResponseReminderDue) {
Expand All @@ -129,8 +122,7 @@ public function executeActions()
if ($reviewAssignment->getDateReminded() === null) {
// There has not been any reminder sent after responding to REVIEW REQUEST
// no REVIEW SUBMIT reminder has been sent
if ($enableBeforeReviewSubmitReminder &&
$numDaysBeforeReviewSubmitReminderDue &&
if ($numDaysBeforeReviewSubmitReminderDue &&
$currentDate->lt($dateDue) &&
$dateDue->diffInDays($currentDate) <= $numDaysBeforeReviewSubmitReminderDue) {

Expand All @@ -143,8 +135,7 @@ public function executeActions()

$dateReminded = Carbon::parse($reviewAssignment->getDateReminded());

if ($enableAfterReviewSubmitReminder &&
$numDaysAfterReviewSubmitReminderDue &&
if ($numDaysAfterReviewSubmitReminderDue &&
$currentDate->gt($dateDue) &&
$dateReminded->lt($dateDue) &&
$currentDate->diffInDays($dateDue) >= $numDaysAfterReviewSubmitReminderDue) {
Expand Down
2 changes: 0 additions & 2 deletions js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ import FieldControlledVocab from '@/components/Form/fields/FieldControlledVocab.
import FieldHtml from '@/components/Form/fields/FieldHtml.vue';
import FieldMetadataSetting from '@/components/Form/fields/FieldMetadataSetting.vue';
import FieldOptions from '@/components/Form/fields/FieldOptions.vue';
import FieldCheckbox from '@/components/Form/fields/FieldCheckbox.vue';
import FieldRangeSlider from '@/components/Form/fields/FieldRangeSlider.vue';
import FieldPreparedContent from '@/components/Form/fields/FieldPreparedContent.vue';
import FieldPubId from '@/components/Form/fields/FieldPubId.vue';
Expand Down Expand Up @@ -173,7 +172,6 @@ VueRegistry.registerComponent('PkpFieldControlledVocab', FieldControlledVocab);
VueRegistry.registerComponent('PkpFieldHtml', FieldHtml);
VueRegistry.registerComponent('PkpFieldMetadataSetting', FieldMetadataSetting);
VueRegistry.registerComponent('PkpFieldOptions', FieldOptions);
VueRegistry.registerComponent('PkpFieldCheckbox', FieldCheckbox);
VueRegistry.registerComponent('PkpFieldRangeSlider', FieldRangeSlider);
VueRegistry.registerComponent('PkpFieldPreparedContent', FieldPreparedContent);
VueRegistry.registerComponent('PkpFieldPubId', FieldPubId);
Expand Down
24 changes: 0 additions & 24 deletions schemas/context.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,30 +539,6 @@
"min:0"
]
},
"enableBeforeReviewResponseReminder": {
"type": "boolean",
"validation": [
"nullable"
]
},
"enableAfterReviewResponseReminder": {
"type": "boolean",
"validation": [
"nullable"
]
},
"enableBeforeReviewSubmitReminder": {
"type": "boolean",
"validation": [
"nullable"
]
},
"enableAfterReviewSubmitReminder": {
"type": "boolean",
"validation": [
"nullable"
]
},
"numPageLinks": {
"type": "integer",
"default": 10,
Expand Down

0 comments on commit c2a1432

Please sign in to comment.