@topconsultnpm/sdkui-react 6.19.0-dev1.47 → 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.
- package/lib/components/features/search/TMSearchResult.js +1 -1
- package/lib/components/forms/TMChooserForm.d.ts +1 -1
- package/lib/components/forms/TMChooserForm.js +2 -2
- package/lib/hooks/useRelatedDocuments.d.ts +1 -1
- package/lib/hooks/useRelatedDocuments.js +26 -8
- package/lib/ts/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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 });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ITMChooserFormProps } from '../../ts';
|
|
2
|
-
declare const TMChooserForm: <T>({ children, title, allowMultipleSelection, allowApplyWithZeroSelection, startWithShowOnlySelectedItems, hasShowOnlySelectedItems, allowGrouping, allowSorting, width, height, dataSource, selectedIDs, manageUseLocalizedName, hasShowId, hideRefresh, keyName, customButtons, showDefaultColumns, columns, summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged }: ITMChooserFormProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const TMChooserForm: <T>({ children, title, allowMultipleSelection, allowApplyWithZeroSelection, startWithShowOnlySelectedItems, hasShowOnlySelectedItems, allowGrouping, allowSorting, width, height, dataSource, selectedIDs, manageUseLocalizedName, hasShowId, hideRefresh, keyName, customButtons, showFilterPanel, showDefaultColumns, columns, summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged }: ITMChooserFormProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default TMChooserForm;
|
|
@@ -8,7 +8,7 @@ import TMModal from '../base/TMModal';
|
|
|
8
8
|
import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
|
|
9
9
|
import { TMColors } from '../../utils/theme';
|
|
10
10
|
import TMDataGrid from '../base/TMDataGrid';
|
|
11
|
-
const TMChooserForm = ({ children, title, allowMultipleSelection = false, allowApplyWithZeroSelection = false, startWithShowOnlySelectedItems = true, hasShowOnlySelectedItems = false, allowGrouping, allowSorting = true, width, height, dataSource, selectedIDs, manageUseLocalizedName = true, hasShowId = true, hideRefresh = false, keyName = "id", customButtons, showDefaultColumns = true, columns = [], summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged }) => {
|
|
11
|
+
const TMChooserForm = ({ children, title, allowMultipleSelection = false, allowApplyWithZeroSelection = false, startWithShowOnlySelectedItems = true, hasShowOnlySelectedItems = false, allowGrouping, allowSorting = true, width, height, dataSource, selectedIDs, manageUseLocalizedName = true, hasShowId = true, hideRefresh = false, keyName = "id", customButtons, showFilterPanel = false, showDefaultColumns = true, columns = [], summaryItems, convertID, customFilter, getItems, cellRenderIcon, cellRenderNameAndDesc, onChoose, onClose, onShowIdChanged }) => {
|
|
12
12
|
const [showId, setShowId] = useState(false);
|
|
13
13
|
const [showOnlySelectedItems, setShowOnlySelectedItems] = useState(allowMultipleSelection && hasShowOnlySelectedItems && startWithShowOnlySelectedItems && selectedIDs != undefined && selectedIDs.length > 0);
|
|
14
14
|
const [allItems, setAllItems] = useState([]);
|
|
@@ -88,7 +88,7 @@ const TMChooserForm = ({ children, title, allowMultipleSelection = false, allowA
|
|
|
88
88
|
}, [manageUseLocalizedName, summaryItems]);
|
|
89
89
|
return (_jsx(TMModal, { title: renderTitle(), width: width ?? '550px', height: height ?? '600px', toolbar: _jsx(ToolbarButtons, {}), onClose: onClose, children: children ??
|
|
90
90
|
filteredItems.length > 0
|
|
91
|
-
? _jsx(TMDataGrid, { dataSource: filteredItems, keyExpr: keyName, dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, searchPanelFocusStarting: true, headerFilter: { visible: true }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single', showCheckBoxesMode: 'always', selectAllMode: 'allPages' }, grouping: allowGrouping ? { autoExpandAll: false, expandMode: 'rowClick' } : undefined, summary: customSummary, onFocusedRowChanged: handleFocusedRowChange, onSelectionChanged: handleSelectionChanged, onRowDblClick: handleRowDoubleClick })
|
|
91
|
+
? _jsx(TMDataGrid, { dataSource: filteredItems, keyExpr: keyName, dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, searchPanelFocusStarting: true, headerFilter: { visible: true }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single', showCheckBoxesMode: 'always', selectAllMode: 'allPages' }, grouping: allowGrouping ? { autoExpandAll: false, expandMode: 'rowClick' } : undefined, summary: customSummary, showFilterPanel: showFilterPanel, onFocusedRowChanged: handleFocusedRowChange, onSelectionChanged: handleSelectionChanged, onRowDblClick: handleRowDoubleClick })
|
|
92
92
|
: _jsx(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: _jsx(TMLayoutItem, { children: _jsx("p", { style: { height: "100%", color: TMColors.primaryColor, fontSize: "1.5rem", display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: SDKUI_Localizator.NoDataToDisplay }) }) }) }));
|
|
93
93
|
};
|
|
94
94
|
export default TMChooserForm;
|
|
@@ -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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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/lib/ts/types.d.ts
CHANGED
|
@@ -263,6 +263,7 @@ export interface ITMChooserFormProps<T> {
|
|
|
263
263
|
title?: any;
|
|
264
264
|
manageUseLocalizedName?: boolean;
|
|
265
265
|
tmSession?: ITopMediaSession;
|
|
266
|
+
showFilterPanel?: boolean;
|
|
266
267
|
getItems?: (refreshCache: boolean) => Promise<T[]>;
|
|
267
268
|
convertID?: (item: T) => any;
|
|
268
269
|
customFilter?: (items: T[]) => T[];
|