@topconsultnpm/sdkui-react 6.20.0-dev1.2 → 6.20.0-dev1.20
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.
- package/lib/components/NewComponents/ContextMenu/TMContextMenu.js +2 -2
- package/lib/components/NewComponents/ContextMenu/hooks.d.ts +1 -0
- package/lib/components/NewComponents/ContextMenu/hooks.js +8 -4
- package/lib/components/NewComponents/ContextMenu/styles.d.ts +4 -1
- package/lib/components/NewComponents/ContextMenu/styles.js +41 -8
- package/lib/components/NewComponents/FloatingMenuBar/TMFloatingMenuBar.js +5 -5
- package/lib/components/NewComponents/FloatingMenuBar/styles.d.ts +8 -0
- package/lib/components/NewComponents/FloatingMenuBar/styles.js +25 -15
- package/lib/components/base/TMAccordion.js +2 -2
- package/lib/components/base/TMCustomButton.js +0 -1
- package/lib/components/base/TMDataGrid.d.ts +2 -2
- package/lib/components/base/TMDataGrid.js +16 -5
- package/lib/components/editors/TMHtmlEditor.js +1 -1
- package/lib/components/editors/TMMetadataValues.js +20 -2
- package/lib/components/features/documents/TMDcmtBlog.d.ts +1 -7
- package/lib/components/features/documents/TMDcmtBlog.js +29 -2
- package/lib/components/features/documents/TMDcmtForm.js +233 -114
- package/lib/components/features/documents/TMDcmtPreview.js +94 -28
- package/lib/components/features/search/TMDcmtCheckoutInfoForm.d.ts +8 -0
- package/lib/components/features/search/{TMSearchResultCheckoutInfoForm.js → TMDcmtCheckoutInfoForm.js} +6 -11
- package/lib/components/features/search/TMSearchResult.js +46 -108
- package/lib/components/features/search/TMSearchResultsMenuItems.d.ts +1 -1
- package/lib/components/features/search/TMSearchResultsMenuItems.js +16 -16
- package/lib/components/features/search/TMViewHistoryDcmt.js +1 -1
- package/lib/components/forms/Login/TMLoginForm.js +2 -0
- package/lib/css/tm-sdkui.css +1 -1
- package/lib/helper/SDKUI_Globals.d.ts +3 -14
- package/lib/helper/SDKUI_Localizator.d.ts +8 -0
- package/lib/helper/SDKUI_Localizator.js +98 -0
- package/lib/helper/TMUtils.d.ts +3 -1
- package/lib/helper/TMUtils.js +51 -0
- package/lib/helper/checkinCheckoutManager.d.ts +85 -0
- package/lib/helper/checkinCheckoutManager.js +348 -0
- package/lib/helper/devextremeCustomMessages.d.ts +30 -0
- package/lib/helper/devextremeCustomMessages.js +30 -0
- package/lib/helper/helpers.js +7 -1
- package/lib/helper/index.d.ts +1 -0
- package/lib/helper/index.js +1 -0
- package/lib/helper/queryHelper.js +29 -0
- package/lib/hooks/useCheckInOutOperations.d.ts +28 -0
- package/lib/hooks/useCheckInOutOperations.js +223 -0
- package/lib/services/platform_services.d.ts +1 -1
- package/package.json +12 -10
- package/lib/components/features/search/TMSearchResultCheckoutInfoForm.d.ts +0 -8
- package/lib/helper/cicoHelper.d.ts +0 -31
- package/lib/helper/cicoHelper.js +0 -155
|
@@ -14,7 +14,7 @@ const TMContextMenu = ({ items, trigger = 'right', children }) => {
|
|
|
14
14
|
const menuRef = useRef(null);
|
|
15
15
|
const triggerRef = useRef(null);
|
|
16
16
|
const submenuTimeoutRef = useRef(null);
|
|
17
|
-
const { openLeft, openUp } = useMenuPosition(menuRef, menuState.position);
|
|
17
|
+
const { openLeft, openUp, isCalculated } = useMenuPosition(menuRef, menuState.position);
|
|
18
18
|
const handleClose = () => {
|
|
19
19
|
setMenuState(prev => ({
|
|
20
20
|
...prev,
|
|
@@ -182,6 +182,6 @@ const TMContextMenu = ({ items, trigger = 'right', children }) => {
|
|
|
182
182
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
183
183
|
handleClick(e);
|
|
184
184
|
}
|
|
185
|
-
}, role: "button", tabIndex: 0, style: { display: 'inline-block' }, children: children }), menuState.visible && (_jsxs(_Fragment, { children: [_jsx(S.Overlay, { onClick: handleClose }), _jsxs(S.MenuContainer, { ref: menuRef, "$x": menuState.position.x, "$y": menuState.position.y, "$openLeft": openLeft, "$openUp": openUp, children: [isMobile && menuState.parentNames.length > 0 && (_jsxs(S.MobileMenuHeader, { children: [_jsx(S.BackButton, { onClick: handleBack, "aria-label": "Go back", children: "\u2190" }), _jsx(S.HeaderTitle, { children: currentParentName })] })), renderMenuItems(currentMenu, 0)] }), !isMobile && hoveredSubmenus.map((submenu, idx) => (_jsx(S.Submenu, { "$parentRect": submenu.parentRect, "$openUp": submenu.openUp, "data-submenu": "true", onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: () => handleMouseLeave(submenu.depth), children: renderMenuItems(submenu.items, submenu.depth) }, `submenu-${submenu.depth}-${idx}`)))] }))] }));
|
|
185
|
+
}, role: "button", tabIndex: 0, style: { display: 'inline-block' }, children: children }), menuState.visible && (_jsxs(_Fragment, { children: [_jsx(S.Overlay, { onClick: handleClose }), _jsxs(S.MenuContainer, { ref: menuRef, "$x": menuState.position.x, "$y": menuState.position.y, "$openLeft": openLeft, "$openUp": openUp, "$isPositioned": isCalculated, children: [isMobile && menuState.parentNames.length > 0 && (_jsxs(S.MobileMenuHeader, { children: [_jsx(S.BackButton, { onClick: handleBack, "aria-label": "Go back", children: "\u2190" }), _jsx(S.HeaderTitle, { children: currentParentName })] })), renderMenuItems(currentMenu, 0)] }), !isMobile && hoveredSubmenus.map((submenu, idx) => (_jsx(S.Submenu, { "$parentRect": submenu.parentRect, "$openUp": submenu.openUp, "data-submenu": "true", onMouseEnter: handleSubmenuMouseEnter, onMouseLeave: () => handleMouseLeave(submenu.depth), children: renderMenuItems(submenu.items, submenu.depth) }, `submenu-${submenu.depth}-${idx}`)))] }))] }));
|
|
186
186
|
};
|
|
187
187
|
export default TMContextMenu;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect, useRef } from 'react';
|
|
1
|
+
import { useState, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
2
|
export const useIsMobile = () => {
|
|
3
3
|
const [isMobile, setIsMobile] = useState(false);
|
|
4
4
|
useEffect(() => {
|
|
@@ -31,9 +31,12 @@ export const useClickOutside = (callback) => {
|
|
|
31
31
|
};
|
|
32
32
|
export const useMenuPosition = (menuRef, position) => {
|
|
33
33
|
const [adjustedPosition, setAdjustedPosition] = useState({ openLeft: false, openUp: false });
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const [isCalculated, setIsCalculated] = useState(false);
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
if (!menuRef.current) {
|
|
37
|
+
setIsCalculated(false);
|
|
36
38
|
return;
|
|
39
|
+
}
|
|
37
40
|
const menuRect = menuRef.current.getBoundingClientRect();
|
|
38
41
|
const viewportWidth = window.innerWidth;
|
|
39
42
|
const viewportHeight = window.innerHeight;
|
|
@@ -43,6 +46,7 @@ export const useMenuPosition = (menuRef, position) => {
|
|
|
43
46
|
openLeft: spaceRight < menuRect.width + 20,
|
|
44
47
|
openUp: spaceBottom < menuRect.height + 20,
|
|
45
48
|
});
|
|
49
|
+
setIsCalculated(true);
|
|
46
50
|
}, [position, menuRef]);
|
|
47
|
-
return adjustedPosition;
|
|
51
|
+
return { ...adjustedPosition, isCalculated };
|
|
48
52
|
};
|
|
@@ -3,6 +3,7 @@ export declare const MenuContainer: import("styled-components/dist/types").IStyl
|
|
|
3
3
|
$y: number;
|
|
4
4
|
$openLeft: boolean;
|
|
5
5
|
$openUp: boolean;
|
|
6
|
+
$isPositioned: boolean;
|
|
6
7
|
}>> & string;
|
|
7
8
|
export declare const MenuItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
8
9
|
$disabled?: boolean;
|
|
@@ -12,7 +13,9 @@ export declare const MenuItem: import("styled-components/dist/types").IStyledCom
|
|
|
12
13
|
export declare const MenuItemContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
13
14
|
export declare const IconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
14
15
|
export declare const MenuItemName: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
15
|
-
export declare const RightIconButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>,
|
|
16
|
+
export declare const RightIconButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
17
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
18
|
+
}>, never>, never>> & string;
|
|
16
19
|
export declare const SubmenuIndicator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
17
20
|
$isMobile?: boolean;
|
|
18
21
|
}>> & string;
|
|
@@ -36,6 +36,13 @@ export const MenuContainer = styled.div `
|
|
|
36
36
|
animation: ${fadeIn} 0.15s ease-out;
|
|
37
37
|
backdrop-filter: blur(10px);
|
|
38
38
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
|
39
|
+
opacity: ${props => props.$isPositioned ? 1 : 0};
|
|
40
|
+
transition: opacity 0.05s ease-in;
|
|
41
|
+
|
|
42
|
+
/* Reset color inheritance from parent with !important to override panel header styles */
|
|
43
|
+
& *:not(svg):not(.right-icon-btn):not(.right-icon-btn *) {
|
|
44
|
+
color: #1a1a1a !important;
|
|
45
|
+
}
|
|
39
46
|
|
|
40
47
|
[data-theme='dark'] & {
|
|
41
48
|
background: #2a2a2a;
|
|
@@ -43,6 +50,10 @@ export const MenuContainer = styled.div `
|
|
|
43
50
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
|
|
44
51
|
0 2px 8px rgba(0, 0, 0, 0.3);
|
|
45
52
|
}
|
|
53
|
+
|
|
54
|
+
[data-theme='dark'] & *:not(svg):not(.right-icon-btn):not(.right-icon-btn *) {
|
|
55
|
+
color: #e0e0e0 !important;
|
|
56
|
+
}
|
|
46
57
|
`;
|
|
47
58
|
export const MenuItem = styled.div `
|
|
48
59
|
display: flex;
|
|
@@ -50,7 +61,6 @@ export const MenuItem = styled.div `
|
|
|
50
61
|
justify-content: space-between;
|
|
51
62
|
padding: 4px 12px;
|
|
52
63
|
cursor: ${props => props.$disabled ? 'not-allowed' : 'pointer'};
|
|
53
|
-
opacity: ${props => props.$disabled ? 0.4 : 1};
|
|
54
64
|
transition: all 0.15s ease;
|
|
55
65
|
position: relative;
|
|
56
66
|
user-select: none;
|
|
@@ -63,12 +73,26 @@ export const MenuItem = styled.div `
|
|
|
63
73
|
padding-top: 8px;
|
|
64
74
|
`}
|
|
65
75
|
|
|
76
|
+
/* Apply opacity only to direct children except right-icon-btn */
|
|
77
|
+
& > *:not(.right-icon-btn) {
|
|
78
|
+
opacity: ${props => props.$disabled ? 0.4 : 1};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Right icon button hidden by default, shown on hover */
|
|
82
|
+
& .right-icon-btn {
|
|
83
|
+
cursor: pointer !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
66
86
|
&:hover {
|
|
67
87
|
${props => !props.$disabled && `
|
|
68
88
|
background: linear-gradient(90deg, #f0f7ff 0%, #e6f2ff 100%);
|
|
69
89
|
color: #0066cc;
|
|
70
|
-
padding-left: 14px;
|
|
71
90
|
`}
|
|
91
|
+
|
|
92
|
+
/* Show right icon on hover */
|
|
93
|
+
& .right-icon-btn {
|
|
94
|
+
opacity: 1 !important;
|
|
95
|
+
}
|
|
72
96
|
}
|
|
73
97
|
|
|
74
98
|
&:active {
|
|
@@ -124,23 +148,23 @@ export const MenuItemName = styled.span `
|
|
|
124
148
|
overflow-wrap: break-word;
|
|
125
149
|
line-height: 1.4;
|
|
126
150
|
`;
|
|
127
|
-
export const RightIconButton = styled.button
|
|
151
|
+
export const RightIconButton = styled.button.attrs({
|
|
152
|
+
className: 'right-icon-btn'
|
|
153
|
+
}) `
|
|
128
154
|
display: flex;
|
|
129
155
|
align-items: center;
|
|
130
156
|
justify-content: center;
|
|
131
157
|
background: transparent;
|
|
132
158
|
border: none;
|
|
133
|
-
cursor: pointer;
|
|
159
|
+
cursor: pointer !important;
|
|
134
160
|
padding: 4px 8px;
|
|
135
161
|
margin-left: 8px;
|
|
136
162
|
border-radius: 6px;
|
|
137
|
-
color: inherit;
|
|
138
163
|
font-size: 14px;
|
|
139
|
-
opacity: 0
|
|
140
|
-
transition:
|
|
164
|
+
opacity: 0 !important;
|
|
165
|
+
transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
|
|
141
166
|
|
|
142
167
|
&:hover {
|
|
143
|
-
opacity: 1;
|
|
144
168
|
background: rgba(0, 0, 0, 0.05);
|
|
145
169
|
transform: scale(1.1);
|
|
146
170
|
}
|
|
@@ -223,12 +247,21 @@ export const Submenu = styled.div `
|
|
|
223
247
|
background: transparent;
|
|
224
248
|
}
|
|
225
249
|
|
|
250
|
+
/* Reset color inheritance from parent with !important to override panel header styles */
|
|
251
|
+
& *:not(svg):not(.right-icon-btn):not(.right-icon-btn *) {
|
|
252
|
+
color: #1a1a1a !important;
|
|
253
|
+
}
|
|
254
|
+
|
|
226
255
|
[data-theme='dark'] & {
|
|
227
256
|
background: #2a2a2a;
|
|
228
257
|
border-color: rgba(255, 255, 255, 0.1);
|
|
229
258
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
|
|
230
259
|
0 2px 8px rgba(0, 0, 0, 0.3);
|
|
231
260
|
}
|
|
261
|
+
|
|
262
|
+
[data-theme='dark'] & *:not(svg):not(.right-icon-btn):not(.right-icon-btn *) {
|
|
263
|
+
color: #e0e0e0 !important;
|
|
264
|
+
}
|
|
232
265
|
`;
|
|
233
266
|
export const MobileMenuHeader = styled.div `
|
|
234
267
|
display: flex;
|
|
@@ -4,7 +4,7 @@ import { ContextMenu } from '../ContextMenu';
|
|
|
4
4
|
import Notification from '../Notification';
|
|
5
5
|
import TMTooltip from '../../base/TMTooltip';
|
|
6
6
|
import * as S from './styles';
|
|
7
|
-
import { IconApply, IconMenuKebab, IconMenuVertical,
|
|
7
|
+
import { IconApply, IconMenuKebab, IconMenuVertical, IconPencil, IconPin } from '../../../helper';
|
|
8
8
|
const IconDraggableDots = (props) => (_jsx("svg", { fontSize: 18, viewBox: "0 0 24 24", fill: "currentColor", height: "1em", width: "1em", ...props, children: _jsx("path", { d: "M9 3a2 2 0 11-4 0 2 2 0 014 0zm0 9a2 2 0 11-4 0 2 2 0 014 0zm0 9a2 2 0 11-4 0 2 2 0 014 0zm10-18a2 2 0 11-4 0 2 2 0 014 0zm0 9a2 2 0 11-4 0 2 2 0 014 0zm0 9a2 2 0 11-4 0 2 2 0 014 0z" }) }));
|
|
9
9
|
const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], storageKey = 'floatingMenuBar-config', isConstrained = false, defaultPosition = { x: 100, y: 100 }, maxItems = 8, }) => {
|
|
10
10
|
const loadConfig = () => {
|
|
@@ -60,7 +60,7 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], storageKey = '
|
|
|
60
60
|
result.push({
|
|
61
61
|
id: itemId,
|
|
62
62
|
name: item.name,
|
|
63
|
-
icon: item.icon || _jsx(
|
|
63
|
+
icon: item.icon || _jsx(IconPin, {}),
|
|
64
64
|
onClick: item.onClick,
|
|
65
65
|
disabled: item.disabled,
|
|
66
66
|
isPinned: pinnedItemIds.has(itemId),
|
|
@@ -150,7 +150,7 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], storageKey = '
|
|
|
150
150
|
const isInFloatingBar = currentItemIds.has(itemId) || currentItemNames.has(item.name);
|
|
151
151
|
const enhanced = {
|
|
152
152
|
...item,
|
|
153
|
-
rightIcon: item.onClick && !item.submenu ? (isInFloatingBar ? _jsx(
|
|
153
|
+
rightIcon: item.onClick && !item.submenu ? (isInFloatingBar ? _jsx(IconPin, { color: "#e12a2a" }) : _jsx(IconPin, {})) : undefined,
|
|
154
154
|
onRightIconClick: item.onClick && !item.submenu ? () => {
|
|
155
155
|
if (flatItem) {
|
|
156
156
|
togglePin(flatItem);
|
|
@@ -347,7 +347,7 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], storageKey = '
|
|
|
347
347
|
setState(s => ({ ...s, draggedItemIndex: null }));
|
|
348
348
|
setDragOverIndex(null);
|
|
349
349
|
};
|
|
350
|
-
return (_jsxs(_Fragment, { children: [_jsx(S.Overlay, { "$visible": state.isConfigMode }), _jsxs(S.FloatingContainer, { ref: floatingRef, "$x": state.position.x, "$y": state.position.y, "$orientation": state.orientation, "$isDragging": state.isDragging, "$isConfigMode": state.isConfigMode, "$isConstrained": isConstrained, children: [_jsx(S.GripHandle, { "$orientation": state.orientation, onMouseDown: handleMouseDown, children: _jsx(IconDraggableDots, {}) }), _jsx(S.
|
|
350
|
+
return (_jsxs(_Fragment, { children: [_jsx(S.Overlay, { "$visible": state.isConfigMode }), _jsxs(S.FloatingContainer, { ref: floatingRef, "$x": state.position.x, "$y": state.position.y, "$orientation": state.orientation, "$isDragging": state.isDragging, "$isConfigMode": state.isConfigMode, "$isConstrained": isConstrained, children: [_jsx(S.GripHandle, { "$orientation": state.orientation, onMouseDown: handleMouseDown, children: _jsx(IconDraggableDots, {}) }), _jsx(S.Separator, { "$orientation": state.orientation }), state.items.map((item, index) => {
|
|
351
351
|
// Get current state (disabled and onClick) from contextMenuItems
|
|
352
352
|
const currentState = getCurrentItemState(item.name);
|
|
353
353
|
const isDisabled = currentState.disabled || false;
|
|
@@ -365,6 +365,6 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], storageKey = '
|
|
|
365
365
|
currentOnClick();
|
|
366
366
|
}
|
|
367
367
|
}, disabled: isDisabled, children: item.icon }) })), state.isConfigMode && (_jsx(S.RemoveButton, { onClick: () => removeItem(item.id), children: "\u00D7" }))] }, item.id));
|
|
368
|
-
}), !state.isConfigMode && contextMenuItems.length > 0 && (_jsx(ContextMenu, { items: enhancedContextMenuItems(), trigger: "left", children: _jsx(S.
|
|
368
|
+
}), !state.isConfigMode && contextMenuItems.length > 0 && (_jsx(ContextMenu, { items: enhancedContextMenuItems(), trigger: "left", children: _jsx(S.ContextMenuButton, { children: _jsx(IconMenuVertical, {}) }) }, Array.from(pinnedItemIds).join(','))), _jsx(S.ConfigButton, { onClick: toggleConfigMode, "$isActive": state.isConfigMode, children: state.isConfigMode ? _jsx(IconApply, {}) : _jsx(IconPencil, {}) }), !state.isConfigMode && (_jsx(S.OrientationToggle, { "$orientation": state.orientation, onClick: toggleOrientation, children: _jsx(IconMenuKebab, {}) }))] }), showMaxItemsNotification && (_jsx("div", { style: { position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)', zIndex: 100001 }, children: _jsx(Notification, { title: "Maximum Items Reached", message: `You have reached the maximum number of pinned items (${maxItems}). Please unpin an item before adding a new one.`, mode: "warning", position: "top-center", duration: 4000, closable: true, stopOnMouseEnter: true, hasProgress: true, onClose: () => setShowMaxItemsNotification(false) }) }))] }));
|
|
369
369
|
};
|
|
370
370
|
export default TMFloatingMenuBar;
|
|
@@ -21,12 +21,20 @@ export declare const FloatingContainer: import("styled-components/dist/types").I
|
|
|
21
21
|
export declare const GripHandle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
22
22
|
$orientation: "horizontal" | "vertical";
|
|
23
23
|
}>> & string;
|
|
24
|
+
export declare const Separator: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
25
|
+
$orientation: "horizontal" | "vertical";
|
|
26
|
+
}>> & string;
|
|
24
27
|
export declare const MenuButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
25
28
|
$isActive?: boolean;
|
|
26
29
|
}>> & string;
|
|
27
30
|
export declare const ConfigButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
28
31
|
$isActive?: boolean;
|
|
29
32
|
}>> & string;
|
|
33
|
+
export declare const ContextMenuButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "$isActive"> & {
|
|
34
|
+
$isActive?: boolean;
|
|
35
|
+
}, "ref"> & {
|
|
36
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
37
|
+
}, never>> & string;
|
|
30
38
|
export declare const RemoveButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
31
39
|
export declare const OrientationToggle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
32
40
|
$orientation: "horizontal" | "vertical";
|
|
@@ -55,7 +55,7 @@ export const FloatingContainer = styled.div.attrs(props => ({
|
|
|
55
55
|
transition: none;
|
|
56
56
|
|
|
57
57
|
&:hover {
|
|
58
|
-
background: linear-gradient(135deg, #
|
|
58
|
+
background: linear-gradient(135deg, #0071BC 0%, #1B1464 100%);
|
|
59
59
|
border: 1px solid #667eea;
|
|
60
60
|
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3),
|
|
61
61
|
0 6px 16px rgba(0, 0, 0, 0.2);
|
|
@@ -98,6 +98,13 @@ export const GripHandle = styled.div `
|
|
|
98
98
|
height: 14px;
|
|
99
99
|
}
|
|
100
100
|
`;
|
|
101
|
+
export const Separator = styled.div `
|
|
102
|
+
background: rgba(255, 255, 255, 0.25);
|
|
103
|
+
width: ${props => props.$orientation === 'horizontal' ? '1px' : '100%'};
|
|
104
|
+
height: ${props => props.$orientation === 'horizontal' ? '24px' : '1px'};
|
|
105
|
+
margin: ${props => props.$orientation === 'horizontal' ? '0 4px' : '4px 0'};
|
|
106
|
+
flex-shrink: 0;
|
|
107
|
+
`;
|
|
101
108
|
export const MenuButton = styled.button `
|
|
102
109
|
display: flex;
|
|
103
110
|
align-items: center;
|
|
@@ -110,36 +117,35 @@ export const MenuButton = styled.button `
|
|
|
110
117
|
color: white;
|
|
111
118
|
font-size: 16px;
|
|
112
119
|
cursor: pointer;
|
|
113
|
-
transition:
|
|
120
|
+
transition: background 0.2s ease;
|
|
114
121
|
position: relative;
|
|
115
122
|
|
|
116
123
|
&:hover:not(:disabled) {
|
|
117
124
|
background: rgba(255, 255, 255, 0.2);
|
|
118
|
-
transform: scale(1.1);
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
&:active:not(:disabled) {
|
|
122
|
-
|
|
128
|
+
opacity: 0.8;
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
&:disabled {
|
|
126
|
-
opacity: 0.
|
|
132
|
+
opacity: 0.5;
|
|
127
133
|
cursor: not-allowed;
|
|
128
|
-
|
|
129
|
-
color: rgba(255, 255, 255, 0.4);
|
|
134
|
+
color: rgba(255, 255, 255, 0.6);
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
svg {
|
|
133
138
|
width: 18px;
|
|
134
139
|
height: 18px;
|
|
140
|
+
transform: translateY(2px);
|
|
135
141
|
}
|
|
136
142
|
`;
|
|
137
143
|
export const ConfigButton = styled.button `
|
|
138
144
|
display: flex;
|
|
139
145
|
align-items: center;
|
|
140
146
|
justify-content: center;
|
|
141
|
-
width:
|
|
142
|
-
height:
|
|
147
|
+
width: 28px;
|
|
148
|
+
height: 28px;
|
|
143
149
|
background: ${props => props.$isActive
|
|
144
150
|
? 'rgba(0, 0, 0, 0.2)'
|
|
145
151
|
: 'rgba(0, 0, 0, 0.1)'};
|
|
@@ -148,9 +154,9 @@ export const ConfigButton = styled.button `
|
|
|
148
154
|
: 'rgba(255, 255, 255, 0.15)'};
|
|
149
155
|
border-radius: 8px;
|
|
150
156
|
color: white;
|
|
151
|
-
font-size:
|
|
157
|
+
font-size: 14px;
|
|
152
158
|
cursor: pointer;
|
|
153
|
-
transition:
|
|
159
|
+
transition: background 0.2s ease, border-color 0.2s ease;
|
|
154
160
|
position: relative;
|
|
155
161
|
|
|
156
162
|
&:hover {
|
|
@@ -158,16 +164,20 @@ export const ConfigButton = styled.button `
|
|
|
158
164
|
? 'rgba(0, 0, 0, 0.25)'
|
|
159
165
|
: 'rgba(0, 0, 0, 0.15)'};
|
|
160
166
|
border-color: rgba(255, 255, 255, 0.35);
|
|
161
|
-
transform: scale(1.05);
|
|
162
167
|
}
|
|
163
168
|
|
|
164
169
|
&:active {
|
|
165
|
-
|
|
170
|
+
opacity: 0.8;
|
|
166
171
|
}
|
|
167
172
|
|
|
168
173
|
svg {
|
|
169
|
-
width:
|
|
170
|
-
height:
|
|
174
|
+
width: 16px;
|
|
175
|
+
height: 16px;
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
178
|
+
export const ContextMenuButton = styled(MenuButton) `
|
|
179
|
+
svg {
|
|
180
|
+
transform: translateY(0);
|
|
171
181
|
}
|
|
172
182
|
`;
|
|
173
183
|
export const RemoveButton = styled.button `
|
|
@@ -47,12 +47,12 @@ const StyledGroupTemplate = styled.div `
|
|
|
47
47
|
&::after {
|
|
48
48
|
content: '';
|
|
49
49
|
display: block;
|
|
50
|
-
width:
|
|
50
|
+
width: calc(100% - 35px);
|
|
51
51
|
margin: 0 auto;
|
|
52
52
|
border-bottom: 1px solid #00A99D;
|
|
53
53
|
margin-top: 8px;
|
|
54
54
|
position: absolute;
|
|
55
|
-
left:
|
|
55
|
+
left: 35px;
|
|
56
56
|
bottom: 0;
|
|
57
57
|
}
|
|
58
58
|
`;
|
|
@@ -39,8 +39,8 @@ export interface TMDataGridProps<T> extends IDataGridOptions {
|
|
|
39
39
|
showFilterPanel?: boolean;
|
|
40
40
|
/** Show the load panel */
|
|
41
41
|
showLoadPanel?: boolean;
|
|
42
|
-
/** Show the column chooser */
|
|
43
|
-
|
|
42
|
+
/** Show the header column chooser in context menu */
|
|
43
|
+
showHeaderColumnChooser?: boolean;
|
|
44
44
|
/** Show the search panel */
|
|
45
45
|
showSearchPanel?: boolean;
|
|
46
46
|
/** Show the group panel */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
-
import DataGrid, { Column, HeaderFilter, Selection, Scrolling, LoadPanel, SearchPanel, Pager, Sorting, Paging, FilterPanel, ColumnChooser, Grouping, GroupPanel, Summary, Editing, FilterRow, StateStoring, RowDragging, MasterDetail } from 'devextreme-react/data-grid';
|
|
3
|
+
import DataGrid, { Column, HeaderFilter, Selection, Scrolling, LoadPanel, SearchPanel, Pager, Sorting, Paging, FilterPanel, ColumnChooser, Grouping, GroupPanel, Summary, Editing, FilterRow, StateStoring, RowDragging, MasterDetail, Position, ColumnChooserSearch, ColumnChooserSelection } from 'devextreme-react/data-grid';
|
|
4
4
|
import DataSource from 'devextreme/data/data_source';
|
|
5
5
|
import { IconAll, IconSelected, IconVisible, SDKUI_Globals, SDKUI_Localizator } from '../../helper';
|
|
6
6
|
import TMCounterContainer, { CounterItemKey } from './TMCounterContainer';
|
|
@@ -16,9 +16,9 @@ const TMDataGrid = React.forwardRef((props, ref) => {
|
|
|
16
16
|
// main properties
|
|
17
17
|
keyExpr = 'id', dataSource, focusedRowEnabled = true, hoverStateEnabled = true, focusedRowKey, selectedRowKeys = [],
|
|
18
18
|
// custom options
|
|
19
|
-
dataColumns = [], pageSize = TMDataGridPageSize.Large, showHeaderFilter = true, showFilterPanel = true, showLoadPanel = true, showSearchPanel = true, searchPanelToolbarPosition = 'before', searchPanelFocusStarting = false, counterConfig = { show: false, items: new Map() }, onHasFiltersChange,
|
|
19
|
+
dataColumns = [], pageSize = TMDataGridPageSize.Large, showHeaderFilter = true, showFilterPanel = true, showHeaderColumnChooser = false, showLoadPanel = true, showSearchPanel = true, searchPanelToolbarPosition = 'before', searchPanelFocusStarting = false, counterConfig = { show: false, items: new Map() }, onHasFiltersChange,
|
|
20
20
|
// events and callbacks
|
|
21
|
-
onSelectionChanged, onFocusedRowChanged, onRowDblClick, onRowClick, onCellClick, onCellDblClick, onOptionChanged, onContentReady, onContextMenuPreparing, onInitialized, onEditorPreparing, onCellPrepared, onRowPrepared, onRowUpdating, onRowExpanded, onRowCollapsed, onRowUpdated, onSaved, onEditCanceled, onEditingStart, onEditingChange, customizeColumns, onKeyDown, scrolling = { mode: 'standard', useNative: SDKUI_Globals.userSettings?.themeSettings.gridSettings.useNativeScrollbar === 1 }, paging = { enabled: true, pageSize: pageSize }, pager = { visible: true, showInfo: true, showNavigationButtons: true }, selection = { mode: 'multiple', showCheckBoxesMode: "always", selectAllMode: "allPages" }, sorting, summary, stateStoring,
|
|
21
|
+
onSelectionChanged, onFocusedRowChanged, onRowDblClick, onRowClick, onCellClick, onCellDblClick, onOptionChanged, onContentReady, onContextMenuPreparing, onInitialized, onEditorPreparing, onCellPrepared, onRowPrepared, onRowUpdating, onRowExpanded, onRowCollapsed, onRowUpdated, onSaved, onEditCanceled, onEditingStart, onEditingChange, customizeColumns, onKeyDown, scrolling = { mode: 'standard', useNative: SDKUI_Globals.userSettings?.themeSettings.gridSettings.useNativeScrollbar === 1 }, paging = { enabled: true, pageSize: pageSize }, pager = { visible: true, showInfo: true, showNavigationButtons: true }, selection = { mode: 'multiple', showCheckBoxesMode: "always", selectAllMode: "allPages" }, sorting, summary, stateStoring, grouping, groupPanel, filterRow, headerFilter, editing, rowDragging, masterDetail,
|
|
22
22
|
// other properties
|
|
23
23
|
disabled = false, autoNavigateToFocusedRow = true, columnResizingMode = 'widget', columnHidingEnabled = true, columnAutoWidth = true, allowColumnResizing = true, allowColumnReordering = true, showBorders = true, showRowLines = SDKUI_Globals.userSettings?.themeSettings.gridSettings.showRowLines === 1, showColumnLines = SDKUI_Globals.userSettings?.themeSettings.gridSettings.showColumnLines === 1, showColumnHeaders = true, rowAlternationEnabled = false, wordWrapEnabled = false, noDataText,
|
|
24
24
|
// styles
|
|
@@ -146,7 +146,18 @@ const TMDataGrid = React.forwardRef((props, ref) => {
|
|
|
146
146
|
e.items = [...updatedContextMenuItems];
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
// Add column chooser to header context menu
|
|
150
|
+
if (e.target === 'header' && showHeaderColumnChooser) {
|
|
151
|
+
e.items = e.items || [];
|
|
152
|
+
e.items.push({
|
|
153
|
+
text: SDKUI_Localizator.ShowColumnSelection,
|
|
154
|
+
icon: 'columnchooser',
|
|
155
|
+
onItemClick: () => {
|
|
156
|
+
internalRef.current?.instance().showColumnChooser();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}, [updateContextMenuItems, onContextMenuPreparing, showHeaderColumnChooser]);
|
|
150
161
|
// Handle toolbar preparation, especially for the search panel
|
|
151
162
|
const onToolbarPreparingCallback = useCallback((e) => {
|
|
152
163
|
if (e === undefined || e.toolbarOptions === undefined || e.toolbarOptions.items === undefined)
|
|
@@ -223,7 +234,7 @@ const TMDataGrid = React.forwardRef((props, ref) => {
|
|
|
223
234
|
// other properties
|
|
224
235
|
disabled: disabled, autoNavigateToFocusedRow: autoNavigateToFocusedRow, focusedRowKey: focusedRowKey, columnHidingEnabled: columnHidingEnabled, columnResizingMode: columnResizingMode, columnAutoWidth: columnAutoWidth, allowColumnResizing: allowColumnResizing, allowColumnReordering: allowColumnReordering, showBorders: showBorders, showRowLines: showRowLines, showColumnLines: showColumnLines, showColumnHeaders: showColumnHeaders, rowAlternationEnabled: rowAlternationEnabled, wordWrapEnabled: wordWrapEnabled, noDataText: noDataText,
|
|
225
236
|
// styles
|
|
226
|
-
width: width, height: height, style: { userSelect: 'none' }, children: [dataColumns.map((column, index) => (_jsx(Column, { ...column }, column.caption + index.toString()))), sorting && _jsx(Sorting, { ...sorting }), selection && _jsx(Selection, { ...selection }), scrolling && _jsx(Scrolling, { ...scrolling }), summary && _jsx(Summary, { ...summary }), showHeaderFilter && _jsx(HeaderFilter, { visible: true, ...headerFilter }), rowDragging && _jsx(RowDragging, { ...rowDragging }), filterRow && _jsx(FilterRow, { ...filterRow }), showFilterPanel && _jsx(FilterPanel, { visible: true }),
|
|
237
|
+
width: width, height: height, style: { userSelect: 'none' }, children: [dataColumns.map((column, index) => (_jsx(Column, { ...column }, column.caption + index.toString()))), sorting && _jsx(Sorting, { ...sorting }), selection && _jsx(Selection, { ...selection }), scrolling && _jsx(Scrolling, { ...scrolling }), summary && _jsx(Summary, { ...summary }), showHeaderFilter && _jsx(HeaderFilter, { visible: true, ...headerFilter }), rowDragging && _jsx(RowDragging, { ...rowDragging }), filterRow && _jsx(FilterRow, { ...filterRow }), showFilterPanel && _jsx(FilterPanel, { visible: true }), showHeaderColumnChooser && _jsxs(ColumnChooser, { height: "400px", enabled: !showHeaderColumnChooser, mode: "select", children: [_jsx(Position, { my: "center", at: "center", of: window }), _jsx(ColumnChooserSearch, { enabled: true }), _jsx(ColumnChooserSelection, { allowSelectAll: false, selectByClick: true, recursive: true })] }), stateStoring && _jsx(StateStoring, { ...stateStoring }), groupPanel && _jsx(GroupPanel, { ...groupPanel }), _jsx(Grouping, { contextMenuEnabled: true, ...grouping }), _jsx(LoadPanel, { enabled: showLoadPanel }), _jsx(SearchPanel, { visible: showSearchPanel, searchVisibleColumnsOnly: true, highlightSearchText: true }), editing && _jsx(Editing, { ...editing }), paging && _jsx(Paging, { ...paging }), pager && _jsx(Pager, { ...pager, visible: totalRecordCount > pageSize }), masterDetail && _jsx(MasterDetail, { ...masterDetail })] }) }), counterConfig.show && _jsx("div", { style: { width: "100%", height: "25px", display: "flex", alignItems: "center", gap: "15px", backgroundColor: "#e0e0e0" }, children: _jsx(TMCounterContainer, { items: counterValues, bgColorContainer: counterConfig.bgColorContainer, bgColorItem: counterConfig.bgColorItem, hoverColorItem: counterConfig.hoverColorItem, textColorItem: counterConfig.textColorItem }) })] });
|
|
227
238
|
});
|
|
228
239
|
export default TMDataGrid;
|
|
229
240
|
const getRecordCount = (dataSource) => {
|
|
@@ -170,7 +170,7 @@ const TMHtmlEditor = (props) => {
|
|
|
170
170
|
justifyContent: 'flex-end',
|
|
171
171
|
fontSize: 12,
|
|
172
172
|
color: '#6c757d',
|
|
173
|
-
marginTop: 4,
|
|
173
|
+
marginTop: showInfoIcon ? 0 : 4,
|
|
174
174
|
gap: 4,
|
|
175
175
|
}, children: [`${Math.max(charactersRemaining, 0)} ${SDKUI_Localizator.CharactersRemaining}`, showInfoIcon && (_jsx(TMTooltip, { content: 'Markup HTML', children: _jsx("span", { className: "dx-icon-codeblock", style: { fontSize: 22, cursor: 'pointer' }, onClick: () => {
|
|
176
176
|
TMMessageBoxManager.show({
|
|
@@ -389,17 +389,35 @@ const TMMetadataValues = ({ showCheckBoxes = ShowCheckBoxesMode.Never, checkPerm
|
|
|
389
389
|
return (_jsxs("div", { style: { width: '100%' }, children: [draftData.length > 0 && _jsx(TMAccordion, { title: SDKUI_Localizator.Draft, children: draftData.map(item => renderMetadataItem(item, isReadOnly)) }), checkOutData.length > 0 && _jsx(TMAccordion, { title: `${SDKUI_Localizator.CheckIn}/${SDKUI_Localizator.CheckOut}`, children: checkOutData.map(item => renderMetadataItem(item, true)) })] }));
|
|
390
390
|
}, [metadataValues, showCheckBoxes, showNullValueCheckBoxes, isReadOnly, dynDataListsToBeRefreshed, validationItems, selectedMID, isOpenDistinctValues, openChooserBySingleClick, metadataValuesOrig]);
|
|
391
391
|
const layoutChronology = useMemo(() => {
|
|
392
|
-
|
|
392
|
+
// Definiamo l'ordine desiderato: Version, Tipo, Dimensione, Autore, Data Ultima modifica
|
|
393
|
+
const desiredChronologyOrder = [
|
|
394
|
+
ChronologyMIDs.Ver,
|
|
395
|
+
SystemMIDsAsNumber.FileExt,
|
|
396
|
+
SystemMIDsAsNumber.FileSize,
|
|
397
|
+
ChronologyMIDs.AuthorID,
|
|
398
|
+
ChronologyMIDs.CheckInTime,
|
|
399
|
+
];
|
|
400
|
+
const tempChronologyDataMap = {};
|
|
393
401
|
metadataValues.forEach(item => {
|
|
394
402
|
switch (item.md?.id) {
|
|
395
403
|
case ChronologyMIDs.Ver:
|
|
396
404
|
case ChronologyMIDs.AuthorID:
|
|
397
|
-
|
|
405
|
+
case ChronologyMIDs.CheckInTime:
|
|
406
|
+
case SystemMIDsAsNumber.FileExt:
|
|
407
|
+
case SystemMIDsAsNumber.FileSize:
|
|
408
|
+
tempChronologyDataMap[item.md.id] = item;
|
|
398
409
|
break;
|
|
399
410
|
default:
|
|
400
411
|
break;
|
|
401
412
|
}
|
|
402
413
|
});
|
|
414
|
+
// Visualizziamo nell'ordine desiderato
|
|
415
|
+
const chronologyData = [];
|
|
416
|
+
desiredChronologyOrder.forEach(id => {
|
|
417
|
+
if (tempChronologyDataMap[id]) {
|
|
418
|
+
chronologyData.push(tempChronologyDataMap[id]);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
403
421
|
return (_jsx("div", { style: { width: '100%' }, children: chronologyData.length > 0 && chronologyData.map(item => renderMetadataItem(item, isReadOnly)) }));
|
|
404
422
|
}, [metadataValues, showCheckBoxes, showNullValueCheckBoxes, isReadOnly, dynDataListsToBeRefreshed, validationItems, selectedMID, isOpenDistinctValues, openChooserBySingleClick, metadataValuesOrig]);
|
|
405
423
|
const layoutDsAttachs = useMemo(() => {
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HomeBlogPost, TaskDescriptor } from '@topconsultnpm/sdk-ts';
|
|
3
3
|
interface ITMDcmtBlogProps {
|
|
4
|
-
blogsDatasource: HomeBlogPost[];
|
|
5
|
-
setBlogsDatasource: (posts: HomeBlogPost[]) => void;
|
|
6
|
-
hasLoadedDataOnce: boolean;
|
|
7
|
-
setHasLoadedDataOnce: (loaded: boolean) => void;
|
|
8
|
-
lastLoadedDid: number | undefined;
|
|
9
|
-
setLastLoadedDid: (did: number | undefined) => void;
|
|
10
4
|
tid: number | undefined;
|
|
11
5
|
did: number | undefined;
|
|
12
|
-
fetchBlogDataAsync: (tid: number | undefined, did: number | undefined) => Promise<void>;
|
|
13
6
|
isVisible?: boolean;
|
|
7
|
+
fetchBlogDataTrigger?: number;
|
|
14
8
|
allTasks?: Array<TaskDescriptor>;
|
|
15
9
|
getAllTasks?: () => Promise<void>;
|
|
16
10
|
deleteTaskByIdsCallback?: (deletedTaskIds: Array<number>) => Promise<void>;
|
|
@@ -6,13 +6,40 @@ import { TMNothingToShow } from './TMDcmtPreview';
|
|
|
6
6
|
import { IconBoard, SDKUI_Localizator } from '../../../helper';
|
|
7
7
|
import TMBlogCommentForm from '../blog/TMBlogCommentForm';
|
|
8
8
|
import TMBlogsPost from '../../grids/TMBlogsPost';
|
|
9
|
-
|
|
9
|
+
import TMSpinner from '../../base/TMSpinner';
|
|
10
|
+
import { TMExceptionBoxManager } from '../../base/TMPopUp';
|
|
11
|
+
const TMDcmtBlog = ({ tid, did, isVisible, fetchBlogDataTrigger, allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTaskCallback, editTaskCallback, handleNavigateToWGs, handleNavigateToDossiers }) => {
|
|
12
|
+
const [blogsDatasource, setBlogsDatasource] = useState([]);
|
|
13
|
+
const [hasLoadedDataOnce, setHasLoadedDataOnce] = useState(false); //traccia se *qualsiasi* dato è stato caricato per la prima volta
|
|
14
|
+
const [lastLoadedDid, setLastLoadedDid] = useState(undefined); // `lastLoadedDid` tiene traccia dell'ultimo `did` per cui abbiamo caricato i dati
|
|
10
15
|
// State to manage show comment form selected file
|
|
11
16
|
const [showCommentForm, setShowCommentForm] = useState(false);
|
|
12
17
|
const [externalBlogPost, setExternalBlogPost] = useState(undefined);
|
|
18
|
+
const fetchBlogDataAsync = useCallback(async (tid, did) => {
|
|
19
|
+
try {
|
|
20
|
+
TMSpinner.show({ description: 'Caricamento - Bacheca...' });
|
|
21
|
+
const res = await SDK_Globals.tmSession?.NewSearchEngine().BlogRetrieveAsync(tid, did);
|
|
22
|
+
setBlogsDatasource(res ?? []);
|
|
23
|
+
setHasLoadedDataOnce(true);
|
|
24
|
+
setLastLoadedDid(did);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
let err = e;
|
|
28
|
+
TMExceptionBoxManager.show({ exception: err });
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
TMSpinner.hide();
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
13
34
|
const showCommentFormCallback = useCallback(() => {
|
|
14
35
|
setShowCommentForm(true);
|
|
15
36
|
}, []);
|
|
37
|
+
// useEffect per triggerare il fetch dall'esterno tramite props
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (fetchBlogDataTrigger !== undefined && fetchBlogDataTrigger > 0) {
|
|
40
|
+
fetchBlogDataAsync(tid, did);
|
|
41
|
+
}
|
|
42
|
+
}, [fetchBlogDataTrigger, fetchBlogDataAsync, tid, did]);
|
|
16
43
|
useEffect(() => {
|
|
17
44
|
if (!tid || !did) {
|
|
18
45
|
setBlogsDatasource([]);
|
|
@@ -21,7 +48,7 @@ const TMDcmtBlog = ({ blogsDatasource, setBlogsDatasource, hasLoadedDataOnce, se
|
|
|
21
48
|
}
|
|
22
49
|
// Condizione per eseguire il fetch:
|
|
23
50
|
// 1. Il pannello è visibile
|
|
24
|
-
// 2. E (non abbiamo ancora caricato dati
|
|
51
|
+
// 2. E (non abbiamo ancora caricato dati o il `did` è cambiato rispetto all'ultima volta)
|
|
25
52
|
const shouldFetch = isVisible && (!hasLoadedDataOnce || did !== lastLoadedDid);
|
|
26
53
|
// Esegui la chiamata API solo se il pannello è visibile E i dati non sono già stati caricati
|
|
27
54
|
// O, se vuoi ricaricare ogni volta che diventa visibile (ma è meno efficiente per "pesante")
|