From 82b01a53115ef115f5677ca34c361e3e30584ea5 Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Thu, 18 Nov 2021 13:29:10 +0300 Subject: [PATCH] Revert "Fixed #1737 - New selectionMode for OrderList" This reverts commit d849dea6f8528de79cea7d7a3a5f1257cce151f2. --- api-generator/components/orderlist.js | 6 ---- src/components/orderlist/OrderList.d.ts | 1 - src/components/orderlist/OrderList.vue | 37 ++++--------------------- src/views/orderlist/OrderListDoc.vue | 6 ---- 4 files changed, 6 insertions(+), 44 deletions(-) diff --git a/api-generator/components/orderlist.js b/api-generator/components/orderlist.js index 0498a8a50..f2c9e4bc1 100644 --- a/api-generator/components/orderlist.js +++ b/api-generator/components/orderlist.js @@ -11,12 +11,6 @@ const OrderListProps = [ default: "null", description: "Selected items in the list." }, - { - name: "selectionMode", - type: "string", - default: "null", - description: 'Defines selection mode, options are "single" and "multiple".' - }, { name: "metaKeySelection", type: "boolean", diff --git a/src/components/orderlist/OrderList.d.ts b/src/components/orderlist/OrderList.d.ts index d0844e892..0ef53d8d8 100755 --- a/src/components/orderlist/OrderList.d.ts +++ b/src/components/orderlist/OrderList.d.ts @@ -4,7 +4,6 @@ interface OrderListProps { modelValue?: any[]; dataKey?: string; selection?: any[]; - selectionMode?: string; metaKeySelection?: boolean; listStyle?: any; responsive?: boolean; diff --git a/src/components/orderlist/OrderList.vue b/src/components/orderlist/OrderList.vue index b613768b0..3c4d20206 100755 --- a/src/components/orderlist/OrderList.vue +++ b/src/components/orderlist/OrderList.vue @@ -42,10 +42,6 @@ export default { type: Array, default: null }, - selectionMode: { - type: String, - default: null - }, dataKey: { type: String, default: null @@ -206,46 +202,31 @@ export default { }, onItemClick(event, item, index) { this.itemTouched = false; - let selection = this.d_selection; let selectedIndex = ObjectUtils.findIndexInList(item, this.d_selection); let selected = (selectedIndex != -1); let metaSelection = this.itemTouched ? false : this.metaKeySelection; - let _selection = []; if (metaSelection) { let metaKey = (event.metaKey || event.ctrlKey); if (selected && metaKey) { - _selection = selection.filter((val, index) => index !== selectedIndex); + this.d_selection = this.d_selection.filter((val, index) => index !== selectedIndex); } else { - if (this.isMultipleSelectionMode()) { - _selection = (selection && metaKey) ? [...selection] : []; - } - ObjectUtils.insertIntoOrderedArray(item, index, _selection, this.modelValue); + this.d_selection = (metaKey) ? this.d_selection ? [...this.d_selection] : [] : []; + ObjectUtils.insertIntoOrderedArray(item, index, this.d_selection, this.modelValue); } } else { if (selected) { - if (this.isSingleSelectionMode()) { - _selection = [...selection]; - } - else if (this.isMultipleSelectionMode()) { - _selection = selection.filter((val, index) => index !== selectedIndex); - } + this.d_selection = this.d_selection.filter((val, index) => index !== selectedIndex); } else { - if (this.isMultipleSelectionMode()) { - _selection = selection ? [...selection] : []; - } - ObjectUtils.insertIntoOrderedArray(item, index, _selection, this.modelValue); + this.d_selection = this.d_selection ? [...this.d_selection] : []; + ObjectUtils.insertIntoOrderedArray(item, index, this.d_selection, this.modelValue); } } - let newSelection = [this.d_selection]; - newSelection = _selection; - this.d_selection = newSelection; - this.$emit('update:selection', this.d_selection); this.$emit('selection-change', { originalEvent:event, @@ -368,12 +349,6 @@ export default { document.head.removeChild(this.styleElement); this.styleElement = null; } - }, - isSingleSelectionMode() { - return this.selectionMode === 'single'; - }, - isMultipleSelectionMode() { - return this.selectionMode === 'multiple'; } }, computed: { diff --git a/src/views/orderlist/OrderListDoc.vue b/src/views/orderlist/OrderListDoc.vue index 8a234e81c..f4307fb62 100755 --- a/src/views/orderlist/OrderListDoc.vue +++ b/src/views/orderlist/OrderListDoc.vue @@ -93,12 +93,6 @@ import OrderList from 'primevue/orderlist'; null Selected items in the list. - - selectionMode - string - null - Defines selection mode, options are "single" and "multiple". - metaKeySelection boolean