Skip to content

Commit

Permalink
#5885 updated using new slider component
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Apr 19, 2024
1 parent 7802c25 commit a33f137
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 248 deletions.
173 changes: 0 additions & 173 deletions classes/components/forms/FieldRangeSlider.php

This file was deleted.

15 changes: 3 additions & 12 deletions classes/components/forms/FieldSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,20 @@ class FieldSlider extends Field
/** @copydoc Field::$component */
public $component = 'field-slider';


/**
* Range min value
*
* @var int|float
*/
public $min;
public int|float $min;

/**
* Range max value
*
* @var int|float
*/
public $max;
public int|float $max;

/**
* Range step value
*
* @var int|float
*/
public $step = 1;
public int|float $step = 1;

/**
* Label for min value, it displays actual value when not present
Expand All @@ -67,8 +60,6 @@ class FieldSlider extends Field
*/
public ?string $valueLabelMax = null;



/**
* @copydoc Field::getConfig()
*/
Expand Down
59 changes: 23 additions & 36 deletions classes/components/forms/context/PKPReviewSetupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use PKP\components\forms\FieldHTML;
use PKP\context\Context;
use PKP\components\forms\FieldOptions;
use PKP\components\forms\FieldRangeSlider;
use PKP\components\forms\FieldSlider;
use PKP\components\forms\FieldText;
use PKP\components\forms\FormComponent;
use PKP\config\Config;
Expand All @@ -38,9 +38,8 @@ class PKPReviewSetupForm extends FormComponent
protected const REVIEW_SETTINGS_GROUP = 'reviewSettingsGroup';
protected const REVIEW_REMINDER_GROUP = 'reviewReminderGroup';

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

/**
* Constructor
Expand Down Expand Up @@ -135,63 +134,51 @@ protected function addReminderFields(Context $context): static

$this
->addGroup([
'id' => self::REVIEW_REMINDER_GROUP
'id' => self::REVIEW_REMINDER_GROUP,
])
->addField(new FieldHTML('reminderForReview', [
'label' => __('manager.setup.reviewOptions.reminders'),
'description' => __('manager.setup.reviewOptions.reminders.description'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldHTML('reviewRequestResponseReminder', [
'label' => __('manager.setup.reviewOptions.reminders.response'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldRangeSlider('numDaysBeforeReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.description.before'),
->addField(new FieldSlider('numDaysBeforeReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.response.before'),
'value' => $context->getData('numDaysBeforeReviewResponseReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'onResetValue' => $context->getData('numDaysBeforeReviewResponseReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.before.days'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.before.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldRangeSlider('numDaysAfterReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.description.after'),
->addField(new FieldSlider('numDaysAfterReviewResponseReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.response.after'),
'value' => $context->getData('numDaysAfterReviewResponseReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'onResetValue' => $context->getData('numDaysAfterReviewResponseReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.after.days'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldHTML('submissionReviewResponseReminder', [
'label' => __('manager.setup.reviewOptions.reminders.submit'),
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.after.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldRangeSlider('numDaysBeforeReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.description.before'),
->addField(new FieldSlider('numDaysBeforeReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.submit.before'),
'value' => $context->getData('numDaysBeforeReviewSubmitReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'onResetValue' => $context->getData('numDaysBeforeReviewSubmitReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.before.days'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.before.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]))
->addField(new FieldRangeSlider('numDaysAfterReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.description.after'),
->addField(new FieldSlider('numDaysAfterReviewSubmitReminderDue', [
'label' => __('manager.setup.reviewOptions.reminders.submit.after'),
'value' => $context->getData('numDaysAfterReviewSubmitReminderDue'),
'min' => static::MIN_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'max' => static::MAX_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'onResetValue' => $context->getData('numDaysAfterReviewSubmitReminderDue') ?? static::DEFAULT_REMINDER_NOTIFICATION_SEND_IN_DAYS,
'updateLabel' => __('manager.setup.reviewOptions.reminders.description.after.days'),
'controlLabelOnDisable' => __('manager.setup.reviewOptions.reminders.enable'),
'controlLabelOnEnable' => __('manager.setup.reviewOptions.reminders.disable'),
'minLabel' => __('manager.setup.reviewOptions.reminders.min.label'),
'valueLabel' => __('manager.setup.reviewOptions.reminders.label.after.days'),
'valueLabelMin' => __('manager.setup.reviewOptions.reminders.disbale.label'),
'groupId' => self::REVIEW_REMINDER_GROUP,
]));

Expand Down
17 changes: 8 additions & 9 deletions classes/task/ReviewReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public function executeActions()
unset($context);
$context = $contextDao->getById($submission->getData('contextId'));

$numDaysBeforeReviewResponseReminderDue = $context->getData('numDaysBeforeReviewResponseReminderDue');
$numDaysAfterReviewResponseReminderDue = $context->getData('numDaysAfterReviewResponseReminderDue');
$numDaysBeforeReviewSubmitReminderDue = $context->getData('numDaysBeforeReviewSubmitReminderDue');
$numDaysAfterReviewSubmitReminderDue = $context->getData('numDaysAfterReviewSubmitReminderDue');
$numDaysBeforeReviewResponseReminderDue = (int) $context->getData('numDaysBeforeReviewResponseReminderDue');
$numDaysAfterReviewResponseReminderDue = (int) $context->getData('numDaysAfterReviewResponseReminderDue');
$numDaysBeforeReviewSubmitReminderDue = (int) $context->getData('numDaysBeforeReviewSubmitReminderDue');
$numDaysAfterReviewSubmitReminderDue = (int) $context->getData('numDaysAfterReviewSubmitReminderDue');
}

$mailable = null;
Expand All @@ -85,15 +85,14 @@ public function executeActions()

// after a REVIEW REQUEST has been responded, the value of `dateReminded` and `reminderWasAutomatic`
// get reset, see \PKP\submission\reviewer\ReviewerAction::confirmReview.
//
if ($reviewAssignment->getDateConfirmed() === null) {
// REVIEW REQUEST has not been responded
// only need to concern with BEFORE/AFTER REVIEW REQUEST RESPONSE reminder

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 ($numDaysBeforeReviewResponseReminderDue &&
if ($numDaysBeforeReviewResponseReminderDue > 0 &&
$dateResponseDue->gt($currentDate) &&
$dateResponseDue->diffInDays($currentDate) <= $numDaysBeforeReviewResponseReminderDue) {

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

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

if ($numDaysAfterReviewResponseReminderDue &&
if ($numDaysAfterReviewResponseReminderDue > 0 &&
$currentDate->gt($dateResponseDue) &&
$dateReminded->lt($dateResponseDue) &&
$currentDate->diffInDays($dateResponseDue) >= $numDaysAfterReviewResponseReminderDue) {
Expand All @@ -122,7 +121,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 ($numDaysBeforeReviewSubmitReminderDue &&
if ($numDaysBeforeReviewSubmitReminderDue > 0 &&
$currentDate->lt($dateDue) &&
$dateDue->diffInDays($currentDate) <= $numDaysBeforeReviewSubmitReminderDue) {

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

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

if ($numDaysAfterReviewSubmitReminderDue &&
if ($numDaysAfterReviewSubmitReminderDue > 0 &&
$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 @@ -79,7 +79,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 FieldRangeSlider from '@/components/Form/fields/FieldRangeSlider.vue';
import FieldPreparedContent from '@/components/Form/fields/FieldPreparedContent.vue';
import FieldPubId from '@/components/Form/fields/FieldPubId.vue';
import FieldRadioInput from '@/components/Form/fields/FieldRadioInput.vue';
Expand Down Expand Up @@ -176,7 +175,6 @@ VueRegistry.registerComponent('PkpFieldControlledVocab', FieldControlledVocab);
VueRegistry.registerComponent('PkpFieldHtml', FieldHtml);
VueRegistry.registerComponent('PkpFieldMetadataSetting', FieldMetadataSetting);
VueRegistry.registerComponent('PkpFieldOptions', FieldOptions);
VueRegistry.registerComponent('PkpFieldRangeSlider', FieldRangeSlider);
VueRegistry.registerComponent('PkpFieldPreparedContent', FieldPreparedContent);
VueRegistry.registerComponent('PkpFieldPubId', FieldPubId);
VueRegistry.registerComponent('PkpFieldRadioInput', FieldRadioInput);
Expand Down
Loading

0 comments on commit a33f137

Please sign in to comment.