@topconsultnpm/sdkui-react 6.20.0-dev2.5 → 6.20.0-dev2.51

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.
Files changed (67) hide show
  1. package/lib/components/base/Styled.d.ts +1 -0
  2. package/lib/components/base/Styled.js +10 -2
  3. package/lib/components/base/TMTreeView.d.ts +3 -1
  4. package/lib/components/base/TMTreeView.js +63 -20
  5. package/lib/components/choosers/TMDataListItemEditor.d.ts +11 -0
  6. package/lib/components/choosers/TMDataListItemEditor.js +130 -0
  7. package/lib/components/choosers/TMDataListItemFields.d.ts +11 -0
  8. package/lib/components/choosers/TMDataListItemFields.js +61 -0
  9. package/lib/components/choosers/TMDataListItemPicker.d.ts +1 -0
  10. package/lib/components/choosers/TMDataListItemPicker.js +178 -18
  11. package/lib/components/choosers/TMDynDataListItemChooser.js +11 -6
  12. package/lib/components/choosers/TMImageIDChooser.d.ts +16 -0
  13. package/lib/components/choosers/TMImageIDChooser.js +53 -0
  14. package/lib/components/choosers/TMMetadataChooser.js +1 -1
  15. package/lib/components/editors/TMLocalizedTextBox.d.ts +1 -0
  16. package/lib/components/editors/TMLocalizedTextBox.js +3 -3
  17. package/lib/components/editors/TMMetadataValues.js +3 -1
  18. package/lib/components/editors/TMTextBox.js +8 -9
  19. package/lib/components/features/archive/TMArchive.js +29 -42
  20. package/lib/components/features/documents/TMDcmtForm.js +165 -42
  21. package/lib/components/features/documents/TMDcmtPreview.js +2 -1
  22. package/lib/components/features/documents/TMMasterDetailDcmts.js +67 -6
  23. package/lib/components/features/documents/TMRelationViewer.d.ts +7 -1
  24. package/lib/components/features/documents/TMRelationViewer.js +389 -76
  25. package/lib/components/features/search/TMSearchResult.d.ts +1 -0
  26. package/lib/components/features/search/TMSearchResult.js +44 -82
  27. package/lib/components/features/search/TMSearchResultsMenuItems.js +2 -2
  28. package/lib/components/features/tasks/TMTaskForm.js +35 -187
  29. package/lib/components/features/tasks/TMTaskFormUtils.d.ts +74 -0
  30. package/lib/components/features/tasks/TMTaskFormUtils.js +538 -0
  31. package/lib/components/features/tasks/TMTasksUtils.d.ts +2 -0
  32. package/lib/components/features/tasks/TMTasksUtils.js +38 -13
  33. package/lib/components/features/tasks/TMTasksUtilsView.d.ts +0 -7
  34. package/lib/components/features/tasks/TMTasksUtilsView.js +7 -14
  35. package/lib/components/features/tasks/TMTasksView.js +2 -2
  36. package/lib/components/features/workflow/TMWorkflowPopup.d.ts +2 -1
  37. package/lib/components/features/workflow/TMWorkflowPopup.js +2 -1
  38. package/lib/components/features/workflow/diagram/DiagramItemForm.js +1 -1
  39. package/lib/components/forms/Login/TMLoginForm.js +1 -1
  40. package/lib/components/forms/TMSaveForm.js +61 -13
  41. package/lib/components/grids/TMBlogsPost.js +2 -2
  42. package/lib/components/index.d.ts +2 -0
  43. package/lib/components/index.js +2 -0
  44. package/lib/components/layout/panelManager/TMPanelManagerContainer.js +3 -2
  45. package/lib/components/pages/TMPage.js +4 -0
  46. package/lib/components/query/TMQueryEditor.d.ts +1 -0
  47. package/lib/components/query/TMQueryEditor.js +2 -2
  48. package/lib/helper/Enum_Localizator.js +5 -0
  49. package/lib/helper/GlobalStyles.js +3 -0
  50. package/lib/helper/SDKUI_Globals.d.ts +4 -0
  51. package/lib/helper/SDKUI_Globals.js +6 -0
  52. package/lib/helper/SDKUI_Localizator.d.ts +11 -3
  53. package/lib/helper/SDKUI_Localizator.js +102 -22
  54. package/lib/helper/TMUtils.d.ts +18 -0
  55. package/lib/helper/TMUtils.js +58 -0
  56. package/lib/helper/helpers.d.ts +6 -2
  57. package/lib/helper/helpers.js +23 -8
  58. package/lib/helper/index.d.ts +1 -0
  59. package/lib/helper/index.js +1 -0
  60. package/lib/helper/queryHelper.js +1 -1
  61. package/lib/hooks/useBetaFeatures.d.ts +1 -0
  62. package/lib/hooks/useBetaFeatures.js +41 -0
  63. package/lib/hooks/useDcmtOperations.js +14 -2
  64. package/lib/hooks/useRelatedDocuments.js +34 -11
  65. package/lib/index.d.ts +1 -0
  66. package/lib/index.js +1 -0
  67. package/package.json +11 -11
@@ -9,6 +9,7 @@ import TMChooserForm from '../forms/TMChooserForm';
9
9
  import { TMColors } from '../../utils/theme';
10
10
  import TMTooltip from '../base/TMTooltip';
11
11
  import { FormulaHelper } from '../editors/TMFormulaEditor';
12
+ import { TMExceptionBoxManager } from '../base/TMPopUp';
12
13
  const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChooserBySingleClick, readOnly, layoutMode = LayoutModes.None, queryParamsDynDataList, buttons = [], backgroundColor, showBorder = true, elementStyle, allowMultipleSelection, values, isModifiedWhen, label, placeHolder, validationItems = [], icon, labelColor, showClearButton, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs, updateIsModalOpen }) => {
13
14
  const [showChooser, setShowChooser] = useState(false);
14
15
  const [dynDl, setDynDl] = useState();
@@ -30,7 +31,9 @@ const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChoo
30
31
  setDynDl(d);
31
32
  if (!IsParametricQuery(d?.qd) && !dataSource) {
32
33
  setDataSource(undefined);
33
- loadData().then((result) => { setDataSource(result); });
34
+ loadData()
35
+ .then((result) => { setDataSource(result); })
36
+ .catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
34
37
  }
35
38
  }, [md]);
36
39
  useEffect(() => {
@@ -42,12 +45,13 @@ const TMDynDataListItemChooser = ({ tid, md, width = '100%', titleForm, openChoo
42
45
  setDataSource(undefined);
43
46
  return;
44
47
  }
45
- loadData().then((result) => {
46
- setDataSource(result);
47
- });
48
+ loadData()
49
+ .then((result) => { setDataSource(result); })
50
+ .catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
48
51
  }, [queryParamsDynDataList, dynDl]);
49
52
  const loadData = async () => {
50
- return await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, md?.id, layoutMode, queryParamsDynDataList ?? []);
53
+ return await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, md?.id, layoutMode, queryParamsDynDataList ?? [])
54
+ .catch((err) => { throw err; });
51
55
  };
52
56
  const getDescription = () => {
53
57
  if (!Array.isArray(values))
@@ -152,7 +156,8 @@ export const TMDynDataListItemChooserForm = (props) => {
152
156
  if (refreshCache)
153
157
  DataListCacheService.RemoveAll();
154
158
  TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
155
- let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(props.TID, props.MID, props.layoutMode, []);
159
+ let result = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(props.TID, props.MID, props.layoutMode, [])
160
+ .catch((err) => { TMSpinner.hide(); TMExceptionBoxManager.show({ exception: err }); });
156
161
  TMSpinner.hide();
157
162
  return result ? searchResultDescriptorToSimpleArray(result) ?? [] : [];
158
163
  };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ITMChooserProps, ITMChooserFormProps } from '../../ts';
3
+ interface ITMImageIDChooserProps extends ITMChooserProps {
4
+ /** Contiene i values selezionati -> attualmente sempre e solo 1 elemento */
5
+ value?: string;
6
+ readOnly?: boolean;
7
+ }
8
+ declare const TMImageIDChooser: React.FunctionComponent<ITMImageIDChooserProps>;
9
+ export default TMImageIDChooser;
10
+ interface ITMImageIDChooserFormProps extends ITMChooserFormProps<Image_Wrap> {
11
+ }
12
+ declare class Image_Wrap {
13
+ id: number;
14
+ imageID?: string;
15
+ }
16
+ export declare const TMImageIDChooserForm: React.FunctionComponent<ITMImageIDChooserFormProps>;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import { TMImageLibrary, IconSearch } from '../../helper';
4
+ import { StyledDivHorizontal } from '../base/Styled';
5
+ import TMSummary from '../editors/TMSummary';
6
+ import TMChooserForm from '../forms/TMChooserForm';
7
+ import { ImageIDList } from '../viewers/TMTidViewer';
8
+ const TMImageIDChooser = ({ backgroundColor, elementStyle, value, isModifiedWhen, placeHolder, validationItems = [], readOnly, onValueChanged }) => {
9
+ const [showChooser, setShowChooser] = useState(false);
10
+ const renderTemplate = () => {
11
+ return (_jsx(StyledDivHorizontal, { style: { minWidth: '125px' }, children: placeHolder && (!value || value == '')
12
+ ? _jsx("p", { children: placeHolder })
13
+ : _jsx(TMImageLibrary, { imageID: value }) }));
14
+ };
15
+ return (_jsxs(_Fragment, { children: [_jsx(TMSummary, { backgroundColor: backgroundColor, showClearButton: true, iconEditButton: _jsx(IconSearch, {}), onEditorClick: () => setShowChooser(true), onClearClick: () => onValueChanged?.(''), elementStyle: elementStyle, isModifiedWhen: isModifiedWhen, label: "Immagine", hasValue: value != undefined && value?.length > 0, template: renderTemplate(), validationItems: validationItems,
16
+ // openEditorOnSummaryClick={!readOnly}
17
+ readOnly: readOnly, disabled: readOnly }), showChooser &&
18
+ _jsx(TMImageIDChooserForm, { selectedIDs: [value], onClose: () => setShowChooser(false), onChoose: (img) => { onValueChanged?.(img); } })] }));
19
+ };
20
+ export default TMImageIDChooser;
21
+ class Image_Wrap {
22
+ constructor() {
23
+ this.id = 0;
24
+ }
25
+ }
26
+ export const TMImageIDChooserForm = (props) => {
27
+ const getItems = async () => {
28
+ let datasource = [];
29
+ let i = 0;
30
+ for (let img of Object.values(ImageIDList))
31
+ datasource.push({ id: i, imageID: img });
32
+ return datasource;
33
+ };
34
+ const cellRenderImageListItemIcon = (data) => {
35
+ let imageID = data.row.data;
36
+ return _jsx(TMImageLibrary, { imageID: imageID.imageID });
37
+ };
38
+ const cellRenderName = (data) => {
39
+ let imageID = data.row.data;
40
+ return _jsxs("p", { children: [imageID.imageID, " "] });
41
+ };
42
+ const dataColumns = useMemo(() => {
43
+ return [
44
+ { name: 'icon', dataField: 'imageID', caption: '', width: '40px', allowResizing: false, cellRender: cellRenderImageListItemIcon },
45
+ { name: 'name', dataField: 'imageID', caption: '', cellRender: cellRenderName }
46
+ ];
47
+ }, []);
48
+ return (_jsx(TMChooserForm, { title: "Immagini", hasShowId: false, allowMultipleSelection: false, height: props.height, width: '200px', showDefaultColumns: false, keyName: 'imageID', columns: dataColumns, selectedIDs: props.selectedIDs, dataSource: props.dataSource, getItems: getItems, onClose: props.onClose, onChoose: (IDs) => {
49
+ if (IDs && IDs.length > 0) {
50
+ props.onChoose?.(IDs[0]);
51
+ }
52
+ } }));
53
+ };
@@ -21,7 +21,7 @@ const TMMetadataChooser = ({ tmSession, dataSource, showEditButton = true, butto
21
21
  return undefined;
22
22
  };
23
23
  const renderTemplate = useMemo(() => {
24
- return (_jsxs(StyledDivHorizontal, { style: { width: 'max-content', height: '100%' }, children: [values && values.length > 0 && values[0].mid && values[0].mid > 0 && _jsx(TMMidViewer, { tmSession: tmSession, tid_mid: values[0], showIcon: true, showId: showId, showCompleteName: showCompleteMetadataName }), values && values.length > 0 && values[0].mid && values[0].mid < 0 && _jsx(TMMidViewer, { tmSession: tmSession, tid_mid: values[0], inputMd: getinputMd(), showIcon: true, showId: showId, showCompleteName: showCompleteMetadataName }), values && values.length > 1 && _jsx("p", { style: { marginLeft: '10px' }, children: `(+${values.length - 1} ${values.length == 2 ? 'altro' : 'altri'})` }), (values == undefined || values.length == 0) && _jsx("p", { children: placeHolder })] }));
24
+ return (_jsxs(StyledDivHorizontal, { style: { width: 'max-content', height: '100%' }, children: [values && values.length > 0 && values[0].mid && values[0].mid > 0 && _jsx(TMMidViewer, { tmSession: tmSession, tid_mid: values[0], showIcon: true, showId: showId, showCompleteName: showCompleteMetadataName }), values && values.length > 0 && values[0].mid && values[0].mid < 0 && _jsx(TMMidViewer, { tmSession: tmSession, tid_mid: values[0], inputMd: getinputMd(), showIcon: true, showId: showId, showCompleteName: showCompleteMetadataName }), values && values.length > 1 && _jsx("p", { style: { marginLeft: '10px' }, children: `(+${values.length - 1} ${values.length == 2 ? 'altro' : 'altri'})` }), (values == undefined || values.length == 0) && _jsx("p", { children: placeHolder ?? SDKUI_Localizator.SelectMetadata })] }));
25
25
  }, [values, tmSession, showId, showCompleteMetadataName, placeHolder]);
26
26
  return (_jsxs(_Fragment, { children: [_jsx(TMSummary, { label: label, width: width, height: height, disabled: disabled, validationItems: validationItems, backgroundColor: backgroundColor, buttons: buttons, placeHolder: placeHolder, fontSize: fontSize, showBorder: showBorder, borderRadius: borderRadius, hasValue: values && values.length > 0, showClearButton: showClearButton, showEditButton: showEditButton, iconEditButton: _jsx(IconSearch, { fontSize: 16 }), openEditorOnSummaryClick: openEditorOnSummaryClick, onEditorClick: () => {
27
27
  if (!disabled) {
@@ -15,6 +15,7 @@ interface TMLocalizedTextBoxProps {
15
15
  validationItems?: ValidationItem[];
16
16
  qd?: QueryDescriptor;
17
17
  tid?: number;
18
+ readOnly?: boolean;
18
19
  onValueChanged: (lang: CultureIDs, value: string) => void;
19
20
  }
20
21
  declare const TMLocalizedTextBox: React.FC<TMLocalizedTextBoxProps>;
@@ -40,7 +40,7 @@ const Popover = styled.div `
40
40
  border-radius: 4px;
41
41
  background-color: #fff;
42
42
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
43
- z-index: 1502;
43
+ z-index: 2000000001;
44
44
  padding: 8px;
45
45
  `;
46
46
  const Badge = styled.span `
@@ -71,7 +71,7 @@ export const getCultureIDImg = (cultureID) => {
71
71
  default: return it;
72
72
  }
73
73
  };
74
- const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_PT, value_ES, value_DE, isModifiedWhen, validationItems, qd, tid, onValueChanged, }) => {
74
+ const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_PT, value_ES, value_DE, isModifiedWhen, validationItems, qd, tid, readOnly, onValueChanged, }) => {
75
75
  const [isPopoverVisible, setIsPopoverVisible] = useState(false);
76
76
  const containerRef = useRef(null);
77
77
  const popoverRef = useRef(null);
@@ -122,6 +122,6 @@ const TMLocalizedTextBox = ({ label, value, value_IT, value_EN, value_FR, value_
122
122
  icon: (_jsxs(IconContainer, { children: [_jsx(IconLanguage, {}), localizedCount > 0 && _jsx(Badge, { children: localizedCount })] })),
123
123
  onClick: handleTogglePopover,
124
124
  };
125
- return (_jsxs(LocalizedContainer, { ref: containerRef, children: [(qd || tid) ? (_jsx(TMMetadataTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, qd: qd, tid: tid, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) })) : (_jsx(TMTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) })), isPopoverVisible && (_jsx(Portal, { popoverRef: popoverRef, children: _jsx(Popover, { ref: popoverRef, "$isVisible": isPopoverVisible, "$top": popoverPosition.top, "$left": popoverPosition.left, "$width": popoverPosition.width, onMouseDown: (e) => e.stopPropagation(), children: languages.map((lang) => ((qd || tid) ? (_jsx(TMMetadataTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', qd: qd, tid: tid, onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code)) : (_jsx(TMTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code)))) }) }))] }));
125
+ return (_jsxs(LocalizedContainer, { ref: containerRef, children: [(qd || tid) ? (_jsx(TMMetadataTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, qd: qd, tid: tid, readOnly: readOnly, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) })) : (_jsx(TMTextBox, { type: "text", label: label, value: value, isModifiedWhen: isModifiedWhen, buttons: [localizationButton], validationItems: validationItems, readOnly: readOnly, onValueChanged: (e) => onValueChanged(CultureIDs.None, e.target.value) })), isPopoverVisible && (_jsx(Portal, { popoverRef: popoverRef, children: _jsx(Popover, { ref: popoverRef, "$isVisible": isPopoverVisible, "$top": popoverPosition.top, "$left": popoverPosition.left, "$width": popoverPosition.width, onMouseDown: (e) => e.stopPropagation(), children: languages.map((lang) => ((qd || tid) ? (_jsx(TMMetadataTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', qd: qd, tid: tid, readOnly: readOnly, onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code)) : (_jsx(TMTextBox, { label: `${lang.label}`, showClearButton: true, icon: _jsx("img", { src: getCultureIDImg(lang.code), alt: "Lang", width: 18, height: 18 }), value: lang.value || '', readOnly: readOnly, onValueChanged: (e) => onValueChanged(lang.code, e.target.value) }, lang.code)))) }) }))] }));
126
126
  };
127
127
  export default TMLocalizedTextBox;
@@ -14,6 +14,7 @@ import { ChronologyMIDs, DraftsMIDs, DSAttachsMIDs } from "../../ts";
14
14
  import { TMNothingToShow } from "../features/documents/TMDcmtPreview";
15
15
  import TMAccordion from "../base/TMAccordion";
16
16
  import TabPanel, { Item } from 'devextreme-react/tab-panel';
17
+ import { TMExceptionBoxManager } from "../base/TMPopUp";
17
18
  export var ShowCheckBoxesMode;
18
19
  (function (ShowCheckBoxesMode) {
19
20
  ShowCheckBoxesMode[ShowCheckBoxesMode["Never"] = 0] = "Never";
@@ -165,7 +166,8 @@ const TMMetadataValues = ({ showCheckBoxes = ShowCheckBoxesMode.Never, checkPerm
165
166
  if (!d)
166
167
  return;
167
168
  let toBeRefreshed = [];
168
- let dynDlDataSource = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, mid, layoutMode, qParams);
169
+ let dynDlDataSource = await SDK_Globals.tmSession?.NewSearchEngine().GetDynDataListValuesAsync(tid, mid, layoutMode, qParams)
170
+ .catch((err) => { TMExceptionBoxManager.show({ exception: err }); });
169
171
  if (!d.onValueChanged_DynDataListsToBeRefreshed)
170
172
  return;
171
173
  let row = dynDlDataSource?.dtdResult?.rows?.filter(o => o[d.selectItemForValue ?? 0] == value);
@@ -81,15 +81,14 @@ const TMTextBox = ({ autoFocus, maxLength, labelColor, precision, fromModal = fa
81
81
  }, [maxValue, minValue, currentValue, currentType]);
82
82
  // Handle autofocus behavior on mount
83
83
  useEffect(() => {
84
- if (autoFocus && inputRef.current) {
85
- if (fromModal) // utilizzato per i textBox derivanti da una Modal che non riescono a utilizzare l'autofocus
86
- setTimeout(() => {
87
- inputRef.current && inputRef.current.focus(); // Focus the input field
88
- }, 100);
89
- else
90
- inputRef.current.focus(); // Focus the input field
91
- }
92
- }, [autoFocus]); // This effect runs when the autoFocus prop changes
84
+ if (!autoFocus || !inputRef.current)
85
+ return;
86
+ const delay = fromModal ? 100 : 50;
87
+ const timeoutId = setTimeout(() => {
88
+ inputRef.current?.focus();
89
+ }, delay);
90
+ return () => clearTimeout(timeoutId);
91
+ }, [autoFocus, fromModal]); // This effect runs when the autoFocus or fromModal prop changes
93
92
  useEffect(() => {
94
93
  if (formulaItems && formulaItems.length > 0) {
95
94
  let menuItems = [];
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useEffect, useMemo, useState } from 'react';
3
3
  import Logo from '../../../assets/Toppy-generico.png';
4
- import { DcmtTypeListCacheService, LayoutModes, SDK_Localizator } from '@topconsultnpm/sdk-ts';
4
+ import { ArchiveConstraints, DcmtTypeListCacheService, LayoutModes, SDK_Localizator } from '@topconsultnpm/sdk-ts';
5
5
  import { IconTree, SDKUI_Globals, SDKUI_Localizator, IconRecentlyViewed, IconPreview, IconShow, IconBoard, IconDcmtTypeSys, removeMruTid, getMoreInfoTasksForDocument } from '../../../helper';
6
6
  import { useDeviceType, DeviceType } from '../../base/TMDeviceProvider';
7
7
  import TMLayoutContainer from '../../base/TMLayout';
@@ -145,49 +145,36 @@ const TMArchive = ({ onDcmtTypeSelect = undefined, inputTID, inputFile = null, c
145
145
  export default TMArchive;
146
146
  const TMTreeSelectorWrapper = ({ isMobile, isSharedArchive, onSelectedTIDChanged }) => {
147
147
  const { setPanelVisibilityById, toggleMaximize, setToolbarButtonVisibility, countVisibleLeafPanels } = useTMPanelManagerContext();
148
- return (_jsx(TMTreeSelector, { layoutMode: LayoutModes.Ark, onClosePanel: !isMobile && countVisibleLeafPanels() > 1 ? () => setPanelVisibilityById('tmTreeSelector', false) : undefined, allowMaximize: !isMobile && countVisibleLeafPanels() > 1, onMaximizePanel: !isMobile && countVisibleLeafPanels() > 1 ? () => toggleMaximize("tmTreeSelector") : undefined, onSelectedTIDChanged: (tid) => {
149
- onSelectedTIDChanged?.(tid);
150
- if (isMobile)
151
- setPanelVisibilityById('tmDcmtForm', true);
152
- else {
153
- setPanelVisibilityById('tmDcmtForm', true);
154
- if (!isSharedArchive) {
155
- setPanelVisibilityById('tmDcmtPreview', true);
156
- }
157
- }
158
- if (!isSharedArchive) {
159
- setToolbarButtonVisibility('tmDcmtPreview', true);
160
- }
161
- setToolbarButtonVisibility('tmDcmtForm', true);
162
- } }));
148
+ const updatePanelsVisibility = async (tid) => {
149
+ if (!tid)
150
+ return;
151
+ const dtd = await DcmtTypeListCacheService.GetAsync(tid);
152
+ const isOnlyMetadata = dtd?.archiveConstraint === ArchiveConstraints.OnlyMetadata;
153
+ const previewVisible = !isSharedArchive && !isOnlyMetadata;
154
+ setPanelVisibilityById('tmDcmtPreview', previewVisible);
155
+ setToolbarButtonVisibility('tmDcmtPreview', previewVisible);
156
+ setPanelVisibilityById('tmDcmtForm', true);
157
+ setToolbarButtonVisibility('tmDcmtForm', true);
158
+ };
159
+ return (_jsx(TMTreeSelector, { layoutMode: LayoutModes.Ark, onClosePanel: !isMobile && countVisibleLeafPanels() > 1 ? () => setPanelVisibilityById('tmTreeSelector', false) : undefined, allowMaximize: !isMobile && countVisibleLeafPanels() > 1, onMaximizePanel: !isMobile && countVisibleLeafPanels() > 1 ? () => toggleMaximize("tmTreeSelector") : undefined, onSelectedTIDChanged: async (tid) => { updatePanelsVisibility(tid); onSelectedTIDChanged?.(tid); } }));
163
160
  };
164
161
  const TMRecentsManagerWrapper = ({ mruTIDs, currentTID, currentMruTID, deviceType, isSharedArchive, onSelectedTID, onDeletedTID }) => {
165
162
  const { setPanelVisibilityById, setToolbarButtonVisibility } = useTMPanelManagerContext();
163
+ // This avoids unnecessary re-renders by only recalculating when deviceType changes.
164
+ let isMobile = useMemo(() => { return deviceType === DeviceType.MOBILE; }, [deviceType]);
165
+ const updatePanelsVisibility = async (tid) => {
166
+ if (!tid)
167
+ return;
168
+ const dtd = await DcmtTypeListCacheService.GetAsync(tid);
169
+ const isOnlyMetadata = dtd?.archiveConstraint === ArchiveConstraints.OnlyMetadata;
170
+ const previewVisible = !isSharedArchive && !isOnlyMetadata;
171
+ setPanelVisibilityById('tmDcmtPreview', previewVisible);
172
+ setToolbarButtonVisibility('tmDcmtPreview', previewVisible);
173
+ setPanelVisibilityById('tmDcmtForm', true);
174
+ setToolbarButtonVisibility('tmDcmtForm', true);
175
+ };
166
176
  useEffect(() => {
167
- if (currentTID) {
168
- setPanelVisibilityById('tmDcmtForm', true);
169
- if (!isSharedArchive) {
170
- setToolbarButtonVisibility('tmDcmtPreview', true);
171
- }
172
- setToolbarButtonVisibility('tmDcmtForm', true);
173
- }
174
- }, [currentTID, isSharedArchive]);
175
- return (_jsx(TMRecentsManager, { accessFilter: 'canArchive', mruTIDs: mruTIDs, currentMruTID: currentMruTID, deviceType: deviceType, onSelectedTID: (tid) => {
176
- onSelectedTID?.(tid);
177
- if (deviceType === DeviceType.MOBILE) {
178
- setPanelVisibilityById('tmDcmtForm', true);
179
- }
180
- else {
181
- setPanelVisibilityById('tmDcmtForm', true);
182
- if (!isSharedArchive) {
183
- setPanelVisibilityById('tmDcmtPreview', true);
184
- }
185
- }
186
- if (!isSharedArchive) {
187
- setToolbarButtonVisibility('tmDcmtPreview', true);
188
- }
189
- setToolbarButtonVisibility('tmDcmtForm', true);
190
- }, onDeletedTID: (tid) => {
191
- onDeletedTID?.(tid);
192
- } }));
177
+ updatePanelsVisibility(currentTID);
178
+ }, [currentTID, isSharedArchive, isMobile]);
179
+ return (_jsx(TMRecentsManager, { accessFilter: "canArchive", mruTIDs: mruTIDs, currentMruTID: currentMruTID, deviceType: deviceType, onSelectedTID: async (tid) => { await updatePanelsVisibility(tid); onSelectedTID?.(tid); }, onDeletedTID: onDeletedTID }));
193
180
  };