Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9857 FieldSlider #9858

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions classes/components/forms/FieldSlider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?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
*
* @var int|float
*/
public $min;

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

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

/**
* 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['step'] = $this->step;
$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