@topconsultnpm/sdkui-react 6.21.0-dev5.5 → 6.21.0-dev5.7
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/features/documents/TMMergeToPdfForm.js +4 -2
- package/lib/components/features/documents/TMRelationViewer.d.ts +1 -0
- package/lib/components/features/documents/TMRelationViewer.js +15 -17
- package/lib/components/features/documents/copyAndMergeDcmtsShared.js +0 -1
- package/lib/components/features/documents/mergePdfUtils.js +18 -10
- package/package.json +1 -1
|
@@ -108,8 +108,10 @@ const TMMergeToPdfForm = (props) => {
|
|
|
108
108
|
});
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
|
-
// Mappa per lookup veloce di FILECOUNT e FILEEXT
|
|
112
|
-
const fileInfoMap = new Map(
|
|
111
|
+
// Mappa per lookup veloce di FILECOUNT e FILEEXT
|
|
112
|
+
const fileInfoMap = new Map(showTMRelationViewer
|
|
113
|
+
? selectedItemsRelationViewer.map(d => [`${d.tid}_${d.did}`, { fileExt: d.fileExt ?? null, fileCount: d.fileCount ?? null }])
|
|
114
|
+
: selectedItemsFull.map(d => [`${d.TID}_${d.DID}`, { fileExt: d.FILEEXT, fileCount: d.FILECOUNT }]));
|
|
113
115
|
// Mappa per i risultati: mantiene l'ordine originale
|
|
114
116
|
const pdfFilesMap = new Map();
|
|
115
117
|
// Identifica documenti di soli metadati e documenti con file
|
|
@@ -309,6 +309,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
309
309
|
hidden: false,
|
|
310
310
|
name: row?.SYS_Abstract?.value || row?.SYS_SUBJECT?.value || `Documento ${did}`,
|
|
311
311
|
fileExt: row?.FILEEXT?.value,
|
|
312
|
+
fileCount: row?.FILECOUNT?.value,
|
|
312
313
|
// Note: Recursive loading on expansion is handled by calculateItemsForNode
|
|
313
314
|
});
|
|
314
315
|
}
|
|
@@ -318,7 +319,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
catch (error) {
|
|
321
|
-
console.error('
|
|
322
|
+
console.error('Error loading detail documents:', error);
|
|
322
323
|
}
|
|
323
324
|
return items;
|
|
324
325
|
}, [allowedTIDs]);
|
|
@@ -393,6 +394,7 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
393
394
|
values: row,
|
|
394
395
|
searchResult: [searchResult],
|
|
395
396
|
fileExt: row?.FILEEXT?.value,
|
|
397
|
+
fileCount: row?.FILECOUNT?.value,
|
|
396
398
|
// Leave items and itemsCount undefined so TMTreeView shows expand arrow based on isExpandible
|
|
397
399
|
// Children will be loaded lazily by calculateItemsForNode when expanded
|
|
398
400
|
expanded: false,
|
|
@@ -513,16 +515,8 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
513
515
|
expanded: true,
|
|
514
516
|
isRoot: true
|
|
515
517
|
};
|
|
516
|
-
//
|
|
517
|
-
|
|
518
|
-
const containerChildren = docItems?.filter(child => child.isContainer) ?? [];
|
|
519
|
-
if (containerChildren.length === 1 && docItems && docItems.length > 0 && docItems[0].isContainer) {
|
|
520
|
-
const newFirstCorrelation = { ...docItems[0], expanded: true };
|
|
521
|
-
newFirstDoc = {
|
|
522
|
-
...newFirstDoc,
|
|
523
|
-
items: [newFirstCorrelation, ...docItems.slice(1)]
|
|
524
|
-
};
|
|
525
|
-
}
|
|
518
|
+
// NOTE: Le cartelle di correlazione rimangono con expanded: false.
|
|
519
|
+
// Verranno espanse solo tramite il pulsante "espandi n livelli" o espansione manuale.
|
|
526
520
|
// Update the container's items
|
|
527
521
|
newContainer = {
|
|
528
522
|
...newContainer,
|
|
@@ -531,11 +525,11 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
531
525
|
}
|
|
532
526
|
else if (firstDocOrContainer.isContainer) {
|
|
533
527
|
// First item is a container (correlation folder)
|
|
534
|
-
|
|
535
|
-
|
|
528
|
+
// NOTE: Le cartelle di correlazione rimangono con expanded: false.
|
|
529
|
+
// Verranno espanse solo tramite il pulsante "espandi n livelli" o espansione manuale.
|
|
536
530
|
let newFirstCorrelation = {
|
|
537
531
|
...firstDocOrContainer,
|
|
538
|
-
expanded:
|
|
532
|
+
expanded: false
|
|
539
533
|
};
|
|
540
534
|
// Find first document inside this container and mark for focus
|
|
541
535
|
const correlationItems = newFirstCorrelation.items;
|
|
@@ -725,7 +719,8 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
725
719
|
searchResult: result ? [result] : [],
|
|
726
720
|
items: relatedDocs,
|
|
727
721
|
itemsCount: relatedDocs.length,
|
|
728
|
-
fileExt: docRow?.FILEEXT?.value
|
|
722
|
+
fileExt: docRow?.FILEEXT?.value,
|
|
723
|
+
fileCount: docRow?.FILECOUNT?.value
|
|
729
724
|
};
|
|
730
725
|
// Check if a type container for this TID already exists in the tree
|
|
731
726
|
const existingContainer = tree.find(c => c.tid === dcmt.TID && c.isContainer);
|
|
@@ -1276,6 +1271,8 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
1276
1271
|
/**
|
|
1277
1272
|
* Recursively set the `expanded` property on every node that has children loaded.
|
|
1278
1273
|
* Nodes without `items` are left untouched (will be loaded lazily on user click).
|
|
1274
|
+
* NOTE: Solo i nodi con figli già caricati (isLoaded o hasChildren) vengono espansi.
|
|
1275
|
+
* I nodi con isExpandible ma senza figli caricati rimangono chiusi.
|
|
1279
1276
|
*/
|
|
1280
1277
|
const setExpandedRecursively = useCallback((nodes, expanded) => {
|
|
1281
1278
|
if (!nodes || !Array.isArray(nodes))
|
|
@@ -1283,8 +1280,9 @@ const TMRelationViewer = ({ inputDcmts, isForMaster = false, showCurrentDcmtIndi
|
|
|
1283
1280
|
return nodes.map(node => {
|
|
1284
1281
|
const hasChildren = Array.isArray(node.items) && node.items.length > 0;
|
|
1285
1282
|
const newItems = hasChildren ? setExpandedRecursively(node.items, expanded) : node.items;
|
|
1286
|
-
// Only toggle expansion if the node
|
|
1287
|
-
|
|
1283
|
+
// Only toggle expansion if the node has children already loaded.
|
|
1284
|
+
// Nodes with isExpandible but no loaded children stay collapsed (will be loaded lazily).
|
|
1285
|
+
const canExpand = hasChildren || node.isLoaded;
|
|
1288
1286
|
return { ...node, expanded: canExpand ? expanded : node.expanded, items: newItems };
|
|
1289
1287
|
});
|
|
1290
1288
|
}, []);
|
|
@@ -224,7 +224,6 @@ export const generateTargetFileName = async (file, dcmtInfo, options) => {
|
|
|
224
224
|
case 'onlyCustomMetadata': {
|
|
225
225
|
try {
|
|
226
226
|
const filteredMetadata = await getFilteredMetadata(dcmtInfo.TID, dcmtInfo.DID, separatorChar);
|
|
227
|
-
console.log("filteredMetadata for TID:", dcmtInfo.TID, "DID:", dcmtInfo.DID, "is", filteredMetadata);
|
|
228
227
|
if (filteredMetadata) {
|
|
229
228
|
if (fileNamingMode === 'documentTypeAndCustomMetadata') {
|
|
230
229
|
const typeName = await getTypeName(dcmtInfo.TID);
|
|
@@ -17,11 +17,15 @@ export const isMetadataOnlyDcmt = (fileExt, fileCount) => {
|
|
|
17
17
|
* @param showTMRelationViewer - Se true, usa selectedItemsRelationViewer, altrimenti selectedDcmtInfos
|
|
18
18
|
*/
|
|
19
19
|
export const getMergePdfSelectionStats = (selectedDcmtInfos, selectedItemsFull, selectedItemsRelationViewer, showTMRelationViewer) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Pre-calcola info documenti selezionati in base alla sorgente dati:
|
|
22
|
+
* - RelationViewer (showTMRelationViewer=true): usa IRelatedDcmt con itemsCount/fileExt
|
|
23
|
+
* - Griglia documenti (showTMRelationViewer=false): usa DcmtInfo + lookup FILECOUNT da selectedItemsFull
|
|
24
|
+
*/
|
|
25
|
+
let docs;
|
|
26
|
+
if (showTMRelationViewer) {
|
|
27
|
+
// Sorgente: RelationViewer - itemsCount e fileExt disponibili direttamente su IRelatedDcmt
|
|
28
|
+
docs = selectedItemsRelationViewer
|
|
25
29
|
.filter(i => i.isDcmt)
|
|
26
30
|
.map(i => {
|
|
27
31
|
const ext = i.fileExt ?? undefined;
|
|
@@ -30,21 +34,25 @@ export const getMergePdfSelectionStats = (selectedDcmtInfos, selectedItemsFull,
|
|
|
30
34
|
ext,
|
|
31
35
|
isPdf: isPdfExt(ext),
|
|
32
36
|
isConvertible: isConvertibleToPdfExt(ext),
|
|
33
|
-
isMetadataOnly: isMetadataOnlyDcmt(ext,
|
|
37
|
+
isMetadataOnly: isMetadataOnlyDcmt(ext, i.fileCount)
|
|
34
38
|
};
|
|
35
|
-
})
|
|
36
|
-
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Sorgente: Griglia documenti - FILECOUNT richiede lookup da selectedItemsFull
|
|
43
|
+
const fileCountMap = new Map(selectedItemsFull.map(d => [`${d.TID}_${d.DID}`, d.FILECOUNT]));
|
|
44
|
+
docs = selectedDcmtInfos.map(d => {
|
|
37
45
|
const ext = d.FILEEXT ?? undefined;
|
|
38
46
|
const key = `${d.TID}_${d.DID}`;
|
|
39
|
-
const fileCount = fileCountMap.get(key);
|
|
40
47
|
return {
|
|
41
48
|
key,
|
|
42
49
|
ext,
|
|
43
50
|
isPdf: isPdfExt(ext),
|
|
44
51
|
isConvertible: isConvertibleToPdfExt(ext),
|
|
45
|
-
isMetadataOnly: isMetadataOnlyDcmt(ext,
|
|
52
|
+
isMetadataOnly: isMetadataOnlyDcmt(ext, fileCountMap.get(key))
|
|
46
53
|
};
|
|
47
54
|
});
|
|
55
|
+
}
|
|
48
56
|
// Elementi convertibili: file con estensione convertibile (esclusi documenti di soli metadati)
|
|
49
57
|
const convertibleSelectedItems = docs
|
|
50
58
|
.filter(i => i.isConvertible && !i.isMetadataOnly)
|