mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:36:05 +00:00
fix(data-vi): allow to map integer enum value (#5115)
This commit is contained in:
parent
6b03c725cf
commit
94aa8df382
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* This file is part of the NocoBase (R) project.
|
||||
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||
* Authors: NocoBase Team.
|
||||
*
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { processData } from '../utils';
|
||||
|
||||
describe('utils', () => {
|
||||
it('processFields', () => {
|
||||
expect(
|
||||
processData(
|
||||
[
|
||||
{
|
||||
name: 'tag',
|
||||
type: 'bigInt',
|
||||
interface: 'select',
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
{
|
||||
value: '1',
|
||||
label: 'Yes',
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
label: 'No',
|
||||
},
|
||||
],
|
||||
},
|
||||
label: 'Tag',
|
||||
value: 'tag',
|
||||
key: 'tag',
|
||||
},
|
||||
],
|
||||
[{ tag: 1 }],
|
||||
{},
|
||||
),
|
||||
).toEqual([{ tag: 'Yes' }]);
|
||||
});
|
||||
});
|
@ -93,7 +93,7 @@ export const processData = (selectedFields: FieldOption[], data: any[], scope: a
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((v) => parseEnum(field, v));
|
||||
}
|
||||
const option = options.find((option) => option.value === value);
|
||||
const option = options.find((option) => option.value === (value?.toString?.() || value));
|
||||
return Schema.compile(option?.label || value, scope);
|
||||
};
|
||||
return data.map((record) => {
|
||||
|
Loading…
Reference in New Issue
Block a user