@topconsultnpm/sdkui-react 6.22.0-dev3.24 → 6.22.0-dev3.26
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/lib/components/NewComponents/ContextMenu/styles.d.ts +43 -45
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +60 -67
- package/lib/components/base/Styled.d.ts +77 -93
- package/lib/components/base/TMAlert.js +6 -8
- package/lib/components/base/TMAreaManager.js +53 -55
- package/lib/components/base/TMCounterBar.d.ts +2 -2
- package/lib/components/base/TMCounterContainer.d.ts +1 -2
- package/lib/components/base/TMCustomButton.d.ts +1 -1
- package/lib/components/base/TMCustomButton.js +39 -48
- package/lib/components/base/TMDataGridExportForm.d.ts +1 -2
- package/lib/components/base/TMFileManager.d.ts +1 -2
- package/lib/components/base/TMFileManagerDataGridView.d.ts +1 -2
- package/lib/components/base/TMFileManagerThumbnailItems.d.ts +1 -1
- package/lib/components/base/TMFileManagerThumbnailsView.d.ts +1 -1
- package/lib/components/base/TMFileManagerUtils.d.ts +6 -4
- package/lib/components/base/TMLayout.d.ts +4 -4
- package/lib/components/base/TMList.d.ts +1 -2
- package/lib/components/base/TMListView.d.ts +1 -1
- package/lib/components/base/TMPanel.js +167 -167
- package/lib/components/base/TMSpinner.d.ts +1 -2
- package/lib/components/base/TMTab.d.ts +3 -4
- package/lib/components/base/TMTabControl.js +208 -208
- package/lib/components/base/TMTooltip.d.ts +1 -1
- package/lib/components/base/TMTreeView.d.ts +8 -14
- package/lib/components/base/TMTreeView.js +14 -0
- package/lib/components/base/TMUserAvatar.d.ts +1 -2
- package/lib/components/base/TMVilViewer.d.ts +1 -2
- package/lib/components/base/TMWaitPanel.d.ts +2 -3
- package/lib/components/base/waitPanel/TMWaitPanelConfirm.d.ts +12 -0
- package/lib/components/base/waitPanel/TMWaitPanelConfirm.js +185 -0
- package/lib/components/base/waitPanel/TMWaitPanelManager.d.ts +169 -0
- package/lib/components/base/waitPanel/TMWaitPanelManager.js +320 -0
- package/lib/components/base/waitPanel/TMWaitPanelView.d.ts +52 -0
- package/lib/components/base/waitPanel/TMWaitPanelView.js +274 -0
- package/lib/components/base/waitPanel/index.d.ts +1 -0
- package/lib/components/base/waitPanel/index.js +1 -0
- package/lib/components/choosers/TMDynDataListItemChooser.d.ts +1 -1
- package/lib/components/choosers/TMInvoiceRetrieveFormats.d.ts +1 -2
- package/lib/components/choosers/TMOrderRetrieveFormats.d.ts +1 -2
- package/lib/components/choosers/TMPathChooser.js +17 -34
- package/lib/components/choosers/TMQuickSearchInfo.d.ts +1 -2
- package/lib/components/choosers/TMRelationChooser.d.ts +3 -3
- package/lib/components/choosers/TMUserChooser.d.ts +2 -2
- package/lib/components/editors/TMEditorStyled.d.ts +42 -20
- package/lib/components/editors/TMFormulaEditor.d.ts +1 -1
- package/lib/components/editors/TMHtmlContentDisplay.d.ts +1 -2
- package/lib/components/editors/TMHtmlEditor.d.ts +1 -2
- package/lib/components/editors/TMTreeDropDown.d.ts +1 -1
- package/lib/components/features/assistant/TMHelpOnLineChat.d.ts +28 -0
- package/lib/components/features/assistant/TMHelpOnLineChat.js +871 -0
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.d.ts +1 -1
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.js +2 -2
- package/lib/components/features/blog/TMBlogCommentForm.d.ts +1 -2
- package/lib/components/features/documents/TMBatchUpdateForm.js +3 -4
- package/lib/components/features/documents/TMCopyToFolderForm.js +32 -35
- package/lib/components/features/documents/TMDcmtForm.js +48 -60
- package/lib/components/features/documents/TMDcmtFormActionButtons.d.ts +1 -1
- package/lib/components/features/documents/TMDcmtIcon.d.ts +1 -4
- package/lib/components/features/documents/TMDcmtIcon.js +3 -5
- package/lib/components/features/documents/TMDcmtPreview.d.ts +6 -8
- package/lib/components/features/documents/TMDcmtPreview.js +5 -3
- package/lib/components/features/documents/TMDcmtTasks.d.ts +1 -2
- package/lib/components/features/documents/TMDragDropOverlay.d.ts +1 -1
- package/lib/components/features/documents/TMFileUploader.js +21 -21
- package/lib/components/features/documents/TMMasterDetailDcmts.d.ts +2 -0
- package/lib/components/features/documents/TMMasterDetailDcmts.js +45 -147
- package/lib/components/features/documents/TMMasterInfoFields.d.ts +1 -2
- package/lib/components/features/documents/TMMergeToPdfForm.d.ts +1 -2
- package/lib/components/features/documents/TMMergeToPdfForm.js +48 -47
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.d.ts +1 -2
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.js +14 -15
- package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.d.ts +4 -4
- package/lib/components/features/documents/TMRelationViewer.d.ts +3 -14
- package/lib/components/features/documents/TMRelationViewer.js +115 -79
- package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +1 -2
- package/lib/components/features/search/TMMetadataOutputForm.d.ts +1 -2
- package/lib/components/features/search/TMMetadataSorterForm.d.ts +1 -2
- package/lib/components/features/search/TMSavedQuerySelector.d.ts +2 -2
- package/lib/components/features/search/TMSearch.d.ts +1 -2
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +3 -9
- package/lib/components/features/search/TMSearchResult.js +6 -8
- package/lib/components/features/search/TMSearchResultFloatingActionButton.d.ts +1 -1
- package/lib/components/features/search/TMSignatureInfoContent.d.ts +1 -2
- package/lib/components/features/search/TMViewHistoryDcmt.d.ts +1 -2
- package/lib/components/features/search/TMViewHistoryDcmt.js +14 -25
- package/lib/components/features/tasks/TMTaskForm.d.ts +1 -1
- package/lib/components/features/tasks/TMTaskFormUtils.d.ts +10 -10
- package/lib/components/features/tasks/TMTasksAgenda.d.ts +1 -1
- package/lib/components/features/tasks/TMTasksCalendar.d.ts +1 -1
- package/lib/components/features/tasks/TMTasksHeader.d.ts +1 -1
- package/lib/components/features/tasks/TMTasksPanelContent.d.ts +1 -1
- package/lib/components/features/tasks/TMTasksUtilsView.d.ts +5 -5
- package/lib/components/features/tasks/TMTasksView.d.ts +1 -1
- package/lib/components/features/tasks/TMTasksView.js +91 -90
- package/lib/components/features/wg/TMWGsCopyMoveForm.d.ts +2 -3
- package/lib/components/features/wg/TMWGsCopyMoveForm.js +91 -91
- package/lib/components/features/workflow/TMWorkflowPopup.d.ts +7 -8
- package/lib/components/features/workflow/diagram/WorkitemRecipientsEditor.d.ts +1 -3
- package/lib/components/forms/Login/ChangePasswordInputs.d.ts +1 -3
- package/lib/components/forms/Login/Chooser.d.ts +2 -2
- package/lib/components/forms/TMChooserForm.d.ts +1 -2
- package/lib/components/forms/TMSaveForm.d.ts +4 -4
- package/lib/components/grids/TMBlogAttachments.d.ts +1 -2
- package/lib/components/grids/TMBlogHeader.d.ts +1 -1
- package/lib/components/grids/TMBlogsPost.d.ts +1 -1
- package/lib/components/grids/TMBlogsPost.js +92 -96
- package/lib/components/grids/TMBlogsPostUtils.d.ts +9 -9
- package/lib/components/grids/TMValidationItemsList.d.ts +1 -2
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +3 -0
- package/lib/components/layout/panelManager/TMPanelManagerContainer.d.ts +1 -2
- package/lib/components/layout/panelManager/TMPanelManagerContext.d.ts +2 -2
- package/lib/components/layout/panelManager/TMPanelManagerToolbar.d.ts +6 -5
- package/lib/components/layout/panelManager/TMPanelManagerWithPersistenceProvider.d.ts +2 -2
- package/lib/components/layout/panelManager/TMPanelWrapper.d.ts +2 -2
- package/lib/components/pages/TMPage.d.ts +1 -1
- package/lib/components/pages/TMPage.js +29 -31
- package/lib/components/query/TMQueryEditor.d.ts +10 -14
- package/lib/components/settings/SettingsAppearance.d.ts +1 -2
- package/lib/components/sidebar/TMAboutApp.d.ts +1 -2
- package/lib/components/sidebar/TMCommandsPanel.d.ts +4 -4
- package/lib/components/sidebar/TMHeader.d.ts +3 -3
- package/lib/components/viewers/TMDataListItemViewer.d.ts +2 -3
- package/lib/components/viewers/TMDataUserIdItemViewer.d.ts +2 -3
- package/lib/components/viewers/TMMidViewer.d.ts +2 -2
- package/lib/components/viewers/TMTidViewer.d.ts +2 -2
- package/lib/helper/SDKUI_Localizator.d.ts +7 -0
- package/lib/helper/SDKUI_Localizator.js +70 -0
- package/lib/helper/TMAppUpdatedModal.d.ts +1 -2
- package/lib/helper/TMAppUpdatedModal.js +93 -93
- package/lib/helper/TMCommandsContextMenu.d.ts +1 -1
- package/lib/helper/TMIcons.d.ts +280 -280
- package/lib/helper/TMPdfViewer.d.ts +1 -2
- package/lib/helper/TMToppyMessage.d.ts +2 -2
- package/lib/helper/TMUtils.d.ts +4 -10
- package/lib/helper/ZipManager.d.ts +1 -1
- package/lib/helper/ZipManager.js +2 -1
- package/lib/helper/helpers.d.ts +1 -1
- package/lib/hooks/useCheckInOutOperations.d.ts +0 -6
- package/lib/hooks/useCheckInOutOperations.js +14 -34
- package/lib/hooks/useDcmtOperations.d.ts +3 -12
- package/lib/hooks/useDcmtOperations.js +130 -160
- package/lib/hooks/useDocumentOperations.js +12 -23
- package/lib/hooks/useInputDialog.d.ts +1 -2
- package/lib/hooks/useMultiMasterDetailDcmts.d.ts +0 -15
- package/lib/hooks/useMultiMasterDetailDcmts.js +62 -65
- package/lib/hooks/useWorkflowApprove.js +33 -17
- package/lib/services/platform_services.d.ts +2 -3
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { clearMultiDetailLayout, Globalization, getExceptionMessage, getMultiDet
|
|
|
5
5
|
import { canViewMetadata, getDcmtMetadataByMid, getUserMetadataSorted, mapAssociationsFromMetadata } from '../helper/dcmtsHelper';
|
|
6
6
|
import { ButtonNames, TMExceptionBoxManager, TMMessageBoxManager } from '../components/base/TMPopUp';
|
|
7
7
|
import TMSpinner from '../components/base/TMSpinner';
|
|
8
|
+
import { TMWaitPanelManager } from '../components/base/waitPanel';
|
|
8
9
|
import ShowAlert from '../components/base/TMAlert';
|
|
9
10
|
import { TMResultManager } from '../components/forms/TMResultDialog';
|
|
10
11
|
import { useDataListItem } from './useDataListItem';
|
|
@@ -17,18 +18,6 @@ export var MultiDetailArchivePhase;
|
|
|
17
18
|
/** Riepilogo delle archiviazioni */
|
|
18
19
|
MultiDetailArchivePhase[MultiDetailArchivePhase["ArchiveSummary"] = 1] = "ArchiveSummary";
|
|
19
20
|
})(MultiDetailArchivePhase || (MultiDetailArchivePhase = {}));
|
|
20
|
-
const CLOSED_WAIT_PANEL = {
|
|
21
|
-
showWaitPanel: false,
|
|
22
|
-
waitPanelTitle: '',
|
|
23
|
-
showWaitPanelPrimary: false,
|
|
24
|
-
waitPanelTextPrimary: '',
|
|
25
|
-
waitPanelValuePrimary: 0,
|
|
26
|
-
waitPanelMaxValuePrimary: 0,
|
|
27
|
-
showWaitPanelSecondary: false,
|
|
28
|
-
waitPanelTextSecondary: '',
|
|
29
|
-
waitPanelValueSecondary: 0,
|
|
30
|
-
waitPanelMaxValueSecondary: 0,
|
|
31
|
-
};
|
|
32
21
|
/**
|
|
33
22
|
* Logica dell'archiviazione multipla dei dettagli: relazioni, sezioni, righe del riepilogo e
|
|
34
23
|
* archiviazione. Il rendering sta in TMMultiMasterDetailDcmtsForm
|
|
@@ -76,8 +65,6 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose, canNavigat
|
|
|
76
65
|
// Archiviazione finale
|
|
77
66
|
const [stopOnFirstError, setStopOnFirstError] = useState(true);
|
|
78
67
|
const [isArchiving, setIsArchiving] = useState(false);
|
|
79
|
-
const [waitPanel, setWaitPanel] = useState(CLOSED_WAIT_PANEL);
|
|
80
|
-
const abortControllerRef = useRef(undefined);
|
|
81
68
|
const selectedItem = detailRelationItems.find(item => item.relation === selectedRelation);
|
|
82
69
|
const hasMultipleTypes = detailRelationItems.length > 1;
|
|
83
70
|
const canUpdateMaster = canUpdateMasterCallback(dtd, masterDcmt);
|
|
@@ -620,44 +607,68 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose, canNavigat
|
|
|
620
607
|
dataTypeByMid.set(md.id, md.dataType); });
|
|
621
608
|
// Collegamenti della relazione valorizzati dal master (prevalgono sui valori del form)
|
|
622
609
|
const associationMids = await getMasterAssociationsForDetailAsync(selectedRelation);
|
|
623
|
-
//
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
610
|
+
// Con piu' righe: primaria sui documenti, secondaria sui byte. Con una riga sola solo i byte.
|
|
611
|
+
const isBatch = rowsToArchive.length > 1;
|
|
612
|
+
const waitPanel = TMWaitPanelManager.show({
|
|
613
|
+
title: SDKUI_Localizator.Archiving,
|
|
614
|
+
max: isBatch ? rowsToArchive.length : 0,
|
|
615
|
+
cancelable: true,
|
|
616
|
+
showSecondary: isBatch,
|
|
617
|
+
showCounters: isBatch,
|
|
618
|
+
primaryLabel: isBatch ? SDKUI_Localizator.Documents : undefined,
|
|
619
|
+
secondaryLabel: isBatch ? 'File corrente' : undefined,
|
|
633
620
|
});
|
|
621
|
+
const publishBytes = (loaded, total) => {
|
|
622
|
+
const text = total > 0
|
|
623
|
+
? `Uploading... ${Globalization.getNumberDisplayValue(loaded, true)} / ${Globalization.getNumberDisplayValue(total, true)}`
|
|
624
|
+
: '';
|
|
625
|
+
if (isBatch)
|
|
626
|
+
waitPanel.setSecondary({ value: loaded, max: total, text });
|
|
627
|
+
else
|
|
628
|
+
waitPanel.update({ value: loaded, max: total, subtitle: text });
|
|
629
|
+
};
|
|
634
630
|
const result = [];
|
|
635
631
|
const archivedRowIds = new Set();
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const rowData = rowsToArchive[i];
|
|
642
|
-
try {
|
|
643
|
-
setWaitPanel(prev => ({ ...prev, waitPanelTextPrimary: `${SDKUI_Localizator.Archiving} ${i + 1} / ${rowsToArchive.length}` }));
|
|
644
|
-
const newDID = await archiveRowAsync(rowData, detailTID, dataTypeByMid, associationMids, abortController.signal);
|
|
645
|
-
setWaitPanel(prev => ({ ...prev, waitPanelValuePrimary: i + 1 }));
|
|
646
|
-
archivedRowIds.add(rowData.id);
|
|
647
|
-
result.push({ rowIndex: i, id1: detailTID, id2: newDID, resultType: ResultTypes.SUCCESS });
|
|
648
|
-
}
|
|
649
|
-
catch (error) {
|
|
650
|
-
const err = error;
|
|
651
|
-
// Annullamento richiesto dall'utente: interrompe senza mostrare l'errore
|
|
652
|
-
if (err?.name === 'CanceledError' || abortController.signal.aborted) {
|
|
632
|
+
try {
|
|
633
|
+
for (let i = 0; i < rowsToArchive.length; i++) {
|
|
634
|
+
// Con la conferma di interruzione aperta il loop resta in pausa qui
|
|
635
|
+
await waitPanel.waitWhilePaused();
|
|
636
|
+
if (waitPanel.aborted) {
|
|
653
637
|
result.push({ rowIndex: i, id1: detailTID, id2: undefined, resultType: ResultTypes.WARNING, description: `Operazione interrotta. Elaborati ${i} documenti` });
|
|
638
|
+
waitPanel.warning();
|
|
654
639
|
break;
|
|
655
640
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
641
|
+
if (isBatch)
|
|
642
|
+
waitPanel.setSubtitle(`${SDKUI_Localizator.Archiving} ${i + 1} / ${rowsToArchive.length}`);
|
|
643
|
+
const rowData = rowsToArchive[i];
|
|
644
|
+
try {
|
|
645
|
+
const newDID = await archiveRowAsync(rowData, detailTID, dataTypeByMid, associationMids, waitPanel.signal, publishBytes);
|
|
646
|
+
archivedRowIds.add(rowData.id);
|
|
647
|
+
result.push({ rowIndex: i, id1: detailTID, id2: newDID, resultType: ResultTypes.SUCCESS });
|
|
648
|
+
waitPanel.ok();
|
|
649
|
+
}
|
|
650
|
+
catch (error) {
|
|
651
|
+
const err = error;
|
|
652
|
+
// Annullamento richiesto dall'utente: interrompe senza mostrare l'errore
|
|
653
|
+
if (err?.name === 'CanceledError' || waitPanel.aborted) {
|
|
654
|
+
result.push({ rowIndex: i, id1: detailTID, id2: undefined, resultType: ResultTypes.WARNING, description: `Operazione interrotta. Elaborati ${i} documenti` });
|
|
655
|
+
waitPanel.warning();
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
result.push({ rowIndex: i, id1: detailTID, id2: undefined, resultType: ResultTypes.ERROR, description: getExceptionMessage(error) });
|
|
659
|
+
waitPanel.error();
|
|
660
|
+
if (stopOnFirstError)
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
// Avanza a elaborazione conclusa: la barra non arriva al 100% prima dell'ultimo documento
|
|
664
|
+
if (isBatch)
|
|
665
|
+
await waitPanel.step();
|
|
659
666
|
}
|
|
660
667
|
}
|
|
668
|
+
finally {
|
|
669
|
+
// Chiuso prima del riepilogo dei risultati
|
|
670
|
+
waitPanel.close();
|
|
671
|
+
}
|
|
661
672
|
// Le righe archiviate escono dal riepilogo
|
|
662
673
|
if (archivedRowIds.size > 0) {
|
|
663
674
|
setArchiveRows(prev => prev.filter(r => !archivedRowIds.has(r.id)));
|
|
@@ -677,13 +688,11 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose, canNavigat
|
|
|
677
688
|
TMExceptionBoxManager.show({ exception: error });
|
|
678
689
|
}
|
|
679
690
|
finally {
|
|
680
|
-
abortControllerRef.current = undefined;
|
|
681
|
-
setWaitPanel(CLOSED_WAIT_PANEL);
|
|
682
691
|
setIsArchiving(false);
|
|
683
692
|
}
|
|
684
693
|
};
|
|
685
|
-
// Archiviazione di una singola riga, con avanzamento dell'upload
|
|
686
|
-
const archiveRowAsync = async (row, detailTID, dataTypeByMid, associationMids, signal) => {
|
|
694
|
+
// Archiviazione di una singola riga, con avanzamento dell'upload notificato a onBytes
|
|
695
|
+
const archiveRowAsync = async (row, detailTID, dataTypeByMid, associationMids, signal, onBytes) => {
|
|
687
696
|
const ae = new ArchiveEngineByID(SDK_Globals.tmSession);
|
|
688
697
|
ae.TID = detailTID;
|
|
689
698
|
ae.Metadata_ClearAll();
|
|
@@ -715,23 +724,12 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose, canNavigat
|
|
|
715
724
|
});
|
|
716
725
|
if (row.__file)
|
|
717
726
|
ae.ArchivingFile = row.__file;
|
|
718
|
-
let firstBlock = true;
|
|
719
|
-
let maxFileSize = 0;
|
|
720
727
|
return ae.ArchiveAsync(signal, (pd) => {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
setWaitPanel(prev => ({
|
|
727
|
-
...prev,
|
|
728
|
-
waitPanelValueSecondary: pd.ProgressBarValue,
|
|
729
|
-
waitPanelTextSecondary: `Uploading... ${Globalization.getNumberDisplayValue(pd.ProgressBarValue, true)} / ${Globalization.getNumberDisplayValue(maxFileSize, true)}`,
|
|
730
|
-
}));
|
|
731
|
-
if (pd.ProgressBarValue === pd.ProgressBarMaximum) {
|
|
732
|
-
setWaitPanel(prev => ({ ...prev, waitPanelValueSecondary: 0, waitPanelMaxValueSecondary: 0, waitPanelTextSecondary: '' }));
|
|
733
|
-
firstBlock = true;
|
|
734
|
-
}
|
|
728
|
+
// Upload completato: la barra si azzera per il file successivo
|
|
729
|
+
if (pd.ProgressBarValue === pd.ProgressBarMaximum)
|
|
730
|
+
onBytes(0, 0);
|
|
731
|
+
else
|
|
732
|
+
onBytes(pd.ProgressBarValue ?? 0, pd.ProgressBarMaximum ?? 0);
|
|
735
733
|
});
|
|
736
734
|
};
|
|
737
735
|
return {
|
|
@@ -756,6 +754,5 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose, canNavigat
|
|
|
756
754
|
openAddForm, openEditForm, closeAddForm, deleteRow, duplicateRow, upsertRow, updateRowValues, copyArchivedDetailToRows,
|
|
757
755
|
// Archiviazione
|
|
758
756
|
stopOnFirstError, setStopOnFirstError, isArchiving, archiveAllAsync,
|
|
759
|
-
waitPanel, abortController: abortControllerRef.current,
|
|
760
757
|
};
|
|
761
758
|
};
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import { SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
const WORKFLOW_APPROVE_CHANGED_EVENT = 'onWorkflowApproveChange';
|
|
4
|
+
/** Totale dei documenti da approvare: somma dei dcmtsFound delle singole categorie. */
|
|
5
|
+
const calcTotalDcmtsFound = (data) => {
|
|
6
|
+
return data.reduce((sum, item) => sum + (item.dcmtsFound || 0), 0);
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Fetch in corso.
|
|
10
|
+
*
|
|
11
|
+
* La WFAppr non porta un contatore ma l'intera lista di approvazione con le righe
|
|
12
|
+
* dei documenti, ed è chiesta da più istanze del hook a ridosso l'una dell'altra
|
|
13
|
+
* (coda del login, pagina di approvazione, widget della home). Chi arriva mentre
|
|
14
|
+
* è già in volo aspetta la stessa risposta invece di aprire una seconda richiesta.
|
|
15
|
+
*/
|
|
16
|
+
let inFlight;
|
|
17
|
+
/** Ricarica i dati e notifica tutte le istanze del hook. */
|
|
18
|
+
const load = async () => {
|
|
19
|
+
const result = await SDK_Globals.tmSession?.NewWorkflowEngine().WFApprAsync(1);
|
|
20
|
+
SDK_Globals.currentWorkflowApproveData = result ?? [];
|
|
21
|
+
window.dispatchEvent(new CustomEvent(WORKFLOW_APPROVE_CHANGED_EVENT));
|
|
22
|
+
};
|
|
3
23
|
/**
|
|
4
24
|
* Hook per gestire i dati di approvazione del workflow.
|
|
5
25
|
* Fornisce il dataSource, lo stato di caricamento e una funzione per aggiornare i dati.
|
|
@@ -7,13 +27,10 @@ import { SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
|
7
27
|
export const useWorkflowApprove = () => {
|
|
8
28
|
const [workflowApproveData, setWorkflowApproveData] = useState(SDK_Globals.currentWorkflowApproveData);
|
|
9
29
|
const [isLoading, setIsLoading] = useState(false);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const calculateTotalDcmtsFound = useCallback((data) => {
|
|
15
|
-
return data.reduce((sum, item) => sum + (item.dcmtsFound || 0), 0);
|
|
16
|
-
}, []);
|
|
30
|
+
// Seminato dai dati già in cache: un'istanza montata a login concluso parte dal
|
|
31
|
+
// totale reale e non da zero, altrimenti chi confronta questo valore con il
|
|
32
|
+
// contatore della home vede una differenza inesistente e ricarica a vuoto.
|
|
33
|
+
const [totalDcmtsFound, setTotalDcmtsFound] = useState(() => calcTotalDcmtsFound(SDK_Globals.currentWorkflowApproveData));
|
|
17
34
|
/**
|
|
18
35
|
* Ottiene tutti i work items che corrispondono a un determinato DID.
|
|
19
36
|
* Restituisce un array di oggetti { tid, did }.
|
|
@@ -40,12 +57,10 @@ export const useWorkflowApprove = () => {
|
|
|
40
57
|
}
|
|
41
58
|
setIsLoading(true);
|
|
42
59
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Notifica tutte le istanze del hook che i dati sono cambiati.
|
|
48
|
-
window.dispatchEvent(new CustomEvent('onWorkflowApproveChange'));
|
|
60
|
+
if (!inFlight) {
|
|
61
|
+
inFlight = load().finally(() => { inFlight = undefined; });
|
|
62
|
+
}
|
|
63
|
+
await inFlight;
|
|
49
64
|
}
|
|
50
65
|
catch (error) {
|
|
51
66
|
console.error("Errore durante il fetch dei dati di approvazione workflow:", error);
|
|
@@ -53,18 +68,19 @@ export const useWorkflowApprove = () => {
|
|
|
53
68
|
finally {
|
|
54
69
|
setIsLoading(false);
|
|
55
70
|
}
|
|
56
|
-
}, [
|
|
71
|
+
}, []);
|
|
57
72
|
// Questo useEffect serve a sincronizzare lo stato tra diverse istanze del hook.
|
|
58
73
|
// Se il componente A chiama refreshWorkflowApprove, il componente B (che usa lo stesso hook)
|
|
59
74
|
// riceverà l'evento e aggiornerà il suo stato locale.
|
|
60
75
|
useEffect(() => {
|
|
61
76
|
const handleUpdate = () => {
|
|
62
77
|
setWorkflowApproveData(SDK_Globals.currentWorkflowApproveData);
|
|
78
|
+
setTotalDcmtsFound(calcTotalDcmtsFound(SDK_Globals.currentWorkflowApproveData));
|
|
63
79
|
};
|
|
64
|
-
window.addEventListener(
|
|
80
|
+
window.addEventListener(WORKFLOW_APPROVE_CHANGED_EVENT, handleUpdate);
|
|
65
81
|
return () => {
|
|
66
|
-
window.removeEventListener(
|
|
82
|
+
window.removeEventListener(WORKFLOW_APPROVE_CHANGED_EVENT, handleUpdate);
|
|
67
83
|
};
|
|
68
|
-
}, [
|
|
84
|
+
}, []);
|
|
69
85
|
return { workflowApproveData, isLoading, refreshWorkflowApprove, totalDcmtsFound, getWorkItemsByDID };
|
|
70
86
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { JobTypes, ObjectClasses, ProcessDescriptor, DcmtTypeDescriptor } from "@topconsultnpm/sdk-ts";
|
|
3
2
|
export declare class PlatformObjectService {
|
|
4
3
|
static readonly retrieveAllAsync: (objClass: ObjectClasses, refreshCache?: boolean) => Promise<import("@topconsultnpm/sdk-ts").AreaDescriptor[] | import("@topconsultnpm/sdk-ts").NotificationDescriptor[] | import("@topconsultnpm/sdk-ts").RelationDescriptor[] | import("@topconsultnpm/sdk-ts").TaskDescriptor[] | import("@topconsultnpm/sdk-ts").WorkingGroupDescriptor[] | undefined>;
|
|
@@ -14,6 +13,6 @@ export declare class PlatformObjectService {
|
|
|
14
13
|
static readonly createAsync: (objClass: ObjectClasses, jobType: JobTypes, d: any) => Promise<number | undefined>;
|
|
15
14
|
static readonly deleteAsync: (objClass: ObjectClasses, id: number) => Promise<number | undefined>;
|
|
16
15
|
static readonly getName: (objClass: ObjectClasses, jobType?: JobTypes, isPlural?: boolean) => string;
|
|
17
|
-
static readonly getIcon: (objClass: ObjectClasses, d: any) =>
|
|
18
|
-
static readonly getTooltip: (objClass: ObjectClasses, d: any) =>
|
|
16
|
+
static readonly getIcon: (objClass: ObjectClasses, d: any) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
static readonly getTooltip: (objClass: ObjectClasses, d: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
19
18
|
}
|