2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2024-02-11 23:48:21 +00:00
|
|
|
<div :class="cx('root')" v-bind="ptmi('root')">
|
2023-08-17 23:36:06 +00:00
|
|
|
<div v-if="showSourceControls" :class="cx('sourceControls')" v-bind="ptm('sourceControls')" data-pc-group-section="controls">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="sourcecontrolsstart"></slot>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveUpAriaLabel" :disabled="moveDisabled(0)" @click="moveUp($event, 0)" v-bind="{ ...buttonProps, ...moveUpButtonProps }" :pt="ptm('sourceMoveUpButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="moveupicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleUpIcon v-bind="ptm('sourceMoveUpButton')['icon']" data-pc-section="moveupicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveTopAriaLabel" :disabled="moveDisabled(0)" @click="moveTop($event, 0)" v-bind="{ ...buttonProps, ...moveTopButtonProps }" :pt="ptm('sourceMoveTopButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="movetopicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleDoubleUpIcon v-bind="ptm('sourceMoveTopButton')['icon']" data-pc-section="movetopicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveDownAriaLabel" :disabled="moveDisabled(0)" @click="moveDown($event, 0)" v-bind="{ ...buttonProps, ...moveDownButtonProps }" :pt="ptm('sourceMoveDownButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="movedownicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleDownIcon v-bind="ptm('sourceMoveDownButton')['icon']" data-pc-section="movedownicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveBottomAriaLabel" :disabled="moveDisabled(0)" @click="moveBottom($event, 0)" v-bind="{ ...buttonProps, ...moveBottomButtonProps }" :pt="ptm('sourceMoveBottomButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="movebottomicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleDoubleDownIcon v-bind="ptm('sourceMoveBottomButton')['icon']" data-pc-section="movebottomicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="sourcecontrolsend"></slot>
|
|
|
|
</div>
|
2023-08-17 23:36:06 +00:00
|
|
|
<div :class="cx('sourceWrapper')" v-bind="ptm('sourceWrapper')" data-pc-group-section="listwrapper">
|
2024-03-21 13:21:01 +00:00
|
|
|
<Listbox
|
2022-12-08 11:04:25 +00:00
|
|
|
ref="sourceList"
|
|
|
|
:id="idSource + '_list'"
|
2024-03-21 13:21:01 +00:00
|
|
|
:modelValue="d_selection[0]"
|
|
|
|
:options="sourceList"
|
|
|
|
multiple
|
|
|
|
:metaKeySelection="metaKeySelection"
|
|
|
|
:listStyle="listStyle"
|
2024-03-26 14:21:39 +00:00
|
|
|
:scrollHeight="scrollHeight"
|
2022-12-08 11:04:25 +00:00
|
|
|
:tabindex="sourceList && sourceList.length > 0 ? tabindex : -1"
|
2024-03-21 13:21:01 +00:00
|
|
|
:dataKey="dataKey"
|
|
|
|
:autoOptionFocus="autoOptionFocus"
|
|
|
|
:focusOnHover="focusOnHover"
|
2024-03-22 08:57:54 +00:00
|
|
|
:stripedRows="stripedRows"
|
2024-03-21 13:52:26 +00:00
|
|
|
:disabled="disabled"
|
2024-03-21 13:21:01 +00:00
|
|
|
:pt="ptm('list')"
|
|
|
|
:unstyled="unstyled"
|
2022-12-08 11:04:25 +00:00
|
|
|
@focus="onListFocus($event, 'sourceList')"
|
|
|
|
@blur="onListBlur($event, 'sourceList')"
|
2024-03-21 13:21:01 +00:00
|
|
|
@change="onChangeSelection($event, 0)"
|
|
|
|
@item-dblclick="onItemDblClick($event, 0)"
|
2023-08-17 23:36:06 +00:00
|
|
|
data-pc-group-section="list"
|
2022-12-08 11:04:25 +00:00
|
|
|
>
|
2024-03-21 13:21:01 +00:00
|
|
|
<template v-if="$slots.sourceheader" #header>
|
2024-03-26 10:31:15 +00:00
|
|
|
<slot name="sourceheader"></slot>
|
2022-09-06 12:03:37 +00:00
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
<template #option="{ option, index }">
|
|
|
|
<slot name="item" :item="option" :index="index" />
|
|
|
|
</template>
|
|
|
|
</Listbox>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
2023-08-17 23:36:06 +00:00
|
|
|
<div :class="cx('buttons')" v-bind="ptm('buttons')" data-pc-group-section="controls">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="movecontrolsstart"></slot>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveToTargetAriaLabel" @click="moveToTarget" :disabled="moveDisabled(0)" v-bind="{ ...buttonProps, ...moveToTargetProps }" :pt="ptm('moveToTargetButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
2023-04-18 13:55:04 +00:00
|
|
|
<slot name="movetotargeticon" :viewChanged="viewChanged">
|
2023-09-06 07:13:47 +00:00
|
|
|
<component :is="viewChanged ? 'AngleDownIcon' : 'AngleRightIcon'" v-bind="ptm('moveToTargetButton')['icon']" data-pc-section="movetotargeticon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveAllToTargetAriaLabel" @click="moveAllToTarget" :disabled="moveAllDisabled('sourceList')" v-bind="{ ...buttonProps, ...moveAllToTargetProps }" :pt="ptm('moveAllToTargetButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
2023-04-18 13:55:04 +00:00
|
|
|
<slot name="movealltotargeticon" :viewChanged="viewChanged">
|
2023-09-06 07:13:47 +00:00
|
|
|
<component :is="viewChanged ? 'AngleDoubleDownIcon' : 'AngleDoubleRightIcon'" v-bind="ptm('moveAllToTargetButton')['icon']" data-pc-section="movealltotargeticon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveToSourceAriaLabel" @click="moveToSource" :disabled="moveDisabled(1)" v-bind="{ ...buttonProps, ...moveToSourceProps }" :pt="ptm('moveToSourceButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
2023-04-18 13:55:04 +00:00
|
|
|
<slot name="movetosourceicon" :viewChanged="viewChanged">
|
2023-09-06 07:13:47 +00:00
|
|
|
<component :is="viewChanged ? 'AngleUpIcon' : 'AngleLeftIcon'" v-bind="ptm('moveToSourceButton')['icon']" data-pc-section="movetosourceicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveAllToSourceAriaLabel" @click="moveAllToSource" :disabled="moveAllDisabled('targetList')" v-bind="{ ...buttonProps, ...moveAllToSourceProps }" :pt="ptm('moveAllToSourceButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
2023-04-18 13:55:04 +00:00
|
|
|
<slot name="movealltosourceicon" :viewChanged="viewChanged">
|
2023-09-06 07:13:47 +00:00
|
|
|
<component :is="viewChanged ? 'AngleDoubleUpIcon' : 'AngleDoubleLeftIcon'" v-bind="ptm('moveAllToSourceButton')['icon']" data-pc-section="movealltosourceicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="movecontrolsend"></slot>
|
|
|
|
</div>
|
2023-08-17 23:36:06 +00:00
|
|
|
<div :class="cx('targetWrapper')" v-bind="ptm('targetWrapper')" data-pc-group-section="listwrapper">
|
2024-03-21 13:21:01 +00:00
|
|
|
<Listbox
|
2022-12-08 11:04:25 +00:00
|
|
|
ref="targetList"
|
|
|
|
:id="idTarget + '_list'"
|
2024-03-21 13:21:01 +00:00
|
|
|
:modelValue="d_selection[1]"
|
|
|
|
:options="targetList"
|
|
|
|
multiple
|
|
|
|
:metaKeySelection="metaKeySelection"
|
|
|
|
:listStyle="listStyle"
|
2024-03-26 14:21:39 +00:00
|
|
|
:scrollHeight="scrollHeight"
|
2022-12-08 11:04:25 +00:00
|
|
|
:tabindex="targetList && targetList.length > 0 ? tabindex : -1"
|
2024-03-21 13:21:01 +00:00
|
|
|
:dataKey="dataKey"
|
|
|
|
:autoOptionFocus="autoOptionFocus"
|
|
|
|
:focusOnHover="focusOnHover"
|
2024-03-22 08:57:54 +00:00
|
|
|
:stripedRows="stripedRows"
|
2024-03-21 13:52:26 +00:00
|
|
|
:disabled="disabled"
|
2024-03-21 13:21:01 +00:00
|
|
|
:pt="ptm('list')"
|
|
|
|
:unstyled="unstyled"
|
2022-12-08 11:04:25 +00:00
|
|
|
@focus="onListFocus($event, 'targetList')"
|
|
|
|
@blur="onListBlur($event, 'targetList')"
|
2024-03-21 13:21:01 +00:00
|
|
|
@change="onChangeSelection($event, 1)"
|
|
|
|
@item-dblclick="onItemDblClick($event, 1)"
|
2023-08-17 23:36:06 +00:00
|
|
|
data-pc-group-section="list"
|
2022-12-08 11:04:25 +00:00
|
|
|
>
|
2024-03-21 13:21:01 +00:00
|
|
|
<template v-if="$slots.targetheader" #header>
|
2024-03-26 10:31:15 +00:00
|
|
|
<slot name="targetheader"></slot>
|
2024-03-21 13:21:01 +00:00
|
|
|
</template>
|
|
|
|
<template #option="{ option, index }">
|
|
|
|
<slot name="item" :item="option" :index="index" />
|
2022-09-06 12:03:37 +00:00
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Listbox>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
2023-08-17 23:36:06 +00:00
|
|
|
<div v-if="showTargetControls" :class="cx('targetControls')" v-bind="ptm('targetControls')" data-pc-group-section="controls">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="targetcontrolsstart"></slot>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveUpAriaLabel" :disabled="moveDisabled(1)" @click="moveUp($event, 1)" v-bind="{ ...buttonProps, ...moveUpButtonProps }" :pt="ptm('targetMoveUpButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="moveupicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleUpIcon v-bind="ptm('targetMoveUpButton')['icon']" data-pc-section="moveupicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveTopAriaLabel" :disabled="moveDisabled(1)" @click="moveTop($event, 1)" v-bind="{ ...buttonProps, ...moveTopButtonProps }" :pt="ptm('targetMoveTopButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="movetopicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleDoubleUpIcon v-bind="ptm('targetMoveTopButton')['icon']" data-pc-section="movetopicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveDownAriaLabel" :disabled="moveDisabled(1)" @click="moveDown($event, 1)" v-bind="{ ...buttonProps, ...moveDownButtonProps }" :pt="ptm('targetMoveDownButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="movedownicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleDownIcon v-bind="ptm('targetMoveDownButton')['icon']" data-pc-section="movedownicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2024-03-25 13:02:23 +00:00
|
|
|
<Button :aria-label="moveBottomAriaLabel" :disabled="moveDisabled(1)" @click="moveBottom($event, 1)" v-bind="{ ...buttonProps, ...moveBottomButtonProps }" :pt="ptm('targetMoveBottomButton')" :unstyled="unstyled">
|
2023-04-14 07:44:20 +00:00
|
|
|
<template #icon>
|
|
|
|
<slot name="movebottomicon">
|
2023-09-06 07:13:47 +00:00
|
|
|
<AngleDoubleDownIcon v-bind="ptm('targetMoveBottomButton')['icon']" data-pc-section="movebottomicon" />
|
2023-04-14 07:44:20 +00:00
|
|
|
</slot>
|
|
|
|
</template>
|
2024-03-21 13:21:01 +00:00
|
|
|
</Button>
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot name="targetcontrolsend"></slot>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Button from 'primevue/button';
|
2023-04-18 12:53:43 +00:00
|
|
|
import AngleDoubleDownIcon from 'primevue/icons/angledoubledown';
|
|
|
|
import AngleDoubleLeftIcon from 'primevue/icons/angledoubleleft';
|
|
|
|
import AngleDoubleRightIcon from 'primevue/icons/angledoubleright';
|
|
|
|
import AngleDoubleUpIcon from 'primevue/icons/angledoubleup';
|
|
|
|
import AngleDownIcon from 'primevue/icons/angledown';
|
|
|
|
import AngleLeftIcon from 'primevue/icons/angleleft';
|
|
|
|
import AngleRightIcon from 'primevue/icons/angleright';
|
|
|
|
import AngleUpIcon from 'primevue/icons/angleup';
|
2024-03-21 13:21:01 +00:00
|
|
|
import Listbox from 'primevue/listbox';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Ripple from 'primevue/ripple';
|
2022-12-08 11:04:25 +00:00
|
|
|
import { DomHandler, ObjectUtils, UniqueComponentId } from 'primevue/utils';
|
2023-06-05 10:19:03 +00:00
|
|
|
import BasePickList from './BasePickList.vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PickList',
|
2023-06-02 15:43:30 +00:00
|
|
|
extends: BasePickList,
|
2024-02-11 23:48:21 +00:00
|
|
|
inheritAttrs: false,
|
2022-12-08 11:04:25 +00:00
|
|
|
emits: ['update:modelValue', 'reorder', 'update:selection', 'selection-change', 'move-to-target', 'move-to-source', 'move-all-to-target', 'move-all-to-source', 'focus', 'blur'],
|
2022-09-06 12:03:37 +00:00
|
|
|
itemTouched: false,
|
|
|
|
reorderDirection: null,
|
|
|
|
styleElement: null,
|
2023-04-18 13:55:04 +00:00
|
|
|
media: null,
|
|
|
|
mediaChangeListener: null,
|
2022-09-06 12:03:37 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2023-01-19 04:01:03 +00:00
|
|
|
id: this.$attrs.id,
|
2022-12-08 11:04:25 +00:00
|
|
|
d_selection: this.selection,
|
2023-04-18 13:55:04 +00:00
|
|
|
viewChanged: false
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
2023-01-19 04:01:03 +00:00
|
|
|
'$attrs.id': function (newValue) {
|
|
|
|
this.id = newValue || UniqueComponentId();
|
|
|
|
},
|
2022-09-14 11:26:01 +00:00
|
|
|
selection(newValue) {
|
|
|
|
this.d_selection = newValue;
|
2023-04-18 13:55:04 +00:00
|
|
|
},
|
2024-01-19 09:52:18 +00:00
|
|
|
breakpoint() {
|
2023-04-18 13:55:04 +00:00
|
|
|
this.destroyMedia();
|
|
|
|
this.initMedia();
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
if (this.reorderDirection) {
|
|
|
|
this.updateListScroll(this.$refs.sourceList.$el);
|
|
|
|
this.updateListScroll(this.$refs.targetList.$el);
|
|
|
|
this.reorderDirection = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
this.destroyStyle();
|
2023-04-18 13:55:04 +00:00
|
|
|
this.destroyMedia();
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
2024-01-16 11:28:03 +00:00
|
|
|
mounted() {
|
2024-01-19 09:52:18 +00:00
|
|
|
this.id = this.id || UniqueComponentId();
|
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
if (this.responsive) {
|
|
|
|
this.createStyle();
|
2023-04-18 13:55:04 +00:00
|
|
|
this.initMedia();
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2024-03-21 13:21:01 +00:00
|
|
|
updateSelection(event) {
|
|
|
|
this.$emit('update:selection', this.d_selection);
|
|
|
|
this.$emit('selection-change', {
|
|
|
|
originalEvent: event,
|
|
|
|
value: this.d_selection
|
2023-05-09 22:03:24 +00:00
|
|
|
});
|
|
|
|
},
|
2024-03-21 13:21:01 +00:00
|
|
|
onChangeSelection(params, listIndex) {
|
|
|
|
this.d_selection[listIndex] = params.value;
|
|
|
|
this.updateSelection(params.event);
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
2022-12-08 11:04:25 +00:00
|
|
|
onListFocus(event, listType) {
|
2024-03-21 13:21:01 +00:00
|
|
|
this.$emit('focus', event, listType);
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
onListBlur(event, listType) {
|
2024-03-21 13:21:01 +00:00
|
|
|
this.$emit('blur', event, listType);
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
2024-03-21 13:21:01 +00:00
|
|
|
onReorderUpdate(event, value, listIndex) {
|
|
|
|
this.$emit('update:modelValue', value);
|
|
|
|
this.$emit('reorder', {
|
|
|
|
originalEvent: event,
|
|
|
|
value: value,
|
|
|
|
direction: this.reorderDirection,
|
|
|
|
listIndex
|
|
|
|
});
|
2023-01-09 18:19:45 +00:00
|
|
|
},
|
2024-03-21 13:21:01 +00:00
|
|
|
onItemDblClick(event, listIndex) {
|
|
|
|
if (listIndex === 0) this.moveToTarget({ event: event.originalEvent });
|
|
|
|
else if (listIndex === 1) this.moveToSource({ event: event.originalEvent });
|
2024-01-24 07:02:00 +00:00
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
moveUp(event, listIndex) {
|
|
|
|
if (this.d_selection && this.d_selection[listIndex]) {
|
|
|
|
let valueList = [...this.modelValue[listIndex]];
|
|
|
|
let selectionList = this.d_selection[listIndex];
|
|
|
|
|
|
|
|
for (let i = 0; i < selectionList.length; i++) {
|
|
|
|
let selectedItem = selectionList[i];
|
|
|
|
let selectedItemIndex = ObjectUtils.findIndexInList(selectedItem, valueList);
|
|
|
|
|
|
|
|
if (selectedItemIndex !== 0) {
|
|
|
|
let movedItem = valueList[selectedItemIndex];
|
|
|
|
let temp = valueList[selectedItemIndex - 1];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
valueList[selectedItemIndex - 1] = movedItem;
|
|
|
|
valueList[selectedItemIndex] = temp;
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[listIndex] = valueList;
|
|
|
|
|
|
|
|
this.reorderDirection = 'up';
|
2024-03-21 13:21:01 +00:00
|
|
|
this.onReorderUpdate(event, value, listIndex);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveTop(event, listIndex) {
|
2022-09-14 11:26:01 +00:00
|
|
|
if (this.d_selection) {
|
2022-09-06 12:03:37 +00:00
|
|
|
let valueList = [...this.modelValue[listIndex]];
|
|
|
|
let selectionList = this.d_selection[listIndex];
|
|
|
|
|
|
|
|
for (let i = 0; i < selectionList.length; i++) {
|
|
|
|
let selectedItem = selectionList[i];
|
|
|
|
let selectedItemIndex = ObjectUtils.findIndexInList(selectedItem, valueList);
|
|
|
|
|
|
|
|
if (selectedItemIndex !== 0) {
|
|
|
|
let movedItem = valueList.splice(selectedItemIndex, 1)[0];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
valueList.unshift(movedItem);
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[listIndex] = valueList;
|
|
|
|
|
|
|
|
this.reorderDirection = 'top';
|
2024-03-21 13:21:01 +00:00
|
|
|
this.onReorderUpdate(event, value, listIndex);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveDown(event, listIndex) {
|
2022-09-14 11:26:01 +00:00
|
|
|
if (this.d_selection) {
|
2022-09-06 12:03:37 +00:00
|
|
|
let valueList = [...this.modelValue[listIndex]];
|
|
|
|
let selectionList = this.d_selection[listIndex];
|
|
|
|
|
|
|
|
for (let i = selectionList.length - 1; i >= 0; i--) {
|
|
|
|
let selectedItem = selectionList[i];
|
|
|
|
let selectedItemIndex = ObjectUtils.findIndexInList(selectedItem, valueList);
|
|
|
|
|
2022-09-14 11:26:01 +00:00
|
|
|
if (selectedItemIndex !== valueList.length - 1) {
|
2022-09-06 12:03:37 +00:00
|
|
|
let movedItem = valueList[selectedItemIndex];
|
|
|
|
let temp = valueList[selectedItemIndex + 1];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
valueList[selectedItemIndex + 1] = movedItem;
|
|
|
|
valueList[selectedItemIndex] = temp;
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[listIndex] = valueList;
|
|
|
|
|
|
|
|
this.reorderDirection = 'down';
|
2024-03-21 13:21:01 +00:00
|
|
|
this.onReorderUpdate(event, value, listIndex);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveBottom(event, listIndex) {
|
|
|
|
if (this.d_selection) {
|
|
|
|
let valueList = [...this.modelValue[listIndex]];
|
|
|
|
let selectionList = this.d_selection[listIndex];
|
|
|
|
|
|
|
|
for (let i = selectionList.length - 1; i >= 0; i--) {
|
|
|
|
let selectedItem = selectionList[i];
|
|
|
|
let selectedItemIndex = ObjectUtils.findIndexInList(selectedItem, valueList);
|
|
|
|
|
2022-09-14 11:26:01 +00:00
|
|
|
if (selectedItemIndex !== valueList.length - 1) {
|
2022-09-06 12:03:37 +00:00
|
|
|
let movedItem = valueList.splice(selectedItemIndex, 1)[0];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
valueList.push(movedItem);
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[listIndex] = valueList;
|
|
|
|
|
|
|
|
this.reorderDirection = 'bottom';
|
2024-03-21 13:21:01 +00:00
|
|
|
this.onReorderUpdate(event, value, listIndex);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveToTarget(event) {
|
|
|
|
let selection = this.d_selection && this.d_selection[0] ? this.d_selection[0] : null;
|
|
|
|
let sourceList = [...this.modelValue[0]];
|
|
|
|
let targetList = [...this.modelValue[1]];
|
|
|
|
|
|
|
|
if (selection) {
|
|
|
|
for (let i = 0; i < selection.length; i++) {
|
|
|
|
let selectedItem = selection[i];
|
|
|
|
|
|
|
|
if (ObjectUtils.findIndexInList(selectedItem, targetList) == -1) {
|
2022-09-14 11:26:01 +00:00
|
|
|
targetList.push(sourceList.splice(ObjectUtils.findIndexInList(selectedItem, sourceList), 1)[0]);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[0] = sourceList;
|
|
|
|
value[1] = targetList;
|
|
|
|
this.$emit('update:modelValue', value);
|
|
|
|
|
|
|
|
this.$emit('move-to-target', {
|
|
|
|
originalEvent: event,
|
2023-10-12 15:38:19 +00:00
|
|
|
items: [...new Set(selection)]
|
2022-09-06 12:03:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.d_selection[0] = [];
|
2024-03-21 13:21:01 +00:00
|
|
|
this.updateSelection(event);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveAllToTarget(event) {
|
|
|
|
if (this.modelValue[0]) {
|
|
|
|
let sourceList = [...this.modelValue[0]];
|
|
|
|
let targetList = [...this.modelValue[1]];
|
|
|
|
|
|
|
|
this.$emit('move-all-to-target', {
|
|
|
|
originalEvent: event,
|
|
|
|
items: sourceList
|
|
|
|
});
|
|
|
|
|
|
|
|
targetList = [...targetList, ...sourceList];
|
|
|
|
sourceList = [];
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[0] = sourceList;
|
|
|
|
value[1] = targetList;
|
|
|
|
this.$emit('update:modelValue', value);
|
|
|
|
|
2024-03-21 13:21:01 +00:00
|
|
|
this.d_selection = [[], []];
|
|
|
|
this.updateSelection(event);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveToSource(event) {
|
|
|
|
let selection = this.d_selection && this.d_selection[1] ? this.d_selection[1] : null;
|
|
|
|
let sourceList = [...this.modelValue[0]];
|
|
|
|
let targetList = [...this.modelValue[1]];
|
|
|
|
|
|
|
|
if (selection) {
|
|
|
|
for (let i = 0; i < selection.length; i++) {
|
|
|
|
let selectedItem = selection[i];
|
|
|
|
|
|
|
|
if (ObjectUtils.findIndexInList(selectedItem, sourceList) == -1) {
|
2022-09-14 11:26:01 +00:00
|
|
|
sourceList.push(targetList.splice(ObjectUtils.findIndexInList(selectedItem, targetList), 1)[0]);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[0] = sourceList;
|
|
|
|
value[1] = targetList;
|
|
|
|
this.$emit('update:modelValue', value);
|
|
|
|
|
|
|
|
this.$emit('move-to-source', {
|
|
|
|
originalEvent: event,
|
2023-10-12 15:38:19 +00:00
|
|
|
items: [...new Set(selection)]
|
2022-09-06 12:03:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.d_selection[1] = [];
|
2024-03-21 13:21:01 +00:00
|
|
|
this.updateSelection(event);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
moveAllToSource(event) {
|
|
|
|
if (this.modelValue[1]) {
|
|
|
|
let sourceList = [...this.modelValue[0]];
|
|
|
|
let targetList = [...this.modelValue[1]];
|
|
|
|
|
|
|
|
this.$emit('move-all-to-source', {
|
|
|
|
originalEvent: event,
|
|
|
|
items: targetList
|
|
|
|
});
|
|
|
|
|
|
|
|
sourceList = [...sourceList, ...targetList];
|
|
|
|
targetList = [];
|
|
|
|
|
|
|
|
let value = [...this.modelValue];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
value[0] = sourceList;
|
|
|
|
value[1] = targetList;
|
|
|
|
this.$emit('update:modelValue', value);
|
|
|
|
|
2024-03-21 13:21:01 +00:00
|
|
|
this.d_selection = [[], []];
|
|
|
|
this.updateSelection(event);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
2022-12-08 11:04:25 +00:00
|
|
|
onItemClick(event, item, index, listIndex) {
|
|
|
|
const listType = listIndex === 0 ? 'sourceList' : 'targetList';
|
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
this.itemTouched = false;
|
|
|
|
const selectionList = this.d_selection[listIndex];
|
2023-12-20 10:22:35 +00:00
|
|
|
const selectedIndex = ObjectUtils.findIndexInList(item, selectionList);
|
2022-09-14 11:26:01 +00:00
|
|
|
const selected = selectedIndex != -1;
|
2022-09-06 12:03:37 +00:00
|
|
|
const metaSelection = this.itemTouched ? false : this.metaKeySelection;
|
2023-06-02 15:43:30 +00:00
|
|
|
const selectedId = DomHandler.find(this.$refs[listType].$el, '[data-pc-section="item"]')[index].getAttribute('id');
|
2022-12-08 11:04:25 +00:00
|
|
|
|
2024-01-24 15:04:26 +00:00
|
|
|
this.focusedOptionIndex = selectedId;
|
2022-09-06 12:03:37 +00:00
|
|
|
let _selection;
|
|
|
|
|
|
|
|
if (metaSelection) {
|
2022-09-14 11:26:01 +00:00
|
|
|
let metaKey = event.metaKey || event.ctrlKey;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
if (selected && metaKey) {
|
|
|
|
_selection = selectionList.filter((val, index) => index !== selectedIndex);
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
|
|
|
_selection = metaKey ? (selectionList ? [...selectionList] : []) : [];
|
2022-09-06 12:03:37 +00:00
|
|
|
_selection.push(item);
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
if (selected) {
|
|
|
|
_selection = selectionList.filter((val, index) => index !== selectedIndex);
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
2022-09-06 12:03:37 +00:00
|
|
|
_selection = selectionList ? [...selectionList] : [];
|
|
|
|
_selection.push(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let newSelection = [...this.d_selection];
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
newSelection[listIndex] = _selection;
|
|
|
|
this.d_selection = newSelection;
|
|
|
|
|
2024-03-21 13:21:01 +00:00
|
|
|
this.updateSelection(event);
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
updateListScroll(listElement) {
|
2023-06-02 15:43:30 +00:00
|
|
|
const listItems = DomHandler.find(listElement, '[data-pc-section="item"][data-p-highlight="true"]');
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
if (listItems && listItems.length) {
|
2022-09-14 11:26:01 +00:00
|
|
|
switch (this.reorderDirection) {
|
2022-09-06 12:03:37 +00:00
|
|
|
case 'up':
|
|
|
|
DomHandler.scrollInView(listElement, listItems[0]);
|
2022-09-14 11:26:01 +00:00
|
|
|
break;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
case 'top':
|
|
|
|
listElement.scrollTop = 0;
|
2022-09-14 11:26:01 +00:00
|
|
|
break;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
case 'down':
|
|
|
|
DomHandler.scrollInView(listElement, listItems[listItems.length - 1]);
|
2022-09-14 11:26:01 +00:00
|
|
|
break;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
case 'bottom':
|
|
|
|
listElement.scrollTop = listElement.scrollHeight;
|
2022-09-14 11:26:01 +00:00
|
|
|
break;
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
default:
|
2022-09-14 11:26:01 +00:00
|
|
|
break;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-04-18 13:55:04 +00:00
|
|
|
initMedia() {
|
|
|
|
this.media = window.matchMedia(`(max-width: ${this.breakpoint})`);
|
|
|
|
this.viewChanged = this.media.matches;
|
|
|
|
this.bindMediaChangeListener();
|
|
|
|
},
|
|
|
|
destroyMedia() {
|
|
|
|
this.unbindMediaChangeListener();
|
|
|
|
},
|
|
|
|
bindMediaChangeListener() {
|
|
|
|
if (this.media && !this.mediaChangeListener) {
|
|
|
|
this.mediaChangeListener = (event) => {
|
|
|
|
this.viewChanged = event.matches;
|
|
|
|
};
|
|
|
|
|
|
|
|
this.media.addEventListener('change', this.mediaChangeListener);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
unbindMediaChangeListener() {
|
|
|
|
if (this.media && this.mediaChangeListener) {
|
|
|
|
this.media.removeEventListener('change', this.mediaChangeListener);
|
|
|
|
this.mediaChangeListener = null;
|
|
|
|
}
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
createStyle() {
|
2023-06-05 11:24:13 +00:00
|
|
|
if (!this.styleElement && !this.isUnstyled) {
|
2022-09-06 12:03:37 +00:00
|
|
|
this.$el.setAttribute(this.attributeSelector, '');
|
2022-09-14 11:26:01 +00:00
|
|
|
this.styleElement = document.createElement('style');
|
|
|
|
this.styleElement.type = 'text/css';
|
2023-08-11 01:34:02 +00:00
|
|
|
DomHandler.setAttribute(this.styleElement, 'nonce', this.$primevue?.config?.csp?.nonce);
|
2022-09-14 11:26:01 +00:00
|
|
|
document.head.appendChild(this.styleElement);
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
let innerHTML = `
|
|
|
|
@media screen and (max-width: ${this.breakpoint}) {
|
|
|
|
.p-picklist[${this.attributeSelector}] {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-picklist[${this.attributeSelector}] .p-picklist-buttons {
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-picklist[${this.attributeSelector}] .p-picklist-buttons .p-button:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
this.styleElement.innerHTML = innerHTML;
|
2022-09-14 11:26:01 +00:00
|
|
|
}
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
destroyStyle() {
|
|
|
|
if (this.styleElement) {
|
|
|
|
document.head.removeChild(this.styleElement);
|
|
|
|
this.styleElement = null;
|
|
|
|
}
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
moveDisabled(index) {
|
2024-03-21 13:52:26 +00:00
|
|
|
return this.disabled ? true : this.d_selection && (!this.d_selection[index] || !this.d_selection[index].length) ? true : false;
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
moveAllDisabled(list) {
|
2024-03-21 13:52:26 +00:00
|
|
|
return this.disabled ? true : ObjectUtils.isEmpty(this[list]);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-08 11:04:25 +00:00
|
|
|
idSource() {
|
2023-01-19 04:01:03 +00:00
|
|
|
return `${this.id}_source`;
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
idTarget() {
|
2023-01-19 04:01:03 +00:00
|
|
|
return `${this.id}_target`;
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
sourceList() {
|
|
|
|
return this.modelValue && this.modelValue[0] ? this.modelValue[0] : null;
|
|
|
|
},
|
|
|
|
targetList() {
|
|
|
|
return this.modelValue && this.modelValue[1] ? this.modelValue[1] : null;
|
|
|
|
},
|
|
|
|
attributeSelector() {
|
|
|
|
return UniqueComponentId();
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
moveUpAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveUp : undefined;
|
|
|
|
},
|
|
|
|
moveTopAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveTop : undefined;
|
|
|
|
},
|
|
|
|
moveDownAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveDown : undefined;
|
|
|
|
},
|
|
|
|
moveBottomAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveBottom : undefined;
|
|
|
|
},
|
|
|
|
moveToTargetAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveToTarget : undefined;
|
|
|
|
},
|
|
|
|
moveAllToTargetAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveAllToTarget : undefined;
|
|
|
|
},
|
|
|
|
moveToSourceAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveToSource : undefined;
|
|
|
|
},
|
|
|
|
moveAllToSourceAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.moveAllToSource : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2024-03-21 13:21:01 +00:00
|
|
|
Listbox,
|
|
|
|
AngleRightIcon,
|
|
|
|
AngleLeftIcon,
|
|
|
|
AngleDownIcon,
|
|
|
|
AngleUpIcon,
|
|
|
|
AngleDoubleRightIcon,
|
|
|
|
AngleDoubleLeftIcon,
|
|
|
|
AngleDoubleDownIcon,
|
|
|
|
AngleDoubleUpIcon
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
directives: {
|
2022-09-14 11:26:01 +00:00
|
|
|
ripple: Ripple
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|