@topconsultnpm/sdkui-react 6.19.0-dev1.42 → 6.19.0-dev1.44

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.
@@ -19,6 +19,7 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
19
19
  const [fromDTD, setFromDTD] = useState();
20
20
  const [currentInputMids, setCurrentInputMids] = useState(inputMids);
21
21
  const previousTIDRef = React.useRef(undefined);
22
+ const pendingMidsRef = React.useRef(null);
22
23
  const deviceType = useDeviceType();
23
24
  useEffect(() => { setMruTIDs(SDKUI_Globals.userSettings.archivingSettings.mruTIDs); }, []);
24
25
  useEffect(() => {
@@ -26,12 +27,13 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
26
27
  return;
27
28
  setCurrentTID(inputTID);
28
29
  setCurrentMruTID(mruTIDs.includes(inputTID) ? inputTID : 0);
29
- }, [inputTID]);
30
+ }, [inputTID, mruTIDs]);
30
31
  useEffect(() => {
31
- setCurrentInputMids(inputMids);
32
+ pendingMidsRef.current = inputMids;
32
33
  }, [inputMids]);
33
34
  useEffect(() => {
34
35
  if (!currentTID || currentTID <= 0) {
36
+ previousTIDRef.current = currentTID;
35
37
  return;
36
38
  }
37
39
  if (onDcmtTypeSelect)
@@ -39,8 +41,18 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
39
41
  DcmtTypeListCacheService.GetAsync(currentTID).then(async (dtd) => {
40
42
  setFromDTD(dtd);
41
43
  });
42
- if (previousTIDRef.current !== undefined && previousTIDRef.current !== currentTID) {
43
- setCurrentInputMids([]);
44
+ if (previousTIDRef.current !== undefined && previousTIDRef.current > 0 && previousTIDRef.current !== currentTID) {
45
+ if (pendingMidsRef.current && pendingMidsRef.current.length > 0) {
46
+ setCurrentInputMids(pendingMidsRef.current);
47
+ pendingMidsRef.current = null;
48
+ }
49
+ else {
50
+ setCurrentInputMids([]);
51
+ }
52
+ }
53
+ else if (pendingMidsRef.current) {
54
+ setCurrentInputMids(pendingMidsRef.current);
55
+ pendingMidsRef.current = null;
44
56
  }
45
57
  previousTIDRef.current = currentTID;
46
58
  }, [currentTID, onDcmtTypeSelect]);
@@ -61,7 +73,7 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
61
73
  setMruTIDs(newMruTIDS);
62
74
  } }), [mruTIDs, currentMruTID, deviceType, isSharedArchive]);
63
75
  const tmFormElement = useMemo(() => currentTID ?
64
- _jsx(TMDcmtForm, { TID: currentTID, DID: inputDID, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, inputFile: inputFile, connectorFileSave: connectorFileSave, onSavedAsyncCallback: onSavedAsyncCallback, inputMids: currentInputMids, enableDragDropOverlay: enableDragDropOverlay, passToSearch: passToSearch ? (outputMids) => {
76
+ _jsx(TMDcmtForm, { TID: currentTID, DID: currentTID === inputTID ? inputDID : undefined, sharedSourceTID: isSharedArchive ? inputTID : undefined, sharedSourceDID: isSharedArchive ? inputDID : undefined, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, inputFile: inputFile, connectorFileSave: connectorFileSave, onSavedAsyncCallback: onSavedAsyncCallback, inputMids: currentInputMids, enableDragDropOverlay: enableDragDropOverlay, passToSearch: passToSearch ? (outputMids) => {
65
77
  if (onDcmtTypeSelect)
66
78
  onDcmtTypeSelect(currentTID);
67
79
  passToSearch(currentTID, outputMids);
@@ -46,6 +46,8 @@ interface ITMDcmtFormProps {
46
46
  value: string;
47
47
  }>) => void;
48
48
  isSharedDcmt?: boolean;
49
+ sharedSourceTID?: number;
50
+ sharedSourceDID?: number;
49
51
  }
50
52
  declare const TMDcmtForm: React.FC<ITMDcmtFormProps>;
51
53
  export default TMDcmtForm;
@@ -1,7 +1,7 @@
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
3
  import TMDcmtPreview from './TMDcmtPreview';
4
- import { AccessLevels, ArchiveConstraints, ArchiveEngineByID, DcmtTypeListCacheService, LayoutCacheService, LayoutModes, MetadataDataTypes, ResultTypes, SDK_Globals, SDK_Localizator, SystemMIDsAsNumber, SystemTIDs, Task_States, TemplateTIDs, UpdateEngineByID, ValidationItem, WorkflowCacheService, WorkItemMetadataNames } from '@topconsultnpm/sdk-ts';
4
+ import { AccessLevels, ArchiveConstraints, ArchiveEngineByID, DcmtTypeListCacheService, LayoutCacheService, LayoutModes, MetadataDataTypes, ResultTypes, SDK_Globals, SDK_Localizator, SystemMIDsAsNumber, SystemTIDs, Task_States, TemplateTIDs, TID_DID, UpdateEngineByID, ValidationItem, WorkflowCacheService, WorkItemMetadataNames } from '@topconsultnpm/sdk-ts';
5
5
  import { ContextMenu } from 'devextreme-react';
6
6
  import { WorkFlowApproveRejectPopUp, WorkFlowMoreInfoPopUp, WorkFlowOperationButtons, WorkFlowReAssignPopUp } from '../workflow/TMWorkflowPopup';
7
7
  import { DownloadTypes, FormModes } from '../../../ts';
@@ -37,7 +37,7 @@ import WFDiagram from '../workflow/diagram/WFDiagram';
37
37
  import TMTooltip from '../../base/TMTooltip';
38
38
  let abortControllerLocal = new AbortController();
39
39
  //#endregion
40
- const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtFormSidebar = true, invokedByTodo = false, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId, onWFOperationCompleted, onTaskCompleted, inputFile = null, taskFormDialogComponent, taskMoreInfo, connectorFileSave = undefined, inputMids = [], onOpenS4TViewerRequest, s4TViewerDialogComponent, enableDragDropOverlay = false, passToSearch, isSharedDcmt = false }) => {
40
+ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtFormSidebar = true, invokedByTodo = false, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId, onWFOperationCompleted, onTaskCompleted, inputFile = null, taskFormDialogComponent, taskMoreInfo, connectorFileSave = undefined, inputMids = [], onOpenS4TViewerRequest, s4TViewerDialogComponent, enableDragDropOverlay = false, passToSearch, isSharedDcmt = false, sharedSourceTID, sharedSourceDID }) => {
41
41
  const [id, setID] = useState('');
42
42
  const [showWaitPanelLocal, setShowWaitPanelLocal] = useState(false);
43
43
  const [waitPanelTitleLocal, setWaitPanelTitleLocal] = useState('');
@@ -615,11 +615,12 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
615
615
  else {
616
616
  ae.ArchivingFile = dcmtFileRef.current;
617
617
  }
618
- // if (isSharedDcmt) {
619
- // console.log(TID);
620
- // console.log(DID);
621
- // ae.SharedDcmt = { tid: TID, did: DID } as TID_DID;
622
- // }
618
+ if (isSharedDcmt && sharedSourceTID && sharedSourceDID) {
619
+ const sharedDcmt = new TID_DID();
620
+ sharedDcmt.tid = sharedSourceTID;
621
+ sharedDcmt.did = sharedSourceDID;
622
+ ae.SharedDcmt = sharedDcmt;
623
+ }
623
624
  let newDID = await ae.ArchiveAsync(abortControllerLocal.signal, (pd) => {
624
625
  if (firstBlock) {
625
626
  maxFileSize = pd.ProgressBarMaximum ?? 0;
@@ -42,23 +42,30 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
42
42
  const isMobile = deviceType === DeviceType.MOBILE;
43
43
  let initialMaxItems = deviceType === DeviceType.MOBILE ? 8 : 12;
44
44
  const appliedInputMidsRef = useRef(null);
45
+ const pendingMidsRef = useRef(null);
45
46
  useEffect(() => {
46
47
  if (!SQD)
47
48
  return;
48
49
  setDataAsync(SQD);
49
50
  }, [SQD]);
50
51
  useEffect(() => {
51
- if (!inputMids || inputMids.length === 0 || !qd || !fromDTD)
52
+ pendingMidsRef.current = inputMids ?? null;
53
+ }, [inputMids]);
54
+ useEffect(() => {
55
+ if (!qd || !fromDTD)
56
+ return;
57
+ const midsToApply = pendingMidsRef.current;
58
+ if (!midsToApply || midsToApply.length === 0)
52
59
  return;
53
- if (appliedInputMidsRef.current && deepCompare(appliedInputMidsRef.current, inputMids))
60
+ if (appliedInputMidsRef.current && deepCompare(appliedInputMidsRef.current, midsToApply))
54
61
  return;
55
- appliedInputMidsRef.current = inputMids;
62
+ appliedInputMidsRef.current = midsToApply;
56
63
  const newWhere = qd.where?.map((curItem) => {
57
64
  let newWi = new WhereItem();
58
65
  newWi.init({ ...curItem, value1: undefined, value2: undefined });
59
66
  return newWi;
60
67
  }) || [];
61
- inputMids.forEach(im => {
68
+ midsToApply.forEach(im => {
62
69
  const md = fromDTD.metadata?.find(m => m.id === im.mid);
63
70
  const defaultOperator = getDefaultOperator(md?.dataDomain, md?.dataType);
64
71
  let existingWi = newWhere.find(wi => wi.mid === im.mid);
@@ -78,7 +85,7 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
78
85
  });
79
86
  setQd({ ...qd, where: newWhere });
80
87
  setShowAllMdWhere(true);
81
- }, [inputMids, qd, fromDTD]);
88
+ }, [qd, fromDTD]);
82
89
  // Eseguire la ricerca quando shouldSearch è true e qd è definito
83
90
  useEffect(() => {
84
91
  if (shouldSearch && qd) {
@@ -621,7 +621,7 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
621
621
  await onRefreshSearchAsync?.();
622
622
  } }), isOpenSharedArchive && _jsx(TMModal, { title: "Archiviazione condivisa", onClose: () => {
623
623
  setIsOpenSharedArchive(false);
624
- }, width: isMobile ? '90%' : '80%', height: isMobile ? '90%' : '80%', children: _jsx(TMArchive, { inputDID: focusedItem?.DID, inputTID: focusedItem?.TID, inputMids: currentMetadataValues.filter(md => md.mid && md.mid > 100).map(md => ({ mid: md.mid, value: md.value ?? '' })), isSharedArchive: true, inputFile: sharedDcmtFile, onSavedAsyncCallback: async (tid, did) => {
624
+ }, width: isMobile ? '90%' : '60%', height: isMobile ? '90%' : '80%', children: _jsx(TMArchive, { inputDID: focusedItem?.DID, inputTID: focusedItem?.TID, inputMids: currentMetadataValues.filter(md => md.mid && md.mid > 100).map(md => ({ mid: md.mid, value: md.value ?? '' })), isSharedArchive: true, inputFile: sharedDcmtFile, onSavedAsyncCallback: async (tid, did) => {
625
625
  setIsOpenSharedArchive(false);
626
626
  await onRefreshSearchAsync?.();
627
627
  } }) })] }));
@@ -7,4 +7,4 @@ export declare const signatureInformationCallback: (isMobile: boolean, inputDcmt
7
7
  export declare const getCommandsMenuItems: (isMobile: boolean, dtd: DcmtTypeDescriptor | undefined, selectedItems: Array<any>, focusedItem: any, context: SearchResultContext, showFloatingBar: boolean, workingGroupContext: WorkingGroupDescriptor | undefined, showSearch: boolean, setShowFloatingBar: React.Dispatch<React.SetStateAction<boolean>>, openFormHandler: (layoutMode: LayoutModes) => void, openSharedArchiveHandler: () => Promise<void>, downloadDcmtsAsync: (inputDcmts: DcmtInfo[] | undefined, downloadType: DownloadTypes, downloadMode: DownloadModes, onFileDownloaded?: (dcmtFile: File | undefined) => void, confirmAttachments?: (list: FileDescriptor[]) => Promise<string[] | undefined>) => Promise<void>, runOperationAsync: (inputDcmts: DcmtInfo[] | undefined, dcmtOperationType: DcmtOperationTypes, actionAfterOperationAsync?: () => Promise<void>) => Promise<void>, onRefreshSearchAsync: (() => Promise<void>) | undefined, onRefreshDataRowsAsync: (() => Promise<void>) | undefined, onRefreshAfterAddDcmtToFavs: (() => void) | undefined, confirmFormat: () => Promise<FileFormats>, confirmAttachments: (list: FileDescriptor[]) => Promise<string[] | undefined>, openTaskFormHandler: () => void, openDetailDcmtsFormHandler: (value: boolean) => void, openMasterDcmtsFormHandler: (value: boolean) => void, openBatchUpdateFormHandler: (value: boolean) => void, openExportForm: () => void, handleToggleSearch: () => void, handleSignApprove: () => void, openWGsCopyMoveForm?: ((mode: "copyToWgDraft" | "copyToWgArchivedDoc", dcmtTypeDescriptor: DcmtTypeDescriptor, documents: Array<DcmtInfo>) => void), openCommentFormCallback?: ((documents: Array<DcmtInfo>) => void), openEditPdf?: ((documents: Array<DcmtInfo>) => void), openAddDocumentForm?: () => void, passToArchiveCallback?: (outputMids: Array<{
8
8
  mid: number;
9
9
  value: string;
10
- }>) => void, archiveMasterDocuments?: (tid: number | undefined) => Promise<void>, archiveDetailDocuments?: (tid: number | undefined) => Promise<void>, hasMasterRelation?: boolean, hasDetailRelation?: boolean, canArchiveMasterRelation?: boolean, canArchiveDetailRelation?: boolean, pairManyToManyDocuments?: (isPairing: boolean) => Promise<void>, hasManyToManyRelation?: boolean) => Array<TMDataGridContextMenuItem>;
10
+ }>, tid?: number) => void, archiveMasterDocuments?: (tid: number | undefined) => Promise<void>, archiveDetailDocuments?: (tid: number | undefined) => Promise<void>, hasMasterRelation?: boolean, hasDetailRelation?: boolean, canArchiveMasterRelation?: boolean, canArchiveDetailRelation?: boolean, pairManyToManyDocuments?: (isPairing: boolean) => Promise<void>, hasManyToManyRelation?: boolean) => Array<TMDataGridContextMenuItem>;
@@ -235,7 +235,7 @@ export const getCommandsMenuItems = (isMobile, dtd, selectedItems, focusedItem,
235
235
  ?.filter(md => md.mid && md.mid > 100 && md.value && md.value.length > 0)
236
236
  .map(md => ({ mid: md.mid, value: md.value })) || [];
237
237
  TMSpinner.hide();
238
- passToArchiveCallback?.(outputMids);
238
+ passToArchiveCallback?.(outputMids, item.TID);
239
239
  }
240
240
  catch (error) {
241
241
  TMSpinner.hide();
@@ -397,7 +397,7 @@ export const getCommandsMenuItems = (isMobile, dtd, selectedItems, focusedItem,
397
397
  const sharedDcmtsMenuItem = () => {
398
398
  return {
399
399
  icon: svgToString(_jsx(IconSharedDcmt, {})),
400
- text: 'Documenti Condivisi',
400
+ text: 'Documenti condivisi',
401
401
  operationType: 'multiRow',
402
402
  disabled: disabledForMultiRow(selectedItems, focusedItem),
403
403
  items: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.19.0-dev1.42",
3
+ "version": "6.19.0-dev1.44",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",