@topconsultnpm/sdkui-react 6.19.0-dev1.48 → 6.19.0-dev1.49

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.
@@ -492,7 +492,7 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
492
492
  const relation = relatedDcmts?.find(r => r.id === selectedRelation[0]);
493
493
  if (!relation || !archiveType)
494
494
  return;
495
- archiveRelatedDcmtHandler(relation, archiveType);
495
+ await archiveRelatedDcmtHandler(relation, archiveType);
496
496
  }
497
497
  catch (error) {
498
498
  TMExceptionBoxManager.show({ exception: error });
@@ -65,7 +65,7 @@ interface UseRelatedDocumentsReturn {
65
65
  pairManyToMany: (isPairing: boolean) => Promise<void>;
66
66
  checkRelatedDcmtsArchiveCapability: () => Promise<void>;
67
67
  checkManyToManyCapability: () => Promise<void>;
68
- archiveRelatedDcmtHandler: (relation: RelationDescriptor, type: 'detail' | 'master') => void;
68
+ archiveRelatedDcmtHandler: (relation: RelationDescriptor, type: 'detail' | 'master') => Promise<void>;
69
69
  executeManyToManyPairing: (relation: RelationDescriptor, isPairing: boolean) => Promise<void>;
70
70
  }
71
71
  export declare const useRelatedDocuments: ({ selectedSearchResult, focusedItem, currentSearchResults }: UseRelatedDocumentsProps) => UseRelatedDocumentsReturn;
@@ -3,7 +3,7 @@ import { useState, useCallback, useMemo, useEffect } from 'react';
3
3
  import { SDKUI_Localizator } from '../helper/SDKUI_Localizator';
4
4
  import { IconPair, IconUnpair } from '../helper/TMIcons';
5
5
  import { hasDetailRelations, hasMasterRelations } from '../helper/dcmtsHelper';
6
- import { SDK_Globals, SearchEngine, RelationCacheService, RelationTypes, DcmtTypeListCacheService, SystemMIDsAsNumber } from '@topconsultnpm/sdk-ts';
6
+ import { SDK_Globals, SearchEngine, RelationCacheService, RelationTypes, DcmtTypeListCacheService, SystemMIDsAsNumber, AccessLevelsEx } from '@topconsultnpm/sdk-ts';
7
7
  import { TMSpinner, TMExceptionBoxManager, ShowAlert } from '../components';
8
8
  export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, currentSearchResults }) => {
9
9
  const [relatedDcmts, setRelatedDcmts] = useState(undefined);
@@ -245,15 +245,33 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
245
245
  value: fetchAssociatedValues(type === 'detail' ? (assoc.item1 ?? 0) : (assoc.item2 ?? 0)) ?? ''
246
246
  })) ?? [];
247
247
  }, [fetchAssociatedValues]);
248
- const archiveRelatedDcmtHandler = useCallback((relation, type) => {
248
+ const archiveRelatedDcmtHandler = useCallback(async (relation, type) => {
249
249
  const targetTID = type === 'detail' ? relation.detailTID : relation.masterTID;
250
250
  if (!targetTID)
251
251
  return;
252
- const mids = mapAssociationsToMids(relation, type);
253
- setArchiveType(type);
254
- setArchiveRelatedDcmtFormTID(targetTID);
255
- setArchiveRelatedDcmtFormMids(mids);
256
- setIsOpenArchiveRelationForm(true);
252
+ try {
253
+ const dtd = await DcmtTypeListCacheService.GetWithNotGrantedAsync(targetTID, undefined);
254
+ if (dtd?.perm?.canArchive !== AccessLevelsEx.Yes && dtd?.perm?.canArchive !== AccessLevelsEx.Mixed) {
255
+ ShowAlert({
256
+ message: type === 'detail'
257
+ ? "Non hai i permessi per archiviare documenti di dettaglio di questo tipo."
258
+ : "Non hai i permessi per archiviare documenti master di questo tipo.",
259
+ mode: 'warning',
260
+ title: type === 'detail' ? SDKUI_Localizator.DcmtsDetail : SDKUI_Localizator.DcmtsMaster,
261
+ duration: 5000
262
+ });
263
+ return;
264
+ }
265
+ const mids = mapAssociationsToMids(relation, type);
266
+ setArchiveType(type);
267
+ setArchiveRelatedDcmtFormTID(targetTID);
268
+ setArchiveRelatedDcmtFormMids(mids);
269
+ setIsOpenArchiveRelationForm(true);
270
+ }
271
+ catch (error) {
272
+ console.error("Error checking archive permissions:", error);
273
+ TMExceptionBoxManager.show({ exception: error });
274
+ }
257
275
  }, [mapAssociationsToMids]);
258
276
  const archiveRelatedDocuments = useCallback(async (tid, type) => {
259
277
  try {
@@ -283,7 +301,7 @@ export const useRelatedDocuments = ({ selectedSearchResult, focusedItem, current
283
301
  setShowRelatedDcmtsChooser(true);
284
302
  }
285
303
  else {
286
- archiveRelatedDcmtHandler(withAssociations[0], type);
304
+ await archiveRelatedDcmtHandler(withAssociations[0], type);
287
305
  }
288
306
  }
289
307
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.19.0-dev1.48",
3
+ "version": "6.19.0-dev1.49",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",