refactor: rename multi-check handlers for clarity and improve selection logic

This commit is contained in:
Javier Segarra 2025-04-29 09:02:50 +02:00
parent 34aa128246
commit 3c23b6b247
1 changed files with 6 additions and 13 deletions

View File

@ -644,21 +644,15 @@ const rowCtrlClickFunction = computed(() => {
}; };
return () => {}; return () => {};
}); });
const handleMultiCheck = (value) => { const handleHeaderSelection = (evt, data) => {
if (value) { if (evt === 'selected' && data) {
selected.value = tableRef.value.rows; selected.value = tableRef.value.rows;
} else { } else if (evt === 'selectAll') {
selected.value = [];
}
emit('update:selected', selected.value);
};
const handleSelectedAll = (data) => {
if (data) {
selected.value = data; selected.value = data;
} else { } else {
selected.value = []; selected.value = [];
} }
emit('update:selected', selected.value); emit('update:selected', selected.value);
}; };
</script> </script>
@ -718,7 +712,6 @@ const handleSelectedAll = (data) => {
:virtual-scroll="isTableMode" :virtual-scroll="isTableMode"
@virtual-scroll="onVirtualScroll" @virtual-scroll="onVirtualScroll"
@row-click="(event, row) => handleRowClick(event, row)" @row-click="(event, row) => handleRowClick(event, row)"
@update:selected="emit('update:selected', $event)"
@selection="(details) => handleSelection(details, rows)" @selection="(details) => handleSelection(details, rows)"
:hide-selected-banner="true" :hide-selected-banner="true"
:data-cy :data-cy
@ -729,8 +722,8 @@ const handleSelectedAll = (data) => {
:expand="$props.multiCheck.expand" :expand="$props.multiCheck.expand"
v-model="selectAll" v-model="selectAll"
:url="$attrs['url']" :url="$attrs['url']"
@update:selected="handleMultiCheck" @update:selected="handleHeaderSelection('selected', $event)"
@select:all="handleSelectedAll" @select:all="handleHeaderSelection('selectAll', $event)"
/> />
</template> </template>