From 9665558b25eb127f874d039c8e015f17cc93b8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Tue, 2 Apr 2024 15:22:04 +0200 Subject: [PATCH 1/2] pkp/pkp-lib#9857 FieldSlider --- classes/components/forms/FieldSlider.php | 78 +++++++++++++++++++ .../forms/dashboard/SubmissionFilters.php | 17 ++++ js/load.js | 8 ++ 3 files changed, 103 insertions(+) create mode 100644 classes/components/forms/FieldSlider.php diff --git a/classes/components/forms/FieldSlider.php b/classes/components/forms/FieldSlider.php new file mode 100644 index 00000000000..97985274fca --- /dev/null +++ b/classes/components/forms/FieldSlider.php @@ -0,0 +1,78 @@ +min; + $config['max'] = $this->max; + $config['minLabel'] = $this->minLabel; + $config['maxLabel'] = $this->maxLabel; + $config['valueLabel'] = $this->valueLabel; + $config['valueLabelMin'] = $this->valueLabelMin; + $config['valueLabelMax'] = $this->valueLabelMax; + + return $config; + } + +} diff --git a/classes/components/forms/dashboard/SubmissionFilters.php b/classes/components/forms/dashboard/SubmissionFilters.php index 6875c77a16b..92f7370b19a 100644 --- a/classes/components/forms/dashboard/SubmissionFilters.php +++ b/classes/components/forms/dashboard/SubmissionFilters.php @@ -21,6 +21,7 @@ use Illuminate\Support\LazyCollection; use PKP\components\forms\FieldAutosuggestPreset; use PKP\components\forms\FieldOptions; +use PKP\components\forms\FieldSlider; use PKP\components\forms\FieldSelectUsers; use PKP\components\forms\FormComponent; use PKP\context\Context; @@ -50,6 +51,7 @@ public function __construct( ->addAssignedTo() ->addIssues() ->addCategories() + ->addDaysSinceLastActivity() ; } @@ -157,4 +159,19 @@ protected function addCategories(): self return $this->addField(new FieldOptions('categoryIds', $props)); } + + protected function addDaysSinceLastActivity(): self + { + $props = [ + 'min' => 0, + 'max' => 180, + 'label' => __('submission.list.daysSinceLastActivity'), + 'value' => 0, + 'groupId' => 'default', + + ]; + + return $this->addField(new FieldSlider('daysInactive', $props)); + + } } diff --git a/js/load.js b/js/load.js index a91ce652cff..3b875fb2467 100644 --- a/js/load.js +++ b/js/load.js @@ -17,6 +17,8 @@ import GlobalMixins from '@/mixins/global.js'; import VueAnnouncer from '@vue-a11y/announcer'; import FloatingVue from 'floating-vue'; +import PrimeVue from 'primevue/config'; + import VueScrollTo from 'vue-scrollto'; import emitter from 'tiny-emitter/instance'; @@ -92,6 +94,8 @@ import FieldText from '@/components/Form/fields/FieldText.vue'; import FieldTextarea from '@/components/Form/fields/FieldTextarea.vue'; import FieldUpload from '@/components/Form/fields/FieldUpload.vue'; import FieldUploadImage from '@/components/Form/fields/FieldUploadImage.vue'; +import FieldSlider from '@/components/Form/fields/FieldSlider.vue'; + import VueHighlightJS from 'vue3-highlightjs'; import 'highlight.js/styles/default.css'; @@ -192,6 +196,7 @@ VueRegistry.registerComponent('PkpFieldText', FieldText); VueRegistry.registerComponent('PkpFieldTextarea', FieldTextarea); VueRegistry.registerComponent('PkpFieldUpload', FieldUpload); VueRegistry.registerComponent('PkpFieldUploadImage', FieldUploadImage); +VueRegistry.registerComponent('PkpFieldSlider', FieldSlider); // Required by the URN plugin, to be migrated at some point to pkp prefix VueRegistry.registerComponent('field-text', FieldText); @@ -206,6 +211,9 @@ function pkpCreateVueApp(createAppArgs) { // Initialize Vue const vueApp = createApp(createAppArgs); vueApp.use(pinia); + vueApp.use(PrimeVue, { + unstyled: true, + }); // https://github.com/vuejs/pinia/discussions/1197 // to be able globally share stores From 94229ac0d58a6ebe127eb916fcf4df648333f6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Tue, 9 Apr 2024 16:42:37 +0200 Subject: [PATCH 2/2] pkp/pkp-lib#9857 Add step prop and allow float for min&max&step --- classes/components/forms/FieldSlider.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/classes/components/forms/FieldSlider.php b/classes/components/forms/FieldSlider.php index 97985274fca..c8299c5bb7e 100644 --- a/classes/components/forms/FieldSlider.php +++ b/classes/components/forms/FieldSlider.php @@ -23,13 +23,24 @@ class FieldSlider extends Field /** * Range min value + * + * @var int|float */ - public int $min; + public $min; /** * Range max value + * + * @var int|float */ - public int $max; + public $max; + + /** + * Range step value + * + * @var int|float + */ + public $step = 1; /** * Label for min value, it displays actual value when not present @@ -66,6 +77,7 @@ public function getConfig() $config = parent::getConfig(); $config['min'] = $this->min; $config['max'] = $this->max; + $config['step'] = $this->step; $config['minLabel'] = $this->minLabel; $config['maxLabel'] = $this->maxLabel; $config['valueLabel'] = $this->valueLabel;