@topconsultnpm/sdkui-react-beta 6.12.87 → 6.12.88
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.
@@ -13,6 +13,7 @@ interface ITMMessageBox extends ITMPopup {
|
|
13
13
|
buttons?: ButtonNames[];
|
14
14
|
message?: string | React.ReactNode;
|
15
15
|
onButtonClick?: (e: ButtonNames) => void;
|
16
|
+
parentId?: string;
|
16
17
|
}
|
17
18
|
interface ITMExceptionBox extends ITMPopup {
|
18
19
|
exception?: any;
|
@@ -21,6 +22,6 @@ declare class TMExceptionBoxManager {
|
|
21
22
|
static show({ title, exception }: ITMExceptionBox): void;
|
22
23
|
}
|
23
24
|
declare class TMMessageBoxManager {
|
24
|
-
static show({ title, buttons, onButtonClick, message }: ITMMessageBox): void;
|
25
|
+
static show({ title, buttons, onButtonClick, message, parentId }: ITMMessageBox): void;
|
25
26
|
}
|
26
27
|
export { TMExceptionBoxManager, TMMessageBoxManager };
|
@@ -126,11 +126,22 @@ class TMExceptionBoxManager {
|
|
126
126
|
}
|
127
127
|
}
|
128
128
|
class TMMessageBoxManager {
|
129
|
-
static show({ title, buttons, onButtonClick, message }) {
|
129
|
+
static show({ title, buttons, onButtonClick, message, parentId }) {
|
130
130
|
let container = document.createElement('div');
|
131
|
-
|
131
|
+
if (parentId) {
|
132
|
+
const parent = document.getElementById(parentId);
|
133
|
+
if (parent) {
|
134
|
+
parent.appendChild(container);
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
document.body.appendChild(container);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
document.body.appendChild(container);
|
142
|
+
}
|
132
143
|
const root = ReactDOM.createRoot(container);
|
133
|
-
root.render(_jsx(TMDeviceProvider, { children: React.createElement(TMMessageBox, { title
|
144
|
+
root.render(_jsx(TMDeviceProvider, { children: React.createElement(TMMessageBox, { title, buttons, onButtonClick, message }) }));
|
134
145
|
}
|
135
146
|
}
|
136
147
|
export { TMExceptionBoxManager, TMMessageBoxManager };
|
@@ -9,13 +9,13 @@ 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, IconCloseCircle, IconShow, SDKUI_Localizator, IconBoard, IconDcmtTypeSys, IconDataList, IconDetailDcmts, svgToString, IconDownload, IconHide, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo
|
12
|
+
import { genUniqueId, IconCloseCircle, IconShow, SDKUI_Localizator, IconBoard, IconDcmtTypeSys, IconDataList, IconDetailDcmts, svgToString, IconDownload, IconHide, calcIsModified, IconMenuVertical, Globalization, getListMaxItems, getSystemMetadata, IconBoxArchiveIn, IconClear, IconUndo } 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';
|
16
16
|
import ShowAlert from '../../base/TMAlert';
|
17
17
|
import TMButton from '../../base/TMButton';
|
18
|
-
import
|
18
|
+
import { TMSplitterLayout, TMLayoutItem } from '../../base/TMLayout';
|
19
19
|
import { TMExceptionBoxManager, TMMessageBoxManager, ButtonNames } from '../../base/TMPopUp';
|
20
20
|
import TMSpinner from '../../base/TMSpinner';
|
21
21
|
import TMToolbarCard from '../../base/TMToolbarCard';
|
@@ -30,7 +30,6 @@ import TMMasterDetailDcmts from './TMMasterDetailDcmts';
|
|
30
30
|
import TMDcmtBlog from './TMDcmtBlog';
|
31
31
|
import { useInputAttachmentsDialog } from '../../../hooks/useInputDialog';
|
32
32
|
import TMModal from '../../base/TMModal';
|
33
|
-
import toppy from '../../../assets/Toppy-generico.png';
|
34
33
|
let abortControllerLocal = new AbortController();
|
35
34
|
//#endregion
|
36
35
|
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, showDcmtForm = true, showDcmtFormSidebar = true, showPreview = false, showBoard = false, showSysMetadata = false, onClosePreview, titleModal, isModal = false, widthModal = "100%", heightModal = "100%" }) => {
|
@@ -72,7 +71,6 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
72
71
|
const [dcmtFile, setDcmtFile] = useState(null);
|
73
72
|
const [focusedMetadataValue, setFocusedMetadataValue] = useState();
|
74
73
|
const [showAll, setShowAll] = useState(false);
|
75
|
-
const [showConfirmForClose, setShowConfirmForClose] = useState(false);
|
76
74
|
const { openConfirmAttachmentsDialog, ConfirmAttachmentsDialog } = useInputAttachmentsDialog();
|
77
75
|
const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync } = useDcmtOperations();
|
78
76
|
const deviceType = useDeviceType();
|
@@ -491,7 +489,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
491
489
|
_jsx(StyledModalContainer, { style: { backgroundColor: 'white' }, children: _jsx(TMMasterDetailDcmts, { deviceType: deviceType, isForMaster: false, inputDcmts: getSelectionDcmtInfo(), allowNavigation: allowNavigation, canNext: canNext, canPrev: canPrev, onNext: onNext, onPrev: onPrev, onBack: () => setIsOpenDetails(false) }) }), isOpenMaster &&
|
492
490
|
_jsxs(StyledModalContainer, { style: { backgroundColor: 'white' }, children: [_jsx(TMMasterDetailDcmts, { deviceType: deviceType, inputDcmts: getSelectionDcmtInfo(), isForMaster: true, allowNavigation: allowNavigation, canNext: canNext, canPrev: canPrev, onNext: onNext, onPrev: onPrev, onBack: () => setIsOpenMaster(false), appendMasterDcmts: handleAddItem }), secondaryMasterDcmts.length > 0 && secondaryMasterDcmts.map((dcmt, index) => {
|
493
491
|
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}`));
|
494
|
-
})] })] }));
|
492
|
+
})] }), (isModal && onClose) && _jsx("div", { id: "TMDcmtFormShowConfirmForClose-" + id })] }));
|
495
493
|
};
|
496
494
|
const handleClose = () => {
|
497
495
|
if (!isModified) {
|
@@ -514,31 +512,7 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
514
512
|
}
|
515
513
|
});
|
516
514
|
};
|
517
|
-
|
518
|
-
if (!isModified) {
|
519
|
-
onClose?.();
|
520
|
-
return;
|
521
|
-
}
|
522
|
-
// If confirmation for closing is not yet required, prompt the user by setting showConfirmForClose to true
|
523
|
-
if (showConfirmForClose === false) {
|
524
|
-
setShowConfirmForClose(true);
|
525
|
-
}
|
526
|
-
else {
|
527
|
-
// If confirmation is already shown, reset it and proceed with closing the modal
|
528
|
-
setShowConfirmForClose(false);
|
529
|
-
onClose?.();
|
530
|
-
}
|
531
|
-
};
|
532
|
-
return (_jsx(_Fragment, { children: (isModal && onClose) ? _jsx(_Fragment, { children: _jsxs(TMModal, { title: titleModal, onClose: closeModal, width: widthModal ?? '100%', height: heightModal ?? '100%', hidePopup: false, children: [_jsx("div", { style: { width: "100%", height: "100%", display: 'block', padding: "4px" }, children: renderDcmtForm() }), showConfirmForClose && _jsx(TMModal, { title: titleModal, onClose: () => { setShowConfirmForClose(false); }, width: calcResponsiveSizes(deviceType, '400px', '300px', '250px'), height: '180px', hidePopup: false, children: _jsxs(TMLayoutContainer, { children: [_jsx(TMLayoutItem, { height: 'calc(100% - 40px)', children: _jsx(TMCard, { showBorder: false, scrollY: true, children: _jsxs(TMLayoutContainer, { direction: 'horizontal', alignItems: 'center', justifyContent: 'center', gap: 10, children: [_jsx(TMLayoutItem, { width: 'fit-content', children: _jsx("img", { style: { transform: 'translateY(8px)' }, src: toppy, width: 60, height: 75, alt: "" }) }), _jsx(TMLayoutItem, { height: 'fit-content', children: _jsxs("div", { children: [" ", SDKUI_Localizator.SaveQuestion, " "] }) })] }) }) }), _jsx(TMLayoutItem, { height: '40px', children: _jsxs("div", { style: { position: "relative", display: "flex", flexDirection: "row", justifyContent: "flex-end", alignItems: "center", gap: "5px", padding: "5px", userSelect: "none", borderTop: "1px solid #f3f3f3", backgroundColor: "#ffffff", zIndex: 100, }, children: [_jsx(TMButton, { caption: SDKUI_Localizator.Yes, fontSize: '1.1rem', color: 'primaryOutline', btnStyle: 'text', onClick: async () => {
|
533
|
-
await onSavedAsync?.();
|
534
|
-
setShowConfirmForClose(false);
|
535
|
-
onClose?.();
|
536
|
-
}, showTooltip: false }), _jsx(TMButton, { caption: SDKUI_Localizator.No, fontSize: '1.1rem', btnStyle: 'text', onClick: () => {
|
537
|
-
setShowConfirmForClose(false);
|
538
|
-
onClose?.();
|
539
|
-
}, showTooltip: false, color: 'error' }), _jsx(TMButton, { caption: SDKUI_Localizator.Cancel, fontSize: '1.1rem', btnStyle: 'text', onClick: () => {
|
540
|
-
setShowConfirmForClose(false);
|
541
|
-
}, showTooltip: false, color: 'error' })] }) })] }) })] }) })
|
515
|
+
return (_jsx(_Fragment, { children: (isModal && onClose) ? _jsx(_Fragment, { children: _jsx(TMModal, { title: titleModal, onClose: handleClose, width: widthModal ?? '100%', height: heightModal ?? '100%', hidePopup: false, children: _jsx("div", { style: { width: "100%", height: "100%", display: 'block', padding: "4px" }, children: renderDcmtForm() }) }) })
|
542
516
|
: renderDcmtForm() }));
|
543
517
|
};
|
544
518
|
export default TMDcmtForm;
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
2
2
|
import { useState } from 'react';
|
3
3
|
import { ResultTypes } from '@topconsultnpm/sdk-ts-beta';
|
4
4
|
import { FormModes } from '../../ts/types';
|
5
|
-
import { IconArrowDown, IconArrowLeft, IconArrowUp, IconCloseCircle, IconHide, IconSave, IconShow, IconUndo, IconWarning, LocalizeFormModes, SDKUI_Localizator,
|
5
|
+
import { IconArrowDown, IconArrowLeft, IconArrowUp, IconCloseCircle, IconHide, IconSave, IconShow, IconUndo, IconWarning, LocalizeFormModes, SDKUI_Localizator, getColor } from '../../helper';
|
6
6
|
import { ButtonNames, TMExceptionBoxManager, TMMessageBoxManager } from '../base/TMPopUp';
|
7
7
|
import TMLayoutContainer, { TMCard, TMLayoutItem, TMSplitterLayout } from '../base/TMLayout';
|
8
8
|
import { StyledResultTypeContainer, StyledToolbarForm } from '../base/Styled';
|
@@ -11,11 +11,9 @@ import { TMColors } from '../../utils/theme';
|
|
11
11
|
import TMValidationItemsList from '../grids/TMValidationItemsList';
|
12
12
|
import TMModal from '../base/TMModal';
|
13
13
|
import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
|
14
|
-
import toppy from '../../assets/Toppy-generico.png';
|
15
14
|
const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipIsModifiedCheck = false, title, children, isModal, exception, customToolbarElements, hasNavigation, showSaveButton = true, showBackButton, showWarningsCount = true, showErrorCount = true, showUndoButton = true, onClose, onSaveAsync, onNext, onPrev, canNext, canPrev, isModified, onShowList, validationItems = [], onUndo, onCancel, width, height }) => {
|
16
15
|
const [showList, setShowList] = useState(true);
|
17
16
|
const [showErrorGrid, setShowErrorGrid] = useState(false);
|
18
|
-
const [showConfirmForClose, setShowConfirmForClose] = useState(false);
|
19
17
|
const deviceType = useDeviceType();
|
20
18
|
const doSaveAsync = async () => { try {
|
21
19
|
await onSaveAsync?.();
|
@@ -72,6 +70,7 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipI
|
|
72
70
|
return;
|
73
71
|
}
|
74
72
|
TMMessageBoxManager.show({
|
73
|
+
parentId: isModal ? "TMSaveFormShowConfirmForClose-" + id : undefined,
|
75
74
|
message: SDKUI_Localizator.SaveQuestion, buttons: [ButtonNames.YES, ButtonNames.NO, ButtonNames.CANCEL],
|
76
75
|
onButtonClick: async (e) => {
|
77
76
|
try {
|
@@ -89,25 +88,6 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipI
|
|
89
88
|
}
|
90
89
|
});
|
91
90
|
};
|
92
|
-
const closeModal = () => {
|
93
|
-
// If there are no unsaved modifications or we are skipping the modification check, close the modal immediately
|
94
|
-
if (!isModified || skipIsModifiedCheck) {
|
95
|
-
onClose?.();
|
96
|
-
deviceType === DeviceType.MOBILE && setShowList(true), onShowList?.(true);
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
// If confirmation for closing is not yet required, prompt the user by setting showConfirmForClose to true
|
100
|
-
if (showConfirmForClose === false) {
|
101
|
-
setShowConfirmForClose(true);
|
102
|
-
}
|
103
|
-
else {
|
104
|
-
// If confirmation is already shown, reset it and proceed with closing the modal
|
105
|
-
setShowConfirmForClose(false);
|
106
|
-
onClose?.();
|
107
|
-
deviceType === DeviceType.MOBILE && setShowList(true), onShowList?.(true);
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
};
|
111
91
|
const warningsCount = validationItems.filter(o => o.ResultType == ResultTypes.WARNING).length;
|
112
92
|
const errorsCount = validationItems.filter(o => o.ResultType == ResultTypes.ERROR).length;
|
113
93
|
const renderSaveForm = () => {
|
@@ -118,19 +98,9 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, showToolbar = true, skipI
|
|
118
98
|
_jsx("div", { style: { right: '50px', position: 'absolute' }, children: deviceType !== DeviceType.MOBILE && onCancel && _jsx(TMButton, { icon: _jsx(IconCloseCircle, {}), onClick: onCancel, btnStyle: 'toolbar', caption: SDKUI_Localizator.Cancel, color: 'tertiary' }) })] }) }), _jsx(TMLayoutItem, { height: showToolbar ? 'calc(100% - 35px)' : '100%', children: _jsxs(TMSplitterLayout, { separatorSize: 4, direction: 'vertical', start: showErrorGrid && validationItems.length > 0 ? ['80%', '20%'] : ['100%', '0'], min: ['0', '0'], children: [_jsx(TMCard, { showBorder: false, children: exception
|
119
99
|
?
|
120
100
|
_jsx("div", { style: { width: '100%', height: '100%', marginTop: '50px', display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column', color: getColor('error') }, children: 'Si è verificato un errore' })
|
121
|
-
: _jsx(_Fragment, { children: children }) }), showErrorGrid && validationItems.length > 0 ? _jsx(TMCard, { scrollY: true, padding: false, showBorder: false, children: _jsx(TMValidationItemsList, { validationItems: validationItems }) }) : _jsx(_Fragment, {})] }) })] }));
|
101
|
+
: _jsx(_Fragment, { children: children }) }), showErrorGrid && validationItems.length > 0 ? _jsx(TMCard, { scrollY: true, padding: false, showBorder: false, children: _jsx(TMValidationItemsList, { validationItems: validationItems }) }) : _jsx(_Fragment, {})] }) }), (isModal && onClose) && _jsx("div", { id: "TMSaveFormShowConfirmForClose-" + id })] }));
|
122
102
|
};
|
123
|
-
return (_jsx(_Fragment, { children: (isModal && onClose) ? _jsx(_Fragment, { children:
|
124
|
-
deviceType === DeviceType.MOBILE ? (await onSaveAsync?.(), setShowList(true), onShowList?.(true)) : await onSaveAsync?.();
|
125
|
-
setShowConfirmForClose(false);
|
126
|
-
onClose?.();
|
127
|
-
}, showTooltip: false }), _jsx(TMButton, { caption: SDKUI_Localizator.No, fontSize: '1.1rem', btnStyle: 'text', onClick: () => {
|
128
|
-
deviceType === DeviceType.MOBILE && (onUndo(), setShowList(true), onShowList?.(true));
|
129
|
-
setShowConfirmForClose(false);
|
130
|
-
onClose?.();
|
131
|
-
}, showTooltip: false, color: 'error' }), _jsx(TMButton, { caption: SDKUI_Localizator.Cancel, fontSize: '1.1rem', btnStyle: 'text', onClick: () => {
|
132
|
-
setShowConfirmForClose(false);
|
133
|
-
}, showTooltip: false, color: 'error' })] }) })] }) })] }) })
|
103
|
+
return (_jsx(_Fragment, { children: (isModal && onClose) ? _jsx(_Fragment, { children: _jsx(TMModal, { title: `${title} - ${LocalizeFormModes(formMode)}`, onClose: doClose, width: width ?? '100%', height: height ?? '100%', hidePopup: false, children: _jsx("div", { style: { width: "100%", height: "100%", display: 'block' }, children: renderSaveForm() }) }) })
|
134
104
|
: renderSaveForm() }));
|
135
105
|
};
|
136
106
|
export default TMSaveForm;
|