@topconsultnpm/sdkui-react 6.19.0-dev1.38 → 6.19.0-dev1.40

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.
@@ -6,6 +6,7 @@ interface ITMArchiveProps {
6
6
  value: string;
7
7
  }>;
8
8
  inputTID?: number;
9
+ inputDID?: number;
9
10
  onDcmtTypeSelect?: (tid: number | undefined) => void;
10
11
  connectorFileSave?: () => Promise<File>;
11
12
  onSavedAsyncCallback?: (tid: number | undefined, did: number | undefined) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useState } from 'react';
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
3
  import Logo from '../../../assets/Toppy-generico.png';
4
4
  import { DcmtTypeListCacheService, LayoutModes, SDK_Localizator } from '@topconsultnpm/sdk-ts';
5
5
  import { IconTree, SDKUI_Globals, SDKUI_Localizator, IconRecentlyViewed, IconPreview, IconShow, IconBoard, IconDcmtTypeSys, removeMruTid } from '../../../helper';
@@ -12,11 +12,13 @@ import TMTreeSelector from '../search/TMTreeSelector';
12
12
  import TMPanel from '../../base/TMPanel';
13
13
  import { TMPanelManagerProvider, useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
14
14
  import TMPanelManagerContainer from '../../layout/panelManager/TMPanelManagerContainer';
15
- const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, connectorFileSave = undefined, onSavedAsyncCallback, inputMids = [], enableDragDropOverlay = false, passToSearch, isSharedArchive = false }) => {
15
+ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, connectorFileSave = undefined, onSavedAsyncCallback, inputMids = [], enableDragDropOverlay = false, passToSearch, isSharedArchive = false, inputDID = undefined }) => {
16
16
  const [currentTID, setCurrentTID] = useState(inputTID ?? 0);
17
17
  const [mruTIDs, setMruTIDs] = useState([]);
18
18
  const [currentMruTID, setCurrentMruTID] = useState(0);
19
19
  const [fromDTD, setFromDTD] = useState();
20
+ const [currentInputMids, setCurrentInputMids] = useState(inputMids);
21
+ const previousTIDRef = React.useRef(undefined);
20
22
  const deviceType = useDeviceType();
21
23
  useEffect(() => { setMruTIDs(SDKUI_Globals.userSettings.archivingSettings.mruTIDs); }, []);
22
24
  useEffect(() => {
@@ -25,6 +27,9 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
25
27
  setCurrentTID(inputTID);
26
28
  setCurrentMruTID(mruTIDs.includes(inputTID) ? inputTID : 0);
27
29
  }, [inputTID]);
30
+ useEffect(() => {
31
+ setCurrentInputMids(inputMids);
32
+ }, [inputMids]);
28
33
  useEffect(() => {
29
34
  if (!currentTID || currentTID <= 0) {
30
35
  return;
@@ -34,6 +39,10 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
34
39
  DcmtTypeListCacheService.GetAsync(currentTID).then(async (dtd) => {
35
40
  setFromDTD(dtd);
36
41
  });
42
+ if (previousTIDRef.current !== undefined && previousTIDRef.current !== currentTID) {
43
+ setCurrentInputMids([]);
44
+ }
45
+ previousTIDRef.current = currentTID;
37
46
  }, [currentTID, onDcmtTypeSelect]);
38
47
  const isMobile = deviceType === DeviceType.MOBILE;
39
48
  const tmTreeSelectorElement = useMemo(() => _jsx(TMTreeSelectorWrapper, { isMobile: isMobile, isSharedArchive: isSharedArchive, onSelectedTIDChanged: (tid) => {
@@ -52,13 +61,13 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
52
61
  setMruTIDs(newMruTIDS);
53
62
  } }), [mruTIDs, currentMruTID, deviceType, isSharedArchive]);
54
63
  const tmFormElement = useMemo(() => currentTID ?
55
- _jsx(TMDcmtForm, { TID: currentTID, DID: 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: inputMids, enableDragDropOverlay: enableDragDropOverlay, passToSearch: passToSearch ? (outputMids) => {
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) => {
56
65
  if (onDcmtTypeSelect)
57
66
  onDcmtTypeSelect(currentTID);
58
67
  passToSearch(currentTID, outputMids);
59
- } : undefined })
68
+ } : undefined, isSharedDcmt: isSharedArchive }, currentTID)
60
69
  :
61
- _jsx(TMPanel, { title: 'Archiviazione', allowMaximize: false, children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsx(StyledToppyTextContainer, { children: _jsx(StyledToppyText, { children: SDKUI_Localizator.DcmtTypeSelect }) }), _jsx(StyledToppyImage, { src: Logo, alt: 'Toppy' })] }) }), [currentTID, deviceType, mruTIDs, inputFile, inputMids, enableDragDropOverlay]);
70
+ _jsx(TMPanel, { title: 'Archiviazione', allowMaximize: false, children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsx(StyledToppyTextContainer, { children: _jsx(StyledToppyText, { children: SDKUI_Localizator.DcmtTypeSelect }) }), _jsx(StyledToppyImage, { src: Logo, alt: 'Toppy' })] }) }), [currentTID, deviceType, mruTIDs, inputFile, currentInputMids, enableDragDropOverlay, isSharedArchive]);
62
71
  const allInitialPanelVisibility = {
63
72
  'tmTreeSelector': true,
64
73
  'tmRecentsManager': true,
@@ -45,6 +45,7 @@ interface ITMDcmtFormProps {
45
45
  mid: number;
46
46
  value: string;
47
47
  }>) => void;
48
+ isSharedDcmt?: boolean;
48
49
  }
49
50
  declare const TMDcmtForm: React.FC<ITMDcmtFormProps>;
50
51
  export default TMDcmtForm;
@@ -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 }) => {
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 }) => {
41
41
  const [id, setID] = useState('');
42
42
  const [showWaitPanelLocal, setShowWaitPanelLocal] = useState(false);
43
43
  const [waitPanelTitleLocal, setWaitPanelTitleLocal] = useState('');
@@ -284,6 +284,8 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
284
284
  return;
285
285
  if (!formData || formData.length === 0)
286
286
  return;
287
+ if (!formDataOrig || formDataOrig.length === 0)
288
+ return;
287
289
  // Check if formData has actual user metadata (mid > 99), not just system metadata
288
290
  if (!formData.some(md => md.mid && md.mid > 99))
289
291
  return;
@@ -576,6 +578,11 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
576
578
  else {
577
579
  ae.ArchivingFile = dcmtFileRef.current;
578
580
  }
581
+ // if (isSharedDcmt) {
582
+ // console.log(TID);
583
+ // console.log(DID);
584
+ // ae.SharedDcmt = { tid: TID, did: DID } as TID_DID;
585
+ // }
579
586
  let newDID = await ae.ArchiveAsync(abortControllerLocal.signal, (pd) => {
580
587
  if (firstBlock) {
581
588
  maxFileSize = pd.ProgressBarMaximum ?? 0;
@@ -622,7 +629,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
622
629
  setShowWaitPanelLocal(false);
623
630
  setUseWaitPanelLocalState(false);
624
631
  }
625
- }, [TID, connectorFileSave, onSavedAsyncCallback, onSaveRecents, onClose, DID, setMetadataList, handleReset, layoutMode]);
632
+ }, [TID, connectorFileSave, onSavedAsyncCallback, onSaveRecents, onClose, DID, setMetadataList, handleReset, layoutMode, isSharedDcmt]);
626
633
  const handleClearForm = useCallback(() => {
627
634
  let data = structuredClone(formData);
628
635
  if (!data || data.length === 0)
@@ -165,7 +165,7 @@ const TMSearchResult = ({ context = SearchResultContext.METADATA_SEARCH, isVisib
165
165
  setSharedDcmtFile(dcmtFile?.file);
166
166
  }
167
167
  }
168
- catch (error) {
168
+ catch {
169
169
  ShowAlert({ message: 'Il Documenti ha solo i metadati', mode: "warning", title: 'Archivio Condivisa', duration: 5000 });
170
170
  }
171
171
  setIsOpenSharedArchive(true);
@@ -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, { 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%' : '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) => {
625
625
  setIsOpenSharedArchive(false);
626
626
  await onRefreshSearchAsync?.();
627
627
  } }) })] }));
@@ -139,7 +139,7 @@ export const getAttachmentInfo = (attachment, treeFs, draftLatestInfoMap, archiv
139
139
  return { name, nameElement, tooltipContent, folderId, fileExt, draftExist, archivedDocumentsExist };
140
140
  };
141
141
  export const AttachmentElement = (attachment, treeFs, draftLatestInfoMap, archivedDocumentMap, dcmtTypeDescriptors, isSelected, searchText, color, setShowDcmtForm, handleFocusedAttachment, setAnchorEl, contextMenuRef) => {
142
- const { name, nameElement, tooltipContent, folderId, fileExt, draftExist } = getAttachmentInfo(attachment, treeFs, draftLatestInfoMap, archivedDocumentMap, dcmtTypeDescriptors, isSelected, searchText, color);
142
+ const { name, nameElement, tooltipContent, fileExt, archivedDocumentsExist, draftExist } = getAttachmentInfo(attachment, treeFs, draftLatestInfoMap, archivedDocumentMap, dcmtTypeDescriptors, isSelected, searchText, color);
143
143
  const onDoubleClick = (e) => {
144
144
  e.preventDefault();
145
145
  e.stopPropagation();
@@ -176,7 +176,9 @@ export const AttachmentElement = (attachment, treeFs, draftLatestInfoMap, archiv
176
176
  }, onMouseLeave: (e) => {
177
177
  e.currentTarget.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.1)';
178
178
  e.currentTarget.style.backgroundColor = isSelected ? color : colors.WHITE;
179
- }, children: _jsxs("div", { style: { alignItems: 'center', display: 'flex' }, children: [fileExt ? _jsx("div", { style: { marginRight: "10px" }, children: _jsx(TMDcmtIcon, { tid: attachment.tid, did: attachment.did, fileExtension: fileExt, downloadMode: 'openInNewWindow', tooltipContent: tooltipContent }) }) : _jsx(IconAttachment, { style: { marginRight: "5px" } }), _jsx("span", { children: nameElement })] }) }, attachment.did);
179
+ }, children: _jsxs("div", { style: { alignItems: 'center', display: 'flex' }, children: [(!archivedDocumentsExist && !draftExist) ?
180
+ _jsx(IconAttachment, { style: { marginRight: "5px" } }) :
181
+ _jsx("div", { style: { marginRight: "10px" }, children: _jsx(TMDcmtIcon, { tid: attachment.tid, did: attachment.did, fileExtension: fileExt, downloadMode: 'openInNewWindow', tooltipContent: tooltipContent }) }), _jsx("span", { children: nameElement })] }) }, attachment.did);
180
182
  };
181
183
  export const OwnerInitialsBadge = (blogPost) => {
182
184
  return _jsx(TMTooltip, { content: blogPost.ownerName ?? '-', children: _jsx("div", { style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.19.0-dev1.38",
3
+ "version": "6.19.0-dev1.40",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -39,7 +39,7 @@
39
39
  "lib"
40
40
  ],
41
41
  "dependencies": {
42
- "@topconsultnpm/sdk-ts": "6.19.0-dev1.6",
42
+ "@topconsultnpm/sdk-ts": "6.19.0-dev1.8",
43
43
  "buffer": "^6.0.3",
44
44
  "devextreme": "25.1.4",
45
45
  "devextreme-react": "25.1.4",