@topconsultnpm/sdkui-react 6.19.0-dev1.44 → 6.19.0-dev1.45
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/archive/TMArchive.js +12 -12
- package/lib/components/features/documents/TMDcmtForm.d.ts +1 -1
- package/lib/components/features/documents/TMDcmtForm.js +3 -2
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +1 -1
- package/lib/components/features/search/TMSearchQueryPanel.js +26 -4
- package/package.json +1 -1
|
@@ -30,7 +30,10 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
|
|
|
30
30
|
}, [inputTID, mruTIDs]);
|
|
31
31
|
useEffect(() => {
|
|
32
32
|
pendingMidsRef.current = inputMids;
|
|
33
|
-
|
|
33
|
+
if (currentTID && currentTID > 0 && inputMids && inputMids.length > 0) {
|
|
34
|
+
setCurrentInputMids(inputMids);
|
|
35
|
+
}
|
|
36
|
+
}, [inputMids, currentTID]);
|
|
34
37
|
useEffect(() => {
|
|
35
38
|
if (!currentTID || currentTID <= 0) {
|
|
36
39
|
previousTIDRef.current = currentTID;
|
|
@@ -42,20 +45,16 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
|
|
|
42
45
|
setFromDTD(dtd);
|
|
43
46
|
});
|
|
44
47
|
if (previousTIDRef.current !== undefined && previousTIDRef.current > 0 && previousTIDRef.current !== currentTID) {
|
|
48
|
+
if (!isSharedArchive) {
|
|
49
|
+
setCurrentInputMids([]);
|
|
50
|
+
}
|
|
45
51
|
if (pendingMidsRef.current && pendingMidsRef.current.length > 0) {
|
|
46
52
|
setCurrentInputMids(pendingMidsRef.current);
|
|
47
53
|
pendingMidsRef.current = null;
|
|
48
54
|
}
|
|
49
|
-
else {
|
|
50
|
-
setCurrentInputMids([]);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else if (pendingMidsRef.current) {
|
|
54
|
-
setCurrentInputMids(pendingMidsRef.current);
|
|
55
|
-
pendingMidsRef.current = null;
|
|
56
55
|
}
|
|
57
56
|
previousTIDRef.current = currentTID;
|
|
58
|
-
}, [currentTID, onDcmtTypeSelect]);
|
|
57
|
+
}, [currentTID, onDcmtTypeSelect, isSharedArchive]);
|
|
59
58
|
const isMobile = deviceType === DeviceType.MOBILE;
|
|
60
59
|
const tmTreeSelectorElement = useMemo(() => _jsx(TMTreeSelectorWrapper, { isMobile: isMobile, isSharedArchive: isSharedArchive, onSelectedTIDChanged: (tid) => {
|
|
61
60
|
setCurrentTID(tid);
|
|
@@ -73,10 +72,11 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
|
|
|
73
72
|
setMruTIDs(newMruTIDS);
|
|
74
73
|
} }), [mruTIDs, currentMruTID, deviceType, isSharedArchive]);
|
|
75
74
|
const tmFormElement = useMemo(() => currentTID ?
|
|
76
|
-
_jsx(TMDcmtForm, { TID: currentTID, DID: currentTID === inputTID ? inputDID : undefined, sharedSourceTID: isSharedArchive ? inputTID : undefined, sharedSourceDID: isSharedArchive ? inputDID : undefined, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, inputFile: inputFile, connectorFileSave: connectorFileSave, onSavedAsyncCallback: onSavedAsyncCallback, inputMids: currentInputMids, enableDragDropOverlay: enableDragDropOverlay, passToSearch: passToSearch ? (outputMids) => {
|
|
75
|
+
_jsx(TMDcmtForm, { TID: currentTID, DID: currentTID === inputTID ? inputDID : undefined, sharedSourceTID: isSharedArchive ? inputTID : undefined, sharedSourceDID: isSharedArchive ? inputDID : undefined, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, inputFile: inputFile, connectorFileSave: connectorFileSave, onSavedAsyncCallback: onSavedAsyncCallback, inputMids: currentInputMids, enableDragDropOverlay: enableDragDropOverlay, passToSearch: passToSearch ? (outputMids, tid) => {
|
|
76
|
+
const tidToUse = tid ?? currentTID;
|
|
77
77
|
if (onDcmtTypeSelect)
|
|
78
|
-
onDcmtTypeSelect(
|
|
79
|
-
passToSearch(
|
|
78
|
+
onDcmtTypeSelect(tidToUse);
|
|
79
|
+
passToSearch(tidToUse, outputMids);
|
|
80
80
|
} : undefined, isSharedDcmt: isSharedArchive }, currentTID)
|
|
81
81
|
:
|
|
82
82
|
_jsx(TMPanel, { title: 'Archiviazione', allowMaximize: false, children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsx(StyledToppyTextContainer, { children: _jsx(StyledToppyText, { children: SDKUI_Localizator.DcmtTypeSelect }) }), _jsx(StyledToppyImage, { src: Logo, alt: 'Toppy' })] }) }), [currentTID, deviceType, mruTIDs, inputFile, currentInputMids, enableDragDropOverlay, isSharedArchive]);
|
|
@@ -291,6 +291,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
|
291
291
|
if (layoutMode !== LayoutModes.Ark)
|
|
292
292
|
return;
|
|
293
293
|
setFocusedMetadataValue(undefined);
|
|
294
|
+
appliedInputMidsRef.current = null;
|
|
294
295
|
}, [fromDTD, layoutMode]);
|
|
295
296
|
useEffect(() => {
|
|
296
297
|
if (!inputMids || inputMids.length === 0)
|
|
@@ -421,8 +422,8 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
|
421
422
|
const outputMids = formData
|
|
422
423
|
.filter(md => md.mid && md.mid > 100 && md.value && md.value.length > 0)
|
|
423
424
|
.map(md => ({ mid: md.mid, value: md.value }));
|
|
424
|
-
passToSearch(outputMids);
|
|
425
|
-
}, [passToSearch, formData]);
|
|
425
|
+
passToSearch(outputMids, TID);
|
|
426
|
+
}, [passToSearch, formData, TID]);
|
|
426
427
|
const isPreviewDisabled = useMemo(() => layoutMode === LayoutModes.Ark && fromDTD?.archiveConstraint === ArchiveConstraints.OnlyMetadata, [layoutMode, fromDTD?.archiveConstraint]);
|
|
427
428
|
const isBoardDisabled = useMemo(() => layoutMode !== LayoutModes.Update || fromDTD?.hasBlog !== 1, [layoutMode, fromDTD?.hasBlog]);
|
|
428
429
|
const isSysMetadataDisabled = useMemo(() => layoutMode !== LayoutModes.Update, [layoutMode]);
|
|
@@ -19,7 +19,7 @@ interface ITMSearchQueryPanelProps {
|
|
|
19
19
|
passToArchiveCallback?: (outputMids: Array<{
|
|
20
20
|
mid: number;
|
|
21
21
|
value: string;
|
|
22
|
-
}
|
|
22
|
+
}>, tid?: number) => void;
|
|
23
23
|
}
|
|
24
24
|
declare const TMSearchQueryPanel: React.FunctionComponent<ITMSearchQueryPanelProps>;
|
|
25
25
|
export default TMSearchQueryPanel;
|
|
@@ -52,7 +52,24 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
52
52
|
pendingMidsRef.current = inputMids ?? null;
|
|
53
53
|
}, [inputMids]);
|
|
54
54
|
useEffect(() => {
|
|
55
|
-
if (!
|
|
55
|
+
if (!fromDTD)
|
|
56
|
+
return;
|
|
57
|
+
// Reset appliedInputMidsRef when TID changes so pending mids can be applied to new TID
|
|
58
|
+
appliedInputMidsRef.current = null;
|
|
59
|
+
const initQd = async () => {
|
|
60
|
+
// Only initialize if qd doesn't exist or is for a different TID
|
|
61
|
+
if (!qd || qd.from?.tid !== fromDTD.id) {
|
|
62
|
+
const newQd = await getQD(fromDTD.id, false);
|
|
63
|
+
if (newQd) {
|
|
64
|
+
setQd(newQd);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
initQd();
|
|
69
|
+
}, [fromDTD?.id]);
|
|
70
|
+
// Apply inputMids when qd is ready and matches fromDTD
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!qd || !fromDTD || qd.from?.tid !== fromDTD.id)
|
|
56
73
|
return;
|
|
57
74
|
const midsToApply = pendingMidsRef.current;
|
|
58
75
|
if (!midsToApply || midsToApply.length === 0)
|
|
@@ -67,6 +84,11 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
67
84
|
}) || [];
|
|
68
85
|
midsToApply.forEach(im => {
|
|
69
86
|
const md = fromDTD.metadata?.find(m => m.id === im.mid);
|
|
87
|
+
// Skip MIDs that don't belong to this TID
|
|
88
|
+
if (!md) {
|
|
89
|
+
console.warn(`MID ${im.mid} does not belong to TID ${fromDTD.id}, skipping`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
70
92
|
const defaultOperator = getDefaultOperator(md?.dataDomain, md?.dataType);
|
|
71
93
|
let existingWi = newWhere.find(wi => wi.mid === im.mid);
|
|
72
94
|
if (existingWi) {
|
|
@@ -85,7 +107,7 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
85
107
|
});
|
|
86
108
|
setQd({ ...qd, where: newWhere });
|
|
87
109
|
setShowAllMdWhere(true);
|
|
88
|
-
}, [qd, fromDTD]);
|
|
110
|
+
}, [qd, fromDTD, inputMids]);
|
|
89
111
|
// Eseguire la ricerca quando shouldSearch è true e qd è definito
|
|
90
112
|
useEffect(() => {
|
|
91
113
|
if (shouldSearch && qd) {
|
|
@@ -200,8 +222,8 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
200
222
|
const outputMids = qd.where
|
|
201
223
|
.filter(wi => wi.mid && wi.value1 && wi.value1.length > 0)
|
|
202
224
|
.map(wi => ({ mid: wi.mid, value: wi.value1 }));
|
|
203
|
-
passToArchiveCallback(outputMids);
|
|
204
|
-
}, [passToArchiveCallback, qd?.where]);
|
|
225
|
+
passToArchiveCallback(outputMids, fromDTD?.id);
|
|
226
|
+
}, [passToArchiveCallback, qd?.where, fromDTD?.id]);
|
|
205
227
|
const handleCloseFiltersConfig = useCallback(() => setShowFiltersConfig(false), []);
|
|
206
228
|
const handleChooseFilters = useCallback((tid_mids) => {
|
|
207
229
|
if (!fromDTD?.metadata)
|