Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2024-12-27 11:35:35 +00:00
commit 6a488f2189
6 changed files with 153 additions and 141 deletions

View File

@ -10,6 +10,7 @@
import { createForm } from '@formily/core';
import { useField, useFieldSchema } from '@formily/react';
import {
BlockProvider,
BlockRequestContext_deprecated,
CollectionManagerProvider,
CollectionProvider_deprecated,
@ -82,20 +83,20 @@ export function FormBlockProvider(props) {
return !userJob?.status || values ? (
<CollectionManagerProvider dataSource={dataSource}>
<CollectionProvider_deprecated collection={props.collection}>
<RecordProvider record={values} parent={null}>
<RerenderDataBlockProvider>
<FormActiveFieldsProvider name="form">
<BlockRequestContext_deprecated.Provider
value={{ block: 'form', props, field, service, resource, __parent }}
>
<FormBlockContext.Provider value={formBlockValue}>
<BlockProvider name={props.name || 'form'} {...props} block={'form'} parentRecord={null}>
<FormActiveFieldsProvider name="form">
<BlockRequestContext_deprecated.Provider
value={{ block: 'form', props, field, service, resource, __parent }}
>
<FormBlockContext.Provider value={formBlockValue}>
<RecordProvider record={values} parent={null}>
<FormV2.Templates style={{ marginBottom: token.margin }} form={form} />
<div ref={formBlockRef}>{props.children}</div>
</FormBlockContext.Provider>
</BlockRequestContext_deprecated.Provider>
</FormActiveFieldsProvider>
</RerenderDataBlockProvider>
</RecordProvider>
</RecordProvider>
</FormBlockContext.Provider>
</BlockRequestContext_deprecated.Provider>
</FormActiveFieldsProvider>
</BlockProvider>
</CollectionProvider_deprecated>
</CollectionManagerProvider>
) : null;

View File

@ -58,6 +58,7 @@ export function AssignedFieldsFormSchemaConfig(props) {
const { setFormValueChanged } = useActionContext();
const api = useAPIClient();
const scope = useWorkflowVariableOptions();
const { values, setValuesIn, disabled } = useForm();
const params = toJS(values.params);
const [dataSourceName, collectionName] = parseCollectionName(values.collection);

View File

@ -16,6 +16,7 @@ import {
CollectionProvider_deprecated,
FormBlockContext,
RecordProvider,
RerenderDataBlockProvider,
parseCollectionName,
useAPIClient,
useAssociationNames,
@ -86,20 +87,22 @@ export function DetailsBlockProvider({ collection, dataPath, children }) {
return (
<CollectionProvider_deprecated dataSource={dataSourceName} collection={resolvedCollection}>
<RecordProvider record={values} parent={null}>
<BlockRequestContext_deprecated.Provider value={{ block: 'form', field, service, resource, __parent }}>
<FormBlockContext.Provider
value={{
params,
form,
field,
service,
updateAssociationValues,
formBlockRef,
}}
>
{children}
</FormBlockContext.Provider>
</BlockRequestContext_deprecated.Provider>
<RerenderDataBlockProvider>
<BlockRequestContext_deprecated.Provider value={{ block: 'form', field, service, resource, __parent }}>
<FormBlockContext.Provider
value={{
params,
form,
field,
service,
updateAssociationValues,
formBlockRef,
}}
>
{children}
</FormBlockContext.Provider>
</BlockRequestContext_deprecated.Provider>
</RerenderDataBlockProvider>
</RecordProvider>
</CollectionProvider_deprecated>
);

View File

@ -9,13 +9,131 @@
import React from 'react';
import { Variable } from '@nocobase/client';
import { useCompile, Variable } from '@nocobase/client';
import type { DefaultOptionType } from 'antd/lib/cascader';
import { useWorkflowVariableOptions } from '../variable';
import { NAMESPACE } from '../locale';
const dateRangeSystemVariables = {
key: 'dateRange',
label: `{{t('Date range', { ns: '${NAMESPACE}' })}}`,
value: 'dateRange',
children: [
{
key: 'yesterday',
value: 'yesterday',
label: '{{t("Yesterday")}}',
},
{
key: 'today',
value: 'today',
label: '{{t("Today")}}',
},
{
key: 'tomorrow',
value: 'tomorrow',
label: '{{t("Tomorrow")}}',
},
{
key: 'lastWeek',
value: 'lastWeek',
label: '{{t("Last week")}}',
},
{
key: 'thisWeek',
value: 'thisWeek',
label: '{{t("This week")}}',
},
{
key: 'nextWeek',
value: 'nextWeek',
label: '{{t("Next week")}}',
},
{
key: 'lastMonth',
value: 'lastMonth',
label: '{{t("Last month")}}',
},
{
key: 'thisMonth',
value: 'thisMonth',
label: '{{t("This month")}}',
},
{
key: 'nextMonth',
value: 'nextMonth',
label: '{{t("Next month")}}',
},
{
key: 'lastQuarter',
value: 'lastQuarter',
label: '{{t("Last quarter")}}',
},
{
key: 'thisQuarter',
value: 'thisQuarter',
label: '{{t("This quarter")}}',
},
{
key: 'nextQuarter',
value: 'nextQuarter',
label: '{{t("Next quarter")}}',
},
{
key: 'lastYear',
value: 'lastYear',
label: '{{t("Last year")}}',
},
{
key: 'thisYear',
value: 'thisYear',
label: '{{t("This year")}}',
},
{
key: 'nextYear',
value: 'nextYear',
label: '{{t("Next year")}}',
},
{
key: 'last7Days',
value: 'last7Days',
label: '{{t("Last 7 days")}}',
},
{
key: 'next7Days',
value: 'next7Days',
label: '{{t("Next 7 days")}}',
},
{
key: 'last30Days',
value: 'last30Days',
label: '{{t("Last 30 days")}}',
},
{
key: 'next30Days',
value: 'next30Days',
label: '{{t("Next 30 days")}}',
},
{
key: 'last90Days',
value: 'last90Days',
label: '{{t("Last 90 days")}}',
},
{
key: 'next90Days',
value: 'next90Days',
label: '{{t("Next 90 days")}}',
},
],
};
export function FilterDynamicComponent({ value, onChange, renderSchemaComponent }) {
const scope = useWorkflowVariableOptions();
const compile = useCompile();
const scope: Partial<DefaultOptionType>[] | (() => Partial<DefaultOptionType>[]) = useWorkflowVariableOptions();
const index = scope.findIndex((v) => v.key === '$system');
scope[index].children.push(compile(dateRangeSystemVariables));
return (
<Variable.Input value={value} onChange={onChange} scope={scope}>
{renderSchemaComponent()}

View File

@ -18,7 +18,8 @@ import {
LoadingOutlined,
RedoOutlined,
} from '@ant-design/icons';
import { NAMESPACE } from './locale';
import { i18n } from '@nocobase/client';
import { NAMESPACE, lang } from './locale';
export const EXECUTION_STATUS = {
QUEUEING: null,

View File

@ -147,118 +147,6 @@ export default class PluginWorkflowClient extends Plugin {
label: `{{t("System time", { ns: "${NAMESPACE}" })}}`,
value: 'now',
});
this.registerSystemVariable({
key: 'dateRange',
label: `{{t("Date range", { ns: "${NAMESPACE}" })}}`,
value: 'dateRange',
children: [
{
key: 'yesterday',
value: 'yesterday',
label: `{{t("Yesterday")}}`,
},
{
key: 'today',
value: 'today',
label: `{{t("Today")}}`,
},
{
key: 'tomorrow',
value: 'tomorrow',
label: `{{t("Tomorrow")}}`,
},
{
key: 'lastWeek',
value: 'lastWeek',
label: `{{t("Last week")}}`,
},
{
key: 'thisWeek',
value: 'thisWeek',
label: `{{t("This week")}}`,
},
{
key: 'nextWeek',
value: 'nextWeek',
label: `{{t("Next week")}}`,
},
{
key: 'lastMonth',
value: 'lastMonth',
label: `{{t("Last month")}}`,
},
{
key: 'thisMonth',
value: 'thisMonth',
label: `{{t("This month")}}`,
},
{
key: 'nextMonth',
value: 'nextMonth',
label: `{{t("Next month")}}`,
},
{
key: 'lastQuarter',
value: 'lastQuarter',
label: `{{t("Last quarter")}}`,
},
{
key: 'thisQuarter',
value: 'thisQuarter',
label: `{{t("This quarter")}}`,
},
{
key: 'nextQuarter',
value: 'nextQuarter',
label: `{{t("Next quarter")}}`,
},
{
key: 'lastYear',
value: 'lastYear',
label: `{{t("Last year")}}`,
},
{
key: 'thisYear',
value: 'thisYear',
label: `{{t("This year")}}`,
},
{
key: 'nextYear',
value: 'nextYear',
label: `{{t("Next year")}}`,
},
{
key: 'last7Days',
value: 'last7Days',
label: `{{t("Last 7 days")}}`,
},
{
key: 'next7Days',
value: 'next7Days',
label: `{{t("Next 7 days")}}`,
},
{
key: 'last30Days',
value: 'last30Days',
label: `{{t("Last 30 days")}}`,
},
{
key: 'next30Days',
value: 'next30Days',
label: `{{t("Next 30 days")}}`,
},
{
key: 'last90Days',
value: 'last90Days',
label: `{{t("Last 90 days")}}`,
},
{
key: 'next90Days',
value: 'next90Days',
label: `{{t("Next 90 days")}}`,
},
],
});
}
}