mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:25:57 +00:00
Merge branch 'main' into next
This commit is contained in:
commit
e61755182c
@ -167,6 +167,8 @@ describe('transformToFilter', () => {
|
||||
if (name === `${collectionName}.field1`) return {};
|
||||
if (name === `${collectionName}.field2`) return {};
|
||||
if (name === `${collectionName}.field3`) return { target: 'targetCollection', targetKey: 'id' };
|
||||
if (name === `${collectionName}.chinaRegion`)
|
||||
return { target: 'chinaRegions', targetKey: 'code', interface: 'chinaRegion' };
|
||||
return {};
|
||||
});
|
||||
|
||||
@ -242,4 +244,27 @@ describe('transformToFilter', () => {
|
||||
|
||||
expect(filter).toEqual(expectedFilter);
|
||||
});
|
||||
|
||||
it('should handle chinaRegion', () => {
|
||||
const values = {
|
||||
chinaRegion: [
|
||||
{
|
||||
code: '1',
|
||||
},
|
||||
{
|
||||
code: '2',
|
||||
},
|
||||
{
|
||||
code: '3',
|
||||
},
|
||||
],
|
||||
};
|
||||
const expectedFilter = {
|
||||
$and: [{ 'chinaRegion.code': { $eq: '3' } }],
|
||||
};
|
||||
|
||||
const filter = transformToFilter(values, operators, getCollectionJoinField, collectionName);
|
||||
|
||||
expect(filter).toEqual(expectedFilter);
|
||||
});
|
||||
});
|
||||
|
@ -142,6 +142,10 @@ export const transformToFilter = (
|
||||
if (collectionField?.target) {
|
||||
value = getValuesByPath(value, collectionField.targetKey || 'id');
|
||||
key = `${key}.${collectionField.targetKey || 'id'}`;
|
||||
|
||||
if (collectionField?.interface === 'chinaRegion') {
|
||||
value = _.last(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!value && value !== 0 && value !== false) {
|
||||
|
Loading…
Reference in New Issue
Block a user