@giteeteam/apps-team-components 1.1.4 → 1.2.0-alpha.1
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.
- package/dist/components/fields/actors/BaseField.d.ts +8 -1
- package/dist/components/fields/actors/BaseField.js +1 -1
- package/dist/components/fields/data-quote/utils.d.ts +2 -0
- package/dist/components/fields/data-quote/utils.js +27 -23
- package/dist/components/fields/dropdown/BaseField.d.ts +1 -0
- package/dist/components/fields/status/TransitionButton.d.ts +3 -0
- package/dist/components/fields/status/TransitionButton.js +7 -1
- package/dist/components/fields/status/TransitionPanel.js +12 -5
- package/dist/components/fields/user/ReadView.js +2 -2
- package/dist/lib/array.d.ts +1 -1
- package/dist/lib/array.js +1 -1
- package/dist/lib/hooks/useI18n.d.ts +2 -3
- package/dist/lib/workflow.js +69 -20
- package/package.json +2 -1
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ObjectId, User as UserTyped } from '../../../lib/types/models';
|
|
2
|
+
type UserOption = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: ObjectId;
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const formatUserOption: (actorData: UserTyped) => UserOption;
|
|
8
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { userOptionAdapter } from '../../../lib/users';
|
|
2
|
-
export const formatUserOption = actorData => {
|
|
2
|
+
export const formatUserOption = (actorData) => {
|
|
3
3
|
const isUserData = !!(actorData === null || actorData === void 0 ? void 0 : actorData.username) && (actorData === null || actorData === void 0 ? void 0 : actorData.enabled);
|
|
4
4
|
if (isUserData)
|
|
5
5
|
return userOptionAdapter(actorData);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Item } from '../../../lib/types/models';
|
|
2
2
|
import { selectValue as selectValueProps } from '../dropdown/BaseField';
|
|
3
|
+
export declare const DATA_QUOTE_OPTION_FORMAT_REG: RegExp;
|
|
4
|
+
export declare const dataQuoteOptionFormat: (data: Item, display?: string) => selectValueProps;
|
|
3
5
|
export declare const dataQuoteInit: (dates: Item[], value: string[], display?: string) => selectValueProps[];
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
+
export const DATA_QUOTE_OPTION_FORMAT_REG = /{(\S+?)}/g;
|
|
2
|
+
export const dataQuoteOptionFormat = (data, display) => {
|
|
3
|
+
var _a, _b, _c;
|
|
4
|
+
if (!data)
|
|
5
|
+
return undefined;
|
|
6
|
+
const dataCopy = {
|
|
7
|
+
...data,
|
|
8
|
+
status: (_a = data.status) === null || _a === void 0 ? void 0 : _a.name,
|
|
9
|
+
itemType: (_b = data.itemType) === null || _b === void 0 ? void 0 : _b.name,
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
label: display
|
|
13
|
+
? display.replace(DATA_QUOTE_OPTION_FORMAT_REG, function (itemKey) {
|
|
14
|
+
const key = itemKey.slice(1, itemKey.length - 1);
|
|
15
|
+
return dataCopy[key] || (data.values && data.values[key]) || '';
|
|
16
|
+
})
|
|
17
|
+
: data.name,
|
|
18
|
+
value: data.objectId,
|
|
19
|
+
name: data.name,
|
|
20
|
+
key: data.key,
|
|
21
|
+
itemType: data.itemType,
|
|
22
|
+
icon: (_c = data === null || data === void 0 ? void 0 : data.itemType) === null || _c === void 0 ? void 0 : _c.icon,
|
|
23
|
+
values: data.values,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
1
26
|
export const dataQuoteInit = (dates, value, display) => {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const dataInit = existedDatas === null || existedDatas === void 0 ? void 0 : existedDatas.map(existedData => {
|
|
5
|
-
var _a, _b, _c;
|
|
6
|
-
const dataCopy = {
|
|
7
|
-
...existedData,
|
|
8
|
-
status: (_a = existedData.status) === null || _a === void 0 ? void 0 : _a.name,
|
|
9
|
-
itemType: (_b = existedData.itemType) === null || _b === void 0 ? void 0 : _b.name,
|
|
10
|
-
};
|
|
11
|
-
const values = existedData.values || {};
|
|
12
|
-
return {
|
|
13
|
-
label: display
|
|
14
|
-
? display.replace(regex, function (itemKey) {
|
|
15
|
-
const key = itemKey.slice(1, itemKey.length - 1);
|
|
16
|
-
return dataCopy[key] || values[key] || '';
|
|
17
|
-
})
|
|
18
|
-
: existedData.name,
|
|
19
|
-
value: existedData.objectId,
|
|
20
|
-
itemType: existedData.itemType,
|
|
21
|
-
icon: (_c = existedData === null || existedData === void 0 ? void 0 : existedData.itemType) === null || _c === void 0 ? void 0 : _c.icon,
|
|
22
|
-
values: existedData.values,
|
|
23
|
-
};
|
|
24
|
-
});
|
|
27
|
+
const existedDataList = dates === null || dates === void 0 ? void 0 : dates.filter(data => value === null || value === void 0 ? void 0 : value.includes(data.objectId));
|
|
28
|
+
const dataInit = existedDataList === null || existedDataList === void 0 ? void 0 : existedDataList.map(existedData => dataQuoteOptionFormat(existedData, display));
|
|
25
29
|
return dataInit;
|
|
26
30
|
};
|
|
@@ -29,6 +29,9 @@ interface FlowButtonProps {
|
|
|
29
29
|
};
|
|
30
30
|
hiddenPopover?: () => void;
|
|
31
31
|
readonly?: boolean;
|
|
32
|
+
conditionKey: string;
|
|
33
|
+
fieldTypeConditionKey: string;
|
|
34
|
+
userConditionKey: string;
|
|
32
35
|
}
|
|
33
36
|
declare const _default: React.NamedExoticComponent<FlowButtonProps>;
|
|
34
37
|
export default _default;
|
|
@@ -15,7 +15,7 @@ const CheckInStatus = {
|
|
|
15
15
|
closed: 'closed',
|
|
16
16
|
pending: 'pending',
|
|
17
17
|
};
|
|
18
|
-
const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds, workspaceRoleIds, authRoles, authUsers, authGroups, creatorAuth, authUserFields, authWorkSpaceRoles, scriptValidator, approval, checkIn, conditions = [], handleTransition, target, readonly, }) => {
|
|
18
|
+
const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds, workspaceRoleIds, authRoles, authUsers, authGroups, creatorAuth, authUserFields, authWorkSpaceRoles, scriptValidator, approval, checkIn, conditions = [], handleTransition, target, readonly, conditionKey, fieldTypeConditionKey, userConditionKey, }) => {
|
|
19
19
|
const [isCheck, setIsCheck] = useState(true);
|
|
20
20
|
const [tip, setTip] = useState('');
|
|
21
21
|
const checkApproval = useCallback(() => {
|
|
@@ -62,6 +62,7 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const transition = {
|
|
65
|
+
conditionKey,
|
|
65
66
|
parameters: {
|
|
66
67
|
fieldType: conditions,
|
|
67
68
|
permissionType: {
|
|
@@ -71,7 +72,9 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
|
|
|
71
72
|
workspaceRoles: authWorkSpaceRoles,
|
|
72
73
|
customFields: authUserFields,
|
|
73
74
|
creatorAuth,
|
|
75
|
+
conditionKey: userConditionKey,
|
|
74
76
|
},
|
|
77
|
+
fieldTypeConditionKey,
|
|
75
78
|
},
|
|
76
79
|
};
|
|
77
80
|
const checkResult = checkTransition(item, transition, { userId, roleIds, groupIds, workspaceRoleIds });
|
|
@@ -94,6 +97,9 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
|
|
|
94
97
|
roleIds,
|
|
95
98
|
groupIds,
|
|
96
99
|
workspaceRoleIds,
|
|
100
|
+
conditionKey,
|
|
101
|
+
fieldTypeConditionKey,
|
|
102
|
+
userConditionKey,
|
|
97
103
|
]);
|
|
98
104
|
useEffect(() => {
|
|
99
105
|
checkAuth();
|
|
@@ -31,9 +31,13 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
|
|
|
31
31
|
const [fetching, setFetching] = useState(true);
|
|
32
32
|
const [approval, setApproval] = useState(cloneDeep(DEFAULT_APPROVAL_DATA));
|
|
33
33
|
const [checkIn, setCheckIn] = useState(cloneDeep(DEFAULT_CHECK_IN_DATA));
|
|
34
|
+
const newItem = useRef(itemId);
|
|
34
35
|
useEffect(() => {
|
|
35
36
|
setStatusId(objectId);
|
|
36
|
-
|
|
37
|
+
return () => {
|
|
38
|
+
newItem.current = itemId;
|
|
39
|
+
};
|
|
40
|
+
}, [itemId, objectId]);
|
|
37
41
|
const { checkTransitionScript, getWorkflowData, getItemStatus, runTransition } = useWorkflowConfig();
|
|
38
42
|
const { currentUser } = useCurrentUser();
|
|
39
43
|
const [groupIds, roleIds, workspaceRoleIds] = useWorkflowPermission((_a = itemData === null || itemData === void 0 ? void 0 : itemData.workspace) === null || _a === void 0 ? void 0 : _a.objectId);
|
|
@@ -95,14 +99,17 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
|
|
|
95
99
|
logger('updateWorkflowMessage', statusId);
|
|
96
100
|
updateWorkflowMessage(workflowData, statusId);
|
|
97
101
|
}, [statusId]);
|
|
98
|
-
const refreshItem = (status) => {
|
|
102
|
+
const refreshItem = useCallback((status) => {
|
|
103
|
+
if (newItem.current !== itemId) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
99
106
|
setStatusId(status.objectId);
|
|
100
107
|
onTransitionSuccess === null || onTransitionSuccess === void 0 ? void 0 : onTransitionSuccess(status);
|
|
101
108
|
itemMutate();
|
|
102
109
|
proximaSdk.execute('updateStatusLog');
|
|
103
110
|
proximaSdk.execute('updateApprovalInfo', status.objectId);
|
|
104
111
|
proximaSdk.execute('updateCheckInInfo', status.objectId);
|
|
105
|
-
};
|
|
112
|
+
}, [itemId, itemMutate, onTransitionSuccess]);
|
|
106
113
|
const submitHandle = useCallback(async (transitionText, itemDetail = null) => {
|
|
107
114
|
const params = {
|
|
108
115
|
workflowId: workflowData.objectId,
|
|
@@ -225,8 +232,8 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
|
|
|
225
232
|
refresh();
|
|
226
233
|
});
|
|
227
234
|
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", { children: tasks.map(task => {
|
|
228
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
229
|
-
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 }, task.id));
|
|
235
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
236
|
+
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, 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 }, task.id));
|
|
230
237
|
}) }) })) : (_jsx("span", { onClick: () => {
|
|
231
238
|
setPopoverVisible(false);
|
|
232
239
|
}, css: css(noPermissionStyle), children: i18n.t('pages.fields.view.noWorkflowOrAuth') })), _jsx(View, { workflowData: workflowData, hiddenPopover: () => setPopoverVisible(false), name: name, objectId: objectId })] })) }));
|
|
@@ -14,7 +14,7 @@ const UserReadView = memo(({ value, readonly }) => {
|
|
|
14
14
|
})) || EMPTY_ARRAY);
|
|
15
15
|
}, [value]);
|
|
16
16
|
const tooltipValues = useMemo(() => {
|
|
17
|
-
return value === null || value === void 0 ? void 0 : value.map(
|
|
17
|
+
return value === null || value === void 0 ? void 0 : value.map(val => {
|
|
18
18
|
const item = userDataFormat(val);
|
|
19
19
|
return generateUserDisplayName(item);
|
|
20
20
|
});
|
|
@@ -22,7 +22,7 @@ const UserReadView = memo(({ value, readonly }) => {
|
|
|
22
22
|
if (!displayValues.length) {
|
|
23
23
|
return _jsx(EmptyField, { readonly: readonly, isUser: true });
|
|
24
24
|
}
|
|
25
|
-
return _jsx(BaseOverflowTooltip, { title: tooltipValues.join(','), maxline: 1, children: displayValues });
|
|
25
|
+
return (_jsx(BaseOverflowTooltip, { title: tooltipValues.join(','), maxline: 1, children: displayValues }));
|
|
26
26
|
});
|
|
27
27
|
UserReadView.displayName = 'UserReadView';
|
|
28
28
|
export default UserReadView;
|
package/dist/lib/array.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export declare const arrayDiff: (origin: Array<any>, target: Array<any>) => IDif
|
|
|
6
6
|
export declare const serializationArrayByKey: (list: any[], keyPath: string) => Record<string, any> | null;
|
|
7
7
|
export declare const createHash: () => number;
|
|
8
8
|
export declare function parseArray(str: string): string[];
|
|
9
|
-
export declare const getArrayValue: (value:
|
|
9
|
+
export declare const getArrayValue: <T = any>(value: T) => T[];
|
|
10
10
|
export {};
|
package/dist/lib/array.js
CHANGED
|
@@ -41,4 +41,4 @@ export function parseArray(str) {
|
|
|
41
41
|
}
|
|
42
42
|
return [];
|
|
43
43
|
}
|
|
44
|
-
export const getArrayValue = (value) => { var _a; return (_a = (isArray(value) ? value : [value])) === null || _a === void 0 ? void 0 : _a.filter(Boolean); };
|
|
44
|
+
export const getArrayValue = (value) => { var _a; return (_a = ((isArray(value) ? value : [value]))) === null || _a === void 0 ? void 0 : _a.filter(Boolean); };
|
package/dist/lib/workflow.js
CHANGED
|
@@ -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, } = ((_a = transition.parameters) === null || _a === void 0 ? void 0 : _a.permissionType) || {};
|
|
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) || {};
|
|
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;
|
|
@@ -128,12 +128,16 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
128
128
|
if (!hasUsers && !hasRoles && !hasGroups && !hasUserFields && !hasWorkspaceRoles && !creatorAuth) {
|
|
129
129
|
return { result: true };
|
|
130
130
|
}
|
|
131
|
+
const defaultConditionKey = conditionKey || 'any';
|
|
132
|
+
const isAny = defaultConditionKey === 'any';
|
|
131
133
|
if (creatorAuth) {
|
|
132
134
|
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)) {
|
|
133
135
|
tipText.push(i18n.t('pages.workflow.default.userType.creatorAuth'));
|
|
134
136
|
}
|
|
135
137
|
else {
|
|
136
|
-
|
|
138
|
+
if (isAny) {
|
|
139
|
+
return { result: true };
|
|
140
|
+
}
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
143
|
if (hasUsers) {
|
|
@@ -143,7 +147,9 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
143
147
|
tipText.push(`${i18n.t('libs.workflow.user')}:${tipUsers}`);
|
|
144
148
|
}
|
|
145
149
|
else {
|
|
146
|
-
|
|
150
|
+
if (isAny) {
|
|
151
|
+
return { result: true };
|
|
152
|
+
}
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
if (hasRoles) {
|
|
@@ -153,7 +159,9 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
153
159
|
tipText.push(`${i18n.t('libs.workflow.role')}:${tipRoles}`);
|
|
154
160
|
}
|
|
155
161
|
else {
|
|
156
|
-
|
|
162
|
+
if (isAny) {
|
|
163
|
+
return { result: true };
|
|
164
|
+
}
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
if (hasGroups) {
|
|
@@ -163,7 +171,9 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
163
171
|
tipText.push(`${i18n.t('libs.workflow.group')}:${tipGroup}`);
|
|
164
172
|
}
|
|
165
173
|
else {
|
|
166
|
-
|
|
174
|
+
if (isAny) {
|
|
175
|
+
return { result: true };
|
|
176
|
+
}
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
179
|
if (hasUserFields) {
|
|
@@ -194,7 +204,9 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
194
204
|
tipText.push(`${i18n.t('libs.workflow.userFields')}:${tipRoles}`);
|
|
195
205
|
}
|
|
196
206
|
else {
|
|
197
|
-
|
|
207
|
+
if (isAny) {
|
|
208
|
+
return { result: true };
|
|
209
|
+
}
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
if (hasWorkspaceRoles) {
|
|
@@ -206,7 +218,9 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
206
218
|
tipText.push(`${i18n.t('libs.workflow.workspaceRoles')}:${tipWorkspaceRoles}`);
|
|
207
219
|
}
|
|
208
220
|
else {
|
|
209
|
-
|
|
221
|
+
if (isAny) {
|
|
222
|
+
return { result: true };
|
|
223
|
+
}
|
|
210
224
|
}
|
|
211
225
|
}
|
|
212
226
|
if (tipText.length) {
|
|
@@ -215,8 +229,10 @@ export function checkUserPermission({ transition, userId, roleIds, groupIds, ite
|
|
|
215
229
|
return { result: true };
|
|
216
230
|
}
|
|
217
231
|
export function checkItemCondition(transition, item) {
|
|
218
|
-
var _a, _b;
|
|
219
|
-
const
|
|
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';
|
|
220
236
|
for (const i in conditions) {
|
|
221
237
|
const { comparedValue, numberCompare, stringCompare, dropDownCompare, field, pickerType } = conditions[i];
|
|
222
238
|
let fieldValue;
|
|
@@ -231,12 +247,12 @@ export function checkItemCondition(transition, item) {
|
|
|
231
247
|
fieldValue = item[field.key].objectId;
|
|
232
248
|
}
|
|
233
249
|
else {
|
|
234
|
-
fieldValue = (
|
|
250
|
+
fieldValue = (_c = item.values) === null || _c === void 0 ? void 0 : _c[field.key];
|
|
235
251
|
}
|
|
236
252
|
let sourceValue = null, targetValue = null;
|
|
237
253
|
switch (field.componentType) {
|
|
238
254
|
case CustomFieldComponentTypes.Number:
|
|
239
|
-
case CustomFieldComponentTypes.Date:
|
|
255
|
+
case CustomFieldComponentTypes.Date: {
|
|
240
256
|
targetValue = comparedValue;
|
|
241
257
|
if (field.componentType === CustomFieldComponentTypes.Date && NumberConditions.equalTo.key === numberCompare) {
|
|
242
258
|
targetValue = getFormat(targetValue || null, getDateType(pickerType));
|
|
@@ -251,6 +267,13 @@ export function checkItemCondition(transition, item) {
|
|
|
251
267
|
}),
|
|
252
268
|
};
|
|
253
269
|
}
|
|
270
|
+
else {
|
|
271
|
+
if (isAny) {
|
|
272
|
+
return {
|
|
273
|
+
result: true,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
254
277
|
}
|
|
255
278
|
else if (!numberToCompare(fieldValue, Number(targetValue), numberCompare)) {
|
|
256
279
|
if (isEmptyCondition(numberCompare)) {
|
|
@@ -275,7 +298,14 @@ export function checkItemCondition(transition, item) {
|
|
|
275
298
|
}),
|
|
276
299
|
};
|
|
277
300
|
}
|
|
278
|
-
|
|
301
|
+
else {
|
|
302
|
+
if (isAny) {
|
|
303
|
+
return {
|
|
304
|
+
result: true,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
279
309
|
case CustomFieldComponentTypes.Text:
|
|
280
310
|
case CustomFieldComponentTypes.LongText:
|
|
281
311
|
targetValue = comparedValue;
|
|
@@ -299,7 +329,13 @@ export function checkItemCondition(transition, item) {
|
|
|
299
329
|
message,
|
|
300
330
|
};
|
|
301
331
|
}
|
|
302
|
-
|
|
332
|
+
else {
|
|
333
|
+
if (isAny) {
|
|
334
|
+
return {
|
|
335
|
+
result: true,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
303
339
|
case CustomFieldComponentTypes.User:
|
|
304
340
|
case CustomFieldComponentTypes.Dropdown:
|
|
305
341
|
case CustomFieldComponentTypes.File:
|
|
@@ -337,9 +373,13 @@ export function checkItemCondition(transition, item) {
|
|
|
337
373
|
}),
|
|
338
374
|
};
|
|
339
375
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
376
|
+
else {
|
|
377
|
+
if (isAny) {
|
|
378
|
+
return {
|
|
379
|
+
result: true,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
343
383
|
}
|
|
344
384
|
}
|
|
345
385
|
return { result: true };
|
|
@@ -347,16 +387,25 @@ export function checkItemCondition(transition, item) {
|
|
|
347
387
|
export function checkTransition(item, transition, permissions) {
|
|
348
388
|
if (!item || !transition)
|
|
349
389
|
return { result: false };
|
|
390
|
+
const defaultConditionKey = (transition === null || transition === void 0 ? void 0 : transition.conditionKey) || 'all';
|
|
391
|
+
const isAll = defaultConditionKey === 'all';
|
|
350
392
|
const roleCheck = checkUserPermission({
|
|
351
393
|
transition,
|
|
352
394
|
item,
|
|
353
395
|
...permissions,
|
|
354
396
|
});
|
|
355
|
-
if (!roleCheck.result)
|
|
356
|
-
return roleCheck;
|
|
357
397
|
const conditionCheck = checkItemCondition(transition, item);
|
|
358
|
-
if (
|
|
359
|
-
|
|
398
|
+
if (isAll) {
|
|
399
|
+
if (!roleCheck.result)
|
|
400
|
+
return roleCheck;
|
|
401
|
+
if (!conditionCheck.result)
|
|
402
|
+
return conditionCheck;
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
if (roleCheck.result || conditionCheck.result) {
|
|
406
|
+
return { result: true };
|
|
407
|
+
}
|
|
408
|
+
}
|
|
360
409
|
return { result: true };
|
|
361
410
|
}
|
|
362
411
|
export const useWorkflowPermission = (workspaceId) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giteeteam/apps-team-components",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.0-alpha.1",
|
|
4
4
|
"description": "Gitee team components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"@emotion/cache": "^11.11.0",
|
|
65
65
|
"@emotion/react": "^11.11.1",
|
|
66
66
|
"debug": "^4.3.4",
|
|
67
|
+
"fs-extra": "^11.2.0",
|
|
67
68
|
"lodash-es": "^4.17.21"
|
|
68
69
|
}
|
|
69
70
|
}
|