mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:26:22 +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 { useFieldSchema } from '@formily/react';
|
||||||
import { SchemaSettings, SchemaSettingsNumberFormat, useColumnSchema, useIsFieldReadPretty } from '@nocobase/client';
|
import { SchemaSettings, SchemaSettingsNumberFormat, useColumnSchema, useIsFieldReadPretty } from '@nocobase/client';
|
||||||
|
import { useTargetCollectionField } from './components/Formula/Result';
|
||||||
export const FormulaComponentFieldSettings = new SchemaSettings({
|
export const FormulaComponentFieldSettings = new SchemaSettings({
|
||||||
name: 'fieldSettings:component:Formula.Result',
|
name: 'fieldSettings:component:Formula.Result',
|
||||||
items: [
|
items: [
|
||||||
@ -16,8 +16,13 @@ export const FormulaComponentFieldSettings = new SchemaSettings({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
useVisible() {
|
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();
|
const isFieldReadPretty = useIsFieldReadPretty();
|
||||||
return isFieldReadPretty;
|
return isFieldReadPretty && isNumberFormat;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -28,8 +28,9 @@ const TypedComponents = {
|
|||||||
string: InputString.ReadPretty,
|
string: InputString.ReadPretty,
|
||||||
};
|
};
|
||||||
|
|
||||||
function useTargetCollectionField() {
|
export function useTargetCollectionField(schema?) {
|
||||||
const fieldSchema = useFieldSchema();
|
const targetSchema = useFieldSchema();
|
||||||
|
const fieldSchema = schema || targetSchema;
|
||||||
const providedCollection = useCollection_deprecated();
|
const providedCollection = useCollection_deprecated();
|
||||||
const { getCollection, getCollectionField } = useCollectionManager_deprecated();
|
const { getCollection, getCollectionField } = useCollectionManager_deprecated();
|
||||||
const paths = (fieldSchema.name as string).split('.');
|
const paths = (fieldSchema.name as string).split('.');
|
||||||
|
Loading…
Reference in New Issue
Block a user