@topconsultnpm/sdkui-react 6.20.0-dev1.31 → 6.20.0-dev1.33
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.
|
@@ -7,26 +7,74 @@ import * as S from './styles';
|
|
|
7
7
|
import { IconApply, IconMenuKebab, IconMenuVertical, IconPencil, IconPin, SDKUI_Globals } 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 = [], isConstrained = false, defaultPosition = { x: 100, y: 100 }, maxItems = 8, }) => {
|
|
10
|
+
const getDefaultConfig = () => ({
|
|
11
|
+
orientation: 'horizontal',
|
|
12
|
+
savedItemIds: [],
|
|
13
|
+
position: defaultPosition,
|
|
14
|
+
});
|
|
15
|
+
const resetFloatingBarSettings = () => {
|
|
16
|
+
// Reset the floatingMenuBar settings in SDKUI_Globals to trigger save to localStorage
|
|
17
|
+
SDKUI_Globals.userSettings.searchSettings.floatingMenuBar = {
|
|
18
|
+
orientation: 'horizontal',
|
|
19
|
+
itemIds: [],
|
|
20
|
+
position: defaultPosition,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
10
23
|
const loadConfig = () => {
|
|
11
24
|
try {
|
|
12
25
|
const settings = SDKUI_Globals.userSettings.searchSettings.floatingMenuBar;
|
|
26
|
+
// Validate that settings object exists and has required properties with correct types
|
|
27
|
+
if (!settings || typeof settings !== 'object') {
|
|
28
|
+
console.warn('FloatingMenuBar: Invalid settings object, resetting to defaults');
|
|
29
|
+
resetFloatingBarSettings();
|
|
30
|
+
return getDefaultConfig();
|
|
31
|
+
}
|
|
32
|
+
// Validate position
|
|
33
|
+
const hasValidPosition = settings.position &&
|
|
34
|
+
typeof settings.position.x === 'number' &&
|
|
35
|
+
typeof settings.position.y === 'number' &&
|
|
36
|
+
!isNaN(settings.position.x) &&
|
|
37
|
+
!isNaN(settings.position.y) &&
|
|
38
|
+
isFinite(settings.position.x) &&
|
|
39
|
+
isFinite(settings.position.y);
|
|
40
|
+
if (!hasValidPosition) {
|
|
41
|
+
console.warn('FloatingMenuBar: Invalid position, resetting to defaults');
|
|
42
|
+
resetFloatingBarSettings();
|
|
43
|
+
return getDefaultConfig();
|
|
44
|
+
}
|
|
45
|
+
// Ensure position is within reasonable viewport bounds
|
|
46
|
+
const maxX = globalThis.window?.innerWidth ? globalThis.window.innerWidth - 50 : 1000;
|
|
47
|
+
const maxY = globalThis.window?.innerHeight ? globalThis.window.innerHeight - 50 : 800;
|
|
48
|
+
if (settings.position.x < 0 || settings.position.x > maxX ||
|
|
49
|
+
settings.position.y < 0 || settings.position.y > maxY) {
|
|
50
|
+
console.warn('FloatingMenuBar: Position out of bounds, resetting to defaults');
|
|
51
|
+
resetFloatingBarSettings();
|
|
52
|
+
return getDefaultConfig();
|
|
53
|
+
}
|
|
54
|
+
// Validate orientation
|
|
55
|
+
const validOrientation = (settings.orientation === 'horizontal' || settings.orientation === 'vertical')
|
|
56
|
+
? settings.orientation
|
|
57
|
+
: 'horizontal';
|
|
58
|
+
// Validate itemIds
|
|
59
|
+
const validItemIds = Array.isArray(settings.itemIds) ? settings.itemIds : [];
|
|
13
60
|
// Check if position was actually saved (not just the default class value)
|
|
14
|
-
const hasSavedPosition = settings.position
|
|
15
|
-
(settings.position.x !== 100 || settings.position.y !== 100 ||
|
|
16
|
-
(settings.itemIds && settings.itemIds.length > 0));
|
|
61
|
+
const hasSavedPosition = settings.position.x !== 100 || settings.position.y !== 100 || validItemIds.length > 0;
|
|
17
62
|
return {
|
|
18
|
-
orientation:
|
|
19
|
-
savedItemIds:
|
|
63
|
+
orientation: validOrientation,
|
|
64
|
+
savedItemIds: validItemIds,
|
|
20
65
|
position: hasSavedPosition ? settings.position : defaultPosition,
|
|
21
66
|
};
|
|
22
67
|
}
|
|
23
68
|
catch (error) {
|
|
24
69
|
console.error('Failed to load FloatingMenuBar config:', error);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
70
|
+
// Reset to defaults on any error
|
|
71
|
+
try {
|
|
72
|
+
resetFloatingBarSettings();
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.error('Failed to reset FloatingMenuBar settings:', e);
|
|
76
|
+
}
|
|
77
|
+
return getDefaultConfig();
|
|
30
78
|
}
|
|
31
79
|
};
|
|
32
80
|
const initialConfig = loadConfig();
|
|
@@ -728,11 +728,11 @@ const TMDcmtForm = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTa
|
|
|
728
728
|
const customButtonsItems = customButtonsLayout.customButtons
|
|
729
729
|
.filter((customButton) => customButton.isForUpdate && customButton.isForUpdate > 0)
|
|
730
730
|
.map((customButton) => ({
|
|
731
|
-
icon: TMImageLibrary({ imageID: customButton.glyphID
|
|
731
|
+
icon: TMImageLibrary({ imageID: customButton.glyphID }),
|
|
732
732
|
name: customButton.title || 'Bottone personalizzato',
|
|
733
733
|
onClick: () => setCustomButton(customButton)
|
|
734
734
|
}));
|
|
735
|
-
items.push({
|
|
735
|
+
customButtonsItems && customButtonsItems.length > 0 && items.push({
|
|
736
736
|
icon: _jsx(IconCheck, {}),
|
|
737
737
|
name: SDKUI_Localizator.CustomButtons,
|
|
738
738
|
submenu: customButtonsItems
|
|
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
3
3
|
import { SDK_Globals, DataColumnTypes, MetadataDataDomains, DataListViewModes, MetadataFormats, LayoutModes, TemplateTIDs, DcmtTypeListCacheService, SystemMIDsAsNumber, RetrieveFileOptions, DcmtOpers, GeneralRetrieveFormats, AccessLevelsEx, LayoutCacheService, UserListCacheService } from '@topconsultnpm/sdk-ts';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { getAllFieldSelectedDcmtsOrFocused, getCommandsMenuItems, getSelectedDcmtsOrFocused } from './TMSearchResultsMenuItems';
|
|
6
|
-
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, deepCompare, generateUniqueColumnKeys, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, IconCheck,
|
|
6
|
+
import { genUniqueId, IconShow, IconBoard, IconDcmtTypeSys, SDKUI_Localizator, IconDelete, IconRefresh, IconMenuVertical, deepCompare, generateUniqueColumnKeys, searchResultDescriptorToSimpleArray, searchResultToMetadataValues, IconSearchCheck, IconCheck, TMImageLibrary, convertSearchResultDescriptorToFileItems } from '../../../helper';
|
|
7
7
|
import { useDcmtOperations } from '../../../hooks/useDcmtOperations';
|
|
8
8
|
import { useInputAttachmentsDialog, useInputCvtFormatDialog } from '../../../hooks/useInputDialog';
|
|
9
9
|
import { useRelatedDocuments } from '../../../hooks/useRelatedDocuments';
|
|
@@ -360,15 +360,15 @@ const TMSearchResult = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, a
|
|
|
360
360
|
const customButtonMenuItems = () => {
|
|
361
361
|
const customButtonsItems = customButtonsLayout?.customButtons?.filter((customButton) => customButton.isForSearchResult && customButton.isForSearchResult > 0)
|
|
362
362
|
.map((customButton) => ({
|
|
363
|
-
icon:
|
|
363
|
+
icon: TMImageLibrary({ imageID: customButton.glyphID }),
|
|
364
364
|
name: customButton.title || 'Bottone personalizzato',
|
|
365
365
|
onClick: () => setCustomButton(customButton)
|
|
366
366
|
}));
|
|
367
|
-
return {
|
|
367
|
+
return customButtonsItems && customButtonsItems.length > 0 ? {
|
|
368
368
|
icon: _jsx(IconCheck, {}),
|
|
369
369
|
name: SDKUI_Localizator.CustomButtons,
|
|
370
370
|
submenu: customButtonsItems
|
|
371
|
-
};
|
|
371
|
+
} : {};
|
|
372
372
|
};
|
|
373
373
|
const onContextMenuPreparing = (e) => {
|
|
374
374
|
if (e === undefined)
|