@topconsultnpm/sdkui-react-beta 6.13.104 → 6.14.0

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.
@@ -24,6 +24,7 @@ interface ITMDcmtFormProps {
24
24
  canPrev?: boolean;
25
25
  isClosable?: boolean;
26
26
  groupId?: string;
27
+ invokedByTodo?: boolean;
27
28
  onNext?: () => void;
28
29
  onPrev?: () => void;
29
30
  onClose?: () => void;
@@ -9,7 +9,7 @@ import { DownloadTypes, FormModes } from '../../../ts';
9
9
  import { DeviceType, useDeviceType } from '../../base/TMDeviceProvider';
10
10
  import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
11
11
  import { handleArchiveVisibility, searchResultToMetadataValues } from '../../../helper/queryHelper';
12
- import { genUniqueId, IconShow, SDKUI_Localizator, IconBoard, IconDcmtTypeSys, IconDetailDcmts, svgToString, IconDownload, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo, SDKUI_Globals, IconPreview } from '../../../helper';
12
+ import { genUniqueId, IconShow, SDKUI_Localizator, IconBoard, IconDcmtTypeSys, IconDetailDcmts, svgToString, IconDownload, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo, SDKUI_Globals, IconPreview, defaultDcmtFormLayout } from '../../../helper';
13
13
  import { hasDetailRelations, hasMasterRelations, isXMLFileExt } from '../../../helper/dcmtsHelper';
14
14
  import { TMColors } from '../../../utils/theme';
15
15
  import { StyledFormButtonsContainer, StyledModalContainer, StyledToolbarCardContainer } from '../../base/Styled';
@@ -33,7 +33,7 @@ import { TMPanelManagerProvider, useTMPanelManagerContext } from '../../layout/p
33
33
  import TMPanelManagerContainer from '../../layout/panelManager/TMPanelManagerContainer';
34
34
  let abortControllerLocal = new AbortController();
35
35
  //#endregion
36
- const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes.Update, onClose, onSavedAsyncCallback, TID, DID, formMode = FormModes.Update, canNext, canPrev, count, itemIndex, onNext, onPrev, customRightSidebarItems = [], allowNavigation = true, allowRelations = true, isClosable = false, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showDcmtForm = true, showDcmtFormSidebar = true, showPreview = false, showBoard = false, showSysMetadata = false, onClosePreviewPanel, onCloseBlogPanel, onCloseSysMetadataPanel, titleModal, isModal = false, widthModal = "100%", heightModal = "100%", groupId }) => {
36
+ 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 }) => {
37
37
  const mruTIDs = SDKUI_Globals.userSettings.archivingSettings.mruTIDs;
38
38
  const [id, setID] = useState('');
39
39
  const [showWaitPanelLocal, setShowWaitPanelLocal] = useState(false);
@@ -58,13 +58,8 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
58
58
  const [isOpenDetails, setIsOpenDetails] = useState(false);
59
59
  const [isOpenMaster, setIsOpenMaster] = useState(false);
60
60
  const [secondaryMasterDcmts, setSecondaryMasterDcmts] = useState([]);
61
- const [isOpenDcmtForm, setIsOpenDcmtForm] = useState(false);
62
- const [isOpenPreview, setIsOpenPreview] = useState(false);
63
- const [isOpenSysMetadata, setIsOpenSysMetadata] = useState(false);
64
- const [isOpenBoard, setIsOpenBoard] = useState(false);
65
61
  const [isOpenDistinctValues, setIsOpenDistinctValues] = useState(false);
66
62
  const [isOpenFormulaEditor, setIsOpenFormulaEditor] = useState(false);
67
- const [isOpenTags, setIsOpenTags] = useState(false);
68
63
  const [currentTIDHasDetailRelations, setCurrentTIDHasDetailRelations] = useState();
69
64
  const [currentTIDHasMasterRelations, setCurrentTIDHasMasterRelations] = useState();
70
65
  const [currentDcmt, setCurrentDcmt] = useState();
@@ -122,10 +117,6 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
122
117
  }
123
118
  }
124
119
  }, [formData]);
125
- useEffect(() => { setIsOpenBoard(showBoard); }, [showBoard]);
126
- useEffect(() => { setIsOpenSysMetadata(showSysMetadata); }, [showSysMetadata]);
127
- useEffect(() => { setIsOpenDcmtForm(showDcmtForm); }, [showDcmtForm]);
128
- useEffect(() => { setIsOpenPreview(showPreview); }, [showPreview]);
129
120
  useEffect(() => {
130
121
  hasDetailRelations(TID).then((value) => setCurrentTIDHasDetailRelations(value));
131
122
  hasMasterRelations(TID).then((value) => setCurrentTIDHasMasterRelations(value));
@@ -439,18 +430,56 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
439
430
  const tmDcmtPreview = useMemo(() => _jsx(TMDcmtPreviewWrapper, { currentDcmt: currentDcmt, dcmtFile: dcmtFile, deviceType: deviceType, fromDTD: fromDTD, layoutMode: layoutMode, onFileUpload: (setFile) => {
440
431
  setDcmtFile(setFile);
441
432
  } }), [currentDcmt, dcmtFile, deviceType, fromDTD, layoutMode]);
442
- const allInitialPanelVisibility = {
443
- 'tmDcmtForm': true,
444
- 'tmBlog': false,
445
- 'tmSysMetadata': false,
446
- 'tmDcmtPreview': true,
447
- };
448
- const initialPanelDimensions = {
433
+ const normalizedTID = TID !== undefined ? Number(TID) : undefined;
434
+ const dcmtFormSettings = SDKUI_Globals.userSettings.dcmtFormSettings.find(o => o.TID === normalizedTID);
435
+ const layout = dcmtFormSettings?.layout;
436
+ const layoutToDo = dcmtFormSettings?.layoutToDo;
437
+ const layoutObj = invokedByTodo ? layoutToDo : layout;
438
+ const defaultPanelDimensions = {
449
439
  'tmDcmtForm': { width: '20%', height: '100%' },
450
440
  'tmBlog': { width: '30%', height: '100%' },
451
441
  'tmSysMetadata': { width: '20%', height: '100%' },
452
442
  'tmDcmtPreview': { width: '30%', height: '100%' },
453
443
  };
444
+ const allInitialPanelVisibility = useMemo(() => {
445
+ if (layoutObj) {
446
+ return {
447
+ 'tmDcmtForm': layoutObj['tmDcmtForm']?.visible ?? true,
448
+ 'tmBlog': layoutObj['tmBlog']?.visible ?? false,
449
+ 'tmSysMetadata': layoutObj['tmSysMetadata']?.visible ?? false,
450
+ 'tmDcmtPreview': layoutObj['tmDcmtPreview']?.visible ?? true,
451
+ };
452
+ }
453
+ return {
454
+ 'tmDcmtForm': true,
455
+ 'tmBlog': false,
456
+ 'tmSysMetadata': false,
457
+ 'tmDcmtPreview': true,
458
+ };
459
+ }, [layoutObj]);
460
+ const initialPanelDimensions = useMemo(() => {
461
+ if (layoutObj) {
462
+ return {
463
+ 'tmDcmtForm': {
464
+ width: layoutObj['tmDcmtForm']?.width ?? '20%',
465
+ height: layoutObj['tmDcmtForm']?.height ?? '100%',
466
+ },
467
+ 'tmBlog': {
468
+ width: layoutObj['tmBlog']?.width ?? '30%',
469
+ height: layoutObj['tmBlog']?.height ?? '100%',
470
+ },
471
+ 'tmSysMetadata': {
472
+ width: layoutObj['tmSysMetadata']?.width ?? '20%',
473
+ height: layoutObj['tmSysMetadata']?.height ?? '100%',
474
+ },
475
+ 'tmDcmtPreview': {
476
+ width: layoutObj['tmDcmtPreview']?.width ?? '30%',
477
+ height: layoutObj['tmDcmtPreview']?.height ?? '100%',
478
+ },
479
+ };
480
+ }
481
+ return defaultPanelDimensions;
482
+ }, [layoutObj]);
454
483
  const initialPanels = useMemo(() => [
455
484
  {
456
485
  id: 'tmDcmtForm',
@@ -463,7 +492,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
463
492
  title: fromDTD?.nameLoc,
464
493
  allowMaximize: !isMobile,
465
494
  onBack: (isClosable && deviceType !== DeviceType.MOBILE) ? undefined : handleClose,
466
- onClose: isClosable ? () => setIsOpenDcmtForm(false) : undefined,
495
+ onClose: isClosable ? () => { } : undefined,
467
496
  toolbar: allowNavigation ? formToolbar : _jsx(_Fragment, {})
468
497
  },
469
498
  },
@@ -493,6 +522,36 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
493
522
  toolbarOptions: { icon: _jsx(IconShow, { fontSize: 24 }), disabled: isPreviewDisabled, visible: true, orderNumber: 4, isActive: allInitialPanelVisibility['tmDcmtPreview'] }
494
523
  }
495
524
  ], [tmDcmtForm, tmBlog, tmSysMetadata, tmDcmtPreview, isPreviewDisabled, isBoardDisabled, isSysMetadataDisabled, isClosable]);
525
+ function saveLayout(panelVisibility, panelDimensions) {
526
+ // console.log('panelVisibility', panelVisibility)
527
+ // console.log('panelDimensions', panelDimensions)
528
+ if (normalizedTID === undefined)
529
+ return;
530
+ const layoutPanels = {};
531
+ Object.keys(panelVisibility).forEach(id => {
532
+ layoutPanels[id] = {
533
+ visible: panelVisibility[id],
534
+ width: panelDimensions[id]?.width ?? defaultPanelDimensions[id]?.width ?? '100%',
535
+ height: panelDimensions[id]?.height ?? defaultPanelDimensions[id]?.height ?? '100%'
536
+ };
537
+ });
538
+ // console.log('layoutPanels', layoutPanels)
539
+ const settings = SDKUI_Globals.userSettings.dcmtFormSettings;
540
+ const idx = settings.findIndex(s => Number(s.TID) === normalizedTID);
541
+ const prevSetting = settings[idx] ?? {};
542
+ const newSetting = {
543
+ TID: normalizedTID,
544
+ layout: invokedByTodo ? (prevSetting.layout ?? defaultDcmtFormLayout) : layoutPanels,
545
+ layoutToDo: invokedByTodo ? layoutPanels : (prevSetting.layoutToDo ?? defaultDcmtFormLayout),
546
+ };
547
+ if (idx >= 0) {
548
+ settings[idx] = newSetting;
549
+ }
550
+ else {
551
+ settings.push(newSetting);
552
+ }
553
+ SDKUI_Globals.userSettings.dcmtFormSettings = [...settings];
554
+ }
496
555
  const renderDcmtForm = () => {
497
556
  return (_jsxs("div", { style: {
498
557
  display: 'flex',
@@ -503,7 +562,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
503
562
  height: '100%',
504
563
  }, children: [_jsxs(TMLayoutWaitingContainer, { direction: 'vertical', showWaitPanel: useWaitPanelLocalState ? showWaitPanelLocal : showWaitPanel, showWaitPanelPrimary: useWaitPanelLocalState ? showPrimaryLocal : showPrimary, showWaitPanelSecondary: useWaitPanelLocalState ? showSecondaryLocal : showSecondary, waitPanelTitle: useWaitPanelLocalState ? waitPanelTitleLocal : waitPanelTitle, waitPanelTextPrimary: useWaitPanelLocalState ? waitPanelTextPrimaryLocal : waitPanelTextPrimary, waitPanelValuePrimary: useWaitPanelLocalState ? waitPanelValuePrimaryLocal : waitPanelValuePrimary, waitPanelMaxValuePrimary: useWaitPanelLocalState ? waitPanelMaxValuePrimaryLocal : waitPanelMaxValuePrimary, waitPanelTextSecondary: useWaitPanelLocalState ? waitPanelTextSecondaryLocal : waitPanelTextSecondary, waitPanelValueSecondary: useWaitPanelLocalState ? waitPanelValueSecondaryLocal : waitPanelValueSecondary, waitPanelMaxValueSecondary: useWaitPanelLocalState ? waitPanelMaxValueSecondaryLocal : waitPanelMaxValueSecondary, isCancelable: useWaitPanelLocalState ? dcmtFile ? dcmtFile.size >= 1000000 : false : true, abortController: useWaitPanelLocalState ? abortControllerLocal : abortController, children: [(groupId && groupId.length > 0)
505
564
  ? _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar })
506
- : _jsx(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'tmDcmtForm', children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar }) }), isOpenDistinctValues &&
565
+ : _jsx(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'tmDcmtForm', children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", parentId: groupId, showToolbar: showDcmtFormSidebar, onLayoutChanged: saveLayout }) }), isOpenDistinctValues &&
507
566
  _jsx(TMDistinctValues, { tid: TID, mid: focusedMetadataValue?.mid, isModal: true, showHeader: false, layoutMode: layoutMode, onSelectionChanged: (e) => {
508
567
  if (!e)
509
568
  return;
@@ -526,7 +585,8 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
526
585
  return (_jsx(StyledModalContainer, { style: { backgroundColor: 'white' }, children: _jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: [dcmt], isForMaster: true, allowNavigation: false, onBack: () => handleRemoveItem(dcmt.TID, dcmt.DID), appendMasterDcmts: handleAddItem }) }, `${index}-${dcmt.DID}`));
527
586
  })] })] }));
528
587
  };
529
- return (_jsx(_Fragment, { children: (isModal && onClose) ? _jsx(_Fragment, { children: _jsx(TMModal, { title: titleModal, onClose: handleClose, width: widthModal ?? '100%', height: heightModal ?? '100%', hidePopup: false, askClosingConfirm: true, children: _jsx("div", { style: { width: "100%", height: "100%", display: 'block', padding: "4px" }, children: renderDcmtForm() }) }) })
588
+ return (_jsx(_Fragment, { children: (isModal && onClose)
589
+ ? _jsx(TMModal, { title: titleModal, onClose: handleClose, width: widthModal ?? '100%', height: heightModal ?? '100%', hidePopup: false, askClosingConfirm: true, children: _jsx("div", { style: { width: "100%", height: "100%", display: 'block', padding: "4px" }, children: renderDcmtForm() }) })
530
590
  : renderDcmtForm() }));
531
591
  };
532
592
  export default TMDcmtForm;
@@ -1,9 +1,12 @@
1
- import { TMPanelDefinition, TMPanelDirection } from './types';
1
+ import { TMPanelDefinition, TMPanelDimensionsMap, TMPanelDirection } from './types';
2
2
  interface TMPanelManagerContainerProps {
3
3
  panels: Array<TMPanelDefinition>;
4
4
  showToolbar: boolean;
5
5
  direction: TMPanelDirection;
6
6
  parentId?: string;
7
+ onLayoutChanged?: (panelVisibility: {
8
+ [id: string]: boolean;
9
+ }, panelDimensions: TMPanelDimensionsMap) => void;
7
10
  }
8
11
  declare const TMPanelManagerContainer: (props: TMPanelManagerContainerProps) => import("react/jsx-runtime").JSX.Element | null;
9
12
  export default TMPanelManagerContainer;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useRef, useMemo } from 'react';
2
+ import React, { useRef, useMemo, useEffect } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { useTMPanelManagerContext } from './TMPanelManagerContext';
5
5
  import TMPanelWrapper from './TMPanelWrapper';
@@ -23,8 +23,13 @@ const StyledResizerGutter = styled.div `
23
23
  z-index: 10;
24
24
  `;
25
25
  const TMPanelManagerContainer = (props) => {
26
- const { panels, showToolbar, direction, parentId } = props;
27
- const { panelVisibility, setPanelDimensionsById, hasVisiblePanels, maximizedPanels, updateIsResizingActive } = useTMPanelManagerContext();
26
+ const { panels, showToolbar, direction, parentId, onLayoutChanged } = props;
27
+ const { panelVisibility, panelDimensions, setPanelDimensionsById, hasVisiblePanels, maximizedPanels, updateIsResizingActive } = useTMPanelManagerContext();
28
+ // Returns data to parent for saving layout, only for desktop
29
+ useEffect(() => {
30
+ // console.log('useEffect panelVisibility, panelDimensions', panelVisibility, panelDimensions)
31
+ deviceType === DeviceType.DESKTOP && onLayoutChanged?.(panelVisibility, panelDimensions);
32
+ }, [panelVisibility, panelDimensions]);
28
33
  // Get the current device type (e.g., mobile, tablet, desktop) using a custom hook
29
34
  const deviceType = useDeviceType();
30
35
  // This avoids unnecessary re-renders by only recalculating when deviceType changes
@@ -14,6 +14,7 @@ export declare class UserSettings {
14
14
  fullTextSettings: FullTextSettings;
15
15
  searchSettings: SearchSettings;
16
16
  themeSettings: ThemeSettings;
17
+ dcmtFormSettings: DcmtFormSettings[];
17
18
  constructor(skipCssUpdate?: boolean);
18
19
  /** Load settings from local storage or other sources */
19
20
  static LoadSettings(userID: number | undefined, archiveID: string | undefined): UserSettings;
@@ -54,6 +55,30 @@ export declare class AdvancedSettings {
54
55
  expertMode: number;
55
56
  };
56
57
  }
58
+ export declare const defaultDcmtFormLayout: {
59
+ [id: string]: {
60
+ visible: boolean;
61
+ width: string;
62
+ height: string;
63
+ };
64
+ };
65
+ export declare class DcmtFormSettings {
66
+ TID: number | undefined;
67
+ layout: {
68
+ [id: string]: {
69
+ visible: boolean;
70
+ width: string;
71
+ height: string;
72
+ };
73
+ };
74
+ layoutToDo: {
75
+ [id: string]: {
76
+ visible: boolean;
77
+ width: string;
78
+ height: string;
79
+ };
80
+ };
81
+ }
57
82
  export declare class SDKUI_Globals {
58
83
  static userSettings: UserSettings;
59
84
  }
@@ -17,6 +17,7 @@ export class UserSettings {
17
17
  this.fullTextSettings = new FullTextSettings();
18
18
  this.searchSettings = new SearchSettings();
19
19
  this.themeSettings = new ThemeSettings(true);
20
+ this.dcmtFormSettings = [];
20
21
  this.themeSettings = new ThemeSettings(skipCssUpdate);
21
22
  }
22
23
  /** Load settings from local storage or other sources */
@@ -114,6 +115,18 @@ export class AdvancedSettings {
114
115
  };
115
116
  }
116
117
  }
118
+ export const defaultDcmtFormLayout = {
119
+ 'tmDcmtForm': { visible: true, width: '20%', height: '100%' },
120
+ 'tmBlog': { visible: false, width: '30%', height: '100%' },
121
+ 'tmSysMetadata': { visible: false, width: '20%', height: '100%' },
122
+ 'tmDcmtPreview': { visible: true, width: '30%', height: '100%' },
123
+ };
124
+ export class DcmtFormSettings {
125
+ constructor() {
126
+ this.layout = defaultDcmtFormLayout;
127
+ this.layoutToDo = defaultDcmtFormLayout;
128
+ }
129
+ }
117
130
  export class SDKUI_Globals {
118
131
  }
119
132
  SDKUI_Globals.userSettings = new UserSettings(true);
@@ -68,12 +68,11 @@ export function useDcmtOperations() {
68
68
  });
69
69
  }
70
70
  setWaitPanelValuePrimary(i + 1);
71
+ const fileURL = window.URL.createObjectURL(file);
71
72
  if (downloadMode === "openInNewWindow") {
72
- const fileURL = window.URL.createObjectURL(file);
73
73
  window.open(fileURL, '_blank', 'noopener');
74
74
  }
75
75
  else {
76
- const fileURL = window.URL.createObjectURL(file);
77
76
  const alink2 = document.createElement('a');
78
77
  alink2.href = fileURL;
79
78
  alink2.download = inputDcmts[i].fileName ?? file?.name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.13.104",
3
+ "version": "6.14.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -42,7 +42,7 @@
42
42
  "lib"
43
43
  ],
44
44
  "dependencies": {
45
- "@topconsultnpm/sdk-ts-beta": "6.13.11",
45
+ "@topconsultnpm/sdk-ts-beta": "6.14.0",
46
46
  "buffer": "^6.0.3",
47
47
  "devextreme": "24.2.6",
48
48
  "devextreme-react": "24.2.6",