Revert "Fixed #1737 - New selectionMode for OrderList"
This reverts commit d849dea6f8
.
pull/1792/head
parent
989514a724
commit
82b01a5311
|
@ -11,12 +11,6 @@ const OrderListProps = [
|
||||||
default: "null",
|
default: "null",
|
||||||
description: "Selected items in the list."
|
description: "Selected items in the list."
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "selectionMode",
|
|
||||||
type: "string",
|
|
||||||
default: "null",
|
|
||||||
description: 'Defines selection mode, options are "single" and "multiple".'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "metaKeySelection",
|
name: "metaKeySelection",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
|
|
@ -4,7 +4,6 @@ interface OrderListProps {
|
||||||
modelValue?: any[];
|
modelValue?: any[];
|
||||||
dataKey?: string;
|
dataKey?: string;
|
||||||
selection?: any[];
|
selection?: any[];
|
||||||
selectionMode?: string;
|
|
||||||
metaKeySelection?: boolean;
|
metaKeySelection?: boolean;
|
||||||
listStyle?: any;
|
listStyle?: any;
|
||||||
responsive?: boolean;
|
responsive?: boolean;
|
||||||
|
|
|
@ -42,10 +42,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
selectionMode: {
|
|
||||||
type: String,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
dataKey: {
|
dataKey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
|
@ -206,46 +202,31 @@ export default {
|
||||||
},
|
},
|
||||||
onItemClick(event, item, index) {
|
onItemClick(event, item, index) {
|
||||||
this.itemTouched = false;
|
this.itemTouched = false;
|
||||||
let selection = this.d_selection;
|
|
||||||
let selectedIndex = ObjectUtils.findIndexInList(item, this.d_selection);
|
let selectedIndex = ObjectUtils.findIndexInList(item, this.d_selection);
|
||||||
let selected = (selectedIndex != -1);
|
let selected = (selectedIndex != -1);
|
||||||
let metaSelection = this.itemTouched ? false : this.metaKeySelection;
|
let metaSelection = this.itemTouched ? false : this.metaKeySelection;
|
||||||
let _selection = [];
|
|
||||||
|
|
||||||
if (metaSelection) {
|
if (metaSelection) {
|
||||||
let metaKey = (event.metaKey || event.ctrlKey);
|
let metaKey = (event.metaKey || event.ctrlKey);
|
||||||
|
|
||||||
if (selected && metaKey) {
|
if (selected && metaKey) {
|
||||||
_selection = selection.filter((val, index) => index !== selectedIndex);
|
this.d_selection = this.d_selection.filter((val, index) => index !== selectedIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.isMultipleSelectionMode()) {
|
this.d_selection = (metaKey) ? this.d_selection ? [...this.d_selection] : [] : [];
|
||||||
_selection = (selection && metaKey) ? [...selection] : [];
|
ObjectUtils.insertIntoOrderedArray(item, index, this.d_selection, this.modelValue);
|
||||||
}
|
|
||||||
ObjectUtils.insertIntoOrderedArray(item, index, _selection, this.modelValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
if (this.isSingleSelectionMode()) {
|
this.d_selection = this.d_selection.filter((val, index) => index !== selectedIndex);
|
||||||
_selection = [...selection];
|
|
||||||
}
|
|
||||||
else if (this.isMultipleSelectionMode()) {
|
|
||||||
_selection = selection.filter((val, index) => index !== selectedIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.isMultipleSelectionMode()) {
|
this.d_selection = this.d_selection ? [...this.d_selection] : [];
|
||||||
_selection = selection ? [...selection] : [];
|
ObjectUtils.insertIntoOrderedArray(item, index, this.d_selection, this.modelValue);
|
||||||
}
|
|
||||||
ObjectUtils.insertIntoOrderedArray(item, index, _selection, this.modelValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let newSelection = [this.d_selection];
|
|
||||||
newSelection = _selection;
|
|
||||||
this.d_selection = newSelection;
|
|
||||||
|
|
||||||
this.$emit('update:selection', this.d_selection);
|
this.$emit('update:selection', this.d_selection);
|
||||||
this.$emit('selection-change', {
|
this.$emit('selection-change', {
|
||||||
originalEvent:event,
|
originalEvent:event,
|
||||||
|
@ -368,12 +349,6 @@ export default {
|
||||||
document.head.removeChild(this.styleElement);
|
document.head.removeChild(this.styleElement);
|
||||||
this.styleElement = null;
|
this.styleElement = null;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
isSingleSelectionMode() {
|
|
||||||
return this.selectionMode === 'single';
|
|
||||||
},
|
|
||||||
isMultipleSelectionMode() {
|
|
||||||
return this.selectionMode === 'multiple';
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -93,12 +93,6 @@ import OrderList from 'primevue/orderlist';
|
||||||
<td>null</td>
|
<td>null</td>
|
||||||
<td>Selected items in the list.</td>
|
<td>Selected items in the list.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>selectionMode</td>
|
|
||||||
<td>string</td>
|
|
||||||
<td>null</td>
|
|
||||||
<td>Defines selection mode, options are "single" and "multiple".</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>metaKeySelection</td>
|
<td>metaKeySelection</td>
|
||||||
<td>boolean</td>
|
<td>boolean</td>
|
||||||
|
|
Loading…
Reference in New Issue