Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comp:transfer): select all status error #1442

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,35 @@ export function useTransferSelectState(
getKey,
} = transferDataContext

const sourceDataCount = computed(() =>
props.mode === 'immediate' ? dataKeyMap.value.size : sourceDataKeys.value.size,
)
const targetDataCount = computed(() => targetDataKeys.value.size)
const sourceCheckableDataCount = computed(() => {
const sourceDataCount = props.mode === 'immediate' ? dataKeyMap.value.size : sourceDataKeys.value.size
const disabledCount = props.mode === 'immediate' ? disabledKeys.value.size : disabledSourceKeys.value.size

return sourceDataCount.value - disabledCount
return sourceDataCount - disabledCount
})
const targetCheckableDataCount = computed(() => targetDataKeys.value.size - disabledTargetKeys.value.size)

const sourceSelectAllStatus = computed(() => {
return {
checked: sourceDataCount.value >= sourceSelectedKeys.value.length && sourceSelectedKeys.value.length > 0,
indeterminate: sourceDataCount.value > sourceSelectedKeys.value.length && sourceSelectedKeys.value.length > 0,
}
})
const targetSelectAllStatus = computed(() => {
const getAllSelectedStatus = (isSource: boolean) => {
const allSelectedKeys = transferDataStrategy.value.getAllSelectedKeys(
true,
isSource ? (props.mode === 'immediate' ? dataSource.value : sourceData.value) : targetData.value,
new Set(),
new Set(),
getKey.value,
)
const selectedkeyCount = (isSource ? sourceSelectedKeys : targetSelectedKeys).value.length
const selectedKeySet = isSource ? sourceSelectedKeySet.value : targetSelectedKeySet.value

return {
checked: targetDataCount.value >= targetSelectedKeys.value.length && targetSelectedKeys.value.length > 0,
indeterminate: targetDataCount.value > targetSelectedKeys.value.length && targetSelectedKeys.value.length > 0,
checked: selectedkeyCount > 0,
indeterminate:
(allSelectedKeys.length !== selectedkeyCount || allSelectedKeys.some(key => !selectedKeySet.has(key))) &&
selectedkeyCount > 0,
}
})
}

const sourceSelectAllStatus = computed(() => getAllSelectedStatus(true))
const targetSelectAllStatus = computed(() => getAllSelectedStatus(false))

let transferBySelectionChangeLocked = false
watch(sourceSelectedKeySet, (currentCheckedKeys, originalCheckedKeys) => {
Expand Down