@topconsultnpm/sdkui-react 6.20.0-dev1.65 → 6.20.0-dev1.67

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,9 +1,8 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState, forwardRef, useRef, useImperativeHandle } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useImperativeHandle } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { ContextMenu as TMContextMenu } from '../NewComponents/ContextMenu';
5
5
  import { TMColors } from '../../utils/theme';
6
- import { genUniqueId } from '../../helper';
7
6
  const StyledContent = styled.div `
8
7
  cursor: pointer;
9
8
  border-radius: ${props => props.$borderRadius};
@@ -23,9 +22,7 @@ const StyledContent = styled.div `
23
22
  }
24
23
  `;
25
24
  const TMDropDownMenu = forwardRef(({ content, items, disabled = false, color = TMColors.text_normal, backgroundColor = TMColors.default_background, borderRadius, onMenuShown }, ref) => {
26
- const [id, setID] = useState('');
27
- const dropDownMenuElementRef = useRef(null); // Ref all'elemento DOM div principale
28
- useEffect(() => { setID(genUniqueId()); }, [content]);
25
+ const dropDownMenuElementRef = useRef(null);
29
26
  useImperativeHandle(ref, () => ({
30
27
  focus: () => {
31
28
  dropDownMenuElementRef.current?.focus();
@@ -44,19 +41,6 @@ const TMDropDownMenu = forwardRef(({ content, items, disabled = false, color = T
44
41
  submenu: item.items ? convertToContextMenuItems(item.items) : undefined,
45
42
  }));
46
43
  };
47
- const [menuVisible, setMenuVisible] = useState(false);
48
- const handleMenuOpen = () => {
49
- setMenuVisible(true);
50
- onMenuShown?.();
51
- };
52
- const handleMenuClose = () => {
53
- setMenuVisible(false);
54
- dropDownMenuElementRef.current?.focus();
55
- };
56
- return (_jsxs(_Fragment, { children: [_jsx(StyledContent, { id: `idContainer${id}`, ref: dropDownMenuElementRef, tabIndex: disabled ? -1 : 0, "$disabled": disabled, "$color": color, "$backgroundColor": backgroundColor, "$borderRadius": borderRadius, onClick: !disabled ? handleMenuOpen : undefined, children: content }), _jsx(TMContextMenu, { items: convertToContextMenuItems(items), target: `#idContainer${id}`, trigger: "left", externalControl: {
57
- visible: menuVisible,
58
- position: { x: 0, y: 0 },
59
- onClose: handleMenuClose,
60
- } })] }));
44
+ return (_jsx(TMContextMenu, { items: convertToContextMenuItems(items), trigger: "left", children: _jsx(StyledContent, { ref: dropDownMenuElementRef, tabIndex: disabled ? -1 : 0, "$disabled": disabled, "$color": color, "$backgroundColor": backgroundColor, "$borderRadius": borderRadius, children: content }) }));
61
45
  });
62
46
  export default TMDropDownMenu;
@@ -25,7 +25,7 @@ export declare const WorkFlowApproveRejectPopUp: ({ TID, DID, deviceType, isReje
25
25
  onClose?: () => void;
26
26
  onCompleted?: () => Promise<void>;
27
27
  }) => import("react/jsx-runtime").JSX.Element;
28
- export declare const WorkFlowReAssignPopUp: ({ DID, TID, deviceType, onClose, selectedItems, onCompleted, wf }: {
28
+ export declare const WorkFlowReAssignPopUp: ({ DID, TID, deviceType, onClose, selectedItems, onCompleted, wf, workItemDetail }: {
29
29
  TID?: number;
30
30
  DID?: number;
31
31
  deviceType?: DeviceType;
@@ -33,6 +33,7 @@ export declare const WorkFlowReAssignPopUp: ({ DID, TID, deviceType, onClose, se
33
33
  selectedItems?: any[];
34
34
  onCompleted?: () => Promise<void>;
35
35
  wf?: WFDescriptor;
36
+ workItemDetail?: WorkItemDetail;
36
37
  }) => import("react/jsx-runtime").JSX.Element;
37
38
  /**
38
39
  * Modal per forzare l'approvazione di un work item
@@ -95,6 +95,7 @@ export const WorkFlowApproveRejectPopUp = ({ TID = 0, DID = 0, deviceType = Devi
95
95
  for (const { TID, DID } of items) {
96
96
  await workflowEngine.WorkItem_CompleteOrRejectAsync(TID, DID, commentValue, isReject);
97
97
  }
98
+ ShowAlert({ mode: 'success', position: 'TOP_RIGHT', title: isReject === 0 ? SDKUI_Localizator.WorkitemApprove : SDKUI_Localizator.WorkitemReject, message: SDKUI_Localizator.OperationSuccess, duration: 3000 });
98
99
  }
99
100
  catch (e) {
100
101
  TMExceptionBoxManager.show({ exception: e });
@@ -103,7 +104,6 @@ export const WorkFlowApproveRejectPopUp = ({ TID = 0, DID = 0, deviceType = Devi
103
104
  onCompleted?.();
104
105
  onClose?.();
105
106
  TMSpinner.hide();
106
- ShowAlert({ mode: 'success', position: 'TOP_RIGHT', title: isReject === 0 ? SDKUI_Localizator.WorkitemApprove : SDKUI_Localizator.WorkitemReject, message: SDKUI_Localizator.OperationSuccess, duration: 3000 });
107
107
  }
108
108
  };
109
109
  const workflowAction = isReject === 0 ? SDKUI_Localizator.Approve : SDKUI_Localizator.Reject;
@@ -113,23 +113,33 @@ export const WorkFlowApproveRejectPopUp = ({ TID = 0, DID = 0, deviceType = Devi
113
113
  ? _jsx(TMButton, { btnStyle: 'advanced', showTooltip: false, icon: _jsx(IconApply, {}), caption: SDKUI_Localizator.Approve, disabled: false, onClick: () => completeOrRejectAsync(isReject), advancedColor: TMColors.success })
114
114
  : _jsx(TMButton, { btnStyle: 'advanced', showTooltip: false, icon: _jsx(IconCloseOutline, {}), caption: SDKUI_Localizator.Reject, disabled: disable, onClick: () => { !disable && completeOrRejectAsync(isReject); }, advancedColor: TMColors.error }) })] }) }));
115
115
  };
116
- export const WorkFlowReAssignPopUp = ({ DID = 0, TID = 0, deviceType = DeviceType.DESKTOP, onClose, selectedItems = [], onCompleted, wf }) => {
116
+ export const WorkFlowReAssignPopUp = ({ DID = 0, TID = 0, deviceType = DeviceType.DESKTOP, onClose, selectedItems = [], onCompleted, wf, workItemDetail }) => {
117
117
  const [commentValue, setCommentValue] = useState('');
118
118
  const [selectedUserID, setSelectedUserID] = useState([]);
119
119
  const [participants, setParticipants] = useState([]);
120
120
  const disable = commentValue.length === 0 || !selectedUserID;
121
+ // Determina se siamo nel contesto CtrlWorkflow (quando abbiamo workItemDetail)
122
+ const isCtrlWorkflowContext = !!workItemDetail;
121
123
  const reAssignWorkFlowAsync = async () => {
122
124
  try {
123
125
  TMSpinner.show();
124
126
  const workflowEngine = SDK_Globals.tmSession?.NewWorkflowEngine();
125
127
  if (!workflowEngine)
126
128
  throw new Error("Workflow engine is not available");
127
- const items = selectedItems.length > 0
128
- ? selectedItems.map(({ TID, DID }) => ({ TID, DID }))
129
- : [{ TID, DID }];
130
- for (const { TID, DID } of items) {
131
- await SDK_Globals.tmSession?.NewWorkflowEngine().WorkItem_ReassignAsync(TID, DID, selectedUserID?.[0], commentValue);
129
+ if (isCtrlWorkflowContext && workItemDetail) {
130
+ // Contesto CtrlWorkflow: usa WFCtrl_ReassignWIAsync
131
+ await workflowEngine.WFCtrl_ReassignWIAsync(workItemDetail.wfid, workItemDetail.did, selectedUserID?.[0], commentValue);
132
132
  }
133
+ else {
134
+ // Contesto WorkItem: usa WorkItem_ReassignAsync
135
+ const items = selectedItems.length > 0
136
+ ? selectedItems.map(({ TID, DID }) => ({ TID, DID }))
137
+ : [{ TID, DID }];
138
+ for (const { TID, DID } of items) {
139
+ await workflowEngine.WorkItem_ReassignAsync(TID, DID, selectedUserID?.[0], commentValue);
140
+ }
141
+ }
142
+ ShowAlert({ mode: 'success', position: 'TOP_RIGHT', title: SDKUI_Localizator.WorkitemReassign, message: SDKUI_Localizator.OperationSuccess, duration: 3000 });
133
143
  }
134
144
  catch (e) {
135
145
  TMExceptionBoxManager.show({ exception: e });
@@ -138,11 +148,10 @@ export const WorkFlowReAssignPopUp = ({ DID = 0, TID = 0, deviceType = DeviceTyp
138
148
  onCompleted?.();
139
149
  onClose?.();
140
150
  TMSpinner.hide();
141
- ShowAlert({ mode: 'success', position: 'TOP_RIGHT', title: SDKUI_Localizator.WorkitemReassign, message: SDKUI_Localizator.OperationSuccess, duration: 3000 });
142
151
  }
143
152
  };
144
153
  // Determina il TID da usare
145
- const tidToUse = selectedItems?.[0]?.TID ?? TID;
154
+ const tidToUse = workItemDetail?.tid ?? selectedItems?.[0]?.TID ?? TID;
146
155
  useEffect(() => {
147
156
  let isMounted = true;
148
157
  const fetchData = async () => {
@@ -169,8 +178,11 @@ export const WorkFlowReAssignPopUp = ({ DID = 0, TID = 0, deviceType = DeviceTyp
169
178
  };
170
179
  fetchData();
171
180
  return () => { isMounted = false; };
172
- }, [tidToUse, wf]);
173
- return (_jsx(TMModal, { onClose: onClose, width: '600px', height: '270px', isModal: true, title: SDKUI_Localizator.Reassign + (selectedItems.length > 0 ? ' (' + selectedItems.length + ' workitem)' : ''), children: _jsxs(StyledModalBodyWrapper, { children: [_jsxs(StyledModalContentContainer, { children: [_jsx(TMUserChooser, { dataSource: participants, values: selectedUserID, onValueChanged: (IDs) => {
181
+ }, [tidToUse, wf, workItemDetail]);
182
+ // Determina il conteggio degli item da mostrare nel titolo
183
+ const itemCount = workItemDetail ? 1 : selectedItems.length;
184
+ const titleSuffix = itemCount > 0 ? ` (${itemCount} workitem)` : '';
185
+ return (_jsx(TMModal, { onClose: onClose, width: '600px', height: '270px', isModal: true, title: SDKUI_Localizator.Reassign + titleSuffix, children: _jsxs(StyledModalBodyWrapper, { children: [_jsxs(StyledModalContentContainer, { children: [_jsx(TMUserChooser, { dataSource: participants, values: selectedUserID, onValueChanged: (IDs) => {
174
186
  setSelectedUserID(IDs ?? []);
175
187
  } }), _jsxs("p", { style: { color: commentValue.length === 0 ? TMColors.error : 'black' }, children: [SDKUI_Localizator.CommentText, " ", commentValue.length === 0 && _jsx("span", { children: ` (${SDKUI_Localizator.RequiredField})` }), " "] }), _jsx(StyledTextArea, { maxLength: 200, "$isValid": commentValue.length !== 0, value: commentValue, onChange: (e) => setCommentValue(e.target.value) }), _jsx(CharacterCounter, { children: `${200 - commentValue.length} ${SDKUI_Localizator.CharactersRemaining}` })] }), _jsx(StyledModalFooter, { children: _jsx(TMButton, { btnStyle: 'advanced', showTooltip: false, icon: _jsx(IconUser, { fontSize: 16 }), caption: SDKUI_Localizator.Reassign, disabled: disable, onClick: () => !disable && reAssignWorkFlowAsync(), advancedColor: TMColors.tertiary }) })] }) }));
176
188
  };
@@ -308,6 +320,7 @@ export const WorkFlowMoreInfoPopUp = ({ DID = 0, TID = 0, deviceType = DeviceTyp
308
320
  name: `${TASK_MORE_INFO_PREFIX_NAME}${nameInput}`
309
321
  };
310
322
  await SDK_Globals.tmSession?.NewWorkflowEngine().WorkItem_MoreInfoAsync(TID, DID, taskWithPrefix);
323
+ ShowAlert({ mode: 'success', position: 'TOP_RIGHT', title: SDKUI_Localizator.MoreInformation, message: SDKUI_Localizator.MoreInfoSent, duration: 3000 });
311
324
  }
312
325
  catch (e) {
313
326
  TMExceptionBoxManager.show({ exception: e });
@@ -316,7 +329,6 @@ export const WorkFlowMoreInfoPopUp = ({ DID = 0, TID = 0, deviceType = DeviceTyp
316
329
  onCompleted?.();
317
330
  onClose?.();
318
331
  TMSpinner.hide();
319
- ShowAlert({ mode: 'success', position: 'TOP_RIGHT', title: SDKUI_Localizator.MoreInformation, message: SDKUI_Localizator.MoreInfoSent, duration: 3000 });
320
332
  }
321
333
  };
322
334
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev1.65",
3
+ "version": "6.20.0-dev1.67",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",