mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
refactor: only numerical formula fields support format (#3962)
This commit is contained in:
parent
9f72b4e1ef
commit
c735664ea9
@ -1,6 +1,6 @@
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import { SchemaSettings, SchemaSettingsNumberFormat, useColumnSchema, useIsFieldReadPretty } from '@nocobase/client';
|
||||
|
||||
import { useTargetCollectionField } from './components/Formula/Result';
|
||||
export const FormulaComponentFieldSettings = new SchemaSettings({
|
||||
name: 'fieldSettings:component:Formula.Result',
|
||||
items: [
|
||||
@ -16,8 +16,13 @@ export const FormulaComponentFieldSettings = new SchemaSettings({
|
||||
};
|
||||
},
|
||||
useVisible() {
|
||||
const schema = useFieldSchema();
|
||||
const { fieldSchema: tableColumnSchema } = useColumnSchema();
|
||||
const fieldSchema = tableColumnSchema || schema;
|
||||
const { dataType } = useTargetCollectionField(fieldSchema) || {};
|
||||
const isNumberFormat = ['integer', 'bigInt', 'double', 'decimal'].includes(dataType);
|
||||
const isFieldReadPretty = useIsFieldReadPretty();
|
||||
return isFieldReadPretty;
|
||||
return isFieldReadPretty && isNumberFormat;
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -28,8 +28,9 @@ const TypedComponents = {
|
||||
string: InputString.ReadPretty,
|
||||
};
|
||||
|
||||
function useTargetCollectionField() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
export function useTargetCollectionField(schema?) {
|
||||
const targetSchema = useFieldSchema();
|
||||
const fieldSchema = schema || targetSchema;
|
||||
const providedCollection = useCollection_deprecated();
|
||||
const { getCollection, getCollectionField } = useCollectionManager_deprecated();
|
||||
const paths = (fieldSchema.name as string).split('.');
|
||||
|
Loading…
Reference in New Issue
Block a user