Merge branch 'develop' of github.com:nocobase/nocobase into develop
This commit is contained in:
commit
3150e7eeed
@ -19,12 +19,7 @@ import { useMemo } from 'react';
|
|||||||
import { CodeOutlined } from '@ant-design/icons';
|
import { CodeOutlined } from '@ant-design/icons';
|
||||||
import Editor from '@monaco-editor/react';
|
import Editor from '@monaco-editor/react';
|
||||||
|
|
||||||
import {
|
import { ArrayItems, ArrayCollapse, FormLayout, FormItem as FormilyFormItem } from '@formily/antd';
|
||||||
ArrayItems,
|
|
||||||
ArrayCollapse,
|
|
||||||
FormLayout,
|
|
||||||
FormItem as FormilyFormItem,
|
|
||||||
} from '@formily/antd';
|
|
||||||
|
|
||||||
import { Space, Card, Modal, Spin } from 'antd';
|
import { Space, Card, Modal, Spin } from 'antd';
|
||||||
import { ArrayTable } from '../../schemas/array-table';
|
import { ArrayTable } from '../../schemas/array-table';
|
||||||
@ -34,10 +29,7 @@ import { Calendar } from '../../schemas/calendar';
|
|||||||
import { Cascader } from '../../schemas/cascader';
|
import { Cascader } from '../../schemas/cascader';
|
||||||
import { Checkbox } from '../../schemas/checkbox';
|
import { Checkbox } from '../../schemas/checkbox';
|
||||||
import { ColorSelect } from '../../schemas/color-select';
|
import { ColorSelect } from '../../schemas/color-select';
|
||||||
import {
|
import { DatabaseField, DatabaseCollection } from '../../schemas/database-field';
|
||||||
DatabaseField,
|
|
||||||
DatabaseCollection,
|
|
||||||
} from '../../schemas/database-field';
|
|
||||||
import { DatePicker } from '../../schemas/date-picker';
|
import { DatePicker } from '../../schemas/date-picker';
|
||||||
import { Filter } from '../../schemas/filter';
|
import { Filter } from '../../schemas/filter';
|
||||||
import { Form } from '../../schemas/form';
|
import { Form } from '../../schemas/form';
|
||||||
@ -70,11 +62,7 @@ import { ISchema, FormilyISchema } from '../../schemas';
|
|||||||
import { Resource } from '../../resource';
|
import { Resource } from '../../resource';
|
||||||
import { useRequest } from 'ahooks';
|
import { useRequest } from 'ahooks';
|
||||||
import { CascaderOptionType } from 'antd/lib/cascader';
|
import { CascaderOptionType } from 'antd/lib/cascader';
|
||||||
import {
|
import { useClient, useCollectionContext, useResourceRequest } from '../../constate';
|
||||||
useClient,
|
|
||||||
useCollectionContext,
|
|
||||||
useResourceRequest,
|
|
||||||
} from '../../constate';
|
|
||||||
import { i18n } from '../../i18n';
|
import { i18n } from '../../i18n';
|
||||||
|
|
||||||
export const BlockContext = createContext({ dragRef: null });
|
export const BlockContext = createContext({ dragRef: null });
|
||||||
@ -165,12 +153,7 @@ const useAssociationResource = (options) => {
|
|||||||
const { collection } = useCollectionContext();
|
const { collection } = useCollectionContext();
|
||||||
const ctx = useContext(TableRowContext);
|
const ctx = useContext(TableRowContext);
|
||||||
const associatedKey = ctx?.record?.id;
|
const associatedKey = ctx?.record?.id;
|
||||||
console.log(
|
console.log('useAssociationResource', collection, collectionField, schema['x-component-props']);
|
||||||
'useAssociationResource',
|
|
||||||
collection,
|
|
||||||
collectionField,
|
|
||||||
schema['x-component-props'],
|
|
||||||
);
|
|
||||||
const { associatedName, resourceName } = schema['x-component-props'] || {};
|
const { associatedName, resourceName } = schema['x-component-props'] || {};
|
||||||
const resource = useResourceRequest({
|
const resource = useResourceRequest({
|
||||||
associatedName,
|
associatedName,
|
||||||
@ -292,10 +275,7 @@ export function findPropertyByPath(schema: Schema, path?: any): Schema {
|
|||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addPropertyBefore(
|
export function addPropertyBefore(target: Schema, data: ISchema | FormilyISchema) {
|
||||||
target: Schema,
|
|
||||||
data: ISchema | FormilyISchema,
|
|
||||||
) {
|
|
||||||
Object.keys(target.parent.properties).forEach((name) => {
|
Object.keys(target.parent.properties).forEach((name) => {
|
||||||
if (name === target.name) {
|
if (name === target.name) {
|
||||||
target.parent.addProperty(data.name, data);
|
target.parent.addProperty(data.name, data);
|
||||||
@ -306,10 +286,7 @@ export function addPropertyBefore(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addPropertyAfter(
|
export function addPropertyAfter(target: Schema, data: ISchema | FormilyISchema) {
|
||||||
target: Schema,
|
|
||||||
data: ISchema | FormilyISchema,
|
|
||||||
) {
|
|
||||||
Object.keys(target.parent.properties).forEach((name) => {
|
Object.keys(target.parent.properties).forEach((name) => {
|
||||||
const property = target.parent.properties[name];
|
const property = target.parent.properties[name];
|
||||||
property.parent.removeProperty(property.name);
|
property.parent.removeProperty(property.name);
|
||||||
@ -346,8 +323,7 @@ export function useDesignable(path?: any) {
|
|||||||
const schemaPath = path || useSchemaPath();
|
const schemaPath = path || useSchemaPath();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
let current;
|
let current;
|
||||||
let currentSchema = (current =
|
let currentSchema = (current = findPropertyByPath(schema, schemaPath) || ({} as Schema));
|
||||||
findPropertyByPath(schema, schemaPath) || ({} as Schema));
|
|
||||||
if (!currentSchema) {
|
if (!currentSchema) {
|
||||||
currentSchema = fieldSchema;
|
currentSchema = fieldSchema;
|
||||||
}
|
}
|
||||||
@ -356,10 +332,8 @@ export function useDesignable(path?: any) {
|
|||||||
}
|
}
|
||||||
// console.log('useDesignable', { schema, schemaPath, currentSchema });
|
// console.log('useDesignable', { schema, schemaPath, currentSchema });
|
||||||
const options = useContext(SchemaOptionsContext);
|
const options = useContext(SchemaOptionsContext);
|
||||||
let DesignableBar = get(
|
let DesignableBar = get(options.components, currentSchema['x-designable-bar']);
|
||||||
options.components,
|
debugger;
|
||||||
currentSchema['x-designable-bar'],
|
|
||||||
);
|
|
||||||
if (!designable) {
|
if (!designable) {
|
||||||
DesignableBar = () => null;
|
DesignableBar = () => null;
|
||||||
}
|
}
|
||||||
@ -405,10 +379,7 @@ export function useDesignable(path?: any) {
|
|||||||
refresh();
|
refresh();
|
||||||
return target.properties[property.name];
|
return target.properties[property.name];
|
||||||
},
|
},
|
||||||
appendChild: (
|
appendChild: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {
|
||||||
property: ISchema | FormilyISchema,
|
|
||||||
targetPath?: any,
|
|
||||||
): Schema => {
|
|
||||||
let target = currentSchema;
|
let target = currentSchema;
|
||||||
if (targetPath) {
|
if (targetPath) {
|
||||||
target = findPropertyByPath(schema, targetPath);
|
target = findPropertyByPath(schema, targetPath);
|
||||||
@ -435,10 +406,7 @@ export function useDesignable(path?: any) {
|
|||||||
refresh();
|
refresh();
|
||||||
return target.properties[property.name];
|
return target.properties[property.name];
|
||||||
},
|
},
|
||||||
insertAfter: (
|
insertAfter: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {
|
||||||
property: ISchema | FormilyISchema,
|
|
||||||
targetPath?: any,
|
|
||||||
): Schema => {
|
|
||||||
let target = currentSchema;
|
let target = currentSchema;
|
||||||
if (targetPath) {
|
if (targetPath) {
|
||||||
target = findPropertyByPath(schema, targetPath);
|
target = findPropertyByPath(schema, targetPath);
|
||||||
@ -626,17 +594,8 @@ const FormValues = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CodeOutlined onClick={() => setVisible(true)} />
|
<CodeOutlined onClick={() => setVisible(true)} />
|
||||||
<Modal
|
<Modal width={'50%'} onOk={() => setVisible(false)} onCancel={() => setVisible(false)} visible={visible}>
|
||||||
width={'50%'}
|
<Editor height="60vh" defaultLanguage="json" value={JSON.stringify(form.values, null, 2)} />
|
||||||
onOk={() => setVisible(false)}
|
|
||||||
onCancel={() => setVisible(false)}
|
|
||||||
visible={visible}
|
|
||||||
>
|
|
||||||
<Editor
|
|
||||||
height="60vh"
|
|
||||||
defaultLanguage="json"
|
|
||||||
value={JSON.stringify(form.values, null, 2)}
|
|
||||||
/>
|
|
||||||
{/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
@ -647,21 +606,9 @@ const CodePreview = ({ schema }) => {
|
|||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CodeOutlined
|
<CodeOutlined style={{ position: 'relative', zIndex: 100 }} onClick={() => setVisible(true)} />
|
||||||
style={{ position: 'relative', zIndex: 100 }}
|
<Modal width={'50%'} onOk={() => setVisible(false)} onCancel={() => setVisible(false)} visible={visible}>
|
||||||
onClick={() => setVisible(true)}
|
<Editor height="60vh" defaultLanguage="json" value={JSON.stringify(schema.toJSON(), null, 2)} />
|
||||||
/>
|
|
||||||
<Modal
|
|
||||||
width={'50%'}
|
|
||||||
onOk={() => setVisible(false)}
|
|
||||||
onCancel={() => setVisible(false)}
|
|
||||||
visible={visible}
|
|
||||||
>
|
|
||||||
<Editor
|
|
||||||
height="60vh"
|
|
||||||
defaultLanguage="json"
|
|
||||||
value={JSON.stringify(schema.toJSON(), null, 2)}
|
|
||||||
/>
|
|
||||||
{/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
@ -789,9 +736,7 @@ export const SchemaRenderer = (props: SchemaRendererProps) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DesignableContext.Consumer>
|
<DesignableContext.Consumer>{props.render || defaultRender}</DesignableContext.Consumer>
|
||||||
{props.render || defaultRender}
|
|
||||||
</DesignableContext.Consumer>
|
|
||||||
</DesignableContext.Provider>
|
</DesignableContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -27,6 +27,7 @@ import { TableActionDesignableBar } from './TableActionDesignableBar';
|
|||||||
import { TableOperationDesignableBar } from './TableOperationDesignableBar';
|
import { TableOperationDesignableBar } from './TableOperationDesignableBar';
|
||||||
import { TableProvider } from './TableProvider';
|
import { TableProvider } from './TableProvider';
|
||||||
import { TableIndex } from './TableIndex';
|
import { TableIndex } from './TableIndex';
|
||||||
|
import { TableColumnDesignableBar } from './TableColumnDesignableBar';
|
||||||
|
|
||||||
export const Table: any = observer((props: any) => {
|
export const Table: any = observer((props: any) => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
@ -51,6 +52,7 @@ Table.Action = () => null;
|
|||||||
Table.Action.DesignableBar = TableActionDesignableBar;
|
Table.Action.DesignableBar = TableActionDesignableBar;
|
||||||
Table.Cell = TableCell;
|
Table.Cell = TableCell;
|
||||||
Table.Column = TableColumn;
|
Table.Column = TableColumn;
|
||||||
|
Table.Column.DesignableBar = TableColumnDesignableBar;
|
||||||
Table.SortHandle = TableSortHandle;
|
Table.SortHandle = TableSortHandle;
|
||||||
Table.DesignableBar = TableDesignableBar;
|
Table.DesignableBar = TableDesignableBar;
|
||||||
Table.SimpleDesignableBar = SimpleDesignableBar;
|
Table.SimpleDesignableBar = SimpleDesignableBar;
|
||||||
|
Loading…
Reference in New Issue
Block a user