mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: handle null value check and clear data in manual loading mode (#6460)
* fix: handle null value check and clear data in manual loading mode * fix: add clearSelection method and invoke it in relevant places
This commit is contained in:
parent
3b1f016256
commit
4269ff7412
@ -468,6 +468,10 @@ const useDoFilter = () => {
|
||||
block.defaultFilter,
|
||||
]);
|
||||
|
||||
if (_.isEmpty(storedFilter[uid])) {
|
||||
block.clearSelection?.();
|
||||
}
|
||||
|
||||
if (doNothingWhenFilterIsEmpty && _.isEmpty(storedFilter[uid])) {
|
||||
return;
|
||||
}
|
||||
@ -1349,6 +1353,7 @@ export const useAssociationFilterBlockProps = () => {
|
||||
[filterKey]: value,
|
||||
};
|
||||
} else {
|
||||
block.clearSelection?.();
|
||||
if (block.dataLoadingMode === 'manual') {
|
||||
return block.clearData();
|
||||
}
|
||||
@ -1442,6 +1447,8 @@ async function doReset({
|
||||
const target = targets.find((target) => target.uid === block.uid);
|
||||
if (!target) return;
|
||||
|
||||
block.clearSelection?.();
|
||||
|
||||
if (block.dataLoadingMode === 'manual') {
|
||||
return block.clearData();
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ export interface DataBlock {
|
||||
clearFilter: (uid: string) => void;
|
||||
/** 将数据区块的数据置为空 */
|
||||
clearData: () => void;
|
||||
/** 清除表格的选中项 */
|
||||
clearSelection?: () => void;
|
||||
/** 数据区块表中所有的关系字段 */
|
||||
associatedFields?: CollectionFieldOptions_deprecated[];
|
||||
/** 数据区块表中所有的外键字段 */
|
||||
@ -165,16 +167,21 @@ export const DataBlockCollector = ({
|
||||
clearData() {
|
||||
this.service.mutate(undefined);
|
||||
},
|
||||
clearSelection() {
|
||||
if (field) {
|
||||
field.data.clearSelectedRowKeys?.();
|
||||
}
|
||||
},
|
||||
});
|
||||
}, [
|
||||
associatedFields,
|
||||
collection,
|
||||
dataLoadingMode,
|
||||
field?.componentProps?.title,
|
||||
fieldSchema,
|
||||
params?.filter,
|
||||
recordDataBlocks,
|
||||
getDataBlockRequest,
|
||||
field,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -215,7 +215,7 @@ export const useFilterAPI = () => {
|
||||
// 保留原有的 filter
|
||||
const storedFilter = block.service.params?.[1]?.filters || {};
|
||||
|
||||
if (value !== undefined) {
|
||||
if (value != null) {
|
||||
storedFilter[uid] = {
|
||||
$and: [
|
||||
{
|
||||
@ -226,7 +226,11 @@ export const useFilterAPI = () => {
|
||||
],
|
||||
};
|
||||
} else {
|
||||
block.clearSelection?.();
|
||||
delete storedFilter[uid];
|
||||
if (block.dataLoadingMode === 'manual') {
|
||||
return block.clearData();
|
||||
}
|
||||
}
|
||||
|
||||
const mergedFilter = mergeFilter([
|
||||
|
@ -141,6 +141,7 @@ export const useTableBlockProps = () => {
|
||||
const storedFilter = block.service.params?.[1]?.filters || {};
|
||||
|
||||
if (selectedRow.includes(record[tableBlockContextBasicValue.rowKey])) {
|
||||
block.clearSelection?.();
|
||||
if (block.dataLoadingMode === 'manual') {
|
||||
return block.clearData();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user