From 76927aed86ded8d8c294ee04121b18c64e6efddd Mon Sep 17 00:00:00 2001 From: Gaelle Date: Mon, 20 May 2024 16:22:36 +0200 Subject: [PATCH 1/2] use selectedState instead of isSelected for deselect all files if one row is selected --- src/BIMDataComponents/BIMDataTable/BIMDataTable.vue | 4 ++-- .../BIMDataTable/table-row-selection.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue b/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue index 78fea552..58e13cfb 100644 --- a/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue +++ b/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue @@ -266,8 +266,8 @@ export default { emit("row-deselected", data); } }, - fullSelectionToggleEffect: selected => { - if (selected) { + fullSelectionToggleEffect: selectedState => { + if (selectedState) { emit("all-selected"); } else { emit("all-deselected"); diff --git a/src/BIMDataComponents/BIMDataTable/table-row-selection.js b/src/BIMDataComponents/BIMDataTable/table-row-selection.js index 0508a166..bde1cbeb 100644 --- a/src/BIMDataComponents/BIMDataTable/table-row-selection.js +++ b/src/BIMDataComponents/BIMDataTable/table-row-selection.js @@ -49,13 +49,17 @@ function useRowSelection( rowSelectionToggleEffect(isSelected(), { key, data }); }; const toggleFullSelection = () => { - const isSelected = () => rowSelection.value.size === rows.value.length; - if (isSelected()) { + const selectedState = rowSelection.value.size < rows.value.length + ? rowSelection.value.size > 0 + ? null + : false + : rowSelection.value.size > 0; + if (selectedState || selectedState === null) { rowSelection.value = new Map(); } else { rowSelection.value = new Map(rows.value.map(({ key, data }) => [key, data])); } - fullSelectionToggleEffect(isSelected()); + fullSelectionToggleEffect(selectedState); }; return { From 866cfcce64c96d3ed4d098456648252d34561c1e Mon Sep 17 00:00:00 2001 From: Gaelle Date: Tue, 21 May 2024 10:36:31 +0200 Subject: [PATCH 2/2] fix indeterminate state for deselect all if one is selected --- src/BIMDataComponents/BIMDataTable/BIMDataTable.vue | 4 ++-- .../BIMDataTable/table-row-selection.js | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue b/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue index 58e13cfb..78fea552 100644 --- a/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue +++ b/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue @@ -266,8 +266,8 @@ export default { emit("row-deselected", data); } }, - fullSelectionToggleEffect: selectedState => { - if (selectedState) { + fullSelectionToggleEffect: selected => { + if (selected) { emit("all-selected"); } else { emit("all-deselected"); diff --git a/src/BIMDataComponents/BIMDataTable/table-row-selection.js b/src/BIMDataComponents/BIMDataTable/table-row-selection.js index bde1cbeb..4b4e3765 100644 --- a/src/BIMDataComponents/BIMDataTable/table-row-selection.js +++ b/src/BIMDataComponents/BIMDataTable/table-row-selection.js @@ -49,17 +49,13 @@ function useRowSelection( rowSelectionToggleEffect(isSelected(), { key, data }); }; const toggleFullSelection = () => { - const selectedState = rowSelection.value.size < rows.value.length - ? rowSelection.value.size > 0 - ? null - : false - : rowSelection.value.size > 0; - if (selectedState || selectedState === null) { + const isSelected = () => rowSelection.value.size > 0; + if (isSelected()) { rowSelection.value = new Map(); } else { rowSelection.value = new Map(rows.value.map(({ key, data }) => [key, data])); } - fullSelectionToggleEffect(selectedState); + fullSelectionToggleEffect(isSelected()); }; return {