@topconsultnpm/sdkui-react 6.19.0-test2 → 6.20.0-dev1.10
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/base/TMAccordion.js +2 -2
- package/lib/components/choosers/TMDynDataListItemChooser.js +5 -4
- package/lib/components/editors/TMHtmlEditor.js +1 -1
- package/lib/components/editors/TMMetadataValues.js +34 -12
- package/lib/components/features/assistant/ToppyDraggableHelpCenter.js +74 -63
- package/lib/components/features/documents/TMDcmtBlog.d.ts +1 -7
- package/lib/components/features/documents/TMDcmtBlog.js +29 -2
- package/lib/components/features/documents/TMDcmtForm.d.ts +1 -0
- package/lib/components/features/documents/TMDcmtForm.js +24 -34
- package/lib/components/features/documents/TMDcmtPreview.js +93 -64
- package/lib/components/features/search/TMSavedQuerySelector.js +1 -1
- package/lib/components/features/search/TMSearchQueryPanel.js +1 -1
- package/lib/components/features/search/TMSearchResult.js +249 -58
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +8 -0
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.js +129 -0
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +2 -2
- package/lib/components/features/search/TMSearchResultsMenuItems.js +41 -63
- package/lib/components/features/search/TMTreeSelector.js +1 -1
- package/lib/components/features/search/TMViewHistoryDcmt.d.ts +18 -0
- package/lib/components/features/search/TMViewHistoryDcmt.js +285 -0
- package/lib/components/grids/TMRecentsManager.js +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +3 -7
- package/lib/helper/SDKUI_Globals.js +1 -0
- package/lib/helper/SDKUI_Localizator.d.ts +16 -0
- package/lib/helper/SDKUI_Localizator.js +209 -6
- package/lib/helper/TMIcons.d.ts +3 -1
- package/lib/helper/TMIcons.js +9 -1
- package/lib/helper/TMUtils.d.ts +3 -1
- package/lib/helper/TMUtils.js +51 -0
- package/lib/helper/checkinCheckoutManager.d.ts +55 -0
- package/lib/helper/checkinCheckoutManager.js +266 -0
- package/lib/helper/helpers.d.ts +7 -0
- package/lib/helper/helpers.js +37 -5
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/helper/queryHelper.js +13 -1
- package/lib/services/platform_services.d.ts +1 -1
- package/package.json +52 -52
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import { SDK_Globals, DataColumnTypes, MetadataDataDomains, DataListViewModes, MetadataFormats, LayoutModes, TemplateTIDs, DcmtTypeListCacheService, AccessLevels, SystemMIDsAsNumber, RetrieveFileOptions, DcmtOpers, GeneralRetrieveFormats, AccessLevelsEx, ResultTypes, LayoutCacheService } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
import { SDK_Globals, DataColumnTypes, MetadataDataDomains, DataListViewModes, MetadataFormats, LayoutModes, TemplateTIDs, DcmtTypeListCacheService, AccessLevels, SystemMIDsAsNumber, RetrieveFileOptions, DcmtOpers, GeneralRetrieveFormats, AccessLevelsEx, ResultTypes, LayoutCacheService, UserListCacheService } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { getAllFieldSelectedDcmtsOrFocused, getCommandsMenuItems, getSelectedDcmtsOrFocused } from './TMSearchResultsMenuItems';
|
|
6
|
-
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, IconDetailDcmts, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, IconDownload, deepCompare,
|
|
6
|
+
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, IconDetailDcmts, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, IconDownload, deepCompare, generateUniqueColumnKeys, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, TMCommandsContextMenu, getExceptionMessage, IconCheck, svgToString, TMImageLibrary, SDKUI_Globals, convertSearchResultDescriptorToFileItems, dcmtsFileCachePreview, removeDcmtsFileCache } from '../../../helper';
|
|
7
7
|
import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
|
|
8
8
|
import { useInputAttachmentsDialog, useInputCvtFormatDialog } from '../../../hooks/useInputDialog';
|
|
9
9
|
import { useRelatedDocuments } from '../../../hooks/useRelatedDocuments';
|
|
@@ -43,6 +43,11 @@ import { TMResultManager } from '../../forms/TMResultDialog';
|
|
|
43
43
|
import TMCustomButton from '../../base/TMCustomButton';
|
|
44
44
|
import ToppyDraggableHelpCenter from '../assistant/ToppyDraggableHelpCenter';
|
|
45
45
|
import TMSignSettingsForm from './TMSignSettingsForm';
|
|
46
|
+
import { getDcmtCicoStatus, cicoDownloadFilesCallback, getCicoDownloadFileName, renderCicoCheckInContent, validateCicoFileName, updateCicoCheckoutStorageItem } from '../../../helper/checkinCheckoutManager';
|
|
47
|
+
import TMSearchResultCheckoutInfoForm from './TMSearchResultCheckoutInfoForm';
|
|
48
|
+
import TMViewHistoryDcmt from './TMViewHistoryDcmt';
|
|
49
|
+
import TMBlogCommentForm from '../blog/TMBlogCommentForm';
|
|
50
|
+
let abortControllerLocal = new AbortController();
|
|
46
51
|
//#region Helper Methods
|
|
47
52
|
export const getSearchResultCountersSingleCategory = (searchResults) => {
|
|
48
53
|
// let totDcmtTypes = searchResults.length;
|
|
@@ -106,27 +111,70 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
106
111
|
const disableSignApproveDisable = selectedDocs.length !== 1 || (selectedDocs.length === 1 && selectedDocs[0].FILEEXT === null);
|
|
107
112
|
const dcmtsReturned = (searchResults?.length > 1 ? selectedSearchResult?.dcmtsReturned : searchResults[0]?.dcmtsReturned ?? 0);
|
|
108
113
|
const dcmtsFound = (searchResults?.length > 1 ? selectedSearchResult?.dcmtsFound : searchResults[0]?.dcmtsFound ?? 0);
|
|
109
|
-
//
|
|
110
|
-
const [
|
|
111
|
-
const [
|
|
112
|
-
|
|
114
|
+
// State to manage show history selected file
|
|
115
|
+
const [showHistory, setShowHistory] = useState(false);
|
|
116
|
+
const [allUsers, setAllUsers] = useState([]);
|
|
117
|
+
// State to manage show history selected file
|
|
118
|
+
const [showCheckoutInformationForm, setShowCheckoutInformationForm] = useState(false);
|
|
119
|
+
// State variable to control the visibility of the wait panel
|
|
120
|
+
const [showLocalWaitPanel, setShowLocalWaitPanel] = useState(false);
|
|
121
|
+
// State variable to store the title of the wait panel
|
|
122
|
+
const [localWaitPanelTitle, setLocalWaitPanelTitle] = useState('');
|
|
123
|
+
// State variable to control the visibility of the primary section of the wait panel
|
|
124
|
+
const [localShowPrimary, setLocalShowPrimary] = useState(false);
|
|
125
|
+
// State variable to store the primary text of the wait panel
|
|
126
|
+
const [localWaitPanelTextPrimary, setLocalWaitPanelTextPrimary] = useState('');
|
|
127
|
+
// State variable to track the current value of the primary progress indicator in the wait panel
|
|
128
|
+
const [localWaitPanelValuePrimary, setLocalWaitPanelValuePrimary] = useState(0);
|
|
129
|
+
// State variable to define the maximum value for the primary progress indicator in the wait panel
|
|
130
|
+
const [localWaitPanelMaxValuePrimary, setLocalWaitPanelMaxValuePrimary] = useState(0);
|
|
131
|
+
/* State to manage show attachment badge on comment form */
|
|
132
|
+
const [removeAndEditAttachmentCommentForm, setRemoveAndEditAttachmentCommentForm] = useState(true);
|
|
133
|
+
// State to manage show comment form selected file
|
|
134
|
+
const [showCommentForm, setShowCommentForm] = useState(false);
|
|
135
|
+
// State to manage show comment form close button
|
|
136
|
+
const [isCommentRequired, setIsCommentRequired] = useState(false);
|
|
137
|
+
// Stato per triggerare il refresh del blog dall'esterno
|
|
138
|
+
const [refreshBlogTrigger, setRefreshBlogTrigger] = useState(0);
|
|
139
|
+
// Stato per triggerare il refresh della preview dall'esterno
|
|
140
|
+
const [refreshPreviewTrigger, setRefreshPreviewTrigger] = useState(0);
|
|
141
|
+
const triggerBlogRefresh = useCallback(async () => {
|
|
142
|
+
setRefreshBlogTrigger(prev => prev + 1);
|
|
143
|
+
}, []);
|
|
144
|
+
const triggerPreviewRefresh = useCallback(() => {
|
|
145
|
+
setRefreshPreviewTrigger(prev => prev + 1);
|
|
146
|
+
}, []);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
const fetchAllUsers = async () => {
|
|
149
|
+
const users = await UserListCacheService.GetAllAsync();
|
|
150
|
+
setAllUsers(users ?? []);
|
|
151
|
+
};
|
|
152
|
+
fetchAllUsers();
|
|
153
|
+
}, []);
|
|
113
154
|
useEffect(() => { setID(genUniqueId()); }, []);
|
|
114
155
|
useEffect(() => {
|
|
115
156
|
setSelectedItems([]);
|
|
116
|
-
setFocusedItem(undefined);
|
|
117
157
|
setIsOpenBatchUpdate(false);
|
|
118
158
|
setCurrentSearchResults(searchResults);
|
|
119
|
-
if (searchResults.length <= 0)
|
|
159
|
+
if (searchResults.length <= 0) {
|
|
160
|
+
setSelectedSearchResult(undefined);
|
|
120
161
|
return;
|
|
162
|
+
}
|
|
121
163
|
if (searchResults.length === 1) {
|
|
122
164
|
setSelectedSearchResult(searchResults[0]);
|
|
123
165
|
return;
|
|
124
166
|
}
|
|
167
|
+
// Seleziona sempre il primo risultato ordinato, sia su mobile che desktop
|
|
125
168
|
setSelectedSearchResult(orderByName(searchResults)[0]);
|
|
126
169
|
}, [searchResults]);
|
|
127
170
|
useEffect(() => {
|
|
128
|
-
setFocusedItem(undefined);
|
|
129
171
|
setSelectedItems([]);
|
|
172
|
+
// Se non c'è un selectedSearchResult, resetta tutto
|
|
173
|
+
if (!selectedSearchResult) {
|
|
174
|
+
setFocusedItem(undefined);
|
|
175
|
+
setFromDTD(undefined);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
130
178
|
DcmtTypeListCacheService.GetWithNotGrantedAsync(selectedSearchResult?.fromTID, Number(selectedSearchResult?.dtdResult?.rows?.[0]?.[1])).then((dtd) => {
|
|
131
179
|
setFromDTD(dtd);
|
|
132
180
|
});
|
|
@@ -167,6 +215,16 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
167
215
|
fetchLayout();
|
|
168
216
|
}, [currentMetadataValues]);
|
|
169
217
|
const openFormHandler = (layoutMode) => {
|
|
218
|
+
// Verifica che ci sia un documento selezionato con TID e DID validi
|
|
219
|
+
if (!focusedItem || focusedItem.TID === undefined || focusedItem.DID === undefined) {
|
|
220
|
+
ShowAlert({
|
|
221
|
+
message: SDKUI_Localizator.InvalidDcmt,
|
|
222
|
+
mode: "warning",
|
|
223
|
+
title: layoutMode === LayoutModes.Ark ? SDKUI_Localizator.Archive : SDKUI_Localizator.OpenTheDocument,
|
|
224
|
+
duration: 3000
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
170
228
|
setIsOpenDcmtForm(true);
|
|
171
229
|
setDcmtFormLayoutMode(layoutMode);
|
|
172
230
|
};
|
|
@@ -205,7 +263,6 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
205
263
|
const se = SDK_Globals.tmSession?.NewSearchEngine();
|
|
206
264
|
const sharedDcmts = await se?.GetSharedDcmtsAsync(getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0].TID, getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0].DID);
|
|
207
265
|
if (sharedDcmts && sharedDcmts.length > 0) {
|
|
208
|
-
console.log(sharedDcmts);
|
|
209
266
|
setSharedDcmtSearchResults(sharedDcmts);
|
|
210
267
|
}
|
|
211
268
|
else {
|
|
@@ -260,6 +317,34 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
260
317
|
const closeSignSettingsForm = useCallback(() => {
|
|
261
318
|
setShowSignSettingsForm(false);
|
|
262
319
|
}, []);
|
|
320
|
+
const viewHistoryCallback = useCallback(() => {
|
|
321
|
+
setShowHistory(true);
|
|
322
|
+
}, []);
|
|
323
|
+
const showCheckoutInformationFormCallback = useCallback(() => {
|
|
324
|
+
setShowCheckoutInformationForm(true);
|
|
325
|
+
}, []);
|
|
326
|
+
const showCommentFormCallback = useCallback(() => {
|
|
327
|
+
setShowCommentForm(true);
|
|
328
|
+
}, []);
|
|
329
|
+
const infoCheckCopyToClipboard = () => {
|
|
330
|
+
const selectedDocs = getSelectedDcmtsOrFocused(selectedItems, focusedItem);
|
|
331
|
+
const firstDoc = selectedDocs?.[0];
|
|
332
|
+
if (!firstDoc)
|
|
333
|
+
return;
|
|
334
|
+
const defaultCheckInOutFolder = SDKUI_Globals.userSettings.defaultCheckInOutFolder ?? "Download";
|
|
335
|
+
const wGSDraftCheckoutItemCurrentItems = [...SDKUI_Globals.userSettings.dcmtCheckoutInfo];
|
|
336
|
+
const existingItem = wGSDraftCheckoutItemCurrentItems.find((item) => item.TID === firstDoc.TID.toString() && item.DID === firstDoc.DID.toString());
|
|
337
|
+
const folder = existingItem && existingItem.checkoutFolder && existingItem.checkoutFolder !== "" ? existingItem.checkoutFolder : defaultCheckInOutFolder;
|
|
338
|
+
const name = existingItem?.checkoutName ?? getCicoDownloadFileName({ type: 'dcmtInfo', dcmtInfo: firstDoc, originalFileName: fromDTD?.name ?? SDKUI_Localizator.SearchResult }, true, false);
|
|
339
|
+
const textToCopy = folder ? `${folder}\\${name}` : name;
|
|
340
|
+
navigator.clipboard.writeText(textToCopy)
|
|
341
|
+
.then(() => {
|
|
342
|
+
ShowAlert({ message: SDKUI_Localizator.OperationSuccess, mode: 'success', duration: 5000, title: SDKUI_Localizator.CopyToClipboard });
|
|
343
|
+
})
|
|
344
|
+
.catch(err => {
|
|
345
|
+
ShowAlert({ message: err, mode: 'error', duration: 5000, title: SDKUI_Localizator.OperationResult });
|
|
346
|
+
});
|
|
347
|
+
};
|
|
263
348
|
const getTitleHeader = () => {
|
|
264
349
|
let counters = (showSelector && disableAccordionIfSingleCategory && searchResults.length > 1) ? getSearchResultCountersSingleCategory(searchResults) : "";
|
|
265
350
|
if (title)
|
|
@@ -310,6 +395,9 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
310
395
|
setIsOpenDcmtForm(false);
|
|
311
396
|
}
|
|
312
397
|
else {
|
|
398
|
+
if (isMobile && currentSearchResults.length > 1) {
|
|
399
|
+
setSelectedSearchResult(undefined);
|
|
400
|
+
}
|
|
313
401
|
setSplitterSize(['100%', '0']);
|
|
314
402
|
onClose?.();
|
|
315
403
|
}
|
|
@@ -332,10 +420,9 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
332
420
|
return;
|
|
333
421
|
if (e.target === 'content') {
|
|
334
422
|
e.items = e.items || [];
|
|
335
|
-
const menuItems = getCommandsMenuItems(isMobile, fromDTD, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, refreshSelectionDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, openConfirmAttachmentsDialog, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, currentTIDHasMasterRelations, currentTIDHasDetailRelations, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, hasManyToManyRelation);
|
|
423
|
+
const menuItems = getCommandsMenuItems(isMobile, fromDTD, allUsers, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, refreshSelectionDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, openConfirmAttachmentsDialog, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, handleCheckInOperationCallback, showCheckoutInformationFormCallback, viewHistoryCallback, infoCheckCopyToClipboard, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, currentTIDHasMasterRelations, currentTIDHasDetailRelations, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, hasManyToManyRelation);
|
|
336
424
|
e.items.push(...menuItems);
|
|
337
|
-
|
|
338
|
-
//e.items.push(customButtonMenuItems());
|
|
425
|
+
e.items.push(customButtonMenuItems());
|
|
339
426
|
}
|
|
340
427
|
};
|
|
341
428
|
const handleCheckOutOperationCallback = async (checkout) => {
|
|
@@ -350,10 +437,15 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
350
437
|
message: msg,
|
|
351
438
|
buttons: [ButtonNames.YES, ButtonNames.NO],
|
|
352
439
|
onButtonClick: async (e) => {
|
|
353
|
-
let result = [];
|
|
354
440
|
if (e !== ButtonNames.YES)
|
|
355
441
|
return;
|
|
442
|
+
let result = [];
|
|
356
443
|
try {
|
|
444
|
+
setLocalWaitPanelTitle(title);
|
|
445
|
+
setShowLocalWaitPanel(true);
|
|
446
|
+
setLocalShowPrimary(true);
|
|
447
|
+
abortControllerLocal = new AbortController();
|
|
448
|
+
let i = 0;
|
|
357
449
|
const ue = SDK_Globals.tmSession?.NewUpdateEngineByID();
|
|
358
450
|
if (ue) {
|
|
359
451
|
ue.TID = firstDoc.TID;
|
|
@@ -361,21 +453,22 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
361
453
|
if (checkout) {
|
|
362
454
|
await ue.CheckOutAsync()
|
|
363
455
|
.then(async () => {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
456
|
+
const filename = fromDTD?.nameLoc || SDKUI_Localizator.SearchResult;
|
|
457
|
+
await cicoDownloadFilesCallback([{ type: 'dcmtInfo', dcmtInfo: firstDoc, originalFileName: filename }], true, downloadDcmtsAsync);
|
|
458
|
+
result.push({ rowIndex: i, id1: firstDoc.TID, id2: firstDoc.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
367
459
|
await refreshFocusedDataRowAsync(firstDoc.TID, firstDoc.DID, true);
|
|
368
460
|
})
|
|
369
461
|
.catch((error) => {
|
|
370
|
-
result.push({ rowIndex:
|
|
462
|
+
result.push({ rowIndex: i, id1: firstDoc.TID, id2: firstDoc.DID, resultType: ResultTypes.ERROR, description: getExceptionMessage(error) });
|
|
371
463
|
throw error;
|
|
372
464
|
});
|
|
373
465
|
}
|
|
374
466
|
else {
|
|
375
467
|
await ue.UndoCheckOutAsync()
|
|
376
468
|
.then(async () => {
|
|
377
|
-
result.push({ rowIndex:
|
|
378
|
-
//
|
|
469
|
+
result.push({ rowIndex: i, id1: firstDoc.TID, id2: firstDoc.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
470
|
+
// Remove the corresponding draft checkout item
|
|
471
|
+
updateCicoCheckoutStorageItem({ TID: firstDoc.TID.toString(), DID: firstDoc.DID.toString(), checkoutFolder: "", checkoutName: "" }, "dcmtInfo", "remove");
|
|
379
472
|
await refreshFocusedDataRowAsync(firstDoc.TID, firstDoc.DID, true);
|
|
380
473
|
})
|
|
381
474
|
.catch((error) => {
|
|
@@ -389,11 +482,91 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
389
482
|
result.push({ rowIndex: 0, id1: firstDoc.TID, id2: firstDoc.DID, resultType: ResultTypes.ERROR, description: getExceptionMessage(error) });
|
|
390
483
|
}
|
|
391
484
|
finally {
|
|
485
|
+
setLocalWaitPanelTextPrimary('');
|
|
486
|
+
setLocalWaitPanelMaxValuePrimary(0);
|
|
487
|
+
setLocalWaitPanelValuePrimary(0);
|
|
488
|
+
setShowLocalWaitPanel(false);
|
|
392
489
|
TMResultManager.show(result, title, "ID", undefined);
|
|
393
490
|
}
|
|
394
491
|
}
|
|
395
492
|
});
|
|
396
493
|
};
|
|
494
|
+
const triggerCommentOnFileAdd = (addedFiles) => {
|
|
495
|
+
if (addedFiles.length > 0) {
|
|
496
|
+
showCommentFormCallback();
|
|
497
|
+
setIsCommentRequired(true);
|
|
498
|
+
setRemoveAndEditAttachmentCommentForm(false);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
const handleCheckInOperationCallback = useCallback(() => {
|
|
502
|
+
const selectedDocs = getSelectedDcmtsOrFocused(selectedItems, focusedItem);
|
|
503
|
+
const firstDoc = selectedDocs?.[0];
|
|
504
|
+
if (!firstDoc)
|
|
505
|
+
return;
|
|
506
|
+
// Create a new file input element
|
|
507
|
+
const input = document.createElement("input");
|
|
508
|
+
// Set the input type to "file" to allow file selection
|
|
509
|
+
input.type = "file";
|
|
510
|
+
// Set the accepted file types (e.g., images, PDFs, etc.)
|
|
511
|
+
input.accept = "*/*";
|
|
512
|
+
// Enable the input to accept one file at once
|
|
513
|
+
input.multiple = false;
|
|
514
|
+
// Add an event listener for when the file selection changes
|
|
515
|
+
input.addEventListener('change', async (event) => {
|
|
516
|
+
const fileInput = event.target;
|
|
517
|
+
if (!fileInput.files || fileInput.files.length === 0)
|
|
518
|
+
return;
|
|
519
|
+
const file = fileInput.files[0];
|
|
520
|
+
firstDoc.fileName = fromDTD?.name ?? SDKUI_Localizator.SearchResult;
|
|
521
|
+
const validateFileName = validateCicoFileName({ type: 'dcmtInfo', dcmtInfo: firstDoc, originalFileName: firstDoc.fileName }, file.name);
|
|
522
|
+
TMMessageBoxManager.show({
|
|
523
|
+
resizable: true,
|
|
524
|
+
buttons: [ButtonNames.YES, ButtonNames.NO],
|
|
525
|
+
message: renderCicoCheckInContent({ type: 'dcmtInfo', dcmtInfo: firstDoc, originalFileName: firstDoc.fileName }, file, validateFileName.isValid, validateFileName.validationResults),
|
|
526
|
+
title: "Check in",
|
|
527
|
+
onButtonClick: async (e) => {
|
|
528
|
+
if (e !== ButtonNames.YES)
|
|
529
|
+
return;
|
|
530
|
+
setLocalWaitPanelTitle('Check in');
|
|
531
|
+
setShowLocalWaitPanel(true);
|
|
532
|
+
setLocalShowPrimary(true);
|
|
533
|
+
abortControllerLocal = new AbortController();
|
|
534
|
+
let result = [];
|
|
535
|
+
let i = 0;
|
|
536
|
+
if (firstDoc.TID && firstDoc.DID) {
|
|
537
|
+
try {
|
|
538
|
+
const ue = SDK_Globals.tmSession?.NewUpdateEngineByID();
|
|
539
|
+
if (ue) {
|
|
540
|
+
ue.TID = firstDoc.TID;
|
|
541
|
+
ue.DID = firstDoc.DID;
|
|
542
|
+
await ue.CheckInAsync(file, "", abortControllerLocal.signal);
|
|
543
|
+
// Remove the corresponding draft checkout item
|
|
544
|
+
updateCicoCheckoutStorageItem({ TID: firstDoc.TID.toString(), DID: firstDoc.DID.toString(), checkoutFolder: "", checkoutName: "" }, "dcmtInfo", "remove");
|
|
545
|
+
result.push({ rowIndex: i, id1: firstDoc.DID, id2: firstDoc.DID, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS });
|
|
546
|
+
await refreshFocusedDataRowAsync(firstDoc.TID, firstDoc.DID, true);
|
|
547
|
+
const cacheKey = `${firstDoc.TID}-${firstDoc.DID}`;
|
|
548
|
+
if (dcmtsFileCachePreview.has(cacheKey))
|
|
549
|
+
removeDcmtsFileCache(cacheKey);
|
|
550
|
+
triggerPreviewRefresh();
|
|
551
|
+
triggerCommentOnFileAdd([firstDoc.DID]);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
catch (err) {
|
|
555
|
+
result.push({ rowIndex: i, id1: i, id2: i, resultType: ResultTypes.ERROR, description: getExceptionMessage(err) });
|
|
556
|
+
}
|
|
557
|
+
finally {
|
|
558
|
+
setLocalWaitPanelTextPrimary('');
|
|
559
|
+
setLocalWaitPanelMaxValuePrimary(0);
|
|
560
|
+
setLocalWaitPanelValuePrimary(0);
|
|
561
|
+
setShowLocalWaitPanel(false);
|
|
562
|
+
TMResultManager.show(result, 'Check in', "ID", undefined, SDKUI_Localizator.CheckInSuccessMessage, 6000);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
input.click();
|
|
569
|
+
}, [selectedItems, focusedItem, getSelectedDcmtsOrFocused]);
|
|
397
570
|
const refreshDataGridAfterRemoveAsync = async () => {
|
|
398
571
|
let index = selectedSearchResult?.dtdResult?.columns?.findIndex(col => col.caption === 'DID');
|
|
399
572
|
let selectedRows = [];
|
|
@@ -572,7 +745,7 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
572
745
|
}
|
|
573
746
|
};
|
|
574
747
|
const searchResutlToolbar = _jsxs(_Fragment, { children: [(dcmtsReturned != dcmtsFound) && _jsx("p", { style: { backgroundColor: `white`, color: TMColors.primaryColor, textAlign: 'center', padding: '1px 4px', borderRadius: '3px', display: 'flex' }, children: `${dcmtsReturned}/${dcmtsFound} restituiti` }), context === SearchResultContext.FAVORITES_AND_RECENTS &&
|
|
575
|
-
_jsx("div", { style: { display: 'flex', alignItems: 'center', gap: '5px' }, children: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconDelete, { color: 'white' }), caption: "Rimuovi da " + (selectedSearchResult?.category === "Favorites" ? '"Preferiti"' : '"Recenti"'), disabled: getSelectedDcmtsOrFocused(selectedItems, focusedItem).length <= 0, onClick: removeDcmtFromFavsOrRecents }) }), _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconRefresh, { color: 'white' }), caption: SDKUI_Localizator.Refresh, onClick: onRefreshSearchAsync }), _jsx(IconMenuVertical, { id: `commands-header-${id}`, color: 'white', cursor: 'pointer' }), _jsx(TMCommandsContextMenu, { target: `#commands-header-${id}`, showEvent: "click", menuItems: getCommandsMenuItems(isMobile, fromDTD, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, refreshSelectionDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, openConfirmAttachmentsDialog, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, currentTIDHasMasterRelations, currentTIDHasDetailRelations, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, hasManyToManyRelation).concat([customButtonMenuItems()]) })] });
|
|
748
|
+
_jsx("div", { style: { display: 'flex', alignItems: 'center', gap: '5px' }, children: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconDelete, { color: 'white' }), caption: "Rimuovi da " + (selectedSearchResult?.category === "Favorites" ? '"Preferiti"' : '"Recenti"'), disabled: getSelectedDcmtsOrFocused(selectedItems, focusedItem).length <= 0, onClick: removeDcmtFromFavsOrRecents }) }), _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconRefresh, { color: 'white' }), caption: SDKUI_Localizator.Refresh, onClick: onRefreshSearchAsync }), _jsx(IconMenuVertical, { id: `commands-header-${id}`, color: 'white', cursor: 'pointer' }), _jsx(TMCommandsContextMenu, { target: `#commands-header-${id}`, showEvent: "click", menuItems: getCommandsMenuItems(isMobile, fromDTD, allUsers, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, refreshSelectionDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, openConfirmAttachmentsDialog, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, handleCheckInOperationCallback, showCheckoutInformationFormCallback, viewHistoryCallback, infoCheckCopyToClipboard, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, currentTIDHasMasterRelations, currentTIDHasDetailRelations, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, hasManyToManyRelation).concat([customButtonMenuItems()]) })] });
|
|
576
749
|
const handleAddItem = (tid, did) => {
|
|
577
750
|
let newItem = { TID: tid ?? 0, DID: did ?? 0 };
|
|
578
751
|
setSecondaryMasterDcmts((prevItems) => [...prevItems, newItem]);
|
|
@@ -580,22 +753,6 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
580
753
|
const handleRemoveItem = (tid, did) => {
|
|
581
754
|
setSecondaryMasterDcmts((prevItems) => prevItems.filter(item => item.TID !== tid && item.DID !== did));
|
|
582
755
|
};
|
|
583
|
-
const fetchBlogDataAsync = useCallback(async (tid, did) => {
|
|
584
|
-
try {
|
|
585
|
-
TMSpinner.show({ description: 'Caricamento - Bacheca...' });
|
|
586
|
-
const res = await SDK_Globals.tmSession?.NewSearchEngine().BlogRetrieveAsync(tid, did);
|
|
587
|
-
setBlogsDatasource(res ?? []);
|
|
588
|
-
setHasLoadedDataOnce(true);
|
|
589
|
-
setLastLoadedDid(did);
|
|
590
|
-
}
|
|
591
|
-
catch (e) {
|
|
592
|
-
let err = e;
|
|
593
|
-
TMExceptionBoxManager.show({ exception: err });
|
|
594
|
-
}
|
|
595
|
-
finally {
|
|
596
|
-
TMSpinner.hide();
|
|
597
|
-
}
|
|
598
|
-
}, []);
|
|
599
756
|
const handleSavedAsyncCallback = useCallback(async (tid, did, metadataResult) => {
|
|
600
757
|
await refreshFocusedDataRowAsync(tid, did, true, metadataResult);
|
|
601
758
|
}, []);
|
|
@@ -604,10 +761,10 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
604
761
|
? _jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%' }, children: [_jsx(IconBoard, { fontSize: 96 }), _jsx("div", { style: { fontSize: "15px", marginTop: "10px" }, children: SDKUI_Localizator.NoDcmtFound }), openAddDocumentForm && _jsx("div", { style: { marginTop: "10px" }, children: _jsx(TMButton, { fontSize: "15px", icon: _jsx("i", { className: 'dx-icon-share' }), caption: SDKUI_Localizator.Share, onClick: openAddDocumentForm }) })] })
|
|
605
762
|
:
|
|
606
763
|
_jsxs(_Fragment, { children: [_jsxs(TMLayoutItem, { height: '100%', children: [_jsxs(TMSplitterLayout, { direction: 'horizontal', overflow: 'visible', separatorSize: Gutters.getGutters(), separatorActiveColor: 'transparent', separatorColor: 'transparent', min: ['0', '0'], showSeparator: showSelector && deviceType !== DeviceType.MOBILE, start: showSelector ? deviceType !== DeviceType.MOBILE ? ['30%', '70%'] : splitterSize : ['0%', '100%'], children: [showSelector ?
|
|
607
|
-
_jsx(TMLayoutItem, { children: _jsx(TMSearchResultSelector, { searchResults: currentSearchResults, disableAccordionIfSingleCategory: disableAccordionIfSingleCategory, selectedTID: selectedSearchResultTID, onSelectionChanged: onSearchResultSelectionChanged }) })
|
|
764
|
+
_jsx(TMLayoutItem, { children: _jsx(TMSearchResultSelector, { searchResults: currentSearchResults, disableAccordionIfSingleCategory: disableAccordionIfSingleCategory, selectedTID: selectedSearchResultTID, selectedSearchResult: selectedSearchResult, autoSelectFirst: !isMobile || currentSearchResults.length === 1, onSelectionChanged: onSearchResultSelectionChanged }) })
|
|
608
765
|
:
|
|
609
|
-
_jsx(_Fragment, {}), _jsxs(TMLayoutItem, { children: [_jsx(TMSearchResultGrid, { showSearch: showSearch, inputFocusedItem: focusedItem, inputSelectedItems: selectedItems, searchResult: searchResults.length > 1 ? selectedSearchResult : searchResults[0], lastUpdateSearchTime: lastUpdateSearchTime, openInOffice: openInOffice, onDblClick: () => openFormHandler(LayoutModes.Update), onContextMenuPreparing: onContextMenuPreparing, onSelectionChanged: (items) => { setSelectedItems(items); }, onVisibleItemChanged: setVisibleItems, onFocusedItemChanged: setFocusedItem, onDownloadDcmtsAsync: async (inputDcmts, downloadType, downloadMode, _y, confirmAttachments) => await downloadDcmtsAsync(inputDcmts, downloadType, downloadMode, onFileOpened, confirmAttachments), showExportForm: showExportForm, onCloseExportForm: onCloseExportForm }), allowFloatingBar && showFloatingBar && deviceType !== DeviceType.MOBILE &&
|
|
610
|
-
_jsxs(TMFloatingToolbar, { backgroundColor: TMColors.primaryColor, initialLeft: '10px', initialTop: 'calc(100% - 75px)', children: [fromDTD?.perm?.canRetrieveFile === AccessLevels.Yes && _jsx(TMButton, { btnStyle: 'icon', caption: "Download file", disabled: fromDTD?.perm?.canRetrieveFile !== AccessLevels.Yes || !focusedItem?.DID, icon: _jsx(IconDownload, { color: 'white' }), onClick: () => { downloadDcmtsAsync(getSelectedDcmtsOrFocused(selectedItems, focusedItem), DownloadTypes.Dcmt, "download"); } }), allowRelations && _jsx(TMButton, { btnStyle: 'icon', disabled: !currentTIDHasDetailRelations || !focusedItem?.DID, icon: _jsx(IconDetailDcmts, { color: 'white' }), caption: SDKUI_Localizator.DcmtsDetail, onClick: () => setIsOpenDetails(true) }), allowRelations && _jsx(TMButton, { btnStyle: 'icon', disabled: !currentTIDHasMasterRelations || !focusedItem?.DID, icon: _jsx(IconDetailDcmts, { color: 'white', transform: 'scale(-1, 1)' }), caption: SDKUI_Localizator.DcmtsMaster, onClick: () => setIsOpenMaster(true) }), _jsx(IconMenuVertical, { id: `commands-floating-${id}`, color: 'white', cursor: 'pointer' }), _jsx(TMCommandsContextMenu, { target: `#commands-floating-${id}`, showEvent: "click", menuItems: getCommandsMenuItems(isMobile, fromDTD, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, refreshSelectionDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, openConfirmAttachmentsDialog, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, currentTIDHasMasterRelations, currentTIDHasDetailRelations, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, hasManyToManyRelation).concat([customButtonMenuItems()]) })] })] })] }), showApprovePopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: onWFOperationCompleted, selectedItems: getSelectedDcmtsOrFocused(selectedItems, focusedItem), isReject: 0, onClose: () => setShowApprovePopup(false) }), showRejectPopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: onWFOperationCompleted, selectedItems: getSelectedDcmtsOrFocused(selectedItems, focusedItem), isReject: 1, onClose: () => setShowRejectPopup(false) }), showReAssignPopup && _jsx(WorkFlowReAssignPopUp, { deviceType: deviceType, onCompleted: onWFOperationCompleted, selectedItems: getSelectedDcmtsOrFocused(selectedItems, focusedItem), onClose: () => setShowReAssignPopup(false) }), showMoreInfoPopup && _jsx(WorkFlowMoreInfoPopUp, { TID: focusedItem?.TID, DID: focusedItem?.DID, deviceType: deviceType, onCompleted: onWFOperationCompleted, onClose: () => setShowMoreInfoPopup(false) }), isOpenBatchUpdate && _jsx(TMBatchUpdateForm, { isModal: true, titleModal: `${SDKUI_Localizator.BatchUpdate} (${getSelectionDcmtInfo().length} documenti selezionati)`, inputDcmts: getSelectionDcmtInfo(), TID: focusedItem ? focusedItem?.TID : selectedItems[0]?.TID, DID: focusedItem ? focusedItem?.DID : selectedItems[0]?.DID, onBack: () => {
|
|
766
|
+
_jsx(_Fragment, {}), _jsxs(TMLayoutItem, { children: [_jsx(TMSearchResultGrid, { showSearch: showSearch, fromDTD: fromDTD, allUsers: allUsers, inputFocusedItem: focusedItem, inputSelectedItems: selectedItems, searchResult: searchResults.length > 1 ? selectedSearchResult : searchResults[0], lastUpdateSearchTime: lastUpdateSearchTime, openInOffice: openInOffice, onDblClick: () => openFormHandler(LayoutModes.Update), onContextMenuPreparing: onContextMenuPreparing, onSelectionChanged: (items) => { setSelectedItems(items); }, onVisibleItemChanged: setVisibleItems, onFocusedItemChanged: setFocusedItem, onDownloadDcmtsAsync: async (inputDcmts, downloadType, downloadMode, _y, confirmAttachments) => await downloadDcmtsAsync(inputDcmts, downloadType, downloadMode, onFileOpened, confirmAttachments), showExportForm: showExportForm, onCloseExportForm: onCloseExportForm }), allowFloatingBar && showFloatingBar && deviceType !== DeviceType.MOBILE &&
|
|
767
|
+
_jsxs(TMFloatingToolbar, { backgroundColor: TMColors.primaryColor, initialLeft: '10px', initialTop: 'calc(100% - 75px)', children: [fromDTD?.perm?.canRetrieveFile === AccessLevels.Yes && _jsx(TMButton, { btnStyle: 'icon', caption: "Download file", disabled: fromDTD?.perm?.canRetrieveFile !== AccessLevels.Yes || !focusedItem?.DID, icon: _jsx(IconDownload, { color: 'white' }), onClick: () => { downloadDcmtsAsync(getSelectedDcmtsOrFocused(selectedItems, focusedItem), DownloadTypes.Dcmt, "download"); } }), allowRelations && _jsx(TMButton, { btnStyle: 'icon', disabled: !currentTIDHasDetailRelations || !focusedItem?.DID, icon: _jsx(IconDetailDcmts, { color: 'white' }), caption: SDKUI_Localizator.DcmtsDetail, onClick: () => setIsOpenDetails(true) }), allowRelations && _jsx(TMButton, { btnStyle: 'icon', disabled: !currentTIDHasMasterRelations || !focusedItem?.DID, icon: _jsx(IconDetailDcmts, { color: 'white', transform: 'scale(-1, 1)' }), caption: SDKUI_Localizator.DcmtsMaster, onClick: () => setIsOpenMaster(true) }), _jsx(IconMenuVertical, { id: `commands-floating-${id}`, color: 'white', cursor: 'pointer' }), _jsx(TMCommandsContextMenu, { target: `#commands-floating-${id}`, showEvent: "click", menuItems: getCommandsMenuItems(isMobile, fromDTD, allUsers, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, refreshSelectionDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, openConfirmAttachmentsDialog, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, handleCheckInOperationCallback, showCheckoutInformationFormCallback, viewHistoryCallback, infoCheckCopyToClipboard, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, currentTIDHasMasterRelations, currentTIDHasDetailRelations, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToMany, hasManyToManyRelation).concat([customButtonMenuItems()]) })] })] })] }), showApprovePopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: onWFOperationCompleted, selectedItems: getSelectedDcmtsOrFocused(selectedItems, focusedItem), isReject: 0, onClose: () => setShowApprovePopup(false) }), showRejectPopup && _jsx(WorkFlowApproveRejectPopUp, { deviceType: deviceType, onCompleted: onWFOperationCompleted, selectedItems: getSelectedDcmtsOrFocused(selectedItems, focusedItem), isReject: 1, onClose: () => setShowRejectPopup(false) }), showReAssignPopup && _jsx(WorkFlowReAssignPopUp, { deviceType: deviceType, onCompleted: onWFOperationCompleted, selectedItems: getSelectedDcmtsOrFocused(selectedItems, focusedItem), onClose: () => setShowReAssignPopup(false) }), showMoreInfoPopup && _jsx(WorkFlowMoreInfoPopUp, { TID: focusedItem?.TID, DID: focusedItem?.DID, deviceType: deviceType, onCompleted: onWFOperationCompleted, onClose: () => setShowMoreInfoPopup(false) }), isOpenBatchUpdate && _jsx(TMBatchUpdateForm, { isModal: true, titleModal: `${SDKUI_Localizator.BatchUpdate} (${getSelectionDcmtInfo().length} documenti selezionati)`, inputDcmts: getSelectionDcmtInfo(), TID: focusedItem ? focusedItem?.TID : selectedItems[0]?.TID, DID: focusedItem ? focusedItem?.DID : selectedItems[0]?.DID, onBack: () => {
|
|
611
768
|
setIsOpenBatchUpdate(false);
|
|
612
769
|
}, onSavedCallbackAsync: async () => {
|
|
613
770
|
setIsOpenBatchUpdate(false);
|
|
@@ -665,7 +822,8 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
665
822
|
}, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), sharedDcmtSearchResults.length > 0 &&
|
|
666
823
|
_jsx(TMModal, { title: "Documenti condivisi", onClose: () => {
|
|
667
824
|
setSharedDcmtSearchResults([]);
|
|
668
|
-
}, width: isMobile ? '90%' : '60%', height: isMobile ? '90%' : '80%', children: _jsx(TMSearchResult, { searchResults: sharedDcmtSearchResults, allowFloatingBar: false, showSelector: true, showBackButton:
|
|
825
|
+
}, width: isMobile ? '90%' : '60%', height: isMobile ? '90%' : '80%', children: _jsx(TMSearchResult, { searchResults: sharedDcmtSearchResults, allowFloatingBar: false, showSelector: true, disableAccordionIfSingleCategory: true, showBackButton: isMobile, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), (showCheckoutInformationForm && fromDTD && getSelectedDcmtsOrFocused(selectedItems, focusedItem).length > 0) &&
|
|
826
|
+
_jsx(TMSearchResultCheckoutInfoForm, { dtdName: fromDTD.name ?? SDKUI_Localizator.SearchResult, selectedDcmtOrFocused: getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0], onClose: () => setShowCheckoutInformationForm(false) }), (floatingActionConfig && floatingActionConfig.isVisible) && _jsx(TMSearchResultFloatingActionButton, { selectedDcmtsOrFocused: getSelectedDcmtsOrFocused(selectedItems, focusedItem), config: floatingActionConfig })] }), [
|
|
669
827
|
searchResults,
|
|
670
828
|
selectedSearchResult,
|
|
671
829
|
lastUpdateSearchTime,
|
|
@@ -718,9 +876,9 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
718
876
|
sharedDcmtFile,
|
|
719
877
|
onRefreshSearchAsync
|
|
720
878
|
]);
|
|
721
|
-
const tmBlog = useMemo(() => _jsx(TMDcmtBlog, {
|
|
879
|
+
const tmBlog = useMemo(() => _jsx(TMDcmtBlog, { tid: focusedItem?.TID, did: focusedItem?.DID, fetchBlogDataTrigger: refreshBlogTrigger, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), [focusedItem, allTasks, refreshBlogTrigger]);
|
|
722
880
|
const tmSysMetadata = useMemo(() => _jsx(TMMetadataValues, { layoutMode: LayoutModes.Update, openChooserBySingleClick: true, TID: focusedItem?.TID, isReadOnly: true, deviceType: deviceType, metadataValues: currentMetadataValues.filter(o => (o.mid != undefined && o.mid <= 100)), metadataValuesOrig: currentMetadataValues.filter(o => (o.mid != undefined && o.mid <= 100)), validationItems: [] }), [focusedItem, currentMetadataValues, deviceType]);
|
|
723
|
-
const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt }), [currentDcmt]);
|
|
881
|
+
const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt }, refreshPreviewTrigger), [currentDcmt, refreshPreviewTrigger]);
|
|
724
882
|
const allInitialPanelVisibility = {
|
|
725
883
|
'tmSearchResult': true,
|
|
726
884
|
'tmBlog': false,
|
|
@@ -778,12 +936,12 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
778
936
|
gap: Gutters.getGutters(),
|
|
779
937
|
width: '100%',
|
|
780
938
|
height: '100%',
|
|
781
|
-
}, children: _jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showWaitPanel, showWaitPanelPrimary: showPrimary, showWaitPanelSecondary: showSecondary, waitPanelTitle: waitPanelTitle, waitPanelTextPrimary: waitPanelTextPrimary, waitPanelValuePrimary: waitPanelValuePrimary, waitPanelMaxValuePrimary: waitPanelMaxValuePrimary, waitPanelTextSecondary: waitPanelTextSecondary, waitPanelValueSecondary: waitPanelValueSecondary, waitPanelMaxValueSecondary: waitPanelMaxValueSecondary, isCancelable: true, abortController: abortController, children: (groupId && groupId.length > 0) ?
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
939
|
+
}, children: _jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showWaitPanel, showWaitPanelPrimary: showPrimary, showWaitPanelSecondary: showSecondary, waitPanelTitle: waitPanelTitle, waitPanelTextPrimary: waitPanelTextPrimary, waitPanelValuePrimary: waitPanelValuePrimary, waitPanelMaxValuePrimary: waitPanelMaxValuePrimary, waitPanelTextSecondary: waitPanelTextSecondary, waitPanelValueSecondary: waitPanelValueSecondary, waitPanelMaxValueSecondary: waitPanelMaxValueSecondary, isCancelable: true, abortController: abortController, children: _jsx(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: showLocalWaitPanel, showWaitPanelPrimary: localShowPrimary, waitPanelTitle: localWaitPanelTitle, waitPanelTextPrimary: localWaitPanelTextPrimary, waitPanelValuePrimary: localWaitPanelValuePrimary, waitPanelMaxValuePrimary: localWaitPanelMaxValuePrimary, isCancelable: true, abortController: abortControllerLocal, children: (groupId && groupId.length > 0) ?
|
|
940
|
+
_jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showSearchResultSidebar })
|
|
941
|
+
:
|
|
942
|
+
_jsx(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: initialPanelDimensions, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'tmSearchResult', children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showSearchResultSidebar }) }) }) }) }), _jsx(StyledMultiViewPanel, { "$isVisible": isOpenDetails, children: isOpenDetails && _jsx(TMMasterDetailDcmts, { deviceType: deviceType, isForMaster: false, inputDcmts: getSelectionDcmtInfo(), allowNavigation: focusedItem && selectedItems.length <= 0, canNext: canNavigateHandler('next'), canPrev: canNavigateHandler('prev'), onNext: () => onNavigateHandler('next'), onPrev: () => onNavigateHandler('prev'), onBack: () => setIsOpenDetails(false), allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), _jsxs(StyledMultiViewPanel, { "$isVisible": isOpenMaster, children: [isOpenMaster && _jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: getSelectionDcmtInfo(), isForMaster: true, allowNavigation: focusedItem && selectedItems.length <= 0, canNext: canNavigateHandler('next'), canPrev: canNavigateHandler('prev'), onNext: () => onNavigateHandler('next'), onPrev: () => onNavigateHandler('prev'), onBack: () => setIsOpenMaster(false), appendMasterDcmts: handleAddItem, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), secondaryMasterDcmts.length > 0 && secondaryMasterDcmts.map((dcmt, index) => {
|
|
785
943
|
return (_jsx(StyledModalContainer, { style: { backgroundColor: 'white' }, children: _jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: [dcmt], isForMaster: true, allowNavigation: false, onBack: () => handleRemoveItem(dcmt.TID, dcmt.DID), appendMasterDcmts: handleAddItem, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }, `${index}-${dcmt.DID}`));
|
|
786
|
-
})] }), _jsx(StyledMultiViewPanel, { "$isVisible": isOpenDcmtForm, children: isOpenDcmtForm && _jsx(TMDcmtForm, { isModal: openDcmtFormAsModal || (dcmtFormLayoutMode === LayoutModes.Ark && focusedItem?.DID), titleModal: fromDTD?.name ?? '', TID: focusedItem
|
|
944
|
+
})] }), _jsx(StyledMultiViewPanel, { "$isVisible": isOpenDcmtForm, children: isOpenDcmtForm && focusedItem?.TID !== undefined && focusedItem?.DID !== undefined && _jsx(TMDcmtForm, { isModal: openDcmtFormAsModal || (dcmtFormLayoutMode === LayoutModes.Ark && focusedItem?.DID), titleModal: fromDTD?.name ?? '', TID: focusedItem.TID, DID: focusedItem.DID, allowButtonsRefs: true, layoutMode: dcmtFormLayoutMode, count: visibleItems.length, itemIndex: visibleItems.findIndex(o => o.rowIndex === focusedItem?.rowIndex) + 1, canNext: canNavigateHandler('next'), canPrev: canNavigateHandler('prev'), onNext: () => onNavigateHandler('next'), onPrev: () => onNavigateHandler('prev'), onClose: () => { setIsOpenDcmtForm(false); }, onWFOperationCompleted: onWFOperationCompleted, onTaskCreateRequest: onTaskCreateRequest, onSavedAsyncCallback: handleSavedAsyncCallback, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, onReferenceClick: onReferenceClick, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }) }), isOpenArchiveRelationForm && _jsx(TMDcmtForm, { isModal: true, titleModal: SDKUI_Localizator.Archive + ' - ' + (archiveType === 'detail' ? SDKUI_Localizator.DcmtsDetail : SDKUI_Localizator.DcmtsMaster), TID: archiveRelatedDcmtFormTID, layoutMode: LayoutModes.Ark, inputMids: archiveRelatedDcmtFormMids, showBackButton: false, allowButtonsRefs: false, onClose: () => {
|
|
787
945
|
setIsOpenArchiveRelationForm(false);
|
|
788
946
|
setArchiveType(undefined);
|
|
789
947
|
setArchiveRelatedDcmtFormTID(undefined);
|
|
@@ -794,13 +952,13 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
794
952
|
setArchiveRelatedDcmtFormTID(undefined);
|
|
795
953
|
setArchiveRelatedDcmtFormMids([]);
|
|
796
954
|
await onRefreshSearchAsync?.();
|
|
797
|
-
}, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), (showSignSettingsForm && fromDTD) && _jsx(TMSignSettingsForm, { fromDTD: fromDTD, inputDcmts: allFieldSelectedDocs, onCloseSignSettingsForm: closeSignSettingsForm, onSavedAsyncCallback: handleSavedAsyncCallback })] }));
|
|
955
|
+
}, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), (showSignSettingsForm && fromDTD) && _jsx(TMSignSettingsForm, { fromDTD: fromDTD, inputDcmts: allFieldSelectedDocs, onCloseSignSettingsForm: closeSignSettingsForm, onSavedAsyncCallback: handleSavedAsyncCallback }), (showHistory && fromDTD && getSelectedDcmtsOrFocused(selectedItems, focusedItem).length > 0) && _jsx(TMViewHistoryDcmt, { fromDTD: fromDTD, deviceType: deviceType, inputDcmt: getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0], onClose: () => setShowHistory(false), allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), (showCommentForm && getSelectedDcmtsOrFocused(selectedItems, focusedItem).length > 0) && _jsx(TMBlogCommentForm, { context: { engine: 'SearchEngine', object: { tid: getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0].TID, did: getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0].DID } }, onClose: () => setShowCommentForm(false), refreshCallback: triggerBlogRefresh, participants: [], showAttachmentsSection: true, allArchivedDocumentsFileItems: convertSearchResultDescriptorToFileItems(currentSearchResults ?? []), isCommentRequired: isCommentRequired, removeAndEditAttachment: removeAndEditAttachmentCommentForm, selectedAttachmentDid: [Number(getSelectedDcmtsOrFocused(selectedItems, focusedItem)[0].DID)] })] }));
|
|
798
956
|
};
|
|
799
957
|
export default TMSearchResult;
|
|
800
958
|
const renderDcmtIcon = (cellData, onDownloadDcmtsAsync, openInOffice) => {
|
|
801
959
|
return _jsx(TMDcmtIcon, { tid: cellData.data.TID, did: cellData.data.DID, fileExtension: cellData.data.FILEEXT, fileCount: cellData.data.FILECOUNT, isLexProt: cellData.data.IsLexProt, isMail: cellData.data.ISMAIL, isShared: cellData.data.ISSHARED, isSigned: cellData.data.ISSIGNED, downloadMode: 'openInNewWindow', onDownloadDcmtsAsync: onDownloadDcmtsAsync, openInOffice: openInOffice });
|
|
802
960
|
};
|
|
803
|
-
const TMSearchResultGrid = ({ openInOffice, inputFocusedItem, showSearch, allowMultipleSelection = true, showExportForm = false, onCloseExportForm, onFocusedItemChanged, onDownloadDcmtsAsync, onVisibleItemChanged, inputSelectedItems = [], lastUpdateSearchTime, searchResult, onContextMenuPreparing, onSelectionChanged, onDblClick }) => {
|
|
961
|
+
const TMSearchResultGrid = ({ openInOffice, fromDTD, allUsers, inputFocusedItem, showSearch, allowMultipleSelection = true, showExportForm = false, onCloseExportForm, onFocusedItemChanged, onDownloadDcmtsAsync, onVisibleItemChanged, inputSelectedItems = [], lastUpdateSearchTime, searchResult, onContextMenuPreparing, onSelectionChanged, onDblClick }) => {
|
|
804
962
|
const [dataSource, setDataSource] = useState();
|
|
805
963
|
const [columns, setColumns] = useState([]);
|
|
806
964
|
// State to store selected row keys
|
|
@@ -880,12 +1038,20 @@ const TMSearchResultGrid = ({ openInOffice, inputFocusedItem, showSearch, allowM
|
|
|
880
1038
|
return null;
|
|
881
1039
|
const isLogDel = cellData.data.ISLOGDEL == 1;
|
|
882
1040
|
const isLexProt = cellData.data.IsLexProt == 1;
|
|
1041
|
+
// Prima colonna: la colonna numero 2 (dopo icona e selezione)
|
|
1042
|
+
const isFirstColumn = cellData.columnIndex === 2;
|
|
1043
|
+
const { checkoutStatus } = getDcmtCicoStatus(cellData.data, allUsers, fromDTD);
|
|
1044
|
+
const shouldShowCheckoutIcon = isFirstColumn && checkoutStatus.isCheckedOut && checkoutStatus.icon;
|
|
883
1045
|
let style = {};
|
|
884
1046
|
if (isLogDel) {
|
|
885
1047
|
style = { color: 'gray', textDecoration: 'line-through' };
|
|
886
1048
|
}
|
|
887
|
-
else if (isLexProt)
|
|
1049
|
+
else if (isLexProt) {
|
|
888
1050
|
style = { color: 'blue' };
|
|
1051
|
+
}
|
|
1052
|
+
if (shouldShowCheckoutIcon) {
|
|
1053
|
+
style = { ...style, display: 'flex', gap: '4px', whiteSpace: 'nowrap' };
|
|
1054
|
+
}
|
|
889
1055
|
let child = _jsx("div", { children: cellData.text });
|
|
890
1056
|
if (dataDomain === MetadataDataDomains.DataList) {
|
|
891
1057
|
child = _jsx(TMDataListItemViewer, { dataListId: dataListID, viewMode: dataListViewMode, value: cellData.value });
|
|
@@ -893,8 +1059,8 @@ const TMSearchResultGrid = ({ openInOffice, inputFocusedItem, showSearch, allowM
|
|
|
893
1059
|
if (dataDomain === MetadataDataDomains.UserID) {
|
|
894
1060
|
child = _jsx(TMUserIdViewer, { userId: cellData.value, showIcon: true, noneSelectionText: '' });
|
|
895
1061
|
}
|
|
896
|
-
return
|
|
897
|
-
}, []);
|
|
1062
|
+
return (_jsxs("div", { style: style, children: [shouldShowCheckoutIcon && checkoutStatus.icon, child] }));
|
|
1063
|
+
}, [fromDTD, allUsers]);
|
|
898
1064
|
const dataType = useCallback((col) => {
|
|
899
1065
|
switch (col.dataType) {
|
|
900
1066
|
case DataColumnTypes.DateTime: return "datetime";
|
|
@@ -945,16 +1111,19 @@ const TMSearchResultGrid = ({ openInOffice, inputFocusedItem, showSearch, allowM
|
|
|
945
1111
|
return undefined;
|
|
946
1112
|
}, []);
|
|
947
1113
|
useEffect(() => {
|
|
1114
|
+
if (fromDTD === undefined || searchResult === undefined)
|
|
1115
|
+
return;
|
|
948
1116
|
setFocusedItem(undefined); // resetta sempre prima
|
|
949
1117
|
let cols = [];
|
|
1118
|
+
// Generate unique keys for all columns
|
|
1119
|
+
const uniqueKeys = generateUniqueColumnKeys(searchResult?.dtdResult?.columns, searchResult?.fromTID);
|
|
950
1120
|
searchResult?.dtdResult?.columns?.map((col, index) => {
|
|
951
|
-
let keyField = getDataColumnName(searchResult?.fromTID, col);
|
|
952
1121
|
const isVisible = col.extendedProperties?.["Visibility"] != "Hidden";
|
|
953
1122
|
const dataDomain = MetadataDataDomains[(col.extendedProperties?.["DataDomain"] ?? "None")];
|
|
954
1123
|
const dataListID = Number(col.extendedProperties?.["DataListID"]);
|
|
955
1124
|
const dataListViewMode = DataListViewModes[(col.extendedProperties?.["DataListViewMode"] ?? "None")];
|
|
956
1125
|
cols.push({
|
|
957
|
-
dataField:
|
|
1126
|
+
dataField: uniqueKeys[index],
|
|
958
1127
|
dataType: dataType(col),
|
|
959
1128
|
visible: isVisible,
|
|
960
1129
|
cellRender: (cellData) => cellRender(cellData, dataDomain, dataListID, dataListViewMode),
|
|
@@ -966,7 +1135,7 @@ const TMSearchResultGrid = ({ openInOffice, inputFocusedItem, showSearch, allowM
|
|
|
966
1135
|
let newDataSource = searchResultDescriptorToSimpleArray(searchResult);
|
|
967
1136
|
setDataSource(newDataSource);
|
|
968
1137
|
// setFocusedItem(newDataSource && newDataSource.length > 0 ? newDataSource[0] : undefined);
|
|
969
|
-
}, [searchResult]);
|
|
1138
|
+
}, [searchResult, fromDTD, allUsers]);
|
|
970
1139
|
useEffect(() => {
|
|
971
1140
|
let newDataSource = searchResultDescriptorToSimpleArray(searchResult);
|
|
972
1141
|
setDataSource(newDataSource);
|
|
@@ -999,6 +1168,16 @@ const TMSearchResultGrid = ({ openInOffice, inputFocusedItem, showSearch, allowM
|
|
|
999
1168
|
// Era sull'icona, non fare nulla
|
|
1000
1169
|
return;
|
|
1001
1170
|
}
|
|
1171
|
+
// Verifica che il documento abbia TID e DID validi prima di procedere
|
|
1172
|
+
if (!e.data.TID || !e.data.DID) {
|
|
1173
|
+
ShowAlert({
|
|
1174
|
+
message: SDKUI_Localizator.InvalidDcmt,
|
|
1175
|
+
mode: "warning",
|
|
1176
|
+
title: SDKUI_Localizator.OpenForm,
|
|
1177
|
+
duration: 3000
|
|
1178
|
+
});
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1002
1181
|
// setFocusedItem(e.data);
|
|
1003
1182
|
onFocusedItemChanged?.(e.data);
|
|
1004
1183
|
onDblClick();
|
|
@@ -1035,7 +1214,7 @@ const StyledItemTemplate = styled.div `
|
|
|
1035
1214
|
cursor: pointer;
|
|
1036
1215
|
`;
|
|
1037
1216
|
const MemoizedStyledItemTemplate = React.memo(StyledItemTemplate);
|
|
1038
|
-
const TMSearchResultSelector = ({ searchResults = [], disableAccordionIfSingleCategory = false, selectedTID, onSelectionChanged }) => {
|
|
1217
|
+
const TMSearchResultSelector = ({ searchResults = [], disableAccordionIfSingleCategory = false, selectedTID, selectedSearchResult, autoSelectFirst = true, onSelectionChanged }) => {
|
|
1039
1218
|
const [selectedResult, setSelectedResult] = useState(undefined);
|
|
1040
1219
|
/** Group results by category */
|
|
1041
1220
|
const groupedResults = useMemo(() => {
|
|
@@ -1059,7 +1238,19 @@ const TMSearchResultSelector = ({ searchResults = [], disableAccordionIfSingleCa
|
|
|
1059
1238
|
sortedCategories.forEach((category) => {
|
|
1060
1239
|
groupedResults[category].sort((a, b) => (a.fromName ?? '').localeCompare(b.fromName ?? ''));
|
|
1061
1240
|
});
|
|
1241
|
+
// Reset internal selection when parent sets selectedSearchResult to undefined
|
|
1242
|
+
// (this happens on mobile when clicking back to return to the list)
|
|
1062
1243
|
useEffect(() => {
|
|
1244
|
+
if (selectedSearchResult === undefined) {
|
|
1245
|
+
setSelectedResult(undefined);
|
|
1246
|
+
}
|
|
1247
|
+
}, [selectedSearchResult]);
|
|
1248
|
+
// Auto-seleziona il primo risultato di ricerca solo se autoSelectFirst è true.
|
|
1249
|
+
// Su mobile con più risultati, autoSelectFirst è false per permettere all'utente
|
|
1250
|
+
// di vedere prima la lista dei tipi documento e scegliere manualmente.
|
|
1251
|
+
useEffect(() => {
|
|
1252
|
+
if (!autoSelectFirst)
|
|
1253
|
+
return;
|
|
1063
1254
|
if (sortedCategories.length > 0) {
|
|
1064
1255
|
const firstCategory = sortedCategories[0];
|
|
1065
1256
|
if (groupedResults[firstCategory].length > 0) {
|
|
@@ -1067,7 +1258,7 @@ const TMSearchResultSelector = ({ searchResults = [], disableAccordionIfSingleCa
|
|
|
1067
1258
|
onSelectionChanged?.(groupedResults[firstCategory][0]);
|
|
1068
1259
|
}
|
|
1069
1260
|
}
|
|
1070
|
-
}, [sortedCategories.length]);
|
|
1261
|
+
}, [sortedCategories.length, autoSelectFirst]);
|
|
1071
1262
|
useEffect(() => {
|
|
1072
1263
|
if (selectedTID !== undefined) {
|
|
1073
1264
|
const found = searchResults.find(r => Number(r.fromTID) === selectedTID);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DcmtInfo } from "../../../ts";
|
|
2
|
+
interface TMSearchResultCheckoutInfoFormProps {
|
|
3
|
+
dtdName: string;
|
|
4
|
+
selectedDcmtOrFocused: DcmtInfo;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
declare const TMSearchResultCheckoutInfoForm: (props: TMSearchResultCheckoutInfoFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default TMSearchResultCheckoutInfoForm;
|