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