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

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]);
@@ -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) {
@@ -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();
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.43",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",