Junyi 139ca9a635
refactor(plugin-formula): combine 2 formula field type into 1 (#1457)
* fix: observer

* refactor(plugin-formula): merge 2 formula field type

* fix(plugin-formula): fix types

* fix(plugin-formula): fix type

* fix(plugin-formula): fix formulajs version

* fix(plugin-formula): change to VariableInput to avoid range error

* test(plugin-formula): add test

* fix(plugin-formula): fix test case

* fix(plugin-formula): fix test case

* fix(plugin-formula): fix test case

* refactor(plugin-formula): move components into plugin

* fix(plugin-formula): fix migration

* fix(plugin-formula): revert legacy component to fix build

* fix(plugin-formula): fix test case

* fix(plugin-formula): fix test case

* fix(plugin-formula): fix read-pretty component

* fix(plugin-formula): fix formula result component

* feat(plugin-formula): add checkbox display X

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
2023-02-21 20:12:21 +08:00

58 lines
1.3 KiB
TypeScript

import { ISchema } from '@formily/react';
import { interfacesProperties } from '@nocobase/client';
import { MapTypes } from '../constants';
import { generateNTemplate } from '../locale';
const { defaultProps } = interfacesProperties;
if (Array.isArray(interfacesProperties.type.enum)) {
interfacesProperties.type.enum.push(
{
label: 'Point',
value: 'point',
},
{
label: 'LineString',
value: 'lineString',
},
{
label: 'Polygon',
value: 'polygon',
},
{
label: 'Circle',
value: 'circle',
},
);
}
export const commonSchema = {
properties: {
...defaultProps,
'uiSchema.x-component-props.mapType': {
title: generateNTemplate('Map type'),
type: 'string',
required: true,
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {
showSearch: false,
allowClear: false,
},
'x-disabled': '{{ isOverride || !createOnly }}',
default: 'amap',
enum: MapTypes
}
},
schemaInitialize(schema: ISchema, { readPretty, block }) {
if (block === 'Form') {
Object.assign(schema, {
'x-component-props': {
readOnly: readPretty ? true : false
},
'x-designer': 'Map.Designer',
});
}
},
}