@topconsultnpm/sdkui-react-beta 6.15.93 → 6.15.95

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.
@@ -252,6 +252,30 @@ export const StyledToolbarCardContainer = styled.div `
252
252
  flex-direction: column;
253
253
  gap: 10px;
254
254
  `;
255
+ const spinAnimation = keyframes `
256
+ 0% { transform: rotate(0deg); }
257
+ 100% { transform: rotate(360deg); }
258
+ `;
259
+ export const StyledSpinner = styled.div `
260
+ border: 4px solid #f3f3f3; /* Light grey */
261
+ border-top: 4px solid #C2388B; /* Colore primario della toolbar */
262
+ border-radius: 50%;
263
+ width: 40px;
264
+ height: 40px;
265
+ animation: ${spinAnimation} 1s linear infinite;
266
+ `;
267
+ export const StyledLoadingContainer = styled.div `
268
+ position: absolute;
269
+ top: 50%;
270
+ left: 50%;
271
+ transform: translate(-50%, -50%);
272
+ display: flex;
273
+ flex-direction: column;
274
+ align-items: center;
275
+ gap: 15px;
276
+ font-size: 1rem;
277
+ color: #555;
278
+ `;
255
279
  //#region Animations
256
280
  const scaleAndColorChange = (scaleValue) => keyframes `
257
281
  0% { transform: scale(1); color: white; }
@@ -13,7 +13,7 @@ import TMPanel from '../../base/TMPanel';
13
13
  import { TMPanelManagerProvider, useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
14
14
  import TMPanelManagerContainer from '../../layout/panelManager/TMPanelManagerContainer';
15
15
  const TMArchive = ({ inputTID, inputFile = null, connectorFileSave = undefined, onSavedAsyncCallback, inputMids = [], onCurrentTIDChanged }) => {
16
- const [currentTID, setCurrentTID] = useState(0);
16
+ const [currentTID, setCurrentTID] = useState(inputTID ?? 0);
17
17
  const [mruTIDs, setMruTIDs] = useState([]);
18
18
  const [currentMruTID, setCurrentMruTID] = useState(0);
19
19
  const [fromDTD, setFromDTD] = useState();
@@ -117,7 +117,7 @@ const TMArchive = ({ inputTID, inputFile = null, connectorFileSave = undefined,
117
117
  ]
118
118
  },
119
119
  ], [tmTreeSelectorElement, tmRecentsManagerElement, tmFormElement, currentTID, mruTIDs]);
120
- return (_jsx(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: initialPanelDimensions, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'tmRecentsManager', children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", showToolbar: true }) }));
120
+ return (_jsx(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: initialPanelDimensions, initialDimensions: initialPanelDimensions, initialMobilePanelId: inputTID ? 'tmDcmtForm' : 'tmRecentsManager', children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", showToolbar: true }) }));
121
121
  };
122
122
  export default TMArchive;
123
123
  const TMTreeSelectorWrapper = ({ isMobile, onSelectedTIDChanged }) => {
@@ -11,7 +11,7 @@ import { handleArchiveVisibility, searchResultToMetadataValues } from '../../../
11
11
  import { genUniqueId, IconShow, SDKUI_Localizator, updateMruTids, IconBoard, IconDcmtTypeSys, IconDetailDcmts, svgToString, IconDownload, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo, SDKUI_Globals, IconPreview, isTaskMoreInfo, IconWorkflow, IconZoomIn, IconZoomOut } from '../../../helper';
12
12
  import { hasDetailRelations, hasMasterRelations, isXMLFileExt } from '../../../helper/dcmtsHelper';
13
13
  import { Gutters, TMColors } from '../../../utils/theme';
14
- import { StyledClickableIconWrapper, StyledFormButtonsContainer, StyledModalContainer, StyledToolbarCardContainer } from '../../base/Styled';
14
+ import { StyledClickableIconWrapper, StyledFormButtonsContainer, StyledLoadingContainer, StyledModalContainer, StyledSpinner, StyledToolbarCardContainer } from '../../base/Styled';
15
15
  import ShowAlert from '../../base/TMAlert';
16
16
  import TMButton from '../../base/TMButton';
17
17
  import { TMExceptionBoxManager, TMMessageBoxManager, ButtonNames } from '../../base/TMPopUp';
@@ -70,6 +70,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
70
70
  const [focusedMetadataValue, setFocusedMetadataValue] = useState();
71
71
  const [showAll, setShowAll] = useState(layoutMode === LayoutModes.Ark);
72
72
  const [fetchError, setFetchError] = useState(false);
73
+ const [isWFDataLoading, setIsWFDataLoading] = useState(false);
73
74
  const [workItems, setWorkItems] = useState([]);
74
75
  const [workflows, setWorkflows] = useState([]);
75
76
  const [showCommentForm, setShowCommentForm] = useState(false);
@@ -210,10 +211,12 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
210
211
  return;
211
212
  if (!DID) {
212
213
  setWorkItems([]);
214
+ setWorkflows([]); // Assicurati di pulire anche i workflows
213
215
  return;
214
216
  }
217
+ setIsWFDataLoading(true);
215
218
  let items = [];
216
- // Cerchiamo tutti i workitem(S) associati al DID corrente (potrebbero esserci più istanze di workflow)
219
+ // Cerchiamo tutti i workitem(S) associati al DID corrente...
217
220
  for (const workflow of workflowApproveData) {
218
221
  for (const dataRow of workflow.dtdResult?.rows ?? []) {
219
222
  let did = Number(dataRow?.[1]);
@@ -225,12 +228,15 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
225
228
  }
226
229
  }
227
230
  }
228
- setWorkItems(items);
229
- // Attendi tutte le chiamate async e aggiorna lo stato solo quando tutte sono terminate
231
+ // Attendi tutte le chiamate async...
230
232
  Promise.all(items.map(item => WorkflowCacheService.GetWFInfoAsync(item.tid)))
231
233
  .then(results => {
232
234
  // Filtra solo i workflow validi
233
235
  setWorkflows(results.filter(Boolean));
236
+ })
237
+ .finally(() => {
238
+ setWorkItems(items);
239
+ setIsWFDataLoading(false);
234
240
  });
235
241
  }, [workflowApproveData, DID, layoutMode]);
236
242
  const getSelectionDcmtInfo = () => {
@@ -508,6 +514,16 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
508
514
  setDcmtFile(setFile);
509
515
  } }), [currentDcmt, dcmtFile, deviceType, fromDTD, layoutMode, inputFile]);
510
516
  const tmWF = useMemo(() => {
517
+ if (isWFDataLoading) {
518
+ return (_jsx("div", { style: {
519
+ display: 'flex',
520
+ alignItems: 'center',
521
+ justifyContent: 'center',
522
+ width: '100%',
523
+ height: '100%',
524
+ minHeight: '200px' // Evita salti nel layout
525
+ }, children: _jsxs(StyledLoadingContainer, { children: [_jsx(StyledSpinner, {}), _jsx("span", { children: `${'Caricamento dati workflow'}...` })] }) }));
526
+ }
511
527
  return (_jsxs("div", { style: { position: 'relative', width: '100%', height: '100%', display: 'flex', flexDirection: 'column', gap: 3 }, children: [workItems.length > 0
512
528
  ? _jsx(WFDiagram, { xmlDiagramString: workflows?.[0]?.diagram || '', currentSetID: WIsetIdValue, readOnly: true, zoomLevel: zoomLevel, translateX: 0, translateY: 0 })
513
529
  : _jsx("div", { style: {
@@ -11,6 +11,7 @@ import { calculateArrowAngle, getConnectionPoint, isConnectionNonLinear, validat
11
11
  import { IconFlowChart, IconUndo, IconRestore, IconAdjust, IconCopy, IconCut, IconPaste, IconPin, IconUnpin, IconChevronRight, IconCloseOutline, IconNew, SDKUI_Localizator } from '../../../../helper';
12
12
  import TMModal from '../../../base/TMModal';
13
13
  import { TMExceptionBoxManager } from '../../../base/TMPopUp';
14
+ import { StyledLoadingContainer, StyledSpinner } from '../../../base/Styled';
14
15
  const CanvasContainer = styled.div `
15
16
  position: relative;
16
17
  width: 100%;
@@ -201,6 +202,7 @@ const DiagramMessage = styled.div `
201
202
  text-align: center;
202
203
  `;
203
204
  const WFDiagram = ({ xmlDiagramString, currentSetID, readOnly = false, zoomLevel = 1, translateX = 0, translateY = 0 }) => {
205
+ const [isLoading, setIsLoading] = useState(true);
204
206
  const [wfDiagram, setWfDiagram] = useState(null);
205
207
  const [selectedItems, setSelectedItems] = useState(new Set());
206
208
  const [selectedConnections, setSelectedConnections] = useState(new Set());
@@ -265,18 +267,33 @@ const WFDiagram = ({ xmlDiagramString, currentSetID, readOnly = false, zoomLevel
265
267
  return { svgWidth: Math.max(0, totalWidth * zoomLevel), svgHeight: Math.max(0, totalHeight * zoomLevel) };
266
268
  }, [wfDiagram, zoomLevel]);
267
269
  useEffect(() => {
268
- let newDiagram = null;
269
- if (xmlDiagramString) {
270
- newDiagram = parseWfDiagramXml(xmlDiagramString);
271
- if (newDiagram) {
272
- // Applica l'auto-aggiustamento subito dopo il parsing
273
- newDiagram = autoAdjustDiagram(newDiagram);
270
+ setIsLoading(true); // Imposta il caricamento all'avvio dell'effetto
271
+ const processDiagram = () => {
272
+ try {
273
+ let newDiagram = null;
274
+ if (xmlDiagramString) {
275
+ newDiagram = parseWfDiagramXml(xmlDiagramString);
276
+ if (newDiagram) {
277
+ newDiagram = autoAdjustDiagram(newDiagram);
278
+ }
279
+ }
280
+ setWfDiagram(newDiagram);
281
+ initialDiagramRef.current = newDiagram;
282
+ setWfDiagramHistory(newDiagram ? [newDiagram] : []);
283
+ setHistoryIndex(newDiagram ? 0 : -1);
274
284
  }
275
- }
276
- setWfDiagram(newDiagram);
277
- initialDiagramRef.current = newDiagram;
278
- setWfDiagramHistory(newDiagram ? [newDiagram] : []);
279
- setHistoryIndex(newDiagram ? 0 : -1);
285
+ catch (error) {
286
+ console.error("Errore durante l'elaborazione del diagramma:", error);
287
+ setWfDiagram(null); // Assicurati che il diagramma sia nullo in caso di errore
288
+ }
289
+ finally {
290
+ setIsLoading(false); // Termina il caricamento, sia in caso di successo che di errore
291
+ }
292
+ };
293
+ // Utilizziamo un timeout di 0ms per consentire a React di renderizzare lo stato di caricamento
294
+ // prima di eseguire il calcolo potenzialmente pesante, evitando che il browser si blocchi.
295
+ const timerId = setTimeout(processDiagram, 0);
296
+ return () => clearTimeout(timerId); // Pulisce il timeout se il componente viene smontato
280
297
  }, [xmlDiagramString]);
281
298
  useEffect(() => {
282
299
  if (isUndoingRedoing.current) {
@@ -1322,7 +1339,7 @@ const WFDiagram = ({ xmlDiagramString, currentSetID, readOnly = false, zoomLevel
1322
1339
  // DiagramItemTypes.SignAndTimeStamp
1323
1340
  ];
1324
1341
  }, []);
1325
- return (_jsxs(CanvasContainer, { children: [!readOnly && (_jsxs(ToolbarContainer, { "$isCollapsed": isToolbarCollapsed, "$isFloating": isToolbarFloating, "$isToolboxVisible": isToolboxVisible, children: [_jsx(ButtonGroup, { "$isFloating": isToolbarFloating, children: _jsxs("button", { onClick: handleToggleToolboxVisibility, title: "Show toolbox", children: [_jsx(IconFlowChart, {}), !isToolbarCollapsed && _jsx("span", { children: "Mostra/nascondi toolbox" })] }) }), _jsxs(ButtonGroup, { "$isFloating": isToolbarFloating, children: [_jsxs("button", { onClick: handleUndo, disabled: historyIndex === 0, title: "Undo", children: [_jsx(IconUndo, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Undo" })] }), _jsxs("button", { onClick: handleRedo, disabled: historyIndex === wfDiagramHistory.length - 1, title: "Redo", children: [_jsx(IconUndo, { style: { transform: 'scaleX(-1)' } }), " ", !isToolbarCollapsed && _jsx("span", { children: "Redo" })] }), _jsxs("button", { onClick: handleRestore, title: "Restore", children: [_jsx(IconRestore, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Restore" })] }), _jsxs("button", { onClick: handleNew, title: "New diagram", disabled: readOnly, children: [_jsx(IconNew, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "New" })] })] }), _jsx(ButtonGroup, { "$isFloating": isToolbarFloating, children: _jsxs("button", { onClick: handleAutoAdjust, title: "Auto adjust", children: [_jsx(IconAdjust, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Auto Adjust" })] }) }), _jsxs(ButtonGroup, { "$isFloating": isToolbarFloating, children: [_jsxs("button", { onClick: handleCopy, disabled: selectedItems.size === 0, title: "Copy", children: [_jsx(IconCopy, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Copy" })] }), _jsxs("button", { onClick: handleCut, disabled: selectedItems.size === 0, title: "Cut", children: [_jsx(IconCut, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Cut" })] }), _jsxs("button", { onClick: handlePaste, disabled: copiedItems.length === 0 && copiedConnections.length === 0, title: "Paste", children: [_jsx(IconPaste, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Paste" })] })] }), _jsxs("button", { onClick: handleToggleToolbarMode, title: isToolbarFloating ? "Dock Toolbar" : "Float Toolbar", children: [isToolbarFloating ? _jsx(IconPin, {}) : _jsx(IconUnpin, {}), !isToolbarCollapsed && !isToolbarFloating && _jsx("span", { children: "Toggle Mode" })] }), !isToolbarFloating && _jsx(ToolbarToggle, { onClick: () => setIsToolbarCollapsed(!isToolbarCollapsed), title: isToolbarCollapsed ? "Expand Toolbar" : "Collapse Toolbar", children: isToolbarCollapsed ? _jsx(IconChevronRight, {}) : _jsx(IconCloseOutline, {}) })] })), !readOnly && (_jsx(ToolboxContainer, { "$isVisible": isToolboxVisible, children: isToolboxVisible && availableItemTypes.map(type => (_jsxs(ToolboxItem, { draggable: true, onDragStart: (e) => handleToolboxDragStart(e, type), onDragEnd: handleToolboxDragEnd, children: [_jsx(DiagramItemSvgContent, { itemType: type, width: 40, height: 40, isToolboxPreview: true }), _jsx("span", { children: DiagramItemTypes[type] })] }, type))) })), _jsx(SvgScrollContainer, { children: wfDiagram ? (_jsx(StyledSvg, { ref: svgRef, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseDown: handleMouseDown, onDrop: handleDropOnCanvas, onDragOver: handleDragOver, width: svgWidth, height: svgHeight, children: _jsxs(ScalableGroup, { "$scale": zoomLevel, "$translateX": translateX, "$translateY": translateY, children: [wfDiagram?.DiagramItems.map(item => (_jsx(DiagramItemComponent, { readOnly: readOnly, item: item, isSelected: selectedItems.has(item.ID), isCurrent: item.ID === currentSetID, onClick: handleDiagramItemClick, onDrag: handleDrag, onDragEnd: handleDragEnd, onConnectorMouseDown: handleConnectorMouseDown, onConnectorMouseUp: handleConnectorMouseUp, onDimensionsChange: handleItemDimensionsChange, onDoubleClick: handleDoubleClickItem }, item.ID))), calculatedConnections.map(connection => {
1342
+ return (_jsxs(CanvasContainer, { children: [!readOnly && (_jsxs(ToolbarContainer, { "$isCollapsed": isToolbarCollapsed, "$isFloating": isToolbarFloating, "$isToolboxVisible": isToolboxVisible, children: [_jsx(ButtonGroup, { "$isFloating": isToolbarFloating, children: _jsxs("button", { onClick: handleToggleToolboxVisibility, title: "Show toolbox", children: [_jsx(IconFlowChart, {}), !isToolbarCollapsed && _jsx("span", { children: "Mostra/nascondi toolbox" })] }) }), _jsxs(ButtonGroup, { "$isFloating": isToolbarFloating, children: [_jsxs("button", { onClick: handleUndo, disabled: historyIndex === 0, title: "Undo", children: [_jsx(IconUndo, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Undo" })] }), _jsxs("button", { onClick: handleRedo, disabled: historyIndex === wfDiagramHistory.length - 1, title: "Redo", children: [_jsx(IconUndo, { style: { transform: 'scaleX(-1)' } }), " ", !isToolbarCollapsed && _jsx("span", { children: "Redo" })] }), _jsxs("button", { onClick: handleRestore, title: "Restore", children: [_jsx(IconRestore, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Restore" })] }), _jsxs("button", { onClick: handleNew, title: "New diagram", disabled: readOnly, children: [_jsx(IconNew, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "New" })] })] }), _jsx(ButtonGroup, { "$isFloating": isToolbarFloating, children: _jsxs("button", { onClick: handleAutoAdjust, title: "Auto adjust", children: [_jsx(IconAdjust, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Auto Adjust" })] }) }), _jsxs(ButtonGroup, { "$isFloating": isToolbarFloating, children: [_jsxs("button", { onClick: handleCopy, disabled: selectedItems.size === 0, title: "Copy", children: [_jsx(IconCopy, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Copy" })] }), _jsxs("button", { onClick: handleCut, disabled: selectedItems.size === 0, title: "Cut", children: [_jsx(IconCut, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Cut" })] }), _jsxs("button", { onClick: handlePaste, disabled: copiedItems.length === 0 && copiedConnections.length === 0, title: "Paste", children: [_jsx(IconPaste, {}), " ", !isToolbarCollapsed && _jsx("span", { children: "Paste" })] })] }), _jsxs("button", { onClick: handleToggleToolbarMode, title: isToolbarFloating ? "Dock Toolbar" : "Float Toolbar", children: [isToolbarFloating ? _jsx(IconPin, {}) : _jsx(IconUnpin, {}), !isToolbarCollapsed && !isToolbarFloating && _jsx("span", { children: "Toggle Mode" })] }), !isToolbarFloating && _jsx(ToolbarToggle, { onClick: () => setIsToolbarCollapsed(!isToolbarCollapsed), title: isToolbarCollapsed ? "Expand Toolbar" : "Collapse Toolbar", children: isToolbarCollapsed ? _jsx(IconChevronRight, {}) : _jsx(IconCloseOutline, {}) })] })), !readOnly && (_jsx(ToolboxContainer, { "$isVisible": isToolboxVisible, children: isToolboxVisible && availableItemTypes.map(type => (_jsxs(ToolboxItem, { draggable: true, onDragStart: (e) => handleToolboxDragStart(e, type), onDragEnd: handleToolboxDragEnd, children: [_jsx(DiagramItemSvgContent, { itemType: type, width: 40, height: 40, isToolboxPreview: true }), _jsx("span", { children: DiagramItemTypes[type] })] }, type))) })), _jsx(SvgScrollContainer, { children: isLoading ? (_jsxs(StyledLoadingContainer, { children: [_jsx(StyledSpinner, {}), _jsx("span", { children: `${'Caricamento diagramma'}...` })] })) : wfDiagram ? (_jsx(StyledSvg, { ref: svgRef, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseDown: handleMouseDown, onDrop: handleDropOnCanvas, onDragOver: handleDragOver, width: svgWidth, height: svgHeight, children: _jsxs(ScalableGroup, { "$scale": zoomLevel, "$translateX": translateX, "$translateY": translateY, children: [wfDiagram?.DiagramItems.map(item => (_jsx(DiagramItemComponent, { readOnly: readOnly, item: item, isSelected: selectedItems.has(item.ID), isCurrent: item.ID === currentSetID, onClick: handleDiagramItemClick, onDrag: handleDrag, onDragEnd: handleDragEnd, onConnectorMouseDown: handleConnectorMouseDown, onConnectorMouseUp: handleConnectorMouseUp, onDimensionsChange: handleItemDimensionsChange, onDoubleClick: handleDoubleClickItem }, item.ID))), calculatedConnections.map(connection => {
1326
1343
  const sourceItem = wfDiagram?.DiagramItems.find(item => item.ID === connection.Source.ParentDiagramItem.ID);
1327
1344
  const sinkItem = wfDiagram?.DiagramItems.find(item => item.ID === connection.Sink.ParentDiagramItem.ID);
1328
1345
  if (!sourceItem || !sinkItem)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.15.93",
3
+ "version": "6.15.95",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",