@topconsultnpm/sdkui-react 6.20.0-t3 → 6.20.0
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.
|
@@ -1583,7 +1583,7 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
1583
1583
|
const emptyArchivedDocumentsFileItems = useMemo(() => [], []);
|
|
1584
1584
|
const handleSignApprove = useCallback(() => {
|
|
1585
1585
|
if (onOpenS4TViewerRequest && TID && DID) {
|
|
1586
|
-
onOpenS4TViewerRequest([{ TID, DID }]);
|
|
1586
|
+
onOpenS4TViewerRequest([{ TID, DID }], onClose ? async () => { onClose(); } : undefined);
|
|
1587
1587
|
return;
|
|
1588
1588
|
}
|
|
1589
1589
|
ShowAlert({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { PlatformObjectValidator, QueryDescriptor, WhereItem, SDK_Localizator, OrderByItem, SelectItem, SelectItemVisibilities, SDK_Globals, SavedQueryCacheService, SearchEngine, QueryOperators, AccessLevelsEx } from '@topconsultnpm/sdk-ts';
|
|
3
|
+
import { PlatformObjectValidator, QueryDescriptor, WhereItem, SDK_Localizator, OrderByItem, SelectItem, SelectItemVisibilities, SDK_Globals, SavedQueryCacheService, SearchEngine, QueryOperators, AccessLevelsEx, AccessLevels } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import TMSearchQueryEditor from './TMSearchQueryEditor';
|
|
6
6
|
import { getDcmtTypesByQdAsync, SDKUI_Localizator, getQD, IconMenuVertical, IconAddCircleOutline, IconEdit, IconEasy, IconAdvanced, deepCompare, IconSearch, IconClear, getDefaultOperator, prepareQdForSearchAsync, IsParametricQuery, SDKUI_Globals, IconArrowRight, IconMenuCAArchive, getListMaxItems, DEFAULT_MAX_DCMTS_TO_BE_RETURNED } from '../../../helper';
|
|
@@ -337,9 +337,9 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
337
337
|
gap: '10px',
|
|
338
338
|
width: '100%'
|
|
339
339
|
}, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, width: '90px', caption: SDKUI_Localizator.Search, advancedColor: '#4A96D2', onClick: handleSearchButtonClick }), _jsx(TMButton, { width: '90px', btnStyle: 'advanced', advancedType: 'primary', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), advancedColor: 'white', color: 'primaryOutline', onClick: clearFilters }), (!showAdvancedSearch && qd?.where && qd.where.length > initialMaxItems) && (_jsx(TMButton, { width: '120px', btnStyle: isMobile ? 'icon' : 'advanced', advancedColor: TMColors.button_primary, caption: captionText, showTooltip: false, icon: isMobile ? (_jsx("div", { children: _jsx("p", { children: showAllMdWhere ? `-${diff}` : `+${diff}` }) })) : (_jsx("p", { children: showAllMdWhere ? `-${diff}` : `+${diff}` })), onClick: () => setShowAllMdWhere(!showAllMdWhere) }))] }), showFiltersConfig &&
|
|
340
|
-
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose: handleCloseFiltersConfig, onChoose: handleChooseFilters }), showOutputConfig &&
|
|
341
|
-
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.select?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOutputConfig, onChoose: handleChooseOutput }), showOrderByConfig &&
|
|
342
|
-
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.orderBy?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOrderByConfig, onChoose: handleChooseOrderBy })] })
|
|
340
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, filterMetadata: (o => o.perm?.canSearch === AccessLevels.Yes), qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose: handleCloseFiltersConfig, onChoose: handleChooseFilters }), showOutputConfig &&
|
|
341
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, filterMetadata: (o => o.perm?.canView === AccessLevels.Yes || o.perm?.canUpdate === AccessLevels.Yes), qd: qd, selectedIDs: qd?.select?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOutputConfig, onChoose: handleChooseOutput }), showOrderByConfig &&
|
|
342
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, filterMetadata: (o => o.perm?.canView === AccessLevels.Yes || o.perm?.canUpdate === AccessLevels.Yes), qd: qd, selectedIDs: qd?.orderBy?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOrderByConfig, onChoose: handleChooseOrderBy })] })
|
|
343
343
|
:
|
|
344
344
|
_jsx(TMToppyMessage, { message: SDKUI_Localizator.DcmtTypeSelectOrQuickSearch, titleTooltip: SDKUI_Localizator.DcmtTypeSelectOrQuickSearch }), showSqdForm &&
|
|
345
345
|
_jsx(StyledModalContainer, { style: { backgroundColor: `${TMColors.backgroundColorHeader}12` }, children: _jsx(TMSavedQueryForm, { height: '50%', width: '50%', id: formModeSqdForm === FormModes.Create ? -1 : SQD?.id, title: 'Ricerca rapida', formMode: formModeSqdForm, showBackButton: true, qd: qd, isAdvancedSearch: showAdvancedSearch, isModal: false, onClose: () => { setShowSqdForm(false); }, onSaved: onSqdSaved }) })] }), showDistinctValuesPanel &&
|
|
@@ -272,8 +272,11 @@ const TMTidViewer = ({ tmSession, tid, did, showIcon = false, color, showId = fa
|
|
|
272
272
|
if (count <= 0)
|
|
273
273
|
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.ListDcmtTypeOrView} ...` });
|
|
274
274
|
try {
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
let resultDTD = await DcmtTypeListCacheService.GetAsync(tid);
|
|
276
|
+
if (!resultDTD) {
|
|
277
|
+
resultDTD = await DcmtTypeListCacheService.GetWithNotGrantedAsync(tid, did);
|
|
278
|
+
}
|
|
279
|
+
setDtd(resultDTD);
|
|
277
280
|
}
|
|
278
281
|
finally {
|
|
279
282
|
if (count <= 0)
|
|
@@ -194,29 +194,6 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
194
194
|
setHasManyToManyRelation(false);
|
|
195
195
|
}
|
|
196
196
|
}, [selectedSearchResult?.fromTID]);
|
|
197
|
-
const getFocusedItem = useCallback(() => {
|
|
198
|
-
if (!focusedItem)
|
|
199
|
-
return undefined;
|
|
200
|
-
if (currentSearchResults.length === 1) {
|
|
201
|
-
return { mdList: currentSearchResults[0].dtdResult?.rows?.[focusedItem?.rowIndex ?? 0], mids: currentSearchResults[0].selectMIDs ?? [] };
|
|
202
|
-
}
|
|
203
|
-
const matchingSearchResult = currentSearchResults.find(res => res.fromTID == focusedItem?.TID);
|
|
204
|
-
if (!matchingSearchResult)
|
|
205
|
-
return undefined;
|
|
206
|
-
return {
|
|
207
|
-
mdList: matchingSearchResult.dtdResult?.rows?.[focusedItem?.rowIndex ?? 0],
|
|
208
|
-
mids: matchingSearchResult.selectMIDs ?? []
|
|
209
|
-
};
|
|
210
|
-
}, [focusedItem, currentSearchResults]);
|
|
211
|
-
const fetchAssociatedValues = useCallback((mid) => {
|
|
212
|
-
let mdList = getFocusedItem();
|
|
213
|
-
if (!mdList)
|
|
214
|
-
return;
|
|
215
|
-
let index = mdList.mids.findIndex(m => m == mid);
|
|
216
|
-
if (index === -1)
|
|
217
|
-
return;
|
|
218
|
-
return mdList.mdList?.[index];
|
|
219
|
-
}, [getFocusedItem]);
|
|
220
197
|
const filterRelationsByType = (relations, tid, type) => {
|
|
221
198
|
return type === 'detail'
|
|
222
199
|
? relations.filter(r => r.masterTID == tid)
|
|
@@ -245,12 +222,34 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
245
222
|
duration: 5000
|
|
246
223
|
});
|
|
247
224
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
225
|
+
//This ensures archive master/detail works correctly regardless of output metadata configuration.
|
|
226
|
+
const mapAssociationsToMidsAsync = useCallback(async (relation, type) => {
|
|
227
|
+
if (!relation.associations || relation.associations.length === 0)
|
|
228
|
+
return [];
|
|
229
|
+
if (!focusedItem?.TID || !focusedItem?.DID)
|
|
230
|
+
return [];
|
|
231
|
+
const searchEngine = SDK_Globals.tmSession?.NewSearchEngine();
|
|
232
|
+
if (!searchEngine)
|
|
233
|
+
return [];
|
|
234
|
+
const allMetadata = await searchEngine.GetMetadataAsync(focusedItem.TID, focusedItem.DID, false);
|
|
235
|
+
if (!allMetadata?.dtdResult?.rows?.[0] || !allMetadata.selectMIDs)
|
|
236
|
+
return [];
|
|
237
|
+
const row = allMetadata.dtdResult.rows[0];
|
|
238
|
+
const mids = allMetadata.selectMIDs;
|
|
239
|
+
const metadataMap = new Map();
|
|
240
|
+
mids.forEach((mid, index) => {
|
|
241
|
+
const value = row[index];
|
|
242
|
+
if (value !== undefined && value !== null) {
|
|
243
|
+
metadataMap.set(mid, value.toString());
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return relation.associations.map(assoc => {
|
|
247
|
+
const sourceMid = type === 'detail' ? (assoc.item1 ?? 0) : (assoc.item2 ?? 0);
|
|
248
|
+
const targetMid = type === 'detail' ? (assoc.item2 ?? 0) : (assoc.item1 ?? 0);
|
|
249
|
+
const value = metadataMap.get(sourceMid) ?? '';
|
|
250
|
+
return { mid: targetMid, value };
|
|
251
|
+
});
|
|
252
|
+
}, [focusedItem]);
|
|
254
253
|
const archiveRelatedDcmtHandler = useCallback(async (relation, type) => {
|
|
255
254
|
const targetTID = type === 'detail' ? relation.detailTID : relation.masterTID;
|
|
256
255
|
if (!targetTID)
|
|
@@ -268,7 +267,7 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
268
267
|
});
|
|
269
268
|
return;
|
|
270
269
|
}
|
|
271
|
-
const mids =
|
|
270
|
+
const mids = await mapAssociationsToMidsAsync(relation, type);
|
|
272
271
|
setArchiveType(type);
|
|
273
272
|
setArchiveRelatedDcmtFormTID(targetTID);
|
|
274
273
|
setArchiveRelatedDcmtFormMids(mids);
|
|
@@ -278,7 +277,7 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
|
|
|
278
277
|
console.error("Error checking archive permissions:", error);
|
|
279
278
|
TMExceptionBoxManager.show({ exception: error });
|
|
280
279
|
}
|
|
281
|
-
}, [
|
|
280
|
+
}, [mapAssociationsToMidsAsync]);
|
|
282
281
|
const filterRelationsByPermission = async (relations, type) => {
|
|
283
282
|
const dataSourcePromises = relations.map(async (rel) => {
|
|
284
283
|
const targetTID = type === 'detail' ? rel.detailTID : rel.masterTID;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topconsultnpm/sdkui-react",
|
|
3
|
-
"version": "6.20.0
|
|
3
|
+
"version": "6.20.0",
|
|
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
|
|
43
|
+
"@topconsultnpm/sdk-ts": "6.20.0",
|
|
44
44
|
"buffer": "^6.0.3",
|
|
45
45
|
"devextreme": "25.2.4",
|
|
46
46
|
"devextreme-react": "25.2.4",
|