@giteeteam/apps-team-components 1.2.3-alpha.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { NodeItemProps } from '../../../lib/types/workflow';
2
3
  interface SelectFlowHandlerProps {
3
4
  itemId: string;
4
5
  onBack: () => void;
@@ -7,7 +8,7 @@ interface SelectFlowHandlerProps {
7
8
  loading: boolean;
8
9
  loadingUser: boolean;
9
10
  fetchUsers: (itemId: string, status: string, keyword?: string) => Promise<void>;
10
- handleTransition: (updateTask: string, screenId: string, script: string, flowHandler?: Array<{
11
+ handleTransition: (updateTask: string, screenId: string, script: string, target: NodeItemProps, flowHandler?: Array<{
11
12
  label: string;
12
13
  value: string;
13
14
  }>) => void;
@@ -54,7 +54,7 @@ const SelectFlowHandler = ({ itemId, task, onBack, users, loading, loadingUser,
54
54
  label: user.nickname ? `${user.nickname}(${user.username})` : user.username,
55
55
  value: user.objectId,
56
56
  }));
57
- handleTransition(task.name, (_b = (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.screen) === null || _b === void 0 ? void 0 : _b.key, (_c = task.parameters) === null || _c === void 0 ? void 0 : _c.scriptValidator, submitUsers);
57
+ handleTransition(task.name, (_b = (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.screen) === null || _b === void 0 ? void 0 : _b.key, (_c = task.parameters) === null || _c === void 0 ? void 0 : _c.scriptValidator, task.target, submitUsers);
58
58
  }, [
59
59
  handleTransition,
60
60
  selectedUserIds.length,
@@ -62,6 +62,7 @@ const SelectFlowHandler = ({ itemId, task, onBack, users, loading, loadingUser,
62
62
  task.name,
63
63
  (_b = (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.screen) === null || _b === void 0 ? void 0 : _b.key,
64
64
  (_c = task.parameters) === null || _c === void 0 ? void 0 : _c.scriptValidator,
65
+ task.target,
65
66
  ]);
66
67
  const OverflowText = () => {
67
68
  var _a, _b;
@@ -18,7 +18,7 @@ interface SelectTransitionProps {
18
18
  workspaceRoleIds: string[];
19
19
  approval: ApprovalData;
20
20
  checkIn: CheckInData;
21
- handleTransition: (updateTask: string, screenId: string, script: string) => void;
21
+ handleTransition: (updateTask: string, screenId: string, script: string, target?: any) => void;
22
22
  readonly: boolean;
23
23
  flowHandlerActive?: boolean;
24
24
  }
@@ -1,41 +1,15 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { memo, useCallback, useEffect, useState } from 'react';
2
+ import { memo } from 'react';
3
3
  import { ClassNames } from '@emotion/react';
4
4
  import { Spin } from 'antd';
5
- import useWorkflowConfig from '../../../lib/hooks/useWorkflowConfig';
6
5
  import { i18n } from '../../../lib/i18n';
7
6
  import { flowNextStyle, flowWrapperStyle, noPermissionStyle, spinStyle } from './style';
8
7
  import TransitionButton from './TransitionButton';
9
8
  import View from './View';
10
9
  const SelectTransition = ({ fetching, flowing, tasks, itemId, itemData, currentUser, workspace, setPopoverVisible, name, objectId, workflowData, roleIds, groupIds, workspaceRoleIds, approval, checkIn, handleTransition, readonly, flowHandlerActive, }) => {
11
- const [init, setInit] = useState(false);
12
- const { postCheckTransitions, hideDisabledStatusTransition } = useWorkflowConfig();
13
- const [checkResultList, setCheckResultList] = useState([]);
14
- const [hideIds, setHideIds] = useState([]);
15
- useEffect(() => {
16
- if (!init && workflowData.objectId && tasks.length && postCheckTransitions && itemId) {
17
- setInit(true);
18
- postCheckTransitions(tasks.map(_transition => ({
19
- transitionId: _transition.id,
20
- itemId,
21
- workflowId: workflowData.objectId,
22
- }))).then(checkResultList => {
23
- setCheckResultList(checkResultList);
24
- });
25
- }
26
- }, [init, itemId, workflowData, postCheckTransitions, tasks]);
27
- const handleHide = useCallback(id => {
28
- setHideIds(c => {
29
- if (!c.includes(id)) {
30
- return c.concat(id);
31
- }
32
- return c;
33
- });
34
- }, []);
35
- const isAllHide = tasks.every(task => hideIds.includes(task.id));
36
- return (_jsx(ClassNames, { children: ({ cx, css }) => (_jsxs(_Fragment, { children: [fetching ? (_jsx(Spin, { css: css(spinStyle) })) : tasks.length && !isAllHide ? (_jsx("div", { className: cx(css(flowNextStyle), `flow-next-global`), children: _jsx("div", { className: cx(css(flowWrapperStyle)), children: tasks.map(task => {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
38
- return (_jsx(TransitionButton, { itemId: itemId, loading: flowing, text: task.name, item: itemData, workspace: workspace, userId: currentUser.id, groupIds: groupIds, roleIds: roleIds, workspaceRoleIds: workspaceRoleIds, currentTaskId: task.id, authUsers: (_b = (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.permissionType) === null || _b === void 0 ? void 0 : _b.users, authRoles: (_d = (_c = task.parameters) === null || _c === void 0 ? void 0 : _c.permissionType) === null || _d === void 0 ? void 0 : _d.roles, authGroups: (_f = (_e = task.parameters) === null || _e === void 0 ? void 0 : _e.permissionType) === null || _f === void 0 ? void 0 : _f.groups, authUserFields: (_h = (_g = task.parameters) === null || _g === void 0 ? void 0 : _g.permissionType) === null || _h === void 0 ? void 0 : _h.customFields, authWorkSpaceRoles: (_k = (_j = task.parameters) === null || _j === void 0 ? void 0 : _j.permissionType) === null || _k === void 0 ? void 0 : _k.workspaceRoles, creatorAuth: (_m = (_l = task.parameters) === null || _l === void 0 ? void 0 : _l.permissionType) === null || _m === void 0 ? void 0 : _m.creatorAuth, scriptValidator: (_o = task.parameters) === null || _o === void 0 ? void 0 : _o.scriptValidator, conditions: (_p = task.parameters) === null || _p === void 0 ? void 0 : _p.fieldType, screenId: (_r = (_q = task.parameters) === null || _q === void 0 ? void 0 : _q.screen) === null || _r === void 0 ? void 0 : _r.key, target: task.target, approval: approval, checkIn: checkIn, handleTransition: handleTransition, hiddenPopover: () => setPopoverVisible(false), readonly: readonly, flowHandlerActive: flowHandlerActive, conditionKey: (_s = task.parameters) === null || _s === void 0 ? void 0 : _s.conditionKey, fieldTypeConditionKey: (_t = task.parameters) === null || _t === void 0 ? void 0 : _t.fieldTypeConditionKey, userConditionKey: (_v = (_u = task.parameters) === null || _u === void 0 ? void 0 : _u.permissionType) === null || _v === void 0 ? void 0 : _v.conditionKey, conditionCheck: (_w = checkResultList.find(checkResult => checkResult.transitionId === task.id)) === null || _w === void 0 ? void 0 : _w.result, hideDisabledStatusTransition: hideDisabledStatusTransition, onHide: handleHide }, task.id));
10
+ return (_jsx(ClassNames, { children: ({ cx, css }) => (_jsxs(_Fragment, { children: [fetching ? (_jsx(Spin, { css: css(spinStyle) })) : tasks.length ? (_jsx("div", { className: cx(css(flowNextStyle), `flow-next-global`), children: _jsx("div", { className: cx(css(flowWrapperStyle)), children: tasks.map(task => {
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
12
+ return (_jsx(TransitionButton, { itemId: itemId, loading: flowing, text: task.name, item: itemData, workspace: workspace, userId: currentUser.id, groupIds: groupIds, roleIds: roleIds, workspaceRoleIds: workspaceRoleIds, currentTaskId: task.id, authUsers: (_b = (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.permissionType) === null || _b === void 0 ? void 0 : _b.users, authRoles: (_d = (_c = task.parameters) === null || _c === void 0 ? void 0 : _c.permissionType) === null || _d === void 0 ? void 0 : _d.roles, authGroups: (_f = (_e = task.parameters) === null || _e === void 0 ? void 0 : _e.permissionType) === null || _f === void 0 ? void 0 : _f.groups, authUserFields: (_h = (_g = task.parameters) === null || _g === void 0 ? void 0 : _g.permissionType) === null || _h === void 0 ? void 0 : _h.customFields, authWorkSpaceRoles: (_k = (_j = task.parameters) === null || _j === void 0 ? void 0 : _j.permissionType) === null || _k === void 0 ? void 0 : _k.workspaceRoles, creatorAuth: (_m = (_l = task.parameters) === null || _l === void 0 ? void 0 : _l.permissionType) === null || _m === void 0 ? void 0 : _m.creatorAuth, scriptValidator: (_o = task.parameters) === null || _o === void 0 ? void 0 : _o.scriptValidator, conditions: (_p = task.parameters) === null || _p === void 0 ? void 0 : _p.fieldType, screenId: (_r = (_q = task.parameters) === null || _q === void 0 ? void 0 : _q.screen) === null || _r === void 0 ? void 0 : _r.key, target: task.target, approval: approval, checkIn: checkIn, handleTransition: handleTransition, hiddenPopover: () => setPopoverVisible(false), readonly: readonly, flowHandlerActive: flowHandlerActive }, task.id));
39
13
  }) }) })) : (_jsx("span", { onClick: () => {
40
14
  setPopoverVisible(false);
41
15
  }, css: css(noPermissionStyle), children: i18n.t('pages.fields.view.noWorkflowOrAuth') })), _jsx(View, { workflowData: workflowData, hiddenPopover: () => setPopoverVisible(false), name: name, objectId: objectId })] })) }));
@@ -23,22 +23,13 @@ interface FlowButtonProps {
23
23
  conditions?: ConditionType[];
24
24
  approval: ApprovalData;
25
25
  checkIn: CheckInData;
26
- handleTransition: (updateTask: string, screenId: string, script: string) => void;
26
+ handleTransition: (updateTask: string, screenId: string, script: string, target: NodeItemProps) => void;
27
27
  target: NodeItemProps & {
28
28
  type?: string;
29
29
  };
30
30
  hiddenPopover?: () => void;
31
31
  readonly?: boolean;
32
- conditionKey: string;
33
- fieldTypeConditionKey: string;
34
- userConditionKey: string;
35
32
  flowHandlerActive?: boolean;
36
- conditionCheck?: {
37
- result: boolean;
38
- message: string;
39
- };
40
- hideDisabledStatusTransition?: string;
41
- onHide?: (id: string) => void;
42
33
  }
43
34
  declare const _default: React.NamedExoticComponent<FlowButtonProps>;
44
35
  export default _default;
@@ -4,7 +4,7 @@ import { ClassNames, css } from '@emotion/react';
4
4
  import { Tooltip } from 'antd';
5
5
  import { WorkFlowStatusColor } from '../../../lib/global';
6
6
  import { i18n } from '../../../lib/i18n';
7
- import { checkFlowHandler } from '../../../lib/workflow';
7
+ import { checkTransition } from '../../../lib/workflow';
8
8
  import BaseOverflowTooltip from '../../common/overflow-tooltip/BaseOverflowTooltip';
9
9
  import { flowBtnStyle, flowStateStyle, iconStyle, notAllowedStyle, pointerStyle, stateBoxStyle, tipLineStyle, tooltipStyle, } from './style';
10
10
  const ApprovalStatus = {
@@ -15,10 +15,9 @@ const CheckInStatus = {
15
15
  closed: 'closed',
16
16
  pending: 'pending',
17
17
  };
18
- const FlowButton = ({ loading, screenId, text, item, userId, authRoles, authUsers, authGroups, creatorAuth, authUserFields, authWorkSpaceRoles, scriptValidator, approval, checkIn, conditions = [], handleTransition, target, readonly, conditionKey, fieldTypeConditionKey, userConditionKey, flowHandlerActive, conditionCheck, hideDisabledStatusTransition, onHide, currentTaskId, }) => {
18
+ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds, workspaceRoleIds, authRoles, authUsers, authGroups, creatorAuth, authUserFields, authWorkSpaceRoles, scriptValidator, approval, checkIn, conditions = [], handleTransition, target, readonly, flowHandlerActive, }) => {
19
19
  const [isCheck, setIsCheck] = useState(true);
20
20
  const [tip, setTip] = useState('');
21
- const [hide, setHide] = useState(false);
22
21
  const checkApproval = useCallback(() => {
23
22
  var _a;
24
23
  if (!approval.requireApproval)
@@ -63,7 +62,6 @@ const FlowButton = ({ loading, screenId, text, item, userId, authRoles, authUser
63
62
  return;
64
63
  }
65
64
  const transition = {
66
- conditionKey,
67
65
  parameters: {
68
66
  fieldType: conditions,
69
67
  permissionType: {
@@ -73,25 +71,15 @@ const FlowButton = ({ loading, screenId, text, item, userId, authRoles, authUser
73
71
  workspaceRoles: authWorkSpaceRoles,
74
72
  customFields: authUserFields,
75
73
  creatorAuth,
76
- conditionKey: userConditionKey,
77
74
  },
78
- fieldTypeConditionKey,
79
75
  },
80
76
  };
81
- let checkResult = checkFlowHandler(item, transition, { userId }, flowHandlerActive);
82
- if (!checkResult) {
83
- checkResult = conditionCheck;
84
- }
85
- if (!(checkResult === null || checkResult === void 0 ? void 0 : checkResult.result)) {
86
- setTip(checkResult === null || checkResult === void 0 ? void 0 : checkResult.message);
77
+ const checkResult = checkTransition(item, transition, { userId, roleIds, groupIds, workspaceRoleIds }, flowHandlerActive);
78
+ if (!checkResult.result) {
79
+ setTip(checkResult.message);
87
80
  setIsCheck(false);
88
- if (hideDisabledStatusTransition === 'enabled') {
89
- setHide(true);
90
- onHide(currentTaskId);
91
- }
92
81
  }
93
82
  }, [
94
- hideDisabledStatusTransition,
95
83
  checkApproval,
96
84
  validateCheckIn,
97
85
  conditions,
@@ -103,13 +91,10 @@ const FlowButton = ({ loading, screenId, text, item, userId, authRoles, authUser
103
91
  creatorAuth,
104
92
  item,
105
93
  userId,
106
- conditionKey,
107
- fieldTypeConditionKey,
108
- userConditionKey,
94
+ roleIds,
95
+ groupIds,
96
+ workspaceRoleIds,
109
97
  flowHandlerActive,
110
- conditionCheck,
111
- onHide,
112
- currentTaskId,
113
98
  ]);
114
99
  useEffect(() => {
115
100
  checkAuth();
@@ -132,9 +117,9 @@ const FlowButton = ({ loading, screenId, text, item, userId, authRoles, authUser
132
117
  return (_jsx(ClassNames, { children: ({ cx, css }) => {
133
118
  return isCheck && !readonly ? (_jsx("div", { className: cx(css(flowBtnStyle), loading ? css(notAllowedStyle) : css(pointerStyle)), onClick: () => {
134
119
  if (!loading) {
135
- handleTransition(text, screenId, scriptValidator);
120
+ handleTransition(text, screenId, scriptValidator, target);
136
121
  }
137
- }, children: _jsx(OverflowText, { text: text, target: target }) })) : hide ? null : (_jsx(Tooltip, { title: tipContent, placement: "right", children: _jsx("div", { className: cx(css(flowBtnStyle), css(notAllowedStyle)), children: _jsx(OverflowText, { text: text, target: target }) }) }));
122
+ }, children: _jsx(OverflowText, { text: text, target: target }) })) : (_jsx(Tooltip, { title: tipContent, placement: "right", children: _jsx("div", { className: cx(css(flowBtnStyle), css(notAllowedStyle)), children: _jsx(OverflowText, { text: text, target: target }) }) }));
138
123
  } }));
139
124
  };
140
125
  export default memo(FlowButton);
@@ -171,13 +171,16 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
171
171
  const submitTransition = useCallback(async (itemDetail) => {
172
172
  await submitHandle(updateTransitionText, itemDetail);
173
173
  }, [submitHandle, updateTransitionText]);
174
- const handleTransition = useCallback(async (transitionText, screenId, scriptValidator, flowHandler) => {
174
+ const handleTransition = useCallback(async (transitionText, screenId, scriptValidator, target, flowHandler) => {
175
175
  if (flowHandlerActive) {
176
176
  if (transitionStep === TransitionStepType.SelectTransition) {
177
- setCurrentFlowHandler(undefined);
178
- setFlowTask(tasks.find(task => task.name === transitionText));
179
- setTransitionStep(TransitionStepType.SelectFlowHandler);
180
- return;
177
+ const nextStateTransition = workflowData.transitions.find(t => t.source.id === target.key);
178
+ if (nextStateTransition) {
179
+ setCurrentFlowHandler(undefined);
180
+ setFlowTask(tasks.find(task => task.name === transitionText));
181
+ setTransitionStep(TransitionStepType.SelectFlowHandler);
182
+ return;
183
+ }
181
184
  }
182
185
  else {
183
186
  console.info('flowHandler', flowHandler);
@@ -220,8 +223,9 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
220
223
  }
221
224
  }, [
222
225
  flowHandlerActive,
223
- transitionStep,
224
226
  setFlowing,
227
+ transitionStep,
228
+ workflowData.transitions,
225
229
  tasks,
226
230
  itemId,
227
231
  itemType,
@@ -5,8 +5,6 @@ export interface IWorkflowConfig {
5
5
  getWorkflowData?: (itemId: string) => Promise<any>;
6
6
  runTransition?: (params: Record<string, any>) => Promise<any>;
7
7
  getItemStatus?: (itemId: string) => Promise<any>;
8
- postCheckTransitions?: (params: Record<string, any>[]) => Promise<any>;
9
- hideDisabledStatusTransition?: string;
10
8
  }
11
9
  export interface IWorkflowConfigContext {
12
10
  workflow?: IWorkflowConfig;
@@ -107,6 +107,5 @@ interface CheckUserPermissionParams {
107
107
  export declare function checkUserPermission({ transition, userId, roleIds, groupIds, item, workspaceRoleIds, }: CheckUserPermissionParams): ResultType;
108
108
  export declare function checkItemCondition(transition: TransitionProps, item: ItemResultProps): ResultType;
109
109
  export declare function checkTransition(item: ItemResultProps, transition: TransitionProps, permissions: WorkflowPermissionType, flowHandlerActive?: boolean): ResultType;
110
- export declare function checkFlowHandler(item: ItemResultProps, transition: TransitionProps, permissions: WorkflowPermissionType, flowHandlerActive?: boolean): ResultType;
111
110
  export declare const useWorkflowPermission: (workspaceId: ObjectId) => [ObjectId[], ObjectId[], ObjectId[]];
112
111
  export {};
@@ -118,7 +118,7 @@ function listToCompare(list1, list2, compareString) {
118
118
  export function checkUserPermission({ transition, userId, roleIds, groupIds, item, workspaceRoleIds, }) {
119
119
  var _a, _b, _c;
120
120
  const values = (item === null || item === void 0 ? void 0 : item.values) || {};
121
- const { users: authUsers, roles: authRoles, groups: authGroups, customFields: authUserFields, workspaceRoles: authWorkspaceRoles, creatorAuth, conditionKey, } = ((_a = transition.parameters) === null || _a === void 0 ? void 0 : _a.permissionType) || {};
121
+ const { users: authUsers, roles: authRoles, groups: authGroups, customFields: authUserFields, workspaceRoles: authWorkspaceRoles, creatorAuth, } = ((_a = transition.parameters) === null || _a === void 0 ? void 0 : _a.permissionType) || {};
122
122
  const hasUsers = (authUsers === null || authUsers === void 0 ? void 0 : authUsers.length) > 0;
123
123
  const hasRoles = (authRoles === null || authRoles === void 0 ? void 0 : authRoles.length) > 0;
124
124
  const hasGroups = (authGroups === null || authGroups === void 0 ? void 0 : authGroups.length) > 0;
@@ -126,18 +126,14 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
126
126
  const hasWorkspaceRoles = (authWorkspaceRoles === null || authWorkspaceRoles === void 0 ? void 0 : authWorkspaceRoles.length) > 0;
127
127
  const tipText = [];
128
128
  if (!hasUsers && !hasRoles && !hasGroups && !hasUserFields && !hasWorkspaceRoles && !creatorAuth) {
129
- return { result: true, isEmpty: true };
129
+ return { result: true };
130
130
  }
131
- const defaultConditionKey = conditionKey || 'any';
132
- const isAny = defaultConditionKey === 'any';
133
131
  if (creatorAuth) {
134
132
  if (![(_b = item.createdBy) === null || _b === void 0 ? void 0 : _b.objectId, (_c = item.createdBy) === null || _c === void 0 ? void 0 : _c.id].includes(userId)) {
135
133
  tipText.push(i18n.t('pages.workflow.default.userType.creatorAuth'));
136
134
  }
137
135
  else {
138
- if (isAny) {
139
- return { result: true };
140
- }
136
+ return { result: true };
141
137
  }
142
138
  }
143
139
  if (hasUsers) {
@@ -147,9 +143,7 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
147
143
  tipText.push(`${i18n.t('libs.workflow.user')}:${tipUsers}`);
148
144
  }
149
145
  else {
150
- if (isAny) {
151
- return { result: true };
152
- }
146
+ return { result: true };
153
147
  }
154
148
  }
155
149
  if (hasRoles) {
@@ -159,9 +153,7 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
159
153
  tipText.push(`${i18n.t('libs.workflow.role')}:${tipRoles}`);
160
154
  }
161
155
  else {
162
- if (isAny) {
163
- return { result: true };
164
- }
156
+ return { result: true };
165
157
  }
166
158
  }
167
159
  if (hasGroups) {
@@ -171,9 +163,7 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
171
163
  tipText.push(`${i18n.t('libs.workflow.group')}:${tipGroup}`);
172
164
  }
173
165
  else {
174
- if (isAny) {
175
- return { result: true };
176
- }
166
+ return { result: true };
177
167
  }
178
168
  }
179
169
  if (hasUserFields) {
@@ -204,9 +194,7 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
204
194
  tipText.push(`${i18n.t('libs.workflow.userFields')}:${tipRoles}`);
205
195
  }
206
196
  else {
207
- if (isAny) {
208
- return { result: true };
209
- }
197
+ return { result: true };
210
198
  }
211
199
  }
212
200
  if (hasWorkspaceRoles) {
@@ -218,9 +206,7 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
218
206
  tipText.push(`${i18n.t('libs.workflow.workspaceRoles')}:${tipWorkspaceRoles}`);
219
207
  }
220
208
  else {
221
- if (isAny) {
222
- return { result: true };
223
- }
209
+ return { result: true };
224
210
  }
225
211
  }
226
212
  if (tipText.length) {
@@ -229,13 +215,8 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
229
215
  return { result: true };
230
216
  }
231
217
  export function checkItemCondition(transition, item) {
232
- var _a, _b, _c;
233
- const defaultConditionKey = ((_a = transition === null || transition === void 0 ? void 0 : transition.parameters) === null || _a === void 0 ? void 0 : _a.fieldTypeConditionKey) || 'all';
234
- const conditions = ((_b = transition.parameters) === null || _b === void 0 ? void 0 : _b.fieldType) || [];
235
- const isAny = defaultConditionKey === 'any';
236
- if (!conditions.length) {
237
- return { result: true, isEmpty: true };
238
- }
218
+ var _a, _b;
219
+ const conditions = ((_a = transition.parameters) === null || _a === void 0 ? void 0 : _a.fieldType) || [];
239
220
  for (const i in conditions) {
240
221
  const { comparedValue, numberCompare, stringCompare, dropDownCompare, field, pickerType } = conditions[i];
241
222
  let fieldValue;
@@ -250,7 +231,7 @@ export function checkItemCondition(transition, item) {
250
231
  fieldValue = item[field.key].objectId;
251
232
  }
252
233
  else {
253
- fieldValue = (_c = item.values) === null || _c === void 0 ? void 0 : _c[field.key];
234
+ fieldValue = (_b = item.values) === null || _b === void 0 ? void 0 : _b[field.key];
254
235
  }
255
236
  let sourceValue = null, targetValue = null;
256
237
  switch (field.componentType) {
@@ -270,13 +251,6 @@ export function checkItemCondition(transition, item) {
270
251
  }),
271
252
  };
272
253
  }
273
- else {
274
- if (isAny) {
275
- return {
276
- result: true,
277
- };
278
- }
279
- }
280
254
  }
281
255
  else if (!numberToCompare(fieldValue, Number(targetValue), numberCompare)) {
282
256
  if (isEmptyCondition(numberCompare)) {
@@ -290,7 +264,7 @@ export function checkItemCondition(transition, item) {
290
264
  }
291
265
  let showValue = comparedValue;
292
266
  if (field.componentType === CustomFieldComponentTypes.Date) {
293
- showValue = getFormat(comparedValue, getDateType(pickerType));
267
+ showValue = getFormat(comparedValue, getDateType('dateTime'));
294
268
  }
295
269
  return {
296
270
  result: false,
@@ -301,13 +275,6 @@ export function checkItemCondition(transition, item) {
301
275
  }),
302
276
  };
303
277
  }
304
- else {
305
- if (isAny) {
306
- return {
307
- result: true,
308
- };
309
- }
310
- }
311
278
  break;
312
279
  case CustomFieldComponentTypes.Text:
313
280
  case CustomFieldComponentTypes.LongText:
@@ -332,13 +299,6 @@ export function checkItemCondition(transition, item) {
332
299
  message,
333
300
  };
334
301
  }
335
- else {
336
- if (isAny) {
337
- return {
338
- result: true,
339
- };
340
- }
341
- }
342
302
  break;
343
303
  case CustomFieldComponentTypes.User:
344
304
  case CustomFieldComponentTypes.Dropdown:
@@ -377,13 +337,8 @@ export function checkItemCondition(transition, item) {
377
337
  }),
378
338
  };
379
339
  }
380
- else {
381
- if (isAny) {
382
- return {
383
- result: true,
384
- };
385
- }
386
- }
340
+ break;
341
+ default:
387
342
  break;
388
343
  }
389
344
  }
@@ -393,8 +348,6 @@ export function checkTransition(item, transition, permissions, flowHandlerActive
393
348
  var _a, _b;
394
349
  if (!item || !transition)
395
350
  return { result: false };
396
- const defaultConditionKey = (transition === null || transition === void 0 ? void 0 : transition.conditionKey) || 'all';
397
- const isAll = defaultConditionKey === 'all';
398
351
  if (flowHandlerActive && ((_b = (_a = item === null || item === void 0 ? void 0 : item.values) === null || _a === void 0 ? void 0 : _a.flowHandler) === null || _b === void 0 ? void 0 : _b.length)) {
399
352
  const flowHandler = item.values.flowHandler;
400
353
  const flowUser = flowHandler.find(user => user.value === permissions.userId);
@@ -414,50 +367,12 @@ export function checkTransition(item, transition, permissions, flowHandlerActive
414
367
  item,
415
368
  ...permissions,
416
369
  });
370
+ if (!roleCheck.result)
371
+ return roleCheck;
417
372
  const conditionCheck = checkItemCondition(transition, item);
418
- if (isAll) {
419
- if (!roleCheck.result)
420
- return roleCheck;
421
- if (!conditionCheck.result)
422
- return conditionCheck;
423
- return { result: true };
424
- }
425
- else {
426
- const conditionList = [roleCheck, conditionCheck];
427
- const notEmpty = conditionList.filter(item => !item.isEmpty);
428
- if ((notEmpty === null || notEmpty === void 0 ? void 0 : notEmpty.length) > 0) {
429
- const hasPass = notEmpty.find(item => item.result);
430
- if (hasPass) {
431
- return { result: true };
432
- }
433
- else {
434
- const notPass = notEmpty.find(item => !item.result);
435
- return notPass;
436
- }
437
- }
438
- else {
439
- return { result: true };
440
- }
441
- }
442
- }
443
- export function checkFlowHandler(item, transition, permissions, flowHandlerActive) {
444
- var _a, _b;
445
- if (!item || !transition)
446
- return { result: false };
447
- if (flowHandlerActive && ((_b = (_a = item === null || item === void 0 ? void 0 : item.values) === null || _a === void 0 ? void 0 : _a.flowHandler) === null || _b === void 0 ? void 0 : _b.length)) {
448
- const flowHandler = item.values.flowHandler;
449
- const flowUser = flowHandler.find(user => user.value === permissions.userId);
450
- if (flowUser) {
451
- return { result: true };
452
- }
453
- else {
454
- const tipUsers = flowHandler.map(user => user.label).join('、');
455
- return {
456
- result: false,
457
- message: i18n.t('libs.default.tipText', { text: `${i18n.t('libs.workflow.flowHandler')}:${tipUsers}` }),
458
- };
459
- }
460
- }
373
+ if (!conditionCheck.result)
374
+ return conditionCheck;
375
+ return { result: true };
461
376
  }
462
377
  export const useWorkflowPermission = (workspaceId) => {
463
378
  const [roles, setRoles] = useState([]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.2.3-alpha.1",
3
+ "version": "1.2.3",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",