@topconsultnpm/sdkui-react 6.19.0-dev1.7 → 6.19.0-dev1.9
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.
|
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import { SDK_Globals, DataColumnTypes, MetadataDataDomains, DataListViewModes, MetadataFormats, LayoutModes, TemplateTIDs, DcmtTypeListCacheService, AccessLevels, SystemMIDsAsNumber, RelationCacheService, RelationTypes } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { getCommandsMenuItems, getSelectedDcmtsOrFocused } from './TMSearchResultsMenuItems';
|
|
6
|
-
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, IconDetailDcmts, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, IconDownload, deepCompare, getDataColumnName, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, TMCommandsContextMenu } from '../../../helper';
|
|
6
|
+
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, IconDetailDcmts, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, IconDownload, deepCompare, getDataColumnName, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, TMCommandsContextMenu, IconRelation } from '../../../helper';
|
|
7
7
|
import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
|
|
8
8
|
import { useInputAttachmentsDialog, useInputCvtFormatDialog } from '../../../hooks/useInputDialog';
|
|
9
9
|
import { DcmtOperationTypes, FormModes, SearchResultContext, DownloadTypes } from '../../../ts';
|
|
@@ -141,7 +141,6 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
|
|
|
141
141
|
const newDataSource = searchResultDescriptorToSimpleArray(selectedSearchResult);
|
|
142
142
|
// Se esiste almeno una riga, seleziona la prima
|
|
143
143
|
setFocusedItem(newDataSource && newDataSource.length > 0 ? newDataSource[0] : undefined);
|
|
144
|
-
setSelectedItems([]);
|
|
145
144
|
}, [selectedSearchResult]);
|
|
146
145
|
useEffect(() => {
|
|
147
146
|
if (!focusedItem)
|
|
@@ -425,6 +424,13 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
|
|
|
425
424
|
}
|
|
426
425
|
};
|
|
427
426
|
//#region Related Documents Archive Section
|
|
427
|
+
const pairFloatingActionConfig = useMemo(() => ({
|
|
428
|
+
isVisible: true,
|
|
429
|
+
type: 'multi',
|
|
430
|
+
onClick: (selected) => { console.log(selected); },
|
|
431
|
+
iconElement: _jsx(IconRelation, { fontSize: 26 }),
|
|
432
|
+
tooltip: isPairingManyToMany ? 'Abbina' : 'Disabbina',
|
|
433
|
+
}), [isPairingManyToMany, pairedSearchResults]);
|
|
428
434
|
const getAllRelationsAsync = async () => {
|
|
429
435
|
const tmSession = SDK_Globals.tmSession;
|
|
430
436
|
try {
|
|
@@ -574,6 +580,52 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
|
|
|
574
580
|
const archiveMasterDocuments = async (tid) => {
|
|
575
581
|
await archiveRelatedDocuments(tid, 'master');
|
|
576
582
|
};
|
|
583
|
+
const getAlreadyPairedDIDs = async (relation, currentTID, currentDID) => {
|
|
584
|
+
if (!relation || !currentDID)
|
|
585
|
+
return [];
|
|
586
|
+
try {
|
|
587
|
+
const tmSession = SDK_Globals.tmSession;
|
|
588
|
+
if (!tmSession)
|
|
589
|
+
return [];
|
|
590
|
+
const searchEngine = tmSession.NewSearchEngine();
|
|
591
|
+
if (!searchEngine)
|
|
592
|
+
return [];
|
|
593
|
+
const isMaster = currentTID === relation.masterTID;
|
|
594
|
+
const pairedResults = isMaster
|
|
595
|
+
? await searchEngine.GetAllDetailDcmtsAsync(currentTID, currentDID)
|
|
596
|
+
: await searchEngine.GetAllMasterDcmtsAsync(currentTID, currentDID);
|
|
597
|
+
if (!pairedResults || pairedResults.length === 0)
|
|
598
|
+
return [];
|
|
599
|
+
const relationResult = pairedResults.find(r => r.relationID === relation.id);
|
|
600
|
+
if (!relationResult?.dtdResult)
|
|
601
|
+
return [];
|
|
602
|
+
const pairedDIDs = [];
|
|
603
|
+
const rows = relationResult.dtdResult.rows ?? [];
|
|
604
|
+
const columns = relationResult.dtdResult.columns ?? [];
|
|
605
|
+
const didColumnIndex = columns.findIndex(col => {
|
|
606
|
+
const caption = col.caption?.toUpperCase();
|
|
607
|
+
const mid = col.extendedProperties?.["MID"];
|
|
608
|
+
const midNum = typeof mid === 'string' ? Number.parseInt(mid, 10) : mid;
|
|
609
|
+
return caption === 'DID' || midNum === 5;
|
|
610
|
+
});
|
|
611
|
+
if (didColumnIndex === -1)
|
|
612
|
+
return [];
|
|
613
|
+
for (const row of rows) {
|
|
614
|
+
const did = row[didColumnIndex];
|
|
615
|
+
if (did) {
|
|
616
|
+
const didNumber = typeof did === 'string' ? Number.parseInt(did, 10) : did;
|
|
617
|
+
if (!Number.isNaN(didNumber)) {
|
|
618
|
+
pairedDIDs.push(didNumber);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return pairedDIDs;
|
|
623
|
+
}
|
|
624
|
+
catch (error) {
|
|
625
|
+
console.error('getAlreadyPairedDIDs - Error:', error);
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
628
|
+
};
|
|
577
629
|
const executeManyToManyPairing = async (relation, isPairing) => {
|
|
578
630
|
const searchEngine = SDK_Globals.tmSession?.NewSearchEngine();
|
|
579
631
|
if (!focusedItem?.TID || !focusedItem?.DID) {
|
|
@@ -664,12 +716,48 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
|
|
|
664
716
|
}
|
|
665
717
|
}
|
|
666
718
|
}
|
|
667
|
-
const
|
|
719
|
+
const targetTID = relation.detailTID === selectedSearchResult?.fromTID
|
|
720
|
+
? relation.masterTID
|
|
721
|
+
: relation.detailTID;
|
|
722
|
+
const qdWithDID = structuredClone(qd);
|
|
723
|
+
const didSelect = { tid: targetTID, mid: 1, visibility: 1 };
|
|
724
|
+
const fileExtSelect = { tid: targetTID, mid: 5, visibility: 1 };
|
|
725
|
+
if (qdWithDID.select) {
|
|
726
|
+
qdWithDID.select = [didSelect, fileExtSelect, ...qdWithDID.select];
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
qdWithDID.select = [didSelect, fileExtSelect];
|
|
730
|
+
}
|
|
731
|
+
const sq = await searchEngine.SearchByIDAsync(qdWithDID);
|
|
668
732
|
if (!sq?.dtdResult?.rows || sq.dtdResult.rows.length === 0) {
|
|
669
733
|
alert("Nessun documento trovato.");
|
|
670
734
|
return;
|
|
671
735
|
}
|
|
672
|
-
|
|
736
|
+
const pairedDIDs = await getAlreadyPairedDIDs(relation, focusedItem.TID, focusedItem.DID);
|
|
737
|
+
const filteredRows = sq.dtdResult.rows.filter(row => {
|
|
738
|
+
const did = row[0];
|
|
739
|
+
const didNum = typeof did === 'string' ? parseInt(did, 10) : did;
|
|
740
|
+
if (isPairing) {
|
|
741
|
+
return !pairedDIDs.includes(didNum);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
return pairedDIDs.includes(didNum);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
const filteredSq = {
|
|
748
|
+
...sq,
|
|
749
|
+
dtdResult: {
|
|
750
|
+
...sq.dtdResult,
|
|
751
|
+
rows: filteredRows
|
|
752
|
+
},
|
|
753
|
+
dcmtsReturned: filteredRows.length,
|
|
754
|
+
dcmtsFound: filteredRows.length
|
|
755
|
+
};
|
|
756
|
+
if (filteredRows.length === 0) {
|
|
757
|
+
alert(isPairing ? "Nessun documento da abbinare." : "Nessun documento abbinato trovato.");
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
setPairedSearchResults([filteredSq]);
|
|
673
761
|
setIsPairingManyToMany(isPairing);
|
|
674
762
|
setShowPairDcmtsModal(true);
|
|
675
763
|
};
|
|
@@ -771,7 +859,7 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
|
|
|
771
859
|
TMSpinner.hide();
|
|
772
860
|
}
|
|
773
861
|
}, onClose: () => setShowManyToManyChooser(false), manageUseLocalizedName: false }), showPairDcmtsModal &&
|
|
774
|
-
_jsx(TMModal, { title: (isPairingManyToMany ? "Abbina" : "Disabbina") + " documenti", onClose: () => setShowPairDcmtsModal(false), children: _jsx(TMSearchResult, { searchResults: pairedSearchResults, onRefreshAfterAddDcmtToFavs: onRefreshAfterAddDcmtToFavs, onRefreshSearchAsync: onRefreshSearchAsync, onFileOpened: onFileOpened, onTaskCreateRequest: onTaskCreateRequest, openWGsCopyMoveForm: openWGsCopyMoveForm, openEditPdf: openEditPdf, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, passToArchiveCallback: passToArchiveCallback, showTodoDcmtForm: showTodoDcmtForm }) }), (floatingActionConfig && floatingActionConfig.isVisible) && _jsx(TMSearchResultFloatingActionButton, { selectedDcmtsOrFocused: getSelectedDcmtsOrFocused(selectedItems, focusedItem), config: floatingActionConfig })] }), [
|
|
862
|
+
_jsx(TMModal, { title: (isPairingManyToMany ? "Abbina" : "Disabbina") + " documenti", onClose: () => setShowPairDcmtsModal(false), children: _jsx(TMSearchResult, { searchResults: pairedSearchResults, onRefreshAfterAddDcmtToFavs: onRefreshAfterAddDcmtToFavs, onRefreshSearchAsync: onRefreshSearchAsync, onFileOpened: onFileOpened, onTaskCreateRequest: onTaskCreateRequest, openWGsCopyMoveForm: openWGsCopyMoveForm, openEditPdf: openEditPdf, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, passToArchiveCallback: passToArchiveCallback, showTodoDcmtForm: showTodoDcmtForm, floatingActionConfig: pairFloatingActionConfig }) }), (floatingActionConfig && floatingActionConfig.isVisible) && _jsx(TMSearchResultFloatingActionButton, { selectedDcmtsOrFocused: getSelectedDcmtsOrFocused(selectedItems, focusedItem), config: floatingActionConfig })] }), [
|
|
775
863
|
searchResults,
|
|
776
864
|
selectedSearchResult,
|
|
777
865
|
lastUpdateSearchTime,
|
|
@@ -314,5 +314,12 @@ export const renderDTDTooltipContent = (dtd) => {
|
|
|
314
314
|
_jsxs(_Fragment, { children: [_jsx(StyledTooltipItem, { "$color": 'primary', "$marginTop": '5px', children: SDKUI_Localizator.Perms }), _jsx(StyledTooltipSeparatorItem, {}), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Archive}: ${dtd.perm.canArchive}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.View_Metadato}: ${dtd.perm.canView}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Search}: ${dtd.perm.canSearch}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Update}: ${dtd.perm.canUpdate}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.RetrieveFile}: ${dtd.perm.canRetrieveFile}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.AddOrSubstFile}: ${dtd.perm.canSubstFile}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.LogDelete}: ${dtd.perm.canLogicalDelete}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.PhysDelete}: ${dtd.perm.canPhysicalDelete}` }), dtd.hasBlog && _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Blog_Read}: ${dtd.perm.canReadBlog}` }), dtd.hasBlog && _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Blog_Write}: ${dtd.perm.canWriteBlog}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.CheckIn}: ${dtd.perm.canCICO}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.ChronologyDelete}: ${dtd.perm.canDelChron}` })] })
|
|
315
315
|
: dtd.ownershipLevel == OwnershipLevels.DirectOwner || dtd.ownershipLevel == OwnershipLevels.IndirectOwner ?
|
|
316
316
|
_jsxs(_Fragment, { children: [_jsx(StyledTooltipItem, { "$color": 'primary', "$marginTop": '5px', children: SDKUI_Localizator.Perms }), _jsx(StyledTooltipSeparatorItem, {}), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Archive}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.View_Metadato}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Search}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Update}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.RetrieveFile}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.AddOrSubstFile}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.LogDelete}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.PhysDelete}: ${SDKUI_Localizator.Yes}` }), dtd.hasBlog && _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Blog_Read}: ${SDKUI_Localizator.Yes}` }), dtd.hasBlog && _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.Blog_Write}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.CheckIn}: ${SDKUI_Localizator.Yes}` }), _jsx(StyledTooltipItem, { children: `${SDKUI_Localizator.ChronologyDelete}: ${SDKUI_Localizator.Yes}` })] })
|
|
317
|
-
: _jsx(_Fragment, {}), (dtd.widgets && dtd.widgets.length > 0) ?
|
|
317
|
+
: _jsx(_Fragment, {}), (dtd.widgets && dtd.widgets.length > 0) ? (() => {
|
|
318
|
+
const enabledWidgets = [
|
|
319
|
+
isSign4TopEnabled(dtd.widgets) ? 'Sign4Top' : null,
|
|
320
|
+
isCreateCertificateEnabled(dtd.widgets) ? `Sign4Top - ${SDKUI_Localizator.Create} ${SDK_Localizator.SignCert.toLocaleLowerCase()}` : null,
|
|
321
|
+
isPdfEditorEnabled(dtd.widgets) ? 'PDFEditor' : null,
|
|
322
|
+
].filter(Boolean);
|
|
323
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledTooltipSeparatorItem, {}), enabledWidgets.length > 0 && (_jsxs(StyledTooltipItem, { children: ["Widgets: ", enabledWidgets.join(', ')] })), enabledWidgets.length === 0 && (_jsxs(StyledTooltipItem, { children: ["Widgets: ", SDKUI_Localizator.No] }))] }));
|
|
324
|
+
})() : (_jsxs(_Fragment, { children: [_jsx(StyledTooltipSeparatorItem, {}), _jsxs(StyledTooltipItem, { children: ["Widgets: ", SDKUI_Localizator.No] })] }))] })] }));
|
|
318
325
|
};
|