diff --git a/packages/core/client/src/application/schema-settings/SchemaSettings.tsx b/packages/core/client/src/application/schema-settings/SchemaSettings.tsx index 595f3f63b..d0869413d 100644 --- a/packages/core/client/src/application/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/application/schema-settings/SchemaSettings.tsx @@ -1,5 +1,5 @@ -import { SchemaSettingOptions, SchemaSettingsItemType, SchemaSettingsItemTypeWithoutName } from './types'; import { defaultSettingItems } from './SchemaSettingsDefaults'; +import { SchemaSettingOptions, SchemaSettingsItemType, SchemaSettingsItemTypeWithoutName } from './types'; export class SchemaSettings { options: SchemaSettingOptions; diff --git a/packages/core/client/src/data-source/data-block/DataBlockProvider.tsx b/packages/core/client/src/data-source/data-block/DataBlockProvider.tsx index 15990a58e..a682d0ad4 100644 --- a/packages/core/client/src/data-source/data-block/DataBlockProvider.tsx +++ b/packages/core/client/src/data-source/data-block/DataBlockProvider.tsx @@ -1,4 +1,4 @@ -import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react'; +import React, { createContext, FC, ReactNode, useContext, useMemo } from 'react'; import { ACLCollectionProvider } from '../../acl/ACLProvider'; import { UseRequestOptions, UseRequestService } from '../../api-client'; @@ -6,9 +6,9 @@ import { withDynamicSchemaProps } from '../../application/hoc'; import { Designable, useDesignable } from '../../schema-component'; import { AssociationProvider, CollectionManagerProvider, CollectionOptions, CollectionProvider } from '../collection'; import { CollectionRecord } from '../collection-record'; +import { ConfigSettingProvider } from './context/ConfigSetting.provider'; import { BlockRequestProvider } from './DataBlockRequestProvider'; import { DataBlockResourceProvider } from './DataBlockResourceProvider'; -import { ConfigSettingProvider } from './context/ConfigSetting.provider'; export interface AllDataBlockProps { collection: string | CollectionOptions; diff --git a/packages/core/client/src/filter-provider/utils.ts b/packages/core/client/src/filter-provider/utils.ts index 52cab8c87..cc90c1cab 100644 --- a/packages/core/client/src/filter-provider/utils.ts +++ b/packages/core/client/src/filter-provider/utils.ts @@ -1,7 +1,9 @@ +import { useCallback, useEffect, useState } from 'react'; import { Schema, useFieldSchema } from '@tachybase/schema'; import { flatten, getValuesByPath } from '@tachybase/utils/client'; + import _ from 'lodash'; -import { useCallback, useEffect, useState } from 'react'; + import { FilterTarget, findFilterTargets } from '../block-provider/hooks'; import { Collection_deprecated, diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx b/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx index 39b967e8b..f0fd17608 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/form/fieldSettingsFormItem.tsx @@ -1,21 +1,22 @@ +import { useContextConfigSetting } from '@tachybase/client'; import { ArrayCollapse, FormLayout } from '@tachybase/components'; -import { Field } from '@tachybase/schema'; -import { ISchema, useField, useFieldSchema } from '@tachybase/schema'; +import { Field, ISchema, useField, useFieldSchema } from '@tachybase/schema'; + import _ from 'lodash'; import { useTranslation } from 'react-i18next'; + import { useApp, useSchemaToolbar } from '../../../../application'; import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { useFormBlockContext } from '../../../../block-provider'; -import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../../collection-manager'; +import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../../collection-manager'; import { useFieldComponentName } from '../../../../common/useFieldComponentName'; import { useDesignable, useValidateSchema } from '../../../../schema-component'; import { useIsFormReadPretty } from '../../../../schema-component/antd/form-item/FormItem.Settings'; import { getTempFieldState } from '../../../../schema-component/antd/form-v2/utils'; import { isPatternDisabled } from '../../../../schema-settings'; +import { useIsAllowToSetDefaultValue } from '../../../../schema-settings/hooks/useIsAllowToSetDefaultValue'; import { ActionType } from '../../../../schema-settings/LinkageRules/type'; import { SchemaSettingsDefaultValue } from '../../../../schema-settings/SchemaSettingsDefaultValue'; -import { useIsAllowToSetDefaultValue } from '../../../../schema-settings/hooks/useIsAllowToSetDefaultValue'; -import { useContextConfigSetting } from '@tachybase/client'; export const fieldSettingsFormItem = new SchemaSettings({ name: 'fieldSettings:FormItem', diff --git a/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts index 194382f89..aaf0e34ed 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts @@ -1,9 +1,10 @@ -import { ArrayItems } from '@tachybase/components'; -import { ISchema } from '@tachybase/schema'; -import { useField, useFieldSchema } from '@tachybase/schema'; -import _ from 'lodash'; import { useMemo } from 'react'; +import { ArrayItems } from '@tachybase/components'; +import { ISchema, useField, useFieldSchema } from '@tachybase/schema'; + +import _ from 'lodash'; import { useTranslation } from 'react-i18next'; + import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { useFormBlockContext } from '../../../../block-provider'; import { useCollection_deprecated, useSortFields } from '../../../../collection-manager'; @@ -16,9 +17,9 @@ import { screenSizeTitleMaps, } from '../../../../schema-component/antd/grid-card/options'; import { SchemaSettingsTemplate } from '../../../../schema-settings'; -import { columnCountMarks } from './utils'; import { SchemaSettingsDataScope } from '../../../../schema-settings/SchemaSettingsDataScope'; import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem'; +import { columnCountMarks } from './utils'; export const gridCardBlockSettings = new SchemaSettings({ name: 'blockSettings:gridCard', diff --git a/packages/core/client/src/modules/fields/component/Checkbox/checkboxComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/Checkbox/checkboxComponentFieldSettings.tsx index dd7598360..ca19f75f6 100644 --- a/packages/core/client/src/modules/fields/component/Checkbox/checkboxComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/Checkbox/checkboxComponentFieldSettings.tsx @@ -1,8 +1,11 @@ import { Field, useField, useFieldSchema } from '@tachybase/schema'; -import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; -import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator'; -import { useDesignable } from '../../../../schema-component'; + import { useTranslation } from 'react-i18next'; + +import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; +import { useDesignable } from '../../../../schema-component'; +import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator'; + export const checkboxComponentFieldSettings = new SchemaSettings({ name: 'fieldSettings:component:Checkbox', items: [ diff --git a/packages/core/client/src/schema-component/antd/action/Action.Container.tsx b/packages/core/client/src/schema-component/antd/action/Action.Container.tsx index b02090138..399fd23c4 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Container.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Container.tsx @@ -1,10 +1,11 @@ -import { observer, RecursionField, useField, useFieldSchema } from '@tachybase/schema'; import React from 'react'; +import { observer, RecursionField, useField, useFieldSchema } from '@tachybase/schema'; + import { useActionContext } from '.'; import { ActionDrawer } from './Action.Drawer'; -import { ActionSheet } from './Action.Sheet'; import { ActionModal } from './Action.Modal'; import { ActionPage } from './Action.Page'; +import { ActionSheet } from './Action.Sheet'; import { ComposedActionDrawer } from './types'; export const ActionContainer: ComposedActionDrawer = observer( diff --git a/packages/core/client/src/schema-component/antd/action/context.tsx b/packages/core/client/src/schema-component/antd/action/context.tsx index 27bec8559..68ebabc85 100644 --- a/packages/core/client/src/schema-component/antd/action/context.tsx +++ b/packages/core/client/src/schema-component/antd/action/context.tsx @@ -1,6 +1,8 @@ -import { Schema } from '@tachybase/schema'; -import { DrawerProps, ModalProps } from 'antd'; import React, { createContext } from 'react'; +import { Schema } from '@tachybase/schema'; + +import { DrawerProps, ModalProps } from 'antd'; + import { useActionContext } from './hooks'; export const ActionContext = createContext({}); diff --git a/packages/core/client/src/schema-component/antd/appends-tree-select/AppendsTreeSelect.tsx b/packages/core/client/src/schema-component/antd/appends-tree-select/AppendsTreeSelect.tsx index 2ce7c8454..c2d9bef83 100644 --- a/packages/core/client/src/schema-component/antd/appends-tree-select/AppendsTreeSelect.tsx +++ b/packages/core/client/src/schema-component/antd/appends-tree-select/AppendsTreeSelect.tsx @@ -1,8 +1,10 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; + import { CloseCircleFilled } from '@ant-design/icons'; import { Tag, TreeSelect } from 'antd'; import type { DefaultOptionType, TreeSelectProps } from 'rc-tree-select/es/TreeSelect'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; + import { CollectionFieldOptions_deprecated, parseCollectionName, diff --git a/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx b/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx index 4ec3a8653..03eaf8433 100644 --- a/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/AssociationSelect.tsx @@ -1,15 +1,25 @@ -import { LoadingOutlined, PlusOutlined } from '@ant-design/icons'; -import { onFieldInputValueChange } from '@tachybase/schema'; -import { RecursionField, connect, mapProps, observer, useField, useFieldSchema, useForm } from '@tachybase/schema'; -import { uid } from '@tachybase/schema'; -import { Space, message } from 'antd'; -import { isFunction } from 'mathjs'; import React, { useEffect, useMemo, useState } from 'react'; +import { + connect, + mapProps, + observer, + onFieldInputValueChange, + RecursionField, + uid, + useField, + useFieldSchema, + useForm, +} from '@tachybase/schema'; + +import { LoadingOutlined, PlusOutlined } from '@ant-design/icons'; +import { message, Space } from 'antd'; +import { isFunction } from 'mathjs'; import { useTranslation } from 'react-i18next'; + import { RecordProvider, useAPIClient, useApp, useCollectionRecordData } from '../../../'; import { isVariable } from '../../../variables/utils/isVariable'; import { getInnermostKeyAndValue } from '../../common/utils/uitls'; -import { RemoteSelectProps, RemoteSelect } from '../remote-select'; +import { RemoteSelect, RemoteSelectProps } from '../remote-select'; import useServiceOptions, { useAssociationFieldContext } from './hooks'; export type AssociationSelectProps

= RemoteSelectProps

& { diff --git a/packages/core/client/src/schema-component/antd/checkbox/Checkbox.tsx b/packages/core/client/src/schema-component/antd/checkbox/Checkbox.tsx index 06d927625..6563d5542 100644 --- a/packages/core/client/src/schema-component/antd/checkbox/Checkbox.tsx +++ b/packages/core/client/src/schema-component/antd/checkbox/Checkbox.tsx @@ -1,13 +1,14 @@ +import React from 'react'; +import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/schema'; + import { CheckOutlined, CloseOutlined } from '@ant-design/icons'; -import { connect, mapProps, mapReadPretty, useField } from '@tachybase/schema'; -import { isValid } from '@tachybase/schema'; import { Checkbox as AntdCheckbox, Radio, Tag } from 'antd'; import type { CheckboxGroupProps, CheckboxProps } from 'antd/es/checkbox'; import uniq from 'lodash/uniq'; -import React from 'react'; +import { useTranslation } from 'react-i18next'; + import { useCollectionField } from '../../../data-source/collection-field/CollectionFieldProvider'; import { EllipsisWithTooltip } from '../input/EllipsisWithTooltip'; -import { useTranslation } from 'react-i18next'; type ComposedCheckbox = React.ForwardRefExoticComponent< Pick, string | number | symbol> & React.RefAttributes diff --git a/packages/core/client/src/schema-component/antd/grid-card/GridCard.Decorator.tsx b/packages/core/client/src/schema-component/antd/grid-card/GridCard.Decorator.tsx index fb5f96726..946befc28 100644 --- a/packages/core/client/src/schema-component/antd/grid-card/GridCard.Decorator.tsx +++ b/packages/core/client/src/schema-component/antd/grid-card/GridCard.Decorator.tsx @@ -1,11 +1,11 @@ -import { FormLayout } from '@tachybase/components'; -import { createForm } from '@tachybase/schema'; -import { FormContext, useField, useFieldSchema } from '@tachybase/schema'; import React, { createContext, useContext, useEffect, useMemo } from 'react'; -import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider'; -import useStyles from './GridCard.Decorator.style'; -import { useGridCardBlockParams } from '../../../modules/blocks/data-blocks/grid-card/hooks/useGridCardBlockParams'; +import { FormLayout } from '@tachybase/components'; +import { createForm, FormContext, useField, useFieldSchema } from '@tachybase/schema'; + import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps'; +import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider'; +import { useGridCardBlockParams } from '../../../modules/blocks/data-blocks/grid-card/hooks/useGridCardBlockParams'; +import useStyles from './GridCard.Decorator.style'; export const GridCardBlockContext = createContext({}); GridCardBlockContext.displayName = 'GridCardBlockContext'; diff --git a/packages/core/client/src/schema-component/common/infinite-scroll/infinite-scroll.tsx b/packages/core/client/src/schema-component/common/infinite-scroll/infinite-scroll.tsx index 19ef38c89..99aaf159c 100644 --- a/packages/core/client/src/schema-component/common/infinite-scroll/infinite-scroll.tsx +++ b/packages/core/client/src/schema-component/common/infinite-scroll/infinite-scroll.tsx @@ -1,8 +1,10 @@ +import React, { ReactNode, useEffect, useRef, useState } from 'react'; import { getScrollParent, merge } from '@tachybase/utils/client'; + import { useLockFn, useThrottleFn } from 'ahooks'; import { Spin } from 'antd'; -import React, { ReactNode, useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; + import useStyles from './style'; function isWindow(element: any | Window): element is Window { diff --git a/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx b/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx index 60a755213..ecfd08e64 100644 --- a/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx +++ b/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx @@ -1,7 +1,7 @@ -import { createForm } from '@tachybase/schema'; -import { Schema } from '@tachybase/schema'; // import { Spin } from 'antd'; import React, { PropsWithChildren, useMemo } from 'react'; +import { createForm, Schema } from '@tachybase/schema'; + import { useRequest } from '../../api-client'; import { useSchemaComponentContext } from '../hooks'; import { FormProvider } from './FormProvider'; diff --git a/packages/core/client/src/schema-items/OpenModeSchemaItems.tsx b/packages/core/client/src/schema-items/OpenModeSchemaItems.tsx index d1e094d2c..07a6bbb69 100644 --- a/packages/core/client/src/schema-items/OpenModeSchemaItems.tsx +++ b/packages/core/client/src/schema-items/OpenModeSchemaItems.tsx @@ -1,7 +1,9 @@ -import { useField, useFieldSchema } from '@tachybase/schema'; -import { Select } from 'antd'; import React from 'react'; +import { useField, useFieldSchema } from '@tachybase/schema'; + +import { Select } from 'antd'; import { useTranslation } from 'react-i18next'; + import { SchemaInitializerItem, SchemaInitializerSelect } from '../application'; import { useDesignable } from '../schema-component'; import { SchemaSettingsSelectItem } from '../schema-settings'; diff --git a/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts b/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts index 2fd29dfcf..694cbaef8 100644 --- a/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts +++ b/packages/core/client/src/schema-settings/SchemaSettingsPlugin.ts @@ -39,21 +39,21 @@ import { filterCollapseItemFieldSettings } from '../modules/blocks/filter-blocks import { filterFormBlockSettings } from '../modules/blocks/filter-blocks/form/filterFormBlockSettings'; import { filterFormItemFieldSettings } from '../modules/blocks/filter-blocks/form/filterFormItemFieldSettings'; import { markdownBlockSettings } from '../modules/blocks/other-blocks/markdown/markdownBlockSettings'; -import { cascadeSelectComponentFieldSettings } from '../modules/fields/component/CascadeSelect/cascadeSelectComponentFieldSettings'; import { cascaderComponentFieldSettings } from '../modules/fields/component/Cascader/cascaderComponentFieldSettings'; +import { cascadeSelectComponentFieldSettings } from '../modules/fields/component/CascadeSelect/cascadeSelectComponentFieldSettings'; +import { checkboxComponentFieldSettings } from '../modules/fields/component/Checkbox/checkboxComponentFieldSettings'; import { datePickerComponentFieldSettings } from '../modules/fields/component/DatePicker/datePickerComponentFieldSettings'; +import { drawerSubTableComponentFieldSettings } from '../modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings'; import { fileManagerComponentFieldSettings } from '../modules/fields/component/FileManager/fileManagerComponentFieldSettings'; import { uploadAttachmentComponentFieldSettings } from '../modules/fields/component/FileManager/uploadAttachmentComponentFieldSettings'; +import { inputNumberComponentFieldSettings } from '../modules/fields/component/InputNumber/inputNumberComponentFieldSettings'; import { subformComponentFieldSettings } from '../modules/fields/component/Nester/subformComponentFieldSettings'; import { recordPickerComponentFieldSettings } from '../modules/fields/component/Picker/recordPickerComponentFieldSettings'; import { subformPopoverComponentFieldSettings } from '../modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings'; -import { drawerSubTableComponentFieldSettings } from '../modules/fields/component/DrawerSubTable/drawerSubTableComponentFieldSettings'; import { selectComponentFieldSettings } from '../modules/fields/component/Select/selectComponentFieldSettings'; import { subTablePopoverComponentFieldSettings } from '../modules/fields/component/SubTable/subTablePopoverComponentFieldSettings'; import { tagComponentFieldSettings } from '../modules/fields/component/Tag/tagComponentFieldSettings'; import { unixTimestampComponentFieldSettings } from '../modules/fields/component/UnixTimestamp/unixTimestampComponentFieldSettings'; -import { inputNumberComponentFieldSettings } from '../modules/fields/component/InputNumber/inputNumberComponentFieldSettings'; -import { checkboxComponentFieldSettings } from '../modules/fields/component/Checkbox/checkboxComponentFieldSettings'; export class SchemaSettingsPlugin extends Plugin { async load() { diff --git a/packages/core/utils/src/client.ts b/packages/core/utils/src/client.ts index e8359b0de..449a54638 100644 --- a/packages/core/utils/src/client.ts +++ b/packages/core/utils/src/client.ts @@ -1,4 +1,5 @@ import lodash from 'lodash'; + import { dayjs } from './dayjs'; export * from './collections-graph'; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/ApprovalBlockInitializer.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/ApprovalBlockInitializer.tsx index e008dbcf0..7f95537ab 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/ApprovalBlockInitializer.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/ApprovalBlockInitializer.tsx @@ -1,6 +1,7 @@ -import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; import React from 'react'; +import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; import { ISchema } from '@tachybase/schema'; + import { CalendarOutline } from 'antd-mobile-icons'; export const ApprovalBlockInitializer = () => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx index d3e92656a..ecbc72256 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx @@ -1,13 +1,15 @@ +import React, { useMemo } from 'react'; import { createStyles, useCurrentUserContext } from '@tachybase/client'; import { EXECUTION_STATUS } from '@tachybase/plugin-workflow/client'; +import { dayjs } from '@tachybase/utils/client'; + +import { Space, Steps, Tag } from 'antd-mobile'; import _ from 'lodash'; -import React, { useMemo } from 'react'; + import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS, ApprovalStatusEnums, approvalStatusOptions } from '../constants'; -import { lang, usePluginTranslation, useTranslation } from '../locale'; import { useContextApprovalExecution } from '../context/ApprovalExecution'; import { ContextWithActionEnabled } from '../context/WithActionEnabled'; -import { Space, Steps, Tag } from 'antd-mobile'; -import { dayjs } from '@tachybase/utils/client'; +import { lang, usePluginTranslation, useTranslation } from '../locale'; export const ApprovalProcess = (props) => { const { t } = usePluginTranslation(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalReachDataType.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalReachDataType.tsx index c10ac8f0e..daa0325b6 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalReachDataType.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalReachDataType.tsx @@ -1,8 +1,9 @@ +import React, { useState } from 'react'; import { observer } from '@tachybase/schema'; import { dayjs } from '@tachybase/utils/client'; + import { AutoCenter, Button, DatePicker, Grid, Popup, Space, Toast } from 'antd-mobile'; import { DownOutline } from 'antd-mobile-icons'; -import React, { useState } from 'react'; export const ApprovalReachDataType = observer((props) => { const { changeFilter, filter } = props as any; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalTemplateType.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalTemplateType.tsx index 694a3b665..b9e07f75c 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalTemplateType.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalTemplateType.tsx @@ -1,8 +1,10 @@ +import React, { useEffect, useState } from 'react'; import { useAPIClient } from '@tachybase/client'; import { observer, useFieldSchema } from '@tachybase/schema'; + import { Picker, Space } from 'antd-mobile'; import { DownOutline } from 'antd-mobile-icons'; -import React, { useEffect, useState } from 'react'; + import { useTranslation } from '../locale'; export const ApprovalTemplateType = observer((props) => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/constants.ts b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/constants.ts index 4691832db..890f782c5 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/constants.ts +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/constants.ts @@ -1,5 +1,6 @@ import { JOB_STATUS } from '@tachybase/plugin-workflow/client'; -import { NAMESPACE, lang, tval } from './locale'; + +import { lang, NAMESPACE, tval } from './locale'; /**显示状态 */ export const APPROVAL_STATUS = { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/ApprovalExecution.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/ApprovalExecution.tsx index cd4584a7d..2ceadfd9e 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/ApprovalExecution.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/ApprovalExecution.tsx @@ -1,4 +1,5 @@ import { createContext, useContext } from 'react'; + import { ApprovalExecution } from '../todos/interface/interface'; export const ContextApprovalExecution = createContext>({}); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/FormBlock.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/FormBlock.tsx index d49759086..520d017f2 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/FormBlock.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/FormBlock.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment, useContext, useMemo, useRef } from 'react'; import { BlockRequestContext_deprecated, CollectionProvider_deprecated, @@ -11,8 +11,8 @@ import { useAssociationNames, useDesignable, } from '@tachybase/client'; -import { RecursionField, createForm, useField, useFieldSchema } from '@tachybase/schema'; -import { Fragment, useContext, useMemo, useRef } from 'react'; +import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema'; + import { useContextApprovalExecution } from './ApprovalExecution'; export const FormBlockProvider = (props) => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/SchemaComponent.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/SchemaComponent.tsx index 19bf99c11..0e18cfec3 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/SchemaComponent.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/context/SchemaComponent.tsx @@ -1,5 +1,5 @@ -import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client'; import React from 'react'; +import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client'; export function SchemaComponentContextProvider({ designable, children }) { const schemaComponentContext = useSchemaComponentContext(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/index.ts b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/index.ts index 3d7546f86..3c7d26e28 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/index.ts +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/index.ts @@ -1,13 +1,14 @@ import { Plugin } from '@tachybase/client'; + import { ApprovalBlockInitializer } from './ApprovalBlockInitializer'; import { ApprovalSettings } from './ApprovalSettings'; -import { TodosBlock } from './todos/TodosBlock'; -import { InitiationsBlock } from './initiations/InitiationsBlock'; -import { LauncherActionConfigInitializer } from './initiations/config/LauncherActionConfig'; -import { ViewActionTodosContent } from './todos/component/ViewActionTodosContent'; -import { ViewActionUserInitiationsContent } from './initiations/component/ViewActionUserInitiationsContent'; import { ApprovalProcess } from './component/ApprovalProcess.view'; import { ViewActionInitiationsContent } from './initiations/component/ViewActionInitiationsContent'; +import { ViewActionUserInitiationsContent } from './initiations/component/ViewActionUserInitiationsContent'; +import { LauncherActionConfigInitializer } from './initiations/config/LauncherActionConfig'; +import { InitiationsBlock } from './initiations/InitiationsBlock'; +import { ViewActionTodosContent } from './todos/component/ViewActionTodosContent'; +import { TodosBlock } from './todos/TodosBlock'; class PluginApproval extends Plugin { async load() { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx index d7f02a773..8ba076b7b 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx @@ -1,11 +1,13 @@ -import { useAPIClient, useCurrentUserContext } from '@tachybase/client'; -import { Badge, Empty, List, Space, Tag } from 'antd-mobile'; import React, { useContext, useEffect, useState } from 'react'; -import { useDeepCompareEffect } from 'ahooks'; -import { ApprovalPriorityType, ApprovalStatusEnums } from '../../constants'; -import { useNavigate } from 'react-router-dom'; -import { useTranslation } from '../../locale'; +import { useAPIClient, useCurrentUserContext } from '@tachybase/client'; import { observer } from '@tachybase/schema'; + +import { useDeepCompareEffect } from 'ahooks'; +import { Badge, Empty, List, Space, Tag } from 'antd-mobile'; +import { useNavigate } from 'react-router-dom'; + +import { ApprovalPriorityType, ApprovalStatusEnums } from '../../constants'; +import { useTranslation } from '../../locale'; import { InitiationsBlockContext } from '../InitiationsBlock'; export const ApprovalItem = observer((props) => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalStatus.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalStatus.tsx index b9fdbe4e7..e78f9283b 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalStatus.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalStatus.tsx @@ -1,8 +1,10 @@ +import React, { useState } from 'react'; +import { observer, useFieldSchema } from '@tachybase/schema'; + import { Picker, Space } from 'antd-mobile'; import { DownOutline } from 'antd-mobile-icons'; -import React, { useState } from 'react'; + import { useTranslation } from '../../locale'; -import { observer, useFieldSchema } from '@tachybase/schema'; export const ApprovalStatus = observer((props) => { const { changeFilter, filter } = props as any; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/UserInitiationsItem.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/UserInitiationsItem.tsx index f47f222dd..720a11ce0 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/UserInitiationsItem.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/UserInitiationsItem.tsx @@ -1,11 +1,14 @@ -import { BlockItem } from '@tachybase/client'; -import { Space } from 'antd-mobile'; import React, { useState } from 'react'; +import { BlockItem } from '@tachybase/client'; import { observer } from '@tachybase/schema'; -import { ApprovalTemplateType } from '../../component/ApprovalTemplateType'; -import { ApprovalStatus } from './ApprovalStatus'; -import { ApprovalItem } from './ApprovalItem'; + +import { Space } from 'antd-mobile'; + import { ApprovalReachDataType } from '../../component/ApprovalReachDataType'; +import { ApprovalTemplateType } from '../../component/ApprovalTemplateType'; +import { ApprovalItem } from './ApprovalItem'; +import { ApprovalStatus } from './ApprovalStatus'; + import '../../style/style.css'; export const UserInitiationsItem = observer((props) => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfig.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfig.tsx index bb7f71104..7fa33c35f 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfig.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfig.tsx @@ -1,7 +1,8 @@ import { SchemaInitializer } from '@tachybase/client'; -import { LauncherActionConfigComponent } from './LauncherActionConfigComponent'; -import { NAMESPACE } from '../../locale'; + import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from '../../constants'; +import { NAMESPACE } from '../../locale'; +import { LauncherActionConfigComponent } from './LauncherActionConfigComponent'; // 区块-配置操作 export const LauncherActionConfigInitializer = new SchemaInitializer({ diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfigComponent.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfigComponent.tsx index 539ad063a..680f6736d 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfigComponent.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/config/LauncherActionConfigComponent.tsx @@ -1,5 +1,5 @@ -import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client'; import React from 'react'; +import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client'; // 区块-配置操作 export const LauncherActionConfigComponent = () => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useDestroyAction.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useDestroyAction.tsx index 573c3ed2f..5e94b5654 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useDestroyAction.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useDestroyAction.tsx @@ -1,6 +1,8 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField } from '@tachybase/schema'; + import _ from 'lodash'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function useDestroyAction() { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useFormBlockProps.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useFormBlockProps.tsx index 420a5538c..14f636355 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useFormBlockProps.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useFormBlockProps.tsx @@ -1,9 +1,10 @@ +import { useEffect } from 'react'; import { useCurrentUserContext } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; import { useForm } from '@tachybase/schema'; -import { useEffect } from 'react'; -import { useContextApprovalExecution } from '../../context/ApprovalExecution'; + import { ApprovalStatusEnums } from '../../constants'; +import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function useFormBlockProps() { const { approval, id } = useContextApprovalExecution(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useUpadteSubmit.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useUpadteSubmit.tsx index 106b767cb..e72d5ea2b 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useUpadteSubmit.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useUpadteSubmit.tsx @@ -1,9 +1,11 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField, useForm } from '@tachybase/schema'; + +import { Toast } from 'antd-mobile'; import _ from 'lodash'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; import { useContextApprovalStatus } from '../provider/ApplyActionStatus'; -import { Toast } from 'antd-mobile'; export function useUpdateSubmit() { const from = useForm(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useWithdrawAction.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useWithdrawAction.tsx index 2ac62abf2..3ff06d38b 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useWithdrawAction.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useWithdrawAction.tsx @@ -1,8 +1,10 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField } from '@tachybase/schema'; -import { useContextApprovalExecution } from '../../context/ApprovalExecution'; + import { Toast } from 'antd-mobile'; +import { useContextApprovalExecution } from '../../context/ApprovalExecution'; + // 撤回 export function useWithdrawAction() { const field = useField(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ActionBar.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ActionBar.tsx index 1e395cace..1b3c21d10 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ActionBar.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ActionBar.tsx @@ -1,6 +1,7 @@ import { useCurrentUserContext } from '@tachybase/client'; -import { useContextApprovalExecution } from '../../context/ApprovalExecution'; + import { APPROVAL_ACTION_STATUS } from '../../constants'; +import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function ActionBarProvider(props) { const { data } = useCurrentUserContext(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ApplyActionStatus.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ApplyActionStatus.tsx index f3867776f..8ce7142ea 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ApplyActionStatus.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/ApplyActionStatus.tsx @@ -1,7 +1,7 @@ -import React, { useContext } from 'react'; +import React, { createContext, useContext } from 'react'; import { useCurrentUserContext } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; -import { createContext } from 'react'; + import { APPROVAL_ACTION_STATUS } from '../../constants'; import { useContextApprovalExecution } from '../../context/ApprovalExecution'; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/WithdrawAction.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/WithdrawAction.tsx index 0e251f042..7a735a547 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/WithdrawAction.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/provider/WithdrawAction.tsx @@ -1,4 +1,5 @@ import { useCurrentUserContext } from '@tachybase/client'; + import { APPROVAL_ACTION_STATUS } from '../../constants'; import { useContextApprovalExecution } from '../../context/ApprovalExecution'; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/locale.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/locale.tsx index 3c725186a..0c7af895b 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/locale.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/locale.tsx @@ -1,4 +1,4 @@ -import { tval as nTval, i18n } from '@tachybase/client'; +import { i18n, tval as nTval } from '@tachybase/client'; export const NAMESPACE = '@hera/plugin-approval-mobile'; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx index c96a4ad88..a083c99bf 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx @@ -1,18 +1,22 @@ -import { BlockItem, ExtendCollectionsProvider } from '@tachybase/client'; -import { SearchBar, Space, Tabs } from 'antd-mobile'; import React, { useEffect, useState } from 'react'; -import { TabApplicantType } from './component/TabApplicantType'; -import { TabApprovalType } from './component/TabApprovalType'; -import { TabApprovalItem } from './component/TabApprovalItem'; +import { BlockItem, ExtendCollectionsProvider } from '@tachybase/client'; import { observer } from '@tachybase/schema'; + +import { SearchBar, Space, Tabs } from 'antd-mobile'; + +import { TabApplicantType } from './component/TabApplicantType'; +import { TabApprovalItem } from './component/TabApprovalItem'; +import { TabApprovalType } from './component/TabApprovalType'; + import '../style/style.css'; + +import { CollectionApprovals } from '../collection/Approvals.collection'; +import { CollectionApprovalTodos } from '../collection/ApprovalTodos'; +import { CollectionFlowNodes } from '../collection/FlowNodes.collection'; +import { CollectionWorkflows } from '../collection/Workflows.collection'; import { ApprovalReachDataType } from '../component/ApprovalReachDataType'; import { ApprovalTemplateType } from '../component/ApprovalTemplateType'; import { PendingStatus, ProcessedStatus } from '../constants'; -import { CollectionWorkflows } from '../collection/Workflows.collection'; -import { CollectionFlowNodes } from '../collection/FlowNodes.collection'; -import { CollectionApprovals } from '../collection/Approvals.collection'; -import { CollectionApprovalTodos } from '../collection/ApprovalTodos'; export const TodosBlock = observer((props) => { const [filter, setFilter] = useState({ diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApplicantType.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApplicantType.tsx index eda99be14..e24454c23 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApplicantType.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApplicantType.tsx @@ -1,8 +1,10 @@ +import React, { useEffect, useState } from 'react'; import { useAPIClient } from '@tachybase/client'; import { observer, useFieldSchema } from '@tachybase/schema'; + import { Picker, Space } from 'antd-mobile'; import { DownOutline } from 'antd-mobile-icons'; -import React, { useEffect, useState } from 'react'; + import { useTranslation } from '../../locale'; export const TabApplicantType = observer((props) => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalType.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalType.tsx index f1aee4341..f656c9dcb 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalType.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalType.tsx @@ -1,8 +1,10 @@ +import React, { useState } from 'react'; import { observer } from '@tachybase/schema'; + import { Picker, Space } from 'antd-mobile'; import { DownOutline } from 'antd-mobile-icons'; -import React, { useState } from 'react'; -import { ProcessedStatus, approvalStatusOptions } from '../../constants'; + +import { approvalStatusOptions, ProcessedStatus } from '../../constants'; import { useTranslation } from '../../locale'; export const TabApprovalType = observer((props) => { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useApprovalDetailBlockProps.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useApprovalDetailBlockProps.tsx index 7835ebccb..e08e23210 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useApprovalDetailBlockProps.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useApprovalDetailBlockProps.tsx @@ -1,5 +1,6 @@ -import { useFormBlockContext } from '@tachybase/client'; import { useEffect } from 'react'; +import { useFormBlockContext } from '@tachybase/client'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function useApprovalDetailBlockProps() { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useDestroyAction.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useDestroyAction.tsx index cffdb3f46..501f82f5f 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useDestroyAction.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useDestroyAction.tsx @@ -1,6 +1,8 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField } from '@tachybase/schema'; + import _ from 'lodash'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function useDestroyAction() { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx index 37bb80045..8ffbe8b87 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx @@ -1,8 +1,9 @@ +import { useEffect } from 'react'; import { useCurrentUserContext } from '@tachybase/client'; import { useForm } from '@tachybase/schema'; -import { useEffect } from 'react'; -import { useContextApprovalExecution } from '../../context/ApprovalExecution'; + import { ApprovalStatusEnumDict } from '../../constants'; +import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function useFormBlockProps() { const { approval, id, workflow } = useContextApprovalExecution(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx index 18fc7240b..30ff1384e 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx @@ -1,8 +1,10 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField, useForm } from '@tachybase/schema'; + +import { Toast } from 'antd-mobile'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; import { useContextApprovalAction } from '../provider/ApprovalAction'; -import { Toast } from 'antd-mobile'; export function useSubmit() { const field = useField(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ActionBarProvider.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ActionBarProvider.tsx index dc3b3f61f..f26f1541f 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ActionBarProvider.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ActionBarProvider.tsx @@ -1,9 +1,11 @@ import React from 'react'; import { ActionBarProvider as ClientActionBarProvider, useCompile } from '@tachybase/client'; import { str2moment } from '@tachybase/utils/client'; + import { Space, Tag } from 'antd'; -import { useContextApprovalExecution } from '../../context/ApprovalExecution'; + import { approvalStatusOptions } from '../../constants'; +import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function ActionBarProvider(props) { const { status } = useContextApprovalExecution(); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApplyActionStatus.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApplyActionStatus.tsx index 07faf720b..f64b88f86 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApplyActionStatus.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApplyActionStatus.tsx @@ -1,6 +1,6 @@ -import React, { useContext } from 'react'; +import React, { createContext, useContext } from 'react'; import { useCurrentUserContext } from '@tachybase/client'; -import { createContext } from 'react'; + import { APPROVAL_ACTION_STATUS } from '../../constants'; import { useContextApprovalExecution } from '../../context/ApprovalExecution'; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalAction.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalAction.tsx index 4ff8e2cb1..d3d9a914d 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalAction.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalAction.tsx @@ -1,5 +1,5 @@ -import React, { useContext } from 'react'; -import { createContext } from 'react'; +import React, { createContext, useContext } from 'react'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export interface ApprovalAction { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalFormBlock.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalFormBlock.tsx index eb5379410..b19fe8b99 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalFormBlock.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/ApprovalFormBlock.tsx @@ -1,3 +1,4 @@ +import React, { Fragment, useContext, useMemo, useRef } from 'react'; import { BlockRequestContext_deprecated, FormActiveFieldsProvider, @@ -8,9 +9,10 @@ import { useCurrentUserContext, useDesignable, } from '@tachybase/client'; -import { RecursionField, createForm, useField, useFieldSchema } from '@tachybase/schema'; +import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema'; + import _ from 'lodash'; -import React, { Fragment, useContext, useMemo, useRef } from 'react'; + import { useContextApprovalExecution } from '../../context/ApprovalExecution'; export function ApprovalFormBlockDecorator(props) { diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/WithdrawAction.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/WithdrawAction.tsx index 68a515479..65f246e76 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/WithdrawAction.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/provider/WithdrawAction.tsx @@ -1,4 +1,5 @@ import { useCurrentUserContext } from '@tachybase/client'; + import { APPROVAL_ACTION_STATUS } from '../../constants'; import { useContextApprovalExecution } from '../../context/ApprovalExecution'; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/index.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/index.tsx index 8f0acb621..ed3332461 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/index.tsx @@ -1,4 +1,5 @@ import { Plugin } from '@tachybase/client'; + import PluginApproval from './approval'; export class PluginApprovalMobileClient extends Plugin { diff --git a/packages/plugins/@hera/plugin-approval/src/client/common/Pd.FormBlock.tsx b/packages/plugins/@hera/plugin-approval/src/client/common/Pd.FormBlock.tsx index c06e1159c..3ce6f023e 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/common/Pd.FormBlock.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/common/Pd.FormBlock.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment, useContext, useMemo, useRef } from 'react'; import { BlockRequestContext_deprecated, CollectionProvider_deprecated, @@ -11,8 +11,8 @@ import { useAssociationNames, useDesignable, } from '@tachybase/client'; -import { RecursionField, createForm, useField, useFieldSchema } from '@tachybase/schema'; -import { Fragment, useContext, useMemo, useRef } from 'react'; +import { createForm, RecursionField, useField, useFieldSchema } from '@tachybase/schema'; + import { useContextApprovalExecution } from '../usage/approval-block/common/ApprovalExecution.provider'; export const FormBlockProvider = (props) => { diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/approval-config/VC.SchemaConfigButtonApprover.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/approval-config/VC.SchemaConfigButtonApprover.tsx index 71576ce04..a584324e4 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/approval-config/VC.SchemaConfigButtonApprover.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/approval-config/VC.SchemaConfigButtonApprover.tsx @@ -1,5 +1,6 @@ -import { useActionContext } from '@tachybase/client'; import React from 'react'; +import { useActionContext } from '@tachybase/client'; + import { ConfigButtonView } from '../../trigger/ConfigButton.view'; import { ContextApproverConfig } from '../Pd.ContextApproverConfig'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/plugin.ts b/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/plugin.ts index 47eb09118..16907ff6b 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/plugin.ts +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/instruction/plugin.ts @@ -1,8 +1,9 @@ import { Plugin } from '@tachybase/client'; import PluginWorkflow from '@tachybase/plugin-workflow/client'; -import { ApprovalInstruction } from './node.ApprovalInstruction'; + import { ApproverActionConfigInitializer } from './approver-interface/Iz.ApproverActionConfig'; import { ApproverAddBlockInitializer } from './approver-interface/Iz.ApproverAddBlock'; +import { ApprovalInstruction } from './node.ApprovalInstruction'; export class KitApprovalInstruction extends Plugin { async load() { diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/plugin.ts b/packages/plugins/@hera/plugin-approval/src/client/configuration/plugin.ts index f00bb8b54..3687d8038 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/plugin.ts +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/plugin.ts @@ -1,4 +1,5 @@ import { Plugin } from '@tachybase/client'; + import { KitApprovalInstruction } from './instruction/plugin'; import { KitApprovalTrigger } from './trigger/plugin'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/ConfigButton.view.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/ConfigButton.view.tsx index a4fd3c3b9..c138b04bb 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/ConfigButton.view.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/ConfigButton.view.tsx @@ -1,6 +1,8 @@ -import { ActionContextProvider } from '@tachybase/client'; -import { Button } from 'antd'; import React, { useState } from 'react'; +import { ActionContextProvider } from '@tachybase/client'; + +import { Button } from 'antd'; + import { useTranslation } from '../../locale'; // 发起人操作界面->进入配置按钮 diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx index 539ad063a..680f6736d 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx @@ -1,5 +1,5 @@ -import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client'; import React from 'react'; +import { ActionInitializer, useSchemaInitializerItem } from '@tachybase/client'; // 区块-配置操作 export const LauncherActionConfigComponent = () => { diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx index 1c7d9eecd..ddaf99463 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx @@ -1,6 +1,7 @@ import { SchemaInitializer } from '@tachybase/client'; -import { NAMESPACE } from '../../../locale'; + import { APPROVAL_STATUS } from '../../../constants'; +import { NAMESPACE } from '../../../locale'; import { LauncherActionConfigComponent } from './LauncherActionConfig.component'; // 区块-配置操作 diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherAddBlockButton.initializer.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherAddBlockButton.initializer.tsx index 6b6ffe8b8..679d8b64e 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherAddBlockButton.initializer.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherAddBlockButton.initializer.tsx @@ -1,4 +1,5 @@ -import { SchemaInitializer, gridRowColWrap } from '@tachybase/client'; +import { gridRowColWrap, SchemaInitializer } from '@tachybase/client'; + import { NAMESPACE } from '../../../locale'; import { LauncherAddBlockButtonComponent } from './LauncherBlockButton.component'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherBlockButton.component.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherBlockButton.component.tsx index 98f3caeb2..84aafd6d4 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherBlockButton.component.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/LauncherBlockButton.component.tsx @@ -1,16 +1,16 @@ import React from 'react'; import { - SchemaInitializerItem, createFormBlockSchema, + SchemaInitializerItem, useCollection_deprecated, useRecordCollectionDataSourceItems, useSchemaInitializer, useSchemaInitializerItem, useSchemaTemplateManager, } from '@tachybase/client'; + +import { APPROVAL_STATUS, flatSchemaArray } from '../../../constants'; import { NAMESPACE } from '../../../locale'; -import { flatSchemaArray } from '../../../constants'; -import { APPROVAL_STATUS } from '../../../constants'; // 创建区块-Initializer的component export const LauncherAddBlockButtonComponent = () => { diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/SchemaAddBlock.component.tsx b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/SchemaAddBlock.component.tsx index f69c8fe24..0ed6f5f75 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/SchemaAddBlock.component.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/launcher-interface/SchemaAddBlock.component.tsx @@ -1,3 +1,4 @@ +import React, { useContext } from 'react'; import { SchemaComponent, SchemaComponentContext, @@ -8,8 +9,8 @@ import { } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; import { uid } from '@tachybase/utils/client'; + import { Spin } from 'antd'; -import React, { useContext } from 'react'; // 发起人操作界面-创建区块 export const SchemaAddBlock = ({ value, onChange }) => { diff --git a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/plugin.ts b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/plugin.ts index 60230fe76..b5e35eae2 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/plugin.ts +++ b/packages/plugins/@hera/plugin-approval/src/client/configuration/trigger/plugin.ts @@ -1,5 +1,6 @@ import { Plugin } from '@tachybase/client'; import PluginWorkflow from '@tachybase/plugin-workflow/client'; + import { ApprovalTrigger } from './Approval.trigger'; import { LauncherActionConfigInitializer } from './launcher-interface/LauncherActionConfig.initializer'; import { LauncherAddBlockButtonIntializer } from './launcher-interface/LauncherAddBlockButton.initializer'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/ApprovalBlock.schema.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/ApprovalBlock.schema.tsx index 8c05ad875..198191bca 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/ApprovalBlock.schema.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/ApprovalBlock.schema.tsx @@ -1,11 +1,12 @@ -import { Plugin } from '@tachybase/client'; -import { TableOutlined } from '@ant-design/icons'; -import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; -import { uid } from '@tachybase/utils/client'; import React from 'react'; +import { Plugin, SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; +import { uid } from '@tachybase/utils/client'; + +import { TableOutlined } from '@ant-design/icons'; + import { NAMESPACE } from '../../locale'; -import { ApprovalBlockLaunch } from './launch/VC.ApprovalBlockLaunch'; import { ApprovalBlockProvider } from './ApprovalBlock.provider'; +import { ApprovalBlockLaunch } from './launch/VC.ApprovalBlockLaunch'; import { ApprovalBlockTodos } from './todos/VC.ApprovalBlockTodos'; export class SCApprovalBlock extends Plugin { diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/FlowContext.provider.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/FlowContext.provider.tsx index afbc21a05..fb0ef43e0 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/FlowContext.provider.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/FlowContext.provider.tsx @@ -1,5 +1,5 @@ -import { FlowContext } from '@tachybase/plugin-workflow/client'; import React, { useContext } from 'react'; +import { FlowContext } from '@tachybase/plugin-workflow/client'; export function useFlowContext() { return useContext(FlowContext); diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/SchemaComponent.provider.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/SchemaComponent.provider.tsx index 19bf99c11..0e18cfec3 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/SchemaComponent.provider.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/common/SchemaComponent.provider.tsx @@ -1,5 +1,5 @@ -import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client'; import React from 'react'; +import { SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client'; export function SchemaComponentContextProvider({ designable, children }) { const schemaComponentContext = useSchemaComponentContext(); diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ActionBar.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ActionBar.tsx index 5059d846a..a7a1a8632 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ActionBar.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ActionBar.tsx @@ -1,7 +1,8 @@ import { useCurrentUserContext } from '@tachybase/client'; -import { useContextApprovalExecution } from '../common/ApprovalExecution.provider'; -import { useApproval } from '../../approval-common/ApprovalData.provider'; + import { APPROVAL_STATUS } from '../../../constants'; +import { useApproval } from '../../approval-common/ApprovalData.provider'; +import { useContextApprovalExecution } from '../common/ApprovalExecution.provider'; export function ActionBarProvider(props) { const { data } = useCurrentUserContext(); diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ApplyActionStatus.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ApplyActionStatus.tsx index d5484d1c0..3af3ad065 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ApplyActionStatus.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.ApplyActionStatus.tsx @@ -1,9 +1,9 @@ -import React, { useContext } from 'react'; +import React, { createContext, useContext } from 'react'; import { useCurrentUserContext } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; -import { createContext } from 'react'; -import { useApproval } from '../../approval-common/ApprovalData.provider'; + import { APPROVAL_STATUS } from '../../../constants'; +import { useApproval } from '../../approval-common/ApprovalData.provider'; const ContextApprovalStatus = createContext(APPROVAL_STATUS.SUBMITTED); diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.WithdrawAction.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.WithdrawAction.tsx index 567bb94d9..177367916 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.WithdrawAction.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/Pd.WithdrawAction.tsx @@ -1,5 +1,6 @@ import { useCurrentUserContext } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; + import { APPROVAL_STATUS } from '../../../constants'; import { useApproval } from '../../approval-common/ApprovalData.provider'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/VC.ViewActionLaunchContent.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/VC.ViewActionLaunchContent.tsx index 1357c9449..990fe8c6d 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/VC.ViewActionLaunchContent.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/VC.ViewActionLaunchContent.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useContext } from 'react'; import { RemoteSchemaComponent, SchemaComponent, @@ -9,22 +9,23 @@ import { } from '@tachybase/client'; import { DetailsBlockProvider, FlowContext } from '@tachybase/plugin-workflow/client'; import { useForm } from '@tachybase/schema'; + import { Result, Spin } from 'antd'; -import { useContext } from 'react'; -import { NAMESPACE } from '../../../locale'; + import { FormBlockProvider } from '../../../common/Pd.FormBlock'; -import { ContextApprovalExecution } from '../common/ApprovalExecution.provider'; +import { NAMESPACE } from '../../../locale'; import { ApprovalContext } from '../../approval-common/ApprovalData.provider'; import { ContextWithActionEnabled } from '../../approval-common/WithActionEnabled.provider'; +import { ContextApprovalExecution } from '../common/ApprovalExecution.provider'; +import { FlowContextProvider } from '../common/FlowContext.provider'; +import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider'; +import { useDestroyAction } from './hooks/useDestroyAction'; import { useFormBlockProps } from './hooks/useFormBlockProps'; import { useSubmit } from './hooks/useSubmit'; import { useWithdrawAction } from './hooks/useWithdrawAction'; -import { useDestroyAction } from './hooks/useDestroyAction'; import { ActionBarProvider } from './Pd.ActionBar'; -import { WithdrawActionProvider } from './Pd.WithdrawAction'; -import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider'; import { ApplyActionStatusProvider } from './Pd.ApplyActionStatus'; -import { FlowContextProvider } from '../common/FlowContext.provider'; +import { WithdrawActionProvider } from './Pd.WithdrawAction'; export const ViewActionLaunchContent = () => { const { id } = useRecord(); diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useDestroyAction.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useDestroyAction.tsx index 4e3f18f15..19db297bc 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useDestroyAction.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useDestroyAction.tsx @@ -1,8 +1,10 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField } from '@tachybase/schema'; -import { useApproval } from '../../../approval-common/ApprovalData.provider'; + import _ from 'lodash'; +import { useApproval } from '../../../approval-common/ApprovalData.provider'; + export function useDestroyAction() { const field = useField(); const { setVisible, setSubmitted } = useActionContext() as any; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useFormBlockProps.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useFormBlockProps.tsx index b63043a00..56c648d1f 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useFormBlockProps.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useFormBlockProps.tsx @@ -1,10 +1,11 @@ +import { useEffect } from 'react'; import { useCurrentUserContext } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; import { useForm } from '@tachybase/schema'; -import { useEffect } from 'react'; -import { useContextApprovalExecution } from '../../common/ApprovalExecution.provider'; -import { useApproval } from '../../../approval-common/ApprovalData.provider'; + import { ApprovalStatusEnumDict } from '../../../../constants'; +import { useApproval } from '../../../approval-common/ApprovalData.provider'; +import { useContextApprovalExecution } from '../../common/ApprovalExecution.provider'; export function useFormBlockProps() { const approval = useApproval() as any; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useSubmit.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useSubmit.tsx index 7dd56326d..23532c7db 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useSubmit.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useSubmit.tsx @@ -1,7 +1,9 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useFlowContext } from '@tachybase/plugin-workflow/client'; import { useField, useForm } from '@tachybase/schema'; + import _ from 'lodash'; + import { useApproval } from '../../../approval-common/ApprovalData.provider'; import { useContextApprovalStatus } from '../Pd.ApplyActionStatus'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useWithdrawAction.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useWithdrawAction.tsx index a2ac7895e..daeafd189 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useWithdrawAction.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/launch/hooks/useWithdrawAction.tsx @@ -1,5 +1,6 @@ -import { useAPIClient, useActionContext } from '@tachybase/client'; +import { useActionContext, useAPIClient } from '@tachybase/client'; import { useField } from '@tachybase/schema'; + import { useApproval } from '../../../approval-common/ApprovalData.provider'; // 撤回 diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/Pd.ApprovalExecutions.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/Pd.ApprovalExecutions.tsx index 9b0d53150..d775e3d86 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/Pd.ApprovalExecutions.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/Pd.ApprovalExecutions.tsx @@ -1,4 +1,5 @@ import { createContext, useContext } from 'react'; + export interface Approval { id: number; collectionName: string; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/VC.ViewActionTodosContent.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/VC.ViewActionTodosContent.tsx index 8f7cdf4e4..a1425df1c 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/VC.ViewActionTodosContent.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-block/todos/VC.ViewActionTodosContent.tsx @@ -1,3 +1,4 @@ +import React, { useContext } from 'react'; import { RemoteSchemaComponent, SchemaComponent, @@ -7,9 +8,10 @@ import { useRequest, } from '@tachybase/client'; import { DetailsBlockProvider, ExecutionContextProvider } from '@tachybase/plugin-workflow/client'; + import { Result, Spin } from 'antd'; import _ from 'lodash'; -import React, { useContext } from 'react'; + import { FormBlockProvider } from '../../../common/Pd.FormBlock'; import { NAMESPACE, useTranslation } from '../../../locale'; import { ApprovalContext } from '../../approval-common/ApprovalData.provider'; @@ -17,12 +19,12 @@ import { ContextWithActionEnabled } from '../../approval-common/WithActionEnable import { ContextApprovalExecution } from '../common/ApprovalExecution.provider'; import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider'; import { ApprovalFormBlockDecorator } from './Dt.ApprovalFormBlock'; -import { ActionBarProvider } from './Pd.ActionBarProvider'; -import { ApprovalActionProvider } from './Pd.ApprovalAction'; -import { ContextApprovalExecutions } from './Pd.ApprovalExecutions'; import { useApprovalDetailBlockProps } from './hooks/useApprovalDetailBlockProps'; import { useApprovalFormBlockProps } from './hooks/useApprovalFormBlockProps'; import { useSubmit } from './hooks/useSubmit'; +import { ActionBarProvider } from './Pd.ActionBarProvider'; +import { ApprovalActionProvider } from './Pd.ApprovalAction'; +import { ContextApprovalExecutions } from './Pd.ApprovalExecutions'; // 审批-待办-查看: 内容 export const ViewActionTodosContent = () => { diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalData.provider.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalData.provider.tsx index 7f9245202..f01fda89b 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalData.provider.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalData.provider.tsx @@ -1,5 +1,6 @@ -import { useRecord } from '@tachybase/client'; import React, { createContext, useContext } from 'react'; +import { useRecord } from '@tachybase/client'; + import { Approval } from '../approval-block/todos/Pd.ApprovalExecutions'; export const ApprovalContext = createContext>({}); diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalProcess.view.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalProcess.view.tsx index 2f1d76b82..3f70858ce 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalProcess.view.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/ApprovalProcess.view.tsx @@ -1,13 +1,15 @@ +import React, { useMemo } from 'react'; import { createStyles, useCurrentUserContext } from '@tachybase/client'; import { EXECUTION_STATUS } from '@tachybase/plugin-workflow/client'; + import { Space, Table } from 'antd'; import _ from 'lodash'; -import React, { useMemo } from 'react'; + import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from '../../constants'; import { lang, usePluginTranslation } from '../../locale'; import { useApproval } from './ApprovalData.provider'; -import { ContextWithActionEnabled } from './WithActionEnabled.provider'; import { getAntdTableColumns } from './process-columns/columns'; +import { ContextWithActionEnabled } from './WithActionEnabled.provider'; // 审批(发起/待办)区块-查看-审批处理 export const ApprovalProcess = (props) => { diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/process-columns/render.detail.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/process-columns/render.detail.tsx index 3574e7875..25c0c8105 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/process-columns/render.detail.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-common/process-columns/render.detail.tsx @@ -1,8 +1,9 @@ -import { DatePicker, InputReadPretty, RecordProvider, useCurrentUserContext } from '@tachybase/client'; import React, { useContext } from 'react'; -import { ContextWithActionEnabled } from '../WithActionEnabled.provider'; +import { DatePicker, InputReadPretty, RecordProvider, useCurrentUserContext } from '@tachybase/client'; + import { ViewActionLaunch } from '../../approval-block/launch/VC.ViewActionLaunch'; import { ViewActionTodos } from '../../approval-block/todos/VC.ViewActionTodos'; +import { ContextWithActionEnabled } from '../WithActionEnabled.provider'; // Component开头的是,不知道起什么名字合适的 export function renderColumnDetail(e, props, exist) { diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.decorator.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.decorator.tsx index b10675366..5aa6ed50a 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.decorator.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.decorator.tsx @@ -1,14 +1,15 @@ +import React, { useMemo } from 'react'; import { CollectionProvider_deprecated, ExtendCollectionsProvider, - List, joinCollectionName, + List, useCollection_deprecated, useRecord, } from '@tachybase/client'; -import React, { useMemo } from 'react'; -import { CollectionApprovals } from '../approval-common/Approvals.collection'; + import { CollectionApprovalTodos } from '../../common/Cn.ApprovalTodos'; +import { CollectionApprovals } from '../approval-common/Approvals.collection'; import { CollectionFlowNodes } from '../approval-common/FlowNodes.collection'; import { CollectionWorkflows } from '../approval-common/Workflows.collection'; diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.initializer.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.initializer.tsx index 39ad1ee7f..2d5283ea7 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.initializer.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.initializer.tsx @@ -1,7 +1,8 @@ -import { AuditOutlined } from '@ant-design/icons'; +import React from 'react'; import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; import { uid } from '@tachybase/utils/client'; -import React from 'react'; + +import { AuditOutlined } from '@ant-design/icons'; // 初始化器,创建区块-相关审批 export function RecordApprovalsInitializer() { diff --git a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.view.tsx b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.view.tsx index a4e1ae1bf..363290ae4 100644 --- a/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.view.tsx +++ b/packages/plugins/@hera/plugin-approval/src/client/usage/approval-record-block/RecordApprovals.view.tsx @@ -1,5 +1,6 @@ -import { SchemaComponent } from '@tachybase/client'; import React from 'react'; +import { SchemaComponent } from '@tachybase/client'; + import { ApprovalRecordStatusColumn } from '../approval-common/approval-columns/column.status'; import { UserColumn } from '../approval-common/approval-columns/column.user'; import { WorkflowColumn } from '../approval-common/approval-columns/column.workflow'; diff --git a/packages/plugins/@hera/plugin-core/src/client/components/PDFViewer.tsx b/packages/plugins/@hera/plugin-core/src/client/components/PDFViewer.tsx index 99bd43bbe..5a80b0aa0 100644 --- a/packages/plugins/@hera/plugin-core/src/client/components/PDFViewer.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/components/PDFViewer.tsx @@ -1,14 +1,19 @@ import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; -import { Spin, Tag } from 'antd'; + import { LoadingOutlined } from '@ant-design/icons'; -import { Document, Page, pdfjs } from 'react-pdf'; +import { Spin, Tag } from 'antd'; import { saveAs } from 'file-saver'; +import { Document, Page, pdfjs } from 'react-pdf'; + import 'react-pdf/dist/Page/AnnotationLayer.css'; import 'react-pdf/dist/Page/TextLayer.css'; -import { uid } from '@tachybase/schema'; + import { css, useRequest } from '@tachybase/client'; +import { uid } from '@tachybase/schema'; + +import { TransformComponent, TransformWrapper } from 'react-zoom-pan-pinch'; + import { useTranslation } from '../locale'; -import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch'; const options = { cMapUrl: '/cmaps/', diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/CHANGELOG.md b/packages/plugins/@hera/plugin-core/src/client/features/departments/CHANGELOG.md new file mode 100644 index 000000000..64016399b --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/CHANGELOG.md @@ -0,0 +1,10 @@ +// 1. 拆解 refined 文件, 根据归类原则 +// 2. 反编译文件 +// 3. 根据功能进行归类, 根据就近原则 + +## 1. 拆解 refined 文件, 根据归类原则 +// 完成 +## 2. 反编译文件 +// 正在进行中 +// 备份代码, 可查看标签 backup-dev-20240527-departments +## 3. 根据功能进行归类, 根据就近原则 diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/collections/departments.collection.ts b/packages/plugins/@hera/plugin-core/src/client/features/departments/collections/departments.collection.ts new file mode 100644 index 000000000..702d49e6d --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/collections/departments.collection.ts @@ -0,0 +1,91 @@ +// 数据表-部门 +export const collectionDepartments = { + name: 'departments', + fields: [ + { + interface: 'id', + type: 'bigInt', + name: 'id', + primaryKey: true, + autoIncrement: true, + uiSchema: { + type: 'id', + title: '{{t("ID")}}', + }, + }, + { + interface: 'input', + type: 'string', + name: 'title', + uiSchema: { + type: 'string', + title: '{{t("Department name")}}', + 'x-component': 'Input', + required: true, + }, + }, + { + interface: 'm2o', + type: 'belongsTo', + name: 'parent', + collectionName: 'departments', + foreignKey: 'parentId', + target: 'departments', + targetKey: 'id', + treeParent: true, + uiSchema: { + title: '{{t("Superior department")}}', + 'x-component': 'DepartmentSelect', + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'roles', + target: 'roles', + collectionName: 'departments', + through: 'departmentsRoles', + foreignKey: 'departmentId', + otherKey: 'roleName', + targetKey: 'name', + sourceKey: 'id', + uiSchema: { + title: '{{t("Roles")}}', + 'x-component': 'AssociationField', + 'x-component-props': { + multiple: true, + fieldNames: { + label: 'title', + value: 'name', + }, + }, + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'owners', + collectionName: 'departments', + target: 'users', + through: 'departmentsUsers', + foreignKey: 'departmentId', + otherKey: 'userId', + targetKey: 'id', + sourceKey: 'id', + scope: { + isOwner: true, + }, + uiSchema: { + title: '{{t("Owners")}}', + 'x-component': 'AssociationField', + 'x-component-props': { + multiple: true, + fieldNames: { + label: 'nickname', + value: 'id', + }, + }, + }, + }, + ], +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/collections/users.collection.ts b/packages/plugins/@hera/plugin-core/src/client/features/departments/collections/users.collection.ts new file mode 100644 index 000000000..2b9760591 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/collections/users.collection.ts @@ -0,0 +1,132 @@ +// 数据表-用户 +export const collectionUsers = { + name: 'users', + fields: [ + { + interface: 'id', + type: 'bigInt', + name: 'id', + primaryKey: true, + autoIncrement: true, + allowNull: false, + uiSchema: { + type: 'number', + title: '{{t("ID")}}', + 'x-component': 'InputNumber', + 'x-read-pretty': true, + }, + }, + { + interface: 'input', + type: 'string', + name: 'nickname', + uiSchema: { + type: 'string', + title: '{{t("Nickname")}}', + 'x-component': 'Input', + }, + }, + { + interface: 'input', + type: 'string', + name: 'username', + unique: true, + uiSchema: { + type: 'string', + title: '{{t("Username")}}', + 'x-component': 'Input', + 'x-validator': { + username: true, + }, + required: true, + }, + }, + { + interface: 'email', + type: 'string', + name: 'email', + unique: true, + uiSchema: { + type: 'string', + title: '{{t("Email")}}', + 'x-component': 'Input', + 'x-validator': 'email', + required: true, + }, + }, + { + interface: 'phone', + type: 'string', + name: 'phone', + unique: true, + uiSchema: { + type: 'string', + title: '{{t("Phone")}}', + 'x-component': 'Input', + 'x-validator': 'phone', + required: true, + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'roles', + target: 'roles', + foreignKey: 'userId', + otherKey: 'roleName', + onDelete: 'CASCADE', + sourceKey: 'id', + targetKey: 'name', + through: 'rolesUsers', + uiSchema: { + type: 'array', + title: '{{t("Roles")}}', + 'x-component': 'AssociationField', + 'x-component-props': { + multiple: true, + fieldNames: { + label: 'title', + value: 'name', + }, + }, + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'departments', + target: 'departments', + foreignKey: 'userId', + otherKey: 'departmentId', + onDelete: 'CASCADE', + sourceKey: 'id', + targetKey: 'id', + through: 'departmentsUsers', + uiSchema: { + type: 'array', + title: '{{t("Departments")}}', + 'x-component': 'DepartmentField', + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'mainDepartment', + target: 'departments', + foreignKey: 'userId', + otherKey: 'departmentId', + onDelete: 'CASCADE', + sourceKey: 'id', + targetKey: 'id', + through: 'departmentsUsers', + throughScope: { + isMain: true, + }, + uiSchema: { + type: 'array', + title: '{{t("Main department")}}', + 'x-component': 'DepartmentField', + }, + }, + ], +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/AddMembersNnt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/AddMembersNnt.tsx new file mode 100644 index 000000000..11bcc3c0c --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/AddMembersNnt.tsx @@ -0,0 +1,59 @@ +import { SchemaComponent, useAPIClient, useResourceActionContext } from '@tachybase/client'; +import { useContext, useRef } from 'react'; +import { contextK } from '../context/contextK'; +import { k } from '../others/k'; +import { schemaAddMembers } from '../schema/addMembers.schema'; +import React from 'react'; + +export const AddMembersNnt = () => { + const { department, useAddMembersAction, handleSelect } = useAction(); + return ( + + ); +}; + +function useAction() { + const { department } = useContext(contextK); + const { refresh } = useResourceActionContext(); + const ref = useRef([]); + const api = useAPIClient(); + const useAddMembersAction = () => ({ + run() { + return k(this, null, function* () { + const x = ref.current; + + x != null && + x.length && + (yield api.resource('departments.members', department.id).add({ values: x }), (ref.current = []), refresh()); + }); + }, + }); + + const useAddMembersAction2 = () => ({ + async run() { + const x = ref.current; + if (x?.length > 0) { + await api.resource('departments.members', department.id).add({ values: x }); + ref.current = []; + refresh(); + } + }, + }); + + const handleSelect = (val) => { + ref.current = val; + }; + + return { + department, + useAddMembersAction, + handleSelect, + }; +} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/CeComponent.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/CeComponent.tsx new file mode 100644 index 000000000..4579a1e0f --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/CeComponent.tsx @@ -0,0 +1,16 @@ +import { CollectionProvider_deprecated, ResourceActionContext } from '@tachybase/client'; +import React from 'react'; +import { collectionDepartments } from '../collections/departments.collection'; +import { useContextK } from '../context/contextK'; + +export const CeComponent = ({ children }) => { + const context = useContextK(); + const { departmentsResource } = context; + const { service } = departmentsResource || {}; + + return ( + + {children} + + ); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentBe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentBe.tsx new file mode 100644 index 000000000..b77f6023b --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentBe.tsx @@ -0,0 +1,21 @@ +import { CollectionProvider_deprecated, ResourceActionContext } from '@tachybase/client'; +import React, { useContext } from 'react'; +// import { jsx } from 'react/jsx-runtime'; +import { collectionUsers } from '../collections/users.collection'; +import { contextK } from '../context/contextK'; + +export const BeComponent = ({ children }) => { + const { usersResource } = useContext(contextK); + const { service } = usersResource || {}; + + return ( + + {children} + + ); + + // return jsx(ResourceActionContext.Provider, { + // value: { ...o }, + // children: jsx(CollectionProvider_deprecated, { collection: collectionUsers, children: e.children }), + // }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentEEE.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentEEE.tsx new file mode 100644 index 000000000..4fa633850 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentEEE.tsx @@ -0,0 +1,124 @@ +import { UserOutlined } from '@ant-design/icons'; +import { ActionContextProvider, RecordProvider, SchemaComponent, SchemaComponentOptions } from '@tachybase/client'; +import { Button, Divider, Row, theme } from 'antd'; +import React, { useContext, useState } from 'react'; +import { useTranslation } from '../../../locale'; +import { contextK } from '../context/contextK'; +import { ContextNProvider } from '../context/contextN'; +import { useCreateDepartment } from '../hooks/useCreateDepartment'; +import { useHooksG } from '../hooks/useHooksG'; +import { useUpdateDepartmentLe } from '../hooks/useUpdateDepartmentLe'; +import { ComponentSe } from './ComponentSe'; +import { ComponentX } from './ComponentX'; +import { ComponentXxe } from './ComponentXxe'; +import { DepartmentOwnersField } from './DepartmentOwnersField'; + +interface drawerState { + node?: object; + schema?: object; +} + +export const ComponentEEE = () => { + const { t: tval } = useTranslation(); + + const [visible, setVisible] = useState(false); + const [drawer, setDrawer] = useState({}); + + const { department, setDepartment } = useContext(contextK); + const { token } = theme.useToken(); + const m = useHooksG({ + label: ({ node }) => , + }); + + return ( + + + + + + + + + + + + + + + + + ); + + // return jsx(SchemaComponentOptions, { + // scope: { + // useCreateDepartment: useCreateDepartment, + // useUpdateDepartment: useUpdateDepartmentLe, + // }, + // children: jsxs(contextN.Provider, { + // value: m, + // children: [ + // jsxs(Row, { + // children: [ + // jsx(ComponentSe, {}), + // jsx(Button, { + // type: 'text', + // icon: jsx(UserOutlined, {}), + // style: { textAlign: 'left', marginBottom: '5px', background: c ? '' : x.colorBgTextHover }, + // onClick: () => { + // i(null); + // }, + // block: true, + // children: e('All users'), + // }), + // jsx(ComponentXxe, {}), + // ], + // }), + // jsx(Divider, { style: { margin: '12px 0' } }), + // jsx(ComponentX, {}), + // jsx(ActionContextProvider, { + // value: { visible: t, setVisible: o }, + // children: jsx(RecordProvider, { + // record: a.node || {}, + // children: jsx(SchemaComponent, { + // scope: { t: e }, + // components: { DepartmentOwnersField: DepartmentOwnersField }, + // schema: a.schema || {}, + // }), + // }), + // }), + // ], + // }), + // }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentIit.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentIit.tsx new file mode 100644 index 000000000..85640dee8 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentIit.tsx @@ -0,0 +1,95 @@ +import { SchemaComponent, useResourceActionContext } from '@tachybase/client'; +import { useContext, useEffect, useMemo, Fragment } from 'react'; +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; +import { contextK } from '../context/contextK'; +import { useFilterActionPropsZ } from '../scopes/useFilterActionPropsZ'; +import { DepartmentFieldYe } from './DepartmentFieldYe'; +import { IsOwnerFieldQe } from './IsOwnerFieldQe'; +import { UserDepartmentsFieldOot } from './UserDepartmentsFieldOot'; +import { AddMembersNnt } from './AddMembersNnt'; +import { useShowTotal } from '../hooks/useShowTotal'; +import { useMembersDataSource } from '../hooks/useMembersDataSource'; +import { useBulkRemoveMembersAction } from '../hooks/useBulkRemoveMembersAction'; +import { useRemoveMemberAction } from '../hooks/useRemoveMemberAction'; +import { getSchemaHe } from '../schema/getSchemaHe'; +import { schemaZe } from '../schema/schemaZe'; +import { schemaWe } from '../schema/schemaWe'; +import React from 'react'; + +export const ComponentIit = () => { + const { t: tval } = useTranslation(); + const { department, user } = useContext(contextK); + const { data, setState } = useResourceActionContext(); + + const MemberActions = () => (department ? : null); + const RowRemoveAction = () => + department ? ( + + ) : null; + + const schema = useMemo(() => getSchemaHe(department, user), [department, user]); + + useEffect(() => { + setState?.({ + selectedRowKeys: [], + }); + }, [data, setState]); + + return ( + <> +

{user ? tval('Search results') : tval(department?.title ?? 'All users')}

+ + + ); + + // return jsxs(Fragment, { + // children: [ + // o + // ? jsx('h2', { children: e('Search results') }) + // : jsx('h2', { + // children: e((t == null ? void 0 : t.title) || 'All users'), + // }), + // jsx(SchemaComponent, { + // scope: { + // useBulkRemoveMembersAction: useBulkRemoveMembersAction, + // useMembersDataSource: useMembersDataSource, + // t: e, + // useShowTotal: useShowTotal, + // useFilterActionProps: useFilterActionPropsZ, + // }, + // components: { + // MemberActions: c, + // AddMembers: AddMembersNnt, + // RowRemoveAction: i, + // DepartmentField: DepartmentFieldYe, + // IsOwnerField: IsOwnerFieldQe, + // UserDepartmentsField: UserDepartmentsFieldOot, + // }, + // schema: x, + // }), + // ], + // }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentLle.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentLle.tsx new file mode 100644 index 000000000..2b8435d76 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentLle.tsx @@ -0,0 +1,112 @@ +import { useField } from '@tachybase/schema'; +import { TreeSelect } from 'antd'; +import React, { useEffect, useState } from 'react'; +// import { jsx } from 'react/jsx-runtime'; +import { k } from '../others/k'; +import { getDepartmentStr } from '../utils/getDepartmentStr'; + +interface tempField { + value?: any; + setValue: Function; +} + +interface IState { + label?: object; + value?: object; +} + +// 编辑部门-上级部门选择器 +export const ComponentLle = (props) => { + const field = useField(); + const [value, setValue] = useState({ label: null, value: null }); + const { + treeData: treeData, + initData: initData, + getByKeyword: getByKeyword, + loadData: loadData, + loadedKeys: loadedKeys, + setLoadedKeys: setLoadedKeys, + originData: originData, + } = props; + const onSearch = (h) => + k(this, null, function* () { + if (!h) { + initData(originData); + return; + } + yield getByKeyword(h); + }); + // const b = useCallback((h) => { + // const F = h.title, + // C = h.parent; + // return C ? b(C) + ' / ' + F : F; + // }, []); + + useEffect(() => { + initData(originData); + }, [originData, initData]); + useEffect(() => { + if (!field.value) { + setValue({ label: null, value: null }); + return; + } + setValue({ + label: getDepartmentStr(field.value) || field.value.label, + value: field.value.id, + }); + }, [field.value, getDepartmentStr]); + + // return null; + return ( + { + field.setValue(currValue); + }} + onChange={(h) => { + h || field.setValue(null); + }} + treeData={treeData} + treeLoadedKeys={loadedKeys} + onTreeLoad={(keys) => setLoadedKeys(keys)} + loadData={(value) => loadData({ key: value.id, children: value.children })} + fieldNames={{ value: 'id' }} + showSearch={true} + allowClear={true} + treeNodeFilterProp={'title'} + onSearch={onSearch} + labelInValue={true} + /> + ); + // return ( + // useEffect(() => { + // c(d); + // }, [d, c]), + // useEffect(() => { + // if (!t.value) { + // a({ label: null, value: null }); + // return; + // } + // a({ label: b(t.value) || t.value.label, value: t.value.id }); + // }, [t.value, b]), + // jsx(TreeSelect, { + // value: o, + // onSelect: (h, F) => { + // t.setValue(F); + // }, + // onChange: (h) => { + // h || t.setValue(null); + // }, + // treeData: r, + // treeLoadedKeys: m, + // onTreeLoad: (h) => g(h), + // loadData: (h) => x({ key: h.id, children: h.children }), + // fieldNames: { value: 'id' }, + // showSearch: true, + // allowClear: true, + // treeNodeFilterProp: 'title', + // onSearch: A, + // labelInValue: true, + // }) + // ); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentSe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentSe.tsx new file mode 100644 index 000000000..636b02b2a --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentSe.tsx @@ -0,0 +1,148 @@ +import { createStyles, useAPIClient, useRequest } from '@tachybase/client'; +import { Button, Dropdown, Empty, Input, theme } from 'antd'; +import { useContext, useState } from 'react'; +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; +import { contextK } from '../context/contextK'; + +const createStyleAe = createStyles(({ css }) => ({ + searchDropdown: css` + .ant-dropdown-menu { + max-height: 500px; + overflow-y: scroll; + } + `, +})); + +export const ComponentSe = () => { + const { t: e } = useTranslation(); + const { token: t } = theme.useToken(); + const { setDepartment: setDepartment, setUser: setUser } = useContext(contextK); + const [r, c] = useState(false); + const [i, x] = useState(''); + const [m, g] = useState([]); + const [d, A] = useState([]); + const [b, h] = useState(true); + const [F, C] = useState(true); + const { styles } = createStyleAe(); + const l = 10; + const api = useAPIClient(); + const data = useRequest( + (M) => + api + .resource('departments') + .aggregateSearch(M) + .then((P) => { + var q; + return (q = P == null ? void 0 : P.data) == null ? void 0 : q.data; + }), + { + manual: true, + onSuccess: (M, P) => { + const { + values: { type: q }, + } = P[0] || {}; + M && + ((!q || q === 'user') && M.users.length < l && h(false), + (!q || q === 'department') && M.departments.length < l && C(false), + g((se) => [...se, ...M.users]), + A((se) => [...se, ...M.departments])); + }, + }, + ); + const { run: S } = data; + const O = (M) => { + x(M), g([]), A([]), h(true), C(true), M && (S({ values: { keyword: M, limit: l } }), c(true)); + }; + const $ = (M) => { + M.target.value || (setUser(null), x(''), c(false), data.mutate({}), g([]), A([])); + }; + const W = (M) => { + const P = M.title, + q = M.parent; + return q ? W(q) + ' / ' + P : P; + }; + const H = (M) => + jsx(Button, { + type: 'link', + style: { padding: '0 8px' }, + onClick: (P) => { + c(true), S({ values: { keyword: i, limit: l, ...M } }); + }, + children: e('Load more'), + }); + const J = () => { + const M = []; + return !m.length && !d.length + ? [ + { + key: '0', + label: jsx(Empty, { + description: e('No results'), + image: Empty.PRESENTED_IMAGE_SIMPLE, + }), + disabled: true, + }, + ] + : (m.length && + (M.push({ + key: '0', + type: 'group', + label: e('Users'), + children: m.map((P) => ({ + key: P.username, + label: jsxs('div', { + onClick: () => setUser(P), + children: [ + jsx('div', { children: P.nickname || P.username }), + jsx('div', { + style: { fontSize: t.fontSizeSM, color: t.colorTextDescription }, + children: `${P.username}${P.phone ? ' | ' + P.phone : ''}${P.email ? ' | ' + P.email : ''}`, + }), + ], + }), + })), + }), + b && + M.push({ + type: 'group', + key: '0-loadMore', + label: jsx(H, { type: 'user', last: m[m.length - 1].id }), + })), + d.length && + (M.push({ + key: '1', + type: 'group', + label: e('Departments'), + children: d.map((P) => ({ + key: P.id, + label: jsx('div', { onClick: () => setDepartment(P), children: W(P) }), + })), + }), + F && + M.push({ + type: 'group', + key: '1-loadMore', + label: jsx(H, { type: 'department', last: d[d.length - 1].id }), + })), + M); + }; + return jsx(Dropdown, { + menu: { items: J() }, + overlayClassName: styles.searchDropdown, + trigger: ['click'], + open: r, + onOpenChange: (M) => c(M), + children: jsx(Input.Search, { + allowClear: true, + onClick: () => { + i || c(false); + }, + onFocus: () => setDepartment(null), + onSearch: O, + onChange: $, + placeholder: e('Search for departments, users'), + style: { marginBottom: '20px' }, + }), + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentX.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentX.tsx new file mode 100644 index 000000000..500c35e47 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentX.tsx @@ -0,0 +1,161 @@ +import { MoreOutlined } from '@ant-design/icons'; +import { css, useAPIClient, useResourceActionContext } from '@tachybase/client'; +import { App, Dropdown, Empty, Tree } from 'antd'; +import { useContext, useEffect } from 'react'; +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; +import { contextK } from '../context/contextK'; +import { k } from '../others/k'; +import { schemaHhe } from '../schema/schemaHhe'; +import { schemaYye } from '../schema/schemaYye'; +import { contextN } from '../context/contextN'; + +export const ComponentX = () => { + const { data: e, loading: t } = useResourceActionContext(); + const { department, setDepartment, setUser } = useContext(contextK); + const { treeData, nodeMap, loadData, loadedKeys, setLoadedKeys, initData, expandedKeys, setExpandedKeys } = + useContext(contextN); + + const h = (v) => { + if (!v.length) return; + const l = nodeMap[v[0]]; + setDepartment(l); + setUser(null); + }; + const F = (v) => { + setExpandedKeys(v); + }; + const C = (v) => { + setLoadedKeys(v); + }; + useEffect(() => { + initData(e == null ? void 0 : e.data); + }, [e, initData, t]); + useEffect(() => { + if (!department) return; + const v = (u) => (u.parent ? [u.parent.id, ...v(u.parent)] : []), + l = v(department); + setExpandedKeys((u) => Array.from(new Set([...u, ...l]))); + }, [department, setExpandedKeys]); + + return jsx('div', { + className: css` + height: 57vh; + overflow: auto; + .ant-tree-node-content-wrapper { + overflow: hidden; + } + `, + children: + treeData != null && treeData.length + ? jsx(Tree.DirectoryTree, { + loadData: loadData, + treeData: treeData, + loadedKeys: loadedKeys, + onSelect: h, + selectedKeys: [department == null ? void 0 : department.id], + onExpand: F, + onLoad: C, + expandedKeys: expandedKeys, + expandAction: false, + showIcon: false, + fieldNames: { key: 'id' }, + }) + : jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }), + }); + // return ( + // useEffect(() => { + // initData(e == null ? void 0 : e.data); + // }, [e, initData, t]), + // useEffect(() => { + // if (!department) return; + // const v = (u) => (u.parent ? [u.parent.id, ...v(u.parent)] : []), + // l = v(department); + // setExpandedKeys((u) => Array.from(new Set([...u, ...l]))); + // }, [department, setExpandedKeys]), + // jsx('div', { + // className: css` + // height: 57vh; + // overflow: auto; + // .ant-tree-node-content-wrapper { + // overflow: hidden; + // } + // `, + // children: + // treeData != null && treeData.length + // ? jsx(Tree.DirectoryTree, { + // loadData: loadData, + // treeData: treeData, + // loadedKeys: loadedKeys, + // onSelect: h, + // selectedKeys: [department == null ? void 0 : department.id], + // onExpand: F, + // onLoad: C, + // expandedKeys: expandedKeys, + // expandAction: false, + // showIcon: false, + // fieldNames: { key: 'id' }, + // }) + // : jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }), + // }) + // ); +}; +ComponentX.Item = function ({ node: t, setVisible: o, setDrawer: a }) { + const { t: r } = useTranslation(), + { refreshAsync: c } = useResourceActionContext(), + { setLoadedKeys: i, expandedKeys: x, setExpandedKeys: m } = useContext(contextN), + { modal: g, message: d } = App.useApp(), + A = useAPIClient(), + b = () => { + g.confirm({ + title: r('Delete'), + content: r('Are you sure you want to delete it?'), + onOk: () => + k(this, null, function* () { + yield A.resource('departments').destroy({ filterByTk: t.id }), + d.success(r('Deleted successfully')), + m((v) => v.filter((l) => l !== t.id)); + const C = [...x]; + i([]), m([]), yield c(), m(C); + }), + }); + }, + h = (C) => { + a({ schema: C, node: t }), o(true); + }, + F = ({ key: C, domEvent: v }) => { + switch ((v.stopPropagation(), C)) { + case 'new-sub': + h(schemaYye); + break; + case 'edit': + h(schemaHhe); + break; + case 'delete': + b(); + } + }; + return jsxs('div', { + style: { display: 'flex', justifyContent: 'space-between', overflow: 'hidden' }, + children: [ + jsx('div', { + style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, + children: t.title, + }), + jsx(Dropdown, { + menu: { + items: [ + { label: r('New sub department'), key: 'new-sub' }, + { label: r('Edit department'), key: 'edit' }, + { label: r('Delete department'), key: 'delete' }, + ], + onClick: F, + }, + children: jsx('div', { + style: { marginLeft: '15px' }, + children: jsx(MoreOutlined, {}), + }), + }), + ], + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentXxe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentXxe.tsx new file mode 100644 index 000000000..4dd6d1af8 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ComponentXxe.tsx @@ -0,0 +1,59 @@ +import { SchemaComponent } from '@tachybase/client'; +import { jsx } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; + +export const ComponentXxe = () => { + const { t: e } = useTranslation(); + return jsx(SchemaComponent, { + scope: { t: e }, + schema: { + type: 'void', + properties: { + newDepartment: { + type: 'void', + title: e('New department'), + 'x-component': 'Action', + 'x-component-props': { type: 'text', icon: 'PlusOutlined', style: { width: '100%', textAlign: 'left' } }, + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + title: e('New department'), + properties: { + title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', required: true }, + parent: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.parent', + 'x-component-props': { component: 'DepartmentSelect' }, + }, + roles: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.roles', + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ContextR.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ContextR.tsx new file mode 100644 index 000000000..3082f2027 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/ContextR.tsx @@ -0,0 +1,3 @@ +import React from 'react'; + +export const ContextR = React.createContext({}); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentFieldYe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentFieldYe.tsx new file mode 100644 index 000000000..26f8e9ae3 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentFieldYe.tsx @@ -0,0 +1,72 @@ +import { EllipsisWithTooltip } from '@tachybase/client'; +import { useField } from '@tachybase/schema'; +import React, { useContext } from 'react'; +// import { jsx, jsxs } from 'react/jsx-runtime'; +import { contextK } from '../context/contextK'; +import { getDepartmentStr } from '../utils/getDepartmentStr'; + +export const DepartmentFieldYe = () => { + const { setDepartment } = useContext(contextK); + const field = useField<{ value: Array }>(); + const fieldValues = field.value || []; + + const department = fieldValues.reduce((acc, curr) => { + acc[curr.id] = curr; + return acc; + }, {}); + + return ( + + {fieldValues.map((currFieldValue, index) => ( + + { + event.preventDefault(); + setDepartment(department[currFieldValue.id]); + }} + > + {getDepartmentStr(currFieldValue)} + + {index !== fieldValues.length - 1 ? , : ''} + + ))} + + ); + + // const children2 = fieldValues.map((currFieldValue, index) => { + // return ( + // + // { + // x.preventDefault(), setDepartment(department[currFieldValue.id]); + // }} + // > + // {getDepartmentStr(currFieldValue)} + // + // {index !== fieldValues.length - 1 ? , : ''} + // + // ); + // }); + + // const children = fieldValues.map((currFieldValue, index) => + // jsxs( + // 'span', + // { + // children: [ + // jsx('a', { + // onClick: (x) => { + // x.preventDefault(), setDepartment(department[currFieldValue.id]); + // }, + // children: getDepartmentStr(currFieldValue), + // }), + // index !== fieldValues.length - 1 + // ? jsx('span', { style: { marginRight: 4, color: '#aaa' }, children: ',' }) + // : '', + // ], + // }, + // index, + // ), + // ); + + // return jsx(EllipsisWithTooltip, { ellipsis: true, children: children }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentManagement.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentManagement.tsx new file mode 100644 index 000000000..f20c04386 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentManagement.tsx @@ -0,0 +1,59 @@ +import { SchemaComponentOptions } from '@tachybase/client'; +import { Col, Row } from 'antd'; +// import { jsx, jsxs } from 'react/jsx-runtime'; +import React from 'react'; +import { useFilterActionPropsZ } from '../scopes/useFilterActionPropsZ'; +import { CeComponent } from './CeComponent'; +import { BeComponent } from './ComponentBe'; +import { ComponentEEE } from './ComponentEEE'; +import { ComponentIit } from './ComponentIit'; +import { DepartmentSelect } from './DepartmentSelect'; +import { SuperiorDepartmentSelect } from './SuperiorDepartmentSelect'; + +export const DepartmentManagement = () => { + return ( + + + + + + + + + + + + + + + ); + // return jsx(SchemaComponentOptions, { + // components: { + // SuperiorDepartmentSelect: SuperiorDepartmentSelect, + // DepartmentSelect: DepartmentSelect, + // }, + // scope: { + // useFilterActionProps: useFilterActionPropsZ, + // }, + + // children: jsxs(Row, { + // gutter: 48, + // style: { flexWrap: 'nowrap' }, + // children: [ + // jsx(Col, { + // span: 6, + // style: { borderRight: '1px solid #eee', minWidth: '300px' }, + // children: jsx(CeComponent, { children: jsx(ComponentEEE, {}) }), + // }), + // jsx(Col, { + // flex: 'auto', + // style: { overflow: 'hidden' }, + // children: jsx(BeComponent, { children: jsx(ComponentIit, {}) }), + // }), + // ], + // }), + // }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentOwnersField.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentOwnersField.tsx new file mode 100644 index 000000000..7129b47b3 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentOwnersField.tsx @@ -0,0 +1,71 @@ +import { + ResourceActionProvider, + SchemaComponent, + ActionContextProvider, + useActionContext, + useRecord, +} from '@tachybase/client'; +import { useField } from '@tachybase/schema'; +import { Select } from 'antd'; +import { useEffect, useRef, useState } from 'react'; +import { jsx, jsxs } from 'react/jsx-runtime'; +import { schemaFfe } from '../schema/schemaFfe'; + +export const DepartmentOwnersField = () => { + const [e, t] = useState(false), + o = useRecord(), + a = useField(), + [r, c] = useState([]), + i = useRef([]), + x = (d, A) => { + i.current = A; + }, + m = () => { + const { setVisible: d } = useActionContext(); + return { + run() { + const A = a.value || []; + a.setValue([...A, ...i.current]), (i.current = []), d(false); + }, + }; + }; + useEffect(() => { + a.value && c(a.value.map((d) => ({ value: d.id, label: d.nickname || d.username }))); + }, [a.value]); + const g = (d) => { + var A; + return jsx(ResourceActionProvider, { + collection: 'users', + request: { + resource: `departments/${o.id}/members`, + action: 'list', + params: { filter: (A = a.value) != null && A.length ? { id: { $notIn: a.value.map((b) => b.id) } } : {} }, + }, + children: d.children, + }); + }; + return jsxs(ActionContextProvider, { + value: { visible: e, setVisible: t }, + children: [ + jsx(Select, { + open: false, + onChange: (d) => { + if (!d) { + a.setValue([]); + return; + } + a.setValue(d.map(({ label: A, value: b }) => ({ id: b, nickname: A }))); + }, + mode: 'multiple', + value: r, + labelInValue: true, + onDropdownVisibleChange: (d) => t(d), + }), + jsx(SchemaComponent, { + schema: schemaFfe, + components: { RequestProvider: g }, + scope: { department: o, handleSelect: x, useSelectOwners: m }, + }), + ], + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentSelect.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentSelect.tsx new file mode 100644 index 000000000..2ca1a0672 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentSelect.tsx @@ -0,0 +1,16 @@ +import { useContext } from 'react'; +import { jsx } from 'react/jsx-runtime'; +import { T } from '../others/T'; +import { y } from '../others/y'; +import { contextK } from '../context/contextK'; +import { ComponentLle } from './ComponentLle'; +import { useHooksG } from '../hooks/useHooksG'; + +export const DepartmentSelect = () => { + const e = useHooksG(), + { departmentsResource: t } = useContext(contextK), + { + service: { data: o }, + } = t || {}; + return jsx(ComponentLle, T(y({}, e), { originData: o == null ? void 0 : o.data })); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentTablePpe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentTablePpe.tsx new file mode 100644 index 000000000..723e36947 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentTablePpe.tsx @@ -0,0 +1,52 @@ +import { SchemaComponent } from '@tachybase/client'; +import { uid } from '@tachybase/schema'; +import { jsx } from 'react/jsx-runtime'; +import { useFilterActionPropsXe } from '../scopes/useFilterActionPropsXe'; +import { InternalDepartmentTableRe } from './InternalDepartmentTableRe'; +import { RequestProviderEet } from './RequestProviderEet'; + +export const DepartmentTablePpe = ({ useDataSource: e, useDisabled: t }) => + jsx(SchemaComponent, { + scope: { + useDisabled: t, + useFilterActionProps: useFilterActionPropsXe, + }, + components: { + InternalDepartmentTable: InternalDepartmentTableRe, + RequestProvider: RequestProviderEet, + }, + schema: { + type: 'void', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'RequestProvider', + 'x-component-props': { useDataSource: e }, + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + filter: { + type: 'void', + title: '{{ t("Filter") }}', + default: { $and: [{ title: { $includes: '' } }] }, + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + }, + }, + departments: { + type: 'array', + 'x-component': 'InternalDepartmentTable', + 'x-component-props': { useDisabled: '{{ useDisabled }}' }, + }, + }, + }, + }, + }, + }); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentTitleHht.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentTitleHht.tsx new file mode 100644 index 000000000..9137be134 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/DepartmentTitleHht.tsx @@ -0,0 +1,13 @@ +import { useRecord } from '@tachybase/client'; +import { Fragment } from 'react'; +import { jsx } from 'react/jsx-runtime'; + +export const DepartmentTitleHht = () => { + const e = useRecord(), + t = (o) => { + const a = o.title, + r = o.parent; + return r ? t(r) + ' / ' + a : a; + }; + return jsx(Fragment, { children: t(e) }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/Departments.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/Departments.tsx new file mode 100644 index 000000000..3d562e957 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/Departments.tsx @@ -0,0 +1,58 @@ +import { useContext, useEffect, useMemo } from 'react'; +import { CollectionProvider_deprecated, ResourceActionContext, SchemaComponent, useRequest } from '@tachybase/client'; +import { RolesManagerContext } from '@tachybase/plugin-acl/client'; + +import { jsx } from 'react/jsx-runtime'; + +import { useTranslation } from '../../../locale'; +import { collectionDepartments } from '../collections/departments.collection'; +import { useAddDepartmentsGgt } from '../hooks/useAddDepartmentsGgt'; +import { useBulkRemoveDepartmentsYyt } from '../hooks/useBulkRemoveDepartmentsYyt'; +import { useDataSourceFt } from '../hooks/useDataSourceFt'; +import { useDisabledVvt } from '../hooks/useDisabledVvt'; +import { useRemoveDepartmentXxt } from '../hooks/useRemoveDepartmentXxt'; +import { y } from '../others/y'; +import { getSchemaDdt } from '../schema/getSchemaDdt'; +import { useFilterActionPropsZ } from '../scopes/useFilterActionPropsZ'; +import { DepartmentTablePpe } from './DepartmentTablePpe'; +import { DepartmentTitleHht } from './DepartmentTitleHht'; + +export const Departments = () => { + const { t: e } = useTranslation(), + { role: t } = useContext(RolesManagerContext), + o = useRequest( + { + resource: `roles/${t == null ? void 0 : t.name}/departments`, + action: 'list', + params: { appends: ['parent', 'parent.parent(recursively=true)'] }, + }, + { ready: !!t }, + ); + useEffect(() => { + o.run(); + }, [o, t]); + // eslint-disable-next-line react-hooks/exhaustive-deps + const a = useMemo(() => getSchemaDdt(), [t]); + return jsx(ResourceActionContext.Provider, { + value: y({}, o), + children: jsx(CollectionProvider_deprecated, { + collection: collectionDepartments, + children: jsx(SchemaComponent, { + schema: a, + components: { + DepartmentTable: DepartmentTablePpe, + DepartmentTitle: DepartmentTitleHht, + }, + scope: { + useFilterActionProps: useFilterActionPropsZ, + t: e, + useRemoveDepartment: useRemoveDepartmentXxt, + useBulkRemoveDepartments: useBulkRemoveDepartmentsYyt, + useDataSource: useDataSourceFt, + useDisabled: useDisabledVvt, + useAddDepartments: useAddDepartmentsGgt, + }, + }), + }), + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/GeComponent.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/GeComponent.tsx new file mode 100644 index 000000000..1ce6b0ae9 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/GeComponent.tsx @@ -0,0 +1,34 @@ +import { useRequest } from '@tachybase/client'; +import { useEffect, useState } from 'react'; +import { jsx } from 'react/jsx-runtime'; +import { contextK } from '../context/contextK'; + +export const GeComponent = (e) => { + const [t, o] = useState(null), + [a, r] = useState(null), + c = useRequest({ + resource: 'users', + action: 'list', + params: { + appends: ['departments', 'departments.parent(recursively=true)'], + filter: a ? { 'departments.id': a.id } : {}, + pageSize: 50, + }, + }); + useEffect(() => { + c.run(); + }, [a]); + const i = { resource: 'departments', action: 'list', params: { pagination: false, filter: { parentId: null } } }, + x = useRequest(i); + return jsx(contextK.Provider, { + value: { + user: t, + setUser: o, + department: a, + setDepartment: r, + usersResource: { service: c }, + departmentsResource: { service: x }, + }, + children: e.children, + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/InternalDepartmentTableRe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/InternalDepartmentTableRe.tsx new file mode 100644 index 000000000..44dda8332 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/InternalDepartmentTableRe.tsx @@ -0,0 +1,58 @@ +import { useResourceActionContext } from '@tachybase/client'; +import { useField } from '@tachybase/schema'; +import { Table } from 'antd'; +import { useContext, useEffect } from 'react'; +import { jsx } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; +import { T } from '../others/T'; +import { y } from '../others/y'; +import { useHooksG } from '../hooks/useHooksG'; +import { getDepartmentStr } from '../utils/getDepartmentStr'; +import { ContextR } from './ContextR'; + +const Ze = () => ({ disabled: () => false }); +export const InternalDepartmentTableRe = ({ useDisabled: e = Ze }) => { + const { t } = useTranslation(), + o = useResourceActionContext(); + console.log(o); + const { run: a, data: r, loading: c, defaultRequest: i } = o, + { resource: x, resourceOf: m, params: g } = i || {}, + { treeData: d, initData: A, loadData: b } = useHooksG({ resource: x, resourceOf: m, params: g }), + h = useField(), + { disabled: F } = e(), + { hasFilter: C, expandedKeys: v, setExpandedKeys: l } = useContext(ContextR); + useEffect(() => { + C || A(r == null ? void 0 : r.data); + }, [r, A, c, C]); + const u = {}; + if ((g != null && g.pageSize && (u.defaultPageSize = g.pageSize), !u.total && r != null && r.meta)) { + const { count: f, page: S, pageSize: O } = r.meta; + (u.total = f), (u.current = S), (u.pageSize = O); + } + return jsx(Table, { + rowKey: 'id', + columns: [{ dataIndex: 'title', title: t('Department name'), render: (f, S) => (C ? getDepartmentStr(S) : f) }], + rowSelection: { + selectedRowKeys: ((h == null ? void 0 : h.value) || []).map((f) => f.id), + onChange: (f, S) => { + var O; + return (O = h == null ? void 0 : h.setValue) == null ? void 0 : O.call(h, S); + }, + getCheckboxProps: (f) => ({ disabled: F(f) }), + }, + pagination: T(y({ showSizeChanger: true }, u), { + onChange(f, S) { + var O; + a(T(y({}, ((O = o == null ? void 0 : o.params) == null ? void 0 : O[0]) || {}), { page: f, pageSize: S })); + }, + }), + dataSource: C ? (r == null ? void 0 : r.data) || [] : d, + expandable: { + onExpand: (f, S) => { + b({ key: S.id, children: S.children }); + }, + expandedRowKeys: v, + onExpandedRowsChange: (f) => l(f), + }, + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/IsOwnerFieldQe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/IsOwnerFieldQe.tsx new file mode 100644 index 000000000..125cafce9 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/IsOwnerFieldQe.tsx @@ -0,0 +1,10 @@ +import { Checkbox, useRecord } from '@tachybase/client'; +import { useContext } from 'react'; +import { jsx } from 'react/jsx-runtime'; +import { contextK } from '../context/contextK'; + +export const IsOwnerFieldQe = () => { + const { department: e } = useContext(contextK), + o = (useRecord().departments || []).find((a) => (a == null ? void 0 : a.id) === (e == null ? void 0 : e.id)); + return jsx(Checkbox.ReadPretty, { value: o == null ? void 0 : o.departmentsUsers.isOwner }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/MmtComponent.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/MmtComponent.tsx new file mode 100644 index 000000000..23725f94b --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/MmtComponent.tsx @@ -0,0 +1,34 @@ +import { SchemaComponent } from '@tachybase/client'; +import { uid } from '@tachybase/schema'; +import React from 'react'; +import { DepartmentManagement } from './DepartmentManagement'; + +export const MmtComponent = () => { + return ( + + ); + + // return jsx(SchemaComponent, { + // components: { + // DepartmentManagement: DepartmentManagement, + // }, + // schema: { + // type: 'void', + // properties: { + // [uid()]: { type: 'void', 'x-decorator': 'CardItem', 'x-component': 'DepartmentManagement' }, + // }, + // }, + // }); +}; \ No newline at end of file diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/RequestProviderEet.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/RequestProviderEet.tsx new file mode 100644 index 000000000..7af6e15f1 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/RequestProviderEet.tsx @@ -0,0 +1,28 @@ +import { CollectionProvider_deprecated, ResourceActionContext } from '@tachybase/client'; +import { useEffect, useState } from 'react'; +import { jsx } from 'react/jsx-runtime'; +import { y } from '../others/y'; +import { collectionDepartments } from '../collections/departments.collection'; +import { ContextR } from './ContextR'; + +export const RequestProviderEet = (e) => { + const [t, o] = useState([]), + [a, r] = useState(false), + { useDataSource: c } = e, + i = c({ manual: true }); + return ( + useEffect(() => { + i.run({ filter: { parentId: null }, pageSize: 10 }); + }, []), + jsx(ResourceActionContext.Provider, { + value: y({}, i), + children: jsx(CollectionProvider_deprecated, { + collection: collectionDepartments, + children: jsx(ContextR.Provider, { + value: { expandedKeys: t, setExpandedKeys: o, hasFilter: a, setHasFilter: r }, + children: e.children, + }), + }), + }) + ); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/SuperiorDepartmentSelect.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/SuperiorDepartmentSelect.tsx new file mode 100644 index 000000000..ed5ea14c3 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/SuperiorDepartmentSelect.tsx @@ -0,0 +1,31 @@ +import { useRecord } from '@tachybase/client'; +import { useContext, useEffect } from 'react'; +import { jsx } from 'react/jsx-runtime'; +import { T } from '../others/T'; +import { y } from '../others/y'; +import { contextK } from '../context/contextK'; +import { ComponentLle } from './ComponentLle'; +import { useHooksG } from '../hooks/useHooksG'; + +export const SuperiorDepartmentSelect = () => { + const e = useHooksG(), + { setTreeData: t, getChildrenIds: o } = e, + a = useRecord(), + { departmentsResource: r } = useContext(contextK), + { + service: { data: c }, + } = r || {}; + return ( + useEffect(() => { + if (!a.id) return; + const i = o(a.id); + i.push(a.id), + t((x) => { + const m = (g) => + g.map((d) => (i.includes(d.id) && (d.disabled = true), d.children && (d.children = m(d.children)), d)); + return m(x); + }); + }, [t, a.id, o]), + jsx(ComponentLle, T(y({}, e), { originData: c == null ? void 0 : c.data })) + ); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/UserDepartmentsField.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/UserDepartmentsField.tsx new file mode 100644 index 000000000..6789535e0 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/UserDepartmentsField.tsx @@ -0,0 +1,25 @@ +import { AssociationField } from '@tachybase/client'; +import { connect, mapReadPretty } from '@tachybase/schema'; +// import { jsxs } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; +import React from 'react'; + +export const UserDepartmentsField = connect(() => { + const { t } = useTranslation(); + // return jsxs('div', { + // style: { + // color: '#ccc', + // }, + // children: [t('This field is currently not supported for use in form blocks.'), ' '], + // }); + + return ( +
+ {t('This field is currently not supported for use in form blocks.')} +
+ ); +}, mapReadPretty(AssociationField.ReadPretty)); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/components/UserDepartmentsFieldOot.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/UserDepartmentsFieldOot.tsx new file mode 100644 index 000000000..dda22a3f0 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/components/UserDepartmentsFieldOot.tsx @@ -0,0 +1,177 @@ +import { MoreOutlined, PlusOutlined } from '@ant-design/icons'; +import { + SchemaComponent, + ActionContextProvider, + useAPIClient, + useRecord, + useRequest, + useResourceActionContext, +} from '@tachybase/client'; +import { useField, useForm } from '@tachybase/schema'; +import { App, Button, Dropdown, Tag } from 'antd'; +import { useState, Fragment } from 'react'; +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useTranslation } from '../../../locale'; +import { T } from '../others/T'; +import { y } from '../others/y'; +import { k } from '../others/k'; +import { schemaJe } from '../schema/schemaJe'; +import { getDepartmentStr } from '../utils/getDepartmentStr'; +import { useDataSourceTtt } from '../hooks/useDataSourceTtt'; +import { DepartmentTablePpe } from './DepartmentTablePpe'; + +export const UserDepartmentsFieldOot = () => { + const { modal: e, message: t } = App.useApp(), + { t: o } = useTranslation(), + [a, r] = useState(false), + c = useRecord(), + i = useField(), + { refresh: x } = useResourceActionContext(), + m = (l) => + l != null && l.length + ? l.map((u) => { + var f, S; + return T(y({}, u), { + isMain: (f = u.departmentsUsers) == null ? void 0 : f.isMain, + isOwner: (S = u.departmentsUsers) == null ? void 0 : S.isOwner, + title: getDepartmentStr(u), + }); + }) + : [], + g = useAPIClient(); + useRequest( + () => + g + .resource('users.departments', c.id) + .list({ appends: ['parent(recursively=true)'], pagination: false }) + .then((l) => { + var f; + const u = m((f = l == null ? void 0 : l.data) == null ? void 0 : f.data); + i.setValue(u); + }), + { ready: c.id }, + ); + const d = () => { + const l = useAPIClient(), + u = useForm(), + { departments: f } = u.values || {}; + return { + run() { + return k(this, null, function* () { + yield l.resource('users.departments', c.id).add({ values: f.map((O) => O.id) }), + u.reset(), + i.setValue([ + ...i.value, + ...f.map((O, $) => + T(y({}, O), { isMain: $ === 0 && i.value.length === 0, title: getDepartmentStr(O) }), + ), + ]), + r(false), + x(); + }); + }, + }; + }, + A = (l) => { + e.confirm({ + title: o('Remove department'), + content: o('Are you sure you want to remove it?'), + onOk: () => + k(this, null, function* () { + yield g.resource('users.departments', c.id).remove({ values: [l.id] }), + t.success(o('Deleted successfully')), + i.setValue( + i.value + .filter((u) => u.id !== l.id) + .map((u, f) => T(y({}, u), { isMain: (l.isMain && f === 0) || u.isMain })), + ), + x(); + }), + }); + }, + b = (l) => + k(this, null, function* () { + yield g.resource('users').setMainDepartment({ values: { userId: c.id, departmentId: l.id } }), + t.success(o('Set successfully')), + i.setValue(i.value.map((u) => T(y({}, u), { isMain: u.id === l.id }))), + x(); + }), + h = (l) => + k(this, null, function* () { + yield g.resource('departments').setOwner({ values: { userId: c.id, departmentId: l.id } }), + t.success(o('Set successfully')), + i.setValue(i.value.map((u) => T(y({}, u), { isOwner: u.id === l.id ? true : u.isOwner }))), + x(); + }), + F = (l) => + k(this, null, function* () { + yield g.resource('departments').removeOwner({ values: { userId: c.id, departmentId: l.id } }), + t.success(o('Set successfully')), + i.setValue(i.value.map((u) => T(y({}, u), { isOwner: u.id === l.id ? false : u.isOwner }))), + x(); + }), + C = (l, u) => { + switch (l) { + case 'setMain': + b(u); + break; + case 'setOwner': + h(u); + break; + case 'removeOwner': + F(u); + break; + case 'remove': + A(u); + } + }, + v = () => ({ disabled: (l) => i.value.some((u) => u.id === l.id) }); + return jsxs(ActionContextProvider, { + value: { visible: a, setVisible: r }, + children: [ + jsxs(Fragment, { + children: [ + ((i == null ? void 0 : i.value) || []).map((l) => + jsxs( + Tag, + { + style: { padding: '5px 8px', background: 'transparent', marginBottom: '5px' }, + children: [ + jsx('span', { style: { marginRight: '5px' }, children: l.title }), + l.isMain ? jsx(Tag, { color: 'processing', bordered: false, children: o('Main') }) : '', + jsx(Dropdown, { + menu: { + items: [ + ...(l.isMain ? [] : [{ label: o('Set as main department'), key: 'setMain' }]), + { label: o('Remove'), key: 'remove' }, + ], + onClick: ({ key: u }) => C(u, l), + }, + children: jsx('div', { + style: { float: 'right' }, + children: jsx(MoreOutlined, {}), + }), + }), + ], + }, + l.id, + ), + ), + jsx(Button, { icon: jsx(PlusOutlined, {}), onClick: () => r(true) }), + ], + }), + jsx(SchemaComponent, { + schema: schemaJe, + components: { + DepartmentTable: DepartmentTablePpe, + }, + scope: { + user: c, + useDataSource: useDataSourceTtt, + useAddDepartments: d, + useDisabled: v, + }, + }), + ], + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/context/contextK.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/context/contextK.tsx new file mode 100644 index 000000000..61aab6522 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/context/contextK.tsx @@ -0,0 +1,32 @@ +import { Result } from 'ahooks/es/useRequest/src/types'; +import React, { useContext } from 'react'; + +interface departmentType { + id?: string | number; + [key: string]: unknown; +} + +interface contextType { + user: object; + setUser?: Function; + department: departmentType; + departmentsResource?: { + service?: Result; + }; + setDepartment?: Function; + usersResource?: { + service?: Result; + }; +} + +// XXX: 等待所有引用重置为以下两个函数后, 删除导出声明 +export const contextK = React.createContext({ + user: {}, + department: {}, +}); + +export const ContextKProvider = contextK.Provider; + +export function useContextK() { + return useContext(contextK); +} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/context/contextN.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/context/contextN.tsx new file mode 100644 index 000000000..220a3940b --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/context/contextN.tsx @@ -0,0 +1,9 @@ +import React, { useContext } from 'react'; + +export const contextN = React.createContext({}); + +export const ContextNProvider = contextN.Provider; + +export function useContextN() { + return useContext(contextN); +} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useAddDepartmentsGgt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useAddDepartmentsGgt.tsx new file mode 100644 index 000000000..0d69ad3ab --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useAddDepartmentsGgt.tsx @@ -0,0 +1,22 @@ +import { useContext } from 'react'; +import { useActionContext, useAPIClient, useResourceActionContext } from '@tachybase/client'; +import { RolesManagerContext } from '@tachybase/plugin-acl/client'; +import { useForm } from '@tachybase/schema'; + +import { k } from '../others/k'; + +export const useAddDepartmentsGgt = () => { + const { role: e } = useContext(RolesManagerContext), + t = useAPIClient(), + o = useForm(), + { setVisible: a } = useActionContext(), + { refresh: r } = useResourceActionContext(), + { departments: c } = o.values || {}; + return { + run() { + return k(this, null, function* () { + yield t.resource('roles.departments', e.name).add({ values: c.map((x) => x.id) }), o.reset(), a(false), r(); + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useBulkRemoveDepartmentsYyt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useBulkRemoveDepartmentsYyt.tsx new file mode 100644 index 000000000..86a162d83 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useBulkRemoveDepartmentsYyt.tsx @@ -0,0 +1,30 @@ +import { useContext } from 'react'; +import { useAPIClient, useResourceActionContext } from '@tachybase/client'; +import { RolesManagerContext } from '@tachybase/plugin-acl/client'; + +import { App } from 'antd'; + +import { useTranslation } from '../../../locale'; +import { k } from '../others/k'; + +export const useBulkRemoveDepartmentsYyt = () => { + const { t: e } = useTranslation(), + { message: t } = App.useApp(), + o = useAPIClient(), + { state: a, setState: r, refresh: c } = useResourceActionContext(), + { role: i } = useContext(RolesManagerContext); + return { + run() { + return k(this, null, function* () { + const m = a == null ? void 0 : a.selectedRowKeys; + if (!(m != null && m.length)) { + t.warning(e('Please select departments')); + return; + } + yield o.resource(`roles/${i == null ? void 0 : i.name}/departments`).remove({ values: m }), + r == null || r({ selectedRowKeys: [] }), + c(); + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useBulkRemoveMembersAction.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useBulkRemoveMembersAction.tsx new file mode 100644 index 000000000..1174ba0db --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useBulkRemoveMembersAction.tsx @@ -0,0 +1,28 @@ +import { useAPIClient, useResourceActionContext } from '@tachybase/client'; +import { App } from 'antd'; +import { useContext } from 'react'; +import { useTranslation } from '../../../locale'; +import { contextK } from '../context/contextK'; +import { k } from '../others/k'; + +export const useBulkRemoveMembersAction = () => { + const { t: e } = useTranslation(), + { message: t } = App.useApp(), + o = useAPIClient(), + { state: a, setState: r, refresh: c } = useResourceActionContext(), + { department: i } = useContext(contextK); + return { + run() { + return k(this, null, function* () { + const m = a == null ? void 0 : a.selectedRowKeys; + if (!(m != null && m.length)) { + t.warning(e('Please select members')); + return; + } + yield o.resource('departments.members', i.id).remove({ values: m }), + r == null || r({ selectedRowKeys: [] }), + c(); + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useCreateDepartment.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useCreateDepartment.tsx new file mode 100644 index 000000000..0bee6b8bd --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useCreateDepartment.tsx @@ -0,0 +1,33 @@ +import { useAPIClient, useActionContext, useResourceActionContext } from '@tachybase/client'; +import { useField, useForm } from '@tachybase/schema'; +import { useContext } from 'react'; +import { k } from '../others/k'; +import { contextN } from '../context/contextN'; + +export const useCreateDepartment = () => { + const e = useForm(), + t = useField(), + o = useActionContext(), + { refreshAsync: a } = useResourceActionContext(), + r = useAPIClient(), + { expandedKeys: c, setLoadedKeys: i, setExpandedKeys: x } = useContext(contextN); + return { + run() { + return k(this, null, function* () { + try { + yield e.submit(), + (t.data = t.data || {}), + (t.data.loading = true), + yield r.resource('departments').create({ values: e.values }), + o.setVisible(false), + yield e.reset(), + (t.data.loading = false); + const g = [...c]; + i([]), x([]), yield a(), x(g); + } catch (g) { + t.data && (t.data.loading = false); + } + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDataSourceFt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDataSourceFt.tsx new file mode 100644 index 000000000..4f27c03e0 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDataSourceFt.tsx @@ -0,0 +1,13 @@ +import { useRequest } from '@tachybase/client'; +import { T } from '../others/T'; +import { y } from '../others/y'; + +export const useDataSourceFt = (e) => { + const t = { + resource: 'departments', + action: 'list', + params: { appends: ['roles', 'parent(recursively=true)'], sort: ['createdAt'] }, + }, + o = useRequest(t, e); + return T(y({}, o), { defaultRequest: t }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDataSourceTtt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDataSourceTtt.tsx new file mode 100644 index 000000000..e249c401e --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDataSourceTtt.tsx @@ -0,0 +1,13 @@ +import { useRequest } from '@tachybase/client'; +import { T } from '../others/T'; +import { y } from '../others/y'; + +export const useDataSourceTtt = (e) => { + const t = { + resource: 'departments', + action: 'list', + params: { appends: ['parent(recursively=true)'], sort: ['createdAt'] }, + }, + o = useRequest(t, e); + return T(y({}, o), { defaultRequest: t }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDisabledVvt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDisabledVvt.tsx new file mode 100644 index 000000000..3e2aeb086 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useDisabledVvt.tsx @@ -0,0 +1,14 @@ +import { useContext } from 'react'; +import { RolesManagerContext } from '@tachybase/plugin-acl/client'; + +export const useDisabledVvt = () => { + const { role: e } = useContext(RolesManagerContext); + return { + disabled: (t) => { + let o; + return (o = t == null ? void 0 : t.roles) == null + ? void 0 + : o.some((a) => a.name === (e == null ? void 0 : e.name)); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksDe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksDe.tsx new file mode 100644 index 000000000..3c7d7bf3c --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksDe.tsx @@ -0,0 +1,98 @@ +import React, { useCallback, useState } from 'react'; +import { T } from '../others/T'; + +export const useHooksDe = (e) => { + const { label: t } = e || {}, + [o, a] = useState([]), + [r, c] = useState({}), + [i, x] = useState([]), + [m, g] = useState([]), + d = useCallback((C) => { + const v = {}, + l = (f) => { + let S = f ? { ...f } : null; + for (; S; ) { + const O = S.parentId || 'root'; + v[O] + ? (v[O].childrenMap[S.id] = S) + : (v[O] = T({ ...(S.parent || { id: O }) }, { childrenMap: { [S.id]: S } })), + (S = S.parent); + } + }, + u = (f) => { + const S = {}; + f.children && + f.children.length && + f.children.forEach((O) => { + (S[O.id] = O), u(O); + }), + (v[f.id] = T({ ...f }, { childrenMap: S })); + }; + return ( + C && + C.length && + C.forEach((f) => { + l(f), u(f); + }), + v + ); + }, []), + A = useCallback((C) => { + const v = (l) => { + var u; + return !C[l] || C[l].isLeaf + ? null + : Object.values(((u = C[l]) == null ? void 0 : u.childrenMap) || {}).map((f: object) => + T({ ...f }, { title: t ? React.createElement(t, { node: f }) : f.title, children: v(f.id) }), + ); + }; + return v('root'); + }, []), + b = useCallback( + (C) => { + const v = d(C); + c(v); + const l = A(v) || []; + a(l); + }, + [a, d, A], + ), + h = (C, v) => { + const l = d(v), + u = { ...l, ...r }; + return ( + v.forEach((f) => { + u[C].childrenMap[f.id] = f; + }), + c(u), + A(u) + ); + }, + F = useCallback( + (C) => { + if (!r[C]) return []; + const v = []; + return ( + v.push(...Object.keys(r[C].childrenMap).map((l) => Number(l))), + Object.keys(r[C].childrenMap).forEach((l) => { + v.push(...F(l)); + }), + v + ); + }, + [r], + ); + return { + initData: b, + treeData: o, + setTreeData: a, + nodeMap: r, + updateTreeData: h, + constructTreeData: A, + getChildrenIds: F, + loadedKeys: m, + setLoadedKeys: g, + expandedKeys: i, + setExpandedKeys: x, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksG.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksG.tsx new file mode 100644 index 000000000..bab6ab171 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksG.tsx @@ -0,0 +1,47 @@ +import { useAPIClient } from '@tachybase/client'; +import { T } from '../others/T'; +import { useHooksDe } from './useHooksDe'; +import { k } from '../others/k'; +import { B } from '../utils/B'; + +function we(e) { + return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, 'default') ? e.default : e; +} + +const je = B; +const Ue = je; + +const ie = we(Ue); + +export const useHooksG = (props) => { + const { resource: t = 'departments', resourceOf: o, params: a = {} } = props || {}, + c = useAPIClient().resource(t, o), + i = useHooksDe(props), + { setTreeData: x, updateTreeData: m, setLoadedKeys: g, initData: d } = i, + A = (C) => + k(this, [C], function* ({ key: h, children: F }) { + var l; + if (F != null && F.length) return; + const { data: v } = yield c.list( + ie(a, { pagination: false, appends: ['parent(recursively=true)'], filter: { parentId: h } }), + ); + (l = v == null ? void 0 : v.data) != null && l.length && x(m(h, v == null ? void 0 : v.data)); + }), + b = (h) => + k(this, null, function* () { + const { data: F } = yield c.list( + ie(a, { + pagination: false, + filter: { title: { $includes: h } }, + appends: ['parent(recursively=true)'], + pageSize: 100, + }), + ); + d(F == null ? void 0 : F.data); + }); + return T({ ...i }, { loadData: A, getByKeyword: b }); +}; + + + + diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksOoe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksOoe.tsx new file mode 100644 index 000000000..2bc63815d --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useHooksOoe.tsx @@ -0,0 +1,15 @@ +import { useCollectionManager_deprecated, useCompile, useCollection_deprecated } from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; + +const bt = (e) => e['x-component'] === 'CollectionField'; + +export const useHooksOoe = () => { + const { getField: e } = useCollection_deprecated(), + t = useCompile(), + o = useFieldSchema(), + { getCollectionJoinField: a } = useCollectionManager_deprecated(), + r = o.reduceProperties((i, x) => (bt(x) ? x : i), null); + if (!r) return {}; + const c = e(r.name) || a(r == null ? void 0 : r['x-collection-field']); + return { columnSchema: o, fieldSchema: r, collectionField: c, uiSchema: t(c == null ? void 0 : c.uiSchema) }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useMembersDataSource.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useMembersDataSource.tsx new file mode 100644 index 000000000..70a8173d4 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useMembersDataSource.tsx @@ -0,0 +1,18 @@ +import { useResourceActionContext } from '@tachybase/client'; +import { useContext, useEffect } from 'react'; +import { contextK } from '../context/contextK'; + +export const useMembersDataSource = (e) => { + const { user: t } = useContext(contextK), + o = useResourceActionContext(); + return ( + useEffect(() => { + if (t) { + e == null || e.onSuccess({ data: [t] }); + return; + } + o.loading || e == null || e.onSuccess(o.data); + }, [t, o.loading]), + o + ); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useRemoveDepartmentXxt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useRemoveDepartmentXxt.tsx new file mode 100644 index 000000000..ec1084340 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useRemoveDepartmentXxt.tsx @@ -0,0 +1,19 @@ +import { useContext } from 'react'; +import { useAPIClient, useRecord, useResourceActionContext } from '@tachybase/client'; +import { RolesManagerContext } from '@tachybase/plugin-acl/client'; + +import { k } from '../others/k'; + +export const useRemoveDepartmentXxt = () => { + const e = useAPIClient(), + { role: t } = useContext(RolesManagerContext), + { data: o } = useRecord(), + { refresh: a } = useResourceActionContext(); + return { + run() { + return k(this, null, function* () { + yield e.resource(`roles/${t == null ? void 0 : t.name}/departments`).remove({ values: [o.id] }), a(); + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useRemoveMemberAction.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useRemoveMemberAction.tsx new file mode 100644 index 000000000..4fa6efc54 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useRemoveMemberAction.tsx @@ -0,0 +1,18 @@ +import { useAPIClient, useRecord, useResourceActionContext } from '@tachybase/client'; +import { useContext } from 'react'; +import { contextK } from '../context/contextK'; +import { k } from '../others/k'; + +export const useRemoveMemberAction = () => { + const e = useAPIClient(), + { department: t } = useContext(contextK), + { id: o } = useRecord(), + { refresh: a } = useResourceActionContext(); + return { + run() { + return k(this, null, function* () { + yield e.resource('departments.members', t.id).remove({ values: [o] }), a(); + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useShowTotal.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useShowTotal.tsx new file mode 100644 index 000000000..ed4be0ab0 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useShowTotal.tsx @@ -0,0 +1,9 @@ +import { useResourceActionContext } from '@tachybase/client'; +import { useTranslation } from '../../../locale'; + +export const useShowTotal = () => { + var o; + const { data: e } = useResourceActionContext(), + { t } = useTranslation(); + return t('Total {{count}} members', { count: (o = e == null ? void 0 : e.meta) == null ? void 0 : o.count }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useUpdateDepartmentLe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useUpdateDepartmentLe.tsx new file mode 100644 index 000000000..06ed8eb34 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/hooks/useUpdateDepartmentLe.tsx @@ -0,0 +1,36 @@ +import { useAPIClient, useActionContext, useRecord, useResourceActionContext } from '@tachybase/client'; +import { useField, useForm } from '@tachybase/schema'; +import { useContext } from 'react'; +import { contextK } from '../context/contextK'; +import { k } from '../others/k'; +import { contextN } from '../context/contextN'; + +export const useUpdateDepartmentLe = () => { + const e = useField(), + t = useForm(), + o = useActionContext(), + { refreshAsync: a } = useResourceActionContext(), + r = useAPIClient(), + { id: c } = useRecord(), + { expandedKeys: i, setLoadedKeys: x, setExpandedKeys: m } = useContext(contextN), + { department: g, setDepartment: d } = useContext(contextK); + return { + run() { + return k(this, null, function* () { + yield t.submit(), (e.data = e.data || {}), (e.data.loading = true); + try { + yield r.resource('departments').update({ filterByTk: c, values: t.values }), + d({ department: g, ...t.values }), + o.setVisible(false), + yield t.reset(); + const b = [...i]; + x([]), m([]), yield a(), m(b); + } catch (b) { + console.log(b); + } finally { + e.data.loading = false; + } + }); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/index.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/index.tsx index f82d65577..ce4862c8e 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/departments/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/index.tsx @@ -1,2453 +1,18 @@ -import { MoreOutlined, PlusOutlined, UserOutlined } from '@ant-design/icons'; -import { - CollectionContext, - SchemaSettings, - SchemaComponentContext, - ResourceActionProvider, - useSchemaComponentContext, - useFilterFieldProps, - useFieldModeOptions, - useCollectionManager_deprecated, - useCompile, - useCollection_deprecated, - useCollectionField, - useTitleFieldOptions, - useDesignable, - AssociationField, - mergeFilter, - removeNullCondition, - Checkbox, - EllipsisWithTooltip, - CollectionProvider_deprecated, - RecordProvider, - Plugin, - ResourceActionContext, - SchemaComponent, - ActionContextProvider, - createStyles, - css, - useAPIClient, - useActionContext, - SchemaComponentOptions, - useFilterFieldOptions, - useRecord, - useRequest, - useResourceActionContext, -} from '@tachybase/client'; -import PluginACLClient, { RolesManagerContext } from '@tachybase/plugin-acl/client'; -import { connect, mapReadPretty, uid, useField, useFieldSchema, useForm } from '@tachybase/schema'; -import { - App, - Button, - Col, - Divider, - Dropdown, - Empty, - Input, - Row, - Select, - Table, - Tag, - Tree, - TreeSelect, - theme, -} from 'antd'; -import React, { useCallback, useContext, useEffect, useMemo, useRef, useState, Fragment } from 'react'; -import { jsx, jsxs } from 'react/jsx-runtime'; -import { useTranslation, tval } from '../../locale'; +import React from 'react'; +import { Plugin, SchemaComponentContext, useSchemaComponentContext } from '@tachybase/client'; +import PluginACLClient from '@tachybase/plugin-acl/client'; + +import { tval } from '../../locale'; +import { Departments } from './components/Departments'; +import { GeComponent } from './components/GeComponent'; +import { MmtComponent } from './components/MmtComponent'; +import { UserDepartmentsField } from './components/UserDepartmentsField'; +import { DepartmentOwnersFieldSetting } from './settings/DepartmentOwnersFieldSetting'; +import { UserDepartmentsFieldSetting } from './settings/UserDepartmentsFieldSetting'; +import { UserMainDepartmentFieldSetting } from './settings/UserMainDepartmentFieldSetting'; + +// import { T } from './others/T'; -var wt = Object.defineProperty, - Ft = Object.defineProperties; -var Mt = Object.getOwnPropertyDescriptors; -var me = Object.getOwnPropertySymbols; -var Tt = Object.prototype.hasOwnProperty, - It = Object.prototype.propertyIsEnumerable; -var de = (w, s, n) => - s in w ? wt(w, s, { enumerable: true, configurable: true, writable: true, value: n }) : (w[s] = n), - y = (w, s) => { - for (var n in s || (s = {})) Tt.call(s, n) && de(w, n, s[n]); - if (me) for (var n of me(s)) It.call(s, n) && de(w, n, s[n]); - return w; - }, - T = (w, s) => Ft(w, Mt(s)); -var k = (w, s, n) => - new Promise((D, p) => { - var j = (V) => { - try { - N(n.next(V)); - } catch (I) { - p(I); - } - }, - Y = (V) => { - try { - N(n.throw(V)); - } catch (I) { - p(I); - } - }, - N = (V) => (V.done ? D(V.value) : Promise.resolve(V.value).then(j, Y)); - N((n = n.apply(w, s)).next()); - }); -const xe = () => { - const { t: e } = useTranslation(); - return jsx(SchemaComponent, { - scope: { t: e }, - schema: { - type: 'void', - properties: { - newDepartment: { - type: 'void', - title: e('New department'), - 'x-component': 'Action', - 'x-component-props': { type: 'text', icon: 'PlusOutlined', style: { width: '100%', textAlign: 'left' } }, - properties: { - drawer: { - type: 'void', - 'x-component': 'Action.Drawer', - 'x-decorator': 'Form', - title: e('New department'), - properties: { - title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', required: true }, - parent: { - 'x-component': 'CollectionField', - 'x-decorator': 'FormItem', - 'x-collection-field': 'departments.parent', - 'x-component-props': { component: 'DepartmentSelect' }, - }, - roles: { - 'x-component': 'CollectionField', - 'x-decorator': 'FormItem', - 'x-collection-field': 'departments.roles', - }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - submit: { - title: '{{t("Submit")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }); -}; -const ye = { - type: 'object', - properties: { - [uid()]: { - type: 'void', - 'x-component': 'Action.Drawer', - 'x-decorator': 'Form', - 'x-decorator-props': { - useValues(e) { - const t = useActionContext(), - o = useRecord(); - return useRequest( - () => Promise.resolve({ data: { parent: { ...o } } }), - T({ ...e }, { refreshDeps: [t.visible] }), - ); - }, - }, - title: '{{t("New sub department")}}', - properties: { - title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem' }, - parent: { - 'x-component': 'CollectionField', - 'x-decorator': 'FormItem', - 'x-collection-field': 'departments.parent', - 'x-component-props': { component: 'DepartmentSelect' }, - }, - roles: { - 'x-component': 'CollectionField', - 'x-decorator': 'FormItem', - 'x-collection-field': 'departments.roles', - }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - submit: { - title: '{{t("Submit")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' }, - }, - }, - }, - }, - }, - }, -}; -const he = { - type: 'object', - properties: { - [uid()]: { - type: 'void', - 'x-component': 'Action.Drawer', - 'x-decorator': 'Form', - 'x-decorator-props': { - useValues(e) { - const t = useAPIClient(), - o = useActionContext(), - a = useRecord(), - r = useRequest( - () => - t - .resource('departments') - .get({ filterByTk: a.id, appends: ['parent(recursively=true)', 'roles', 'owners'] }) - .then((c) => (c == null ? void 0 : c.data)), - T({ ...e }, { manual: true }), - ); - return ( - useEffect(() => { - o.visible && r.run(); - }, [o.visible]), - r - ); - }, - }, - title: '{{t("Edit department")}}', - properties: { - title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem' }, - parent: { - 'x-component': 'CollectionField', - 'x-decorator': 'FormItem', - 'x-collection-field': 'departments.parent', - 'x-component-props': { component: 'SuperiorDepartmentSelect' }, - }, - roles: { - 'x-component': 'CollectionField', - 'x-decorator': 'FormItem', - 'x-collection-field': 'departments.roles', - }, - owners: { title: '{{t("Owners")}}', 'x-component': 'DepartmentOwnersField', 'x-decorator': 'FormItem' }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - submit: { - title: '{{t("Submit")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useUpdateDepartment }}' }, - }, - }, - }, - }, - }, - }, -}; -const fe = { - type: 'void', - properties: { - drawer: { - title: '{{t("Select Owners")}}', - 'x-component': 'Action.Drawer', - properties: { - resource: { - type: 'void', - 'x-decorator': 'FormItem', - 'x-component': 'RequestProvider', - properties: { - actions: { - type: 'void', - 'x-component': 'ActionBar', - 'x-component-props': { style: { marginBottom: 16 } }, - properties: { - filter: { - type: 'void', - title: '{{ t("Filter") }}', - default: { $and: [{ username: { $includes: '' } }, { nickname: { $includes: '' } }] }, - 'x-action': 'filter', - 'x-component': 'Filter.Action', - 'x-use-component-props': 'useFilterActionProps', - 'x-component-props': { icon: 'FilterOutlined' }, - 'x-align': 'left', - }, - }, - }, - table: { - type: 'void', - 'x-component': 'Table.Void', - 'x-component-props': { - rowKey: 'id', - rowSelection: { type: 'checkbox', onChange: '{{ handleSelect }}' }, - useDataSource: '{{ cm.useDataSourceFromRAC }}', - }, - properties: { - username: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { - username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, - }, - }, - nickname: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { - nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, - }, - }, - phone: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - email: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - }, - }, - }, - }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - confirm: { - title: '{{t("Confirm")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useSelectOwners }}' }, - }, - }, - }, - }, - }, - }, - }, - Q = { - name: 'departments', - fields: [ - { - type: 'bigInt', - name: 'id', - primaryKey: true, - autoIncrement: true, - interface: 'id', - uiSchema: { type: 'id', title: '{{t("ID")}}' }, - }, - { - name: 'title', - type: 'string', - interface: 'input', - uiSchema: { type: 'string', title: '{{t("Department name")}}', 'x-component': 'Input', required: true }, - }, - { - name: 'parent', - type: 'belongsTo', - interface: 'm2o', - collectionName: 'departments', - foreignKey: 'parentId', - target: 'departments', - targetKey: 'id', - treeParent: true, - uiSchema: { title: '{{t("Superior department")}}', 'x-component': 'DepartmentSelect' }, - }, - { - interface: 'm2m', - type: 'belongsToMany', - name: 'roles', - target: 'roles', - collectionName: 'departments', - through: 'departmentsRoles', - foreignKey: 'departmentId', - otherKey: 'roleName', - targetKey: 'name', - sourceKey: 'id', - uiSchema: { - title: '{{t("Roles")}}', - 'x-component': 'AssociationField', - 'x-component-props': { multiple: true, fieldNames: { label: 'title', value: 'name' } }, - }, - }, - { - interface: 'm2m', - type: 'belongsToMany', - name: 'owners', - collectionName: 'departments', - target: 'users', - through: 'departmentsUsers', - foreignKey: 'departmentId', - otherKey: 'userId', - targetKey: 'id', - sourceKey: 'id', - scope: { isOwner: true }, - uiSchema: { - title: '{{t("Owners")}}', - 'x-component': 'AssociationField', - 'x-component-props': { multiple: true, fieldNames: { label: 'nickname', value: 'id' } }, - }, - }, - ], - }; -const ve = { - name: 'users', - fields: [ - { - name: 'id', - type: 'bigInt', - autoIncrement: true, - primaryKey: true, - allowNull: false, - uiSchema: { type: 'number', title: '{{t("ID")}}', 'x-component': 'InputNumber', 'x-read-pretty': true }, - interface: 'id', - }, - { - interface: 'input', - type: 'string', - name: 'nickname', - uiSchema: { type: 'string', title: '{{t("Nickname")}}', 'x-component': 'Input' }, - }, - { - interface: 'input', - type: 'string', - name: 'username', - unique: true, - uiSchema: { - type: 'string', - title: '{{t("Username")}}', - 'x-component': 'Input', - 'x-validator': { username: true }, - required: true, - }, - }, - { - interface: 'email', - type: 'string', - name: 'email', - unique: true, - uiSchema: { - type: 'string', - title: '{{t("Email")}}', - 'x-component': 'Input', - 'x-validator': 'email', - required: true, - }, - }, - { - interface: 'phone', - type: 'string', - name: 'phone', - unique: true, - uiSchema: { - type: 'string', - title: '{{t("Phone")}}', - 'x-component': 'Input', - 'x-validator': 'phone', - required: true, - }, - }, - { - interface: 'm2m', - type: 'belongsToMany', - name: 'roles', - target: 'roles', - foreignKey: 'userId', - otherKey: 'roleName', - onDelete: 'CASCADE', - sourceKey: 'id', - targetKey: 'name', - through: 'rolesUsers', - uiSchema: { - type: 'array', - title: '{{t("Roles")}}', - 'x-component': 'AssociationField', - 'x-component-props': { multiple: true, fieldNames: { label: 'title', value: 'name' } }, - }, - }, - { - name: 'departments', - type: 'belongsToMany', - interface: 'm2m', - target: 'departments', - foreignKey: 'userId', - otherKey: 'departmentId', - onDelete: 'CASCADE', - sourceKey: 'id', - targetKey: 'id', - through: 'departmentsUsers', - uiSchema: { type: 'array', title: '{{t("Departments")}}', 'x-component': 'DepartmentField' }, - }, - { - interface: 'm2m', - type: 'belongsToMany', - name: 'mainDepartment', - target: 'departments', - foreignKey: 'userId', - otherKey: 'departmentId', - onDelete: 'CASCADE', - sourceKey: 'id', - targetKey: 'id', - through: 'departmentsUsers', - throughScope: { isMain: true }, - uiSchema: { type: 'array', title: '{{t("Main department")}}', 'x-component': 'DepartmentField' }, - }, - ], -}; -const K = React.createContext({ user: {}, department: {} }); -const ge = (e) => { - const [t, o] = useState(null), - [a, r] = useState(null), - c = useRequest({ - resource: 'users', - action: 'list', - params: { - appends: ['departments', 'departments.parent(recursively=true)'], - filter: a ? { 'departments.id': a.id } : {}, - pageSize: 50, - }, - }); - useEffect(() => { - c.run(); - }, [a]); - const i = { resource: 'departments', action: 'list', params: { pagination: false, filter: { parentId: null } } }, - x = useRequest(i); - return jsx(K.Provider, { - value: { - user: t, - setUser: o, - department: a, - setDepartment: r, - usersResource: { service: c }, - departmentsResource: { service: x }, - }, - children: e.children, - }); -}; -const Ce = (e) => { - const { departmentsResource: t } = useContext(K), - { service: o } = t || {}; - return jsx(ResourceActionContext.Provider, { - value: { ...o }, - children: jsx(CollectionProvider_deprecated, { collection: Q, children: e.children }), - }); -}; -const be = (e) => { - const { usersResource: t } = useContext(K), - { service: o } = t || {}; - return jsx(ResourceActionContext.Provider, { - value: { ...o }, - children: jsx(CollectionProvider_deprecated, { collection: ve, children: e.children }), - }); -}; -const X = () => { - const { data: e, loading: t } = useResourceActionContext(), - { department: o, setDepartment: a, setUser: r } = useContext(K), - { - treeData: c, - nodeMap: i, - loadData: x, - loadedKeys: m, - setLoadedKeys: g, - initData: d, - expandedKeys: A, - setExpandedKeys: b, - } = useContext(_), - h = (v) => { - if (!v.length) return; - const l = i[v[0]]; - a(l), r(null); - }, - F = (v) => { - b(v); - }, - C = (v) => { - g(v); - }; - return ( - useEffect(() => { - d(e == null ? void 0 : e.data); - }, [e, d, t]), - useEffect(() => { - if (!o) return; - const v = (u) => (u.parent ? [u.parent.id, ...v(u.parent)] : []), - l = v(o); - b((u) => Array.from(new Set([...u, ...l]))); - }, [o, b]), - jsx('div', { - className: css` - height: 57vh; - overflow: auto; - .ant-tree-node-content-wrapper { - overflow: hidden; - } - `, - children: - c != null && c.length - ? jsx(Tree.DirectoryTree, { - loadData: x, - treeData: c, - loadedKeys: m, - onSelect: h, - selectedKeys: [o == null ? void 0 : o.id], - onExpand: F, - onLoad: C, - expandedKeys: A, - expandAction: false, - showIcon: false, - fieldNames: { key: 'id' }, - }) - : jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }), - }) - ); -}; -X.Item = function ({ node: t, setVisible: o, setDrawer: a }) { - const { t: r } = useTranslation(), - { refreshAsync: c } = useResourceActionContext(), - { setLoadedKeys: i, expandedKeys: x, setExpandedKeys: m } = useContext(_), - { modal: g, message: d } = App.useApp(), - A = useAPIClient(), - b = () => { - g.confirm({ - title: r('Delete'), - content: r('Are you sure you want to delete it?'), - onOk: () => - k(this, null, function* () { - yield A.resource('departments').destroy({ filterByTk: t.id }), - d.success(r('Deleted successfully')), - m((v) => v.filter((l) => l !== t.id)); - const C = [...x]; - i([]), m([]), yield c(), m(C); - }), - }); - }, - h = (C) => { - a({ schema: C, node: t }), o(true); - }, - F = ({ key: C, domEvent: v }) => { - switch ((v.stopPropagation(), C)) { - case 'new-sub': - h(ye); - break; - case 'edit': - h(he); - break; - case 'delete': - b(); - } - }; - return jsxs('div', { - style: { display: 'flex', justifyContent: 'space-between', overflow: 'hidden' }, - children: [ - jsx('div', { - style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, - children: t.title, - }), - jsx(Dropdown, { - menu: { - items: [ - { label: r('New sub department'), key: 'new-sub' }, - { label: r('Edit department'), key: 'edit' }, - { label: r('Delete department'), key: 'delete' }, - ], - onClick: F, - }, - children: jsx('div', { - style: { marginLeft: '15px' }, - children: jsx(MoreOutlined, {}), - }), - }), - ], - }); -}; -const Ae = createStyles(({ css: e }) => ({ - searchDropdown: e` - .ant-dropdown-menu { - max-height: 500px; - overflow-y: scroll; - } - `, -})); -const Se = () => { - const { t: e } = useTranslation(), - { token: t } = theme.useToken(), - { setDepartment: o, setUser: a } = useContext(K), - [r, c] = useState(false), - [i, x] = useState(''), - [m, g] = useState([]), - [d, A] = useState([]), - [b, h] = useState(true), - [F, C] = useState(true), - { styles: v } = Ae(), - l = 10, - u = useAPIClient(), - f = useRequest( - (M) => - u - .resource('departments') - .aggregateSearch(M) - .then((P) => { - var q; - return (q = P == null ? void 0 : P.data) == null ? void 0 : q.data; - }), - { - manual: true, - onSuccess: (M, P) => { - const { - values: { type: q }, - } = P[0] || {}; - M && - ((!q || q === 'user') && M.users.length < l && h(false), - (!q || q === 'department') && M.departments.length < l && C(false), - g((se) => [...se, ...M.users]), - A((se) => [...se, ...M.departments])); - }, - }, - ), - { run: S } = f, - O = (M) => { - x(M), g([]), A([]), h(true), C(true), M && (S({ values: { keyword: M, limit: l } }), c(true)); - }, - $ = (M) => { - M.target.value || (a(null), x(''), c(false), f.mutate({}), g([]), A([])); - }, - W = (M) => { - const P = M.title, - q = M.parent; - return q ? W(q) + ' / ' + P : P; - }, - H = (M) => - jsx(Button, { - type: 'link', - style: { padding: '0 8px' }, - onClick: (P) => { - c(true), S({ values: { keyword: i, limit: l, ...M } }); - }, - children: e('Load more'), - }), - J = () => { - const M = []; - return !m.length && !d.length - ? [ - { - key: '0', - label: jsx(Empty, { - description: e('No results'), - image: Empty.PRESENTED_IMAGE_SIMPLE, - }), - disabled: true, - }, - ] - : (m.length && - (M.push({ - key: '0', - type: 'group', - label: e('Users'), - children: m.map((P) => ({ - key: P.username, - label: jsxs('div', { - onClick: () => a(P), - children: [ - jsx('div', { children: P.nickname || P.username }), - jsx('div', { - style: { fontSize: t.fontSizeSM, color: t.colorTextDescription }, - children: `${P.username}${P.phone ? ' | ' + P.phone : ''}${P.email ? ' | ' + P.email : ''}`, - }), - ], - }), - })), - }), - b && - M.push({ - type: 'group', - key: '0-loadMore', - label: jsx(H, { type: 'user', last: m[m.length - 1].id }), - })), - d.length && - (M.push({ - key: '1', - type: 'group', - label: e('Departments'), - children: d.map((P) => ({ - key: P.id, - label: jsx('div', { onClick: () => o(P), children: W(P) }), - })), - }), - F && - M.push({ - type: 'group', - key: '1-loadMore', - label: jsx(H, { type: 'department', last: d[d.length - 1].id }), - })), - M); - }; - return jsx(Dropdown, { - menu: { items: J() }, - overlayClassName: v.searchDropdown, - trigger: ['click'], - open: r, - onOpenChange: (M) => c(M), - children: jsx(Input.Search, { - allowClear: true, - onClick: () => { - i || c(false); - }, - onFocus: () => o(null), - onSearch: O, - onChange: $, - placeholder: e('Search for departments, users'), - style: { marginBottom: '20px' }, - }), - }); -}; -const De = (e) => { - const { label: t } = e || {}, - [o, a] = useState([]), - [r, c] = useState({}), - [i, x] = useState([]), - [m, g] = useState([]), - d = useCallback((C) => { - const v = {}, - l = (f) => { - let S = f ? { ...f } : null; - for (; S; ) { - const O = S.parentId || 'root'; - v[O] - ? (v[O].childrenMap[S.id] = S) - : (v[O] = T({ ...(S.parent || { id: O }) }, { childrenMap: { [S.id]: S } })), - (S = S.parent); - } - }, - u = (f) => { - const S = {}; - f.children && - f.children.length && - f.children.forEach((O) => { - (S[O.id] = O), u(O); - }), - (v[f.id] = T({ ...f }, { childrenMap: S })); - }; - return ( - C && - C.length && - C.forEach((f) => { - l(f), u(f); - }), - v - ); - }, []), - A = useCallback((C) => { - const v = (l) => { - var u; - return !C[l] || C[l].isLeaf - ? null - : Object.values(((u = C[l]) == null ? void 0 : u.childrenMap) || {}).map((f: object) => - T({ ...f }, { title: t ? React.createElement(t, { node: f }) : f.title, children: v(f.id) }), - ); - }; - return v('root'); - }, []), - b = useCallback( - (C) => { - const v = d(C); - c(v); - const l = A(v) || []; - a(l); - }, - [a, d, A], - ), - h = (C, v) => { - const l = d(v), - u = { ...l, ...r }; - return ( - v.forEach((f) => { - u[C].childrenMap[f.id] = f; - }), - c(u), - A(u) - ); - }, - F = useCallback( - (C) => { - if (!r[C]) return []; - const v = []; - return ( - v.push(...Object.keys(r[C].childrenMap).map((l) => Number(l))), - Object.keys(r[C].childrenMap).forEach((l) => { - v.push(...F(l)); - }), - v - ); - }, - [r], - ); - return { - initData: b, - treeData: o, - setTreeData: a, - nodeMap: r, - updateTreeData: h, - constructTreeData: A, - getChildrenIds: F, - loadedKeys: m, - setLoadedKeys: g, - expandedKeys: i, - setExpandedKeys: x, - }; -}; -function we(e) { - return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, 'default') ? e.default : e; -} -var Fe = function (t) { - return Me(t) && !Te(t); -}; -function Me(e) { - return !!e && typeof e == 'object'; -} -function Te(e) { - var t = Object.prototype.toString.call(e); - return t === '[object RegExp]' || t === '[object Date]' || Pe(e); -} -var Ie = typeof Symbol == 'function' && Symbol.for, - Oe = Ie ? Symbol.for('react.element') : 60103; -function Pe(e) { - return e.$$typeof === Oe; -} -function ke(e) { - return Array.isArray(e) ? [] : {}; -} -function L(e, t) { - return t.clone !== false && t.isMergeableObject(e) ? B(ke(e), e, t) : e; -} -function Ee(e, t, o) { - return e.concat(t).map(function (a) { - return L(a, o); - }); -} -function Ke(e, t) { - if (!t.customMerge) return B; - var o = t.customMerge(e); - return typeof o == 'function' ? o : B; -} -function Ne(e) { - return Object.getOwnPropertySymbols - ? Object.getOwnPropertySymbols(e).filter(function (t) { - return Object.propertyIsEnumerable.call(e, t); - }) - : []; -} -function ae(e) { - return Object.keys(e).concat(Ne(e)); -} -function ce(e, t) { - try { - return t in e; - } catch (o) { - return false; - } -} -function qe(e, t) { - return ce(e, t) && !(Object.hasOwnProperty.call(e, t) && Object.propertyIsEnumerable.call(e, t)); -} -function Ve(e, t, o) { - var a = {}; - return ( - o.isMergeableObject(e) && - ae(e).forEach(function (r) { - a[r] = L(e[r], o); - }), - ae(t).forEach(function (r) { - qe(e, r) || (ce(e, r) && o.isMergeableObject(t[r]) ? (a[r] = Ke(r, o)(e[r], t[r], o)) : (a[r] = L(t[r], o))); - }), - a - ); -} -function B(e, t, o) { - (o = o || {}), - (o.arrayMerge = o.arrayMerge || Ee), - (o.isMergeableObject = o.isMergeableObject || Fe), - (o.cloneUnlessOtherwiseSpecified = L); - var a = Array.isArray(t), - r = Array.isArray(e), - c = a === r; - return c ? (a ? o.arrayMerge(e, t, o) : Ve(e, t, o)) : L(t, o); -} -B.all = function (t, o) { - if (!Array.isArray(t)) throw new Error('first argument should be an array'); - return t.reduce(function (a, r) { - return B(a, r, o); - }, {}); -}; -const je = B; -const Ue = je; -const ie = we(Ue); -const G = (e) => { - const { resource: t = 'departments', resourceOf: o, params: a = {} } = e || {}, - c = useAPIClient().resource(t, o), - i = De(e), - { setTreeData: x, updateTreeData: m, setLoadedKeys: g, initData: d } = i, - A = (C) => - k(this, [C], function* ({ key: h, children: F }) { - var l; - if (F != null && F.length) return; - const { data: v } = yield c.list( - ie(a, { pagination: false, appends: ['parent(recursively=true)'], filter: { parentId: h } }), - ); - (l = v == null ? void 0 : v.data) != null && l.length && x(m(h, v == null ? void 0 : v.data)); - }), - b = (h) => - k(this, null, function* () { - const { data: F } = yield c.list( - ie(a, { - pagination: false, - filter: { title: { $includes: h } }, - appends: ['parent(recursively=true)'], - pageSize: 100, - }), - ); - d(F == null ? void 0 : F.data); - }); - return T({ ...i }, { loadData: A, getByKeyword: b }); -}; -const Z = () => { - var a, r; - const e = useContext(CollectionContext), - t = useFilterFieldOptions(e.fields), - o = useResourceActionContext(); - return useFilterFieldProps({ - options: t, - params: ((r = (a = o.state) == null ? void 0 : a.params) == null ? void 0 : r[0]) || o.params, - service: o, - }); -}; -const Be = () => { - const [e, t] = useState(false), - o = useRecord(), - a = useField(), - [r, c] = useState([]), - i = useRef([]), - x = (d, A) => { - i.current = A; - }, - m = () => { - const { setVisible: d } = useActionContext(); - return { - run() { - const A = a.value || []; - a.setValue([...A, ...i.current]), (i.current = []), d(false); - }, - }; - }; - useEffect(() => { - a.value && c(a.value.map((d) => ({ value: d.id, label: d.nickname || d.username }))); - }, [a.value]); - const g = (d) => { - var A; - return jsx(ResourceActionProvider, { - collection: 'users', - request: { - resource: `departments/${o.id}/members`, - action: 'list', - params: { filter: (A = a.value) != null && A.length ? { id: { $notIn: a.value.map((b) => b.id) } } : {} }, - }, - children: d.children, - }); - }; - return jsxs(ActionContextProvider, { - value: { visible: e, setVisible: t }, - children: [ - jsx(Select, { - open: false, - onChange: (d) => { - if (!d) { - a.setValue([]); - return; - } - a.setValue(d.map(({ label: A, value: b }) => ({ id: b, nickname: A }))); - }, - mode: 'multiple', - value: r, - labelInValue: true, - onDropdownVisibleChange: (d) => t(d), - }), - jsx(SchemaComponent, { - schema: fe, - components: { RequestProvider: g }, - scope: { department: o, handleSelect: x, useSelectOwners: m }, - }), - ], - }); -}; -const _ = React.createContext({}); -const $e = () => { - const e = useForm(), - t = useField(), - o = useActionContext(), - { refreshAsync: a } = useResourceActionContext(), - r = useAPIClient(), - { expandedKeys: c, setLoadedKeys: i, setExpandedKeys: x } = useContext(_); - return { - run() { - return k(this, null, function* () { - try { - yield e.submit(), - (t.data = t.data || {}), - (t.data.loading = true), - yield r.resource('departments').create({ values: e.values }), - o.setVisible(false), - yield e.reset(), - (t.data.loading = false); - const g = [...c]; - i([]), x([]), yield a(), x(g); - } catch (g) { - t.data && (t.data.loading = false); - } - }); - }, - }; -}; -const Le = () => { - const e = useField(), - t = useForm(), - o = useActionContext(), - { refreshAsync: a } = useResourceActionContext(), - r = useAPIClient(), - { id: c } = useRecord(), - { expandedKeys: i, setLoadedKeys: x, setExpandedKeys: m } = useContext(_), - { department: g, setDepartment: d } = useContext(K); - return { - run() { - return k(this, null, function* () { - yield t.submit(), (e.data = e.data || {}), (e.data.loading = true); - try { - yield r.resource('departments').update({ filterByTk: c, values: t.values }), - d({ department: g, ...t.values }), - o.setVisible(false), - yield t.reset(); - const b = [...i]; - x([]), m([]), yield a(), m(b); - } catch (b) { - console.log(b); - } finally { - e.data.loading = false; - } - }); - }, - }; -}; -const _e = () => { - const { t: e } = useTranslation(), - [t, o] = useState(false), - [a, r] = useState({}), - { department: c, setDepartment: i } = useContext(K), - { token: x } = theme.useToken(), - m = G({ label: ({ node: g }) => jsx(X.Item, { node: g, setVisible: o, setDrawer: r }) }); - return jsx(SchemaComponentOptions, { - scope: { useCreateDepartment: $e, useUpdateDepartment: Le }, - children: jsxs(_.Provider, { - value: m, - children: [ - jsxs(Row, { - children: [ - jsx(Se, {}), - jsx(Button, { - type: 'text', - icon: jsx(UserOutlined, {}), - style: { textAlign: 'left', marginBottom: '5px', background: c ? '' : x.colorBgTextHover }, - onClick: () => { - i(null); - }, - block: true, - children: e('All users'), - }), - jsx(xe, {}), - ], - }), - jsx(Divider, { style: { margin: '12px 0' } }), - jsx(X, {}), - jsx(ActionContextProvider, { - value: { visible: t, setVisible: o }, - children: jsx(RecordProvider, { - record: a.node || {}, - children: jsx(SchemaComponent, { - scope: { t: e }, - components: { DepartmentOwnersField: Be }, - schema: a.schema || {}, - }), - }), - }), - ], - }), - }); -}; -const ze = { - type: 'void', - 'x-component': 'Space', - properties: { - remove: { - type: 'void', - title: '{{t("Remove")}}', - 'x-component': 'Action', - 'x-component-props': { - icon: 'UserDeleteOutlined', - confirm: { - title: "{{t('Remove members')}}", - content: "{{t('Are you sure you want to remove these members?')}}", - }, - style: { marginRight: 8 }, - useAction: '{{ useBulkRemoveMembersAction }}', - }, - }, - create: { - type: 'void', - title: '{{t("Add members")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', icon: 'UserAddOutlined' }, - properties: { drawer: { type: 'void', 'x-component': 'AddMembers' } }, - }, - }, -}; -const We = { - type: 'void', - properties: { - remove: { - title: '{{ t("Remove") }}', - 'x-component': 'Action.Link', - 'x-component-props': { - confirm: { title: "{{t('Remove member')}}", content: "{{t('Are you sure you want to remove it?')}}" }, - useAction: '{{ useRemoveMemberAction }}', - }, - }, - }, -}; -const He = (e, t) => ({ - type: 'void', - properties: T( - y( - {}, - t - ? {} - : { - actions: { - type: 'void', - 'x-component': 'ActionBar', - 'x-component-props': { style: { marginBottom: 16 } }, - properties: { - [uid()]: { - type: 'void', - title: '{{ t("Filter") }}', - 'x-action': 'filter', - 'x-component': 'Filter.Action', - 'x-use-component-props': 'useFilterActionProps', - 'x-component-props': { icon: 'FilterOutlined' }, - 'x-align': 'left', - }, - actions: { type: 'void', 'x-component': 'MemberActions' }, - }, - }, - }, - ), - { - table: { - type: 'void', - 'x-component': 'Table.Void', - 'x-component-props': { - rowKey: 'id', - rowSelection: { type: 'checkbox' }, - useDataSource: '{{ useMembersDataSource }}', - pagination: { showTotal: '{{ useShowTotal }}' }, - }, - properties: T( - y( - { - nickname: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - username: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - departments: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { - departments: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, - }, - }, - }, - e - ? { - isOwner: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - 'x-component-props': { style: { minWidth: 100 } }, - title: '{{t("Owner")}}', - properties: { isOwner: { type: 'boolean', 'x-component': 'IsOwnerField' } }, - }, - } - : {}, - ), - { - phone: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - email: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - actions: { - type: 'void', - title: '{{t("Actions")}}', - 'x-component': 'Table.Column', - properties: { - actions: { - type: 'void', - 'x-component': 'Space', - 'x-component-props': { split: '|' }, - properties: y( - { - update: { - type: 'void', - title: '{{t("Configure")}}', - 'x-component': 'Action.Link', - 'x-component-props': { type: 'primary' }, - properties: { - drawer: { - type: 'void', - 'x-component': 'Action.Drawer', - 'x-decorator': 'FormV2', - title: '{{t("Configure")}}', - properties: { - departments: { - title: '{{t("Departments")}}', - 'x-decorator': 'FormItem', - 'x-component': 'UserDepartmentsField', - }, - }, - }, - }, - }, - }, - e ? { remove: { type: 'void', 'x-component': 'RowRemoveAction' } } : {}, - ), - }, - }, - }, - }, - ), - }, - }, - ), -}); -const Ge = { - type: 'object', - properties: { - drawer: { - type: 'void', - 'x-component': 'Action.Drawer', - 'x-decorator': 'Form', - title: '{{t("Add members")}}', - properties: { - resource: { - type: 'void', - 'x-decorator': 'FormItem', - 'x-component': 'ResourceActionProvider', - 'x-component-props': { - collection: 'users', - request: { - resource: 'users', - action: 'listExcludeDept', - params: { departmentId: '{{ department?.id }}' }, - }, - }, - properties: { - actions: { - type: 'void', - 'x-component': 'ActionBar', - 'x-component-props': { style: { marginBottom: 16 } }, - properties: { - filter: { - type: 'void', - title: '{{ t("Filter") }}', - default: { $and: [{ username: { $includes: '' } }, { nickname: { $includes: '' } }] }, - 'x-action': 'filter', - 'x-component': 'Filter.Action', - 'x-use-component-props': 'useFilterActionProps', - 'x-component-props': { icon: 'FilterOutlined' }, - 'x-align': 'left', - }, - }, - }, - table: { - type: 'void', - 'x-component': 'Table.Void', - 'x-component-props': { - rowKey: 'id', - rowSelection: { type: 'checkbox', onChange: '{{ handleSelect }}' }, - useDataSource: '{{ cm.useDataSourceFromRAC }}', - }, - properties: { - username: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { - username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, - }, - }, - nickname: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { - nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, - }, - }, - phone: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - email: { - type: 'void', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, - }, - }, - }, - }, - }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - submit: { - title: '{{t("Submit")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useAddMembersAction }}' }, - }, - }, - }, - }, - }, - }, -}; -const Je = { - type: 'void', - properties: { - drawer: { - title: '{{t("Select Departments")}}', - 'x-decorator': 'Form', - 'x-component': 'Action.Drawer', - properties: { - table: { - type: 'void', - 'x-decorator': 'FormItem', - 'x-component': 'DepartmentTable', - 'x-component-props': { useDataSource: '{{ useDataSource }}', useDisabled: '{{ useDisabled }}' }, - }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - confirm: { - title: '{{t("Submit")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useAddDepartments }}' }, - }, - }, - }, - }, - }, - }, -}; -const z = (e) => { - const t = e.title, - o = e.parent; - return o ? z(o) + ' / ' + t : t; -}; -const Ye = () => { - const { setDepartment: e } = useContext(K), - o = useField().value || [], - a = o.reduce((c, i) => ((c[i.id] = i), c), {}), - r = o.map((c, i) => - jsxs( - 'span', - { - children: [ - jsx('a', { - onClick: (x) => { - x.preventDefault(), e(a[c.id]); - }, - children: z(c), - }), - i !== o.length - 1 ? jsx('span', { style: { marginRight: 4, color: '#aaa' }, children: ',' }) : '', - ], - }, - i, - ), - ); - return jsx(EllipsisWithTooltip, { ellipsis: true, children: r }); -}; -const Qe = () => { - const { department: e } = useContext(K), - o = (useRecord().departments || []).find((a) => (a == null ? void 0 : a.id) === (e == null ? void 0 : e.id)); - return jsx(Checkbox.ReadPretty, { value: o == null ? void 0 : o.departmentsUsers.isOwner }); -}; -const R = React.createContext({}); -const Xe = () => { - const { setHasFilter: e, setExpandedKeys: t } = useContext(R), - { t: o } = useTranslation(), - a = useContext(CollectionContext), - r = useFilterFieldOptions(a.fields), - c = useResourceActionContext(), - { run: i, defaultRequest: x } = c, - m = useField(), - { params: g } = x || {}; - return { - options: r, - onSubmit: (d) => - k(this, null, function* () { - const A = g.filter, - b = removeNullCondition(d == null ? void 0 : d.filter); - i(T(y({}, g), { page: 1, pageSize: 10, filter: mergeFilter([b, A]) })); - const h = (b == null ? void 0 : b.$and) || (b == null ? void 0 : b.$or); - h != null && h.length - ? ((m.title = o('{{count}} filter items', { count: (h == null ? void 0 : h.length) || 0 })), e(true)) - : ((m.title = o('Filter')), e(false)); - }), - onReset() { - i( - T(y({}, g || {}), { - filter: T(y({}, (g == null ? void 0 : g.filter) || {}), { parentId: null }), - page: 1, - pageSize: 10, - }), - ), - (m.title = o('Filter')), - e(false), - t([]); - }, - }; -}; -const Ze = () => ({ disabled: () => false }); -const Re = ({ useDisabled: e = Ze }) => { - const { t } = useTranslation(), - o = useResourceActionContext(); - console.log(o); - const { run: a, data: r, loading: c, defaultRequest: i } = o, - { resource: x, resourceOf: m, params: g } = i || {}, - { treeData: d, initData: A, loadData: b } = G({ resource: x, resourceOf: m, params: g }), - h = useField(), - { disabled: F } = e(), - { hasFilter: C, expandedKeys: v, setExpandedKeys: l } = useContext(R); - useEffect(() => { - C || A(r == null ? void 0 : r.data); - }, [r, A, c, C]); - const u = {}; - if ((g != null && g.pageSize && (u.defaultPageSize = g.pageSize), !u.total && r != null && r.meta)) { - const { count: f, page: S, pageSize: O } = r.meta; - (u.total = f), (u.current = S), (u.pageSize = O); - } - return jsx(Table, { - rowKey: 'id', - columns: [{ dataIndex: 'title', title: t('Department name'), render: (f, S) => (C ? z(S) : f) }], - rowSelection: { - selectedRowKeys: ((h == null ? void 0 : h.value) || []).map((f) => f.id), - onChange: (f, S) => { - var O; - return (O = h == null ? void 0 : h.setValue) == null ? void 0 : O.call(h, S); - }, - getCheckboxProps: (f) => ({ disabled: F(f) }), - }, - pagination: T(y({ showSizeChanger: true }, u), { - onChange(f, S) { - var O; - a(T(y({}, ((O = o == null ? void 0 : o.params) == null ? void 0 : O[0]) || {}), { page: f, pageSize: S })); - }, - }), - dataSource: C ? (r == null ? void 0 : r.data) || [] : d, - expandable: { - onExpand: (f, S) => { - b({ key: S.id, children: S.children }); - }, - expandedRowKeys: v, - onExpandedRowsChange: (f) => l(f), - }, - }); -}; -const et = (e) => { - const [t, o] = useState([]), - [a, r] = useState(false), - { useDataSource: c } = e, - i = c({ manual: true }); - return ( - useEffect(() => { - i.run({ filter: { parentId: null }, pageSize: 10 }); - }, []), - jsx(ResourceActionContext.Provider, { - value: y({}, i), - children: jsx(CollectionProvider_deprecated, { - collection: Q, - children: jsx(R.Provider, { - value: { expandedKeys: t, setExpandedKeys: o, hasFilter: a, setHasFilter: r }, - children: e.children, - }), - }), - }) - ); -}; -const pe = ({ useDataSource: e, useDisabled: t }) => - jsx(SchemaComponent, { - scope: { useDisabled: t, useFilterActionProps: Xe }, - components: { InternalDepartmentTable: Re, RequestProvider: et }, - schema: { - type: 'void', - properties: { - [uid()]: { - type: 'void', - 'x-component': 'RequestProvider', - 'x-component-props': { useDataSource: e }, - properties: { - actions: { - type: 'void', - 'x-component': 'ActionBar', - 'x-component-props': { style: { marginBottom: 16 } }, - properties: { - filter: { - type: 'void', - title: '{{ t("Filter") }}', - default: { $and: [{ title: { $includes: '' } }] }, - 'x-action': 'filter', - 'x-component': 'Filter.Action', - 'x-use-component-props': 'useFilterActionProps', - 'x-component-props': { icon: 'FilterOutlined' }, - 'x-align': 'left', - }, - }, - }, - departments: { - type: 'array', - 'x-component': 'InternalDepartmentTable', - 'x-component-props': { useDisabled: '{{ useDisabled }}' }, - }, - }, - }, - }, - }, - }); -const tt = (e) => { - const t = { - resource: 'departments', - action: 'list', - params: { appends: ['parent(recursively=true)'], sort: ['createdAt'] }, - }, - o = useRequest(t, e); - return T(y({}, o), { defaultRequest: t }); -}; -const ot = () => { - const { modal: e, message: t } = App.useApp(), - { t: o } = useTranslation(), - [a, r] = useState(false), - c = useRecord(), - i = useField(), - { refresh: x } = useResourceActionContext(), - m = (l) => - l != null && l.length - ? l.map((u) => { - var f, S; - return T(y({}, u), { - isMain: (f = u.departmentsUsers) == null ? void 0 : f.isMain, - isOwner: (S = u.departmentsUsers) == null ? void 0 : S.isOwner, - title: z(u), - }); - }) - : [], - g = useAPIClient(); - useRequest( - () => - g - .resource('users.departments', c.id) - .list({ appends: ['parent(recursively=true)'], pagination: false }) - .then((l) => { - var f; - const u = m((f = l == null ? void 0 : l.data) == null ? void 0 : f.data); - i.setValue(u); - }), - { ready: c.id }, - ); - const d = () => { - const l = useAPIClient(), - u = useForm(), - { departments: f } = u.values || {}; - return { - run() { - return k(this, null, function* () { - yield l.resource('users.departments', c.id).add({ values: f.map((O) => O.id) }), - u.reset(), - i.setValue([ - ...i.value, - ...f.map((O, $) => T(y({}, O), { isMain: $ === 0 && i.value.length === 0, title: z(O) })), - ]), - r(false), - x(); - }); - }, - }; - }, - A = (l) => { - e.confirm({ - title: o('Remove department'), - content: o('Are you sure you want to remove it?'), - onOk: () => - k(this, null, function* () { - yield g.resource('users.departments', c.id).remove({ values: [l.id] }), - t.success(o('Deleted successfully')), - i.setValue( - i.value - .filter((u) => u.id !== l.id) - .map((u, f) => T(y({}, u), { isMain: (l.isMain && f === 0) || u.isMain })), - ), - x(); - }), - }); - }, - b = (l) => - k(this, null, function* () { - yield g.resource('users').setMainDepartment({ values: { userId: c.id, departmentId: l.id } }), - t.success(o('Set successfully')), - i.setValue(i.value.map((u) => T(y({}, u), { isMain: u.id === l.id }))), - x(); - }), - h = (l) => - k(this, null, function* () { - yield g.resource('departments').setOwner({ values: { userId: c.id, departmentId: l.id } }), - t.success(o('Set successfully')), - i.setValue(i.value.map((u) => T(y({}, u), { isOwner: u.id === l.id ? true : u.isOwner }))), - x(); - }), - F = (l) => - k(this, null, function* () { - yield g.resource('departments').removeOwner({ values: { userId: c.id, departmentId: l.id } }), - t.success(o('Set successfully')), - i.setValue(i.value.map((u) => T(y({}, u), { isOwner: u.id === l.id ? false : u.isOwner }))), - x(); - }), - C = (l, u) => { - switch (l) { - case 'setMain': - b(u); - break; - case 'setOwner': - h(u); - break; - case 'removeOwner': - F(u); - break; - case 'remove': - A(u); - } - }, - v = () => ({ disabled: (l) => i.value.some((u) => u.id === l.id) }); - return jsxs(ActionContextProvider, { - value: { visible: a, setVisible: r }, - children: [ - jsxs(Fragment, { - children: [ - ((i == null ? void 0 : i.value) || []).map((l) => - jsxs( - Tag, - { - style: { padding: '5px 8px', background: 'transparent', marginBottom: '5px' }, - children: [ - jsx('span', { style: { marginRight: '5px' }, children: l.title }), - l.isMain ? jsx(Tag, { color: 'processing', bordered: false, children: o('Main') }) : '', - jsx(Dropdown, { - menu: { - items: [ - ...(l.isMain ? [] : [{ label: o('Set as main department'), key: 'setMain' }]), - { label: o('Remove'), key: 'remove' }, - ], - onClick: ({ key: u }) => C(u, l), - }, - children: jsx('div', { - style: { float: 'right' }, - children: jsx(MoreOutlined, {}), - }), - }), - ], - }, - l.id, - ), - ), - jsx(Button, { icon: jsx(PlusOutlined, {}), onClick: () => r(true) }), - ], - }), - jsx(SchemaComponent, { - schema: Je, - components: { DepartmentTable: pe }, - scope: { user: c, useDataSource: tt, useAddDepartments: d, useDisabled: v }, - }), - ], - }); -}; -const nt = () => { - const { department: e } = useContext(K), - { refresh: t } = useResourceActionContext(), - o = useRef([]), - a = useAPIClient(), - r = () => ({ - run() { - return k(this, null, function* () { - const x = o.current; - x != null && - x.length && - (yield a.resource('departments.members', e.id).add({ values: x }), (o.current = []), t()); - }); - }, - }), - c = (i) => { - o.current = i; - }; - return jsx(SchemaComponent, { - scope: { useAddMembersAction: r, department: e, handleSelect: c }, - schema: Ge, - }); -}; -const rt = () => { - const { t: e } = useTranslation(), - { message: t } = App.useApp(), - o = useAPIClient(), - { state: a, setState: r, refresh: c } = useResourceActionContext(), - { department: i } = useContext(K); - return { - run() { - return k(this, null, function* () { - const m = a == null ? void 0 : a.selectedRowKeys; - if (!(m != null && m.length)) { - t.warning(e('Please select members')); - return; - } - yield o.resource('departments.members', i.id).remove({ values: m }), - r == null || r({ selectedRowKeys: [] }), - c(); - }); - }, - }; -}; -const st = () => { - const e = useAPIClient(), - { department: t } = useContext(K), - { id: o } = useRecord(), - { refresh: a } = useResourceActionContext(); - return { - run() { - return k(this, null, function* () { - yield e.resource('departments.members', t.id).remove({ values: [o] }), a(); - }); - }, - }; -}; -const at = (e) => { - const { user: t } = useContext(K), - o = useResourceActionContext(); - return ( - useEffect(() => { - if (t) { - e == null || e.onSuccess({ data: [t] }); - return; - } - o.loading || e == null || e.onSuccess(o.data); - }, [t, o.loading]), - o - ); -}; -const ct = () => { - var o; - const { data: e } = useResourceActionContext(), - { t } = useTranslation(); - return t('Total {{count}} members', { count: (o = e == null ? void 0 : e.meta) == null ? void 0 : o.count }); -}; -const it = () => { - const { t: e } = useTranslation(), - { department: t, user: o } = useContext(K), - { data: a, setState: r } = useResourceActionContext(); - useEffect(() => { - r == null || r({ selectedRowKeys: [] }); - }, [a, r]); - const c = () => (t ? jsx(SchemaComponent, { schema: ze }) : null), - i = () => (t ? jsx(SchemaComponent, { scope: { useRemoveMemberAction: st }, schema: We }) : null), - x = useMemo(() => He(t, o), [t, o]); - return jsxs(Fragment, { - children: [ - o - ? jsx('h2', { children: e('Search results') }) - : jsx('h2', { children: e((t == null ? void 0 : t.title) || 'All users') }), - jsx(SchemaComponent, { - scope: { - useBulkRemoveMembersAction: rt, - useMembersDataSource: at, - t: e, - useShowTotal: ct, - useFilterActionProps: Z, - }, - components: { - MemberActions: c, - AddMembers: nt, - RowRemoveAction: i, - DepartmentField: Ye, - IsOwnerField: Qe, - UserDepartmentsField: ot, - }, - schema: x, - }), - ], - }); -}; -const le = (e) => { - const t = useField(), - [o, a] = useState({ label: null, value: null }), - { treeData: r, initData: c, getByKeyword: i, loadData: x, loadedKeys: m, setLoadedKeys: g, originData: d } = e, - A = (h) => - k(this, null, function* () { - if (!h) { - c(d); - return; - } - yield i(h); - }), - b = useCallback((h) => { - const F = h.title, - C = h.parent; - return C ? b(C) + ' / ' + F : F; - }, []); - return ( - useEffect(() => { - c(d); - }, [d, c]), - useEffect(() => { - if (!t.value) { - a({ label: null, value: null }); - return; - } - a({ label: b(t.value) || t.value.label, value: t.value.id }); - }, [t.value, b]), - jsx(TreeSelect, { - value: o, - onSelect: (h, F) => { - t.setValue(F); - }, - onChange: (h) => { - h || t.setValue(null); - }, - treeData: r, - treeLoadedKeys: m, - onTreeLoad: (h) => g(h), - loadData: (h) => x({ key: h.id, children: h.children }), - fieldNames: { value: 'id' }, - showSearch: true, - allowClear: true, - treeNodeFilterProp: 'title', - onSearch: A, - labelInValue: true, - }) - ); -}; -const pt = () => { - const e = G(), - { departmentsResource: t } = useContext(K), - { - service: { data: o }, - } = t || {}; - return jsx(le, T(y({}, e), { originData: o == null ? void 0 : o.data })); -}; -const lt = () => { - const e = G(), - { setTreeData: t, getChildrenIds: o } = e, - a = useRecord(), - { departmentsResource: r } = useContext(K), - { - service: { data: c }, - } = r || {}; - return ( - useEffect(() => { - if (!a.id) return; - const i = o(a.id); - i.push(a.id), - t((x) => { - const m = (g) => - g.map((d) => (i.includes(d.id) && (d.disabled = true), d.children && (d.children = m(d.children)), d)); - return m(x); - }); - }, [t, a.id, o]), - jsx(le, T(y({}, e), { originData: c == null ? void 0 : c.data })) - ); -}; -const ut = () => - jsx(SchemaComponentOptions, { - components: { SuperiorDepartmentSelect: lt, DepartmentSelect: pt }, - scope: { useFilterActionProps: Z }, - children: jsxs(Row, { - gutter: 48, - style: { flexWrap: 'nowrap' }, - children: [ - jsx(Col, { - span: 6, - style: { borderRight: '1px solid #eee', minWidth: '300px' }, - children: jsx(Ce, { children: jsx(_e, {}) }), - }), - jsx(Col, { - flex: 'auto', - style: { overflow: 'hidden' }, - children: jsx(be, { children: jsx(it, {}) }), - }), - ], - }), - }); -const mt = () => - jsx(SchemaComponent, { - components: { DepartmentManagement: ut }, - schema: { - type: 'void', - properties: { - [uid()]: { type: 'void', 'x-decorator': 'CardItem', 'x-component': 'DepartmentManagement' }, - }, - }, - }); -const dt = () => ({ - type: 'void', - properties: { - actions: { - type: 'void', - 'x-component': 'ActionBar', - 'x-component-props': { style: { marginBottom: 16 } }, - properties: { - [uid()]: { - type: 'void', - title: '{{ t("Filter") }}', - 'x-action': 'filter', - 'x-component': 'Filter.Action', - 'x-use-component-props': 'useFilterActionProps', - 'x-component-props': { icon: 'FilterOutlined' }, - 'x-align': 'left', - }, - actions: { - type: 'void', - 'x-component': 'Space', - properties: { - remove: { - type: 'void', - title: '{{t("Remove")}}', - 'x-component': 'Action', - 'x-component-props': { - icon: 'MinusOutlined', - confirm: { - title: "{{t('Remove')}}", - content: "{{t('Are you sure you want to remove these departments?')}}", - }, - style: { marginRight: 8 }, - useAction: '{{ useBulkRemoveDepartments }}', - }, - }, - create: { - type: 'void', - title: '{{t("Add departments")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', icon: 'PlusOutlined' }, - properties: { - drawer: { - type: 'void', - 'x-component': 'Action.Drawer', - 'x-decorator': 'FormV2', - title: '{{t("Add departments")}}', - properties: { - table: { - type: 'void', - 'x-decorator': 'FormItem', - 'x-component': 'DepartmentTable', - 'x-component-props': { - useDataSource: '{{ useDataSource }}', - useDisabled: '{{ useDisabled }}', - }, - }, - footer: { - type: 'void', - 'x-component': 'Action.Drawer.Footer', - properties: { - cancel: { - title: '{{t("Cancel")}}', - 'x-component': 'Action', - 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, - }, - submit: { - title: '{{t("Submit")}}', - 'x-component': 'Action', - 'x-component-props': { type: 'primary', useAction: '{{ useAddDepartments }}' }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - table: { - type: 'void', - 'x-component': 'Table.Void', - 'x-component-props': { - rowKey: 'id', - rowSelection: { type: 'checkbox' }, - useDataSource: '{{ cm.useDataSourceFromRAC }}', - }, - properties: { - title: { - type: 'void', - title: '{{t("Department name")}}', - 'x-decorator': 'Table.Column.Decorator', - 'x-component': 'Table.Column', - properties: { title: { type: 'string', 'x-component': 'DepartmentTitle' } }, - }, - actions: { - type: 'void', - title: '{{t("Actions")}}', - 'x-component': 'Table.Column', - properties: { - actions: { - type: 'void', - 'x-component': 'Space', - 'x-component-props': { split: '|' }, - properties: { - remove: { - type: 'void', - title: '{{ t("Remove") }}', - 'x-component': 'Action.Link', - 'x-component-props': { - confirm: { - title: "{{t('Remove department')}}", - content: "{{t('Are you sure you want to remove it?')}}", - }, - useAction: '{{ useRemoveDepartment }}', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}); -const xt = () => { - const e = useAPIClient(), - { role: t } = useContext(RolesManagerContext), - { data: o } = useRecord(), - { refresh: a } = useResourceActionContext(); - return { - run() { - return k(this, null, function* () { - yield e.resource(`roles/${t == null ? void 0 : t.name}/departments`).remove({ values: [o.id] }), a(); - }); - }, - }; -}; -const yt = () => { - const { t: e } = useTranslation(), - { message: t } = App.useApp(), - o = useAPIClient(), - { state: a, setState: r, refresh: c } = useResourceActionContext(), - { role: i } = useContext(RolesManagerContext); - return { - run() { - return k(this, null, function* () { - const m = a == null ? void 0 : a.selectedRowKeys; - if (!(m != null && m.length)) { - t.warning(e('Please select departments')); - return; - } - yield o.resource(`roles/${i == null ? void 0 : i.name}/departments`).remove({ values: m }), - r == null || r({ selectedRowKeys: [] }), - c(); - }); - }, - }; -}; -const ht = () => { - const e = useRecord(), - t = (o) => { - const a = o.title, - r = o.parent; - return r ? t(r) + ' / ' + a : a; - }; - return jsx(Fragment, { children: t(e) }); -}; -const ft = (e) => { - const t = { - resource: 'departments', - action: 'list', - params: { appends: ['roles', 'parent(recursively=true)'], sort: ['createdAt'] }, - }, - o = useRequest(t, e); - return T(y({}, o), { defaultRequest: t }); -}; -const vt = () => { - const { role: e } = useContext(RolesManagerContext); - return { - disabled: (t) => { - var o; - return (o = t == null ? void 0 : t.roles) == null - ? void 0 - : o.some((a) => a.name === (e == null ? void 0 : e.name)); - }, - }; -}; -const gt = () => { - const { role: e } = useContext(RolesManagerContext), - t = useAPIClient(), - o = useForm(), - { setVisible: a } = useActionContext(), - { refresh: r } = useResourceActionContext(), - { departments: c } = o.values || {}; - return { - run() { - return k(this, null, function* () { - yield t.resource('roles.departments', e.name).add({ values: c.map((x) => x.id) }), o.reset(), a(false), r(); - }); - }, - }; -}; -const Departments = () => { - const { t: e } = useTranslation(), - { role: t } = useContext(RolesManagerContext), - o = useRequest( - { - resource: `roles/${t == null ? void 0 : t.name}/departments`, - action: 'list', - params: { appends: ['parent', 'parent.parent(recursively=true)'] }, - }, - { ready: !!t }, - ); - useEffect(() => { - o.run(); - }, [t]); - const a = useMemo(() => dt(), [t]); - return jsx(ResourceActionContext.Provider, { - value: y({}, o), - children: jsx(CollectionProvider_deprecated, { - collection: Q, - children: jsx(SchemaComponent, { - schema: a, - components: { DepartmentTable: pe, DepartmentTitle: ht }, - scope: { - useFilterActionProps: Z, - t: e, - useRemoveDepartment: xt, - useBulkRemoveDepartments: yt, - useDataSource: ft, - useDisabled: vt, - useAddDepartments: gt, - }, - }), - }), - }); -}; -const UserDepartmentsField = connect(() => { - const { t: e } = useTranslation(); - return jsxs('div', { - style: { color: '#ccc' }, - children: [e('This field is currently not supported for use in form blocks.'), ' '], - }); -}, mapReadPretty(AssociationField.ReadPretty)); -const te = { - name: 'titleField', - type: 'select', - useComponentProps() { - var b, h, F, C; - const { t: e } = useTranslation(), - t = useField(), - { dn: o } = useDesignable(), - a = useTitleFieldOptions(), - { uiSchema: r, fieldSchema: c, collectionField: i } = oe(), - x = useFieldSchema(), - m = c || x, - g = useCollectionField(), - d = i || g, - A = y( - y( - y( - {}, - (h = (b = d == null ? void 0 : d.uiSchema) == null ? void 0 : b['x-component-props']) == null - ? void 0 - : h.fieldNames, - ), - (F = t == null ? void 0 : t.componentProps) == null ? void 0 : F.fieldNames, - ), - (C = m == null ? void 0 : m['x-component-props']) == null ? void 0 : C.fieldNames, - ); - return { - title: e('Title field'), - options: a, - value: A == null ? void 0 : A.label, - onChange(v) { - var S, O, $, W, H, J; - const l = { 'x-uid': m['x-uid'] }, - u = T( - y( - y( - {}, - (O = (S = d == null ? void 0 : d.uiSchema) == null ? void 0 : S['x-component-props']) == null - ? void 0 - : O.fieldNames, - ), - ($ = m['x-component-props']) == null ? void 0 : $.fieldNames, - ), - { label: v }, - ); - (m['x-component-props'] = m['x-component-props'] || {}), - (m['x-component-props'].fieldNames = u), - (l['x-component-props'] = m['x-component-props']), - (t.componentProps.fieldNames = (W = m['x-component-props']) == null ? void 0 : W.fieldNames); - const f = (J = t.path) == null ? void 0 : J.splice(((H = t.path) == null ? void 0 : H.length) - 1, 1); - t.form.query(`${f.concat('*.' + m.name)}`).forEach((M) => { - M.componentProps.fieldNames = A; - }), - o.emit('patch', { schema: l }), - o.refresh(); - }, - }; - }, -}; -const bt = (e) => e['x-component'] === 'CollectionField'; -const oe = () => { - const { getField: e } = useCollection_deprecated(), - t = useCompile(), - o = useFieldSchema(), - { getCollectionJoinField: a } = useCollectionManager_deprecated(), - r = o.reduceProperties((i, x) => (bt(x) ? x : i), null); - if (!r) return {}; - const c = e(r.name) || a(r == null ? void 0 : r['x-collection-field']); - return { columnSchema: o, fieldSchema: r, collectionField: c, uiSchema: t(c == null ? void 0 : c.uiSchema) }; -}; -const ne = { - name: 'enableLink', - type: 'switch', - useVisible() { - return useField().readPretty; - }, - useComponentProps() { - var i; - const { t: e } = useTranslation(), - t = useField(), - { fieldSchema: o } = oe(), - a = useFieldSchema(), - r = o || a, - { dn: c } = useDesignable(); - return { - title: e('Enable link'), - checked: ((i = r['x-component-props']) == null ? void 0 : i.enableLink) !== false, - onChange(x) { - (r['x-component-props'] = T(y({}, r == null ? void 0 : r['x-component-props']), { enableLink: x })), - (t.componentProps.enableLink = x), - c.emit('patch', { - schema: { - 'x-uid': r['x-uid'], - 'x-component-props': y({}, r == null ? void 0 : r['x-component-props']), - }, - }), - c.refresh(); - }, - }; - }, -}; -const re = { - name: 'fieldComponent', - type: 'select', - useComponentProps() { - const { t: e } = useTranslation(), - t = useField(), - { fieldSchema: o, collectionField: a } = oe(), - r = useFieldSchema(), - c = o || r, - i = useFieldModeOptions({ fieldSchema: o, collectionField: a }), - { dn: x } = useDesignable(); - return { - title: e('Field component'), - options: i, - value: 'Select', - onChange(m) { - const g = { 'x-uid': c['x-uid'] }; - (c['x-component-props'] = c['x-component-props'] || {}), - (c['x-component-props'].mode = m), - (g['x-component-props'] = c['x-component-props']), - (t.componentProps = t.componentProps || {}), - (t.componentProps.mode = m), - x.emit('patch', { schema: g }), - x.refresh(); - }, - }; - }, -}; -const At = new SchemaSettings({ - name: 'fieldSettings:component:UserDepartmentsField', - items: [{ ...re }, { ...te }, { ...ne }], -}); -const St = new SchemaSettings({ - name: 'fieldSettings:component:UserMainDepartmentField', - items: [{ ...re }, { ...te }, { ...ne }], -}); -const Dt = new SchemaSettings({ - name: 'fieldSettings:component:DepartmentOwnersField', - items: [{ ...re }, { ...te }, { ...ne }], -}); export class DepartmentsPlugin extends Plugin { async load() { this.app.addComponents({ @@ -2455,18 +20,26 @@ export class DepartmentsPlugin extends Plugin { UserMainDepartmentField: UserDepartmentsField, DepartmentOwnersField: UserDepartmentsField, }); - this.app.schemaSettingsManager.add(At); - this.app.schemaSettingsManager.add(St); - this.app.schemaSettingsManager.add(Dt); + this.app.schemaSettingsManager.add(UserDepartmentsFieldSetting); + this.app.schemaSettingsManager.add(UserMainDepartmentFieldSetting); + this.app.schemaSettingsManager.add(DepartmentOwnersFieldSetting); this.app.pluginSettingsManager.add('users-permissions.departments', { icon: 'ApartmentOutlined', title: tval('Departments'), Component: () => { - const o = useSchemaComponentContext(); - return jsx(SchemaComponentContext.Provider, { - value: T({ ...o }, { designable: false }), - children: jsx(ge, { children: jsx(mt, {}) }), - }); + const context = useSchemaComponentContext(); + // return jsx(SchemaComponentContext.Provider, { + // value: T({ ...o }, { designable: false }), + // children: jsx(GeComponent, { children: jsx(MmtComponent, {}) }), + // }); + + return ( + + + + + + ); }, sort: 2, aclSnippet: 'pm.departments', diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/items/neItems.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/items/neItems.tsx new file mode 100644 index 000000000..7437323aa --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/items/neItems.tsx @@ -0,0 +1,47 @@ +import { useDesignable } from '@tachybase/client'; +import { useField, useFieldSchema } from '@tachybase/schema'; +import { useTranslation } from '../../../locale'; +import { useHooksOoe } from '../hooks/useHooksOoe'; + +export const neItems = { + name: 'enableLink', + type: 'switch', + useVisible() { + return useField().readPretty; + }, + useComponentProps() { + var i; + const { t: e } = useTranslation(); + const field = useField(); + const { fieldSchema: newFieldSchema } = useHooksOoe(); + const oldFieldSchema = useFieldSchema(); + const fieldSchema = newFieldSchema || oldFieldSchema; + const { dn: c } = useDesignable(); + return { + title: e('Enable link'), + checked: ((i = fieldSchema['x-component-props']) == null ? void 0 : i.enableLink) !== false, + onChange(x) { + // fieldSchema['x-component-props'] = T( + // y({}, fieldSchema == null ? void 0 : fieldSchema['x-component-props']), + // { + // enableLink: x, + // }); + fieldSchema['x-component-props'] = { + ...fieldSchema?.['x-component-props'], + enableLink: x, + }; + field.componentProps.enableLink = x; + c.emit('patch', { + schema: { + 'x-uid': fieldSchema['x-uid'], + // 'x-component-props': y({}, fieldSchema == null ? void 0 : fieldSchema['x-component-props']), + 'x-component-props': { + ...fieldSchema?.['x-component-props'], + }, + }, + }); + c.refresh(); + }, + }; + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/items/reItems.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/items/reItems.tsx new file mode 100644 index 000000000..5fb77c3fd --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/items/reItems.tsx @@ -0,0 +1,33 @@ +import { useFieldModeOptions, useDesignable } from '@tachybase/client'; +import { useField, useFieldSchema } from '@tachybase/schema'; +import { useTranslation } from '../../../locale'; +import { useHooksOoe } from '../hooks/useHooksOoe'; + +export const reItems = { + name: 'fieldComponent', + type: 'select', + useComponentProps() { + const { t: e } = useTranslation(), + t = useField(), + { fieldSchema: o, collectionField: a } = useHooksOoe(), + r = useFieldSchema(), + c = o || r, + i = useFieldModeOptions({ fieldSchema: o, collectionField: a }), + { dn: x } = useDesignable(); + return { + title: e('Field component'), + options: i, + value: 'Select', + onChange(m) { + const g = { 'x-uid': c['x-uid'] }; + (c['x-component-props'] = c['x-component-props'] || {}), + (c['x-component-props'].mode = m), + (g['x-component-props'] = c['x-component-props']), + (t.componentProps = t.componentProps || {}), + (t.componentProps.mode = m), + x.emit('patch', { schema: g }), + x.refresh(); + }, + }; + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/items/teItems.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/items/teItems.tsx new file mode 100644 index 000000000..689a88264 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/items/teItems.tsx @@ -0,0 +1,66 @@ +import { useCollectionField, useTitleFieldOptions, useDesignable } from '@tachybase/client'; +import { useField, useFieldSchema } from '@tachybase/schema'; +import { useTranslation } from '../../../locale'; +import { useHooksOoe } from '../hooks/useHooksOoe'; +import { y } from '../others/y'; +import { T } from '../others/T'; + +export const teItems = { + name: 'titleField', + type: 'select', + useComponentProps() { + var b, h, F, C; + const { t: e } = useTranslation(), + t = useField(), + { dn: o } = useDesignable(), + a = useTitleFieldOptions(), + { uiSchema: r, fieldSchema: c, collectionField: i } = useHooksOoe(), + x = useFieldSchema(), + m = c || x, + g = useCollectionField(), + d = i || g, + A = y( + y( + y( + {}, + (h = (b = d == null ? void 0 : d.uiSchema) == null ? void 0 : b['x-component-props']) == null + ? void 0 + : h.fieldNames, + ), + (F = t == null ? void 0 : t.componentProps) == null ? void 0 : F.fieldNames, + ), + (C = m == null ? void 0 : m['x-component-props']) == null ? void 0 : C.fieldNames, + ); + return { + title: e('Title field'), + options: a, + value: A == null ? void 0 : A.label, + onChange(v) { + var S, O, $, W, H, J; + const l = { 'x-uid': m['x-uid'] }, + u = T( + y( + y( + {}, + (O = (S = d == null ? void 0 : d.uiSchema) == null ? void 0 : S['x-component-props']) == null + ? void 0 + : O.fieldNames, + ), + ($ = m['x-component-props']) == null ? void 0 : $.fieldNames, + ), + { label: v }, + ); + (m['x-component-props'] = m['x-component-props'] || {}), + (m['x-component-props'].fieldNames = u), + (l['x-component-props'] = m['x-component-props']), + (t.componentProps.fieldNames = (W = m['x-component-props']) == null ? void 0 : W.fieldNames); + const f = (J = t.path) == null ? void 0 : J.splice(((H = t.path) == null ? void 0 : H.length) - 1, 1); + t.form.query(`${f.concat('*.' + m.name)}`).forEach((M) => { + M.componentProps.fieldNames = A; + }), + o.emit('patch', { schema: l }), + o.refresh(); + }, + }; + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/others/T.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/T.tsx new file mode 100644 index 000000000..03c3bdc19 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/T.tsx @@ -0,0 +1,4 @@ +// NOTE: ohters 文件里都是工具函数, 替换后可删除 +import { Ft, Mt } from './wt'; + +export var T = (w, s) => Ft(w, Mt(s)); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/others/de.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/de.tsx new file mode 100644 index 000000000..65d5f19f4 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/de.tsx @@ -0,0 +1,4 @@ +import { wt } from './wt'; + +export var de = (w, s, n) => + s in w ? wt(w, s, { enumerable: true, configurable: true, writable: true, value: n }) : (w[s] = n); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/others/k.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/k.tsx new file mode 100644 index 000000000..2d18f6a3f --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/k.tsx @@ -0,0 +1,19 @@ +export var k = (w, s, n) => + new Promise((D, p) => { + var j = (V) => { + try { + N(n.next(V)); + } catch (I) { + p(I); + } + }, + Y = (V) => { + try { + N(n.throw(V)); + } catch (I) { + p(I); + } + }, + N = (V) => (V.done ? D(V.value) : Promise.resolve(V.value).then(j, Y)); + N((n = n.apply(w, s)).next()); + }); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/others/wt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/wt.tsx new file mode 100644 index 000000000..d0fcc323d --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/wt.tsx @@ -0,0 +1,6 @@ +export var wt = Object.defineProperty; +export var Ft = Object.defineProperties; +export var Mt = Object.getOwnPropertyDescriptors; +export var me = Object.getOwnPropertySymbols; +export var Tt = Object.prototype.hasOwnProperty; +export var It = Object.prototype.propertyIsEnumerable; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/others/y.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/y.tsx new file mode 100644 index 000000000..a92a42d17 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/others/y.tsx @@ -0,0 +1,8 @@ +import { de } from './de'; +import { Tt, me, It } from './wt'; + +export var y = (w, s) => { + for (var n in s || (s = {})) Tt.call(s, n) && de(w, n, s[n]); + if (me) for (var n of me(s)) It.call(s, n) && de(w, n, s[n]); + return w; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/refined.backup.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/refined.backup.tsx new file mode 100644 index 000000000..e30209830 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/refined.backup.tsx @@ -0,0 +1,2312 @@ +// NOTE: 全部整理完后, 确认运行一段时间, 无误后, 再删除此文件 +// 同时,删除注释代码 +// 删除无用引用 + +// 1. 拆解 refined 文件, 根据归类原则 +// 2. 反编译文件 +// 3. 根据功能进行归类, 根据就近原则 +/* eslint-disable */ +import { MoreOutlined, PlusOutlined, UserOutlined } from '@ant-design/icons'; +import { + CollectionContext, + ResourceActionProvider, + useFilterFieldProps, + useCollectionManager_deprecated, + useCompile, + useCollection_deprecated, + mergeFilter, + removeNullCondition, + Checkbox, + EllipsisWithTooltip, + CollectionProvider_deprecated, + RecordProvider, + ResourceActionContext, + SchemaComponent, + ActionContextProvider, + createStyles, + css, + useAPIClient, + useActionContext, + SchemaComponentOptions, + useFilterFieldOptions, + useRecord, + useRequest, + useResourceActionContext, +} from '@tachybase/client'; +import { RolesManagerContext } from '@tachybase/plugin-acl/client'; +import { uid, useField, useFieldSchema, useForm } from '@tachybase/schema'; +import { + App, + Button, + Col, + Divider, + Dropdown, + Empty, + Input, + Row, + Select, + Table, + Tag, + Tree, + TreeSelect, + theme, +} from 'antd'; +import React, { useCallback, useContext, useEffect, useMemo, useRef, useState, Fragment } from 'react'; +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useTranslation } from '../../locale'; + +var wt = Object.defineProperty, + Ft = Object.defineProperties; +var Mt = Object.getOwnPropertyDescriptors; +var me = Object.getOwnPropertySymbols; +var Tt = Object.prototype.hasOwnProperty, + It = Object.prototype.propertyIsEnumerable; +export var de = (w, s, n) => + s in w ? wt(w, s, { enumerable: true, configurable: true, writable: true, value: n }) : (w[s] = n), + y = (w, s) => { + for (var n in s || (s = {})) Tt.call(s, n) && de(w, n, s[n]); + if (me) for (var n of me(s)) It.call(s, n) && de(w, n, s[n]); + return w; + }, + T = (w, s) => Ft(w, Mt(s)); +var k = (w, s, n) => + new Promise((D, p) => { + var j = (V) => { + try { + N(n.next(V)); + } catch (I) { + p(I); + } + }, + Y = (V) => { + try { + N(n.throw(V)); + } catch (I) { + p(I); + } + }, + N = (V) => (V.done ? D(V.value) : Promise.resolve(V.value).then(j, Y)); + N((n = n.apply(w, s)).next()); + }); +const xe = () => { + const { t: e } = useTranslation(); + return jsx(SchemaComponent, { + scope: { t: e }, + schema: { + type: 'void', + properties: { + newDepartment: { + type: 'void', + title: e('New department'), + 'x-component': 'Action', + 'x-component-props': { type: 'text', icon: 'PlusOutlined', style: { width: '100%', textAlign: 'left' } }, + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + title: e('New department'), + properties: { + title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem', required: true }, + parent: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.parent', + 'x-component-props': { component: 'DepartmentSelect' }, + }, + roles: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.roles', + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }); +}; +const ye = { + type: 'object', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + 'x-decorator-props': { + useValues(e) { + const t = useActionContext(), + o = useRecord(); + return useRequest( + () => Promise.resolve({ data: { parent: { ...o } } }), + T({ ...e }, { refreshDeps: [t.visible] }), + ); + }, + }, + title: '{{t("New sub department")}}', + properties: { + title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem' }, + parent: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.parent', + 'x-component-props': { component: 'DepartmentSelect' }, + }, + roles: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.roles', + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' }, + }, + }, + }, + }, + }, + }, +}; +const he = { + type: 'object', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + 'x-decorator-props': { + useValues(e) { + const t = useAPIClient(), + o = useActionContext(), + a = useRecord(), + r = useRequest( + () => + t + .resource('departments') + .get({ filterByTk: a.id, appends: ['parent(recursively=true)', 'roles', 'owners'] }) + .then((c) => (c == null ? void 0 : c.data)), + T({ ...e }, { manual: true }), + ); + return ( + useEffect(() => { + o.visible && r.run(); + }, [o.visible]), + r + ); + }, + }, + title: '{{t("Edit department")}}', + properties: { + title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem' }, + parent: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.parent', + 'x-component-props': { component: 'SuperiorDepartmentSelect' }, + }, + roles: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.roles', + }, + owners: { title: '{{t("Owners")}}', 'x-component': 'DepartmentOwnersField', 'x-decorator': 'FormItem' }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useUpdateDepartment }}' }, + }, + }, + }, + }, + }, + }, +}; +const fe = { + type: 'void', + properties: { + drawer: { + title: '{{t("Select Owners")}}', + 'x-component': 'Action.Drawer', + properties: { + resource: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'RequestProvider', + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + filter: { + type: 'void', + title: '{{ t("Filter") }}', + default: { $and: [{ username: { $includes: '' } }, { nickname: { $includes: '' } }] }, + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + }, + }, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { type: 'checkbox', onChange: '{{ handleSelect }}' }, + useDataSource: '{{ cm.useDataSourceFromRAC }}', + }, + properties: { + username: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + nickname: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + phone: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + email: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + }, + }, + }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + confirm: { + title: '{{t("Confirm")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useSelectOwners }}' }, + }, + }, + }, + }, + }, + }, + }, + Q = { + name: 'departments', + fields: [ + { + type: 'bigInt', + name: 'id', + primaryKey: true, + autoIncrement: true, + interface: 'id', + uiSchema: { type: 'id', title: '{{t("ID")}}' }, + }, + { + name: 'title', + type: 'string', + interface: 'input', + uiSchema: { type: 'string', title: '{{t("Department name")}}', 'x-component': 'Input', required: true }, + }, + { + name: 'parent', + type: 'belongsTo', + interface: 'm2o', + collectionName: 'departments', + foreignKey: 'parentId', + target: 'departments', + targetKey: 'id', + treeParent: true, + uiSchema: { title: '{{t("Superior department")}}', 'x-component': 'DepartmentSelect' }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'roles', + target: 'roles', + collectionName: 'departments', + through: 'departmentsRoles', + foreignKey: 'departmentId', + otherKey: 'roleName', + targetKey: 'name', + sourceKey: 'id', + uiSchema: { + title: '{{t("Roles")}}', + 'x-component': 'AssociationField', + 'x-component-props': { multiple: true, fieldNames: { label: 'title', value: 'name' } }, + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'owners', + collectionName: 'departments', + target: 'users', + through: 'departmentsUsers', + foreignKey: 'departmentId', + otherKey: 'userId', + targetKey: 'id', + sourceKey: 'id', + scope: { isOwner: true }, + uiSchema: { + title: '{{t("Owners")}}', + 'x-component': 'AssociationField', + 'x-component-props': { multiple: true, fieldNames: { label: 'nickname', value: 'id' } }, + }, + }, + ], + }; +const ve = { + name: 'users', + fields: [ + { + name: 'id', + type: 'bigInt', + autoIncrement: true, + primaryKey: true, + allowNull: false, + uiSchema: { type: 'number', title: '{{t("ID")}}', 'x-component': 'InputNumber', 'x-read-pretty': true }, + interface: 'id', + }, + { + interface: 'input', + type: 'string', + name: 'nickname', + uiSchema: { type: 'string', title: '{{t("Nickname")}}', 'x-component': 'Input' }, + }, + { + interface: 'input', + type: 'string', + name: 'username', + unique: true, + uiSchema: { + type: 'string', + title: '{{t("Username")}}', + 'x-component': 'Input', + 'x-validator': { username: true }, + required: true, + }, + }, + { + interface: 'email', + type: 'string', + name: 'email', + unique: true, + uiSchema: { + type: 'string', + title: '{{t("Email")}}', + 'x-component': 'Input', + 'x-validator': 'email', + required: true, + }, + }, + { + interface: 'phone', + type: 'string', + name: 'phone', + unique: true, + uiSchema: { + type: 'string', + title: '{{t("Phone")}}', + 'x-component': 'Input', + 'x-validator': 'phone', + required: true, + }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'roles', + target: 'roles', + foreignKey: 'userId', + otherKey: 'roleName', + onDelete: 'CASCADE', + sourceKey: 'id', + targetKey: 'name', + through: 'rolesUsers', + uiSchema: { + type: 'array', + title: '{{t("Roles")}}', + 'x-component': 'AssociationField', + 'x-component-props': { multiple: true, fieldNames: { label: 'title', value: 'name' } }, + }, + }, + { + name: 'departments', + type: 'belongsToMany', + interface: 'm2m', + target: 'departments', + foreignKey: 'userId', + otherKey: 'departmentId', + onDelete: 'CASCADE', + sourceKey: 'id', + targetKey: 'id', + through: 'departmentsUsers', + uiSchema: { type: 'array', title: '{{t("Departments")}}', 'x-component': 'DepartmentField' }, + }, + { + interface: 'm2m', + type: 'belongsToMany', + name: 'mainDepartment', + target: 'departments', + foreignKey: 'userId', + otherKey: 'departmentId', + onDelete: 'CASCADE', + sourceKey: 'id', + targetKey: 'id', + through: 'departmentsUsers', + throughScope: { isMain: true }, + uiSchema: { type: 'array', title: '{{t("Main department")}}', 'x-component': 'DepartmentField' }, + }, + ], +}; +const K = React.createContext({ user: {}, department: {} }); +export const GeComponent = (e) => { + const [t, o] = useState(null), + [a, r] = useState(null), + c = useRequest({ + resource: 'users', + action: 'list', + params: { + appends: ['departments', 'departments.parent(recursively=true)'], + filter: a ? { 'departments.id': a.id } : {}, + pageSize: 50, + }, + }); + useEffect(() => { + c.run(); + }, [a]); + const i = { resource: 'departments', action: 'list', params: { pagination: false, filter: { parentId: null } } }, + x = useRequest(i); + return jsx(K.Provider, { + value: { + user: t, + setUser: o, + department: a, + setDepartment: r, + usersResource: { service: c }, + departmentsResource: { service: x }, + }, + children: e.children, + }); +}; +const Ce = (e) => { + const { departmentsResource: t } = useContext(K), + { service: o } = t || {}; + return jsx(ResourceActionContext.Provider, { + value: { ...o }, + children: jsx(CollectionProvider_deprecated, { collection: Q, children: e.children }), + }); +}; +const be = (e) => { + const { usersResource: t } = useContext(K), + { service: o } = t || {}; + return jsx(ResourceActionContext.Provider, { + value: { ...o }, + children: jsx(CollectionProvider_deprecated, { collection: ve, children: e.children }), + }); +}; +const X = () => { + const { data: e, loading: t } = useResourceActionContext(), + { department: o, setDepartment: a, setUser: r } = useContext(K), + { + treeData: c, + nodeMap: i, + loadData: x, + loadedKeys: m, + setLoadedKeys: g, + initData: d, + expandedKeys: A, + setExpandedKeys: b, + } = useContext(_), + h = (v) => { + if (!v.length) return; + const l = i[v[0]]; + a(l), r(null); + }, + F = (v) => { + b(v); + }, + C = (v) => { + g(v); + }; + return ( + useEffect(() => { + d(e == null ? void 0 : e.data); + }, [e, d, t]), + useEffect(() => { + if (!o) return; + const v = (u) => (u.parent ? [u.parent.id, ...v(u.parent)] : []), + l = v(o); + b((u) => Array.from(new Set([...u, ...l]))); + }, [o, b]), + jsx('div', { + className: css` + height: 57vh; + overflow: auto; + .ant-tree-node-content-wrapper { + overflow: hidden; + } + `, + children: + c != null && c.length + ? jsx(Tree.DirectoryTree, { + loadData: x, + treeData: c, + loadedKeys: m, + onSelect: h, + selectedKeys: [o == null ? void 0 : o.id], + onExpand: F, + onLoad: C, + expandedKeys: A, + expandAction: false, + showIcon: false, + fieldNames: { key: 'id' }, + }) + : jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE }), + }) + ); +}; +X.Item = function ({ node: t, setVisible: o, setDrawer: a }) { + const { t: r } = useTranslation(), + { refreshAsync: c } = useResourceActionContext(), + { setLoadedKeys: i, expandedKeys: x, setExpandedKeys: m } = useContext(_), + { modal: g, message: d } = App.useApp(), + A = useAPIClient(), + b = () => { + g.confirm({ + title: r('Delete'), + content: r('Are you sure you want to delete it?'), + onOk: () => + k(this, null, function* () { + yield A.resource('departments').destroy({ filterByTk: t.id }), + d.success(r('Deleted successfully')), + m((v) => v.filter((l) => l !== t.id)); + const C = [...x]; + i([]), m([]), yield c(), m(C); + }), + }); + }, + h = (C) => { + a({ schema: C, node: t }), o(true); + }, + F = ({ key: C, domEvent: v }) => { + switch ((v.stopPropagation(), C)) { + case 'new-sub': + h(ye); + break; + case 'edit': + h(he); + break; + case 'delete': + b(); + } + }; + return jsxs('div', { + style: { display: 'flex', justifyContent: 'space-between', overflow: 'hidden' }, + children: [ + jsx('div', { + style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, + children: t.title, + }), + jsx(Dropdown, { + menu: { + items: [ + { label: r('New sub department'), key: 'new-sub' }, + { label: r('Edit department'), key: 'edit' }, + { label: r('Delete department'), key: 'delete' }, + ], + onClick: F, + }, + children: jsx('div', { + style: { marginLeft: '15px' }, + children: jsx(MoreOutlined, {}), + }), + }), + ], + }); +}; +const Ae = createStyles(({ css: e }) => ({ + searchDropdown: e` + .ant-dropdown-menu { + max-height: 500px; + overflow-y: scroll; + } + `, +})); +const Se = () => { + const { t: e } = useTranslation(), + { token: t } = theme.useToken(), + { setDepartment: o, setUser: a } = useContext(K), + [r, c] = useState(false), + [i, x] = useState(''), + [m, g] = useState([]), + [d, A] = useState([]), + [b, h] = useState(true), + [F, C] = useState(true), + { styles: v } = Ae(), + l = 10, + u = useAPIClient(), + f = useRequest( + (M) => + u + .resource('departments') + .aggregateSearch(M) + .then((P) => { + var q; + return (q = P == null ? void 0 : P.data) == null ? void 0 : q.data; + }), + { + manual: true, + onSuccess: (M, P) => { + const { + values: { type: q }, + } = P[0] || {}; + M && + ((!q || q === 'user') && M.users.length < l && h(false), + (!q || q === 'department') && M.departments.length < l && C(false), + g((se) => [...se, ...M.users]), + A((se) => [...se, ...M.departments])); + }, + }, + ), + { run: S } = f, + O = (M) => { + x(M), g([]), A([]), h(true), C(true), M && (S({ values: { keyword: M, limit: l } }), c(true)); + }, + $ = (M) => { + M.target.value || (a(null), x(''), c(false), f.mutate({}), g([]), A([])); + }, + W = (M) => { + const P = M.title, + q = M.parent; + return q ? W(q) + ' / ' + P : P; + }, + H = (M) => + jsx(Button, { + type: 'link', + style: { padding: '0 8px' }, + onClick: (P) => { + c(true), S({ values: { keyword: i, limit: l, ...M } }); + }, + children: e('Load more'), + }), + J = () => { + const M = []; + return !m.length && !d.length + ? [ + { + key: '0', + label: jsx(Empty, { + description: e('No results'), + image: Empty.PRESENTED_IMAGE_SIMPLE, + }), + disabled: true, + }, + ] + : (m.length && + (M.push({ + key: '0', + type: 'group', + label: e('Users'), + children: m.map((P) => ({ + key: P.username, + label: jsxs('div', { + onClick: () => a(P), + children: [ + jsx('div', { children: P.nickname || P.username }), + jsx('div', { + style: { fontSize: t.fontSizeSM, color: t.colorTextDescription }, + children: `${P.username}${P.phone ? ' | ' + P.phone : ''}${P.email ? ' | ' + P.email : ''}`, + }), + ], + }), + })), + }), + b && + M.push({ + type: 'group', + key: '0-loadMore', + label: jsx(H, { type: 'user', last: m[m.length - 1].id }), + })), + d.length && + (M.push({ + key: '1', + type: 'group', + label: e('Departments'), + children: d.map((P) => ({ + key: P.id, + label: jsx('div', { onClick: () => o(P), children: W(P) }), + })), + }), + F && + M.push({ + type: 'group', + key: '1-loadMore', + label: jsx(H, { type: 'department', last: d[d.length - 1].id }), + })), + M); + }; + return jsx(Dropdown, { + menu: { items: J() }, + overlayClassName: v.searchDropdown, + trigger: ['click'], + open: r, + onOpenChange: (M) => c(M), + children: jsx(Input.Search, { + allowClear: true, + onClick: () => { + i || c(false); + }, + onFocus: () => o(null), + onSearch: O, + onChange: $, + placeholder: e('Search for departments, users'), + style: { marginBottom: '20px' }, + }), + }); +}; +const De = (e) => { + const { label: t } = e || {}, + [o, a] = useState([]), + [r, c] = useState({}), + [i, x] = useState([]), + [m, g] = useState([]), + d = useCallback((C) => { + const v = {}, + l = (f) => { + let S = f ? { ...f } : null; + for (; S; ) { + const O = S.parentId || 'root'; + v[O] + ? (v[O].childrenMap[S.id] = S) + : (v[O] = T({ ...(S.parent || { id: O }) }, { childrenMap: { [S.id]: S } })), + (S = S.parent); + } + }, + u = (f) => { + const S = {}; + f.children && + f.children.length && + f.children.forEach((O) => { + (S[O.id] = O), u(O); + }), + (v[f.id] = T({ ...f }, { childrenMap: S })); + }; + return ( + C && + C.length && + C.forEach((f) => { + l(f), u(f); + }), + v + ); + }, []), + A = useCallback((C) => { + const v = (l) => { + var u; + return !C[l] || C[l].isLeaf + ? null + : Object.values(((u = C[l]) == null ? void 0 : u.childrenMap) || {}).map((f: object) => + T({ ...f }, { title: t ? React.createElement(t, { node: f }) : f.title, children: v(f.id) }), + ); + }; + return v('root'); + }, []), + b = useCallback( + (C) => { + const v = d(C); + c(v); + const l = A(v) || []; + a(l); + }, + [a, d, A], + ), + h = (C, v) => { + const l = d(v), + u = { ...l, ...r }; + return ( + v.forEach((f) => { + u[C].childrenMap[f.id] = f; + }), + c(u), + A(u) + ); + }, + F = useCallback( + (C) => { + if (!r[C]) return []; + const v = []; + return ( + v.push(...Object.keys(r[C].childrenMap).map((l) => Number(l))), + Object.keys(r[C].childrenMap).forEach((l) => { + v.push(...F(l)); + }), + v + ); + }, + [r], + ); + return { + initData: b, + treeData: o, + setTreeData: a, + nodeMap: r, + updateTreeData: h, + constructTreeData: A, + getChildrenIds: F, + loadedKeys: m, + setLoadedKeys: g, + expandedKeys: i, + setExpandedKeys: x, + }; +}; +function we(e) { + return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, 'default') ? e.default : e; +} +var Fe = function (t) { + return Me(t) && !Te(t); +}; +function Me(e) { + return !!e && typeof e == 'object'; +} +function Te(e) { + var t = Object.prototype.toString.call(e); + return t === '[object RegExp]' || t === '[object Date]' || Pe(e); +} +var Ie = typeof Symbol == 'function' && Symbol.for, + Oe = Ie ? Symbol.for('react.element') : 60103; +function Pe(e) { + return e.$$typeof === Oe; +} +function ke(e) { + return Array.isArray(e) ? [] : {}; +} +function L(e, t) { + return t.clone !== false && t.isMergeableObject(e) ? B(ke(e), e, t) : e; +} +function Ee(e, t, o) { + return e.concat(t).map(function (a) { + return L(a, o); + }); +} +function Ke(e, t) { + if (!t.customMerge) return B; + var o = t.customMerge(e); + return typeof o == 'function' ? o : B; +} +function Ne(e) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(e).filter(function (t) { + return Object.propertyIsEnumerable.call(e, t); + }) + : []; +} +function ae(e) { + return Object.keys(e).concat(Ne(e)); +} +function ce(e, t) { + try { + return t in e; + } catch (o) { + return false; + } +} +function qe(e, t) { + return ce(e, t) && !(Object.hasOwnProperty.call(e, t) && Object.propertyIsEnumerable.call(e, t)); +} +function Ve(e, t, o) { + var a = {}; + return ( + o.isMergeableObject(e) && + ae(e).forEach(function (r) { + a[r] = L(e[r], o); + }), + ae(t).forEach(function (r) { + qe(e, r) || (ce(e, r) && o.isMergeableObject(t[r]) ? (a[r] = Ke(r, o)(e[r], t[r], o)) : (a[r] = L(t[r], o))); + }), + a + ); +} +function B(e, t, o) { + (o = o || {}), + (o.arrayMerge = o.arrayMerge || Ee), + (o.isMergeableObject = o.isMergeableObject || Fe), + (o.cloneUnlessOtherwiseSpecified = L); + var a = Array.isArray(t), + r = Array.isArray(e), + c = a === r; + return c ? (a ? o.arrayMerge(e, t, o) : Ve(e, t, o)) : L(t, o); +} +B.all = function (t, o) { + if (!Array.isArray(t)) throw new Error('first argument should be an array'); + return t.reduce(function (a, r) { + return B(a, r, o); + }, {}); +}; +const je = B; +const Ue = je; +const ie = we(Ue); +const G = (e) => { + const { resource: t = 'departments', resourceOf: o, params: a = {} } = e || {}, + c = useAPIClient().resource(t, o), + i = De(e), + { setTreeData: x, updateTreeData: m, setLoadedKeys: g, initData: d } = i, + A = (C) => + k(this, [C], function* ({ key: h, children: F }) { + var l; + if (F != null && F.length) return; + const { data: v } = yield c.list( + ie(a, { pagination: false, appends: ['parent(recursively=true)'], filter: { parentId: h } }), + ); + (l = v == null ? void 0 : v.data) != null && l.length && x(m(h, v == null ? void 0 : v.data)); + }), + b = (h) => + k(this, null, function* () { + const { data: F } = yield c.list( + ie(a, { + pagination: false, + filter: { title: { $includes: h } }, + appends: ['parent(recursively=true)'], + pageSize: 100, + }), + ); + d(F == null ? void 0 : F.data); + }); + return T({ ...i }, { loadData: A, getByKeyword: b }); +}; +const Z = () => { + var a, r; + const e = useContext(CollectionContext), + t = useFilterFieldOptions(e.fields), + o = useResourceActionContext(); + return useFilterFieldProps({ + options: t, + params: ((r = (a = o.state) == null ? void 0 : a.params) == null ? void 0 : r[0]) || o.params, + service: o, + }); +}; +const Be = () => { + const [e, t] = useState(false), + o = useRecord(), + a = useField(), + [r, c] = useState([]), + i = useRef([]), + x = (d, A) => { + i.current = A; + }, + m = () => { + const { setVisible: d } = useActionContext(); + return { + run() { + const A = a.value || []; + a.setValue([...A, ...i.current]), (i.current = []), d(false); + }, + }; + }; + useEffect(() => { + a.value && c(a.value.map((d) => ({ value: d.id, label: d.nickname || d.username }))); + }, [a.value]); + const g = (d) => { + var A; + return jsx(ResourceActionProvider, { + collection: 'users', + request: { + resource: `departments/${o.id}/members`, + action: 'list', + params: { filter: (A = a.value) != null && A.length ? { id: { $notIn: a.value.map((b) => b.id) } } : {} }, + }, + children: d.children, + }); + }; + return jsxs(ActionContextProvider, { + value: { visible: e, setVisible: t }, + children: [ + jsx(Select, { + open: false, + onChange: (d) => { + if (!d) { + a.setValue([]); + return; + } + a.setValue(d.map(({ label: A, value: b }) => ({ id: b, nickname: A }))); + }, + mode: 'multiple', + value: r, + labelInValue: true, + onDropdownVisibleChange: (d) => t(d), + }), + jsx(SchemaComponent, { + schema: fe, + components: { RequestProvider: g }, + scope: { department: o, handleSelect: x, useSelectOwners: m }, + }), + ], + }); +}; +const _ = React.createContext({}); +const $e = () => { + const e = useForm(), + t = useField(), + o = useActionContext(), + { refreshAsync: a } = useResourceActionContext(), + r = useAPIClient(), + { expandedKeys: c, setLoadedKeys: i, setExpandedKeys: x } = useContext(_); + return { + run() { + return k(this, null, function* () { + try { + yield e.submit(), + (t.data = t.data || {}), + (t.data.loading = true), + yield r.resource('departments').create({ values: e.values }), + o.setVisible(false), + yield e.reset(), + (t.data.loading = false); + const g = [...c]; + i([]), x([]), yield a(), x(g); + } catch (g) { + t.data && (t.data.loading = false); + } + }); + }, + }; +}; +const Le = () => { + const e = useField(), + t = useForm(), + o = useActionContext(), + { refreshAsync: a } = useResourceActionContext(), + r = useAPIClient(), + { id: c } = useRecord(), + { expandedKeys: i, setLoadedKeys: x, setExpandedKeys: m } = useContext(_), + { department: g, setDepartment: d } = useContext(K); + return { + run() { + return k(this, null, function* () { + yield t.submit(), (e.data = e.data || {}), (e.data.loading = true); + try { + yield r.resource('departments').update({ filterByTk: c, values: t.values }), + d({ department: g, ...t.values }), + o.setVisible(false), + yield t.reset(); + const b = [...i]; + x([]), m([]), yield a(), m(b); + } catch (b) { + console.log(b); + } finally { + e.data.loading = false; + } + }); + }, + }; +}; +const _e = () => { + const { t: e } = useTranslation(), + [t, o] = useState(false), + [a, r] = useState({}), + { department: c, setDepartment: i } = useContext(K), + { token: x } = theme.useToken(), + m = G({ label: ({ node: g }) => jsx(X.Item, { node: g, setVisible: o, setDrawer: r }) }); + return jsx(SchemaComponentOptions, { + scope: { useCreateDepartment: $e, useUpdateDepartment: Le }, + children: jsxs(_.Provider, { + value: m, + children: [ + jsxs(Row, { + children: [ + jsx(Se, {}), + jsx(Button, { + type: 'text', + icon: jsx(UserOutlined, {}), + style: { textAlign: 'left', marginBottom: '5px', background: c ? '' : x.colorBgTextHover }, + onClick: () => { + i(null); + }, + block: true, + children: e('All users'), + }), + jsx(xe, {}), + ], + }), + jsx(Divider, { style: { margin: '12px 0' } }), + jsx(X, {}), + jsx(ActionContextProvider, { + value: { visible: t, setVisible: o }, + children: jsx(RecordProvider, { + record: a.node || {}, + children: jsx(SchemaComponent, { + scope: { t: e }, + components: { DepartmentOwnersField: Be }, + schema: a.schema || {}, + }), + }), + }), + ], + }), + }); +}; +const ze = { + type: 'void', + 'x-component': 'Space', + properties: { + remove: { + type: 'void', + title: '{{t("Remove")}}', + 'x-component': 'Action', + 'x-component-props': { + icon: 'UserDeleteOutlined', + confirm: { + title: "{{t('Remove members')}}", + content: "{{t('Are you sure you want to remove these members?')}}", + }, + style: { marginRight: 8 }, + useAction: '{{ useBulkRemoveMembersAction }}', + }, + }, + create: { + type: 'void', + title: '{{t("Add members")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', icon: 'UserAddOutlined' }, + properties: { drawer: { type: 'void', 'x-component': 'AddMembers' } }, + }, + }, +}; +const We = { + type: 'void', + properties: { + remove: { + title: '{{ t("Remove") }}', + 'x-component': 'Action.Link', + 'x-component-props': { + confirm: { title: "{{t('Remove member')}}", content: "{{t('Are you sure you want to remove it?')}}" }, + useAction: '{{ useRemoveMemberAction }}', + }, + }, + }, +}; +const He = (e, t) => ({ + type: 'void', + properties: T( + y( + {}, + t + ? {} + : { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + [uid()]: { + type: 'void', + title: '{{ t("Filter") }}', + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + actions: { type: 'void', 'x-component': 'MemberActions' }, + }, + }, + }, + ), + { + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { type: 'checkbox' }, + useDataSource: '{{ useMembersDataSource }}', + pagination: { showTotal: '{{ useShowTotal }}' }, + }, + properties: T( + y( + { + nickname: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + username: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + departments: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + departments: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + }, + e + ? { + isOwner: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + 'x-component-props': { style: { minWidth: 100 } }, + title: '{{t("Owner")}}', + properties: { isOwner: { type: 'boolean', 'x-component': 'IsOwnerField' } }, + }, + } + : {}, + ), + { + phone: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + email: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + actions: { + type: 'void', + title: '{{t("Actions")}}', + 'x-component': 'Table.Column', + properties: { + actions: { + type: 'void', + 'x-component': 'Space', + 'x-component-props': { split: '|' }, + properties: y( + { + update: { + type: 'void', + title: '{{t("Configure")}}', + 'x-component': 'Action.Link', + 'x-component-props': { type: 'primary' }, + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'FormV2', + title: '{{t("Configure")}}', + properties: { + departments: { + title: '{{t("Departments")}}', + 'x-decorator': 'FormItem', + 'x-component': 'UserDepartmentsField', + }, + }, + }, + }, + }, + }, + e ? { remove: { type: 'void', 'x-component': 'RowRemoveAction' } } : {}, + ), + }, + }, + }, + }, + ), + }, + }, + ), +}); +const Ge = { + type: 'object', + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + title: '{{t("Add members")}}', + properties: { + resource: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'ResourceActionProvider', + 'x-component-props': { + collection: 'users', + request: { + resource: 'users', + action: 'listExcludeDept', + params: { departmentId: '{{ department?.id }}' }, + }, + }, + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + filter: { + type: 'void', + title: '{{ t("Filter") }}', + default: { $and: [{ username: { $includes: '' } }, { nickname: { $includes: '' } }] }, + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + }, + }, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { type: 'checkbox', onChange: '{{ handleSelect }}' }, + useDataSource: '{{ cm.useDataSourceFromRAC }}', + }, + properties: { + username: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + nickname: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + phone: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + email: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + }, + }, + }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useAddMembersAction }}' }, + }, + }, + }, + }, + }, + }, +}; +const Je = { + type: 'void', + properties: { + drawer: { + title: '{{t("Select Departments")}}', + 'x-decorator': 'Form', + 'x-component': 'Action.Drawer', + properties: { + table: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'DepartmentTable', + 'x-component-props': { useDataSource: '{{ useDataSource }}', useDisabled: '{{ useDisabled }}' }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + confirm: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useAddDepartments }}' }, + }, + }, + }, + }, + }, + }, +}; +const z = (e) => { + const t = e.title, + o = e.parent; + return o ? z(o) + ' / ' + t : t; +}; +const Ye = () => { + const { setDepartment: e } = useContext(K), + o = useField().value || [], + a = o.reduce((c, i) => ((c[i.id] = i), c), {}), + r = o.map((c, i) => + jsxs( + 'span', + { + children: [ + jsx('a', { + onClick: (x) => { + x.preventDefault(), e(a[c.id]); + }, + children: z(c), + }), + i !== o.length - 1 ? jsx('span', { style: { marginRight: 4, color: '#aaa' }, children: ',' }) : '', + ], + }, + i, + ), + ); + return jsx(EllipsisWithTooltip, { ellipsis: true, children: r }); +}; +const Qe = () => { + const { department: e } = useContext(K), + o = (useRecord().departments || []).find((a) => (a == null ? void 0 : a.id) === (e == null ? void 0 : e.id)); + return jsx(Checkbox.ReadPretty, { value: o == null ? void 0 : o.departmentsUsers.isOwner }); +}; +const R = React.createContext({}); +const Xe = () => { + const { setHasFilter: e, setExpandedKeys: t } = useContext(R), + { t: o } = useTranslation(), + a = useContext(CollectionContext), + r = useFilterFieldOptions(a.fields), + c = useResourceActionContext(), + { run: i, defaultRequest: x } = c, + m = useField(), + { params: g } = x || {}; + return { + options: r, + onSubmit: (d) => + k(this, null, function* () { + const A = g.filter, + b = removeNullCondition(d == null ? void 0 : d.filter); + i(T(y({}, g), { page: 1, pageSize: 10, filter: mergeFilter([b, A]) })); + const h = (b == null ? void 0 : b.$and) || (b == null ? void 0 : b.$or); + h != null && h.length + ? ((m.title = o('{{count}} filter items', { count: (h == null ? void 0 : h.length) || 0 })), e(true)) + : ((m.title = o('Filter')), e(false)); + }), + onReset() { + i( + T(y({}, g || {}), { + filter: T(y({}, (g == null ? void 0 : g.filter) || {}), { parentId: null }), + page: 1, + pageSize: 10, + }), + ), + (m.title = o('Filter')), + e(false), + t([]); + }, + }; +}; +const Ze = () => ({ disabled: () => false }); +const Re = ({ useDisabled: e = Ze }) => { + const { t } = useTranslation(), + o = useResourceActionContext(); + console.log(o); + const { run: a, data: r, loading: c, defaultRequest: i } = o, + { resource: x, resourceOf: m, params: g } = i || {}, + { treeData: d, initData: A, loadData: b } = G({ resource: x, resourceOf: m, params: g }), + h = useField(), + { disabled: F } = e(), + { hasFilter: C, expandedKeys: v, setExpandedKeys: l } = useContext(R); + useEffect(() => { + C || A(r == null ? void 0 : r.data); + }, [r, A, c, C]); + const u = {}; + if ((g != null && g.pageSize && (u.defaultPageSize = g.pageSize), !u.total && r != null && r.meta)) { + const { count: f, page: S, pageSize: O } = r.meta; + (u.total = f), (u.current = S), (u.pageSize = O); + } + return jsx(Table, { + rowKey: 'id', + columns: [{ dataIndex: 'title', title: t('Department name'), render: (f, S) => (C ? z(S) : f) }], + rowSelection: { + selectedRowKeys: ((h == null ? void 0 : h.value) || []).map((f) => f.id), + onChange: (f, S) => { + var O; + return (O = h == null ? void 0 : h.setValue) == null ? void 0 : O.call(h, S); + }, + getCheckboxProps: (f) => ({ disabled: F(f) }), + }, + pagination: T(y({ showSizeChanger: true }, u), { + onChange(f, S) { + var O; + a(T(y({}, ((O = o == null ? void 0 : o.params) == null ? void 0 : O[0]) || {}), { page: f, pageSize: S })); + }, + }), + dataSource: C ? (r == null ? void 0 : r.data) || [] : d, + expandable: { + onExpand: (f, S) => { + b({ key: S.id, children: S.children }); + }, + expandedRowKeys: v, + onExpandedRowsChange: (f) => l(f), + }, + }); +}; +const et = (e) => { + const [t, o] = useState([]), + [a, r] = useState(false), + { useDataSource: c } = e, + i = c({ manual: true }); + return ( + useEffect(() => { + i.run({ filter: { parentId: null }, pageSize: 10 }); + }, []), + jsx(ResourceActionContext.Provider, { + value: y({}, i), + children: jsx(CollectionProvider_deprecated, { + collection: Q, + children: jsx(R.Provider, { + value: { expandedKeys: t, setExpandedKeys: o, hasFilter: a, setHasFilter: r }, + children: e.children, + }), + }), + }) + ); +}; +const pe = ({ useDataSource: e, useDisabled: t }) => + jsx(SchemaComponent, { + scope: { useDisabled: t, useFilterActionProps: Xe }, + components: { InternalDepartmentTable: Re, RequestProvider: et }, + schema: { + type: 'void', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'RequestProvider', + 'x-component-props': { useDataSource: e }, + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + filter: { + type: 'void', + title: '{{ t("Filter") }}', + default: { $and: [{ title: { $includes: '' } }] }, + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + }, + }, + departments: { + type: 'array', + 'x-component': 'InternalDepartmentTable', + 'x-component-props': { useDisabled: '{{ useDisabled }}' }, + }, + }, + }, + }, + }, + }); +const tt = (e) => { + const t = { + resource: 'departments', + action: 'list', + params: { appends: ['parent(recursively=true)'], sort: ['createdAt'] }, + }, + o = useRequest(t, e); + return T(y({}, o), { defaultRequest: t }); +}; +const ot = () => { + const { modal: e, message: t } = App.useApp(), + { t: o } = useTranslation(), + [a, r] = useState(false), + c = useRecord(), + i = useField(), + { refresh: x } = useResourceActionContext(), + m = (l) => + l != null && l.length + ? l.map((u) => { + var f, S; + return T(y({}, u), { + isMain: (f = u.departmentsUsers) == null ? void 0 : f.isMain, + isOwner: (S = u.departmentsUsers) == null ? void 0 : S.isOwner, + title: z(u), + }); + }) + : [], + g = useAPIClient(); + useRequest( + () => + g + .resource('users.departments', c.id) + .list({ appends: ['parent(recursively=true)'], pagination: false }) + .then((l) => { + var f; + const u = m((f = l == null ? void 0 : l.data) == null ? void 0 : f.data); + i.setValue(u); + }), + { ready: c.id }, + ); + const d = () => { + const l = useAPIClient(), + u = useForm(), + { departments: f } = u.values || {}; + return { + run() { + return k(this, null, function* () { + yield l.resource('users.departments', c.id).add({ values: f.map((O) => O.id) }), + u.reset(), + i.setValue([ + ...i.value, + ...f.map((O, $) => T(y({}, O), { isMain: $ === 0 && i.value.length === 0, title: z(O) })), + ]), + r(false), + x(); + }); + }, + }; + }, + A = (l) => { + e.confirm({ + title: o('Remove department'), + content: o('Are you sure you want to remove it?'), + onOk: () => + k(this, null, function* () { + yield g.resource('users.departments', c.id).remove({ values: [l.id] }), + t.success(o('Deleted successfully')), + i.setValue( + i.value + .filter((u) => u.id !== l.id) + .map((u, f) => T(y({}, u), { isMain: (l.isMain && f === 0) || u.isMain })), + ), + x(); + }), + }); + }, + b = (l) => + k(this, null, function* () { + yield g.resource('users').setMainDepartment({ values: { userId: c.id, departmentId: l.id } }), + t.success(o('Set successfully')), + i.setValue(i.value.map((u) => T(y({}, u), { isMain: u.id === l.id }))), + x(); + }), + h = (l) => + k(this, null, function* () { + yield g.resource('departments').setOwner({ values: { userId: c.id, departmentId: l.id } }), + t.success(o('Set successfully')), + i.setValue(i.value.map((u) => T(y({}, u), { isOwner: u.id === l.id ? true : u.isOwner }))), + x(); + }), + F = (l) => + k(this, null, function* () { + yield g.resource('departments').removeOwner({ values: { userId: c.id, departmentId: l.id } }), + t.success(o('Set successfully')), + i.setValue(i.value.map((u) => T(y({}, u), { isOwner: u.id === l.id ? false : u.isOwner }))), + x(); + }), + C = (l, u) => { + switch (l) { + case 'setMain': + b(u); + break; + case 'setOwner': + h(u); + break; + case 'removeOwner': + F(u); + break; + case 'remove': + A(u); + } + }, + v = () => ({ disabled: (l) => i.value.some((u) => u.id === l.id) }); + return jsxs(ActionContextProvider, { + value: { visible: a, setVisible: r }, + children: [ + jsxs(Fragment, { + children: [ + ((i == null ? void 0 : i.value) || []).map((l) => + jsxs( + Tag, + { + style: { padding: '5px 8px', background: 'transparent', marginBottom: '5px' }, + children: [ + jsx('span', { style: { marginRight: '5px' }, children: l.title }), + l.isMain ? jsx(Tag, { color: 'processing', bordered: false, children: o('Main') }) : '', + jsx(Dropdown, { + menu: { + items: [ + ...(l.isMain ? [] : [{ label: o('Set as main department'), key: 'setMain' }]), + { label: o('Remove'), key: 'remove' }, + ], + onClick: ({ key: u }) => C(u, l), + }, + children: jsx('div', { + style: { float: 'right' }, + children: jsx(MoreOutlined, {}), + }), + }), + ], + }, + l.id, + ), + ), + jsx(Button, { icon: jsx(PlusOutlined, {}), onClick: () => r(true) }), + ], + }), + jsx(SchemaComponent, { + schema: Je, + components: { DepartmentTable: pe }, + scope: { user: c, useDataSource: tt, useAddDepartments: d, useDisabled: v }, + }), + ], + }); +}; +const nt = () => { + const { department: e } = useContext(K), + { refresh: t } = useResourceActionContext(), + o = useRef([]), + a = useAPIClient(), + r = () => ({ + run() { + return k(this, null, function* () { + const x = o.current; + x != null && + x.length && + (yield a.resource('departments.members', e.id).add({ values: x }), (o.current = []), t()); + }); + }, + }), + c = (i) => { + o.current = i; + }; + return jsx(SchemaComponent, { + scope: { useAddMembersAction: r, department: e, handleSelect: c }, + schema: Ge, + }); +}; +const rt = () => { + const { t: e } = useTranslation(), + { message: t } = App.useApp(), + o = useAPIClient(), + { state: a, setState: r, refresh: c } = useResourceActionContext(), + { department: i } = useContext(K); + return { + run() { + return k(this, null, function* () { + const m = a == null ? void 0 : a.selectedRowKeys; + if (!(m != null && m.length)) { + t.warning(e('Please select members')); + return; + } + yield o.resource('departments.members', i.id).remove({ values: m }), + r == null || r({ selectedRowKeys: [] }), + c(); + }); + }, + }; +}; +const st = () => { + const e = useAPIClient(), + { department: t } = useContext(K), + { id: o } = useRecord(), + { refresh: a } = useResourceActionContext(); + return { + run() { + return k(this, null, function* () { + yield e.resource('departments.members', t.id).remove({ values: [o] }), a(); + }); + }, + }; +}; +const at = (e) => { + const { user: t } = useContext(K), + o = useResourceActionContext(); + return ( + useEffect(() => { + if (t) { + e == null || e.onSuccess({ data: [t] }); + return; + } + o.loading || e == null || e.onSuccess(o.data); + }, [t, o.loading]), + o + ); +}; +const ct = () => { + var o; + const { data: e } = useResourceActionContext(), + { t } = useTranslation(); + return t('Total {{count}} members', { count: (o = e == null ? void 0 : e.meta) == null ? void 0 : o.count }); +}; +const it = () => { + const { t: e } = useTranslation(), + { department: t, user: o } = useContext(K), + { data: a, setState: r } = useResourceActionContext(); + useEffect(() => { + r == null || r({ selectedRowKeys: [] }); + }, [a, r]); + const c = () => (t ? jsx(SchemaComponent, { schema: ze }) : null), + i = () => (t ? jsx(SchemaComponent, { scope: { useRemoveMemberAction: st }, schema: We }) : null), + x = useMemo(() => He(t, o), [t, o]); + return jsxs(Fragment, { + children: [ + o + ? jsx('h2', { children: e('Search results') }) + : jsx('h2', { children: e((t == null ? void 0 : t.title) || 'All users') }), + jsx(SchemaComponent, { + scope: { + useBulkRemoveMembersAction: rt, + useMembersDataSource: at, + t: e, + useShowTotal: ct, + useFilterActionProps: Z, + }, + components: { + MemberActions: c, + AddMembers: nt, + RowRemoveAction: i, + DepartmentField: Ye, + IsOwnerField: Qe, + UserDepartmentsField: ot, + }, + schema: x, + }), + ], + }); +}; +const le = (e) => { + const t = useField(), + [o, a] = useState({ label: null, value: null }), + { treeData: r, initData: c, getByKeyword: i, loadData: x, loadedKeys: m, setLoadedKeys: g, originData: d } = e, + A = (h) => + k(this, null, function* () { + if (!h) { + c(d); + return; + } + yield i(h); + }), + b = useCallback((h) => { + const F = h.title, + C = h.parent; + return C ? b(C) + ' / ' + F : F; + }, []); + return ( + useEffect(() => { + c(d); + }, [d, c]), + useEffect(() => { + if (!t.value) { + a({ label: null, value: null }); + return; + } + a({ label: b(t.value) || t.value.label, value: t.value.id }); + }, [t.value, b]), + jsx(TreeSelect, { + value: o, + onSelect: (h, F) => { + t.setValue(F); + }, + onChange: (h) => { + h || t.setValue(null); + }, + treeData: r, + treeLoadedKeys: m, + onTreeLoad: (h) => g(h), + loadData: (h) => x({ key: h.id, children: h.children }), + fieldNames: { value: 'id' }, + showSearch: true, + allowClear: true, + treeNodeFilterProp: 'title', + onSearch: A, + labelInValue: true, + }) + ); +}; +const pt = () => { + const e = G(), + { departmentsResource: t } = useContext(K), + { + service: { data: o }, + } = t || {}; + return jsx(le, T(y({}, e), { originData: o == null ? void 0 : o.data })); +}; +const lt = () => { + const e = G(), + { setTreeData: t, getChildrenIds: o } = e, + a = useRecord(), + { departmentsResource: r } = useContext(K), + { + service: { data: c }, + } = r || {}; + return ( + useEffect(() => { + if (!a.id) return; + const i = o(a.id); + i.push(a.id), + t((x) => { + const m = (g) => + g.map((d) => (i.includes(d.id) && (d.disabled = true), d.children && (d.children = m(d.children)), d)); + return m(x); + }); + }, [t, a.id, o]), + jsx(le, T(y({}, e), { originData: c == null ? void 0 : c.data })) + ); +}; +const ut = () => + jsx(SchemaComponentOptions, { + components: { SuperiorDepartmentSelect: lt, DepartmentSelect: pt }, + scope: { useFilterActionProps: Z }, + children: jsxs(Row, { + gutter: 48, + style: { flexWrap: 'nowrap' }, + children: [ + jsx(Col, { + span: 6, + style: { borderRight: '1px solid #eee', minWidth: '300px' }, + children: jsx(Ce, { children: jsx(_e, {}) }), + }), + jsx(Col, { + flex: 'auto', + style: { overflow: 'hidden' }, + children: jsx(be, { children: jsx(it, {}) }), + }), + ], + }), + }); +export const MmtComponent = () => + jsx(SchemaComponent, { + components: { DepartmentManagement: ut }, + schema: { + type: 'void', + properties: { + [uid()]: { type: 'void', 'x-decorator': 'CardItem', 'x-component': 'DepartmentManagement' }, + }, + }, + }); +const dt = () => ({ + type: 'void', + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + [uid()]: { + type: 'void', + title: '{{ t("Filter") }}', + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + actions: { + type: 'void', + 'x-component': 'Space', + properties: { + remove: { + type: 'void', + title: '{{t("Remove")}}', + 'x-component': 'Action', + 'x-component-props': { + icon: 'MinusOutlined', + confirm: { + title: "{{t('Remove')}}", + content: "{{t('Are you sure you want to remove these departments?')}}", + }, + style: { marginRight: 8 }, + useAction: '{{ useBulkRemoveDepartments }}', + }, + }, + create: { + type: 'void', + title: '{{t("Add departments")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', icon: 'PlusOutlined' }, + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'FormV2', + title: '{{t("Add departments")}}', + properties: { + table: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'DepartmentTable', + 'x-component-props': { + useDataSource: '{{ useDataSource }}', + useDisabled: '{{ useDisabled }}', + }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useAddDepartments }}' }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { type: 'checkbox' }, + useDataSource: '{{ cm.useDataSourceFromRAC }}', + }, + properties: { + title: { + type: 'void', + title: '{{t("Department name")}}', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { title: { type: 'string', 'x-component': 'DepartmentTitle' } }, + }, + actions: { + type: 'void', + title: '{{t("Actions")}}', + 'x-component': 'Table.Column', + properties: { + actions: { + type: 'void', + 'x-component': 'Space', + 'x-component-props': { split: '|' }, + properties: { + remove: { + type: 'void', + title: '{{ t("Remove") }}', + 'x-component': 'Action.Link', + 'x-component-props': { + confirm: { + title: "{{t('Remove department')}}", + content: "{{t('Are you sure you want to remove it?')}}", + }, + useAction: '{{ useRemoveDepartment }}', + }, + }, + }, + }, + }, + }, + }, + }, + }, +}); +const xt = () => { + const e = useAPIClient(), + { role: t } = useContext(RolesManagerContext), + { data: o } = useRecord(), + { refresh: a } = useResourceActionContext(); + return { + run() { + return k(this, null, function* () { + yield e.resource(`roles/${t == null ? void 0 : t.name}/departments`).remove({ values: [o.id] }), a(); + }); + }, + }; +}; +const yt = () => { + const { t: e } = useTranslation(), + { message: t } = App.useApp(), + o = useAPIClient(), + { state: a, setState: r, refresh: c } = useResourceActionContext(), + { role: i } = useContext(RolesManagerContext); + return { + run() { + return k(this, null, function* () { + const m = a == null ? void 0 : a.selectedRowKeys; + if (!(m != null && m.length)) { + t.warning(e('Please select departments')); + return; + } + yield o.resource(`roles/${i == null ? void 0 : i.name}/departments`).remove({ values: m }), + r == null || r({ selectedRowKeys: [] }), + c(); + }); + }, + }; +}; +const ht = () => { + const e = useRecord(), + t = (o) => { + const a = o.title, + r = o.parent; + return r ? t(r) + ' / ' + a : a; + }; + return jsx(Fragment, { children: t(e) }); +}; +const ft = (e) => { + const t = { + resource: 'departments', + action: 'list', + params: { appends: ['roles', 'parent(recursively=true)'], sort: ['createdAt'] }, + }, + o = useRequest(t, e); + return T(y({}, o), { defaultRequest: t }); +}; +const vt = () => { + const { role: e } = useContext(RolesManagerContext); + return { + disabled: (t) => { + var o; + return (o = t == null ? void 0 : t.roles) == null + ? void 0 + : o.some((a) => a.name === (e == null ? void 0 : e.name)); + }, + }; +}; +const gt = () => { + const { role: e } = useContext(RolesManagerContext), + t = useAPIClient(), + o = useForm(), + { setVisible: a } = useActionContext(), + { refresh: r } = useResourceActionContext(), + { departments: c } = o.values || {}; + return { + run() { + return k(this, null, function* () { + yield t.resource('roles.departments', e.name).add({ values: c.map((x) => x.id) }), o.reset(), a(false), r(); + }); + }, + }; +}; +export const Departments = () => { + const { t: e } = useTranslation(), + { role: t } = useContext(RolesManagerContext), + o = useRequest( + { + resource: `roles/${t == null ? void 0 : t.name}/departments`, + action: 'list', + params: { appends: ['parent', 'parent.parent(recursively=true)'] }, + }, + { ready: !!t }, + ); + useEffect(() => { + o.run(); + }, [t]); + const a = useMemo(() => dt(), [t]); + return jsx(ResourceActionContext.Provider, { + value: y({}, o), + children: jsx(CollectionProvider_deprecated, { + collection: Q, + children: jsx(SchemaComponent, { + schema: a, + components: { DepartmentTable: pe, DepartmentTitle: ht }, + scope: { + useFilterActionProps: Z, + t: e, + useRemoveDepartment: xt, + useBulkRemoveDepartments: yt, + useDataSource: ft, + useDisabled: vt, + useAddDepartments: gt, + }, + }), + }), + }); +}; +const bt = (e) => e['x-component'] === 'CollectionField'; +export const oe = () => { + const { getField: e } = useCollection_deprecated(), + t = useCompile(), + o = useFieldSchema(), + { getCollectionJoinField: a } = useCollectionManager_deprecated(), + r = o.reduceProperties((i, x) => (bt(x) ? x : i), null); + if (!r) return {}; + const c = e(r.name) || a(r == null ? void 0 : r['x-collection-field']); + return { columnSchema: o, fieldSchema: r, collectionField: c, uiSchema: t(c == null ? void 0 : c.uiSchema) }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/addMembers.schema.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/addMembers.schema.tsx new file mode 100644 index 000000000..f1959fba9 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/addMembers.schema.tsx @@ -0,0 +1,149 @@ +export const schemaAddMembers = { + type: 'object', + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + title: '{{t("Add members")}}', + properties: { + resource: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'ResourceActionProvider', + 'x-component-props': { + collection: 'users', + request: { + resource: 'users', + action: 'listExcludeDept', + params: { + departmentId: '{{ department?.id }}', + }, + }, + }, + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { + style: { + marginBottom: 16, + }, + }, + properties: { + filter: { + type: 'void', + title: '{{ t("Filter") }}', + default: { + $and: [ + { + username: { + $includes: '', + }, + }, + { + nickname: { + $includes: '', + }, + }, + ], + }, + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { + icon: 'FilterOutlined', + }, + 'x-align': 'left', + }, + }, + }, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { + type: 'checkbox', + onChange: '{{ handleSelect }}', + }, + useDataSource: '{{ cm.useDataSourceFromRAC }}', + }, + properties: { + username: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + username: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + nickname: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + nickname: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + phone: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + phone: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + email: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + email: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + }, + }, + }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { + useAction: '{{ cm.useCancelAction }}', + }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { + type: 'primary', + useAction: '{{ useAddMembersAction }}', + }, + }, + }, + }, + }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/getSchemaDdt.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/getSchemaDdt.tsx new file mode 100644 index 000000000..7df8cf7e2 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/getSchemaDdt.tsx @@ -0,0 +1,128 @@ +import { uid } from '@tachybase/schema'; + +export const getSchemaDdt = () => ({ + type: 'void', + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + [uid()]: { + type: 'void', + title: '{{ t("Filter") }}', + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + actions: { + type: 'void', + 'x-component': 'Space', + properties: { + remove: { + type: 'void', + title: '{{t("Remove")}}', + 'x-component': 'Action', + 'x-component-props': { + icon: 'MinusOutlined', + confirm: { + title: "{{t('Remove')}}", + content: "{{t('Are you sure you want to remove these departments?')}}", + }, + style: { marginRight: 8 }, + useAction: '{{ useBulkRemoveDepartments }}', + }, + }, + create: { + type: 'void', + title: '{{t("Add departments")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', icon: 'PlusOutlined' }, + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'FormV2', + title: '{{t("Add departments")}}', + properties: { + table: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'DepartmentTable', + 'x-component-props': { + useDataSource: '{{ useDataSource }}', + useDisabled: '{{ useDisabled }}', + }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useAddDepartments }}' }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { type: 'checkbox' }, + useDataSource: '{{ cm.useDataSourceFromRAC }}', + }, + properties: { + title: { + type: 'void', + title: '{{t("Department name")}}', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { title: { type: 'string', 'x-component': 'DepartmentTitle' } }, + }, + actions: { + type: 'void', + title: '{{t("Actions")}}', + 'x-component': 'Table.Column', + properties: { + actions: { + type: 'void', + 'x-component': 'Space', + 'x-component-props': { split: '|' }, + properties: { + remove: { + type: 'void', + title: '{{ t("Remove") }}', + 'x-component': 'Action.Link', + 'x-component-props': { + confirm: { + title: "{{t('Remove department')}}", + content: "{{t('Are you sure you want to remove it?')}}", + }, + useAction: '{{ useRemoveDepartment }}', + }, + }, + }, + }, + }, + }, + }, + }, + }, +}); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/getSchemaHe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/getSchemaHe.tsx new file mode 100644 index 000000000..e56895042 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/getSchemaHe.tsx @@ -0,0 +1,322 @@ +import { uid } from '@tachybase/schema'; +import React from 'react'; + +export const getSchemaHe = (department, user) => { + const schemaNotUser = user + ? {} + : { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { + style: { + marginBottom: 16, + }, + }, + properties: { + [uid()]: { + type: 'void', + title: '{{ t("Filter") }}', + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { + icon: 'FilterOutlined', + }, + 'x-align': 'left', + }, + actions: { + type: 'void', + 'x-component': 'MemberActions', + }, + }, + }, + }; + const tableSchemaDepartMent = department + ? { + isOwner: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + 'x-component-props': { style: { minWidth: 100 } }, + title: '{{t("Owner")}}', + properties: { + isOwner: { + type: 'boolean', + 'x-component': 'IsOwnerField', + }, + }, + }, + } + : {}; + + const schemaActions = department + ? { + remove: { + type: 'void', + 'x-component': 'RowRemoveAction', + }, + } + : {}; + + return { + type: 'void', + properties: { + ...schemaNotUser, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { + type: 'checkbox', + }, + useDataSource: '{{ useMembersDataSource }}', + pagination: { + showTotal: '{{ useShowTotal }}', + }, + }, + properties: { + nickname: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + nickname: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + username: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + username: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + departments: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + departments: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + ...tableSchemaDepartMent, + phone: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + phone: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + email: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + email: { + type: 'string', + 'x-component': 'CollectionField', + 'x-read-pretty': true, + }, + }, + }, + actions: { + type: 'void', + title: '{{t("Actions")}}', + 'x-component': 'Table.Column', + properties: { + actions: { + type: 'void', + 'x-component': 'Space', + 'x-component-props': { split: '|' }, + properties: { + update: { + type: 'void', + title: '{{t("Configure")}}', + 'x-component': 'Action.Link', + 'x-component-props': { type: 'primary' }, + properties: { + drawer: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'FormV2', + title: '{{t("Configure")}}', + properties: { + departments: { + title: '{{t("Departments")}}', + 'x-decorator': 'FormItem', + 'x-component': 'UserDepartmentsField', + }, + }, + }, + }, + }, + ...schemaActions, + }, + }, + }, + }, + }, + }, + }, + }; + + // return { + // type: 'void', + // properties: T( + // y( + // {}, + // user + // ? {} + // : { + // actions: { + // type: 'void', + // 'x-component': 'ActionBar', + // 'x-component-props': { + // style: { + // marginBottom: 16, + // }, + // }, + // properties: { + // [uid()]: { + // type: 'void', + // title: '{{ t("Filter") }}', + // 'x-action': 'filter', + // 'x-component': 'Filter.Action', + // 'x-use-component-props': 'useFilterActionProps', + // 'x-component-props': { + // icon: 'FilterOutlined', + // }, + // 'x-align': 'left', + // }, + // actions: { + // type: 'void', + // 'x-component': 'MemberActions', + // }, + // }, + // }, + // }, + // ), + // { + // table: { + // type: 'void', + // 'x-component': 'Table.Void', + // 'x-component-props': { + // rowKey: 'id', + // rowSelection: { type: 'checkbox' }, + // useDataSource: '{{ useMembersDataSource }}', + // pagination: { showTotal: '{{ useShowTotal }}' }, + // }, + // properties: T( + // y( + // { + // nickname: { + // type: 'void', + // 'x-decorator': 'Table.Column.Decorator', + // 'x-component': 'Table.Column', + // properties: { nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + // }, + // username: { + // type: 'void', + // 'x-decorator': 'Table.Column.Decorator', + // 'x-component': 'Table.Column', + // properties: { username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + // }, + // departments: { + // type: 'void', + // 'x-decorator': 'Table.Column.Decorator', + // 'x-component': 'Table.Column', + // properties: { + // departments: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + // }, + // }, + // }, + // department + // ? { + // isOwner: { + // type: 'void', + // 'x-decorator': 'Table.Column.Decorator', + // 'x-component': 'Table.Column', + // 'x-component-props': { style: { minWidth: 100 } }, + // title: '{{t("Owner")}}', + // properties: { isOwner: { type: 'boolean', 'x-component': 'IsOwnerField' } }, + // }, + // } + // : {}, + // ), + // { + // phone: { + // type: 'void', + // 'x-decorator': 'Table.Column.Decorator', + // 'x-component': 'Table.Column', + // properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + // }, + // email: { + // type: 'void', + // 'x-decorator': 'Table.Column.Decorator', + // 'x-component': 'Table.Column', + // properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + // }, + // actions: { + // type: 'void', + // title: '{{t("Actions")}}', + // 'x-component': 'Table.Column', + // properties: { + // actions: { + // type: 'void', + // 'x-component': 'Space', + // 'x-component-props': { split: '|' }, + // properties: y( + // { + // update: { + // type: 'void', + // title: '{{t("Configure")}}', + // 'x-component': 'Action.Link', + // 'x-component-props': { type: 'primary' }, + // properties: { + // drawer: { + // type: 'void', + // 'x-component': 'Action.Drawer', + // 'x-decorator': 'FormV2', + // title: '{{t("Configure")}}', + // properties: { + // departments: { + // title: '{{t("Departments")}}', + // 'x-decorator': 'FormItem', + // 'x-component': 'UserDepartmentsField', + // }, + // }, + // }, + // }, + // }, + // }, + // department ? { remove: { type: 'void', 'x-component': 'RowRemoveAction' } } : {}, + // ), + // }, + // }, + // }, + // }, + // ), + // }, + // }, + // ), + + // // properties: { + + // // } + // }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaFfe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaFfe.tsx new file mode 100644 index 000000000..ac61d907e --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaFfe.tsx @@ -0,0 +1,90 @@ +export const schemaFfe = { + type: 'void', + properties: { + drawer: { + title: '{{t("Select Owners")}}', + 'x-component': 'Action.Drawer', + properties: { + resource: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'RequestProvider', + properties: { + actions: { + type: 'void', + 'x-component': 'ActionBar', + 'x-component-props': { style: { marginBottom: 16 } }, + properties: { + filter: { + type: 'void', + title: '{{ t("Filter") }}', + default: { $and: [{ username: { $includes: '' } }, { nickname: { $includes: '' } }] }, + 'x-action': 'filter', + 'x-component': 'Filter.Action', + 'x-use-component-props': 'useFilterActionProps', + 'x-component-props': { icon: 'FilterOutlined' }, + 'x-align': 'left', + }, + }, + }, + table: { + type: 'void', + 'x-component': 'Table.Void', + 'x-component-props': { + rowKey: 'id', + rowSelection: { type: 'checkbox', onChange: '{{ handleSelect }}' }, + useDataSource: '{{ cm.useDataSourceFromRAC }}', + }, + properties: { + username: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + username: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + nickname: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { + nickname: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true }, + }, + }, + phone: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { phone: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + email: { + type: 'void', + 'x-decorator': 'Table.Column.Decorator', + 'x-component': 'Table.Column', + properties: { email: { type: 'string', 'x-component': 'CollectionField', 'x-read-pretty': true } }, + }, + }, + }, + }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + confirm: { + title: '{{t("Confirm")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useSelectOwners }}' }, + }, + }, + }, + }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaHhe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaHhe.tsx new file mode 100644 index 000000000..2199cfca6 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaHhe.tsx @@ -0,0 +1,68 @@ +import { useAPIClient, useActionContext, useRecord, useRequest } from '@tachybase/client'; +import { uid } from '@tachybase/schema'; +import { useEffect } from 'react'; +import { T } from '../others/T'; + +export const schemaHhe = { + type: 'object', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + 'x-decorator-props': { + useValues(e) { + const t = useAPIClient(), + o = useActionContext(), + a = useRecord(), + r = useRequest( + () => + t + .resource('departments') + .get({ filterByTk: a.id, appends: ['parent(recursively=true)', 'roles', 'owners'] }) + .then((c) => (c == null ? void 0 : c.data)), + T({ ...e }, { manual: true }), + ); + return ( + useEffect(() => { + o.visible && r.run(); + }, [o.visible]), + r + ); + }, + }, + title: '{{t("Edit department")}}', + properties: { + title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem' }, + parent: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.parent', + 'x-component-props': { component: 'SuperiorDepartmentSelect' }, + }, + roles: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.roles', + }, + owners: { title: '{{t("Owners")}}', 'x-component': 'DepartmentOwnersField', 'x-decorator': 'FormItem' }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useUpdateDepartment }}' }, + }, + }, + }, + }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaJe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaJe.tsx new file mode 100644 index 000000000..23a737aa8 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaJe.tsx @@ -0,0 +1,34 @@ +export const schemaJe = { + type: 'void', + properties: { + drawer: { + title: '{{t("Select Departments")}}', + 'x-decorator': 'Form', + 'x-component': 'Action.Drawer', + properties: { + table: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'DepartmentTable', + 'x-component-props': { useDataSource: '{{ useDataSource }}', useDisabled: '{{ useDisabled }}' }, + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + confirm: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useAddDepartments }}' }, + }, + }, + }, + }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaWe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaWe.tsx new file mode 100644 index 000000000..4463b7bb4 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaWe.tsx @@ -0,0 +1,13 @@ +export const schemaWe = { + type: 'void', + properties: { + remove: { + title: '{{ t("Remove") }}', + 'x-component': 'Action.Link', + 'x-component-props': { + confirm: { title: "{{t('Remove member')}}", content: "{{t('Are you sure you want to remove it?')}}" }, + useAction: '{{ useRemoveMemberAction }}', + }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaYye.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaYye.tsx new file mode 100644 index 000000000..425b56363 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaYye.tsx @@ -0,0 +1,55 @@ +import { useActionContext, useRecord, useRequest } from '@tachybase/client'; +import { uid } from '@tachybase/schema'; +import { T } from '../others/T'; + +export const schemaYye = { + type: 'object', + properties: { + [uid()]: { + type: 'void', + 'x-component': 'Action.Drawer', + 'x-decorator': 'Form', + 'x-decorator-props': { + useValues(e) { + const t = useActionContext(), + o = useRecord(); + return useRequest( + () => Promise.resolve({ data: { parent: { ...o } } }), + T({ ...e }, { refreshDeps: [t.visible] }), + ); + }, + }, + title: '{{t("New sub department")}}', + properties: { + title: { 'x-component': 'CollectionField', 'x-decorator': 'FormItem' }, + parent: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.parent', + 'x-component-props': { component: 'DepartmentSelect' }, + }, + roles: { + 'x-component': 'CollectionField', + 'x-decorator': 'FormItem', + 'x-collection-field': 'departments.roles', + }, + footer: { + type: 'void', + 'x-component': 'Action.Drawer.Footer', + properties: { + cancel: { + title: '{{t("Cancel")}}', + 'x-component': 'Action', + 'x-component-props': { useAction: '{{ cm.useCancelAction }}' }, + }, + submit: { + title: '{{t("Submit")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', useAction: '{{ useCreateDepartment }}' }, + }, + }, + }, + }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaZe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaZe.tsx new file mode 100644 index 000000000..73176fe4e --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/schema/schemaZe.tsx @@ -0,0 +1,27 @@ +export const schemaZe = { + type: 'void', + 'x-component': 'Space', + properties: { + remove: { + type: 'void', + title: '{{t("Remove")}}', + 'x-component': 'Action', + 'x-component-props': { + icon: 'UserDeleteOutlined', + confirm: { + title: "{{t('Remove members')}}", + content: "{{t('Are you sure you want to remove these members?')}}", + }, + style: { marginRight: 8 }, + useAction: '{{ useBulkRemoveMembersAction }}', + }, + }, + create: { + type: 'void', + title: '{{t("Add members")}}', + 'x-component': 'Action', + 'x-component-props': { type: 'primary', icon: 'UserAddOutlined' }, + properties: { drawer: { type: 'void', 'x-component': 'AddMembers' } }, + }, + }, +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/scopes/useFilterActionPropsXe.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/scopes/useFilterActionPropsXe.tsx new file mode 100644 index 000000000..3a03a3428 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/scopes/useFilterActionPropsXe.tsx @@ -0,0 +1,50 @@ +import { + CollectionContext, + mergeFilter, + removeNullCondition, + useFilterFieldOptions, + useResourceActionContext, +} from '@tachybase/client'; +import { useField } from '@tachybase/schema'; +import { useContext } from 'react'; +import { useTranslation } from '../../../locale'; +import { T } from '../others/T'; +import { y } from '../others/y'; +import { k } from '../others/k'; +import { ContextR } from '../components/ContextR'; + +export const useFilterActionPropsXe = () => { + const { setHasFilter: e, setExpandedKeys: t } = useContext(ContextR), + { t: o } = useTranslation(), + a = useContext(CollectionContext), + r = useFilterFieldOptions(a.fields), + c = useResourceActionContext(), + { run: i, defaultRequest: x } = c, + m = useField(), + { params: g } = x || {}; + return { + options: r, + onSubmit: (d) => + k(this, null, function* () { + const A = g.filter, + b = removeNullCondition(d == null ? void 0 : d.filter); + i(T(y({}, g), { page: 1, pageSize: 10, filter: mergeFilter([b, A]) })); + const h = (b == null ? void 0 : b.$and) || (b == null ? void 0 : b.$or); + h != null && h.length + ? ((m.title = o('{{count}} filter items', { count: (h == null ? void 0 : h.length) || 0 })), e(true)) + : ((m.title = o('Filter')), e(false)); + }), + onReset() { + i( + T(y({}, g || {}), { + filter: T(y({}, (g == null ? void 0 : g.filter) || {}), { parentId: null }), + page: 1, + pageSize: 10, + }), + ), + (m.title = o('Filter')), + e(false), + t([]); + }, + }; +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/scopes/useFilterActionPropsZ.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/scopes/useFilterActionPropsZ.tsx new file mode 100644 index 000000000..98036d1a8 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/scopes/useFilterActionPropsZ.tsx @@ -0,0 +1,19 @@ +import { + CollectionContext, + useFilterFieldProps, + useFilterFieldOptions, + useResourceActionContext, +} from '@tachybase/client'; +import { useContext } from 'react'; + +export const useFilterActionPropsZ = () => { + var a, r; + const e = useContext(CollectionContext), + t = useFilterFieldOptions(e.fields), + o = useResourceActionContext(); + return useFilterFieldProps({ + options: t, + params: ((r = (a = o.state) == null ? void 0 : a.params) == null ? void 0 : r[0]) || o.params, + service: o, + }); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/DepartmentOwnersFieldSetting.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/DepartmentOwnersFieldSetting.tsx new file mode 100644 index 000000000..8f84b6454 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/DepartmentOwnersFieldSetting.tsx @@ -0,0 +1,19 @@ +import { SchemaSettings } from '@tachybase/client'; +import { neItems } from '../items/neItems'; +import { teItems } from '../items/teItems'; +import { reItems } from '../items/reItems'; + +export const DepartmentOwnersFieldSetting = new SchemaSettings({ + name: 'fieldSettings:component:DepartmentOwnersField', + items: [ + { + ...reItems, + }, + { + ...teItems, + }, + { + ...neItems, + }, + ], +}); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/UserDepartmentsFieldSetting.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/UserDepartmentsFieldSetting.tsx new file mode 100644 index 000000000..90ded736c --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/UserDepartmentsFieldSetting.tsx @@ -0,0 +1,19 @@ +import { SchemaSettings } from '@tachybase/client'; +import { neItems } from '../items/neItems'; +import { teItems } from '../items/teItems'; +import { reItems } from '../items/reItems'; + +export const UserDepartmentsFieldSetting = new SchemaSettings({ + name: 'fieldSettings:component:UserDepartmentsField', + items: [ + { + ...reItems, + }, + { + ...teItems, + }, + { + ...neItems, + }, + ], +}); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/UserMainDepartmentFieldSetting.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/UserMainDepartmentFieldSetting.tsx new file mode 100644 index 000000000..4481a173d --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/settings/UserMainDepartmentFieldSetting.tsx @@ -0,0 +1,19 @@ +import { SchemaSettings } from '@tachybase/client'; +import { neItems } from '../items/neItems'; +import { teItems } from '../items/teItems'; +import { reItems } from '../items/reItems'; + +export const UserMainDepartmentFieldSetting = new SchemaSettings({ + name: 'fieldSettings:component:UserMainDepartmentField', + items: [ + { + ...reItems, + }, + { + ...teItems, + }, + { + ...neItems, + }, + ], +}); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/B.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/B.tsx new file mode 100644 index 000000000..f5dbf88d4 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/B.tsx @@ -0,0 +1,19 @@ +import { Ee, Fe, L } from './tools'; +import { Ve } from './Ve'; + +export function B(e, t, o) { + (o = o || {}), + (o.arrayMerge = o.arrayMerge || Ee), + (o.isMergeableObject = o.isMergeableObject || Fe), + (o.cloneUnlessOtherwiseSpecified = L); + var a = Array.isArray(t), + r = Array.isArray(e), + c = a === r; + return c ? (a ? o.arrayMerge(e, t, o) : Ve(e, t, o)) : L(t, o); +} +B.all = function (t, o) { + if (!Array.isArray(t)) throw new Error('first argument should be an array'); + return t.reduce(function (a, r) { + return B(a, r, o); + }, {}); +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/Ve.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/Ve.tsx new file mode 100644 index 000000000..3a5ad194d --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/Ve.tsx @@ -0,0 +1,15 @@ +import { ae, L, qe, ce, Ke } from './tools'; + +export function Ve(e, t, o) { + var a = {}; + return ( + o.isMergeableObject(e) && + ae(e).forEach(function (r) { + a[r] = L(e[r], o); + }), + ae(t).forEach(function (r) { + qe(e, r) || (ce(e, r) && o.isMergeableObject(t[r]) ? (a[r] = Ke(r, o)(e[r], t[r], o)) : (a[r] = L(t[r], o))); + }), + a + ); +} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/getDepartmentStr.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/getDepartmentStr.tsx new file mode 100644 index 000000000..b7fe4dc86 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/getDepartmentStr.tsx @@ -0,0 +1,9 @@ +export const getDepartmentStr = (department) => { + const title = department.title; + const parent = department.parent; + if (parent) { + return getDepartmentStr(parent) + '/' + title; + } else { + return title; + } +}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/tools.tsx b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/tools.tsx new file mode 100644 index 000000000..0de5635b2 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/features/departments/utils/tools.tsx @@ -0,0 +1,54 @@ +// import { TreeSelect } from 'antd'; +import { B } from './B'; + +export var Fe = function (t) { + return Me(t) && !Te(t); +}; +function Me(e) { + return !!e && typeof e == 'object'; +} +function Te(e) { + var t = Object.prototype.toString.call(e); + return t === '[object RegExp]' || t === '[object Date]' || Pe(e); +} +var Ie = typeof Symbol == 'function' && Symbol.for, + Oe = Ie ? Symbol.for('react.element') : 60103; +function Pe(e) { + return e.$$typeof === Oe; +} +function ke(e) { + return Array.isArray(e) ? [] : {}; +} +export function L(e, t) { + return t.clone !== false && t.isMergeableObject(e) ? B(ke(e), e, t) : e; +} +export function Ee(e, t, o) { + return e.concat(t).map(function (a) { + return L(a, o); + }); +} +export function Ke(e, t) { + if (!t.customMerge) return B; + var o = t.customMerge(e); + return typeof o == 'function' ? o : B; +} +function Ne(e) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(e).filter(function (t) { + return Object.propertyIsEnumerable.call(e, t); + }) + : []; +} +export function ae(e) { + return Object.keys(e).concat(Ne(e)); +} +export function ce(e, t) { + try { + return t in e; + } catch (o) { + return false; + } +} +export function qe(e, t) { + return ce(e, t) && !(Object.hasOwnProperty.call(e, t) && Object.propertyIsEnumerable.call(e, t)); +} diff --git a/packages/plugins/@hera/plugin-core/src/client/features/outbound/index.ts b/packages/plugins/@hera/plugin-core/src/client/features/outbound/index.ts index 1ebb2e883..634a0767a 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/outbound/index.ts +++ b/packages/plugins/@hera/plugin-core/src/client/features/outbound/index.ts @@ -1,7 +1,8 @@ import { Plugin } from '@tachybase/client'; -import { OutboundPage } from './OutboundPage'; -import { OutboundButton, OutboundLinkActionInitializer } from './OutboundLinkActionInitializer'; + import { lang } from '../../locale'; +import { OutboundButton, OutboundLinkActionInitializer } from './OutboundLinkActionInitializer'; +import { OutboundPage } from './OutboundPage'; import { useOutboundActionProps } from './useOutboundActionProps'; export class PluginOutbound extends Plugin { diff --git a/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFVIewerBlockInitializer.tsx b/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFVIewerBlockInitializer.tsx index 202f0a2d1..287f8bfc3 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFVIewerBlockInitializer.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFVIewerBlockInitializer.tsx @@ -1,5 +1,4 @@ import React, { createContext, useContext, useRef } from 'react'; -import { PrinterOutlined } from '@ant-design/icons'; import { ActionInitializer, SchemaInitializer, @@ -8,6 +7,9 @@ import { useSchemaInitializer, useSchemaInitializerItem, } from '@tachybase/client'; + +import { PrinterOutlined } from '@ant-design/icons'; + import { tval } from '../../locale'; const PDFViewerContext = createContext(null); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFViewer.tsx b/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFViewer.tsx index a01e188ad..515b8ccd2 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFViewer.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/features/pdf/PDFViewer.tsx @@ -1,10 +1,12 @@ import React, { useEffect, useRef, useState } from 'react'; -import { PDFViewer } from '../../components/PDFViewer'; -import { Space } from 'antd'; import { css } from '@tachybase/client'; -import { usePDFViewerRef } from './PDFVIewerBlockInitializer'; + +import { Space } from 'antd'; import { debounce } from 'lodash'; +import { PDFViewer } from '../../components/PDFViewer'; +import { usePDFViewerRef } from './PDFVIewerBlockInitializer'; + export const InternalPDFViewer = (props) => { const { usePdfPath: useMaybePdfPath } = props; const containerRef = useRef(null); diff --git a/packages/plugins/@hera/plugin-core/src/client/features/pdf/index.ts b/packages/plugins/@hera/plugin-core/src/client/features/pdf/index.ts index 5d65f54ce..bbfc65996 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/pdf/index.ts +++ b/packages/plugins/@hera/plugin-core/src/client/features/pdf/index.ts @@ -1,13 +1,14 @@ import { Plugin } from '@tachybase/client'; + import { tval } from '../../locale'; +import { InternalPDFViewer } from './PDFViewer'; import { + pdfViewActionInitializer, PDFViewerBlockInitializer, PDFViewerPrintActionInitializer, PDFViewerProvider, - pdfViewActionInitializer, usePDFViewerPrintActionProps, } from './PDFVIewerBlockInitializer'; -import { InternalPDFViewer } from './PDFViewer'; export class PluginPDF extends Plugin { async load() { diff --git a/packages/plugins/@hera/plugin-core/src/client/index.tsx b/packages/plugins/@hera/plugin-core/src/client/index.tsx index 4af59f689..7d8f29dc7 100644 --- a/packages/plugins/@hera/plugin-core/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/index.tsx @@ -1,51 +1,61 @@ -import { Plugin, EditTitleField } from '@tachybase/client'; -import { useFieldSchema } from '@tachybase/schema'; -import { isValid } from '@tachybase/schema'; -import { autorun } from '@tachybase/schema'; -import { Locale, tval } from './locale'; -import { - PageModeSetting, - EditFormulaTitleField, - IsTablePageSize, - useFormulaTitleVisible, - usePaginationVisible, - EditTitle, -} from './schema-settings'; -import { useCreateActionProps } from './schema-initializer/actions/hooks/useCreateActionProps'; -import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents'; -import { useGetCustomComponents } from './hooks/useGetCustomComponents'; -import { AdminLayout, DetailsPage, PageLayout } from './pages'; -import { PluginSettingsHelper } from './settings-manager-components'; -import { - AssociatedFieldInterface, - CalcFieldInterface, - CustomFieldInterface, - CustomAssociatedFieldInterface, - SignaturePadFieldInterface, - ExcelFieldInterface, -} from './interfaces'; +import { EditTitleField, Plugin } from '@tachybase/client'; +import { autorun, isValid, useFieldSchema } from '@tachybase/schema'; + import { AssociatedField, CalcResult, CustomAssociatedField, - CustomField, CustomComponentDispatcher, - CustomComponentStub, customComponentDispatcherSettings, + CustomComponentStub, + CustomField, + ExcelFile, Expression, SignatureInput, - ExcelFile, } from './components'; +import { PluginAssistant } from './features/assistant'; +import { PluginContextMenu } from './features/context-menu'; +import { DepartmentsPlugin } from './features/departments'; +import { EmbedPlugin } from './features/embed'; +import { PluginExtendedFilterForm } from './features/extended-filter-form'; +import { PluginHeraVersion } from './features/hera-version'; +import { PluginOutbound } from './features/outbound'; +import { PluginPageStyle } from './features/page-style'; +import { PluginPDF } from './features/pdf'; +import { PluginWorkflowBulk } from './features/workflow-bulk'; +import { PluginWorkflowInterceptor } from './features/workflow-interceptor'; +import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents'; +import { useGetCustomComponents } from './hooks/useGetCustomComponents'; +import { + AssociatedFieldInterface, + CalcFieldInterface, + CustomAssociatedFieldInterface, + CustomFieldInterface, + ExcelFieldInterface, + SignaturePadFieldInterface, +} from './interfaces'; +import { TstzrangeFieldInterface } from './interfaces/TstzrangeFieldInterface'; +import { Locale, tval } from './locale'; +import { AdminLayout, DetailsPage, PageLayout } from './pages'; import { AutoComplete } from './schema-components'; +import AssociationCascader from './schema-components/association-cascader/AssociationCascader'; import { CreateSubmitActionInitializer, GroupBlockPlugin, SettingBlockInitializer } from './schema-initializer'; +import { useCreateActionProps } from './schema-initializer/actions/hooks/useCreateActionProps'; import { SheetBlock, SheetBlockInitializer, SheetBlockProvider, - SheetBlockToolbar, sheetBlockSettings, + SheetBlockToolbar, } from './schema-initializer/blocks/SheetBlockInitializer'; -import AssociationCascader from './schema-components/association-cascader/AssociationCascader'; +import { + EditFormulaTitleField, + EditTitle, + IsTablePageSize, + PageModeSetting, + useFormulaTitleVisible, + usePaginationVisible, +} from './schema-settings'; import { SchemaSettingsDatePickerType } from './schema-settings/SchemaSettingsDatePickerType'; import { SchemaSettingsDatePresets, @@ -53,18 +63,8 @@ import { useCustomPresets1, } from './schema-settings/SchemaSettingsDatePresets'; import { SchemaSettingsSubmitDataType } from './schema-settings/SchemaSettingsSubmitDataType'; -import { EmbedPlugin } from './features/embed'; -import { DepartmentsPlugin } from './features/departments'; -import { PluginPageStyle } from './features/page-style'; -import { PluginHeraVersion } from './features/hera-version'; -import { PluginAssistant } from './features/assistant'; -import { TstzrangeFieldInterface } from './interfaces/TstzrangeFieldInterface'; -import { PluginContextMenu } from './features/context-menu'; -import { PluginWorkflowBulk } from './features/workflow-bulk'; -import { PluginWorkflowInterceptor } from './features/workflow-interceptor'; -import { PluginPDF } from './features/pdf'; -import { PluginExtendedFilterForm } from './features/extended-filter-form'; -import { PluginOutbound } from './features/outbound'; +import { PluginSettingsHelper } from './settings-manager-components'; + export { usePDFViewerRef } from './features/pdf/PDFVIewerBlockInitializer'; export * from './components/custom-components/custom-components'; diff --git a/packages/plugins/@hera/plugin-core/src/client/settings-manager-components/index.ts b/packages/plugins/@hera/plugin-core/src/client/settings-manager-components/index.ts index 4d1c99167..c43057447 100644 --- a/packages/plugins/@hera/plugin-core/src/client/settings-manager-components/index.ts +++ b/packages/plugins/@hera/plugin-core/src/client/settings-manager-components/index.ts @@ -1,8 +1,9 @@ import { Application } from '@tachybase/client'; + import { tval } from '../locale'; -import { Configuration } from './TokenConfiguration'; -import { LinkManager } from './LinkManager'; import { Features } from './Features'; +import { LinkManager } from './LinkManager'; +import { Configuration } from './TokenConfiguration'; export * from './LinkManager'; export * from './TokenConfiguration'; diff --git a/packages/plugins/@hera/plugin-core/src/server/services/connection-manager.ts b/packages/plugins/@hera/plugin-core/src/server/services/connection-manager.ts index 9ff500165..c905cf316 100644 --- a/packages/plugins/@hera/plugin-core/src/server/services/connection-manager.ts +++ b/packages/plugins/@hera/plugin-core/src/server/services/connection-manager.ts @@ -1,9 +1,12 @@ import Application, { Gateway } from '@tachybase/server'; -import WebSocket from 'ws'; +import { App, Service } from '@tachybase/utils'; + import jwt from 'jsonwebtoken'; import { createClient } from 'redis'; +import WebSocket from 'ws'; + import { currentProcessNum, isMain } from '../utils/multiprocess'; -import { App, Service } from '@tachybase/utils'; + const KEY_ONLINE_USERS = 'online_users'; @Service() diff --git a/packages/plugins/@hera/plugin-homepage/src/client/Home.tsx b/packages/plugins/@hera/plugin-homepage/src/client/Home.tsx index 7dc62c863..9d8dc55d5 100644 --- a/packages/plugins/@hera/plugin-homepage/src/client/Home.tsx +++ b/packages/plugins/@hera/plugin-homepage/src/client/Home.tsx @@ -1,6 +1,8 @@ import React from 'react'; -import { Carousel, Image } from 'antd'; import { useAppSpin, useRequest } from '@tachybase/client'; + +import { Carousel, Image } from 'antd'; + import { useStyles } from './style'; export const HomePage: React.FC<{}> = () => { diff --git a/packages/plugins/@hera/plugin-homepage/src/client/index.tsx b/packages/plugins/@hera/plugin-homepage/src/client/index.tsx index edfc54148..5352c548c 100644 --- a/packages/plugins/@hera/plugin-homepage/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-homepage/src/client/index.tsx @@ -1,6 +1,7 @@ import { Plugin, tval } from '@tachybase/client'; -import { HomePageConfiguration } from './HomePageConfiguration'; + import { HomePage } from './Home'; +import { HomePageConfiguration } from './HomePageConfiguration'; export class PluginHomePageClient extends Plugin { async load() { diff --git a/packages/plugins/@hera/plugin-homepage/src/server/home-page-service.ts b/packages/plugins/@hera/plugin-homepage/src/server/home-page-service.ts index 307563aed..d3bca477c 100644 --- a/packages/plugins/@hera/plugin-homepage/src/server/home-page-service.ts +++ b/packages/plugins/@hera/plugin-homepage/src/server/home-page-service.ts @@ -1,6 +1,6 @@ -import Application from '@tachybase/server'; -import { Service, App, Db } from '@tachybase/utils'; import Database from '@tachybase/database'; +import Application from '@tachybase/server'; +import { App, Db, Service } from '@tachybase/utils'; @Service() export class HomePageService { diff --git a/packages/plugins/@hera/plugin-homepage/src/server/plugin.ts b/packages/plugins/@hera/plugin-homepage/src/server/plugin.ts index 34b1d6a76..6c5debb24 100644 --- a/packages/plugins/@hera/plugin-homepage/src/server/plugin.ts +++ b/packages/plugins/@hera/plugin-homepage/src/server/plugin.ts @@ -1,5 +1,6 @@ import { Plugin } from '@tachybase/server'; import { Container } from '@tachybase/utils'; + import { HomePageService } from './home-page-service'; export class PluginHomePageServer extends Plugin { diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordDetails.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordDetails.tsx index 9d64f38a9..2b661afdd 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordDetails.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordDetails.tsx @@ -1,10 +1,11 @@ import React from 'react'; -import _ from 'lodash'; -import { CustomComponentType, CustomFunctionComponent } from '@hera/plugin-core/client'; -import { useField, useFieldSchema, useForm } from '@tachybase/schema'; -import { FormPath } from '@tachybase/schema'; import { useRequest } from '@tachybase/client'; +import { FormPath, useField, useFieldSchema, useForm } from '@tachybase/schema'; + +import { CustomComponentType, CustomFunctionComponent } from '@hera/plugin-core/client'; import { Descriptions, Spin } from 'antd'; +import _ from 'lodash'; + import { formatQuantity } from '../../utils/currencyUtils'; export const RecordDetails: CustomFunctionComponent = () => { diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeConverted.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeConverted.tsx index 7af13b339..1770a1d3a 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeConverted.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeConverted.tsx @@ -1,10 +1,11 @@ -import { onFieldInit, onFieldValueChange } from '@tachybase/schema'; -import { useField, useForm, useFormEffects } from '@tachybase/schema'; -import { CustomComponentType, CustomFunctionComponent } from '@hera/plugin-core/client'; -import { useRequest } from '@tachybase/client'; -import _ from 'lodash'; import React, { useEffect, useState } from 'react'; -import { ConversionLogics, Movement, countCource } from '../../utils/constants'; +import { useRequest } from '@tachybase/client'; +import { onFieldInit, onFieldValueChange, useField, useForm, useFormEffects } from '@tachybase/schema'; + +import { CustomComponentType, CustomFunctionComponent } from '@hera/plugin-core/client'; +import _ from 'lodash'; + +import { ConversionLogics, countCource, Movement } from '../../utils/constants'; import { formatQuantity } from '../../utils/currencyUtils'; export const RecordFeeConvertedAmount: CustomFunctionComponent = () => { diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx index 34f7577d5..8dbe4d77e 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx @@ -1,10 +1,12 @@ -import _ from 'lodash'; -import { Spin } from 'antd'; import React from 'react'; import { observer, useField, useFieldSchema, useForm } from '@tachybase/schema'; + import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; -import { useFeeItems } from '../hooks'; import { useDeepCompareEffect } from 'ahooks'; +import { Spin } from 'antd'; +import _ from 'lodash'; + +import { useFeeItems } from '../hooks'; export const RecordFeeScope = observer(() => { const form = useForm(); diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemCount.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemCount.tsx index 8b8759f61..a548f0682 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemCount.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemCount.tsx @@ -1,9 +1,11 @@ import React from 'react'; -import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; import { observer, useField, useForm } from '@tachybase/schema'; -import _ from 'lodash'; -import { formatQuantity } from '../../utils/currencyUtils'; + +import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; import { Spin } from 'antd'; +import _ from 'lodash'; + +import { formatQuantity } from '../../utils/currencyUtils'; import { useCachedRequest } from '../hooks'; export const RecordItemCount = observer((props) => { diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx index 14cade392..930911943 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx @@ -1,7 +1,9 @@ import React from 'react'; -import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; import { observer, useField, useForm } from '@tachybase/schema'; + +import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; import _ from 'lodash'; + import { ConversionLogics, RecordCategory } from '../../utils/constants'; import { formatQuantity } from '../../utils/currencyUtils'; import { useCachedRequest, useLeaseItems, useProductFeeItems } from '../hooks'; diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemWeight.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemWeight.tsx index f73457f5d..6f6ec1591 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemWeight.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemWeight.tsx @@ -1,7 +1,9 @@ import React from 'react'; -import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; import { observer, useField, useForm } from '@tachybase/schema'; + +import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; import _ from 'lodash'; + import { formatQuantity } from '../../utils/currencyUtils'; export const RecordItemWeight = observer((props) => { diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordProductScope.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordProductScope.tsx index 50444e49e..7f2c56de8 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordProductScope.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordProductScope.tsx @@ -1,11 +1,13 @@ -import _ from 'lodash'; -import { Spin } from 'antd'; import React from 'react'; import { observer, useForm } from '@tachybase/schema'; -import { RecordCategory } from '../../utils/constants'; + import { CustomComponentType, CustomFC } from '@hera/plugin-core/client'; -import { useCachedRequest, useLeaseItems, useProductFeeItems } from '../hooks'; import { useDeepCompareEffect } from 'ahooks'; +import { Spin } from 'antd'; +import _ from 'lodash'; + +import { RecordCategory } from '../../utils/constants'; +import { useCachedRequest, useLeaseItems, useProductFeeItems } from '../hooks'; export const RecordProductScope = observer(() => { const form = useForm(); diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx index fc65ccb46..1bbc9b483 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx @@ -1,12 +1,15 @@ -import { observer, useForm } from '@tachybase/schema'; -import { ConversionLogics, RecordCategory } from '../../utils/constants'; -import { Descriptions, Tabs } from 'antd'; -import { CustomComponentType, CustomFC, CustomFunctionComponent } from '@hera/plugin-core/client'; import React from 'react'; +import { observer, useForm } from '@tachybase/schema'; + +import { CustomComponentType, CustomFC, CustomFunctionComponent } from '@hera/plugin-core/client'; +import { Descriptions, Tabs } from 'antd'; import _ from 'lodash'; + +import { RecordItems } from '../../interfaces/records'; +import { ConversionLogics, RecordCategory } from '../../utils/constants'; import { formatCurrency, formatQuantity } from '../../utils/currencyUtils'; import { useCachedRequest, useLeaseItems, useProductFeeItems } from '../hooks'; -import { RecordItems } from '../../interfaces/records'; + const cache = []; export const RecordSummary = observer((): any => { cache.length = 0; diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx index b52adc623..194781309 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx @@ -1,11 +1,12 @@ -import { onFieldValueChange, onFieldInit } from '@tachybase/schema'; -import { useField, useForm, useFormEffects } from '@tachybase/schema'; import React, { useEffect, useState } from 'react'; -import { ConversionLogics } from '../../utils/constants'; import { useRequest } from '@tachybase/client'; -import _ from 'lodash'; -import { formatCurrency } from '../../utils/currencyUtils'; +import { onFieldInit, onFieldValueChange, useField, useForm, useFormEffects } from '@tachybase/schema'; + import { CustomComponentType, CustomFunctionComponent } from '@hera/plugin-core/client'; +import _ from 'lodash'; + +import { ConversionLogics } from '../../utils/constants'; +import { formatCurrency } from '../../utils/currencyUtils'; export const RecordTotalPrice: CustomFunctionComponent = () => { const form = useForm(); diff --git a/packages/plugins/@hera/plugin-rental/src/client/hooks/index.tsx b/packages/plugins/@hera/plugin-rental/src/client/hooks/index.tsx index ab02167dd..58d334623 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/hooks/index.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/hooks/index.tsx @@ -1,6 +1,7 @@ -import { useRequest } from '@tachybase/client'; -import { stringify } from 'flatted'; import { useEffect } from 'react'; +import { useRequest } from '@tachybase/client'; + +import { stringify } from 'flatted'; export function useCachedRequest

(params: {}, options = {}) { const cacheKey = stringify(params); diff --git a/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx b/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx index 5847d6a41..ec83d0a0c 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/hooks/usePdfPath.tsx @@ -1,5 +1,6 @@ -import { useRecord } from '@tachybase/client'; import React, { createContext, useContext, useMemo, useState } from 'react'; +import { useRecord } from '@tachybase/client'; + import { SettlementStyleContext } from '../schema-initializer/actions/SettlementStyleSwitchActionInitializer'; export const PdfIsDoubleContext = createContext({ diff --git a/packages/plugins/@hera/plugin-rental/src/client/index.tsx b/packages/plugins/@hera/plugin-rental/src/client/index.tsx index 0595f486a..96ddfde7a 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/index.tsx @@ -1,24 +1,17 @@ import { Plugin, useCollection } from '@tachybase/client'; -import { RecordSummary } from './custom-components/RecordSummary'; -import { RecordTotalPrice } from './custom-components/RecordTotalPrice'; -import { RecordItemWeight } from './custom-components/RecordItemWeight'; -import { RecordItemCount } from './custom-components/RecordItemCount'; -import { RecordItemValuationQuantity } from './custom-components/RecordItemValuationQuantity'; -import { RecordProductScope } from './custom-components/RecordProductScope'; -import { RecordFeeScope } from './custom-components/RecordFeeScope'; + +import { DetailChecks } from './custom-components/DetailChecks'; +import { RecordDetails } from './custom-components/RecordDetails'; import { RecordFeeConvertedAmount } from './custom-components/RecordFeeConverted'; import { ReadFeeConvertedAmount } from './custom-components/RecordFeeConvertedRead'; -import { RecordDetails } from './custom-components/RecordDetails'; -import { Locale, tval } from './locale'; -import { AddToChecklistActionInitializer } from './schema-initializer/actions/AddToChecklistActionInitializer'; +import { RecordFeeScope } from './custom-components/RecordFeeScope'; +import { RecordItemCount } from './custom-components/RecordItemCount'; +import { RecordItemValuationQuantity } from './custom-components/RecordItemValuationQuantity'; +import { RecordItemWeight } from './custom-components/RecordItemWeight'; +import { RecordProductScope } from './custom-components/RecordProductScope'; +import { RecordSummary } from './custom-components/RecordSummary'; +import { RecordTotalPrice } from './custom-components/RecordTotalPrice'; import { useAddToChecklistActionProps } from './hooks/useAddToChecklistActionProps'; -import { DetailChecks } from './custom-components/DetailChecks'; -import { - PDFViewerCountablePrintActionInitializer, - PrintCounterAction, - PrintCounterProvider, - usePDFViewerCountablePrintActionProps, -} from './schema-initializer/actions/PDFViewerPrintActionInitializer'; import { PdfIsDoubleProvider, useRecordPdfPath, @@ -26,10 +19,27 @@ import { useWaybillPdfPath, WaybillsProvider, } from './hooks/usePdfPath'; +import { Locale, tval } from './locale'; +import { AddToChecklistActionInitializer } from './schema-initializer/actions/AddToChecklistActionInitializer'; import { ColumnSwitchAction, ColumnSwitchActionInitializer, } from './schema-initializer/actions/ColumnSwitchActionInitializer'; +import { + PDFViewerCountablePrintActionInitializer, + PrintCounterAction, + PrintCounterProvider, + usePDFViewerCountablePrintActionProps, +} from './schema-initializer/actions/PDFViewerPrintActionInitializer'; +import { PrintStyleSetupInitializer, StyleSetup } from './schema-initializer/actions/PrintStyleSetupInitializer'; +import { + PrintSetup, + RecordPrintSetupActionInitializer, +} from './schema-initializer/actions/RecordPrintSetupActionInitializer'; +import { + PrintSetupMargingTop, + RecordPrintSetupMargingTopInitializer, +} from './schema-initializer/actions/RecordPrintSetupMargingTopInitializer'; import { SettlementExcelExportActionInitializer, useSettlementExcelExportActionProps, @@ -40,16 +50,8 @@ import { SettlementStyleSwitchActionInitializer, useSettlementStyleSwitchActionProps, } from './schema-initializer/actions/SettlementStyleSwitchActionInitializer'; -import { - RecordPrintSetupActionInitializer, - PrintSetup, -} from './schema-initializer/actions/RecordPrintSetupActionInitializer'; -import { - RecordPrintSetupMargingTopInitializer, - PrintSetupMargingTop, -} from './schema-initializer/actions/RecordPrintSetupMargingTopInitializer'; import { UnusedRecordsBlockHelper } from './schema-initializer/blocks/UnusedRecordsBlockInitializer'; -import { PrintStyleSetupInitializer, StyleSetup } from './schema-initializer/actions/PrintStyleSetupInitializer'; + export class PluginRentalClient extends Plugin { locale: Locale; async afterAdd() {} diff --git a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/PrintStyleSetupInitializer.tsx b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/PrintStyleSetupInitializer.tsx index f743c1ada..2bbeda722 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/PrintStyleSetupInitializer.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/PrintStyleSetupInitializer.tsx @@ -1,9 +1,11 @@ import React, { useContext, useEffect, useState } from 'react'; -import { ActionInitializer, useAPIClient, useRequest, useCurrentUserContext } from '@tachybase/client'; -import { Button, Form, Input, Popover, Radio, Select, Space, Spin, message } from 'antd'; +import { ActionInitializer, useAPIClient, useCurrentUserContext, useRequest } from '@tachybase/client'; + import { DeleteOutlined, VerticalAlignBottomOutlined, VerticalAlignTopOutlined } from '@ant-design/icons'; -import { tval, useTranslation } from '../../locale'; +import { Button, Form, Input, message, Popover, Radio, Select, Space, Spin } from 'antd'; + import { PrintStyleContext } from '../../hooks/usePdfPath'; +import { tval, useTranslation } from '../../locale'; type FieldType = { name: string; diff --git a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/RecordPrintSetupActionInitializer.tsx b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/RecordPrintSetupActionInitializer.tsx index bebc8d6da..dc4da5688 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/RecordPrintSetupActionInitializer.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/RecordPrintSetupActionInitializer.tsx @@ -1,8 +1,10 @@ import React, { useContext, useEffect, useState } from 'react'; -import { ActionInitializer } from '@tachybase/client'; +import { ActionInitializer, useRequest } from '@tachybase/client'; + import { Radio, RadioChangeEvent } from 'antd'; -import { useRequest } from '@tachybase/client'; + import { PdfIsLoadContext } from '../../hooks/usePdfPath'; + export const PrintSetup = (props) => { const [value, setValue] = useState(''); const settingsData = useRequest({ diff --git a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/SettlementExportExcel.tsx b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/SettlementExportExcel.tsx index f3d17a613..8be45994e 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/SettlementExportExcel.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/schema-initializer/actions/SettlementExportExcel.tsx @@ -1,10 +1,11 @@ +import { message } from 'antd'; import ExcelJS from 'exceljs'; import { saveAs } from 'file-saver'; import * as QRCode from 'qrcode'; -import { RecordCategory, PromptText, Itemcategory, AddItemsCategory } from '../../../utils/constants'; -import { converDate } from '../../../utils/daysUtils'; + +import { AddItemsCategory, Itemcategory, PromptText, RecordCategory } from '../../../utils/constants'; import { formatPercent } from '../../../utils/currencyUtils'; -import { message } from 'antd'; +import { converDate } from '../../../utils/daysUtils'; export const excelDataHandle = (excelData) => { const { calc, contracts, result } = excelData; diff --git a/packages/plugins/@hera/plugin-rental/src/server/actions/settlement-controller.ts b/packages/plugins/@hera/plugin-rental/src/server/actions/settlement-controller.ts index d7103ea93..19f69d797 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/actions/settlement-controller.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/actions/settlement-controller.ts @@ -1,12 +1,14 @@ import { Context } from '@tachybase/actions'; +import { Cache } from '@tachybase/cache'; +import { Action, Controller, Db, Inject } from '@tachybase/utils'; + import { SqlLoader, SystemSettingService } from '@hera/plugin-core'; -import { Inject, Action, Controller, Db } from '@tachybase/utils'; +import { stringify } from 'flatted'; +import getStream from 'get-stream'; +import { QueryTypes } from 'sequelize'; + import { renderIt } from '../pdf-documents/settlements-document'; import { SettlementService } from '../services/settlement-service'; -import { QueryTypes } from 'sequelize'; -import { Cache } from '@tachybase/cache'; -import getStream from 'get-stream'; -import { stringify } from 'flatted'; @Controller('settlements') export class SettlementController { diff --git a/packages/plugins/@hera/plugin-rental/src/server/actions/waybills-controller.ts b/packages/plugins/@hera/plugin-rental/src/server/actions/waybills-controller.ts index 860927d05..4e1cc307a 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/actions/waybills-controller.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/actions/waybills-controller.ts @@ -1,10 +1,12 @@ import { Context } from '@tachybase/actions'; -import { renderWaybill } from '../pdf-documents/waybills-document'; -import { SqlLoader } from '@hera/plugin-core'; -import { Action, Controller, Inject } from '@tachybase/utils'; -import { QueryTypes } from 'sequelize'; -import { Waybill } from '../../interfaces/waybill'; import { FilterParser } from '@tachybase/database'; +import { Action, Controller, Inject } from '@tachybase/utils'; + +import { SqlLoader } from '@hera/plugin-core'; +import { QueryTypes } from 'sequelize'; + +import { Waybill } from '../../interfaces/waybill'; +import { renderWaybill } from '../pdf-documents/waybills-document'; @Controller('waybills') export class WaybillsController { diff --git a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx index dde180d3b..95a876e3e 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx +++ b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx @@ -1,9 +1,12 @@ import React from 'react'; -import { Document, Page, Text, View, StyleSheet, Image, renderToStream } from '@hera/plugin-core'; +import { dayjs } from '@tachybase/utils'; + +import { Document, Image, Page, renderToStream, StyleSheet, Text, View } from '@hera/plugin-core'; import * as QRCode from 'qrcode'; + import { RecordCategory } from '../../utils/constants'; import { formatCurrency, formatQuantity } from '../../utils/currencyUtils'; -import { dayjs } from '@tachybase/utils'; + /** * * @param isDouble 0为单列,1为双列 diff --git a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/settlements-document.tsx b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/settlements-document.tsx index 96bf7e941..38a3d5587 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/settlements-document.tsx +++ b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/settlements-document.tsx @@ -1,9 +1,11 @@ import * as React from 'react'; -import { Document, Page, Text, View, StyleSheet, Image, renderToStream } from '@hera/plugin-core'; -import * as QRCode from 'qrcode'; + +import { Document, Image, Page, renderToStream, StyleSheet, Text, View } from '@hera/plugin-core'; import _ from 'lodash'; +import * as QRCode from 'qrcode'; + import { Itemcategory, PromptText } from '../../utils/constants'; -import { formatCurrency, formatQuantity, formatPercent } from '../../utils/currencyUtils'; +import { formatCurrency, formatPercent, formatQuantity } from '../../utils/currencyUtils'; import { converDate } from '../../utils/daysUtils'; import { mapIfHas } from '../../utils/mapUtils'; diff --git a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/waybills-document.tsx b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/waybills-document.tsx index f52896cf3..c09425aba 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/waybills-document.tsx +++ b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/waybills-document.tsx @@ -1,8 +1,10 @@ import React from 'react'; -import { Document, Page, Text, View, StyleSheet, renderToStream } from '@hera/plugin-core'; + +import { Document, Page, renderToStream, StyleSheet, Text, View } from '@hera/plugin-core'; + +import { Waybill } from '../../interfaces/waybill'; import { formatCurrency, formatQuantity } from '../../utils/currencyUtils'; import { converDate } from '../../utils/daysUtils'; -import { Waybill } from '../../interfaces/waybill'; const boldFont = { fontFamily: 'source-han-sans', diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts index 87445b71f..f6a69e661 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts @@ -1,9 +1,10 @@ -import { ConversionLogics, RecordCategory, RulesNumber, SourcesType, countCource } from '../../utils/constants'; -import { renderItV2 } from '../pdf-documents/records-documentV2'; -import { Db, Service } from '@tachybase/utils'; -import { RecordPdfOptions } from '../../interfaces/options'; -import { PrintSetup } from '../../utils/system'; import Database from '@tachybase/database'; +import { Db, Service } from '@tachybase/utils'; + +import { RecordPdfOptions } from '../../interfaces/options'; +import { ConversionLogics, countCource, RecordCategory, RulesNumber, SourcesType } from '../../utils/constants'; +import { PrintSetup } from '../../utils/system'; +import { renderItV2 } from '../pdf-documents/records-documentV2'; @Service() export class RecordPdfService { diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts index 84c16563d..ce2ccfd6d 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts @@ -1,5 +1,6 @@ import Database, { CreateOptions, MagicAttributeModel, Transaction } from '@tachybase/database'; import { Db, Service } from '@tachybase/utils'; + import { ConversionLogics, Movement, RecordCategory, RecordTypes, settlementStatus } from '../../utils/constants'; import validateLicensePlate from '../../utils/validateLIcensePlate'; diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts index 2835b35fe..b18f86b3f 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts @@ -1,21 +1,23 @@ -import { Db, Service } from '@tachybase/utils'; import Database from '@tachybase/database'; +import { Db, Service } from '@tachybase/utils'; + import dayjs from 'dayjs'; + +import { Record } from '../../interfaces/record'; +import { RecordItems } from '../../interfaces/records'; +import { FeeRule, LeaseRule } from '../../interfaces/rule'; +import { Settlement } from '../../interfaces/settlement'; import { AddItemsCategory, CalcDateType, ConversionLogics, + countCource, Itemcategory, RulesNumber, - countCource, } from '../../utils/constants'; +import { formatQuantity } from '../../utils/currencyUtils'; import { converDate } from '../../utils/daysUtils'; import { converUnitCount } from '../../utils/unitUtils'; -import { Settlement } from '../../interfaces/settlement'; -import { FeeRule, LeaseRule } from '../../interfaces/rule'; -import { Record } from '../../interfaces/record'; -import { RecordItems } from '../../interfaces/records'; -import { formatQuantity } from '../../utils/currencyUtils'; @Service() export class SettlementService { diff --git a/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShareProduct.tsx b/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShareProduct.tsx index 32d9f2e38..ea2c925dc 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShareProduct.tsx +++ b/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShareProduct.tsx @@ -1,8 +1,11 @@ +import React from 'react'; + import { ShareAltOutlined } from '@ant-design/icons'; import { CustomComponentType } from '@hera/plugin-core/client'; import { Button, Image, Modal, Toast } from 'antd-mobile'; -import React from 'react'; + import downloadImage from '../assets/download.svg'; + import './style.less'; export const ShareProduct = () => { diff --git a/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShowDetail.tsx b/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShowDetail.tsx index 0d99e33e5..809652ef6 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShowDetail.tsx +++ b/packages/plugins/@hera/plugin-sancongtou/src/client/custom-components/ShowDetail.tsx @@ -1,7 +1,10 @@ -import { CustomComponentType } from '@hera/plugin-core/client'; import React from 'react'; + +import { CustomComponentType } from '@hera/plugin-core/client'; import { Link, useNavigate } from 'react-router-dom'; + import './style.less'; + import { getPathProductDetail } from '../utils/path'; // @deprecated diff --git a/packages/plugins/@hera/plugin-sancongtou/src/client/index.tsx b/packages/plugins/@hera/plugin-sancongtou/src/client/index.tsx index a508b369c..306442104 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-sancongtou/src/client/index.tsx @@ -1,4 +1,5 @@ import { Plugin } from '@tachybase/client'; + // import { ProductDetail } from './pages/ProductDetail.1'; import { ShareProduct } from './custom-components/ShareProduct'; import { ShowDetail } from './custom-components/ShowDetail'; diff --git a/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.provider.tsx b/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.provider.tsx index 7a509dd48..5ae57226b 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.provider.tsx +++ b/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.provider.tsx @@ -1,6 +1,8 @@ -import { DataBlockProvider, useCollectionManager } from '@tachybase/client'; import React from 'react'; +import { DataBlockProvider, useCollectionManager } from '@tachybase/client'; + import { useParams } from 'react-router-dom'; + // import { ProductDetail } from './ProductDetail'; // THINK: provider 主要作用是定位于, 连接数据库, 不做其他的逻辑 diff --git a/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.schema.tsx b/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.schema.tsx index d3b31f1df..e2019351d 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.schema.tsx +++ b/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.schema.tsx @@ -1,11 +1,13 @@ +import React from 'react'; import { Plugin, SchemaComponent, useCollectionManager } from '@tachybase/client'; import { MPage } from '@tachybase/plugin-mobile-client/client'; -import React from 'react'; -import { CardDetailProvider } from './CardDetail.provider'; -import { CardDetailView } from './CardDetail.view'; -import { useScopeCardDetail } from './CardDetail.scope'; + import { useParams } from 'react-router-dom'; +import { CardDetailProvider } from './CardDetail.provider'; +import { useScopeCardDetail } from './CardDetail.scope'; +import { CardDetailView } from './CardDetail.view'; + // THINK: plugin的注册,应该每个组件自己管自己的, 提高内聚性, 就近原则; // 或者单独写一个轻量的给组件用的 plugin, 用于注册 // 这里暂时用 SC 的前缀 表明这一用途, schema component diff --git a/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.view.tsx b/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.view.tsx index 2af94c375..83f5baec1 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.view.tsx +++ b/packages/plugins/@hera/plugin-sancongtou/src/client/pages/CardDetail.view.tsx @@ -1,7 +1,9 @@ -import { withDynamicSchemaProps } from '@tachybase/client'; -import { Image, NavBar, Skeleton } from 'antd-mobile'; import React from 'react'; +import { withDynamicSchemaProps } from '@tachybase/client'; + +import { Image, NavBar, Skeleton } from 'antd-mobile'; import { useNavigate } from 'react-router-dom'; + import './style.less'; // TODO: 需要提升图片加载速度, 现在是数据库请求然后用 url 去云端拿图片,导致体验有延迟 diff --git a/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts b/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts index 55d43bbf5..36df8c0e8 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts +++ b/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts @@ -1,7 +1,8 @@ -import { SqlLoader } from '@hera/plugin-core'; +import path from 'path'; import { Plugin } from '@tachybase/server'; import { Container } from '@tachybase/utils'; -import path from 'path'; + +import { SqlLoader } from '@hera/plugin-core'; export class PluginSancongtouServer extends Plugin { async afterAdd() {} diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockActionInitializer.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockActionInitializer.ts index 0c4a230cb..e2d5b4cae 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockActionInitializer.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockActionInitializer.ts @@ -1,4 +1,5 @@ -import { useCollection_deprecated, SchemaInitializer } from '@tachybase/client'; +import { SchemaInitializer, useCollection_deprecated } from '@tachybase/client'; + import { tval } from './locale'; export const CommentBlockActionInitializer = new SchemaInitializer({ diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockInitializer.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockInitializer.ts index a2d4915c4..8d5f73e24 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockInitializer.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockInitializer.ts @@ -1,13 +1,15 @@ +import { useContext } from 'react'; import { + DataBlockInitializer, + useCollectionManager_deprecated, useSchemaInitializer, useSchemaInitializerItem, - useCollectionManager_deprecated, - DataBlockInitializer, } from '@tachybase/client'; -import { useContext } from 'react'; -import jsxRuntime from 'react/jsx-runtime'; -import { CommentOutlined } from '@ant-design/icons'; import { SchemaOptionsContext } from '@tachybase/schema'; + +import { CommentOutlined } from '@ant-design/icons'; +import jsxRuntime from 'react/jsx-runtime'; + import { createCommentUISchema } from './createCommentUISchema'; export const CommentBlockInitializer = ({ diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockSchemaSettings.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockSchemaSettings.ts index 7779b2b9e..f8b768145 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockSchemaSettings.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentBlockSchemaSettings.ts @@ -1,15 +1,17 @@ import { - useDesignable, + removeNullCondition, SchemaSettings, SchemaSettingsBlockTitleItem, SchemaSettingsDataScope, useCollection_deprecated, + useDesignable, useFormBlockContext, - removeNullCondition, } from '@tachybase/client'; -import lodash from 'lodash'; -import { useTranslation } from './locale'; import { useField, useFieldSchema } from '@tachybase/schema'; + +import lodash from 'lodash'; + +import { useTranslation } from './locale'; import { useComment } from './useComment'; export const CommentBlockSchemaSettings = new SchemaSettings({ diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentCollectionTemplate.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentCollectionTemplate.ts index 129bd0fc0..140514c0e 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentCollectionTemplate.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentCollectionTemplate.ts @@ -1,4 +1,5 @@ import { CollectionTemplate, getConfigurableProperties } from '@tachybase/client'; + import { tval } from './locale'; export class CommentCollectionTemplate extends CollectionTemplate { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentDecorator.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentDecorator.ts index 8ef0de251..3192e473b 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentDecorator.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentDecorator.ts @@ -1,13 +1,15 @@ +import { useCallback, useEffect, useState } from 'react'; import { - withDynamicSchemaProps, - List, CollectionManagerProvider, CollectionProvider, + List, useDesignable, + withDynamicSchemaProps, } from '@tachybase/client'; -import jsxRuntime from 'react/jsx-runtime'; import { useField, useFieldSchema } from '@tachybase/schema'; -import { useCallback, useEffect, useState } from 'react'; + +import jsxRuntime from 'react/jsx-runtime'; + import { CommentContext } from './CommentContext'; export const CommentDecorator = withDynamicSchemaProps((props) => { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentItem.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentItem.ts index fddfcfcef..6a98c9023 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentItem.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentItem.ts @@ -1,15 +1,17 @@ -import { - useBlockRequestContext, - useCollectionParentRecordData, - useCollectionFields, - RecordProvider, -} from '@tachybase/client'; import react from 'react'; -import jsxRuntime from 'react/jsx-runtime'; -import dayjs from 'dayjs'; -import { useTranslation } from './locale'; -import { RecursionField, observer, useField } from '@tachybase/schema'; +import { + RecordProvider, + useBlockRequestContext, + useCollectionFields, + useCollectionParentRecordData, +} from '@tachybase/client'; +import { observer, RecursionField, useField } from '@tachybase/schema'; + import { Button, Card, Tooltip } from 'antd'; +import dayjs from 'dayjs'; +import jsxRuntime from 'react/jsx-runtime'; + +import { useTranslation } from './locale'; import { styles } from './styles'; export const CommentItem = observer((e) => { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentList.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentList.ts index 26db961e0..d377d18b4 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentList.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentList.ts @@ -1,8 +1,10 @@ -import { useBlockRequestContext, withDynamicSchemaProps } from '@tachybase/client'; import { useCallback, useState } from 'react'; -import jsxRuntime from 'react/jsx-runtime'; +import { useBlockRequestContext, withDynamicSchemaProps } from '@tachybase/client'; import { RecursionField, Schema, useField, useFieldSchema, useForm } from '@tachybase/schema'; + import { List, Spin } from 'antd'; +import jsxRuntime from 'react/jsx-runtime'; + import { styles } from './styles'; export const CommentList = withDynamicSchemaProps((props) => { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/CommentSubmit.ts b/packages/plugins/@tachybase/plugin-comments/src/client/CommentSubmit.ts index 7615f3b2f..b0f738dfa 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/CommentSubmit.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/CommentSubmit.ts @@ -1,15 +1,17 @@ +import { useCallback, useMemo } from 'react'; import { + useACLActionParamsContext, useBlockRequestContext, useCollectionFields, useDesignable, - useACLActionParamsContext, } from '@tachybase/client'; -import { useCallback, useMemo } from 'react'; +import { RecursionField, useField } from '@tachybase/schema'; + +import { Button } from 'antd'; import jsxRuntime from 'react/jsx-runtime'; + import { useTranslation } from './locale'; import { styles } from './styles'; -import { useField, RecursionField } from '@tachybase/schema'; -import { Button } from 'antd'; import { useComment } from './useComment'; export function CommentSubmit() { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionButton.tsx b/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionButton.tsx index 07a3c9fca..e5db0369f 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionButton.tsx +++ b/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionButton.tsx @@ -1,9 +1,9 @@ -import React from 'react'; -import { useDesignable, useACLActionParamsContext } from '@tachybase/client'; -import { useCallback } from 'react'; -import { useTranslation } from './locale'; +import React, { useCallback } from 'react'; +import { useACLActionParamsContext, useDesignable } from '@tachybase/client'; import { useField } from '@tachybase/schema'; +import { useTranslation } from './locale'; + export function QuoteReplyCommentActionButton() { const field = useField(); const { t } = useTranslation(); diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionInitializer.tsx b/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionInitializer.tsx index 1754fe706..f59bf2266 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionInitializer.tsx +++ b/packages/plugins/@tachybase/plugin-comments/src/client/QuoteReplyCommentActionInitializer.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { ActionInitializer } from '@tachybase/client'; + import { useTranslation } from './locale'; export function QuoteReplyCommentActionInitializer(props) { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/UpdateCommentActionButton.tsx b/packages/plugins/@tachybase/plugin-comments/src/client/UpdateCommentActionButton.tsx index 3c7a10b4a..54f3f07d6 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/UpdateCommentActionButton.tsx +++ b/packages/plugins/@tachybase/plugin-comments/src/client/UpdateCommentActionButton.tsx @@ -1,9 +1,9 @@ -import React from 'react'; -import { useDesignable, useACLActionParamsContext } from '@tachybase/client'; -import { useEffect, useState } from 'react'; -import { useTranslation } from './locale'; +import React, { useEffect, useState } from 'react'; +import { useACLActionParamsContext, useDesignable } from '@tachybase/client'; import { useField } from '@tachybase/schema'; +import { useTranslation } from './locale'; + export function UpdateCommentActionButton() { const field = useField(); const { t } = useTranslation(); diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/index.ts b/packages/plugins/@tachybase/plugin-comments/src/client/index.ts index 9f6e89ac7..cb57ae5e1 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/index.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/index.ts @@ -1,19 +1,20 @@ -import { ActionBar, Plugin, useCollection, canMakeAssociationBlock, useCollectionManager } from '@tachybase/client'; import { useMemo } from 'react'; -import { tval } from './locale'; -import { CommentList } from './CommentList'; -import { CommentItem } from './CommentItem'; -import { CommentCollectionTemplate } from './CommentCollectionTemplate'; -import { CommentBlockSchemaSettings } from './CommentBlockSchemaSettings'; +import { ActionBar, canMakeAssociationBlock, Plugin, useCollection, useCollectionManager } from '@tachybase/client'; + import { CommentBlockActionInitializer } from './CommentBlockActionInitializer'; -import { QuoteReplyCommentActionInitializer } from './QuoteReplyCommentActionInitializer'; -import { CommentSubmit } from './CommentSubmit'; +import { CommentBlockInitializer } from './CommentBlockInitializer'; +import { CommentBlockSchemaSettings } from './CommentBlockSchemaSettings'; +import { CommentCollectionTemplate } from './CommentCollectionTemplate'; import { CommentDecorator } from './CommentDecorator'; -import { useCommentBlockDecoratorProps } from './useCommentBlockDecoratorProps'; +import { CommentItem } from './CommentItem'; +import { CommentList } from './CommentList'; +import { CommentSubmit } from './CommentSubmit'; +import { tval } from './locale'; import { QuoteReplyCommentActionButton } from './QuoteReplyCommentActionButton'; +import { QuoteReplyCommentActionInitializer } from './QuoteReplyCommentActionInitializer'; import { UpdateCommentActionButton } from './UpdateCommentActionButton'; import { UpdateCommentActionInitializer } from './UpdateCommentActionInitializer'; -import { CommentBlockInitializer } from './CommentBlockInitializer'; +import { useCommentBlockDecoratorProps } from './useCommentBlockDecoratorProps'; const Comment = () => null; Comment.ActionBar = ActionBar; diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/locale.ts b/packages/plugins/@tachybase/plugin-comments/src/client/locale.ts index a34e470fb..1ffb220f3 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/locale.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/locale.ts @@ -1,4 +1,5 @@ import { tval as cTval } from '@tachybase/client'; + import { useTranslation as useT } from 'react-i18next'; export function tval(e) { diff --git a/packages/plugins/@tachybase/plugin-comments/src/client/useComment.ts b/packages/plugins/@tachybase/plugin-comments/src/client/useComment.ts index 0c59cfd76..6f665e077 100644 --- a/packages/plugins/@tachybase/plugin-comments/src/client/useComment.ts +++ b/packages/plugins/@tachybase/plugin-comments/src/client/useComment.ts @@ -1,4 +1,5 @@ import { useContext } from 'react'; + import { CommentContext } from './CommentContext'; export function useComment() { diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/msql.tsx b/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/msql.tsx index c50e557e2..d8afc5b36 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/msql.tsx +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/msql.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { SchemaComponent } from '@tachybase/client'; + import { tval, usePluginTranslation } from '../locale'; export const MysqlDataSourceSettingsForm = () => { diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/pg.tsx b/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/pg.tsx index 6840f36d7..729d8db42 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/pg.tsx +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/client/forms/pg.tsx @@ -1,6 +1,8 @@ import React from 'react'; -import { Space } from 'antd'; import { SchemaComponent } from '@tachybase/client'; + +import { Space } from 'antd'; + import { tval, usePluginTranslation } from '../locale'; export const PgDataSourceSettingsForm = () => { diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/client/locale.ts b/packages/plugins/@tachybase/plugin-external-data-source/src/client/locale.ts index fa6b8c21f..c47ac7b9c 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/client/locale.ts +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/client/locale.ts @@ -1,4 +1,5 @@ import { i18n } from '@tachybase/client'; + import { useTranslation } from 'react-i18next'; export const NAMESPACE = '@hera/plugin-external-data-source'; diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-collection-manager.ts b/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-collection-manager.ts index 4335b889e..a5d6a9054 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-collection-manager.ts +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-collection-manager.ts @@ -1,2 +1,3 @@ import { SequelizeCollectionManager } from '@tachybase/data-source-manager'; + export class MySQLCollectionManager extends SequelizeCollectionManager {} diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-data-source.ts b/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-data-source.ts index d4c962ad4..c62b665c8 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-data-source.ts +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/server/mysql/mysql-data-source.ts @@ -1,7 +1,8 @@ import { DataSource } from '@tachybase/data-source-manager'; import { Database } from '@tachybase/database'; -import { MySQLCollectionManager } from './mysql-collection-manager'; + import { DatabaseIntrospector } from './database-introspector'; +import { MySQLCollectionManager } from './mysql-collection-manager'; import typeInterfaceMap from './type-interface-map'; export class MySQLDataSource extends DataSource { diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-collection-manager.ts b/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-collection-manager.ts index 5ec978a3d..312d7e211 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-collection-manager.ts +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-collection-manager.ts @@ -1,2 +1,3 @@ import { SequelizeCollectionManager } from '@tachybase/data-source-manager'; + export class PostgresCollectionManager extends SequelizeCollectionManager {} diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-data-source.ts b/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-data-source.ts index 818354a60..f79a70177 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-data-source.ts +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/server/pg/postgres-data-source.ts @@ -1,7 +1,8 @@ import { DataSource } from '@tachybase/data-source-manager'; import { Database, type IDatabaseOptions } from '@tachybase/database'; -import { PostgresCollectionManager } from './postgres-collection-manager'; + import { DatabaseIntrospector } from './database-introspector'; +import { PostgresCollectionManager } from './postgres-collection-manager'; import typeInterfaceMap from './type-interface-map'; export class PostgresDataSource extends DataSource { diff --git a/packages/plugins/@tachybase/plugin-external-data-source/src/server/plugin.ts b/packages/plugins/@tachybase/plugin-external-data-source/src/server/plugin.ts index 69f0b1d11..5289e0315 100644 --- a/packages/plugins/@tachybase/plugin-external-data-source/src/server/plugin.ts +++ b/packages/plugins/@tachybase/plugin-external-data-source/src/server/plugin.ts @@ -1,6 +1,7 @@ import { Plugin } from '@tachybase/server'; -import { PostgresDataSource } from './pg/postgres-data-source'; + import { MySQLDataSource } from './mysql/mysql-data-source'; +import { PostgresDataSource } from './pg/postgres-data-source'; export class PluginExternalDataSourceServer extends Plugin { async afterAdd() {} diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx index 2d27a4534..d5d99aa89 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx @@ -1,5 +1,7 @@ import React, { PropsWithChildren, useEffect } from 'react'; + import { useLocation, useNavigate } from 'react-router-dom'; + import { isJSBridge } from './core/bridge'; export const MobileClientProvider = React.memo((props: PropsWithChildren) => { diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx index da567a3c0..f1408d872 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx @@ -1,7 +1,9 @@ +import React, { useEffect } from 'react'; import { useCollectionField } from '@tachybase/client'; import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/schema'; + import { Checkbox, CheckboxGroupProps, CheckboxProps, Tag } from 'antd-mobile'; -import React, { useEffect } from 'react'; + type ComposedCheckBox = React.FC & { Group?: any; }; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx index 770b75641..bb3201f47 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx @@ -1,7 +1,8 @@ +import React, { useEffect } from 'react'; import { useCollectionField } from '@tachybase/client'; import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/schema'; + import { Radio, RadioGroupProps, RadioProps, Tag } from 'antd-mobile'; -import React, { useEffect } from 'react'; type ComposedRadio = React.FC & { Group?: any; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/container/Container.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/container/Container.tsx index 2789ef91f..7bf29b055 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/container/Container.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/container/Container.tsx @@ -1,10 +1,12 @@ -import { useField, useFieldSchema } from '@tachybase/schema'; -import { cx, SchemaComponent, SortableItem, useDesigner, useToken } from '@tachybase/client'; import React, { useEffect } from 'react'; +import { cx, SchemaComponent, SortableItem, useDesigner, useToken } from '@tachybase/client'; +import { useField, useFieldSchema } from '@tachybase/schema'; + import { Navigate, useLocation, useNavigate, useParams } from 'react-router-dom'; + +import { MobileProvider } from '../../provider/MobileProvider'; import { ContainerDesigner } from './Container.Designer'; import useStyles from './style'; -import { MobileProvider } from '../../provider/MobileProvider'; const findGrid = (schema, uid) => { return schema.reduceProperties((final, next) => { diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx index eb07bfa77..4be7e2dc9 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx @@ -1,15 +1,16 @@ import { AssociatedFields, CompatibleSchemaInitializer, - ParentCollectionFields, - SchemaInitializerItemType, formItemInitializers_deprecated, gridRowColWrap, + ParentCollectionFields, + SchemaInitializerItemType, useActionContext, - useCollectionManager_deprecated, useCollection_deprecated, + useCollectionManager_deprecated, } from '@tachybase/client'; import { Schema, useForm } from '@tachybase/schema'; + import { useIsMobile } from '../../hooks'; import { canMobileField } from './CustomComponent'; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/ImageSearch.configure.ts b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/ImageSearch.configure.ts index 937e28995..3e3aae61b 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/ImageSearch.configure.ts +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/ImageSearch.configure.ts @@ -1,7 +1,8 @@ import { SchemaInitializer, useCollection, useCollectionManager } from '@tachybase/client'; + +import { useIsMobile } from '../../hooks'; import { canBeOptionalField, canBeRelatedField } from '../tab-search/utils'; import { createSchemaImageSearchItem } from './search-item/ImageSearchItem.schema'; -import { useIsMobile } from '../../hooks'; export const ImageSearchConfigureFields = new SchemaInitializer({ name: 'ImageSearchView:configureFields', diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/search-item/ImageSearchItem.view.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/search-item/ImageSearchItem.view.tsx index 94f70d8e8..0e598732a 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/search-item/ImageSearchItem.view.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/image-search/search-item/ImageSearchItem.view.tsx @@ -1,8 +1,11 @@ -import { SortableItem, css, useCollection, useDesigner, withDynamicSchemaProps } from '@tachybase/client'; -import { useFieldSchema } from '@tachybase/schema'; -import { Image, JumboTabs } from 'antd-mobile'; import React from 'react'; +import { css, SortableItem, useCollection, useDesigner, withDynamicSchemaProps } from '@tachybase/client'; +import { useFieldSchema } from '@tachybase/schema'; + +import { Image, JumboTabs } from 'antd-mobile'; + import { useTranslation } from '../../../../../locale'; + // import { useActionImageSearchItemView } from '../hooks/useAction.ImageSearchItemView'; export const ImageSearchItemView = withDynamicSchemaProps( diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/TabSearchCollapsibleInputMItemChild.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/TabSearchCollapsibleInputMItemChild.tsx index 68aa507ec..f33fef756 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/TabSearchCollapsibleInputMItemChild.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/TabSearchCollapsibleInputMItemChild.tsx @@ -1,11 +1,13 @@ +import React, { useRef, useState } from 'react'; +import { css } from '@tachybase/client'; import { dayjs } from '@tachybase/utils/client'; + import { ActionSheet, Button, Calendar, Divider, Grid, Input, Picker, Popup } from 'antd-mobile'; import { DownOutline } from 'antd-mobile-icons'; import type { Action } from 'antd-mobile/es/components/action-sheet'; -import React, { useRef, useState } from 'react'; + import { useTranslation } from '../../../../../../locale'; import { convertFormat } from '../../utils'; -import { css } from '@tachybase/client'; export const ISelect = (props) => { const { options, onChange, customLabelKey } = props; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/hooks.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/hooks.tsx index 5e7379dd1..6fe37daa5 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/hooks.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/components/field-item/hooks.tsx @@ -1,5 +1,6 @@ import { findFilterTargets, mergeFilter, useCollection, useFilterBlock } from '@tachybase/client'; import { useFieldSchema } from '@tachybase/schema'; + import _ from 'lodash'; export const useTabSearchCollapsibleInputItem = () => { diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchAssociated.fields.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchAssociated.fields.tsx index 193b0544a..1a6b1864c 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchAssociated.fields.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchAssociated.fields.tsx @@ -1,21 +1,22 @@ +import React, { useCallback } from 'react'; import { CollectionFieldOptions_deprecated, CollectionManager, FieldOptions, InheritanceCollectionMixin, + isAssocField, SchemaInitializerChildren, SchemaInitializerItemType, - isAssocField, useCollection, useCollectionManager, useDataSource, useDataSourceManager, } from '@tachybase/client'; -import React, { useCallback } from 'react'; + import { tval } from '../../../../../locale'; -import { canBeDataField, canBeOptionalField, canBeRelatedField, canBeSearchField } from '../utils'; import { useIsMobile } from '../../../hooks'; import { mapToMobile } from '../mapToMobile'; +import { canBeDataField, canBeOptionalField, canBeRelatedField, canBeSearchField } from '../utils'; interface ItemInterface { field: FieldOptions; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchFieldSchemaInitializer.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchFieldSchemaInitializer.tsx index b510f0a01..4cb7ac4d0 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchFieldSchemaInitializer.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/tab-search/initializer/TabSearchFieldSchemaInitializer.tsx @@ -1,9 +1,10 @@ import { SchemaInitializer, useCollection, useCollectionManager } from '@tachybase/client'; + import { tval } from '../../../../../locale'; +import { useIsMobile } from '../../../hooks'; import { createTabSearchItemSchema } from '../create/createTabSearchItemSchema'; import { canBeDataField, canBeOptionalField, canBeRelatedField, canBeSearchField } from '../utils'; import { TabSearchAssociatedFields } from './TabSearchAssociated.fields'; -import { useIsMobile } from '../../../hooks'; export const TabSearchFieldSchemaInitializer = new SchemaInitializer({ name: 'tabSearch:configureFields', diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts index 9b8c18346..3fa14669a 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts @@ -1,4 +1,5 @@ import { CompatibleSchemaInitializer, gridRowColWrap } from '@tachybase/client'; + import { generateNTemplate, tval } from '../../../locale'; /** diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx index 146db0b82..795ef6abc 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx @@ -1,5 +1,5 @@ -import { css, cx } from '@tachybase/client'; import React, { PropsWithChildren } from 'react'; +import { css, cx } from '@tachybase/client'; type IProps = PropsWithChildren<{ className: string; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/index.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/index.tsx index 5aeb5b569..493f47e91 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/index.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/index.tsx @@ -1,5 +1,6 @@ -import { css, cx } from '@tachybase/client'; import React, { PropsWithChildren } from 'react'; +import { css, cx } from '@tachybase/client'; + // import { useLocation } from 'react-router-dom'; import Device from './iOS6'; diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppManager.tsx b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppManager.tsx index 46a8bee16..78f33312e 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppManager.tsx +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppManager.tsx @@ -1,6 +1,8 @@ -import { SchemaComponent, useApp, useRecord } from '@tachybase/client'; -import { Card } from 'antd'; import React from 'react'; +import { SchemaComponent, useApp, useRecord } from '@tachybase/client'; + +import { Card } from 'antd'; + import { schema } from './settings/schemas/applications'; import { usePluginUtils } from './utils'; diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppNameInput.tsx b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppNameInput.tsx index 29ebf47ef..8840811a0 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppNameInput.tsx +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppNameInput.tsx @@ -1,7 +1,8 @@ -import { connect, mapReadPretty } from '@tachybase/schema'; -import { useApp } from '@tachybase/client'; -import { Input as AntdInput } from 'antd'; import React from 'react'; +import { useApp } from '@tachybase/client'; +import { connect, mapReadPretty } from '@tachybase/schema'; + +import { Input as AntdInput } from 'antd'; const ReadPretty = (props) => { const app = useApp(); diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/MultiAppManagerProvider.tsx b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/MultiAppManagerProvider.tsx index d9b99aa9a..161701b66 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/MultiAppManagerProvider.tsx +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/MultiAppManagerProvider.tsx @@ -1,7 +1,9 @@ -import { Icon, PinnedPluginListProvider, SchemaComponentOptions, useApp, useRequest } from '@tachybase/client'; -import { Button, Dropdown } from 'antd'; import React from 'react'; +import { Icon, PinnedPluginListProvider, SchemaComponentOptions, useApp, useRequest } from '@tachybase/client'; + +import { Button, Dropdown } from 'antd'; import { Link } from 'react-router-dom'; + import { AppNameInput } from './AppNameInput'; import { useStyles } from './MultiAppManagerProvider.style'; import { usePluginUtils } from './utils'; diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/Settings.tsx b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/Settings.tsx index 02d420a77..f354990a8 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/Settings.tsx +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/Settings.tsx @@ -1,6 +1,7 @@ -import { SchemaComponent } from '@tachybase/client'; -import { Card } from 'antd'; import React from 'react'; +import { SchemaComponent } from '@tachybase/client'; + +import { Card } from 'antd'; const schema = { type: 'object', diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/index.ts b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/index.ts index c621fad0e..49ea78511 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/index.ts +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/index.ts @@ -1,7 +1,8 @@ import { Plugin } from '@tachybase/client'; -import { MultiAppManagerProvider } from './MultiAppManagerProvider'; -import { AppManager } from './AppManager'; + import { NAMESPACE } from '../locale'; +import { AppManager } from './AppManager'; +import { MultiAppManagerProvider } from './MultiAppManagerProvider'; export class MultiAppManagerPlugin extends Plugin { async load() { diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/settings/schemas/applications.ts b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/settings/schemas/applications.ts index f1fa178de..f68ec55ff 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/settings/schemas/applications.ts +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/settings/schemas/applications.ts @@ -1,5 +1,4 @@ -import { ISchema } from '@tachybase/schema'; -import { uid } from '@tachybase/schema'; +import React from 'react'; import { SchemaComponentOptions, tval, @@ -9,7 +8,8 @@ import { useResourceActionContext, useResourceContext, } from '@tachybase/client'; -import React from 'react'; +import { ISchema, uid } from '@tachybase/schema'; + import { i18nText } from '../../utils'; const collection = { diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/gateway.test.ts b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/gateway.test.ts index b3ab13b61..de0d7dfb8 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/gateway.test.ts +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/gateway.test.ts @@ -1,5 +1,5 @@ import { AppSupervisor, Gateway } from '@tachybase/server'; -import { MockServer, createMockServer, createWsClient, startServerWithRandomPort, waitSecond } from '@tachybase/test'; +import { createMockServer, createWsClient, MockServer, startServerWithRandomPort, waitSecond } from '@tachybase/test'; import { uid } from '@tachybase/utils'; describe('gateway with multiple apps', () => { diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/mock-get-schema.test.ts b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/mock-get-schema.test.ts index 15d496be4..2ba0873e5 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/mock-get-schema.test.ts +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/__tests__/mock-get-schema.test.ts @@ -1,6 +1,7 @@ import { AppSupervisor, Plugin, PluginManager } from '@tachybase/server'; import { createMockServer } from '@tachybase/test'; import { uid } from '@tachybase/utils'; + import { vi } from 'vitest'; describe('test with start', () => { diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/models/application.ts b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/models/application.ts index 276be4ba2..62d0dd8fe 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/models/application.ts +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/models/application.ts @@ -1,8 +1,9 @@ import { Model, Transactionable } from '@tachybase/database'; import { Application } from '@tachybase/server'; -import { AppOptionsFactory } from '../server'; import { merge } from '@tachybase/utils'; +import { AppOptionsFactory } from '../server'; + export interface registerAppOptions extends Transactionable { skipInstall?: boolean; appOptionsFactory: AppOptionsFactory; diff --git a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/server.ts b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/server.ts index b706d1d75..0bd421312 100644 --- a/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/server.ts +++ b/packages/plugins/@tachybase/plugin-multi-app-manager/src/server/server.ts @@ -1,7 +1,9 @@ +import path from 'path'; import { Database, IDatabaseOptions, Transactionable } from '@tachybase/database'; import Application, { AppSupervisor, Gateway, Plugin } from '@tachybase/server'; + import lodash from 'lodash'; -import path from 'path'; + import { ApplicationModel } from '../server'; export type AppDbCreator = (app: Application, options?: Transactionable & { context?: any }) => Promise; diff --git a/packages/presets/mini/src/server/index.ts b/packages/presets/mini/src/server/index.ts index 68e865b5a..7bf262356 100644 --- a/packages/presets/mini/src/server/index.ts +++ b/packages/presets/mini/src/server/index.ts @@ -1,4 +1,5 @@ import PresetTachyBase from '@tachybase/preset-tachybase'; + import _ from 'lodash'; export class PluginMini extends PresetTachyBase { diff --git a/packages/presets/rental/src/server/index.ts b/packages/presets/rental/src/server/index.ts index 39dcfa00a..fac1beb58 100644 --- a/packages/presets/rental/src/server/index.ts +++ b/packages/presets/rental/src/server/index.ts @@ -1,4 +1,5 @@ import PresetTachyBase from '@tachybase/preset-tachybase'; + import _ from 'lodash'; export class PluginRental extends PresetTachyBase { diff --git a/packages/presets/sancongtou/src/server/index.ts b/packages/presets/sancongtou/src/server/index.ts index 9e6ae06a1..50f74a93d 100644 --- a/packages/presets/sancongtou/src/server/index.ts +++ b/packages/presets/sancongtou/src/server/index.ts @@ -1,4 +1,5 @@ import PresetTachyBase from '@tachybase/preset-tachybase'; + import _ from 'lodash'; export class PluginSancongtou extends PresetTachyBase {