feat(approval): hidden updateForm when approvaled (#1397)

Reviewed-on: daoyoucloud/tachybase#1397
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
bai.zixv 2024-07-26 14:30:48 +08:00 committed by sealday
parent 021a96e85f
commit 1797292dbc
3 changed files with 17 additions and 0 deletions

View File

@ -43,6 +43,10 @@ function InternalFormBlockInitializer({ schema, ...others }) {
marginTop: '1.5em',
flexWrap: 'wrap',
};
// NOTE: 给表单区域添加 Provider, 方便根据不同进程,控制显示隐藏; ProviderApprovalUpdateForm 在 usage 文件夹里声明和注册
result.properties[formKey].properties['grid']['x-decorator'] = 'ProviderApprovalUpdateForm';
traverseSchema(result, (node) => {
if (node['x-uid']) {
delete node['x-uid'];

View File

@ -0,0 +1,11 @@
import { APPROVAL_ACTION_STATUS } from '../../../constants';
import { useContextApprovalExecutions } from './Pd.ApprovalExecutions';
export const ProviderApprovalUpdateForm = (props) => {
const { status } = useContextApprovalExecutions();
if (status === APPROVAL_ACTION_STATUS.PENDING) {
return props.children;
} else {
return null;
}
};

View File

@ -19,6 +19,7 @@ import { ApprovalContext } from '../../approval-common/ApprovalData.provider';
import { ContextWithActionEnabled } from '../../approval-common/WithActionEnabled.provider';
import { ContextApprovalExecution } from '../common/ApprovalExecution.provider';
import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider';
import { ProviderApprovalUpdateForm } from './ApprovalUpdateForm.provider';
import { ApprovalFormBlockDecorator } from './Dt.ApprovalFormBlock';
import { useApprovalDetailBlockProps } from './hooks/useApprovalDetailBlockProps';
import { useApprovalFormBlockProps } from './hooks/useApprovalFormBlockProps';
@ -98,6 +99,7 @@ export const ViewActionTodosContent = () => {
ApprovalActionProvider,
ApprovalFormBlockProvider: ApprovalFormBlockDecorator,
DetailsBlockProvider,
ProviderApprovalUpdateForm,
}}
scope={{
useApprovalDetailBlockProps,