Skip to content

Commit

Permalink
pkp#9857 FieldSlider
Browse files Browse the repository at this point in the history
  • Loading branch information
jardakotesovec committed Apr 8, 2024
1 parent afd867f commit 9665558
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
78 changes: 78 additions & 0 deletions classes/components/forms/FieldSlider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* @file classes/components/form/FieldSlider.php
*
* 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 FieldSlider
*
* @ingroup classes_controllers_form
*
* @brief A color picker field in a form.
*/

namespace PKP\components\forms;

class FieldSlider extends Field
{
/** @copydoc Field::$component */
public $component = 'field-slider';


/**
* Range min value
*/
public int $min;

/**
* Range max value
*/
public int $max;

/**
* Label for min value, it displays actual value when not present
*/
public ?string $minLabel = null;

/**
* Label for max value, it displays actual value when not present
*/
public ?string $maxLabel = null;

/**
* Expects translation string, which should contain {$value} placeholder. It displays actual value if not present.
*/
public ?string $valueLabel = null;

/**
* Expects translation string, which might contain {$value} placeholder. It fallback to valueLabel is not present..
*/
public ?string $valueLabelMin = null;

/**
* Expects translation string, which might contain {$value} placeholder. It fallback to valueLabel is not present..
*/
public ?string $valueLabelMax = null;



/**
* @copydoc Field::getConfig()
*/
public function getConfig()
{
$config = parent::getConfig();
$config['min'] = $this->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;
}

}
17 changes: 17 additions & 0 deletions classes/components/forms/dashboard/SubmissionFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,7 @@ public function __construct(
->addAssignedTo()
->addIssues()
->addCategories()
->addDaysSinceLastActivity()
;
}

Expand Down Expand Up @@ -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));

}
}
8 changes: 8 additions & 0 deletions js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 9665558

Please sign in to comment.