@topconsultnpm/sdkui-react 6.20.0-dev1.11 → 6.20.0-dev1.111
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/assets/Toppy-help-center.png +0 -0
- package/lib/assets/headergradient.svg +87 -0
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +285 -28
- package/lib/components/NewComponents/ContextMenu/hooks.d.ts +8 -1
- package/lib/components/NewComponents/ContextMenu/hooks.js +80 -8
- package/lib/components/NewComponents/ContextMenu/index.d.ts +3 -0
- package/lib/components/NewComponents/ContextMenu/index.js +2 -0
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +9 -1
- package/lib/components/NewComponents/ContextMenu/styles.js +157 -37
- package/lib/components/NewComponents/ContextMenu/types.d.ts +14 -1
- package/lib/components/NewComponents/ContextMenu/useLongPress.d.ts +21 -0
- package/lib/components/NewComponents/ContextMenu/useLongPress.js +112 -0
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +563 -112
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +21 -5
- package/lib/components/NewComponents/FloatingMenuBar/styles.js +210 -58
- package/lib/components/NewComponents/FloatingMenuBar/types.d.ts +8 -2
- package/lib/components/base/TMAccordionNew.js +35 -14
- package/lib/components/base/TMCustomButton.js +61 -17
- package/lib/components/base/TMDataGrid.d.ts +7 -4
- package/lib/components/base/TMDataGrid.js +153 -11
- package/lib/components/base/TMDropDownMenu.js +19 -18
- package/lib/components/base/TMFileManager.d.ts +4 -3
- package/lib/components/base/TMFileManager.js +32 -24
- package/lib/components/base/TMFileManagerDataGridView.d.ts +3 -2
- package/lib/components/base/TMFileManagerDataGridView.js +1 -11
- package/lib/components/base/TMFileManagerThumbnailItems.d.ts +7 -1
- package/lib/components/base/TMFileManagerThumbnailItems.js +5 -2
- package/lib/components/base/TMFileManagerThumbnailsView.d.ts +17 -4
- package/lib/components/base/TMFileManagerThumbnailsView.js +18 -6
- package/lib/components/base/TMFileManagerUtils.d.ts +0 -12
- package/lib/components/base/TMListView.js +33 -15
- package/lib/components/base/TMPanel.d.ts +1 -1
- package/lib/components/base/TMPanel.js +1 -1
- package/lib/components/base/TMTreeView.d.ts +2 -1
- package/lib/components/base/TMTreeView.js +33 -26
- package/lib/components/choosers/TMDistinctValues.js +2 -2
- package/lib/components/choosers/TMInvoiceRetrieveFormats.js +1 -1
- package/lib/components/choosers/TMMetadataChooser.js +8 -1
- package/lib/components/choosers/TMOrderRetrieveFormats.js +1 -1
- package/lib/components/choosers/TMUserChooser.d.ts +0 -5
- package/lib/components/choosers/TMUserChooser.js +25 -45
- package/lib/components/editors/TMDateBox.js +18 -9
- package/lib/components/editors/TMLocalizedTextBox.d.ts +3 -1
- package/lib/components/editors/TMLocalizedTextBox.js +16 -14
- package/lib/components/editors/TMMetadataTextBox.d.ts +9 -0
- package/lib/components/editors/TMMetadataTextBox.js +92 -0
- package/lib/components/editors/TMMetadataValues.js +23 -5
- package/lib/components/editors/TMTextArea.js +18 -30
- package/lib/components/editors/TMTextBox.d.ts +1 -1
- package/lib/components/editors/TMTextBox.js +6 -3
- package/lib/components/editors/TMTextExpression.js +6 -91
- package/lib/components/features/archive/TMArchive.js +2 -2
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.d.ts +15 -0
- package/lib/components/features/assistant/TMToppyDraggableHelpCenter.js +460 -0
- package/lib/components/features/assistant/TMToppySpeechBubble.d.ts +11 -0
- package/lib/components/features/assistant/TMToppySpeechBubble.js +126 -0
- package/lib/components/features/documents/TMDcmtForm.d.ts +14 -2
- package/lib/components/features/documents/TMDcmtForm.js +457 -206
- package/lib/components/features/documents/TMDcmtPreview.js +44 -110
- package/lib/components/features/documents/TMDcmtTasks.js +9 -9
- package/lib/components/features/documents/TMMasterDetailDcmts.js +38 -53
- package/lib/components/features/documents/TMRelationViewer.d.ts +1 -1
- package/lib/components/features/documents/TMRelationViewer.js +2 -2
- package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
- package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +2 -2
- package/lib/components/features/search/TMSavedQuerySelector.js +72 -67
- package/lib/components/features/search/TMSearch.d.ts +3 -0
- package/lib/components/features/search/TMSearch.js +50 -11
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +1 -0
- package/lib/components/features/search/TMSearchQueryPanel.js +29 -21
- package/lib/components/features/search/TMSearchResult.d.ts +3 -0
- package/lib/components/features/search/TMSearchResult.js +208 -250
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +3 -3
- package/lib/components/features/search/TMSearchResultsMenuItems.js +205 -169
- package/lib/components/features/search/TMSignSettingsForm.js +1 -1
- package/lib/components/features/search/TMSignatureInfoContent.d.ts +6 -0
- package/lib/components/features/search/TMSignatureInfoContent.js +140 -0
- package/lib/components/features/search/TMViewHistoryDcmt.js +2 -2
- package/lib/components/features/tasks/TMTaskForm.js +20 -1
- package/lib/components/features/tasks/TMTasksAgenda.d.ts +3 -1
- package/lib/components/features/tasks/TMTasksAgenda.js +48 -9
- package/lib/components/features/tasks/TMTasksCalendar.d.ts +2 -0
- package/lib/components/features/tasks/TMTasksCalendar.js +19 -7
- package/lib/components/features/tasks/TMTasksUtils.d.ts +2 -2
- package/lib/components/features/tasks/TMTasksUtils.js +43 -36
- package/lib/components/features/tasks/TMTasksView.js +28 -19
- package/lib/components/features/workflow/TMWorkflowPopup.d.ts +33 -2
- package/lib/components/features/workflow/TMWorkflowPopup.js +139 -34
- package/lib/components/features/workflow/diagram/DiagramItemComponent.d.ts +2 -0
- package/lib/components/features/workflow/diagram/DiagramItemComponent.js +12 -7
- package/lib/components/features/workflow/diagram/DiagramItemForm.js +1 -1
- package/lib/components/features/workflow/diagram/RecipientList.js +3 -2
- package/lib/components/features/workflow/diagram/WFDiagram.d.ts +4 -0
- package/lib/components/features/workflow/diagram/WFDiagram.js +164 -13
- package/lib/components/forms/Login/LoginValidatorService.d.ts +2 -0
- package/lib/components/forms/Login/LoginValidatorService.js +7 -2
- package/lib/components/forms/Login/TMLoginForm.js +34 -6
- package/lib/components/forms/TMChooserForm.js +1 -1
- package/lib/components/grids/TMBlogsPost.js +56 -31
- package/lib/components/grids/TMRecentsManager.js +20 -10
- package/lib/components/index.d.ts +6 -3
- package/lib/components/index.js +6 -3
- package/lib/components/query/TMQueryEditor.d.ts +2 -1
- package/lib/components/query/TMQueryEditor.js +92 -92
- package/lib/components/settings/SettingsAppearance.d.ts +2 -1
- package/lib/components/settings/SettingsAppearance.js +99 -30
- package/lib/components/sidebar/TMHeader.js +7 -7
- package/lib/components/sidebar/TMSidebar.d.ts +0 -1
- package/lib/components/sidebar/TMSidebar.js +16 -44
- package/lib/components/sidebar/TMSidebarItem.js +34 -17
- package/lib/components/viewers/TMDataListItemViewer.d.ts +2 -1
- package/lib/components/viewers/TMDataListItemViewer.js +35 -71
- package/lib/components/viewers/TMDataUserIdItemViewer.d.ts +8 -0
- package/lib/components/viewers/TMDataUserIdItemViewer.js +39 -0
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +22 -0
- package/lib/helper/SDKUI_Globals.js +10 -1
- package/lib/helper/SDKUI_Localizator.d.ts +17 -1
- package/lib/helper/SDKUI_Localizator.js +167 -1
- package/lib/helper/TMCommandsContextMenu.d.ts +4 -2
- package/lib/helper/TMCommandsContextMenu.js +15 -4
- package/lib/helper/TMIcons.d.ts +4 -0
- package/lib/helper/TMIcons.js +13 -3
- package/lib/helper/TMPdfViewer.d.ts +8 -0
- package/lib/helper/TMPdfViewer.js +373 -0
- package/lib/helper/checkinCheckoutManager.d.ts +31 -1
- package/lib/helper/checkinCheckoutManager.js +112 -30
- package/lib/helper/devextremeCustomMessages.d.ts +30 -0
- package/lib/helper/devextremeCustomMessages.js +30 -0
- package/lib/helper/helpers.d.ts +28 -1
- package/lib/helper/helpers.js +130 -3
- package/lib/helper/index.d.ts +2 -0
- package/lib/helper/index.js +2 -0
- package/lib/helper/queryHelper.d.ts +1 -1
- package/lib/helper/queryHelper.js +33 -3
- package/lib/helper/workItemsHelper.d.ts +6 -0
- package/lib/helper/workItemsHelper.js +230 -0
- package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
- package/lib/hooks/useCheckInOutOperations.js +223 -0
- package/lib/hooks/useDataListItem.d.ts +12 -0
- package/lib/hooks/useDataListItem.js +132 -0
- package/lib/hooks/useDataUserIdItem.d.ts +10 -0
- package/lib/hooks/useDataUserIdItem.js +96 -0
- package/lib/hooks/useMetadataExpression.d.ts +19 -0
- package/lib/hooks/useMetadataExpression.js +99 -0
- package/lib/hooks/useSettingsFeedback.d.ts +11 -0
- package/lib/hooks/useSettingsFeedback.js +38 -0
- package/lib/hooks/useWorkflowApprove.d.ts +4 -0
- package/lib/hooks/useWorkflowApprove.js +14 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -2
- package/lib/services/platform_services.d.ts +3 -3
- package/lib/ts/types.d.ts +61 -1
- package/lib/utils/theme.d.ts +1 -1
- package/lib/utils/theme.js +1 -1
- package/package.json +7 -4
- package/lib/components/NewComponents/Notification/Notification.d.ts +0 -4
- package/lib/components/NewComponents/Notification/Notification.js +0 -60
- package/lib/components/NewComponents/Notification/NotificationContainer.d.ts +0 -8
- package/lib/components/NewComponents/Notification/NotificationContainer.js +0 -33
- package/lib/components/NewComponents/Notification/index.d.ts +0 -2
- package/lib/components/NewComponents/Notification/index.js +0 -2
- package/lib/components/NewComponents/Notification/styles.d.ts +0 -21
- package/lib/components/NewComponents/Notification/styles.js +0 -180
- package/lib/components/NewComponents/Notification/types.d.ts +0 -18
- package/lib/components/NewComponents/Notification/types.js +0 -1
- package/lib/components/base/TMContextMenu.d.ts +0 -25
- package/lib/components/base/TMContextMenu.js +0 -109
- package/lib/components/base/TMContextMenuOLD.d.ts +0 -26
- package/lib/components/base/TMContextMenuOLD.js +0 -56
- package/lib/components/base/TMFloatingToolbar.d.ts +0 -9
- package/lib/components/base/TMFloatingToolbar.js +0 -101
- package/lib/components/features/assistant/ToppyDraggableHelpCenter.d.ts +0 -30
- package/lib/components/features/assistant/ToppyDraggableHelpCenter.js +0 -482
- package/lib/components/features/assistant/ToppySpeechBubble.d.ts +0 -9
- package/lib/components/features/assistant/ToppySpeechBubble.js +0 -117
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { cicoDownloadFilesCallback, dcmtsFileCachePreview, getCicoDownloadFileName, getExceptionMessage, removeDcmtsFileCache, renderCicoCheckInContent, SDKUI_Globals, SDKUI_Localizator, updateCicoCheckoutStorageItem, validateCicoFileName } from '../helper';
|
|
3
|
+
import { ButtonNames, ShowAlert, TMMessageBoxManager, TMResultManager } from '../components';
|
|
4
|
+
import { ResultTypes, SDK_Globals } from '@topconsultnpm/sdk-ts';
|
|
5
|
+
let abortController = new AbortController();
|
|
6
|
+
export const useCheckInOutOperations = () => {
|
|
7
|
+
const [showHistory, setShowHistory] = useState(false);
|
|
8
|
+
// State to manage show history selected file
|
|
9
|
+
const [showCheckoutInformationForm, setShowCheckoutInformationForm] = useState(false);
|
|
10
|
+
// Stato per triggerare il refresh della preview dall'esterno
|
|
11
|
+
const [refreshPreviewTrigger, setRefreshPreviewTrigger] = useState(0);
|
|
12
|
+
// State to manage comment form
|
|
13
|
+
const [commentFormState, setCommentFormState] = useState({
|
|
14
|
+
removeAndEditAttachment: true,
|
|
15
|
+
show: false,
|
|
16
|
+
isRequired: false
|
|
17
|
+
});
|
|
18
|
+
// State variable to control the visibility of the wait panel
|
|
19
|
+
const [showCicoWaitPanel, setShowCicoWaitPanel] = useState(false);
|
|
20
|
+
// State variable to store the title of the wait panel
|
|
21
|
+
const [cicoWaitPanelTitle, setCicoWaitPanelTitle] = useState('');
|
|
22
|
+
// State variable to control the visibility of the primary section of the wait panel
|
|
23
|
+
const [showCicoPrimaryProgress, setShowCicoPrimaryProgress] = useState(false);
|
|
24
|
+
// State variable to store the primary text of the wait panel
|
|
25
|
+
const [cicoPrimaryProgressText, setCicoPrimaryProgressText] = useState('');
|
|
26
|
+
// State variable to track the current value of the primary progress indicator in the wait panel
|
|
27
|
+
const [cicoPrimaryProgressValue, setCicoPrimaryProgressValue] = useState(0);
|
|
28
|
+
// State variable to define the maximum value for the primary progress indicator in the wait panel
|
|
29
|
+
const [cicoPrimaryProgressMax, setCicoPrimaryProgressMax] = useState(0);
|
|
30
|
+
const showHistoryCallback = useCallback(() => {
|
|
31
|
+
setShowHistory(true);
|
|
32
|
+
}, []);
|
|
33
|
+
const hideHistoryCallback = useCallback(() => {
|
|
34
|
+
setShowHistory(false);
|
|
35
|
+
}, []);
|
|
36
|
+
const showCheckoutInformationFormCallback = useCallback(() => {
|
|
37
|
+
setShowCheckoutInformationForm(true);
|
|
38
|
+
}, []);
|
|
39
|
+
const hideCheckoutInformationFormCallback = useCallback(() => {
|
|
40
|
+
setShowCheckoutInformationForm(false);
|
|
41
|
+
}, []);
|
|
42
|
+
const triggerPreviewRefresh = useCallback(() => {
|
|
43
|
+
setRefreshPreviewTrigger(prev => prev + 1);
|
|
44
|
+
}, []);
|
|
45
|
+
const hideCommentFormCallback = useCallback(() => {
|
|
46
|
+
setCommentFormState(prev => ({ ...prev, show: false }));
|
|
47
|
+
}, []);
|
|
48
|
+
const copyCheckoutPathToClipboardCallback = (dcmt, filename) => {
|
|
49
|
+
const defaultCheckInOutFolder = SDKUI_Globals.userSettings.defaultCheckInOutFolder ?? "Download";
|
|
50
|
+
const wGSDraftCheckoutItemCurrentItems = [...SDKUI_Globals.userSettings.dcmtCheckoutInfo];
|
|
51
|
+
const existingItem = wGSDraftCheckoutItemCurrentItems.find((item) => item.TID === dcmt.TID.toString() && item.DID === dcmt.DID.toString());
|
|
52
|
+
const folder = existingItem && existingItem.checkoutFolder && existingItem.checkoutFolder !== "" ? existingItem.checkoutFolder : defaultCheckInOutFolder;
|
|
53
|
+
const name = existingItem?.checkoutName ?? getCicoDownloadFileName({ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: filename }, true, false);
|
|
54
|
+
const textToCopy = folder ? `${folder}\\${name}` : name;
|
|
55
|
+
navigator.clipboard.writeText(textToCopy)
|
|
56
|
+
.then(() => {
|
|
57
|
+
ShowAlert({ message: SDKUI_Localizator.OperationSuccess, mode: 'success', duration: 5000, title: SDKUI_Localizator.CopyToClipboard });
|
|
58
|
+
})
|
|
59
|
+
.catch(err => {
|
|
60
|
+
ShowAlert({ message: err, mode: 'error', duration: 5000, title: SDKUI_Localizator.OperationResult });
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const handleCheckOutCallback = async (dcmt, checkout, filename, downloadDcmtsAsync, refreshMetadataAsync, refreshFocusedDataRowAsync) => {
|
|
64
|
+
if (!dcmt)
|
|
65
|
+
throw new Error("Document info is required");
|
|
66
|
+
const title = checkout ? 'Check out' : SDKUI_Localizator.CancelCheckOut;
|
|
67
|
+
const msg = checkout ? SDKUI_Localizator.ExecuteCheckOutQuestion : SDKUI_Localizator.ExecuteCancelCheckOutQuestion;
|
|
68
|
+
TMMessageBoxManager.show({
|
|
69
|
+
title: title,
|
|
70
|
+
message: msg,
|
|
71
|
+
buttons: [ButtonNames.YES, ButtonNames.NO],
|
|
72
|
+
onButtonClick: async (e) => {
|
|
73
|
+
if (e !== ButtonNames.YES)
|
|
74
|
+
return;
|
|
75
|
+
let result = [];
|
|
76
|
+
try {
|
|
77
|
+
setCicoWaitPanelTitle(title);
|
|
78
|
+
setShowCicoWaitPanel(true);
|
|
79
|
+
setShowCicoPrimaryProgress(true);
|
|
80
|
+
abortController = new AbortController();
|
|
81
|
+
const ue = SDK_Globals.tmSession?.NewUpdateEngineByID();
|
|
82
|
+
if (!ue)
|
|
83
|
+
throw new Error("Update Engine not available");
|
|
84
|
+
ue.TID = dcmt.TID;
|
|
85
|
+
ue.DID = dcmt.DID;
|
|
86
|
+
if (checkout) {
|
|
87
|
+
await ue.CheckOutAsync()
|
|
88
|
+
.then(async () => {
|
|
89
|
+
await cicoDownloadFilesCallback([{ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: filename }], true, downloadDcmtsAsync);
|
|
90
|
+
result.push({ rowIndex: 1, id1: dcmt.TID, id2: dcmt.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
91
|
+
await refreshMetadataAsync?.();
|
|
92
|
+
await refreshFocusedDataRowAsync?.(dcmt.TID, dcmt.DID, true);
|
|
93
|
+
})
|
|
94
|
+
.catch((error) => {
|
|
95
|
+
result.push({ rowIndex: 1, id1: dcmt.TID, id2: dcmt.DID, resultType: ResultTypes.ERROR, description: getExceptionMessage(error) });
|
|
96
|
+
throw error;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
await ue.UndoCheckOutAsync()
|
|
101
|
+
.then(async () => {
|
|
102
|
+
result.push({ rowIndex: 1, id1: dcmt.TID, id2: dcmt.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
103
|
+
// Remove the corresponding draft checkout item
|
|
104
|
+
updateCicoCheckoutStorageItem({ TID: dcmt.TID.toString(), DID: dcmt.DID.toString(), checkoutFolder: "", checkoutName: "" }, "dcmtInfo", "remove");
|
|
105
|
+
await refreshMetadataAsync?.();
|
|
106
|
+
await refreshFocusedDataRowAsync?.(dcmt.TID, dcmt.DID, true);
|
|
107
|
+
})
|
|
108
|
+
.catch((error) => {
|
|
109
|
+
result.push({ rowIndex: 0, id1: dcmt.TID, id2: dcmt.DID, resultType: ResultTypes.ERROR, description: getExceptionMessage(error) });
|
|
110
|
+
throw error;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
result.push({ rowIndex: 1, id1: dcmt.TID, id2: dcmt.DID, resultType: ResultTypes.ERROR, description: getExceptionMessage(error) });
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
setCicoPrimaryProgressText('');
|
|
119
|
+
setCicoPrimaryProgressMax(0);
|
|
120
|
+
setCicoPrimaryProgressValue(0);
|
|
121
|
+
setShowCicoWaitPanel(false);
|
|
122
|
+
TMResultManager.show(result, title, "ID", undefined);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
const triggerCommentOnFileAdd = (addedFiles) => {
|
|
128
|
+
if (addedFiles.length > 0) {
|
|
129
|
+
setCommentFormState({
|
|
130
|
+
show: true,
|
|
131
|
+
isRequired: true,
|
|
132
|
+
removeAndEditAttachment: false
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const handleCheckInCallback = async (dcmt, refreshMetadataAsync, refreshFocusedDataRowAsync) => {
|
|
137
|
+
if (!dcmt)
|
|
138
|
+
throw new Error("Document info is required");
|
|
139
|
+
// Create a new file input element
|
|
140
|
+
const input = document.createElement("input");
|
|
141
|
+
// Set the input type to "file" to allow file selection
|
|
142
|
+
input.type = "file";
|
|
143
|
+
// Set the accepted file types (e.g., images, PDFs, etc.)
|
|
144
|
+
input.accept = "*/*";
|
|
145
|
+
// Enable the input to accept one file at once
|
|
146
|
+
input.multiple = false;
|
|
147
|
+
// Add an event listener for when the file selection changes
|
|
148
|
+
input.addEventListener('change', async (event) => {
|
|
149
|
+
const fileInput = event.target;
|
|
150
|
+
if (!fileInput.files || fileInput.files.length === 0)
|
|
151
|
+
return;
|
|
152
|
+
const file = fileInput.files[0];
|
|
153
|
+
const validateFileName = validateCicoFileName({ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: dcmt.fileName ?? SDKUI_Localizator.SearchResult }, file.name);
|
|
154
|
+
TMMessageBoxManager.show({
|
|
155
|
+
resizable: true,
|
|
156
|
+
buttons: [ButtonNames.YES, ButtonNames.NO],
|
|
157
|
+
message: renderCicoCheckInContent({ type: 'dcmtInfo', dcmtInfo: dcmt, originalFileName: dcmt.fileName ?? SDKUI_Localizator.SearchResult }, file, validateFileName.isValid, validateFileName.validationResults),
|
|
158
|
+
title: "Check in",
|
|
159
|
+
onButtonClick: async (e) => {
|
|
160
|
+
if (e !== ButtonNames.YES)
|
|
161
|
+
return;
|
|
162
|
+
setCicoWaitPanelTitle('Check in');
|
|
163
|
+
setShowCicoWaitPanel(true);
|
|
164
|
+
setShowCicoPrimaryProgress(true);
|
|
165
|
+
abortController = new AbortController();
|
|
166
|
+
let result = [];
|
|
167
|
+
let i = 0;
|
|
168
|
+
if (dcmt.TID && dcmt.DID) {
|
|
169
|
+
try {
|
|
170
|
+
const ue = SDK_Globals.tmSession?.NewUpdateEngineByID();
|
|
171
|
+
if (ue) {
|
|
172
|
+
ue.TID = dcmt.TID;
|
|
173
|
+
ue.DID = dcmt.DID;
|
|
174
|
+
await ue.CheckInAsync(file, "", abortController.signal);
|
|
175
|
+
// Remove the corresponding draft checkout item
|
|
176
|
+
updateCicoCheckoutStorageItem({ TID: dcmt.TID.toString(), DID: dcmt.DID.toString(), checkoutFolder: "", checkoutName: "" }, "dcmtInfo", "remove");
|
|
177
|
+
result.push({ rowIndex: i, id1: dcmt.DID, id2: dcmt.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
178
|
+
await refreshMetadataAsync?.();
|
|
179
|
+
await refreshFocusedDataRowAsync?.(dcmt.TID, dcmt.DID, true);
|
|
180
|
+
const cacheKey = `${dcmt.TID}-${dcmt.DID}`;
|
|
181
|
+
if (dcmtsFileCachePreview.has(cacheKey))
|
|
182
|
+
removeDcmtsFileCache(cacheKey);
|
|
183
|
+
triggerPreviewRefresh();
|
|
184
|
+
triggerCommentOnFileAdd([dcmt.DID]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
result.push({ rowIndex: i, id1: i, id2: i, resultType: ResultTypes.ERROR, description: getExceptionMessage(err) });
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
setCicoPrimaryProgressText('');
|
|
192
|
+
setCicoPrimaryProgressMax(0);
|
|
193
|
+
setCicoPrimaryProgressValue(0);
|
|
194
|
+
setShowCicoWaitPanel(false);
|
|
195
|
+
TMResultManager.show(result, 'Check in', "ID", undefined, SDKUI_Localizator.CheckInSuccessMessage, 6000);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
input.click();
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
showHistory,
|
|
205
|
+
showHistoryCallback,
|
|
206
|
+
hideHistoryCallback,
|
|
207
|
+
showCheckoutInformationForm,
|
|
208
|
+
showCheckoutInformationFormCallback,
|
|
209
|
+
hideCheckoutInformationFormCallback,
|
|
210
|
+
commentFormState,
|
|
211
|
+
hideCommentFormCallback,
|
|
212
|
+
copyCheckoutPathToClipboardCallback,
|
|
213
|
+
handleCheckOutCallback,
|
|
214
|
+
handleCheckInCallback,
|
|
215
|
+
refreshPreviewTrigger,
|
|
216
|
+
showCicoWaitPanel,
|
|
217
|
+
cicoWaitPanelTitle,
|
|
218
|
+
showCicoPrimaryProgress,
|
|
219
|
+
cicoPrimaryProgressText,
|
|
220
|
+
cicoPrimaryProgressValue,
|
|
221
|
+
cicoPrimaryProgressMax,
|
|
222
|
+
};
|
|
223
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataListItemDescriptor, DataListViewModes } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
export declare const useDataListItem: () => {
|
|
4
|
+
loadDataListsAsync: (dataListIDs: Set<number>) => Promise<void>;
|
|
5
|
+
getDataListItem: (dataListID: number, value: string | number | Date) => DataListItemDescriptor | undefined;
|
|
6
|
+
clearCache: () => void;
|
|
7
|
+
hasDataList: (dataListID: number) => boolean;
|
|
8
|
+
renderDataListCell: (value: string | Date | number | undefined, dataListID: number, dataListViewMode: DataListViewModes) => React.ReactElement;
|
|
9
|
+
dataListsCache: React.MutableRefObject<Map<number, DataListItemDescriptor[]>>;
|
|
10
|
+
convertToDataListValue: (value: string | Date | number | undefined) => string;
|
|
11
|
+
convertToDataListDisplayValue: (value: string | Date | number | undefined) => string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useCallback } from 'react';
|
|
3
|
+
import { DataListCacheService, DataListViewModes } from '@topconsultnpm/sdk-ts';
|
|
4
|
+
import { IconWarning, SDKUI_Localizator, TMImageLibrary } from '../helper';
|
|
5
|
+
import { FormulaHelper, StyledDivHorizontal } from '../components';
|
|
6
|
+
import { TMColors } from '../utils/theme';
|
|
7
|
+
export const useDataListItem = () => {
|
|
8
|
+
const dataListsCacheRef = useRef(new Map());
|
|
9
|
+
/**
|
|
10
|
+
* Converte un valore in formato stringa per DataList
|
|
11
|
+
* @param value Valore da convertire
|
|
12
|
+
* @returns Stringa rappresentante il valore
|
|
13
|
+
*/
|
|
14
|
+
const convertToDataListValue = useCallback((value) => {
|
|
15
|
+
if (value instanceof Date) {
|
|
16
|
+
return value.toISOString();
|
|
17
|
+
}
|
|
18
|
+
else if (typeof value === 'number') {
|
|
19
|
+
return value.toString();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return value ?? '';
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
/**
|
|
26
|
+
* Converte un valore in formato stringa per visualizzazione in DataList
|
|
27
|
+
* @param value Valore da convertire
|
|
28
|
+
* @returns Stringa formattata per visualizzazione
|
|
29
|
+
*/
|
|
30
|
+
const convertToDataListDisplayValue = useCallback((value) => {
|
|
31
|
+
if (value instanceof Date) {
|
|
32
|
+
return value.toLocaleDateString();
|
|
33
|
+
}
|
|
34
|
+
else if (typeof value === 'number') {
|
|
35
|
+
return value.toString();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return value ?? '';
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
/**
|
|
42
|
+
* Carica tutte le DataList necessarie in parallelo e popola la cache
|
|
43
|
+
* @param dataListIDs Set di ID delle DataList da caricare
|
|
44
|
+
* @returns Promise che si risolve quando tutte le DataList sono state caricate
|
|
45
|
+
*/
|
|
46
|
+
const loadDataListsAsync = useCallback(async (dataListIDs) => {
|
|
47
|
+
if (dataListIDs.size === 0)
|
|
48
|
+
return;
|
|
49
|
+
try {
|
|
50
|
+
const results = await Promise.all(Array.from(dataListIDs).map(id => DataListCacheService.GetAsync(id).then(dl => ({
|
|
51
|
+
id,
|
|
52
|
+
items: dl?.items ?? []
|
|
53
|
+
}))));
|
|
54
|
+
const newCache = new Map();
|
|
55
|
+
results.forEach(({ id, items }) => newCache.set(id, items));
|
|
56
|
+
dataListsCacheRef.current = newCache;
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error('Error loading DataLists:', err);
|
|
60
|
+
dataListsCacheRef.current = new Map();
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
/**
|
|
64
|
+
* Recupera un item dalla cache della DataList
|
|
65
|
+
* @param dataListID ID della DataList
|
|
66
|
+
* @param value Valore dell'item da cercare
|
|
67
|
+
* @returns DataListItemDescriptor se trovato, undefined altrimenti
|
|
68
|
+
*/
|
|
69
|
+
const getDataListItem = useCallback((dataListID, value) => {
|
|
70
|
+
const stringValue = convertToDataListValue(value);
|
|
71
|
+
const dataListItems = dataListsCacheRef.current.get(dataListID);
|
|
72
|
+
return dataListItems?.find(o => o.value == stringValue);
|
|
73
|
+
}, []);
|
|
74
|
+
/**
|
|
75
|
+
* Svuota completamente la cache
|
|
76
|
+
*/
|
|
77
|
+
const clearCache = useCallback(() => {
|
|
78
|
+
dataListsCacheRef.current = new Map();
|
|
79
|
+
}, []);
|
|
80
|
+
/**
|
|
81
|
+
* Verifica se una DataList è presente nella cache
|
|
82
|
+
* @param dataListID ID della DataList
|
|
83
|
+
* @returns true se la DataList è in cache, false altrimenti
|
|
84
|
+
*/
|
|
85
|
+
const hasDataList = useCallback((dataListID) => {
|
|
86
|
+
return dataListsCacheRef.current.has(dataListID);
|
|
87
|
+
}, []);
|
|
88
|
+
/**
|
|
89
|
+
* Renderizza una cella DataList con icona e testo formattato
|
|
90
|
+
* @param value Valore della cella
|
|
91
|
+
* @param dataListID ID della DataList
|
|
92
|
+
* @param dataListViewMode Modalità di visualizzazione della DataList
|
|
93
|
+
* @returns Elemento React per la cella DataList
|
|
94
|
+
*/
|
|
95
|
+
const renderDataListCell = useCallback((value, dataListID, dataListViewMode) => {
|
|
96
|
+
const stringValue = convertToDataListValue(value);
|
|
97
|
+
const showIcon = dataListViewMode !== DataListViewModes.Description;
|
|
98
|
+
const showText = dataListViewMode !== DataListViewModes.Image;
|
|
99
|
+
const dataListItem = getDataListItem(dataListID, stringValue);
|
|
100
|
+
const getIcon = () => {
|
|
101
|
+
if (!showIcon)
|
|
102
|
+
return null;
|
|
103
|
+
if (value === undefined || value === null)
|
|
104
|
+
return null;
|
|
105
|
+
if (FormulaHelper.isFormula(stringValue))
|
|
106
|
+
return null;
|
|
107
|
+
return dataListItem
|
|
108
|
+
? _jsx(TMImageLibrary, { imageID: dataListItem.imageID })
|
|
109
|
+
: _jsx(IconWarning, { color: TMColors.warning });
|
|
110
|
+
};
|
|
111
|
+
return (_jsxs(StyledDivHorizontal, { style: { width: '100%' }, title: dataListItem ? dataListItem.value : SDKUI_Localizator.ValueNotPresent, children: [getIcon(), showText && (_jsx("p", { style: {
|
|
112
|
+
textAlign: 'left',
|
|
113
|
+
marginLeft: showIcon ? '5px' : '',
|
|
114
|
+
opacity: dataListItem ? 1 : 0.5,
|
|
115
|
+
whiteSpace: 'nowrap',
|
|
116
|
+
overflow: 'hidden',
|
|
117
|
+
textOverflow: 'ellipsis',
|
|
118
|
+
flexGrow: 1,
|
|
119
|
+
minWidth: 0
|
|
120
|
+
}, children: dataListItem ? dataListItem.name : convertToDataListDisplayValue(value) }))] }));
|
|
121
|
+
}, [getDataListItem]);
|
|
122
|
+
return {
|
|
123
|
+
loadDataListsAsync,
|
|
124
|
+
getDataListItem,
|
|
125
|
+
clearCache,
|
|
126
|
+
hasDataList,
|
|
127
|
+
renderDataListCell,
|
|
128
|
+
dataListsCache: dataListsCacheRef,
|
|
129
|
+
convertToDataListValue,
|
|
130
|
+
convertToDataListDisplayValue
|
|
131
|
+
};
|
|
132
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UserDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
export declare const useDataUserIdItem: () => {
|
|
4
|
+
loadUsersAsync: (userIDs: Set<number>) => Promise<void>;
|
|
5
|
+
getUserItem: (userId: number) => UserDescriptor | undefined;
|
|
6
|
+
clearCache: () => void;
|
|
7
|
+
hasUser: (userId: number) => boolean;
|
|
8
|
+
usersCache: React.MutableRefObject<Map<number, UserDescriptor>>;
|
|
9
|
+
renderUserIdViewer: (userId: number | undefined, showIcon?: boolean, showTitile?: boolean) => React.ReactElement;
|
|
10
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useCallback } from 'react';
|
|
3
|
+
import { UserListCacheService } from '@topconsultnpm/sdk-ts';
|
|
4
|
+
import { IconWarning, SDKUI_Localizator } from '../helper';
|
|
5
|
+
import { TMColors } from '../utils/theme';
|
|
6
|
+
import { TMUserIcon } from '../components';
|
|
7
|
+
export const useDataUserIdItem = () => {
|
|
8
|
+
const usersCacheRef = useRef(new Map());
|
|
9
|
+
/**
|
|
10
|
+
* Carica tutti gli utenti necessari in parallelo e popola la cache
|
|
11
|
+
* @param userIDs Set di ID degli utenti da caricare
|
|
12
|
+
* @returns Promise che si risolve quando tutti gli utenti sono stati caricati
|
|
13
|
+
*/
|
|
14
|
+
const loadUsersAsync = useCallback(async (userIDs) => {
|
|
15
|
+
if (userIDs.size === 0)
|
|
16
|
+
return;
|
|
17
|
+
try {
|
|
18
|
+
const results = await Promise.all(Array.from(userIDs).map(id => UserListCacheService.GetAsync(id).then(user => ({ id, user }))
|
|
19
|
+
.catch(() => ({ id, user: undefined }))));
|
|
20
|
+
const newCache = new Map();
|
|
21
|
+
results.forEach(({ id, user }) => {
|
|
22
|
+
if (user)
|
|
23
|
+
newCache.set(id, user);
|
|
24
|
+
});
|
|
25
|
+
usersCacheRef.current = newCache;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.error('Error loading Users:', err);
|
|
29
|
+
usersCacheRef.current = new Map();
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
/**
|
|
33
|
+
* Recupera un utente dalla cache
|
|
34
|
+
* @param userId ID dell'utente
|
|
35
|
+
* @returns UserDescriptor se trovato, undefined altrimenti
|
|
36
|
+
*/
|
|
37
|
+
const getUserItem = useCallback((userId) => {
|
|
38
|
+
return usersCacheRef.current.get(userId);
|
|
39
|
+
}, []);
|
|
40
|
+
/**
|
|
41
|
+
* Svuota completamente la cache
|
|
42
|
+
*/
|
|
43
|
+
const clearCache = useCallback(() => {
|
|
44
|
+
usersCacheRef.current = new Map();
|
|
45
|
+
}, []);
|
|
46
|
+
/**
|
|
47
|
+
* Verifica se un utente è presente nella cache
|
|
48
|
+
* @param userId ID dell'utente
|
|
49
|
+
* @returns true se l'utente è in cache, false altrimenti
|
|
50
|
+
*/
|
|
51
|
+
const hasUser = useCallback((userId) => {
|
|
52
|
+
return usersCacheRef.current.has(userId);
|
|
53
|
+
}, []);
|
|
54
|
+
/**
|
|
55
|
+
* Helper per ottenere il nome completo dell'utente
|
|
56
|
+
*/
|
|
57
|
+
const getCompleteUserName = useCallback((domain, name) => {
|
|
58
|
+
if (!name)
|
|
59
|
+
return undefined;
|
|
60
|
+
if (!domain)
|
|
61
|
+
return name;
|
|
62
|
+
return domain + "\\" + name;
|
|
63
|
+
}, []);
|
|
64
|
+
/**
|
|
65
|
+
* Renderizza un componente UserIdViewer
|
|
66
|
+
* @param userId ID dell'utente
|
|
67
|
+
* @param showIcon Se mostrare l'icona
|
|
68
|
+
* @param noneSelectionText Testo da mostrare quando non c'è selezione
|
|
69
|
+
* @param TMUserIcon Componente per l'icona utente
|
|
70
|
+
* @returns Elemento React per visualizzare l'utente
|
|
71
|
+
*/
|
|
72
|
+
const renderUserIdViewer = useCallback((userId, showIcon = false, showTitile = true) => {
|
|
73
|
+
const ud = userId && userId > 0 ? getUserItem(userId) : undefined;
|
|
74
|
+
const getIcon = () => {
|
|
75
|
+
if (!showIcon)
|
|
76
|
+
return null;
|
|
77
|
+
if (!userId)
|
|
78
|
+
return null;
|
|
79
|
+
return ud ? _jsx(TMUserIcon, { ud: ud }) : _jsx("div", { title: showTitile ? SDKUI_Localizator.ValueNotPresent : undefined, children: _jsx(IconWarning, { color: TMColors.warning }) });
|
|
80
|
+
};
|
|
81
|
+
const getDescription = () => {
|
|
82
|
+
if (!userId)
|
|
83
|
+
return undefined;
|
|
84
|
+
return ud ? getCompleteUserName(ud.domain, ud.name) : userId.toString() ?? SDKUI_Localizator.NoneSelection;
|
|
85
|
+
};
|
|
86
|
+
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '4px' }, children: [getIcon(), _jsx("span", { children: getDescription() })] }));
|
|
87
|
+
}, [getUserItem, getCompleteUserName]);
|
|
88
|
+
return {
|
|
89
|
+
loadUsersAsync,
|
|
90
|
+
getUserItem,
|
|
91
|
+
clearCache,
|
|
92
|
+
hasUser,
|
|
93
|
+
usersCache: usersCacheRef,
|
|
94
|
+
renderUserIdViewer
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { QueryDescriptor } from '@topconsultnpm/sdk-ts';
|
|
2
|
+
export interface MetadataHelper {
|
|
3
|
+
Mid: number;
|
|
4
|
+
MetadataName: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UseMetadataExpressionProps {
|
|
7
|
+
qd?: QueryDescriptor;
|
|
8
|
+
tid?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface UseMetadataExpressionResult {
|
|
11
|
+
metadatas_Info_Source: MetadataHelper[];
|
|
12
|
+
Expression_IDs2Names: (expression: string | undefined) => string | undefined;
|
|
13
|
+
Expression_Names2IDs: (expression: string | undefined) => string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Custom hook per gestire le espressioni con metadati.
|
|
17
|
+
* Fornisce funzioni per convertire tra IDs e nomi dei metadati e gestisce il caricamento dei metadati.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useMetadataExpression: ({ qd, tid }: UseMetadataExpressionProps) => UseMetadataExpressionResult;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { DcmtTypeListCacheService } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
import { TMExceptionBoxManager } from '../components/base/TMPopUp';
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook per gestire le espressioni con metadati.
|
|
6
|
+
* Fornisce funzioni per convertire tra IDs e nomi dei metadati e gestisce il caricamento dei metadati.
|
|
7
|
+
*/
|
|
8
|
+
export const useMetadataExpression = ({ qd, tid }) => {
|
|
9
|
+
const [metadatas_Info_Source, setMetadatas_Info_Source] = useState([]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
MetadataInfos_Source_Get_Async();
|
|
12
|
+
}, [qd]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
MetadataInfos_Source_GetByTID_Async();
|
|
15
|
+
}, [tid]);
|
|
16
|
+
async function MetadataInfos_Source_Get_Async() {
|
|
17
|
+
if (!qd?.select)
|
|
18
|
+
return;
|
|
19
|
+
let mhs_source = [];
|
|
20
|
+
try {
|
|
21
|
+
let dtd_source;
|
|
22
|
+
let md_source;
|
|
23
|
+
let tid_source = -1;
|
|
24
|
+
let si;
|
|
25
|
+
let sis = qd.select.slice();
|
|
26
|
+
sis = sis.slice().sort((a, b) => a.tid - b.tid);
|
|
27
|
+
for (si of sis) {
|
|
28
|
+
if (si.tid == undefined || si.mid == undefined)
|
|
29
|
+
continue;
|
|
30
|
+
if (tid_source != si.tid) {
|
|
31
|
+
dtd_source = await DcmtTypeListCacheService.GetAsync(si.tid, true);
|
|
32
|
+
if (dtd_source == undefined)
|
|
33
|
+
continue;
|
|
34
|
+
tid_source = si.tid;
|
|
35
|
+
}
|
|
36
|
+
if (dtd_source?.metadata == undefined)
|
|
37
|
+
continue;
|
|
38
|
+
md_source = dtd_source.metadata.find(o => o.id == si.mid);
|
|
39
|
+
if (md_source?.name == undefined)
|
|
40
|
+
continue;
|
|
41
|
+
if (tid_source == undefined)
|
|
42
|
+
continue;
|
|
43
|
+
mhs_source.push({ Mid: si.mid, MetadataName: md_source.name });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
TMExceptionBoxManager.show({ exception: e, title: 'MetadataInfos_Source_Get_Async' });
|
|
48
|
+
}
|
|
49
|
+
setMetadatas_Info_Source(mhs_source);
|
|
50
|
+
}
|
|
51
|
+
async function MetadataInfos_Source_GetByTID_Async() {
|
|
52
|
+
if (!tid)
|
|
53
|
+
return;
|
|
54
|
+
let mhs_source = [];
|
|
55
|
+
try {
|
|
56
|
+
let dtd_source = await DcmtTypeListCacheService.GetAsync(tid, true);
|
|
57
|
+
if (dtd_source == undefined)
|
|
58
|
+
return;
|
|
59
|
+
if (dtd_source?.metadata == undefined)
|
|
60
|
+
return;
|
|
61
|
+
for (let md_source of dtd_source?.metadata) {
|
|
62
|
+
if (md_source?.name == undefined)
|
|
63
|
+
continue;
|
|
64
|
+
if (md_source?.id == undefined)
|
|
65
|
+
continue;
|
|
66
|
+
mhs_source.push({ Mid: md_source.id, MetadataName: md_source.name });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
TMExceptionBoxManager.show({ exception: e, title: 'MetadataInfos_Source_GetByTID_Async' });
|
|
71
|
+
}
|
|
72
|
+
setMetadatas_Info_Source(mhs_source);
|
|
73
|
+
}
|
|
74
|
+
function Expression_IDs2Names(expression) {
|
|
75
|
+
if (expression == undefined)
|
|
76
|
+
return expression;
|
|
77
|
+
let temp = expression.slice();
|
|
78
|
+
for (const mh of metadatas_Info_Source) {
|
|
79
|
+
temp = temp.replaceAll(`{@${mh.Mid}}`, `{@${mh.MetadataName}}`);
|
|
80
|
+
}
|
|
81
|
+
temp = temp.replaceAll("{@1}", "{@DID}");
|
|
82
|
+
return temp;
|
|
83
|
+
}
|
|
84
|
+
function Expression_Names2IDs(expression) {
|
|
85
|
+
if (expression == undefined)
|
|
86
|
+
return expression;
|
|
87
|
+
let temp = expression.slice();
|
|
88
|
+
for (const mh of metadatas_Info_Source) {
|
|
89
|
+
temp = temp.replaceAll(`{@${mh.MetadataName}}`, `{@${mh.Mid}}`);
|
|
90
|
+
}
|
|
91
|
+
temp = temp.replaceAll("{@DID}", "{@1}");
|
|
92
|
+
return temp;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
metadatas_Info_Source,
|
|
96
|
+
Expression_IDs2Names,
|
|
97
|
+
Expression_Names2IDs
|
|
98
|
+
};
|
|
99
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SettingsFeedback {
|
|
2
|
+
showSavedBadge: boolean;
|
|
3
|
+
lastChanged: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
isWarning: boolean;
|
|
8
|
+
triggerUIUpdate: (label: string, value: any, warning?: boolean) => void;
|
|
9
|
+
closeBadge: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const useSettingsFeedback: () => SettingsFeedback;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState, useRef } from 'react';
|
|
2
|
+
export const useSettingsFeedback = () => {
|
|
3
|
+
const [, setForceUpdate] = useState(0);
|
|
4
|
+
const [showSavedBadge, setShowSavedBadge] = useState(false);
|
|
5
|
+
const [lastChanged, setLastChanged] = useState({
|
|
6
|
+
label: '',
|
|
7
|
+
value: ''
|
|
8
|
+
});
|
|
9
|
+
const [isWarning, setIsWarning] = useState(false);
|
|
10
|
+
const timeoutRef = useRef(null);
|
|
11
|
+
const triggerUIUpdate = (label, value, warning = false) => {
|
|
12
|
+
setForceUpdate((prev) => prev + 1);
|
|
13
|
+
setShowSavedBadge(true);
|
|
14
|
+
setLastChanged({ label, value: String(value) });
|
|
15
|
+
setIsWarning(warning);
|
|
16
|
+
if (timeoutRef.current) {
|
|
17
|
+
clearTimeout(timeoutRef.current);
|
|
18
|
+
}
|
|
19
|
+
timeoutRef.current = setTimeout(() => {
|
|
20
|
+
setShowSavedBadge(false);
|
|
21
|
+
timeoutRef.current = null;
|
|
22
|
+
}, 4000);
|
|
23
|
+
};
|
|
24
|
+
const closeBadge = () => {
|
|
25
|
+
setShowSavedBadge(false);
|
|
26
|
+
if (timeoutRef.current) {
|
|
27
|
+
clearTimeout(timeoutRef.current);
|
|
28
|
+
timeoutRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
showSavedBadge,
|
|
33
|
+
lastChanged,
|
|
34
|
+
isWarning,
|
|
35
|
+
triggerUIUpdate,
|
|
36
|
+
closeBadge
|
|
37
|
+
};
|
|
38
|
+
};
|