From 462f4e0760a4596d8b9c74503ed154a8e5676d89 Mon Sep 17 00:00:00 2001 From: sealday Date: Tue, 9 Jul 2024 11:30:35 +0800 Subject: [PATCH] fix: submit (#1294) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1294 --- .../forms/AddActionButton.setting.tsx | 55 +++---------------- .../instruction/forms/Approval.options.ts | 1 + .../LauncherActionConfig.component.tsx | 2 +- .../LauncherActionConfig.initializer.tsx | 2 +- .../src/client/features/approval/constants.ts | 2 +- .../launch/ActionResubmit.provider.tsx | 3 +- .../plugin-workflow/src/locale/en-US.json | 2 +- .../plugin-workflow/src/locale/zh-CN.json | 7 ++- .../src/server/features/approval/actions.ts | 2 +- 9 files changed, 20 insertions(+), 56 deletions(-) diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/AddActionButton.setting.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/AddActionButton.setting.tsx index 078db4f1b..d7a8ebdf9 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/AddActionButton.setting.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/AddActionButton.setting.tsx @@ -1,79 +1,40 @@ import React from 'react'; -import { CompatibleSchemaInitializer, InitializerWithSwitch, useSchemaInitializerItem } from '@tachybase/client'; +import { InitializerWithSwitch, SchemaInitializer, useSchemaInitializerItem } from '@tachybase/client'; -import { JOB_STATUS } from '../../../../../constants'; import { APPROVAL_ACTION_STATUS } from '../../../constants'; import { NAMESPACE } from '../../../locale'; -/** - * @deprecated - */ -// NOTE: 似乎没用, 但删除又报错, 先保留着 -const addActionButton_deprecated = new CompatibleSchemaInitializer({ +export const ApprovalAddActionButton = new SchemaInitializer({ name: 'ApprovalAddActionButton', title: '{{t("Configure actions")}}', items: [ { - name: 'jobStatusResolved', + name: 'approvalStatusResolved', title: `{{t("Continue the process", { ns: "${NAMESPACE}" })}}`, Component: ActionInitializer, - action: JOB_STATUS.RESOLVED, + statusApproval: APPROVAL_ACTION_STATUS.APPROVED, actionProps: { type: 'primary', }, }, { - name: 'jobStatusRejected', + name: 'approvalStatusRejected', title: `{{t("Terminate the process", { ns: "${NAMESPACE}" })}}`, Component: ActionInitializer, - action: JOB_STATUS.REJECTED, + statusApproval: APPROVAL_ACTION_STATUS.REJECTED, actionProps: { danger: true, }, }, { - name: 'jobStatusPending', + name: 'approvalStatusPending', title: `{{t("Save temporarily", { ns: "${NAMESPACE}" })}}`, Component: ActionInitializer, - action: JOB_STATUS.PENDING, + statusApproval: APPROVAL_ACTION_STATUS.PENDING, }, ], }); -export const ApprovalAddActionButton = new CompatibleSchemaInitializer( - { - name: 'ApprovalAddActionButton', - title: '{{t("Configure actions")}}', - items: [ - { - name: 'approvalStatusResolved', - title: `{{t("Continue the process", { ns: "${NAMESPACE}" })}}`, - Component: ActionInitializer, - statusApproval: APPROVAL_ACTION_STATUS.APPROVED, - actionProps: { - type: 'primary', - }, - }, - { - name: 'approvalStatusRejected', - title: `{{t("Terminate the process", { ns: "${NAMESPACE}" })}}`, - Component: ActionInitializer, - statusApproval: APPROVAL_ACTION_STATUS.REJECTED, - actionProps: { - danger: true, - }, - }, - { - name: 'approvalStatusPending', - title: `{{t("Save temporarily", { ns: "${NAMESPACE}" })}}`, - Component: ActionInitializer, - statusApproval: APPROVAL_ACTION_STATUS.PENDING, - }, - ], - }, - addActionButton_deprecated, -); - function ActionInitializer() { const itemConfig = useSchemaInitializerItem(); const { statusApproval, actionProps, ...others } = itemConfig; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/Approval.options.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/Approval.options.ts index 715a8f99e..665dfa444 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/Approval.options.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/forms/Approval.options.ts @@ -1,4 +1,5 @@ import { SchemaInitializerItemType } from '@tachybase/client'; +import { ISchema } from '@tachybase/schema'; import { Registry } from '@tachybase/utils/client'; import { JOB_STATUS } from '../../../../../constants'; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx index 9c8108d5b..26f47d362 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.component.tsx @@ -56,7 +56,7 @@ export const LauncherActionConfigReSubmit = () => { useAction: '{{ useActionResubmit }}', }, 'x-designer': 'Action.Designer', - 'x-action': `reSubmit`, + 'x-action': `Resubmit`, 'x-action-settings': { assignedValues: {}, }, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx index f8cb0f3f7..9224fe766 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.tsx @@ -26,7 +26,7 @@ export const LauncherActionConfigInitializer = new SchemaInitializer({ action: APPROVAL_STATUS.DRAFT, }, { - name: 'reSubmit', + name: 'Resubmit', type: 'item', title: `{{t("resubmit", { ns: "${NAMESPACE}" })}}`, action: APPROVAL_STATUS.RESUBMIT, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/constants.ts b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/constants.ts index 10b6d02f5..85c593df3 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/constants.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/constants.ts @@ -66,7 +66,7 @@ export const ApprovalStatusEnums = [ }, { value: APPROVAL_STATUS.RESUBMIT, - label: `{{t("reSubmit", { ns: "${NAMESPACE}" })}}`, + label: `{{t("Resubmit", { ns: "${NAMESPACE}" })}}`, color: 'blue', editable: true, }, diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/ActionResubmit.provider.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/ActionResubmit.provider.tsx index f6f8ae640..0f65d3a03 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/ActionResubmit.provider.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/ActionResubmit.provider.tsx @@ -11,7 +11,8 @@ export function ProviderActionResubmit(props) { const isSameId = data.data.id === createdById; const isDraft = status === APPROVAL_STATUS.DRAFT; - if (isSameId && !isResubmit && !isDraft) { + const isReturned = status === APPROVAL_STATUS.RETURNED; + if (isSameId && !isResubmit && !isDraft && !isReturned) { return props.children; } diff --git a/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json b/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json index 965bfaafe..f8841fa17 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json +++ b/packages/plugins/@tachybase/plugin-workflow/src/locale/en-US.json @@ -276,6 +276,6 @@ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" only support \"application/json\", and no need to specify", "concat": "concat", "ms": "ms", - "reSubmit": "reSubmit", + "Resubmit": "Resubmit", "Are you sure you want to resubmit it?": "Are you sure you want to resubmit it?" } diff --git a/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json b/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json index 38d3becbe..57c97817f 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json +++ b/packages/plugins/@tachybase/plugin-workflow/src/locale/zh-CN.json @@ -111,7 +111,8 @@ "Custom form": "自定义表单", "Data of associated collection": "关联数据表数据", "Data of collection": "数据表数据", - "Data operation nodes in workflow will run in a same transaction until any interruption. Any failure will cause data rollback, and will also rollback the history of the execution.": "工作流中的节点将在同一个事务中运行。任何失败都会导致数据回滚,同时也会回滚相应的执行历史。", "Data record": "数据记录", + "Data operation nodes in workflow will run in a same transaction until any interruption. Any failure will cause data rollback, and will also rollback the history of the execution.": "工作流中的节点将在同一个事务中运行。任何失败都会导致数据回滚,同时也会回滚相应的执行历史。", + "Data record": "数据记录", "Data will be updated": "更新的数据", "Date variables": "日期变量", "Days": "天", @@ -356,6 +357,6 @@ "\"Content-Type\" only support \"application/json\", and no need to specify": "\"Content-Type\" 请求头仅支持 \"application/json\",无需填写", "concat": "连接", "ms": "毫秒", - "reSubmit": "需重新提交", - "Are you sure you want to resubmit it?": "确定生成一份新的草稿吗?" + "Resubmit": "重新发起", + "Are you sure you want to resubmit it?": "是否确定重新发起?" } diff --git a/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts b/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts index e9d5ae402..eacb42600 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts @@ -116,7 +116,7 @@ const approvals = { }, // NOTE: 和 create 逻辑雷同, 但是 因为原本的 create 并非纯操作, 因此拷贝一份以便方便改动 - async reSubmit(context, next) { + async resubmit(context, next) { const { status, collectionName, data, workflowId, collectionAppends } = context.action.params.values ?? {}; const [dataSourceName, cName] = parseCollectionName(collectionName); const dataSource = context.app.dataSourceManager.dataSources.get(dataSourceName);