@topconsultnpm/sdkui-react 6.20.0-dev2.14 → 6.20.0-dev2.15
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/choosers/TMDynDataListItemChooser.js +11 -6
- package/lib/components/editors/TMMetadataValues.js +3 -1
- package/lib/components/features/documents/TMDcmtForm.js +12 -7
- package/lib/components/features/search/TMSearchResult.js +47 -39
- package/lib/hooks/useDcmtOperations.js +16 -2
- package/lib/hooks/useRelatedDocuments.js +34 -11
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ import TMChooserForm from '../forms/TMChooserForm';
|
|
|
9
9
|
import { TMColors } from '../../utils/theme';
|
|
10
10
|
import TMTooltip from '../base/TMTooltip';
|
|
11
11
|
import { FormulaHelper } from '../editors/TMFormulaEditor';
|
|
12
|
+
import { TMExceptionBoxManager } from '../base/TMPopUp';
|
|
12
13
|
const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChooserBySingleClick, readOnly, layoutMode = LayoutModes.None, queryParamsDynDataList, buttons = [], backgroundColor, showBorder = true, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], icon, labelColor, showClearButton, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs, updateIsModalOpen }) => {
|
|
13
14
|
const [showChooser, setShowChooser] = useState(false);
|
|
14
15
|
const [dynDl, setDynDl] = useState();
|
|
@@ -30,7 +31,9 @@ const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChoo
|
|
|
30
31
|
setDynDl(d);
|
|
31
32
|
if (!IsParametricQuery(d?.qd) && !dataSource) {
|
|
32
33
|
setDataSource(undefined);
|
|
33
|
-
loadData()
|
|
34
|
+
loadData()
|
|
35
|
+
.then((result) => { setDataSource(result); })
|
|
36
|
+
.catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
|
|
34
37
|
}
|
|
35
38
|
}, [md]);
|
|
36
39
|
useEffect(() => {
|
|
@@ -42,12 +45,13 @@ const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChoo
|
|
|
42
45
|
setDataSource(undefined);
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
|
-
loadData()
|
|
46
|
-
setDataSource(result);
|
|
47
|
-
|
|
48
|
+
loadData()
|
|
49
|
+
.then((result) => { setDataSource(result); })
|
|
50
|
+
.catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
|
|
48
51
|
}, [queryParamsDynDataList, dynDl]);
|
|
49
52
|
const loadData = async () => {
|
|
50
|
-
return await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, md?.id, layoutMode, queryParamsDynDataList ?? [])
|
|
53
|
+
return await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, md?.id, layoutMode, queryParamsDynDataList ?? [])
|
|
54
|
+
.catch((err) => { throw err; });
|
|
51
55
|
};
|
|
52
56
|
const getDescription = () => {
|
|
53
57
|
if (!Array.isArray(values))
|
|
@@ -152,7 +156,8 @@ export const TMDynDataListItemChooserForm = (props) => {
|
|
|
152
156
|
if (refreshCache)
|
|
153
157
|
DataListCacheService.RemoveAll();
|
|
154
158
|
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
|
|
155
|
-
let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(props.TID, props.MID, props.layoutMode, [])
|
|
159
|
+
let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(props.TID, props.MID, props.layoutMode, [])
|
|
160
|
+
.catch((err) => { TMSpinner.hide(); TMExceptionBoxManager.show({ exception: err }); });
|
|
156
161
|
TMSpinner.hide();
|
|
157
162
|
return result ? searchResultDescriptorToSimpleArray(result) ?? [] : [];
|
|
158
163
|
};
|
|
@@ -14,6 +14,7 @@ import { ChronologyMIDs, DraftsMIDs, DSAttachsMIDs } from "../../ts";
|
|
|
14
14
|
import { TMNothingToShow } from "../features/documents/TMDcmtPreview";
|
|
15
15
|
import TMAccordion from "../base/TMAccordion";
|
|
16
16
|
import TabPanel, { Item } from 'devextreme-react/tab-panel';
|
|
17
|
+
import { TMExceptionBoxManager } from "../base/TMPopUp";
|
|
17
18
|
export var ShowCheckBoxesMode;
|
|
18
19
|
(function (ShowCheckBoxesMode) {
|
|
19
20
|
ShowCheckBoxesMode[ShowCheckBoxesMode["Never"] = 0] = "Never";
|
|
@@ -165,7 +166,8 @@ const TMMetadataValues = ({ showCheckBoxes = ShowCheckBoxesMode.Never, checkPerm
|
|
|
165
166
|
if (!d)
|
|
166
167
|
return;
|
|
167
168
|
let toBeRefreshed = [];
|
|
168
|
-
let dynDlDataSource = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, mid, layoutMode, qParams)
|
|
169
|
+
let dynDlDataSource = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, mid, layoutMode, qParams)
|
|
170
|
+
.catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
|
|
169
171
|
if (!d.onValueChanged_DynDataListsToBeRefreshed)
|
|
170
172
|
return;
|
|
171
173
|
let row = dynDlDataSource?.dtdResult?.rows?.filter(o => o[d.selectItemForValue ?? 0] == value);
|
|
@@ -123,6 +123,10 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
123
123
|
const [refreshBlogTrigger, setRefreshBlogTrigger] = useState(0);
|
|
124
124
|
const [wfError, setWfError] = useState(null);
|
|
125
125
|
const [metadataDcmtOrigin, setMetadataDcmtOrigin] = useState(null);
|
|
126
|
+
const isReadOnlyOriginCallback = useCallback((fromTID) => {
|
|
127
|
+
return layoutMode !== LayoutModes.Ark && layoutMode !== LayoutModes.ArkFromBasket && layoutMode !== LayoutModes.ArkFromFile && layoutMode !== LayoutModes.ArkFromMail
|
|
128
|
+
&& fromTID?.toString() !== TID?.toString();
|
|
129
|
+
}, [layoutMode, TID]);
|
|
126
130
|
const triggerBlogRefresh = useCallback(async () => {
|
|
127
131
|
setRefreshBlogTrigger(prev => prev + 1);
|
|
128
132
|
}, []);
|
|
@@ -194,7 +198,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
194
198
|
let dtd = res?.dtdResult;
|
|
195
199
|
let rows = dtd.rows ? dtd.rows[0] : [];
|
|
196
200
|
let mids = res?.selectMIDs;
|
|
197
|
-
let metadataList = searchResultToMetadataValues(TID, dtd, rows, mids, mdList, layoutMode, origin.fromTID
|
|
201
|
+
let metadataList = searchResultToMetadataValues(TID, dtd, rows, mids, mdList, layoutMode, isReadOnlyOriginCallback(origin.fromTID));
|
|
198
202
|
if (archived) {
|
|
199
203
|
// Usa setFormData con funzione callback per accedere allo stato precedente
|
|
200
204
|
// invece di dipendere da formDataOrig nell'array di dipendenze
|
|
@@ -282,7 +286,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
282
286
|
}
|
|
283
287
|
else {
|
|
284
288
|
const renderedMetadata = dtd?.metadata?.filter((metadata) => handleArchiveVisibility(metadata)) ?? [];
|
|
285
|
-
const metadataList = searchResultToMetadataValues(dtd?.id, undefined, [], [], renderedMetadata, layoutMode, metadataDcmtOrigin?.fromTID
|
|
289
|
+
const metadataList = searchResultToMetadataValues(dtd?.id, undefined, [], [], renderedMetadata, layoutMode, isReadOnlyOriginCallback(metadataDcmtOrigin?.fromTID));
|
|
286
290
|
setFormDataOrig(structuredClone(metadataList));
|
|
287
291
|
setFormData(structuredClone(metadataList));
|
|
288
292
|
formDataOrigRef.current = structuredClone(metadataList);
|
|
@@ -297,7 +301,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
297
301
|
setIsInitialLoading(false);
|
|
298
302
|
setIsNavigating(false);
|
|
299
303
|
}
|
|
300
|
-
}, [TID, DID, layoutMode, inputFile, setMetadataList, handleReset, allowButtonsRefs, metadataDcmtOrigin?.fromTID]);
|
|
304
|
+
}, [TID, DID, layoutMode, inputFile, setMetadataList, handleReset, allowButtonsRefs, isReadOnlyOriginCallback, metadataDcmtOrigin?.fromTID]);
|
|
301
305
|
const createChange = useCallback((mid, metadataType, modifiedValue) => {
|
|
302
306
|
return { mid, metadataType, modifiedValue };
|
|
303
307
|
}, []);
|
|
@@ -1216,7 +1220,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
1216
1220
|
}, [formData, fromDTD, isMobile]);
|
|
1217
1221
|
const tmDcmtForm = useMemo(() => {
|
|
1218
1222
|
return _jsxs(_Fragment, { children: [checkoutBadge && _jsx("div", { style: { padding: '10px', display: 'flex', justifyContent: 'center' }, children: checkoutBadge }), metadataValuesSource.length > 0 &&
|
|
1219
|
-
_jsxs(StyledToolbarCardContainer, { children: [_jsx(TMMetadataValues, { TID: TID, metadataValues: metadataValuesSource, metadataValuesOrig: metadataValuesSourceOrig, isExpertMode: isExpertMode, isOpenDistinctValues: isOpenDistinctValues, openChooserBySingleClick: !isOpenDistinctValues, selectedMID: focusedMetadataValue?.mid, isReadOnly: formMode === FormModes.ReadOnly, layoutMode: layoutMode, deviceType: deviceType, validationItems: validationItems, inputMids: inputMids, layout: layout, isReadOnlyOrigin: metadataDcmtOrigin?.fromTID
|
|
1223
|
+
_jsxs(StyledToolbarCardContainer, { children: [_jsx(TMMetadataValues, { TID: TID, metadataValues: metadataValuesSource, metadataValuesOrig: metadataValuesSourceOrig, isExpertMode: isExpertMode, isOpenDistinctValues: isOpenDistinctValues, openChooserBySingleClick: !isOpenDistinctValues, selectedMID: focusedMetadataValue?.mid, isReadOnly: formMode === FormModes.ReadOnly, layoutMode: layoutMode, deviceType: deviceType, validationItems: validationItems, inputMids: inputMids, layout: layout, isReadOnlyOrigin: isReadOnlyOriginCallback(metadataDcmtOrigin?.fromTID), onFocusedItemChanged: (item) => { (item?.mid !== focusedMetadataValue?.mid) && setFocusedMetadataValue(item); }, onValueChanged: (newItems) => {
|
|
1220
1224
|
setFormData((prevItems) => prevItems.map((item) => {
|
|
1221
1225
|
const newItem = newItems.find((newItem) => newItem.tid === item.tid && newItem.mid === item.mid);
|
|
1222
1226
|
return newItem ? { ...item, ...newItem } : item;
|
|
@@ -1262,7 +1266,8 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
1262
1266
|
handleConfirmAction,
|
|
1263
1267
|
handleUndo,
|
|
1264
1268
|
handleClearForm,
|
|
1265
|
-
|
|
1269
|
+
isReadOnlyOriginCallback,
|
|
1270
|
+
metadataDcmtOrigin?.fromTID,
|
|
1266
1271
|
]);
|
|
1267
1272
|
const tmBlog = useMemo(() => _jsx(TMDcmtBlog, { tid: TID, did: DID, allTasks: allTasks, fetchBlogDataTrigger: refreshBlogTrigger, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), [TID, DID, allTasks, refreshBlogTrigger, handleNavigateToWGs, handleNavigateToDossiers]);
|
|
1268
1273
|
const tmSysMetadata = useMemo(() => _jsx(TMMetadataValues, { layoutMode: layoutMode, openChooserBySingleClick: !isOpenDistinctValues, TID: TID, isReadOnly: true, deviceType: deviceType, metadataValues: formData.filter(o => (o.mid != undefined && o.mid <= 100)), metadataValuesOrig: formData.filter(o => (o.mid != undefined && o.mid <= 100)), validationItems: [], inputMids: inputMids }), [TID, layoutMode, formData, deviceType, inputMids]);
|
|
@@ -1384,7 +1389,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
1384
1389
|
const { assignedToMe, assignedByMe } = getDcmtTasksCounter(TID, DID, allTasks);
|
|
1385
1390
|
let titleDcmtFormPanel = fromDTD?.nameLoc ?? "";
|
|
1386
1391
|
// Caso: Il documento proviene da un'origine esterna
|
|
1387
|
-
if (metadataDcmtOrigin?.fromTID
|
|
1392
|
+
if (isReadOnlyOriginCallback(metadataDcmtOrigin?.fromTID)) {
|
|
1388
1393
|
titleDcmtFormPanel = (_jsxs("div", { style: { display: 'inline-flex', alignItems: 'center', gap: '4px' }, children: [_jsx(TMTooltip, { content: _jsxs("div", { style: { textAlign: 'left' }, children: [_jsx("p", { children: "Questo documento proviene da un'altra origine e non pu\u00F2 essere modificato." }), _jsx("hr", {}), _jsxs("p", { children: [_jsx("strong", { children: "TID corrente:" }), " ", TID?.toString()] }), _jsxs("p", { children: [_jsx("strong", { children: "Nome corrente:" }), " ", fromDTD?.nameLoc] }), _jsx("hr", {}), _jsxs("p", { children: [_jsx("strong", { children: "TID origine:" }), " ", metadataDcmtOrigin?.fromTID?.toString()] }), _jsxs("p", { children: [_jsx("strong", { children: "Nome origine:" }), " ", metadataDcmtOrigin?.fromName] })] }), children: _jsx(IconLock, { fontSize: 16, style: { alignSelf: 'center' } }) }), metadataDcmtOrigin?.fromName] }));
|
|
1389
1394
|
}
|
|
1390
1395
|
const panels = [
|
|
@@ -1468,7 +1473,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
1468
1473
|
},
|
|
1469
1474
|
];
|
|
1470
1475
|
return panels;
|
|
1471
|
-
}, [fromDTD, showBackButton, tmDcmtForm, tmBlog, tmSysMetadata, tmDcmtPreview, tmWF, tmDcmtTasks, isPreviewDisabled, isSysMetadataDisabled, isBoardDisabled, isWFDisabled, inputFile, isClosable, allTasks, DID, TID, metadataDcmtOrigin?.fromTID]);
|
|
1476
|
+
}, [fromDTD, showBackButton, tmDcmtForm, tmBlog, tmSysMetadata, tmDcmtPreview, tmWF, tmDcmtTasks, isPreviewDisabled, isSysMetadataDisabled, isBoardDisabled, isWFDisabled, inputFile, isClosable, allTasks, DID, TID, isReadOnlyOriginCallback, metadataDcmtOrigin?.fromTID]);
|
|
1472
1477
|
// Retrieves the current document form setting based on the normalized TID
|
|
1473
1478
|
const getCurrentDcmtFormSetting = () => {
|
|
1474
1479
|
const settings = SDKUI_Globals.userSettings.dcmtFormSettings;
|
|
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
3
3
|
import { SDK_Globals, DataColumnTypes, MetadataDataDomains, DataListViewModes, MetadataFormats, LayoutModes, DcmtTypeListCacheService, SystemMIDsAsNumber, RetrieveFileOptions, DcmtOpers, GeneralRetrieveFormats, AccessLevelsEx, LayoutCacheService, UserListCacheService, AppModules } 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, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, deepCompare, generateUniqueColumnKeys, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, TMImageLibrary, convertSearchResultDescriptorToFileItems, IconCustom, isApprovalWorkflowView, SDKUI_Globals, getMoreInfoTasksForDocument,
|
|
6
|
+
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, deepCompare, generateUniqueColumnKeys, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, TMImageLibrary, convertSearchResultDescriptorToFileItems, IconCustom, isApprovalWorkflowView, SDKUI_Globals, getMoreInfoTasksForDocument, IconCache, IconPlatform, getSearchToolbarVisibility } from '../../../helper';
|
|
7
7
|
import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
|
|
8
8
|
import { useInputAttachmentsDialog, useInputCvtFormatDialog } from '../../../hooks/useInputDialog';
|
|
9
9
|
import { useRelatedDocuments } from '../../../hooks/useRelatedDocuments';
|
|
@@ -101,7 +101,6 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
101
101
|
const [indexingInfoCache, setIndexingInfoCache] = useState(new Map());
|
|
102
102
|
const [showIndexingInfo, setShowIndexingInfo] = useState(false);
|
|
103
103
|
const [loadingIndexingInfo, setLoadingIndexingInfo] = useState(false);
|
|
104
|
-
const [openedDrawerItems, setOpenedDrawerItems] = useState(new Set());
|
|
105
104
|
const floatingBarContainerRef = useRef(null);
|
|
106
105
|
const [confirmFormat, ConfirmFormatDialog] = useInputCvtFormatDialog();
|
|
107
106
|
const { openConfirmAttachmentsDialog, ConfirmAttachmentsDialog } = useInputAttachmentsDialog();
|
|
@@ -737,38 +736,47 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
737
736
|
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, handleNavigateToWGs, handleNavigateToDossiers]);
|
|
738
737
|
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]);
|
|
739
738
|
const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt }, refreshPreviewTrigger), [currentDcmt, refreshPreviewTrigger]);
|
|
739
|
+
// Auto-fetch indexing info when drawer is open and focusedItem changes
|
|
740
740
|
useEffect(() => {
|
|
741
|
-
if (!focusedItem)
|
|
741
|
+
if (!focusedItem || !showIndexingInfo)
|
|
742
742
|
return;
|
|
743
743
|
const cacheKey = `${focusedItem.TID}-${focusedItem.DID}`;
|
|
744
|
-
|
|
745
|
-
|
|
744
|
+
if (!indexingInfoCache.has(cacheKey)) {
|
|
745
|
+
const fetchData = async () => {
|
|
746
|
+
try {
|
|
747
|
+
setLoadingIndexingInfo(true);
|
|
748
|
+
const msg = await SDK_Globals.tmSession?.NewSearchEngine().FreeSearchGetDcmtInfoAsync(focusedItem.TID, focusedItem.DID);
|
|
749
|
+
setIndexingInfoCache(prev => new Map(prev).set(cacheKey, msg ?? ''));
|
|
750
|
+
}
|
|
751
|
+
catch (e) {
|
|
752
|
+
TMExceptionBoxManager.show({ exception: e });
|
|
753
|
+
}
|
|
754
|
+
finally {
|
|
755
|
+
setLoadingIndexingInfo(false);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
fetchData();
|
|
759
|
+
}
|
|
760
|
+
}, [focusedItem, showIndexingInfo]);
|
|
746
761
|
const handleToggleIndexingInfo = async () => {
|
|
747
762
|
if (!focusedItem)
|
|
748
763
|
return;
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
setIndexingInfoCache(prev => new Map(prev).set(cacheKey, msg ?? ''));
|
|
766
|
-
}
|
|
767
|
-
catch (e) {
|
|
768
|
-
TMExceptionBoxManager.show({ exception: e });
|
|
769
|
-
}
|
|
770
|
-
finally {
|
|
771
|
-
setLoadingIndexingInfo(false);
|
|
764
|
+
const newShowState = !showIndexingInfo;
|
|
765
|
+
setShowIndexingInfo(newShowState);
|
|
766
|
+
if (newShowState) {
|
|
767
|
+
const cacheKey = `${focusedItem.TID}-${focusedItem.DID}`;
|
|
768
|
+
if (!indexingInfoCache.has(cacheKey)) {
|
|
769
|
+
try {
|
|
770
|
+
setLoadingIndexingInfo(true);
|
|
771
|
+
const msg = await SDK_Globals.tmSession?.NewSearchEngine().FreeSearchGetDcmtInfoAsync(focusedItem.TID, focusedItem.DID);
|
|
772
|
+
setIndexingInfoCache(prev => new Map(prev).set(cacheKey, msg ?? ''));
|
|
773
|
+
}
|
|
774
|
+
catch (e) {
|
|
775
|
+
TMExceptionBoxManager.show({ exception: e });
|
|
776
|
+
}
|
|
777
|
+
finally {
|
|
778
|
+
setLoadingIndexingInfo(false);
|
|
779
|
+
}
|
|
772
780
|
}
|
|
773
781
|
}
|
|
774
782
|
};
|
|
@@ -806,21 +814,21 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
806
814
|
}
|
|
807
815
|
const cacheKey = `${focusedItem.TID}-${focusedItem.DID}`;
|
|
808
816
|
const cachedInfo = indexingInfoCache.get(cacheKey);
|
|
809
|
-
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden', width: '100%' }, children: [_jsx("div", { style: { padding: '10px', overflow: 'auto', flex: 1 }, children: _jsx("div", { dangerouslySetInnerHTML: { __html: ftExplanation } }) }), _jsxs(StyledIndexingInfoSection, { children: [_jsxs(StyledIndexingToggle, { onClick: handleToggleIndexingInfo, disabled: loadingIndexingInfo, children: [_jsxs(StyledLeftContent, { children: [_jsx(
|
|
810
|
-
}, [selectedSearchResult, focusedItem, indexingInfoCache, showIndexingInfo, loadingIndexingInfo]);
|
|
817
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden', width: '100%' }, children: [_jsx("div", { style: { padding: '10px', overflow: 'auto', flex: 1 }, children: _jsx("div", { dangerouslySetInnerHTML: { __html: ftExplanation } }) }), _jsxs(StyledIndexingInfoSection, { children: [_jsxs(StyledIndexingToggle, { onClick: handleToggleIndexingInfo, disabled: loadingIndexingInfo, children: [_jsxs(StyledLeftContent, { children: [_jsx("span", { children: SDKUI_Localizator.IndexingInformation }), cachedInfo && (_jsx(TMTooltip, { content: "Da cache", children: _jsx(StyledCachedIcon, { children: _jsx(IconCache, { fontSize: 13 }) }) }))] }), _jsxs(StyledRightContent, { children: [cachedInfo && (_jsx(TMTooltip, { content: "Aggiorna", children: _jsx(StyledRefreshIcon, { onClick: (e) => { e.stopPropagation(); handleRefreshIndexingInfo(); }, children: _jsx(IconRefresh, {}) }) })), _jsx(StyledChevron, { "$isOpen": showIndexingInfo, children: "\u25BC" })] })] }), loadingIndexingInfo && !cachedInfo && (_jsxs("div", { style: { marginTop: '10px', color: '#666' }, children: [SDKUI_Localizator.Loading, "..."] })), showIndexingInfo && cachedInfo && (_jsxs(StyledIndexingInfoBox, { children: [_jsx("div", { dangerouslySetInnerHTML: { __html: cachedInfo } }), loadingIndexingInfo && (_jsxs("div", { style: { position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', background: 'rgba(255, 255, 255, 0.9)', padding: '10px', borderRadius: '4px', boxShadow: '0 2px 8px rgba(0,0,0,0.15)' }, children: [SDKUI_Localizator.Loading, "..."] }))] }))] })] }));
|
|
818
|
+
}, [selectedSearchResult, focusedItem, indexingInfoCache, showIndexingInfo, loadingIndexingInfo, handleRefreshIndexingInfo]);
|
|
811
819
|
const allInitialPanelVisibility = {
|
|
812
820
|
'tmSearchResult': true,
|
|
813
821
|
'tmBlog': false,
|
|
814
822
|
'tmSysMetadata': false,
|
|
815
|
-
'tmDcmtPreview': false,
|
|
816
823
|
'tmFullTextSearch': false,
|
|
824
|
+
'tmDcmtPreview': false,
|
|
817
825
|
};
|
|
818
826
|
const initialPanelDimensions = {
|
|
819
827
|
'tmSearchResult': { width: '25%', height: '100%' },
|
|
820
828
|
'tmBlog': { width: '25%', height: '100%' },
|
|
821
829
|
'tmSysMetadata': { width: '25%', height: '100%' },
|
|
822
|
-
'tmDcmtPreview': { width: '25%', height: '100%' },
|
|
823
830
|
'tmFullTextSearch': { width: '25%', height: '100%' },
|
|
831
|
+
'tmDcmtPreview': { width: '25%', height: '100%' },
|
|
824
832
|
};
|
|
825
833
|
const initialPanels = useMemo(() => [
|
|
826
834
|
{
|
|
@@ -853,12 +861,6 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
853
861
|
contentOptions: { component: tmSysMetadata, panelContainer: { title: SDKUI_Localizator.MetadataSystem, allowMaximize: !isMobile } },
|
|
854
862
|
toolbarOptions: { icon: _jsx(IconDcmtTypeSys, { fontSize: 24 }), visible: getSearchToolbarVisibility(SDK_Globals.tmSession?.SessionDescr?.appModuleID ?? AppModules.SURFER).tmSysMetadata, orderNumber: 3, isActive: allInitialPanelVisibility['tmSysMetadata'] }
|
|
855
863
|
},
|
|
856
|
-
{
|
|
857
|
-
id: 'tmDcmtPreview',
|
|
858
|
-
name: SDKUI_Localizator.PreviewDocument,
|
|
859
|
-
contentOptions: { component: tmDcmtPreview },
|
|
860
|
-
toolbarOptions: { icon: _jsx(IconShow, { fontSize: 24 }), visible: getSearchToolbarVisibility(SDK_Globals.tmSession?.SessionDescr?.appModuleID ?? AppModules.SURFER).tmDcmtPreview, orderNumber: 4, isActive: allInitialPanelVisibility['tmDcmtPreview'] }
|
|
861
|
-
},
|
|
862
864
|
...(context === SearchResultContext.FREE_SEARCH ? [
|
|
863
865
|
{
|
|
864
866
|
id: 'tmFullTextSearch',
|
|
@@ -866,7 +868,13 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
866
868
|
contentOptions: { component: tmFullTextSearch, panelContainer: { title: SDKUI_Localizator.ResultDetails, allowMaximize: !isMobile } },
|
|
867
869
|
toolbarOptions: { icon: _jsx(IconPlatform, { fontSize: 20 }), visible: getSearchToolbarVisibility(SDK_Globals.tmSession?.SessionDescr?.appModuleID ?? AppModules.SURFER).tmFullTextSearch, orderNumber: 5, isActive: allInitialPanelVisibility['tmFullTextSearch'] }
|
|
868
870
|
}
|
|
869
|
-
] : [])
|
|
871
|
+
] : []),
|
|
872
|
+
{
|
|
873
|
+
id: 'tmDcmtPreview',
|
|
874
|
+
name: SDKUI_Localizator.PreviewDocument,
|
|
875
|
+
contentOptions: { component: tmDcmtPreview },
|
|
876
|
+
toolbarOptions: { icon: _jsx(IconShow, { fontSize: 24 }), visible: getSearchToolbarVisibility(SDK_Globals.tmSession?.SessionDescr?.appModuleID ?? AppModules.SURFER).tmDcmtPreview, orderNumber: 4, isActive: allInitialPanelVisibility['tmDcmtPreview'] }
|
|
877
|
+
}
|
|
870
878
|
], [tmSearchResult, tmBlog, tmSysMetadata, tmDcmtPreview, tmFullTextSearch, showToolbarHeader, context, isMobile]);
|
|
871
879
|
return (_jsxs(StyledMultiViewPanel, { "$isVisible": isVisible, children: [_jsx(StyledMultiViewPanel, { "$isVisible": !isOpenDcmtForm && !isOpenDetails && !isOpenMaster, style: {
|
|
872
880
|
display: 'flex',
|
|
@@ -8,6 +8,20 @@ import { useFileDialog } from './useInputDialog';
|
|
|
8
8
|
import { isXMLFileExt } from '../helper/dcmtsHelper';
|
|
9
9
|
import { ShowConfirm } from '../components/base/TMConfirm';
|
|
10
10
|
let abortController = new AbortController();
|
|
11
|
+
const downloadCountMap = new Map();
|
|
12
|
+
const compoundExts = ['.p7m', '.p7s', '.p7c', '.p7b'];
|
|
13
|
+
const getDownloadFileName = (fileName) => {
|
|
14
|
+
const lower = fileName.toLowerCase();
|
|
15
|
+
const isCompound = compoundExts.some(ext => lower.endsWith(ext) && lower.slice(0, -ext.length).includes('.'));
|
|
16
|
+
if (!isCompound)
|
|
17
|
+
return fileName;
|
|
18
|
+
const count = downloadCountMap.get(fileName) ?? 0;
|
|
19
|
+
downloadCountMap.set(fileName, count + 1);
|
|
20
|
+
if (count === 0)
|
|
21
|
+
return fileName;
|
|
22
|
+
const dotIndex = fileName.indexOf('.');
|
|
23
|
+
return `${fileName.slice(0, dotIndex)}(${count})${fileName.slice(dotIndex)}`;
|
|
24
|
+
};
|
|
11
25
|
export function useDcmtOperations() {
|
|
12
26
|
const [showWaitPanel, setShowWaitPanel] = useState(false);
|
|
13
27
|
const [waitPanelTitle, setWaitPanelTitle] = useState('');
|
|
@@ -96,8 +110,8 @@ export function useDcmtOperations() {
|
|
|
96
110
|
else {
|
|
97
111
|
const alink2 = document.createElement('a');
|
|
98
112
|
alink2.href = fileURL;
|
|
99
|
-
const
|
|
100
|
-
alink2.download =
|
|
113
|
+
const baseFileName = inputDcmts[i].fileName ?? (inputDcmts[i].FILEEXT ? `${inputDcmts[i].DID}.${inputDcmts[i].FILEEXT}` : file?.name);
|
|
114
|
+
alink2.download = getDownloadFileName(baseFileName);
|
|
101
115
|
alink2.target = "_blank";
|
|
102
116
|
alink2.rel = "noreferrer";
|
|
103
117
|
alink2.click();
|
|
@@ -225,9 +225,6 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
225
225
|
const filterRelationsWithAssociations = (relations) => {
|
|
226
226
|
return relations.filter(rel => rel.associations && rel.associations.length > 0);
|
|
227
227
|
};
|
|
228
|
-
const getRelatedDcmt = async (relation, type) => {
|
|
229
|
-
return await DcmtTypeListCacheService.GetAsync(type === 'detail' ? relation.detailTID : relation.masterTID);
|
|
230
|
-
};
|
|
231
228
|
const showNoRelationsAlert = (type) => {
|
|
232
229
|
ShowAlert({
|
|
233
230
|
message: type === 'detail'
|
|
@@ -282,6 +279,26 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
282
279
|
TMExceptionBoxManager.show({ exception: error });
|
|
283
280
|
}
|
|
284
281
|
}, [mapAssociationsToMids]);
|
|
282
|
+
const filterRelationsByPermission = async (relations, type) => {
|
|
283
|
+
const dataSourcePromises = relations.map(async (rel) => {
|
|
284
|
+
const targetTID = type === 'detail' ? rel.detailTID : rel.masterTID;
|
|
285
|
+
const dtd = await DcmtTypeListCacheService.GetWithNotGrantedAsync(targetTID, undefined);
|
|
286
|
+
const hasPermission = dtd?.perm?.canArchive === AccessLevelsEx.Yes || dtd?.perm?.canArchive === AccessLevelsEx.Mixed;
|
|
287
|
+
return { id: rel?.id, name: dtd?.name, hasPermission, relation: rel };
|
|
288
|
+
});
|
|
289
|
+
const allResults = await Promise.all(dataSourcePromises);
|
|
290
|
+
return allResults.filter(r => r.hasPermission);
|
|
291
|
+
};
|
|
292
|
+
const showNoPermissionAlert = (type) => {
|
|
293
|
+
ShowAlert({
|
|
294
|
+
message: type === 'detail'
|
|
295
|
+
? SDKUI_Localizator.YouDoNotHavePermissionsToArchiveDetailDocumentsOfThisType
|
|
296
|
+
: SDKUI_Localizator.YouDoNotHavePermissionsToArchiveMasterDocumentsOfThisType,
|
|
297
|
+
mode: 'warning',
|
|
298
|
+
title: type === 'detail' ? SDKUI_Localizator.DcmtsDetail : SDKUI_Localizator.DcmtsMaster,
|
|
299
|
+
duration: 5000
|
|
300
|
+
});
|
|
301
|
+
};
|
|
285
302
|
const archiveRelatedDocuments = useCallback(async (tid, type) => {
|
|
286
303
|
try {
|
|
287
304
|
TMSpinner.show({ description: SDKUI_Localizator.Loading });
|
|
@@ -300,14 +317,20 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
300
317
|
}
|
|
301
318
|
setRelatedDcmts(withAssociations);
|
|
302
319
|
if (withAssociations.length > 1) {
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
320
|
+
const permittedResults = await filterRelationsByPermission(withAssociations, type);
|
|
321
|
+
if (permittedResults.length === 0) {
|
|
322
|
+
showNoPermissionAlert(type);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (permittedResults.length === 1) {
|
|
326
|
+
await archiveRelatedDcmtHandler(permittedResults[0].relation, type);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
const dataSource = permittedResults.map(r => ({ id: r.id, name: r.name }));
|
|
330
|
+
setRelatedDcmtsChooserDataSource(dataSource);
|
|
331
|
+
setArchiveType(type);
|
|
332
|
+
setShowRelatedDcmtsChooser(true);
|
|
333
|
+
}
|
|
311
334
|
}
|
|
312
335
|
else {
|
|
313
336
|
await archiveRelatedDcmtHandler(withAssociations[0], type);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topconsultnpm/sdkui-react",
|
|
3
|
-
"version": "6.20.0-dev2.
|
|
3
|
+
"version": "6.20.0-dev2.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"lib"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@topconsultnpm/sdk-ts": "6.20.0-dev2.
|
|
43
|
+
"@topconsultnpm/sdk-ts": "6.20.0-dev2.3",
|
|
44
44
|
"buffer": "^6.0.3",
|
|
45
45
|
"devextreme": "25.2.4",
|
|
46
46
|
"devextreme-react": "25.2.4",
|