@nocobase/client 0.5.0-alpha.33 → 0.5.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/admin-layout/Collections/index.d.ts.map +1 -1
- package/lib/components/admin-layout/Collections/index.js +10 -0
- package/lib/components/admin-layout/Collections/index.js.map +1 -1
- package/lib/components/schema-renderer/index.d.ts.map +1 -1
- package/lib/components/schema-renderer/index.js +62 -1
- package/lib/components/schema-renderer/index.js.map +1 -1
- package/lib/constate/Collections.d.ts.map +1 -1
- package/lib/constate/Collections.js +1 -1
- package/lib/constate/Collections.js.map +1 -1
- package/lib/locale/zh_CN.d.ts.map +1 -1
- package/lib/locale/zh_CN.js +1 -1
- package/lib/locale/zh_CN.js.map +1 -1
- package/lib/schemas/database-field/interfaces/linkTo.d.ts.map +1 -1
- package/lib/schemas/database-field/interfaces/linkTo.js +5 -1
- package/lib/schemas/database-field/interfaces/linkTo.js.map +1 -1
- package/lib/schemas/form/Field.DesignableBar.d.ts.map +1 -1
- package/lib/schemas/form/Field.DesignableBar.js +4 -1
- package/lib/schemas/form/Field.DesignableBar.js.map +1 -1
- package/lib/schemas/select/index.d.ts.map +1 -1
- package/lib/schemas/select/index.js +25 -10
- package/lib/schemas/select/index.js.map +1 -1
- package/lib/schemas/table/index.d.ts.map +1 -1
- package/lib/schemas/table/index.js +3 -1
- package/lib/schemas/table/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/admin-layout/Collections/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAC;AA6BxE,eAAO,MAAM,WAAW,oBAAsB,CAAC;AAqvB/C,eAAO,MAAM,WAAW,mBAWvB,CAAC;AAEF,eAAe,WAAW,CAAC","file":"index.d.ts","sourcesContent":["import { SchemaRenderer } from '../../../';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { FormItem } from '@formily/antd';\nimport { action } from '@formily/reactive';\nimport {\n useCollectionContext,\n useCollectionsContext,\n} from '../../../constate/Collections';\nimport { Button, Drawer, Menu, Dropdown, Space } from 'antd';\nimport { PlusOutlined, DownOutlined } from '@ant-design/icons';\nimport cls from 'classnames';\nimport { uid, isValid, clone } from '@formily/shared';\nimport { Resource } from '../../../resource';\nimport { TableRowContext, useTable } from '../../../schemas/table';\nimport { useRequest } from 'ahooks';\nimport { VisibleContext } from '../../../context';\nimport { connect, FormProvider, observer, useForm } from '@formily/react';\nimport { DescriptionsContext } from '../../../schemas/form';\nimport { createContext } from 'react';\nimport { ISchema } from '../../../';\nimport { createForm, Field } from '@formily/core';\nimport { SchemaField } from '../../../schemas';\nimport {\n interfaces,\n options,\n} from '../../../schemas/database-field/interfaces';\nimport { useResourceRequest } from '../../../constate';\nimport { useTranslation } from 'react-i18next';\nimport { useCompile } from '../../../hooks/useCompile';\n\nexport const RoleContext = createContext(null);\n\nfunction VisibleProvider(props) {\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n return (\n <VisibleContext.Provider value={[visible, setVisible]}>\n {props.children}\n </VisibleContext.Provider>\n );\n}\n\nconst useResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nconst useCollectionsResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nclass ActionPermissionResource extends Resource {\n save(options?: any) {\n console.log('ActionPermissionResource.save');\n return Promise.resolve({});\n }\n}\n\nconst useActionPermissionSubmit = () => {\n const form = useForm();\n const role = useContext(RoleContext);\n const resource = useResourceRequest({\n resourceName: 'roles',\n resourceKey: role.name,\n });\n return {\n async run() {\n await resource.save(form.values);\n console.log('useActionPermissionSubmit', form.values?.actionPermissions);\n },\n };\n};\n\nconst useActionPermissionResource = ({ onSuccess }) => {\n const role = useContext(RoleContext);\n console.log('RoleContext', role);\n // const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest(\n {\n resourceName: 'action_permissions',\n },\n ActionPermissionResource,\n );\n const service = useRequest(\n (params?: any) => {\n return resource.list({\n ...params,\n filter: {\n role_name: role.name,\n collection_name: ctx.record.name,\n },\n appends: ['fields'],\n });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess(data) {\n console.log('actionPermissions', data);\n onSuccess({\n actionPermissions: data.map((permission) => {\n const item: any = {};\n Object.keys(permission).forEach((key) => {\n if (isValid(permission[key])) {\n item[key] = permission[key];\n }\n });\n item.fields = permission?.fields.map((field) => field.key) || [];\n return item;\n }),\n });\n },\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useDetailsResource = ({ onSuccess }) => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest({\n resourceName: 'collections',\n resourceKey: ctx.record[props.rowKey],\n });\n const service = useRequest(\n (params?: any) => {\n return resource.get({ ...params });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess,\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useFieldsResource = () => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n class FieldResource extends Resource {\n list(options) {\n return super.list({\n ...options,\n filter: { state: 1, collection_name: ctx.record[props.rowKey] },\n });\n }\n }\n const resource = useResourceRequest('fields', FieldResource);\n return {\n resource,\n };\n};\n\nconst fieldInterfaces = [];\nfor (const [key, schema] of interfaces) {\n fieldInterfaces.push({\n value: key,\n label: schema.title,\n disabled: schema.disabled,\n });\n}\n\nconst collectionSchema: ISchema = {\n type: 'array',\n 'x-decorator': 'VisibleProvider',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'key',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n defaultAppends: ['uiSchema'],\n useResource: useFieldsResource,\n collectionName: 'fields',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Add new')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'CreateFieldButton',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Field display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n 'uiSchema.title': {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Field name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column3: {\n type: 'void',\n title: \"{{t('Field type')}}\",\n 'x-component': 'Table.Column',\n properties: {\n interface: {\n type: 'string',\n 'x-component': 'Select',\n 'x-read-pretty': true,\n // @ts-ignore\n enum: fieldInterfaces,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'EditFieldButton',\n 'x-component-props': {\n type: 'link',\n useAction() {\n return {\n async run() {\n alert('abc');\n },\n };\n },\n },\n 'x-action-type': 'update',\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: '删除数据',\n content: '删除后无法恢复,确定要删除吗?',\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction FieldConfigTitle() {\n const ctx = useContext(TableRowContext);\n const { t } = useTranslation();\n const compile = useCompile();\n return <>{t('Configure fields of {{title}}', { title: compile(ctx.record.title) })}</>;\n}\n\nfunction useCollectionResource({ onSuccess }) {\n const visible = useContext(VisibleContext);\n const resource = useResourceRequest('collections');\n useEffect(() => {\n visible && onSuccess({ name: `t_${uid()}` });\n }, [visible]);\n return { resource };\n}\n\nconst schema: ISchema = {\n type: 'void',\n name: 'action',\n 'x-component': 'Action',\n 'x-component-props': {\n tooltip: \"{{ t('Collections & Fields') }}\",\n className: 'nb-database-config',\n icon: 'DatabaseOutlined',\n type: 'primary',\n },\n properties: {\n modal1: {\n type: 'void',\n title: \"{{t('Collections & Fields')}}\",\n 'x-component': 'Action.Drawer',\n properties: {\n table: {\n type: 'array',\n // 'x-decorator': 'CardItem',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'name',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n useResource,\n collectionName: 'collections',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n properties: {\n modal: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useCollectionResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableCreateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n name: {\n type: 'string',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n description:\n \"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}\",\n },\n },\n },\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n title: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Configure fields')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'view',\n properties: {\n [uid()]: {\n type: 'void',\n title: <FieldConfigTitle />,\n // 'x-decorator': 'RoleProvider',\n 'x-component': 'Action.Drawer',\n 'x-component-props': {},\n properties: {\n [uid()]: collectionSchema,\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'update',\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useDetailsResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableUpdateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction CreateFieldButton() {\n const { t } = useTranslation();\n const compile = useCompile();\n const { refresh } = useCollectionsContext();\n const ctx = useContext(TableRowContext);\n const { service } = useTable();\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const [properties, setProperties] = useState({});\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n\n const menu = (\n <Menu\n onClick={(info) => {\n console.log('click', info.key);\n const schema = interfaces.get(info.key);\n form.setValues({\n ...clone(schema.default),\n collection_name: ctx.record.name,\n key: uid(),\n name: `f_${uid()}`,\n interface: info.key,\n }, 'overwrite');\n setProperties(clone(schema.properties));\n setVisible(true);\n }}\n >\n {options.map(\n (option, groupIndex) =>\n option.children.length > 0 && (\n <Menu.SubMenu key={groupIndex} title={compile(option.label)}>\n {option.children.map((item) => (\n <Menu.Item\n disabled={item.disabled}\n style={{ minWidth: 120 }}\n key={item.name}\n >\n {compile(item.title)}\n </Menu.Item>\n ))}\n </Menu.SubMenu>\n ),\n )}\n </Menu>\n );\n return (\n <>\n <Dropdown overlay={menu} overlayClassName={'all-fields'}>\n <Button type={'primary'} icon={<PlusOutlined />}>\n {t('Add new')} <DownOutlined />\n </Button>\n </Dropdown>\n <Drawer\n title={t('Add field')}\n width={'50%'}\n visible={visible}\n onClose={async () => {\n await form.clearFormGraph();\n setVisible(false);\n }}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={async () => {\n await form.clearFormGraph();\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n await resource.save(form.values);\n setVisible(false);\n await form.reset();\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties,\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nfunction EditFieldButton() {\n const { t } = useTranslation();\n const { refresh, findCollection } = useCollectionsContext();\n const { service } = useTable();\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const schema = interfaces.get(ctx.record.interface);\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n return (\n <>\n <Button\n type={'link'}\n onClick={() => {\n setVisible(true);\n const collection = findCollection(ctx.record.collection_name);\n const values = collection?.generalFields?.find(\n (field) => field.key === ctx.record.key,\n );\n form.setValues(clone(values || {}));\n }}\n >\n {t('Edit')}\n </Button>\n <Drawer\n title={t('Edit field')}\n width={'50%'}\n visible={visible}\n onClose={() => setVisible(false)}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={() => {\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n await resource.save(form.values, {\n resourceKey: ctx.record.key,\n });\n setVisible(false);\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties: clone(schema.properties),\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nexport const Collections = () => {\n return (\n <SchemaRenderer\n components={{\n VisibleProvider,\n CreateFieldButton,\n EditFieldButton,\n }}\n schema={schema}\n />\n );\n};\n\nexport default Collections;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/admin-layout/Collections/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAC;AA6BxE,eAAO,MAAM,WAAW,oBAAsB,CAAC;AA2vB/C,eAAO,MAAM,WAAW,mBAWvB,CAAC;AAEF,eAAe,WAAW,CAAC","file":"index.d.ts","sourcesContent":["import { SchemaRenderer } from '../../../';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { FormItem } from '@formily/antd';\nimport { action } from '@formily/reactive';\nimport {\n useCollectionContext,\n useCollectionsContext,\n} from '../../../constate/Collections';\nimport { Button, Drawer, Menu, Dropdown, Space } from 'antd';\nimport { PlusOutlined, DownOutlined } from '@ant-design/icons';\nimport cls from 'classnames';\nimport { uid, isValid, clone } from '@formily/shared';\nimport { Resource } from '../../../resource';\nimport { TableRowContext, useTable } from '../../../schemas/table';\nimport { useRequest } from 'ahooks';\nimport { VisibleContext } from '../../../context';\nimport { connect, FormProvider, observer, useForm } from '@formily/react';\nimport { DescriptionsContext } from '../../../schemas/form';\nimport { createContext } from 'react';\nimport { ISchema } from '../../../';\nimport { createForm, Field } from '@formily/core';\nimport { SchemaField } from '../../../schemas';\nimport {\n interfaces,\n options,\n} from '../../../schemas/database-field/interfaces';\nimport { useResourceRequest } from '../../../constate';\nimport { useTranslation } from 'react-i18next';\nimport { useCompile } from '../../../hooks/useCompile';\n\nexport const RoleContext = createContext(null);\n\nfunction VisibleProvider(props) {\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n return (\n <VisibleContext.Provider value={[visible, setVisible]}>\n {props.children}\n </VisibleContext.Provider>\n );\n}\n\nconst useResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nconst useCollectionsResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nclass ActionPermissionResource extends Resource {\n save(options?: any) {\n console.log('ActionPermissionResource.save');\n return Promise.resolve({});\n }\n}\n\nconst useActionPermissionSubmit = () => {\n const form = useForm();\n const role = useContext(RoleContext);\n const resource = useResourceRequest({\n resourceName: 'roles',\n resourceKey: role.name,\n });\n return {\n async run() {\n await resource.save(form.values);\n console.log('useActionPermissionSubmit', form.values?.actionPermissions);\n },\n };\n};\n\nconst useActionPermissionResource = ({ onSuccess }) => {\n const role = useContext(RoleContext);\n console.log('RoleContext', role);\n // const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest(\n {\n resourceName: 'action_permissions',\n },\n ActionPermissionResource,\n );\n const service = useRequest(\n (params?: any) => {\n return resource.list({\n ...params,\n filter: {\n role_name: role.name,\n collection_name: ctx.record.name,\n },\n appends: ['fields'],\n });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess(data) {\n console.log('actionPermissions', data);\n onSuccess({\n actionPermissions: data.map((permission) => {\n const item: any = {};\n Object.keys(permission).forEach((key) => {\n if (isValid(permission[key])) {\n item[key] = permission[key];\n }\n });\n item.fields = permission?.fields.map((field) => field.key) || [];\n return item;\n }),\n });\n },\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useDetailsResource = ({ onSuccess }) => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest({\n resourceName: 'collections',\n resourceKey: ctx.record[props.rowKey],\n });\n const service = useRequest(\n (params?: any) => {\n return resource.get({ ...params });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess,\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useFieldsResource = () => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n class FieldResource extends Resource {\n list(options) {\n return super.list({\n ...options,\n filter: { state: 1, collection_name: ctx.record[props.rowKey] },\n });\n }\n }\n const resource = useResourceRequest('fields', FieldResource);\n return {\n resource,\n };\n};\n\nconst fieldInterfaces = [];\nfor (const [key, schema] of interfaces) {\n fieldInterfaces.push({\n value: key,\n label: schema.title,\n disabled: schema.disabled,\n });\n}\n\nconst collectionSchema: ISchema = {\n type: 'array',\n 'x-decorator': 'VisibleProvider',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'key',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n defaultAppends: ['uiSchema'],\n useResource: useFieldsResource,\n collectionName: 'fields',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Add new')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'CreateFieldButton',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Field display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n 'uiSchema.title': {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Field name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column3: {\n type: 'void',\n title: \"{{t('Field type')}}\",\n 'x-component': 'Table.Column',\n properties: {\n interface: {\n type: 'string',\n 'x-component': 'Select',\n 'x-read-pretty': true,\n // @ts-ignore\n enum: fieldInterfaces,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'EditFieldButton',\n 'x-component-props': {\n type: 'link',\n useAction() {\n return {\n async run() {\n alert('abc');\n },\n };\n },\n },\n 'x-action-type': 'update',\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: '删除数据',\n content: '删除后无法恢复,确定要删除吗?',\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction FieldConfigTitle() {\n const ctx = useContext(TableRowContext);\n const { t } = useTranslation();\n const compile = useCompile();\n return <>{t('Configure fields of {{title}}', { title: compile(ctx.record.title) })}</>;\n}\n\nfunction useCollectionResource({ onSuccess }) {\n const visible = useContext(VisibleContext);\n const resource = useResourceRequest('collections');\n useEffect(() => {\n visible && onSuccess({ name: `t_${uid()}` });\n }, [visible]);\n return { resource };\n}\n\nconst schema: ISchema = {\n type: 'void',\n name: 'action',\n 'x-component': 'Action',\n 'x-component-props': {\n tooltip: \"{{ t('Collections & Fields') }}\",\n className: 'nb-database-config',\n icon: 'DatabaseOutlined',\n type: 'primary',\n },\n properties: {\n modal1: {\n type: 'void',\n title: \"{{t('Collections & Fields')}}\",\n 'x-component': 'Action.Drawer',\n properties: {\n table: {\n type: 'array',\n // 'x-decorator': 'CardItem',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'name',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n useResource,\n collectionName: 'collections',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n properties: {\n modal: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useCollectionResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableCreateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n name: {\n type: 'string',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n description:\n \"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}\",\n },\n },\n },\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n title: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Configure fields')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'view',\n properties: {\n [uid()]: {\n type: 'void',\n title: <FieldConfigTitle />,\n // 'x-decorator': 'RoleProvider',\n 'x-component': 'Action.Drawer',\n 'x-component-props': {},\n properties: {\n [uid()]: collectionSchema,\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'update',\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useDetailsResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableUpdateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction CreateFieldButton() {\n const { t } = useTranslation();\n const compile = useCompile();\n const { refresh } = useCollectionsContext();\n const ctx = useContext(TableRowContext);\n const { service } = useTable();\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const [properties, setProperties] = useState({});\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n\n const menu = (\n <Menu\n onClick={(info) => {\n console.log('click', info.key);\n const schema = interfaces.get(info.key);\n form.setValues({\n ...clone(schema.default),\n collection_name: ctx.record.name,\n key: uid(),\n name: `f_${uid()}`,\n interface: info.key,\n }, 'overwrite');\n setProperties(clone(schema.properties));\n setVisible(true);\n }}\n >\n {options.map(\n (option, groupIndex) =>\n option.children.length > 0 && (\n <Menu.SubMenu key={groupIndex} title={compile(option.label)}>\n {option.children.map((item) => (\n <Menu.Item\n disabled={item.disabled}\n style={{ minWidth: 120 }}\n key={item.name}\n >\n {compile(item.title)}\n </Menu.Item>\n ))}\n </Menu.SubMenu>\n ),\n )}\n </Menu>\n );\n return (\n <>\n <Dropdown overlay={menu} overlayClassName={'all-fields'}>\n <Button type={'primary'} icon={<PlusOutlined />}>\n {t('Add new')} <DownOutlined />\n </Button>\n </Dropdown>\n <Drawer\n title={t('Add field')}\n width={'50%'}\n visible={visible}\n onClose={async () => {\n await form.clearFormGraph();\n setVisible(false);\n }}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={async () => {\n console.log('form.values', form.values);\n await form.clearFormGraph();\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n const fieldInterface = interfaces.get(form.values?.interface);\n fieldInterface?.initialize && fieldInterface?.initialize(form.values);\n console.log('form.values', form.values);\n await resource.save(form.values);\n setVisible(false);\n await form.reset();\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties,\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nfunction EditFieldButton() {\n const { t } = useTranslation();\n const { refresh, findCollection } = useCollectionsContext();\n const { service } = useTable();\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const schema = interfaces.get(ctx.record.interface);\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n return (\n <>\n <Button\n type={'link'}\n onClick={() => {\n setVisible(true);\n const collection = findCollection(ctx.record.collection_name);\n const values = collection?.generalFields?.find(\n (field) => field.key === ctx.record.key,\n );\n form.setValues(clone(values || {}));\n }}\n >\n {t('Edit')}\n </Button>\n <Drawer\n title={t('Edit field')}\n width={'50%'}\n visible={visible}\n onClose={() => setVisible(false)}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={() => {\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n const fieldInterface = interfaces.get(form.values?.interface);\n fieldInterface?.initialize && fieldInterface?.initialize(form.values);\n await resource.save(form.values, {\n resourceKey: ctx.record.key,\n });\n setVisible(false);\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties: clone(schema.properties),\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nexport const Collections = () => {\n return (\n <SchemaRenderer\n components={{\n VisibleProvider,\n CreateFieldButton,\n EditFieldButton,\n }}\n schema={schema}\n />\n );\n};\n\nexport default Collections;\n"]}
|
|
@@ -827,12 +827,18 @@ function CreateFieldButton() {
|
|
|
827
827
|
}
|
|
828
828
|
}, react_1.default.createElement(antd_1.Button, {
|
|
829
829
|
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
830
|
+
console.log('form.values', form.values);
|
|
830
831
|
yield form.clearFormGraph();
|
|
831
832
|
setVisible(false);
|
|
832
833
|
})
|
|
833
834
|
}, t('Cancel')), react_1.default.createElement(antd_1.Button, {
|
|
834
835
|
type: 'primary',
|
|
835
836
|
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
837
|
+
var _c;
|
|
838
|
+
|
|
839
|
+
const fieldInterface = interfaces_1.interfaces.get((_c = form.values) === null || _c === void 0 ? void 0 : _c.interface);
|
|
840
|
+
(fieldInterface === null || fieldInterface === void 0 ? void 0 : fieldInterface.initialize) && (fieldInterface === null || fieldInterface === void 0 ? void 0 : fieldInterface.initialize(form.values));
|
|
841
|
+
console.log('form.values', form.values);
|
|
836
842
|
yield resource.save(form.values);
|
|
837
843
|
setVisible(false);
|
|
838
844
|
yield form.reset();
|
|
@@ -941,6 +947,10 @@ function EditFieldButton() {
|
|
|
941
947
|
}, t('Cancel')), react_1.default.createElement(antd_1.Button, {
|
|
942
948
|
type: 'primary',
|
|
943
949
|
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
950
|
+
var _c;
|
|
951
|
+
|
|
952
|
+
const fieldInterface = interfaces_1.interfaces.get((_c = form.values) === null || _c === void 0 ? void 0 : _c.interface);
|
|
953
|
+
(fieldInterface === null || fieldInterface === void 0 ? void 0 : fieldInterface.initialize) && (fieldInterface === null || fieldInterface === void 0 ? void 0 : fieldInterface.initialize(form.values));
|
|
944
954
|
yield resource.save(form.values, {
|
|
945
955
|
resourceKey: ctx.record.key
|
|
946
956
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/admin-layout/Collections/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2C;AAC3C,+CAAwE;AAGxE,+DAGuC;AACvC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M,OAAO,EAAE,CAAC;oBAClB,CAAC,CAAA,IAEA,CAAC,CAAC,QAAQ,CAAC,CACL,CACH;YAGV,8BAAC,oBAAY,IAAC,IAAI,EAAE,IAAI;gBACtB,8BAAC,qBAAW,IACV,KAAK,EAAE;wBACL,eAAe;wBACf,oBAAoB;qBACrB,EACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE,IAAA,cAAK,EAAC,MAAM,CAAC,UAAU,CAAC;qBACrC,GACD,CACW,CACR,CACR,CACJ,CAAC;AACJ,CAAC;AAEM,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,CACL,8BAAC,kBAAc,IACb,UAAU,EAAE;YACV,eAAe;YACf,iBAAiB;YACjB,eAAe;SAChB,EACD,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB;AAEF,kBAAe,mBAAW,CAAC","file":"index.js","sourcesContent":["import { SchemaRenderer } from '../../../';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { FormItem } from '@formily/antd';\nimport { action } from '@formily/reactive';\nimport {\n useCollectionContext,\n useCollectionsContext,\n} from '../../../constate/Collections';\nimport { Button, Drawer, Menu, Dropdown, Space } from 'antd';\nimport { PlusOutlined, DownOutlined } from '@ant-design/icons';\nimport cls from 'classnames';\nimport { uid, isValid, clone } from '@formily/shared';\nimport { Resource } from '../../../resource';\nimport { TableRowContext, useTable } from '../../../schemas/table';\nimport { useRequest } from 'ahooks';\nimport { VisibleContext } from '../../../context';\nimport { connect, FormProvider, observer, useForm } from '@formily/react';\nimport { DescriptionsContext } from '../../../schemas/form';\nimport { createContext } from 'react';\nimport { ISchema } from '../../../';\nimport { createForm, Field } from '@formily/core';\nimport { SchemaField } from '../../../schemas';\nimport {\n interfaces,\n options,\n} from '../../../schemas/database-field/interfaces';\nimport { useResourceRequest } from '../../../constate';\nimport { useTranslation } from 'react-i18next';\nimport { useCompile } from '../../../hooks/useCompile';\n\nexport const RoleContext = createContext(null);\n\nfunction VisibleProvider(props) {\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n return (\n <VisibleContext.Provider value={[visible, setVisible]}>\n {props.children}\n </VisibleContext.Provider>\n );\n}\n\nconst useResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nconst useCollectionsResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nclass ActionPermissionResource extends Resource {\n save(options?: any) {\n console.log('ActionPermissionResource.save');\n return Promise.resolve({});\n }\n}\n\nconst useActionPermissionSubmit = () => {\n const form = useForm();\n const role = useContext(RoleContext);\n const resource = useResourceRequest({\n resourceName: 'roles',\n resourceKey: role.name,\n });\n return {\n async run() {\n await resource.save(form.values);\n console.log('useActionPermissionSubmit', form.values?.actionPermissions);\n },\n };\n};\n\nconst useActionPermissionResource = ({ onSuccess }) => {\n const role = useContext(RoleContext);\n console.log('RoleContext', role);\n // const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest(\n {\n resourceName: 'action_permissions',\n },\n ActionPermissionResource,\n );\n const service = useRequest(\n (params?: any) => {\n return resource.list({\n ...params,\n filter: {\n role_name: role.name,\n collection_name: ctx.record.name,\n },\n appends: ['fields'],\n });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess(data) {\n console.log('actionPermissions', data);\n onSuccess({\n actionPermissions: data.map((permission) => {\n const item: any = {};\n Object.keys(permission).forEach((key) => {\n if (isValid(permission[key])) {\n item[key] = permission[key];\n }\n });\n item.fields = permission?.fields.map((field) => field.key) || [];\n return item;\n }),\n });\n },\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useDetailsResource = ({ onSuccess }) => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest({\n resourceName: 'collections',\n resourceKey: ctx.record[props.rowKey],\n });\n const service = useRequest(\n (params?: any) => {\n return resource.get({ ...params });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess,\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useFieldsResource = () => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n class FieldResource extends Resource {\n list(options) {\n return super.list({\n ...options,\n filter: { state: 1, collection_name: ctx.record[props.rowKey] },\n });\n }\n }\n const resource = useResourceRequest('fields', FieldResource);\n return {\n resource,\n };\n};\n\nconst fieldInterfaces = [];\nfor (const [key, schema] of interfaces) {\n fieldInterfaces.push({\n value: key,\n label: schema.title,\n disabled: schema.disabled,\n });\n}\n\nconst collectionSchema: ISchema = {\n type: 'array',\n 'x-decorator': 'VisibleProvider',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'key',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n defaultAppends: ['uiSchema'],\n useResource: useFieldsResource,\n collectionName: 'fields',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Add new')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'CreateFieldButton',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Field display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n 'uiSchema.title': {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Field name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column3: {\n type: 'void',\n title: \"{{t('Field type')}}\",\n 'x-component': 'Table.Column',\n properties: {\n interface: {\n type: 'string',\n 'x-component': 'Select',\n 'x-read-pretty': true,\n // @ts-ignore\n enum: fieldInterfaces,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'EditFieldButton',\n 'x-component-props': {\n type: 'link',\n useAction() {\n return {\n async run() {\n alert('abc');\n },\n };\n },\n },\n 'x-action-type': 'update',\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: '删除数据',\n content: '删除后无法恢复,确定要删除吗?',\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction FieldConfigTitle() {\n const ctx = useContext(TableRowContext);\n const { t } = useTranslation();\n const compile = useCompile();\n return <>{t('Configure fields of {{title}}', { title: compile(ctx.record.title) })}</>;\n}\n\nfunction useCollectionResource({ onSuccess }) {\n const visible = useContext(VisibleContext);\n const resource = useResourceRequest('collections');\n useEffect(() => {\n visible && onSuccess({ name: `t_${uid()}` });\n }, [visible]);\n return { resource };\n}\n\nconst schema: ISchema = {\n type: 'void',\n name: 'action',\n 'x-component': 'Action',\n 'x-component-props': {\n tooltip: \"{{ t('Collections & Fields') }}\",\n className: 'nb-database-config',\n icon: 'DatabaseOutlined',\n type: 'primary',\n },\n properties: {\n modal1: {\n type: 'void',\n title: \"{{t('Collections & Fields')}}\",\n 'x-component': 'Action.Drawer',\n properties: {\n table: {\n type: 'array',\n // 'x-decorator': 'CardItem',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'name',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n useResource,\n collectionName: 'collections',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n properties: {\n modal: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useCollectionResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableCreateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n name: {\n type: 'string',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n description:\n \"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}\",\n },\n },\n },\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n title: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Configure fields')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'view',\n properties: {\n [uid()]: {\n type: 'void',\n title: <FieldConfigTitle />,\n // 'x-decorator': 'RoleProvider',\n 'x-component': 'Action.Drawer',\n 'x-component-props': {},\n properties: {\n [uid()]: collectionSchema,\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'update',\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useDetailsResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableUpdateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction CreateFieldButton() {\n const { t } = useTranslation();\n const compile = useCompile();\n const { refresh } = useCollectionsContext();\n const ctx = useContext(TableRowContext);\n const { service } = useTable();\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const [properties, setProperties] = useState({});\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n\n const menu = (\n <Menu\n onClick={(info) => {\n console.log('click', info.key);\n const schema = interfaces.get(info.key);\n form.setValues({\n ...clone(schema.default),\n collection_name: ctx.record.name,\n key: uid(),\n name: `f_${uid()}`,\n interface: info.key,\n }, 'overwrite');\n setProperties(clone(schema.properties));\n setVisible(true);\n }}\n >\n {options.map(\n (option, groupIndex) =>\n option.children.length > 0 && (\n <Menu.SubMenu key={groupIndex} title={compile(option.label)}>\n {option.children.map((item) => (\n <Menu.Item\n disabled={item.disabled}\n style={{ minWidth: 120 }}\n key={item.name}\n >\n {compile(item.title)}\n </Menu.Item>\n ))}\n </Menu.SubMenu>\n ),\n )}\n </Menu>\n );\n return (\n <>\n <Dropdown overlay={menu} overlayClassName={'all-fields'}>\n <Button type={'primary'} icon={<PlusOutlined />}>\n {t('Add new')} <DownOutlined />\n </Button>\n </Dropdown>\n <Drawer\n title={t('Add field')}\n width={'50%'}\n visible={visible}\n onClose={async () => {\n await form.clearFormGraph();\n setVisible(false);\n }}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={async () => {\n await form.clearFormGraph();\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n await resource.save(form.values);\n setVisible(false);\n await form.reset();\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties,\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nfunction EditFieldButton() {\n const { t } = useTranslation();\n const { refresh, findCollection } = useCollectionsContext();\n const { service } = useTable();\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const schema = interfaces.get(ctx.record.interface);\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n return (\n <>\n <Button\n type={'link'}\n onClick={() => {\n setVisible(true);\n const collection = findCollection(ctx.record.collection_name);\n const values = collection?.generalFields?.find(\n (field) => field.key === ctx.record.key,\n );\n form.setValues(clone(values || {}));\n }}\n >\n {t('Edit')}\n </Button>\n <Drawer\n title={t('Edit field')}\n width={'50%'}\n visible={visible}\n onClose={() => setVisible(false)}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={() => {\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n await resource.save(form.values, {\n resourceKey: ctx.record.key,\n });\n setVisible(false);\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties: clone(schema.properties),\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nexport const Collections = () => {\n return (\n <SchemaRenderer\n components={{\n VisibleProvider,\n CreateFieldButton,\n EditFieldButton,\n }}\n schema={schema}\n />\n );\n};\n\nexport default Collections;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/admin-layout/Collections/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2C;AAC3C,+CAAwE;AAGxE,+DAGuC;AACvC,+BAA6D;AAC7D,6CAA+D;AAE/D,4CAAsD;AACtD,gDAA6C;AAC7C,kDAAmE;AACnE,mCAAoC;AACpC,8CAAkD;AAClD,0CAA0E;AAE1E,iCAAsC;AAEtC,wCAAkD;AAClD,8CAA+C;AAC/C,2EAGoD;AACpD,gDAAuD;AACvD,iDAA+C;AAC/C,0DAAuD;AAE1C,QAAA,WAAW,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC;AAE/C,SAAS,eAAe,CAAC,KAAK;IAC5B,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,uBAAe,CAAC,CAAC;IACxC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CACL,8BAAC,wBAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,IAClD,KAAK,CAAC,QAAQ,CACS,CAC3B,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,MAAM,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,CAAC;oBAClB,CAAC,CAAA,IAEA,CAAC,CAAC,QAAQ,CAAC,CACL,CACH;YAGV,8BAAC,oBAAY,IAAC,IAAI,EAAE,IAAI;gBACtB,8BAAC,qBAAW,IACV,KAAK,EAAE;wBACL,eAAe;wBACf,oBAAoB;qBACrB,EACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE,IAAA,cAAK,EAAC,MAAM,CAAC,UAAU,CAAC;qBACrC,GACD,CACW,CACR,CACR,CACJ,CAAC;AACJ,CAAC;AAEM,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,CACL,8BAAC,kBAAc,IACb,UAAU,EAAE;YACV,eAAe;YACf,iBAAiB;YACjB,eAAe;SAChB,EACD,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB;AAEF,kBAAe,mBAAW,CAAC","file":"index.js","sourcesContent":["import { SchemaRenderer } from '../../../';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { FormItem } from '@formily/antd';\nimport { action } from '@formily/reactive';\nimport {\n useCollectionContext,\n useCollectionsContext,\n} from '../../../constate/Collections';\nimport { Button, Drawer, Menu, Dropdown, Space } from 'antd';\nimport { PlusOutlined, DownOutlined } from '@ant-design/icons';\nimport cls from 'classnames';\nimport { uid, isValid, clone } from '@formily/shared';\nimport { Resource } from '../../../resource';\nimport { TableRowContext, useTable } from '../../../schemas/table';\nimport { useRequest } from 'ahooks';\nimport { VisibleContext } from '../../../context';\nimport { connect, FormProvider, observer, useForm } from '@formily/react';\nimport { DescriptionsContext } from '../../../schemas/form';\nimport { createContext } from 'react';\nimport { ISchema } from '../../../';\nimport { createForm, Field } from '@formily/core';\nimport { SchemaField } from '../../../schemas';\nimport {\n interfaces,\n options,\n} from '../../../schemas/database-field/interfaces';\nimport { useResourceRequest } from '../../../constate';\nimport { useTranslation } from 'react-i18next';\nimport { useCompile } from '../../../hooks/useCompile';\n\nexport const RoleContext = createContext(null);\n\nfunction VisibleProvider(props) {\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n return (\n <VisibleContext.Provider value={[visible, setVisible]}>\n {props.children}\n </VisibleContext.Provider>\n );\n}\n\nconst useResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nconst useCollectionsResource = () => {\n const resource = useResourceRequest('collections');\n return {\n resource,\n };\n};\n\nclass ActionPermissionResource extends Resource {\n save(options?: any) {\n console.log('ActionPermissionResource.save');\n return Promise.resolve({});\n }\n}\n\nconst useActionPermissionSubmit = () => {\n const form = useForm();\n const role = useContext(RoleContext);\n const resource = useResourceRequest({\n resourceName: 'roles',\n resourceKey: role.name,\n });\n return {\n async run() {\n await resource.save(form.values);\n console.log('useActionPermissionSubmit', form.values?.actionPermissions);\n },\n };\n};\n\nconst useActionPermissionResource = ({ onSuccess }) => {\n const role = useContext(RoleContext);\n console.log('RoleContext', role);\n // const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest(\n {\n resourceName: 'action_permissions',\n },\n ActionPermissionResource,\n );\n const service = useRequest(\n (params?: any) => {\n return resource.list({\n ...params,\n filter: {\n role_name: role.name,\n collection_name: ctx.record.name,\n },\n appends: ['fields'],\n });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess(data) {\n console.log('actionPermissions', data);\n onSuccess({\n actionPermissions: data.map((permission) => {\n const item: any = {};\n Object.keys(permission).forEach((key) => {\n if (isValid(permission[key])) {\n item[key] = permission[key];\n }\n });\n item.fields = permission?.fields.map((field) => field.key) || [];\n return item;\n }),\n });\n },\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useDetailsResource = ({ onSuccess }) => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n const resource = useResourceRequest({\n resourceName: 'collections',\n resourceKey: ctx.record[props.rowKey],\n });\n const service = useRequest(\n (params?: any) => {\n return resource.get({ ...params });\n },\n {\n formatResult: (result) => result?.data,\n onSuccess,\n manual: true,\n },\n );\n const [visible] = useContext(VisibleContext);\n\n useEffect(() => {\n if (visible) {\n service.run({});\n }\n }, [visible]);\n\n return { resource, service, initialValues: service.data, ...service };\n};\n\nconst useFieldsResource = () => {\n const { props } = useTable();\n const ctx = useContext(TableRowContext);\n class FieldResource extends Resource {\n list(options) {\n return super.list({\n ...options,\n filter: { state: 1, collection_name: ctx.record[props.rowKey] },\n });\n }\n }\n const resource = useResourceRequest('fields', FieldResource);\n return {\n resource,\n };\n};\n\nconst fieldInterfaces = [];\nfor (const [key, schema] of interfaces) {\n fieldInterfaces.push({\n value: key,\n label: schema.title,\n disabled: schema.disabled,\n });\n}\n\nconst collectionSchema: ISchema = {\n type: 'array',\n 'x-decorator': 'VisibleProvider',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'key',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n defaultAppends: ['uiSchema'],\n useResource: useFieldsResource,\n collectionName: 'fields',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Add new')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'CreateFieldButton',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Field display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n 'uiSchema.title': {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Field name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column3: {\n type: 'void',\n title: \"{{t('Field type')}}\",\n 'x-component': 'Table.Column',\n properties: {\n interface: {\n type: 'string',\n 'x-component': 'Select',\n 'x-read-pretty': true,\n // @ts-ignore\n enum: fieldInterfaces,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'EditFieldButton',\n 'x-component-props': {\n type: 'link',\n useAction() {\n return {\n async run() {\n alert('abc');\n },\n };\n },\n },\n 'x-action-type': 'update',\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: '删除数据',\n content: '删除后无法恢复,确定要删除吗?',\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction FieldConfigTitle() {\n const ctx = useContext(TableRowContext);\n const { t } = useTranslation();\n const compile = useCompile();\n return <>{t('Configure fields of {{title}}', { title: compile(ctx.record.title) })}</>;\n}\n\nfunction useCollectionResource({ onSuccess }) {\n const visible = useContext(VisibleContext);\n const resource = useResourceRequest('collections');\n useEffect(() => {\n visible && onSuccess({ name: `t_${uid()}` });\n }, [visible]);\n return { resource };\n}\n\nconst schema: ISchema = {\n type: 'void',\n name: 'action',\n 'x-component': 'Action',\n 'x-component-props': {\n tooltip: \"{{ t('Collections & Fields') }}\",\n className: 'nb-database-config',\n icon: 'DatabaseOutlined',\n type: 'primary',\n },\n properties: {\n modal1: {\n type: 'void',\n title: \"{{t('Collections & Fields')}}\",\n 'x-component': 'Action.Drawer',\n properties: {\n table: {\n type: 'array',\n // 'x-decorator': 'CardItem',\n 'x-component': 'Table',\n default: [],\n 'x-component-props': {\n rowKey: 'name',\n dragSort: true,\n showIndex: true,\n refreshRequestOnChange: true,\n pagination: {\n pageSize: 100,\n },\n useResource,\n collectionName: 'collections',\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Table.ActionBar',\n properties: {\n [uid()]: {\n type: 'void',\n name: 'action1',\n title: \"{{t('Delete')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'destroy',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n icon: 'DeleteOutlined',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-align': 'right',\n 'x-decorator': 'AddNew.Displayed',\n 'x-decorator-props': {\n displayName: 'create',\n },\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'primary',\n icon: 'PlusOutlined',\n },\n properties: {\n modal: {\n type: 'void',\n title: \"{{t('Create collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useCollectionResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableCreateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n name: {\n type: 'string',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n description:\n \"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}\",\n },\n },\n },\n },\n },\n },\n },\n column1: {\n type: 'void',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n title: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n column2: {\n type: 'void',\n title: \"{{t('Collection name')}}\",\n 'x-component': 'Table.Column',\n properties: {\n name: {\n type: 'string',\n 'x-component': 'Input',\n 'x-read-pretty': true,\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Actions')}}\",\n 'x-component': 'Table.Column',\n 'x-component-props': {\n width: 160,\n },\n properties: {\n [uid()]: {\n type: 'void',\n 'x-component': 'Action.Group',\n 'x-component-props': {\n type: 'link',\n },\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Configure fields')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'view',\n properties: {\n [uid()]: {\n type: 'void',\n title: <FieldConfigTitle />,\n // 'x-decorator': 'RoleProvider',\n 'x-component': 'Action.Drawer',\n 'x-component-props': {},\n properties: {\n [uid()]: collectionSchema,\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit')}}\",\n 'x-component': 'Action',\n 'x-component-props': {\n type: 'link',\n },\n 'x-action-type': 'update',\n properties: {\n [uid()]: {\n type: 'void',\n title: \"{{t('Edit collection')}}\",\n 'x-decorator': 'Form',\n 'x-decorator-props': {\n useResource: useDetailsResource,\n },\n 'x-component': 'Action.Drawer',\n 'x-component-props': {\n useOkAction: '{{ Table.useTableUpdateAction }}',\n },\n properties: {\n title: {\n type: 'string',\n title: \"{{t('Collection display name')}}\",\n 'x-component': 'Input',\n 'x-decorator': 'FormilyFormItem',\n },\n },\n },\n },\n },\n [uid()]: {\n type: 'void',\n title: \"{{t('Delete')}}\",\n 'x-component': 'Action',\n 'x-action-type': 'destroy',\n 'x-component-props': {\n type: 'link',\n confirm: {\n title: \"{{t('Delete record')}}\",\n content: \"{{t('Are you sure you want to delete it?')}}\",\n },\n useAction: '{{ Table.useTableDestroyAction }}',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n};\n\nfunction CreateFieldButton() {\n const { t } = useTranslation();\n const compile = useCompile();\n const { refresh } = useCollectionsContext();\n const ctx = useContext(TableRowContext);\n const { service } = useTable();\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const [properties, setProperties] = useState({});\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n\n const menu = (\n <Menu\n onClick={(info) => {\n console.log('click', info.key);\n const schema = interfaces.get(info.key);\n form.setValues({\n ...clone(schema.default),\n collection_name: ctx.record.name,\n key: uid(),\n name: `f_${uid()}`,\n interface: info.key,\n }, 'overwrite');\n setProperties(clone(schema.properties));\n setVisible(true);\n }}\n >\n {options.map(\n (option, groupIndex) =>\n option.children.length > 0 && (\n <Menu.SubMenu key={groupIndex} title={compile(option.label)}>\n {option.children.map((item) => (\n <Menu.Item\n disabled={item.disabled}\n style={{ minWidth: 120 }}\n key={item.name}\n >\n {compile(item.title)}\n </Menu.Item>\n ))}\n </Menu.SubMenu>\n ),\n )}\n </Menu>\n );\n return (\n <>\n <Dropdown overlay={menu} overlayClassName={'all-fields'}>\n <Button type={'primary'} icon={<PlusOutlined />}>\n {t('Add new')} <DownOutlined />\n </Button>\n </Dropdown>\n <Drawer\n title={t('Add field')}\n width={'50%'}\n visible={visible}\n onClose={async () => {\n await form.clearFormGraph();\n setVisible(false);\n }}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={async () => {\n console.log('form.values', form.values);\n await form.clearFormGraph();\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n const fieldInterface = interfaces.get(form.values?.interface);\n fieldInterface?.initialize && fieldInterface?.initialize(form.values);\n console.log('form.values', form.values);\n await resource.save(form.values);\n setVisible(false);\n await form.reset();\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties,\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nfunction EditFieldButton() {\n const { t } = useTranslation();\n const { refresh, findCollection } = useCollectionsContext();\n const { service } = useTable();\n const ctx = useContext(TableRowContext);\n const [visible, setVisible] = useState(false);\n const form = useMemo(() => createForm(), []);\n const schema = interfaces.get(ctx.record.interface);\n const { collections = [], loading } = useCollectionsContext();\n const resource = useResourceRequest('fields');\n\n const loadCollections = async (field: any) => {\n return collections.map((item: any) => ({\n label: item.title,\n value: item.name,\n }));\n };\n\n const loadCollectionFields = async (field: Field) => {\n const target = field.query('....target').get('value');\n const f = field.query('....target').take();\n console.log('loadCollectionFields', f, field);\n const collection = collections?.find((item) => item.name === target);\n if (!collection) {\n return [];\n }\n return collection?.generalFields\n ?.filter((item) => item?.uiSchema?.title)\n ?.map((item) => ({\n label: item?.uiSchema?.title || item.name,\n value: item.name,\n }));\n };\n return (\n <>\n <Button\n type={'link'}\n onClick={() => {\n setVisible(true);\n const collection = findCollection(ctx.record.collection_name);\n const values = collection?.generalFields?.find(\n (field) => field.key === ctx.record.key,\n );\n form.setValues(clone(values || {}));\n }}\n >\n {t('Edit')}\n </Button>\n <Drawer\n title={t('Edit field')}\n width={'50%'}\n visible={visible}\n onClose={() => setVisible(false)}\n footer={\n <Space style={{ float: 'right' }}>\n <Button\n onClick={() => {\n setVisible(false);\n }}\n >\n {t('Cancel')}\n </Button>\n <Button\n type={'primary'}\n onClick={async () => {\n const fieldInterface = interfaces.get(form.values?.interface);\n fieldInterface?.initialize && fieldInterface?.initialize(form.values);\n await resource.save(form.values, {\n resourceKey: ctx.record.key,\n });\n setVisible(false);\n await service.refresh();\n await refresh();\n }}\n >\n {t('Submit')}\n </Button>\n </Space>\n }\n >\n <FormProvider form={form}>\n <SchemaField\n scope={{\n loadCollections,\n loadCollectionFields,\n }}\n schema={{\n type: 'object',\n properties: clone(schema.properties),\n }}\n />\n </FormProvider>\n </Drawer>\n </>\n );\n}\n\nexport const Collections = () => {\n return (\n <SchemaRenderer\n components={{\n VisibleProvider,\n CreateFieldButton,\n EditFieldButton,\n }}\n schema={schema}\n />\n );\n};\n\nexport default Collections;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/schema-renderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AACvD,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAwB,MAAM,OAAO,CAAC;AA0D7C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQvD,eAAO,MAAM,YAAY;;EAAmC,CAAC;AAI7D,UAAU,sBAAsB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,eAAO,MAAM,kBAAkB,YAAa,GAAG,aAAa,GAAG,SAY9D,CAAC;AAEF,eAAO,MAAM,yBAAyB,gBAEf,UAAU,iBAqBhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,0BAEL,kBAAkB,EAAE,SAAS,UAAU,SAuB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AAM,cAAc,UAAW,mBAAmB,gBAsDxD,CAAC","file":"index.d.ts","sourcesContent":["import { ArrayField, createForm } from '@formily/core';\nimport {\n createSchemaField,\n FormProvider,\n Schema,\n SchemaOptionsContext,\n useField,\n useFieldSchema,\n useForm,\n} from '@formily/react';\nimport { uid } from '@formily/shared';\nimport constate from 'constate';\nimport { get } from 'lodash';\nimport React, { createContext } from 'react';\nimport { useState } from 'react';\nimport { useContext } from 'react';\nimport { useMemo } from 'react';\n\nimport { CodeOutlined } from '@ant-design/icons';\nimport Editor from '@monaco-editor/react';\n\nimport {\n ArrayItems,\n ArrayCollapse,\n FormLayout,\n FormItem as FormilyFormItem,\n} from '@formily/antd';\n\nimport { Space, Card, Modal, Spin } from 'antd';\nimport { ArrayTable } from '../../schemas/array-table';\nimport { Action } from '../../schemas/action';\nimport { AddNew } from '../../schemas/add-new';\nimport { Calendar } from '../../schemas/calendar';\nimport { Cascader } from '../../schemas/cascader';\nimport { Checkbox } from '../../schemas/checkbox';\nimport { ColorSelect } from '../../schemas/color-select';\nimport {\n DatabaseField,\n DatabaseCollection,\n} from '../../schemas/database-field';\nimport { DatePicker } from '../../schemas/date-picker';\nimport { Filter } from '../../schemas/filter';\nimport { Form } from '../../schemas/form';\nimport { ActionLogs } from '../../schemas/action-logs';\nimport { Grid } from '../../schemas/grid';\nimport { IconPicker } from '../../schemas/icon-picker';\nimport { Input } from '../../schemas/input';\nimport { InputNumber } from '../../schemas/input-number';\nimport { Markdown } from '../../schemas/markdown';\nimport { Kanban } from '../../schemas/kanban';\nimport { Menu } from '../../schemas/menu';\nimport { Password } from '../../schemas/password';\nimport { Radio } from '../../schemas/radio';\nimport { Select } from '../../schemas/select';\nimport {\n CollectionFieldContext,\n Table,\n TableRowContext,\n} from '../../schemas/table';\nimport { Tabs } from '../../schemas/tabs';\nimport { TimePicker } from '../../schemas/time-picker';\nimport { Upload } from '../../schemas/upload';\nimport { FormItem } from '../../schemas/form-item';\nimport { BlockItem } from '../../schemas/block-item';\nimport { CardItem } from '../../schemas/card-item';\nimport { DragAndDrop } from '../../schemas/drag-and-drop';\nimport { TreeSelect } from '../../schemas/tree-select';\nimport { Page } from '../../schemas/page';\nimport { Chart } from '../../schemas/chart';\nimport { useDesignableSwitchContext } from '../../constate/DesignableSwitch';\nimport { action } from '@formily/reactive';\nimport { ISchema, FormilyISchema } from '../../schemas';\nimport { Resource } from '../../resource';\nimport { useRequest } from 'ahooks';\nimport { CascaderOptionType } from 'antd/lib/cascader';\nimport {\n useClient,\n useCollectionContext,\n useResourceRequest,\n} from '../../constate';\nimport { i18n } from '../../i18n';\n\nexport const BlockContext = createContext({ dragRef: null });\n\nconst Div = (props) => <div {...props} />;\n\ninterface DesignableContextProps {\n schema?: Schema;\n refresh?: any;\n}\n\nexport const useAsyncDataSource = (service: any) => (field: any) => {\n field.loading = true;\n const disableAsyncDataSource = field.componentProps.disableAsyncDataSource;\n if (disableAsyncDataSource) {\n return;\n }\n service(field).then(\n action.bound((data: any) => {\n field.dataSource = data;\n field.loading = false;\n }),\n );\n};\n\nexport const loadChinaRegionDataSource = function () {\n const resource = useResourceRequest('china_regions');\n return async (field: ArrayField) => {\n if (field.readPretty) {\n return [];\n }\n const maxLevel = field.componentProps.maxLevel || 3;\n const { data } = await resource.list({\n perPage: -1,\n filter: {\n level: 1,\n },\n });\n console.log('loadChinaRegions', data, field.value);\n return (\n data?.map((item) => {\n if (maxLevel !== 1) {\n item.isLeaf = false;\n }\n return item;\n }) || []\n );\n };\n};\n\nexport const loadChinaRegionData = function () {\n const resource = useResourceRequest('china_regions');\n return (selectedOptions: CascaderOptionType[], field: ArrayField) => {\n const maxLevel = field.componentProps.maxLevel || 3;\n const targetOption = selectedOptions[selectedOptions.length - 1];\n targetOption.loading = true;\n resource\n .list({\n perPage: -1,\n filter: {\n parent_code: targetOption['code'],\n },\n })\n .then((data) => {\n targetOption.loading = false;\n targetOption.children =\n data?.data?.map((item) => {\n if (maxLevel > item.level) {\n item.isLeaf = false;\n }\n return item;\n }) || [];\n field.dataSource = [...field.dataSource];\n });\n };\n};\n\nconst useChinaRegionFieldValue = (field: ArrayField) => {\n if (field.readPretty) {\n field.value = field?.value?.sort((a, b) => a.level - b.level);\n }\n console.log('useChinaRegionFieldValue', field);\n};\n\nconst useAssociationResource = (options) => {\n const { schema } = useDesignable();\n const collectionField = useContext(CollectionFieldContext);\n const { collection } = useCollectionContext();\n const ctx = useContext(TableRowContext);\n const associatedKey = ctx?.record?.id;\n console.log(\n 'useAssociationResource',\n collection,\n collectionField,\n schema['x-component-props'],\n );\n const { associatedName, resourceName } = schema['x-component-props'] || {};\n const resource = useResourceRequest({\n associatedName,\n resourceName,\n associatedKey,\n });\n const service = useRequest((params) => resource.list(params), {\n manual: schema['x-component'] === 'Form',\n formatResult: (data) => data?.data?.[0] || {},\n onSuccess: options?.onSuccess,\n });\n return { resource, service, initialValues: service.data, ...service };\n};\n\nexport const SchemaField = createSchemaField({\n scope: {\n t: i18n.t.bind(i18n),\n Table,\n Calendar,\n Kanban,\n useAsyncDataSource,\n useClient,\n useResourceRequest,\n ChinaRegion: {\n useFieldValue: useChinaRegionFieldValue,\n loadData: loadChinaRegionData,\n loadDataSource: loadChinaRegionDataSource,\n },\n Select,\n Association: {\n useResource: useAssociationResource,\n },\n },\n components: {\n Card,\n Div,\n Space,\n Page,\n Chart,\n\n ArrayItems,\n ArrayCollapse,\n ArrayTable,\n FormLayout,\n TreeSelect,\n FormilyFormItem,\n\n DragAndDrop,\n\n BlockItem,\n CardItem,\n FormItem,\n\n Action,\n AddNew,\n Calendar,\n Cascader,\n Checkbox,\n ColorSelect,\n DatabaseField,\n DatabaseCollection,\n DatePicker,\n Filter,\n Form,\n Grid,\n IconPicker,\n Input,\n InputNumber,\n Kanban,\n Markdown,\n Menu,\n Password,\n Radio,\n Select,\n Table,\n Tabs,\n TimePicker,\n Upload,\n\n ActionLogs,\n },\n});\n\nexport const DesignableContext = createContext<DesignableContextProps>({});\n\nexport function useSchema(path?: any) {\n const { schema, refresh } = useContext(DesignableContext);\n return { schema, refresh };\n}\n\nexport function pathToArray(path): string[] {\n if (Array.isArray(path)) {\n return [...path];\n }\n\n if (typeof path === 'string') {\n return path.split('.');\n }\n}\n\nexport function findPropertyByPath(schema: Schema, path?: any): Schema {\n if (!path) {\n return schema;\n }\n const arr = pathToArray(path);\n let property = schema;\n while (arr.length) {\n const name = arr.shift();\n if (!property.properties) {\n console.warn('property does not exist.');\n return null;\n }\n property = property.properties[name];\n if (!property) {\n console.warn('property does not exist.');\n return null;\n }\n }\n return property;\n}\n\nexport function addPropertyBefore(\n target: Schema,\n data: ISchema | FormilyISchema,\n) {\n Object.keys(target.parent.properties).forEach((name) => {\n if (name === target.name) {\n target.parent.addProperty(data.name, data);\n }\n const property = target.parent.properties[name];\n property.parent.removeProperty(property.name);\n target.parent.addProperty(property.name, property.toJSON());\n });\n}\n\nexport function addPropertyAfter(\n target: Schema,\n data: ISchema | FormilyISchema,\n) {\n Object.keys(target.parent.properties).forEach((name) => {\n const property = target.parent.properties[name];\n property.parent.removeProperty(property.name);\n target.parent.addProperty(property.name, property.toJSON());\n if (name === target.name) {\n target.parent.addProperty(data.name, data);\n }\n });\n}\n\nfunction setKeys(schema: ISchema | FormilyISchema, parentKey = null) {\n if (!schema['key']) {\n schema['key'] = uid();\n }\n if (parentKey) {\n schema['parentKey'] = parentKey;\n }\n Object.keys(schema.properties || {}).forEach((name) => {\n setKeys(schema.properties[name], schema['key']);\n });\n}\n\nexport function useSchemaComponent(component: string) {\n if (!component) {\n return null;\n }\n const options = useContext(SchemaOptionsContext);\n return get(options.components, component);\n}\n\nexport function useDesignable(path?: any) {\n let { designable = true } = useDesignableSwitchContext();\n const { schema = new Schema({}), refresh } = useContext(DesignableContext);\n const schemaPath = path || useSchemaPath();\n const fieldSchema = useFieldSchema();\n let current;\n let currentSchema = (current =\n findPropertyByPath(schema, schemaPath) || ({} as Schema));\n if (!currentSchema) {\n currentSchema = fieldSchema;\n }\n if (Object.keys(currentSchema).length === 0) {\n currentSchema = fieldSchema;\n }\n // console.log('useDesignable', { schema, schemaPath, currentSchema });\n const options = useContext(SchemaOptionsContext);\n let DesignableBar = get(\n options.components,\n currentSchema['x-designable-bar'],\n );\n if (!designable) {\n DesignableBar = () => null;\n }\n if (!DesignableBar) {\n DesignableBar = () => null;\n }\n return {\n designable,\n root: schema,\n currentSchema: current,\n DesignableBar,\n schema: currentSchema,\n refresh,\n prepend: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['key']) {\n property['parentKey'] = target['key'];\n setKeys(property);\n property['__prepend__'] = true;\n // if (!property['key']) {\n // property['key'] = uid();\n // }\n }\n const properties = {};\n properties[property.name] = property;\n Object.keys(target.properties).forEach((name, index) => {\n const current = target.properties[name];\n current.parent.removeProperty(current.name);\n properties[current.name] = current.toJSON();\n });\n // console.log({ properties }, target.properties);\n target.setProperties(properties);\n refresh();\n return target.properties[property.name];\n },\n appendChild: (\n property: ISchema | FormilyISchema,\n targetPath?: any,\n ): Schema => {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['key']) {\n property['parentKey'] = target['key'];\n // if (!property['key']) {\n // property['key'] = uid();\n // }\n setKeys(property);\n }\n target.addProperty(property.name, property);\n // BUG: 空 properties 时,addProperty 无反应。\n const tmp = { name: uid() };\n addPropertyAfter(target, tmp);\n target.parent.removeProperty(tmp.name);\n refresh();\n return target.properties[property.name];\n },\n insertAfter: (\n property: ISchema | FormilyISchema,\n targetPath?: any,\n ): Schema => {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n console.log('target.parentKey', target);\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertAfter__'] = target['key'];\n }\n addPropertyAfter(target, property);\n refresh();\n return target.parent.properties[property.name];\n },\n insertBefore(property: ISchema | FormilyISchema, targetPath?: any): Schema {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertBefore__'] = target['key'];\n }\n addPropertyBefore(target, property);\n refresh();\n return target.parent.properties[property.name];\n },\n deepRemoveIfEmpty(targetPath) {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n const removed = [];\n const remove = (s: Schema) => {\n if (!s.parent) {\n return;\n }\n s.parent.removeProperty(s.name);\n removed.push(s);\n if (s['x-component'] === 'Grid.Row') {\n return;\n }\n if (Object.keys(s.parent.properties || {}).length === 0) {\n remove(s.parent);\n }\n };\n console.log({ removed });\n if (Object.keys(target.properties || {}).length === 0) {\n remove(target);\n }\n refresh();\n return removed;\n },\n deepRemove(targetPath?: any) {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n const removed = [];\n const remove = (s: Schema) => {\n if (!s.parent) {\n return;\n }\n s.parent.removeProperty(s.name);\n removed.push(s);\n if (s['x-component'] === 'Grid.Row') {\n return;\n }\n if (Object.keys(s.parent.properties || {}).length === 0) {\n remove(s.parent);\n }\n };\n console.log({ removed });\n remove(target);\n refresh();\n return removed;\n },\n remove(targetPath?: any) {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n target.parent.removeProperty(target.name);\n refresh();\n return target;\n },\n moveToBefore(path1, path2) {\n const source = findPropertyByPath(schema, path1);\n const property = source.toJSON() as ISchema;\n const target = findPropertyByPath(schema, path2);\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertBefore__'] = target['key'];\n }\n addPropertyBefore(target, property);\n refresh();\n return target.parent.properties[property.name];\n },\n moveToAfter(path1, path2) {\n const source = findPropertyByPath(schema, path1);\n const property = source.toJSON() as ISchema;\n const target = findPropertyByPath(schema, path2);\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertAfter__'] = target['key'];\n }\n addPropertyAfter(target, property);\n\n refresh();\n return target.parent.properties[property.name];\n },\n };\n}\n\nexport function getSchemaPath(schema: Schema) {\n const path = schema['x-path'] || [schema.name];\n let parent = schema.parent;\n while (parent) {\n // if (!parent.name) {\n // break;\n // }\n if (parent['x-path']) {\n path.unshift(...parent['x-path']);\n } else if (parent.name) {\n path.unshift(parent.name);\n }\n parent = parent.parent;\n }\n // console.log('getSchemaPath', path, schema);\n return [...path];\n}\n\nexport function useSchemaPath() {\n const schema = useFieldSchema();\n const path = getSchemaPath(schema);\n return [...path];\n}\n\nconst FormValues = () => {\n const form = useForm();\n const [visible, setVisible] = useState(false);\n return (\n <>\n <CodeOutlined onClick={() => setVisible(true)} />\n <Modal\n width={'50%'}\n onOk={() => setVisible(false)}\n onCancel={() => setVisible(false)}\n visible={visible}\n >\n <Editor\n height=\"60vh\"\n defaultLanguage=\"json\"\n value={JSON.stringify(form.values, null, 2)}\n />\n {/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}\n </Modal>\n </>\n );\n};\n\nconst CodePreview = ({ schema }) => {\n const [visible, setVisible] = useState(false);\n return (\n <>\n <CodeOutlined\n style={{ position: 'relative', zIndex: 100 }}\n onClick={() => setVisible(true)}\n />\n <Modal\n width={'50%'}\n onOk={() => setVisible(false)}\n onCancel={() => setVisible(false)}\n visible={visible}\n >\n <Editor\n height=\"60vh\"\n defaultLanguage=\"json\"\n value={JSON.stringify(schema.toJSON(), null, 2)}\n />\n {/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}\n </Modal>\n </>\n );\n};\n\nexport interface SchemaRendererProps {\n schema: Schema | ISchema | FormilyISchema;\n form?: any;\n render?: any;\n components?: any;\n scope?: any;\n debug?: boolean;\n onlyRenderProperties?: boolean;\n onRefresh?: any;\n [key: string]: any;\n}\n\nexport const SchemaRenderer = (props: SchemaRendererProps) => {\n const { designable = true } = useDesignableSwitchContext();\n const [, refresh] = useState(uid());\n const form = useMemo(() => props.form || createForm(), []);\n const schema = useMemo(() => {\n if (Schema.isSchemaInstance(props.schema)) {\n return props.schema;\n }\n let s = props.schema;\n if (props.onlyRenderProperties) {\n s = {\n type: 'object',\n properties: s.properties,\n };\n } else if (s.name) {\n s = {\n type: 'object',\n properties: {\n [s.name]: s,\n },\n };\n }\n return new Schema(s);\n }, []);\n // useEffect(() => {\n // refresh(uid());\n // }, [designable]);\n console.log({ designable }, 'designable');\n const defaultRender = ({ schema }) => (\n <FormProvider form={form}>\n <SchemaField\n components={props.components}\n scope={props.scope}\n schema={schema}\n />\n {props.debug && <CodePreview schema={schema} />}\n {props.debug && <FormValues />}\n </FormProvider>\n );\n return (\n <DesignableContext.Provider\n value={{\n schema,\n refresh: () => {\n props.onRefresh && props.onRefresh(schema);\n refresh(uid());\n },\n }}\n >\n <DesignableContext.Consumer>\n {props.render || defaultRender}\n </DesignableContext.Consumer>\n </DesignableContext.Provider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/schema-renderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AACvD,OAAO,EAGL,MAAM,EAKP,MAAM,g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;EAuD1B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,SAgB3C;AAED,wBAAgB,aAAa,UAI5B;AAkDD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;IAC1C,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB,gBAkHxD,CAAC","file":"index.d.ts","sourcesContent":["import { ArrayField, createForm } from '@formily/core';\nimport {\n createSchemaField,\n FormProvider,\n Schema,\n SchemaOptionsContext,\n useField,\n useFieldSchema,\n useForm,\n} from '@formily/react';\nimport { uid } from '@formily/shared';\nimport constate from 'constate';\nimport { get } from 'lodash';\nimport React, { createContext } from 'react';\nimport { useState } from 'react';\nimport { useContext } from 'react';\nimport { useMemo } from 'react';\n\nimport { CodeOutlined } from '@ant-design/icons';\nimport Editor from '@monaco-editor/react';\n\nimport {\n ArrayItems,\n ArrayCollapse,\n FormLayout,\n FormItem as FormilyFormItem,\n} from '@formily/antd';\n\nimport { Space, Card, Modal, Spin } from 'antd';\nimport { ArrayTable } from '../../schemas/array-table';\nimport { Action } from '../../schemas/action';\nimport { AddNew } from '../../schemas/add-new';\nimport { Calendar } from '../../schemas/calendar';\nimport { Cascader } from '../../schemas/cascader';\nimport { Checkbox } from '../../schemas/checkbox';\nimport { ColorSelect } from '../../schemas/color-select';\nimport {\n DatabaseField,\n DatabaseCollection,\n} from '../../schemas/database-field';\nimport { DatePicker } from '../../schemas/date-picker';\nimport { Filter } from '../../schemas/filter';\nimport { Form } from '../../schemas/form';\nimport { ActionLogs } from '../../schemas/action-logs';\nimport { Grid } from '../../schemas/grid';\nimport { IconPicker } from '../../schemas/icon-picker';\nimport { Input } from '../../schemas/input';\nimport { InputNumber } from '../../schemas/input-number';\nimport { Markdown } from '../../schemas/markdown';\nimport { Kanban } from '../../schemas/kanban';\nimport { Menu } from '../../schemas/menu';\nimport { Password } from '../../schemas/password';\nimport { Radio } from '../../schemas/radio';\nimport { Select } from '../../schemas/select';\nimport {\n CollectionFieldContext,\n Table,\n TableRowContext,\n} from '../../schemas/table';\nimport { Tabs } from '../../schemas/tabs';\nimport { TimePicker } from '../../schemas/time-picker';\nimport { Upload } from '../../schemas/upload';\nimport { FormItem } from '../../schemas/form-item';\nimport { BlockItem } from '../../schemas/block-item';\nimport { CardItem } from '../../schemas/card-item';\nimport { DragAndDrop } from '../../schemas/drag-and-drop';\nimport { TreeSelect } from '../../schemas/tree-select';\nimport { Page } from '../../schemas/page';\nimport { Chart } from '../../schemas/chart';\nimport { useDesignableSwitchContext } from '../../constate/DesignableSwitch';\nimport { action } from '@formily/reactive';\nimport { ISchema, FormilyISchema } from '../../schemas';\nimport { Resource } from '../../resource';\nimport { useRequest } from 'ahooks';\nimport { CascaderOptionType } from 'antd/lib/cascader';\nimport {\n useClient,\n useCollectionContext,\n useResourceRequest,\n} from '../../constate';\nimport { i18n } from '../../i18n';\n\nexport const BlockContext = createContext({ dragRef: null });\n\nconst Div = (props) => <div {...props} />;\n\ninterface DesignableContextProps {\n schema?: Schema;\n refresh?: any;\n}\n\nexport const useAsyncDataSource = (service: any) => (field: any) => {\n field.loading = true;\n const disableAsyncDataSource = field.componentProps.disableAsyncDataSource;\n if (disableAsyncDataSource) {\n return;\n }\n service(field).then(\n action.bound((data: any) => {\n field.dataSource = data;\n field.loading = false;\n }),\n );\n};\n\nexport const loadChinaRegionDataSource = function () {\n const resource = useResourceRequest('china_regions');\n return async (field: ArrayField) => {\n if (field.readPretty) {\n return [];\n }\n const maxLevel = field.componentProps.maxLevel || 3;\n const { data } = await resource.list({\n perPage: -1,\n filter: {\n level: 1,\n },\n });\n console.log('loadChinaRegions', data, field.value);\n return (\n data?.map((item) => {\n if (maxLevel !== 1) {\n item.isLeaf = false;\n }\n return item;\n }) || []\n );\n };\n};\n\nexport const loadChinaRegionData = function () {\n const resource = useResourceRequest('china_regions');\n return (selectedOptions: CascaderOptionType[], field: ArrayField) => {\n const maxLevel = field.componentProps.maxLevel || 3;\n const targetOption = selectedOptions[selectedOptions.length - 1];\n targetOption.loading = true;\n resource\n .list({\n perPage: -1,\n filter: {\n parent_code: targetOption['code'],\n },\n })\n .then((data) => {\n targetOption.loading = false;\n targetOption.children =\n data?.data?.map((item) => {\n if (maxLevel > item.level) {\n item.isLeaf = false;\n }\n return item;\n }) || [];\n field.dataSource = [...field.dataSource];\n });\n };\n};\n\nconst useChinaRegionFieldValue = (field: ArrayField) => {\n if (field.readPretty) {\n field.value = field?.value?.sort((a, b) => a.level - b.level);\n }\n console.log('useChinaRegionFieldValue', field);\n};\n\nconst useAssociationResource = (options) => {\n const { schema } = useDesignable();\n const collectionField = useContext(CollectionFieldContext);\n const { collection } = useCollectionContext();\n const ctx = useContext(TableRowContext);\n const associatedKey = ctx?.record?.id;\n console.log(\n 'useAssociationResource',\n collection,\n collectionField,\n schema['x-component-props'],\n );\n const { associatedName, resourceName } = schema['x-component-props'] || {};\n const resource = useResourceRequest({\n associatedName,\n resourceName,\n associatedKey,\n });\n const service = useRequest((params) => resource.list(params), {\n manual: schema['x-component'] === 'Form',\n formatResult: (data) => data?.data?.[0] || {},\n onSuccess: options?.onSuccess,\n });\n return { resource, service, initialValues: service.data, ...service };\n};\n\nexport const SchemaField = createSchemaField({\n scope: {\n t: i18n.t.bind(i18n),\n Table,\n Calendar,\n Kanban,\n useAsyncDataSource,\n useClient,\n useResourceRequest,\n ChinaRegion: {\n useFieldValue: useChinaRegionFieldValue,\n loadData: loadChinaRegionData,\n loadDataSource: loadChinaRegionDataSource,\n },\n Select,\n Association: {\n useResource: useAssociationResource,\n },\n },\n components: {\n Card,\n Div,\n Space,\n Page,\n Chart,\n\n ArrayItems,\n ArrayCollapse,\n ArrayTable,\n FormLayout,\n TreeSelect,\n FormilyFormItem,\n\n DragAndDrop,\n\n BlockItem,\n CardItem,\n FormItem,\n\n Action,\n AddNew,\n Calendar,\n Cascader,\n Checkbox,\n ColorSelect,\n DatabaseField,\n DatabaseCollection,\n DatePicker,\n Filter,\n Form,\n Grid,\n IconPicker,\n Input,\n InputNumber,\n Kanban,\n Markdown,\n Menu,\n Password,\n Radio,\n Select,\n Table,\n Tabs,\n TimePicker,\n Upload,\n\n ActionLogs,\n },\n});\n\nexport const DesignableContext = createContext<DesignableContextProps>({});\n\nexport function useSchema(path?: any) {\n const { schema, refresh } = useContext(DesignableContext);\n return { schema, refresh };\n}\n\nexport function pathToArray(path): string[] {\n if (Array.isArray(path)) {\n return [...path];\n }\n\n if (typeof path === 'string') {\n return path.split('.');\n }\n}\n\nexport function findPropertyByPath(schema: Schema, path?: any): Schema {\n if (!path) {\n return schema;\n }\n const arr = pathToArray(path);\n let property = schema;\n while (arr.length) {\n const name = arr.shift();\n if (!property.properties) {\n console.warn('property does not exist.');\n return null;\n }\n property = property.properties[name];\n if (!property) {\n console.warn('property does not exist.');\n return null;\n }\n }\n return property;\n}\n\nexport function addPropertyBefore(\n target: Schema,\n data: ISchema | FormilyISchema,\n) {\n Object.keys(target.parent.properties).forEach((name) => {\n if (name === target.name) {\n target.parent.addProperty(data.name, data);\n }\n const property = target.parent.properties[name];\n property.parent.removeProperty(property.name);\n target.parent.addProperty(property.name, property.toJSON());\n });\n}\n\nexport function addPropertyAfter(\n target: Schema,\n data: ISchema | FormilyISchema,\n) {\n Object.keys(target.parent.properties).forEach((name) => {\n const property = target.parent.properties[name];\n property.parent.removeProperty(property.name);\n target.parent.addProperty(property.name, property.toJSON());\n if (name === target.name) {\n target.parent.addProperty(data.name, data);\n }\n });\n}\n\nfunction setKeys(schema: ISchema | FormilyISchema, parentKey = null) {\n if (!schema['key']) {\n schema['key'] = uid();\n }\n if (parentKey) {\n schema['parentKey'] = parentKey;\n }\n Object.keys(schema.properties || {}).forEach((name) => {\n setKeys(schema.properties[name], schema['key']);\n });\n}\n\nexport function useSchemaComponent(component: string) {\n if (!component) {\n return null;\n }\n const options = useContext(SchemaOptionsContext);\n return get(options.components, component);\n}\n\nexport function useDesignable(path?: any) {\n let { designable = true } = useDesignableSwitchContext();\n const { schema = new Schema({}), refresh } = useContext(DesignableContext);\n const schemaPath = path || useSchemaPath();\n const fieldSchema = useFieldSchema();\n let current;\n let currentSchema = (current =\n findPropertyByPath(schema, schemaPath) || ({} as Schema));\n if (!currentSchema) {\n currentSchema = fieldSchema;\n }\n if (Object.keys(currentSchema).length === 0) {\n currentSchema = fieldSchema;\n }\n // console.log('useDesignable', { schema, schemaPath, currentSchema });\n const options = useContext(SchemaOptionsContext);\n let DesignableBar = get(\n options.components,\n currentSchema['x-designable-bar'],\n );\n if (!designable) {\n DesignableBar = () => null;\n }\n if (!DesignableBar) {\n DesignableBar = () => null;\n }\n return {\n designable,\n root: schema,\n currentSchema: current,\n DesignableBar,\n schema: currentSchema,\n refresh,\n prepend: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['key']) {\n property['parentKey'] = target['key'];\n setKeys(property);\n property['__prepend__'] = true;\n // if (!property['key']) {\n // property['key'] = uid();\n // }\n }\n const properties = {};\n properties[property.name] = property;\n Object.keys(target.properties).forEach((name, index) => {\n const current = target.properties[name];\n current.parent.removeProperty(current.name);\n properties[current.name] = current.toJSON();\n });\n // console.log({ properties }, target.properties);\n target.setProperties(properties);\n refresh();\n return target.properties[property.name];\n },\n appendChild: (\n property: ISchema | FormilyISchema,\n targetPath?: any,\n ): Schema => {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['key']) {\n property['parentKey'] = target['key'];\n // if (!property['key']) {\n // property['key'] = uid();\n // }\n setKeys(property);\n }\n target.addProperty(property.name, property);\n // BUG: 空 properties 时,addProperty 无反应。\n const tmp = { name: uid() };\n addPropertyAfter(target, tmp);\n target.parent.removeProperty(tmp.name);\n refresh();\n return target.properties[property.name];\n },\n insertAfter: (\n property: ISchema | FormilyISchema,\n targetPath?: any,\n ): Schema => {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n console.log('target.parentKey', target);\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertAfter__'] = target['key'];\n }\n addPropertyAfter(target, property);\n refresh();\n return target.parent.properties[property.name];\n },\n insertBefore(property: ISchema | FormilyISchema, targetPath?: any): Schema {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertBefore__'] = target['key'];\n }\n addPropertyBefore(target, property);\n refresh();\n return target.parent.properties[property.name];\n },\n deepRemoveIfEmpty(targetPath) {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n const removed = [];\n const remove = (s: Schema) => {\n if (!s.parent) {\n return;\n }\n s.parent.removeProperty(s.name);\n removed.push(s);\n if (s['x-component'] === 'Grid.Row') {\n return;\n }\n if (Object.keys(s.parent.properties || {}).length === 0) {\n remove(s.parent);\n }\n };\n console.log({ removed });\n if (Object.keys(target.properties || {}).length === 0) {\n remove(target);\n }\n refresh();\n return removed;\n },\n deepRemove(targetPath?: any) {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n const removed = [];\n const remove = (s: Schema) => {\n if (!s.parent) {\n return;\n }\n s.parent.removeProperty(s.name);\n removed.push(s);\n if (s['x-component'] === 'Grid.Row') {\n return;\n }\n if (Object.keys(s.parent.properties || {}).length === 0) {\n remove(s.parent);\n }\n };\n console.log({ removed });\n remove(target);\n refresh();\n return removed;\n },\n remove(targetPath?: any) {\n let target = currentSchema;\n if (targetPath) {\n target = findPropertyByPath(schema, targetPath);\n }\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n target.parent.removeProperty(target.name);\n refresh();\n return target;\n },\n moveToBefore(path1, path2) {\n const source = findPropertyByPath(schema, path1);\n const property = source.toJSON() as ISchema;\n const target = findPropertyByPath(schema, path2);\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertBefore__'] = target['key'];\n }\n addPropertyBefore(target, property);\n refresh();\n return target.parent.properties[property.name];\n },\n moveToAfter(path1, path2) {\n const source = findPropertyByPath(schema, path1);\n const property = source.toJSON() as ISchema;\n const target = findPropertyByPath(schema, path2);\n if (!target) {\n console.error('target schema does not exist.');\n return;\n }\n if (!property.name) {\n property.name = uid();\n }\n if (target['parentKey']) {\n property['parentKey'] = target['parentKey'];\n setKeys(property);\n property['__insertAfter__'] = target['key'];\n }\n addPropertyAfter(target, property);\n\n refresh();\n return target.parent.properties[property.name];\n },\n };\n}\n\nexport function getSchemaPath(schema: Schema) {\n const path = schema['x-path'] || [schema.name];\n let parent = schema.parent;\n while (parent) {\n // if (!parent.name) {\n // break;\n // }\n if (parent['x-path']) {\n path.unshift(...parent['x-path']);\n } else if (parent.name) {\n path.unshift(parent.name);\n }\n parent = parent.parent;\n }\n // console.log('getSchemaPath', path, schema);\n return [...path];\n}\n\nexport function useSchemaPath() {\n const schema = useFieldSchema();\n const path = getSchemaPath(schema);\n return [...path];\n}\n\nconst FormValues = () => {\n const form = useForm();\n const [visible, setVisible] = useState(false);\n return (\n <>\n <CodeOutlined onClick={() => setVisible(true)} />\n <Modal\n width={'50%'}\n onOk={() => setVisible(false)}\n onCancel={() => setVisible(false)}\n visible={visible}\n >\n <Editor\n height=\"60vh\"\n defaultLanguage=\"json\"\n value={JSON.stringify(form.values, null, 2)}\n />\n {/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}\n </Modal>\n </>\n );\n};\n\nconst CodePreview = ({ schema }) => {\n const [visible, setVisible] = useState(false);\n return (\n <>\n <CodeOutlined\n style={{ position: 'relative', zIndex: 100 }}\n onClick={() => setVisible(true)}\n />\n <Modal\n width={'50%'}\n onOk={() => setVisible(false)}\n onCancel={() => setVisible(false)}\n visible={visible}\n >\n <Editor\n height=\"60vh\"\n defaultLanguage=\"json\"\n value={JSON.stringify(schema.toJSON(), null, 2)}\n />\n {/* <pre>{JSON.stringify(schema.toJSON(), null, 2)}</pre> */}\n </Modal>\n </>\n );\n};\n\nexport interface SchemaRendererProps {\n schema: Schema | ISchema | FormilyISchema;\n form?: any;\n render?: any;\n components?: any;\n scope?: any;\n debug?: boolean;\n onlyRenderProperties?: boolean;\n onRefresh?: any;\n [key: string]: any;\n}\n\nexport const SchemaRenderer = (props: SchemaRendererProps) => {\n const { designable = true } = useDesignableSwitchContext();\n const [, refresh] = useState(uid());\n const form = useMemo(() => props.form || createForm(), []);\n const schema = useMemo(() => {\n if (Schema.isSchemaInstance(props.schema)) {\n return props.schema;\n }\n let s = props.schema;\n if (props.onlyRenderProperties) {\n s = {\n type: 'object',\n properties: s.properties,\n };\n } else if (s.name) {\n s = {\n type: 'object',\n properties: {\n [s.name]: s,\n },\n };\n }\n return new Schema(s);\n }, []);\n\n const resource = useResourceRequest('china_regions');\n\n const loadChinaRegionDataSource = function () {\n return async (field: ArrayField) => {\n if (field.readPretty) {\n return [];\n }\n const maxLevel = field.componentProps.maxLevel || 3;\n const { data } = await resource.list({\n perPage: -1,\n filter: {\n level: 1,\n },\n });\n console.log('loadChinaRegions', data, field.value);\n return (\n data?.map((item) => {\n if (maxLevel !== 1) {\n item.isLeaf = false;\n }\n return item;\n }) || []\n );\n };\n };\n\n const loadChinaRegionData = function () {\n return (selectedOptions: CascaderOptionType[], field: ArrayField) => {\n const maxLevel = field.componentProps.maxLevel || 3;\n const targetOption = selectedOptions[selectedOptions.length - 1];\n targetOption.loading = true;\n resource\n .list({\n perPage: -1,\n filter: {\n parent_code: targetOption['code'],\n },\n })\n .then((data) => {\n targetOption.loading = false;\n targetOption.children =\n data?.data?.map((item) => {\n if (maxLevel > item.level) {\n item.isLeaf = false;\n }\n return item;\n }) || [];\n field.dataSource = [...field.dataSource];\n });\n };\n };\n\n // useEffect(() => {\n // refresh(uid());\n // }, [designable]);\n console.log({ designable }, 'designable');\n const defaultRender = ({ schema }) => (\n <FormProvider form={form}>\n <SchemaField\n components={props.components}\n scope={{\n ...props.scope,\n ChinaRegion: {\n useFieldValue: useChinaRegionFieldValue,\n loadData: loadChinaRegionData,\n loadDataSource: loadChinaRegionDataSource,\n },\n }}\n schema={schema}\n />\n {props.debug && <CodePreview schema={schema} />}\n {props.debug && <FormValues />}\n </FormProvider>\n );\n return (\n <DesignableContext.Provider\n value={{\n schema,\n refresh: () => {\n props.onRefresh && props.onRefresh(schema);\n refresh(uid());\n },\n }}\n >\n <DesignableContext.Consumer>\n {props.render || defaultRender}\n </DesignableContext.Consumer>\n </DesignableContext.Provider>\n );\n};\n"]}
|
|
@@ -924,6 +924,61 @@ const SchemaRenderer = props => {
|
|
|
924
924
|
|
|
925
925
|
return new react_1.Schema(s);
|
|
926
926
|
}, []);
|
|
927
|
+
const resource = (0, constate_1.useResourceRequest)('china_regions');
|
|
928
|
+
|
|
929
|
+
const loadChinaRegionDataSource = function loadChinaRegionDataSource() {
|
|
930
|
+
return field => __awaiter(this, void 0, void 0, function* () {
|
|
931
|
+
if (field.readPretty) {
|
|
932
|
+
return [];
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
const maxLevel = field.componentProps.maxLevel || 3;
|
|
936
|
+
|
|
937
|
+
const _yield$resource$list2 = yield resource.list({
|
|
938
|
+
perPage: -1,
|
|
939
|
+
filter: {
|
|
940
|
+
level: 1
|
|
941
|
+
}
|
|
942
|
+
}),
|
|
943
|
+
data = _yield$resource$list2.data;
|
|
944
|
+
|
|
945
|
+
console.log('loadChinaRegions', data, field.value);
|
|
946
|
+
return (data === null || data === void 0 ? void 0 : data.map(item => {
|
|
947
|
+
if (maxLevel !== 1) {
|
|
948
|
+
item.isLeaf = false;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
return item;
|
|
952
|
+
})) || [];
|
|
953
|
+
});
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
const loadChinaRegionData = function loadChinaRegionData() {
|
|
957
|
+
return (selectedOptions, field) => {
|
|
958
|
+
const maxLevel = field.componentProps.maxLevel || 3;
|
|
959
|
+
const targetOption = selectedOptions[selectedOptions.length - 1];
|
|
960
|
+
targetOption.loading = true;
|
|
961
|
+
resource.list({
|
|
962
|
+
perPage: -1,
|
|
963
|
+
filter: {
|
|
964
|
+
parent_code: targetOption['code']
|
|
965
|
+
}
|
|
966
|
+
}).then(data => {
|
|
967
|
+
var _a;
|
|
968
|
+
|
|
969
|
+
targetOption.loading = false;
|
|
970
|
+
targetOption.children = ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.map(item => {
|
|
971
|
+
if (maxLevel > item.level) {
|
|
972
|
+
item.isLeaf = false;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return item;
|
|
976
|
+
})) || [];
|
|
977
|
+
field.dataSource = [...field.dataSource];
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
|
|
927
982
|
console.log({
|
|
928
983
|
designable
|
|
929
984
|
}, 'designable');
|
|
@@ -934,7 +989,13 @@ const SchemaRenderer = props => {
|
|
|
934
989
|
form: form
|
|
935
990
|
}, react_2.default.createElement(exports.SchemaField, {
|
|
936
991
|
components: props.components,
|
|
937
|
-
scope: props.scope,
|
|
992
|
+
scope: Object.assign(Object.assign({}, props.scope), {
|
|
993
|
+
ChinaRegion: {
|
|
994
|
+
useFieldValue: useChinaRegionFieldValue,
|
|
995
|
+
loadData: loadChinaRegionData,
|
|
996
|
+
loadDataSource: loadChinaRegionDataSource
|
|
997
|
+
}
|
|
998
|
+
}),
|
|
938
999
|
schema: schema
|
|
939
1000
|
}), props.debug && react_2.default.createElement(CodePreview, {
|
|
940
1001
|
schema: schema
|