@topconsultnpm/sdkui-react-beta 6.14.11 → 6.14.13
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/features/archive/TMArchive.js +1 -3
- package/lib/components/features/documents/TMDcmtForm.js +1 -1
- package/lib/components/features/search/TMSearchQueryEditor.d.ts +2 -4
- package/lib/components/features/search/TMSearchQueryEditor.js +156 -183
- package/lib/components/features/search/TMSearchQueryPanel.d.ts +0 -2
- package/lib/components/features/search/TMSearchQueryPanel.js +107 -104
- package/package.json +1 -1
|
@@ -18,8 +18,6 @@ const TMArchive = ({ inputTID, fileFromConnector = null }) => {
|
|
|
18
18
|
const [mruTIDs, setMruTIDs] = useState(TIDs);
|
|
19
19
|
const [currentMruTID, setCurrentMruTID] = useState(0);
|
|
20
20
|
const [fromDTD, setFromDTD] = useState();
|
|
21
|
-
console.log(fileFromConnector, "File from connector in TMArchive");
|
|
22
|
-
console.log("Current TID in TMArchive:", currentTID);
|
|
23
21
|
const deviceType = useDeviceType();
|
|
24
22
|
useEffect(() => { setMruTIDs(TIDs); }, []);
|
|
25
23
|
useEffect(() => {
|
|
@@ -58,7 +56,7 @@ const TMArchive = ({ inputTID, fileFromConnector = null }) => {
|
|
|
58
56
|
const tmFormElement = useMemo(() => currentTID ?
|
|
59
57
|
_jsx(TMDcmtForm, { TID: currentTID, DID: undefined, groupId: 'tmForm', layoutMode: LayoutModes.Ark, onClose: deviceType === DeviceType.MOBILE ? () => setCurrentTID(undefined) : undefined, onSaveRecents: (TIDs) => setMruTIDs(TIDs), showDcmtFormSidebar: false, fileFromConnector: fileFromConnector })
|
|
60
58
|
:
|
|
61
|
-
_jsx(TMPanel, { title: 'Archiviazione', children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsxs(StyledToppyTextContainer, { children: [" ", _jsxs(StyledToppyText, { children: [" ", SDKUI_Localizator.DcmtTypeSelect, " "] }), " "] }), " "] }), _jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsx("img", { src: Logo, width: 120, alt: '' }), " "] })] }) }), [currentTID, deviceType, mruTIDs]);
|
|
59
|
+
_jsx(TMPanel, { title: 'Archiviazione', children: _jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsxs(StyledToppyTextContainer, { children: [" ", _jsxs(StyledToppyText, { children: [" ", SDKUI_Localizator.DcmtTypeSelect, " "] }), " "] }), " "] }), _jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsx("img", { src: Logo, width: 120, alt: '' }), " "] })] }) }), [currentTID, deviceType, mruTIDs, fileFromConnector]);
|
|
62
60
|
const allInitialPanelVisibility = {
|
|
63
61
|
'tmTreeSelector': true,
|
|
64
62
|
'tmRecentsManager': true,
|
|
@@ -92,12 +92,12 @@ const TMDcmtForm = ({ showHeader = true, onSaveRecents, layoutMode = LayoutModes
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
useEffect(() => { setID(genUniqueId()); }, []);
|
|
95
|
+
//here
|
|
95
96
|
useEffect(() => {
|
|
96
97
|
if (!fileFromConnector || fileFromConnector === null)
|
|
97
98
|
return;
|
|
98
99
|
setDcmtFile(fileFromConnector);
|
|
99
100
|
}, [fileFromConnector]);
|
|
100
|
-
console.log("File from connector:", fileFromConnector);
|
|
101
101
|
useEffect(() => {
|
|
102
102
|
retrieveMetadataAsync();
|
|
103
103
|
}, [TID, DID]);
|
|
@@ -4,14 +4,12 @@ import { TID_MID } from '../../../ts';
|
|
|
4
4
|
import { AdvancedMenuClickEventArgs } from '../../editors/TMMetadataValues';
|
|
5
5
|
interface ITMSearchQueryEditorProps {
|
|
6
6
|
qd: QueryDescriptor | undefined;
|
|
7
|
-
fromDTD?: DcmtTypeDescriptor;
|
|
8
7
|
dcmtTypesList?: DcmtTypeDescriptor[];
|
|
9
8
|
isExpertMode?: boolean;
|
|
10
9
|
showAllMdWhere?: boolean;
|
|
11
|
-
isOpenDistinctValuesPanel: boolean;
|
|
12
10
|
onQdChanged?: (qd: QueryDescriptor) => void;
|
|
13
11
|
onAdvancedMenuClick?: (e: AdvancedMenuClickEventArgs) => void;
|
|
14
12
|
onFocusedMetadataChanged?: (tid_mid: TID_MID | undefined) => void;
|
|
15
13
|
}
|
|
16
|
-
declare const
|
|
17
|
-
export default
|
|
14
|
+
declare const _default: React.NamedExoticComponent<ITMSearchQueryEditorProps>;
|
|
15
|
+
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { LayoutModes, DcmtTypeListCacheService, PlatformObjectValidator, MetadataDataTypes, QueryOperators, DataListCacheService, MetadataDataDomains, SDK_Localizator, UserListCacheService } from '@topconsultnpm/sdk-ts-beta';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { LocalizeQueryOperators, getDefaultOperator, SDKUI_Localizator, IconUndo, IconPencil, IconDataList, IconFunction, IconMenuVertical, IconClearButton, displayMetadataValue, SDKUI_Globals } from '../../../helper';
|
|
@@ -28,202 +28,68 @@ const StyledMetadataListItem = styled.div `
|
|
|
28
28
|
cursor: pointer;
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
|
-
const TMSearchQueryEditor = ({ qd,
|
|
31
|
+
const TMSearchQueryEditor = ({ qd, dcmtTypesList = [], isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, showAllMdWhere, onQdChanged, onFocusedMetadataChanged, onAdvancedMenuClick }) => {
|
|
32
32
|
const [dynDataListsToBeRefreshed, setDynDataListsToBeRefreshed] = useState([]);
|
|
33
|
-
const [showDistinctValuesPanel, setShowDistinctValuesPanel] = useState(false);
|
|
34
33
|
const [currentEditingMID, setCurrentEditingMID] = useState(0);
|
|
35
34
|
const [isEditableList, addOrRemoveEditableList] = useMetadataEditableList();
|
|
36
35
|
const [focusedTidMid, setFocusedTidMid] = useState();
|
|
37
36
|
const deviceType = useDeviceType();
|
|
38
37
|
let initialMaxItems = deviceType === DeviceType.MOBILE ? 8 : 12;
|
|
39
|
-
useEffect(() => { setShowDistinctValuesPanel(isOpenDistinctValuesPanel); }, [isOpenDistinctValuesPanel]);
|
|
40
38
|
useEffect(() => {
|
|
41
39
|
onFocusedMetadataChanged?.(focusedTidMid);
|
|
42
40
|
}, [focusedTidMid]);
|
|
43
|
-
|
|
41
|
+
// --- Callbacks Memoizzate ---
|
|
42
|
+
const handleWhereItemChanged = useCallback((wi) => {
|
|
43
|
+
if (!wi || !qd?.where)
|
|
44
|
+
return;
|
|
45
|
+
const whereCopy = qd.where.map((curItem) => (curItem.mid !== wi.mid ? curItem : wi));
|
|
46
|
+
onQdChanged?.({ ...qd, where: whereCopy });
|
|
47
|
+
}, [qd, onQdChanged]);
|
|
48
|
+
const handleItemSelect = useCallback((tid, mid) => {
|
|
44
49
|
if (currentEditingMID !== mid)
|
|
45
50
|
setCurrentEditingMID(mid);
|
|
46
|
-
if (mid !== focusedTidMid
|
|
51
|
+
if (!focusedTidMid || mid !== focusedTidMid.mid) {
|
|
47
52
|
setFocusedTidMid({ tid: tid, mid: mid });
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
}
|
|
54
|
+
}, [currentEditingMID, focusedTidMid]);
|
|
55
|
+
const handleAdvancedMenuClick = useCallback((e) => {
|
|
56
|
+
if (e.button === AdvancedMenuButtons.MakeEditable && e.mid) {
|
|
57
|
+
addOrRemoveEditableList(e.mid);
|
|
58
|
+
}
|
|
59
|
+
// Propaga l'evento al genitore
|
|
60
|
+
onAdvancedMenuClick?.(e);
|
|
61
|
+
}, [addOrRemoveEditableList, onAdvancedMenuClick]);
|
|
62
|
+
const handleCascadeRefresh = useCallback((ddlToBeRefreshed) => {
|
|
63
|
+
setDynDataListsToBeRefreshed(prevList => {
|
|
64
|
+
const newList = prevList.filter(item => !ddlToBeRefreshed.some(o => o.mid === item.mid || (o.mid === -1 && o.midStarter === item.midStarter)));
|
|
65
|
+
const itemsToAdd = ddlToBeRefreshed.filter(item => item.queryParams.length > 0 && item.mid && item.mid > 0);
|
|
66
|
+
return [...newList, ...itemsToAdd];
|
|
67
|
+
});
|
|
68
|
+
}, []);
|
|
69
|
+
const handleCascadeUpdate = useCallback((midsToBeUpdated) => {
|
|
70
|
+
if (!qd?.where)
|
|
51
71
|
return;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
let changed = false;
|
|
73
|
+
const whereCopy = qd.where.map(wi => {
|
|
74
|
+
const updateInfo = midsToBeUpdated.find(item => item.mid === wi.mid);
|
|
75
|
+
if (updateInfo) {
|
|
76
|
+
changed = true;
|
|
77
|
+
return { ...wi, value1: updateInfo.value };
|
|
78
|
+
}
|
|
55
79
|
return wi;
|
|
56
80
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const getQueryOperatorsMenuItems = (wi, index) => {
|
|
60
|
-
const onChange_WhereItem_QueryOperator = (qo, index) => {
|
|
61
|
-
handleWhereItemChanged({ ...wi, operator: qo, value1: undefined, value2: undefined });
|
|
62
|
-
};
|
|
63
|
-
let items = [];
|
|
64
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.Equal), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Equal, index) });
|
|
65
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEqual, index) });
|
|
66
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNull, index) });
|
|
67
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNotNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNotNull, index) });
|
|
68
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.In), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.In, index) });
|
|
69
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.NotIn), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotIn, index) });
|
|
70
|
-
let md = fromDTD?.metadata?.find(o => o.id == wi.mid);
|
|
71
|
-
let mdDataType = md?.dataType;
|
|
72
|
-
if (mdDataType != MetadataDataTypes.Varchar) {
|
|
73
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.Greater), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Greater, index) });
|
|
74
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.GreaterOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.GreaterOrEqual, index) });
|
|
75
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.Less), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Less, index) });
|
|
76
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.LessOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LessOrEqual, index) });
|
|
77
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenExclusive, index) });
|
|
78
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenInclusive, index) });
|
|
79
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideExclusive, index) });
|
|
80
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideInclusive, index) });
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.Contain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Contain, index) });
|
|
84
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.NotContain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotContain, index) });
|
|
85
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.BeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BeginWith, index) });
|
|
86
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.NotBeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotBeginWith, index) });
|
|
87
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.EndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.EndWith, index) });
|
|
88
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEndWith, index) });
|
|
89
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.Like), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Like, index) });
|
|
90
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.NotLike), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotLike, index) });
|
|
91
|
-
}
|
|
92
|
-
items.push({ text: LocalizeQueryOperators(QueryOperators.Custom), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Custom, index) });
|
|
93
|
-
if (mdDataType == MetadataDataTypes.DateTime) {
|
|
94
|
-
items.push({
|
|
95
|
-
text: "Operatori speciali", items: [
|
|
96
|
-
{ text: LocalizeQueryOperators(QueryOperators.Yesterday), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Yesterday, index) },
|
|
97
|
-
{ text: LocalizeQueryOperators(QueryOperators.Today), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Today, index) },
|
|
98
|
-
{ text: LocalizeQueryOperators(QueryOperators.Tomorrow), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Tomorrow, index) },
|
|
99
|
-
{ text: LocalizeQueryOperators(QueryOperators.PreviousWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousWeek, index) },
|
|
100
|
-
{ text: LocalizeQueryOperators(QueryOperators.ThisWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisWeek, index) },
|
|
101
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextWeek, index) },
|
|
102
|
-
{ text: LocalizeQueryOperators(QueryOperators.PreviousMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousMonth, index) },
|
|
103
|
-
{ text: LocalizeQueryOperators(QueryOperators.ThisMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisMonth, index) },
|
|
104
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextMonth, index) },
|
|
105
|
-
{ text: LocalizeQueryOperators(QueryOperators.PreviousYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousYear, index) },
|
|
106
|
-
{ text: LocalizeQueryOperators(QueryOperators.ThisYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisYear, index) },
|
|
107
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextYear, index) },
|
|
108
|
-
{ text: LocalizeQueryOperators(QueryOperators.LastXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXHours, index) },
|
|
109
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXHours, index) },
|
|
110
|
-
{ text: LocalizeQueryOperators(QueryOperators.LastXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXDays, index) },
|
|
111
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXDays, index) },
|
|
112
|
-
{ text: LocalizeQueryOperators(QueryOperators.LastXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXWeeks, index) },
|
|
113
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXWeeks, index) },
|
|
114
|
-
{ text: LocalizeQueryOperators(QueryOperators.LastXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXMonths, index) },
|
|
115
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXMonths, index) },
|
|
116
|
-
{ text: LocalizeQueryOperators(QueryOperators.LastXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXYears, index) },
|
|
117
|
-
{ text: LocalizeQueryOperators(QueryOperators.NextXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXYears, index) }
|
|
118
|
-
]
|
|
119
|
-
});
|
|
81
|
+
if (changed) {
|
|
82
|
+
onQdChanged?.({ ...qd, where: whereCopy });
|
|
120
83
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const getOperatorColor = (whereItem) => {
|
|
124
|
-
if (dcmtTypesList.length <= 0)
|
|
125
|
-
return 'green';
|
|
126
|
-
let dtd = dcmtTypesList.find(o => o.id === whereItem.tid);
|
|
127
|
-
let md = dtd?.metadata?.find(o => o.id === whereItem.mid);
|
|
128
|
-
return whereItem.operator === getDefaultOperator(md?.dataDomain, md?.dataType) ? 'green' : TMColors.tertiary;
|
|
129
|
-
};
|
|
130
|
-
const getAdvancedMenuItems = (tid, mid) => {
|
|
131
|
-
let isEditable = isEditableList(mid);
|
|
132
|
-
let dtd = dcmtTypesList.find(o => o.id == tid);
|
|
133
|
-
if (!dtd)
|
|
134
|
-
return [];
|
|
135
|
-
let md = dtd.metadata?.find(o => o.id == mid);
|
|
136
|
-
if (!md)
|
|
137
|
-
return [];
|
|
138
|
-
const menu = [
|
|
139
|
-
// Only add MakeEditable/Restore if isExpertMode is true
|
|
140
|
-
...(isExpertMode ? [{
|
|
141
|
-
text: isEditable ? SDKUI_Localizator.Restore : SDKUI_Localizator.MakeEditable,
|
|
142
|
-
icon: isEditable ? _jsx(IconUndo, {}) : _jsx(IconPencil, {}),
|
|
143
|
-
onClick: () => {
|
|
144
|
-
addOrRemoveEditableList(mid);
|
|
145
|
-
onAdvancedMenuClick?.({ tid: tid, mid: mid, button: AdvancedMenuButtons.MakeEditable });
|
|
146
|
-
}
|
|
147
|
-
}] : []),
|
|
148
|
-
{
|
|
149
|
-
text: SDKUI_Localizator.DistinctValues,
|
|
150
|
-
icon: _jsx(IconDataList, {}),
|
|
151
|
-
onClick: () => {
|
|
152
|
-
handleMetadataSelection(tid, mid);
|
|
153
|
-
setShowDistinctValuesPanel(!showDistinctValuesPanel);
|
|
154
|
-
onAdvancedMenuClick?.({ tid: tid, mid: mid, button: AdvancedMenuButtons.DistinctValues });
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
];
|
|
158
|
-
return menu;
|
|
159
|
-
};
|
|
84
|
+
}, [qd, onQdChanged]);
|
|
85
|
+
const itemsToRender = qd?.where?.slice(0, showAllMdWhere ? qd.where.length : initialMaxItems) ?? [];
|
|
160
86
|
return (_jsx(_Fragment, { children: deviceType === DeviceType.MOBILE ?
|
|
161
|
-
_jsx("div", { style: { overflow: 'auto', display: 'flex', flexDirection: 'column', height: '100%', padding: '5px', gap: '5px' }, children:
|
|
162
|
-
let newDynDataListsToBeRefreshed = [];
|
|
163
|
-
for (const item of dynDataListsToBeRefreshed) {
|
|
164
|
-
let index = ddlToBeRefreshed.findIndex(o => o.mid == item.mid || (o.mid == -1 && o.midStarter == item.midStarter));
|
|
165
|
-
if (index >= 0)
|
|
166
|
-
continue;
|
|
167
|
-
newDynDataListsToBeRefreshed.push(item);
|
|
168
|
-
}
|
|
169
|
-
for (const item of ddlToBeRefreshed) {
|
|
170
|
-
if (item.queryParams.length <= 0)
|
|
171
|
-
continue;
|
|
172
|
-
if (!item.mid)
|
|
173
|
-
continue;
|
|
174
|
-
if (item.mid <= 0)
|
|
175
|
-
continue;
|
|
176
|
-
newDynDataListsToBeRefreshed.push(item);
|
|
177
|
-
}
|
|
178
|
-
setDynDataListsToBeRefreshed(newDynDataListsToBeRefreshed);
|
|
179
|
-
}, onCascadeUpdateMIDs: (midsToBeUpdated) => {
|
|
180
|
-
for (const item of midsToBeUpdated) {
|
|
181
|
-
const whereItem = qd?.where?.find(o => o.mid === item.mid);
|
|
182
|
-
if (whereItem) {
|
|
183
|
-
whereItem.value1 = item.value;
|
|
184
|
-
handleWhereItemChanged(whereItem);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}, onWhereItemChange: (newWi) => { handleWhereItemChanged(newWi); }, onHideEditor: () => { setCurrentEditingMID(0); } }) }, `${wi.tid}_${wi.mid}_${index}`))) })
|
|
87
|
+
_jsx("div", { style: { overflow: 'auto', display: 'flex', flexDirection: 'column', height: '100%', padding: '5px', gap: '5px' }, children: itemsToRender.map((wi, index) => (_jsx(WhereItemRow, { whereItem: wi, index: index, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, isSelected: false, isEditable: isEditableList(wi.mid), currentEditingMID: currentEditingMID, queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid === wi.mid)?.queryParams ?? [], onItemChange: handleWhereItemChanged, onItemSelect: handleItemSelect, onAdvancedMenuClick: handleAdvancedMenuClick, onCascadeRefreshDynDataLists: handleCascadeRefresh, onCascadeUpdateMIDs: handleCascadeUpdate, onHideMobileEditor: () => setCurrentEditingMID(0) }, `${wi.tid}_${wi.mid}_${index}`))) })
|
|
188
88
|
:
|
|
189
|
-
_jsx("div", { style: { display: 'grid', borderRadius: '8px', alignItems: 'center', overflow: 'auto', padding: '5px', gap: '8px', gridTemplateColumns: 'minmax(0, max-content) minmax(0, max-content) minmax(50%, 1fr)' }, children:
|
|
190
|
-
return (_jsxs(React.Fragment, { children: [_jsx("div", { id: `wi-item-${whereItem.mid}`, style: { gridColumn: 1 }, children: _jsx(TMMidViewer, { color: TMColors.primaryColor, isMetadataSelected: showDistinctValuesPanel && whereItem.mid === focusedTidMid?.mid, showIcon: true, tid_mid: { tid: whereItem?.tid, mid: whereItem?.mid, aliasTID: whereItem?.alias } }) }), _jsx("div", { style: { gridColumn: 2, paddingLeft: '5px', paddingRight: '5px' }, children: _jsx(TMDropDownMenu, { backgroundColor: colorOperator, color: getOperatorColor(whereItem), items: getQueryOperatorsMenuItems(whereItem, index), content: _jsx(StyledItemWrapper, { children: LocalizeQueryOperators(whereItem.operator) }) }) }), _jsxs("div", { style: { gridColumn: 3, position: 'relative' }, onClick: () => { handleMetadataSelection(whereItem.tid, whereItem.mid); }, onFocus: () => { handleMetadataSelection(whereItem.tid, whereItem.mid); }, children: [_jsx(TMSearchWhereItemEditor, { isSelected: showDistinctValuesPanel && whereItem.mid === focusedTidMid?.mid, openChooserBySingleClick: !showDistinctValuesPanel, whereItem: whereItem, index: index, isEditableList: isEditableList(whereItem.mid), queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid == whereItem.mid)?.queryParams ?? [], onValueChanged: (values) => {
|
|
191
|
-
handleWhereItemChanged({ ...whereItem, value1: values[0], value2: values[1] });
|
|
192
|
-
}, onCascadeRefreshDynDataLists: (ddlToBeRefreshed) => {
|
|
193
|
-
let newDynDataListsToBeRefreshed = [];
|
|
194
|
-
for (const item of dynDataListsToBeRefreshed) {
|
|
195
|
-
let index = ddlToBeRefreshed.findIndex(o => o.mid == item.mid || (o.mid == -1 && o.midStarter == item.midStarter));
|
|
196
|
-
if (index >= 0)
|
|
197
|
-
continue;
|
|
198
|
-
newDynDataListsToBeRefreshed.push(item);
|
|
199
|
-
}
|
|
200
|
-
for (const item of ddlToBeRefreshed) {
|
|
201
|
-
if (item.queryParams.length <= 0)
|
|
202
|
-
continue;
|
|
203
|
-
if (!item.mid)
|
|
204
|
-
continue;
|
|
205
|
-
if (item.mid <= 0)
|
|
206
|
-
continue;
|
|
207
|
-
newDynDataListsToBeRefreshed.push(item);
|
|
208
|
-
}
|
|
209
|
-
setDynDataListsToBeRefreshed(newDynDataListsToBeRefreshed);
|
|
210
|
-
}, onCascadeUpdateMIDs: (midsToBeUpdated) => {
|
|
211
|
-
for (const item of midsToBeUpdated) {
|
|
212
|
-
const whereItem = qd?.where?.find(o => o.mid === item.mid);
|
|
213
|
-
if (whereItem) {
|
|
214
|
-
whereItem.value1 = item.value;
|
|
215
|
-
handleWhereItemChanged(whereItem);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
} }), FormulaHelper.isFormula(whereItem.value1)
|
|
219
|
-
? _jsx(IconFunction, { color: "#1a89d3", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
|
220
|
-
: (isEditableList(whereItem.mid))
|
|
221
|
-
? _jsx(IconPencil, { color: "#138603", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
|
222
|
-
: _jsx(_Fragment, {})] }), _jsx("div", { style: { gridColumn: 4 }, children: _jsx(TMDropDownMenu, { backgroundColor: 'white', color: TMColors.button_icon, borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconMenuVertical, {}), showTooltip: false }), items: getAdvancedMenuItems(whereItem.tid, whereItem.mid) }) })] }, `${whereItem.tid}_${whereItem.mid}_${index}`));
|
|
223
|
-
}) }) }));
|
|
89
|
+
_jsx("div", { style: { display: 'grid', borderRadius: '8px', alignItems: 'center', overflow: 'auto', padding: '5px', gap: '8px', gridTemplateColumns: 'minmax(0, max-content) minmax(0, max-content) minmax(50%, 1fr) minmax(0, max-content)' }, children: itemsToRender.map((wi, index) => (_jsx(WhereItemRow, { whereItem: wi, index: index, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, isSelected: false, isEditable: isEditableList(wi.mid), currentEditingMID: currentEditingMID, queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid === wi.mid)?.queryParams ?? [], onItemChange: handleWhereItemChanged, onItemSelect: handleItemSelect, onAdvancedMenuClick: handleAdvancedMenuClick, onCascadeRefreshDynDataLists: handleCascadeRefresh, onCascadeUpdateMIDs: handleCascadeUpdate, onHideMobileEditor: () => setCurrentEditingMID(0) }, `${wi.tid}_${wi.mid}_${index}`))) }) }));
|
|
224
90
|
};
|
|
225
|
-
export default TMSearchQueryEditor;
|
|
226
|
-
const TMSearchWhereItemEditor = ({ whereItem, queryParamsDynDataList, index, isSelected, isEditableList, autoFocus, openChooserBySingleClick, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
|
91
|
+
export default React.memo(TMSearchQueryEditor);
|
|
92
|
+
const TMSearchWhereItemEditor = React.memo(({ whereItem, queryParamsDynDataList, index, isSelected, isEditableList, autoFocus, openChooserBySingleClick, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
|
227
93
|
const [showValue1, setShowValue1] = useState(true);
|
|
228
94
|
const [showValue2, setShowValue2] = useState(false);
|
|
229
95
|
const [dataList, setDataList] = useState();
|
|
@@ -286,8 +152,8 @@ const TMSearchWhereItemEditor = ({ whereItem, queryParamsDynDataList, index, isS
|
|
|
286
152
|
onValueChanged?.(newValues);
|
|
287
153
|
};
|
|
288
154
|
return (_jsxs(StyledRowItem, { style: { marginBottom: 0 }, children: [showValue1 && _jsx(TMMetadataEditor, { openChooserBySingleClick: openChooserBySingleClick, isSelected: isSelected, tid: whereItem.tid, mid: whereItem.mid, layoutMode: LayoutModes.None, isEditable: isEditableList, value: whereItem.value1, queryOperator: whereItem.operator, queryParamsDynDataList: queryParamsDynDataList, autoFocus: autoFocus ?? false, containerElement: undefined, onValueChanged: (value) => { normalizeValue(value, true); }, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs }), showValue2 && _jsx(TMMetadataEditor, { openChooserBySingleClick: openChooserBySingleClick, isSelected: isSelected, tid: whereItem.tid, mid: whereItem.mid, layoutMode: LayoutModes.None, isEditable: isEditableList, value: whereItem.value2, queryOperator: whereItem.operator, autoFocus: autoFocus ?? false, containerElement: undefined, onValueChanged: (value) => { normalizeValue(value, false); } })] }));
|
|
289
|
-
};
|
|
290
|
-
const TMSearchWhereItemCard = ({ index, whereItem, isSelected, queryParamsDynDataList, showEditor, showCompleteMetadataName, showId, isEditableList, onWhereItemChange, onHideEditor, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
|
155
|
+
});
|
|
156
|
+
const TMSearchWhereItemCard = React.memo(({ index, whereItem, isSelected, queryParamsDynDataList, showEditor, showCompleteMetadataName, showId, isEditableList, onWhereItemChange, onHideEditor, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
|
291
157
|
const [isOpen, setIsOpen] = useState(false);
|
|
292
158
|
const [md, setMd] = useState();
|
|
293
159
|
useEffect(() => { getMetadata().then((mdOut) => { setMd(mdOut); }); }, [whereItem]);
|
|
@@ -361,8 +227,8 @@ const TMSearchWhereItemCard = ({ index, whereItem, isSelected, queryParamsDynDat
|
|
|
361
227
|
};
|
|
362
228
|
return (_jsxs("div", { style: { width: "100%", fontSize: '1rem', userSelect: 'none' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }, children: [_jsx(TMSearchWhereItemViewer, { isSelected: isSelected, whereItem: whereItem, showCompleteMetadataName: showCompleteMetadataName, showId: showId, showValue: !isOpen }), isOpen &&
|
|
363
229
|
_jsx("div", { onClick: (e) => e.stopPropagation(), children: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconClearButton, { color: 'red' }), caption: SDKUI_Localizator.Close, showTooltip: false, onClick: () => { onHideEditor?.(); } }) })] }), _jsx("div", { style: { display: isOpen ? 'flex' : 'none', flexDirection: 'column', paddingTop: 5, gap: '5px' }, children: _jsxs(StyledDivHorizontal, { style: { gap: '5px' }, children: [_jsx(TMDropDownMenu, { backgroundColor: colorOperator, color: 'green', content: _jsx(StyledItemWrapper, { children: LocalizeQueryOperators(whereItem.operator) }), items: getQueryOperatorsMenuItems(whereItem, index) }), _jsx(TMSearchWhereItemEditor, { isSelected: isSelected, whereItem: whereItem, index: index, isEditableList: isEditableList, autoFocus: !!isOpen, onValueChanged: (values) => { onWhereItemChange?.({ ...whereItem, value1: values[0], value2: values[1] }); }, queryParamsDynDataList: queryParamsDynDataList, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs })] }) })] }));
|
|
364
|
-
};
|
|
365
|
-
const TMSearchWhereItemViewer = ({ isSelected = false, whereItem, showCompleteMetadataName, showId, showValue }) => {
|
|
230
|
+
});
|
|
231
|
+
const TMSearchWhereItemViewer = React.memo(({ isSelected = false, whereItem, showCompleteMetadataName, showId, showValue }) => {
|
|
366
232
|
const [numberOfOperands, setNumberOfOperands] = useState(0);
|
|
367
233
|
const [md, setMd] = useState();
|
|
368
234
|
useEffect(() => {
|
|
@@ -379,4 +245,111 @@ const TMSearchWhereItemViewer = ({ isSelected = false, whereItem, showCompleteMe
|
|
|
379
245
|
? _jsx(_Fragment, { children: whereItem.value1 })
|
|
380
246
|
// ? <>{numberOfOperands == 11 ? whereItem.value1?.split(',').map((item: string) => !item.startsWith("'") ? item : item.slice(1, -1)).join(",") : whereItem.value1}</>
|
|
381
247
|
: _jsxs(_Fragment, { children: [displayMetadataValue(md, whereItem.value1, ""), numberOfOperands == 2 && (whereItem.value2 && whereItem.value2 != '' ? ` - ${displayMetadataValue(md, whereItem.value2, "")}` : ' - ?')] }) })] }));
|
|
382
|
-
};
|
|
248
|
+
});
|
|
249
|
+
const WhereItemRow = React.memo(({ whereItem, index, dcmtTypesList, isExpertMode, isSelected, isEditable, currentEditingMID, queryParamsDynDataList, onItemChange, onItemSelect, onAdvancedMenuClick, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs, onHideMobileEditor }) => {
|
|
250
|
+
const deviceType = useDeviceType();
|
|
251
|
+
// Trova il metadata descriptor per l'item corrente
|
|
252
|
+
const md = useMemo(() => {
|
|
253
|
+
const dtd = dcmtTypesList.find(o => o.id === whereItem.tid);
|
|
254
|
+
return dtd?.metadata?.find(o => o.id === whereItem.mid);
|
|
255
|
+
}, [dcmtTypesList, whereItem.tid, whereItem.mid]);
|
|
256
|
+
// --- Memoized Menu Items ---
|
|
257
|
+
const queryOperatorsItems = useMemo(() => {
|
|
258
|
+
const onChange_WhereItem_QueryOperator = (qo) => {
|
|
259
|
+
onItemChange({ ...whereItem, operator: qo, value1: undefined, value2: undefined });
|
|
260
|
+
};
|
|
261
|
+
let items = [];
|
|
262
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Equal), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Equal) });
|
|
263
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEqual) });
|
|
264
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNull) });
|
|
265
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNotNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNotNull) });
|
|
266
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.In), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.In) });
|
|
267
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotIn), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotIn) });
|
|
268
|
+
if (md?.dataType !== MetadataDataTypes.Varchar) {
|
|
269
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Greater), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Greater) });
|
|
270
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.GreaterOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.GreaterOrEqual) });
|
|
271
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Less), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Less) });
|
|
272
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.LessOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LessOrEqual) });
|
|
273
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenExclusive) });
|
|
274
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenInclusive) });
|
|
275
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideExclusive) });
|
|
276
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideInclusive) });
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Contain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Contain) });
|
|
280
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotContain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotContain) });
|
|
281
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BeginWith) });
|
|
282
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotBeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotBeginWith) });
|
|
283
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.EndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.EndWith) });
|
|
284
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEndWith) });
|
|
285
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Like), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Like) });
|
|
286
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotLike), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotLike) });
|
|
287
|
+
}
|
|
288
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Custom), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Custom) });
|
|
289
|
+
if (md?.dataType == MetadataDataTypes.DateTime) {
|
|
290
|
+
items.push({
|
|
291
|
+
text: "Operatori speciali", items: [
|
|
292
|
+
{ text: LocalizeQueryOperators(QueryOperators.Yesterday), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Yesterday) },
|
|
293
|
+
{ text: LocalizeQueryOperators(QueryOperators.Today), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Today) },
|
|
294
|
+
{ text: LocalizeQueryOperators(QueryOperators.Tomorrow), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Tomorrow) },
|
|
295
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousWeek) },
|
|
296
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisWeek) },
|
|
297
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextWeek) },
|
|
298
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousMonth) },
|
|
299
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisMonth) },
|
|
300
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextMonth) },
|
|
301
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousYear) },
|
|
302
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisYear) },
|
|
303
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextYear) },
|
|
304
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXHours) },
|
|
305
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXHours) },
|
|
306
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXDays) },
|
|
307
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXDays) },
|
|
308
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXWeeks) },
|
|
309
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXWeeks) },
|
|
310
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXMonths) },
|
|
311
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXMonths) },
|
|
312
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXYears) },
|
|
313
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXYears) }
|
|
314
|
+
]
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return items;
|
|
318
|
+
}, [whereItem, md, onItemChange]);
|
|
319
|
+
const advancedMenuItems = useMemo(() => {
|
|
320
|
+
const menu = [
|
|
321
|
+
...(isExpertMode ? [{
|
|
322
|
+
text: isEditable ? SDKUI_Localizator.Restore : SDKUI_Localizator.MakeEditable,
|
|
323
|
+
icon: isEditable ? _jsx(IconUndo, {}) : _jsx(IconPencil, {}),
|
|
324
|
+
onClick: () => {
|
|
325
|
+
onAdvancedMenuClick({ tid: whereItem.tid, mid: whereItem.mid, button: AdvancedMenuButtons.MakeEditable });
|
|
326
|
+
}
|
|
327
|
+
}] : []),
|
|
328
|
+
{
|
|
329
|
+
text: SDKUI_Localizator.DistinctValues,
|
|
330
|
+
icon: _jsx(IconDataList, {}),
|
|
331
|
+
onClick: () => {
|
|
332
|
+
onItemSelect(whereItem.tid, whereItem.mid); // Seleziona prima di chiamare l'azione
|
|
333
|
+
onAdvancedMenuClick({ tid: whereItem.tid, mid: whereItem.mid, button: AdvancedMenuButtons.DistinctValues });
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
];
|
|
337
|
+
return menu;
|
|
338
|
+
}, [whereItem, isEditable, isExpertMode, onAdvancedMenuClick, onItemSelect]);
|
|
339
|
+
const getOperatorColor = () => {
|
|
340
|
+
if (!md)
|
|
341
|
+
return 'green';
|
|
342
|
+
return whereItem.operator === getDefaultOperator(md.dataDomain, md.dataType) ? 'green' : TMColors.tertiary;
|
|
343
|
+
};
|
|
344
|
+
// --- Rendering ---
|
|
345
|
+
if (deviceType === DeviceType.MOBILE) {
|
|
346
|
+
return (_jsx(StyledMetadataListItem, { id: `wi-item-${whereItem.mid}`, onClick: () => onItemSelect(whereItem.tid, whereItem.mid), onFocus: () => onItemSelect(whereItem.tid, whereItem.mid), "$backgroundColor": !PlatformObjectValidator.WhereItemHasValues(whereItem) ? `${TMColors.primary}66` : 'rgba(236, 202, 156, 1)', "$hoverColor": !PlatformObjectValidator.WhereItemHasValues(whereItem) ? `${TMColors.primary}33` : 'rgba(236, 202, 156, .5)', children: _jsx(TMSearchWhereItemCard, { isSelected: isSelected, index: index, whereItem: whereItem, showEditor: currentEditingMID === whereItem.mid, isEditableList: isEditable, queryParamsDynDataList: queryParamsDynDataList, onWhereItemChange: onItemChange, onHideEditor: onHideMobileEditor, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs }) }));
|
|
347
|
+
}
|
|
348
|
+
return (_jsxs(React.Fragment, { children: [_jsx("div", { id: `wi-item-${whereItem.mid}`, style: { gridColumn: 1 }, children: _jsx(TMMidViewer, { color: TMColors.primaryColor, isMetadataSelected: isSelected, showIcon: true, tid_mid: { tid: whereItem?.tid, mid: whereItem?.mid, aliasTID: whereItem?.alias } }) }), _jsx("div", { style: { gridColumn: 2, paddingLeft: '5px', paddingRight: '5px' }, children: _jsx(TMDropDownMenu, { backgroundColor: colorOperator, color: getOperatorColor(), items: queryOperatorsItems, content: _jsx(StyledItemWrapper, { children: LocalizeQueryOperators(whereItem.operator) }) }) }), _jsxs("div", { style: { gridColumn: 3, position: 'relative' }, onClick: () => onItemSelect(whereItem.tid, whereItem.mid), onFocus: () => onItemSelect(whereItem.tid, whereItem.mid), children: [_jsx(TMSearchWhereItemEditor, { isSelected: isSelected, openChooserBySingleClick: !isSelected, whereItem: whereItem, index: index, isEditableList: isEditable, queryParamsDynDataList: queryParamsDynDataList, onValueChanged: (values) => {
|
|
349
|
+
onItemChange({ ...whereItem, value1: values[0], value2: values[1] });
|
|
350
|
+
}, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs }), FormulaHelper.isFormula(whereItem.value1)
|
|
351
|
+
? _jsx(IconFunction, { color: "#1a89d3", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
|
352
|
+
: isEditable
|
|
353
|
+
? _jsx(IconPencil, { color: "#138603", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
|
354
|
+
: null] }), _jsx("div", { style: { gridColumn: 4 }, children: _jsx(TMDropDownMenu, { backgroundColor: 'white', color: TMColors.button_icon, borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', icon: _jsx(IconMenuVertical, {}), showTooltip: false }), items: advancedMenuItems }) })] }));
|
|
355
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DcmtTypeDescriptor, QueryDescriptor, SavedQueryDescriptor, SearchResultDescriptor } from '@topconsultnpm/sdk-ts-beta';
|
|
3
|
-
import { TID_MID } from '../../../ts';
|
|
4
3
|
interface ITMSearchQueryPanelProps {
|
|
5
4
|
fromDTD?: DcmtTypeDescriptor;
|
|
6
5
|
SQD?: SavedQueryDescriptor;
|
|
@@ -9,7 +8,6 @@ interface ITMSearchQueryPanelProps {
|
|
|
9
8
|
onBack?: () => void;
|
|
10
9
|
onBackToResult?: () => void;
|
|
11
10
|
onSqdSaved?: (newSqd: SavedQueryDescriptor) => void;
|
|
12
|
-
onFocusedMetadataChanged?: (tid_mid: TID_MID | undefined) => void;
|
|
13
11
|
onSearchCompleted?: (searchResult: SearchResultDescriptor[], qd: QueryDescriptor | undefined) => void;
|
|
14
12
|
onClosePanel?: () => void;
|
|
15
13
|
onMaximizePanel?: () => void;
|
|
@@ -23,7 +23,7 @@ import TMQueryEditor from '../../query/TMQueryEditor';
|
|
|
23
23
|
import TMSavedQueryForm from './TMSavedQueryForm';
|
|
24
24
|
import { AdvancedMenuButtons } from '../../editors/TMMetadataValues';
|
|
25
25
|
import TMShowAllOrMaxItemsButton from '../../base/TMShowAllOrMaxItemsButton';
|
|
26
|
-
const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, SQD, onSearchCompleted,
|
|
26
|
+
const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, SQD, onSearchCompleted, onSqdSaved, onBack, onClosePanel, onMaximizePanel, onBackToResult }) => {
|
|
27
27
|
const [confirmQueryParams, ConfirmQueryParamsDialog] = useQueryParametersDialog();
|
|
28
28
|
const [qd, setQd] = useState();
|
|
29
29
|
const [shouldSearch, setShouldSearch] = useState(false); // Nuovo stato per attivare la ricerca
|
|
@@ -57,7 +57,26 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
57
57
|
executeSearch();
|
|
58
58
|
}
|
|
59
59
|
}, [shouldSearch, qd, showAdvancedSearch]);
|
|
60
|
-
useEffect(() => {
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const handleKeyDown = (e) => {
|
|
62
|
+
if (panelRef.current &&
|
|
63
|
+
panelRef.current.contains(document.activeElement)) {
|
|
64
|
+
if (e.key === 'Enter') {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
// Disattiva l'elemento attivo per forzare l'onBlur
|
|
67
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
68
|
+
document.activeElement.blur();
|
|
69
|
+
}
|
|
70
|
+
// Attiva il flag di ricerca. L'useEffect sopra gestirà l'attesa di qd.
|
|
71
|
+
setShouldSearch(true);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
76
|
+
return () => {
|
|
77
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
61
80
|
const setDataAsync = async (sqd) => {
|
|
62
81
|
let newSqd = (sqd?.id == 1) ? sqd : await SavedQueryCacheService.GetAsync(sqd?.id);
|
|
63
82
|
let newQd = SearchEngine.NormalizeQueryDescriptor(newSqd?.qd);
|
|
@@ -127,29 +146,88 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
127
146
|
setQd(newQd);
|
|
128
147
|
}
|
|
129
148
|
}, []);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (e.key === 'Enter') {
|
|
135
|
-
e.preventDefault();
|
|
136
|
-
// Disattiva l'elemento attivo per forzare l'onBlur
|
|
137
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
138
|
-
document.activeElement.blur();
|
|
139
|
-
}
|
|
140
|
-
// Attiva il flag di ricerca. L'useEffect sopra gestirà l'attesa di qd.
|
|
141
|
-
setShouldSearch(true);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
146
|
-
return () => {
|
|
147
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
148
|
-
};
|
|
149
|
+
const handleAdvancedMenuClick = useCallback((e) => {
|
|
150
|
+
if (e.button === AdvancedMenuButtons.DistinctValues) {
|
|
151
|
+
setShowDistinctValuesPanel(true);
|
|
152
|
+
}
|
|
149
153
|
}, []);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
const handleCloseFiltersConfig = useCallback(() => setShowFiltersConfig(false), []);
|
|
155
|
+
const handleChooseFilters = useCallback((tid_mids) => {
|
|
156
|
+
if (!fromDTD?.metadata)
|
|
157
|
+
return;
|
|
158
|
+
if (!tid_mids)
|
|
159
|
+
return;
|
|
160
|
+
// copia dei whereItem senza i rimossi
|
|
161
|
+
let newWhere = qd?.where?.filter(wi => tid_mids?.some(tm => tm.mid == wi.mid)) ?? [];
|
|
162
|
+
// aggiungiamo i nuovi
|
|
163
|
+
for (const tm of tid_mids.filter(tm => !qd?.where?.some(wi => wi.mid == tm.mid))) {
|
|
164
|
+
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
165
|
+
let wi = new WhereItem();
|
|
166
|
+
wi.or = false;
|
|
167
|
+
wi.leftBrackets = "(";
|
|
168
|
+
wi.tid = SQD?.masterTID;
|
|
169
|
+
wi.mid = tm.mid;
|
|
170
|
+
wi.operator = getDefaultOperator(md?.dataDomain, md?.dataType);
|
|
171
|
+
wi.rightBrackets = ")";
|
|
172
|
+
let indexMD = 0;
|
|
173
|
+
for (const m of fromDTD?.metadata ?? []) {
|
|
174
|
+
if (m.id == wi.mid)
|
|
175
|
+
break;
|
|
176
|
+
if (newWhere.findIndex(o => o.mid == m.id && o.tid == SQD?.masterTID) < 0)
|
|
177
|
+
continue;
|
|
178
|
+
indexMD++;
|
|
179
|
+
}
|
|
180
|
+
newWhere.splice(indexMD, 0, wi);
|
|
181
|
+
}
|
|
182
|
+
setQd({ ...qd, where: newWhere });
|
|
183
|
+
}, [qd, fromDTD?.metadata, SQD?.masterTID]);
|
|
184
|
+
const handleCloseOutputConfig = useCallback(() => setShowOutputConfig(false), []);
|
|
185
|
+
const handleChooseOutput = useCallback((tid_mids) => {
|
|
186
|
+
if (!fromDTD?.metadata)
|
|
187
|
+
return;
|
|
188
|
+
if (!tid_mids)
|
|
189
|
+
return;
|
|
190
|
+
// copia dei SelectItems senza i rimossi
|
|
191
|
+
let newSelect = qd?.select?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
|
|
192
|
+
// aggiungiamo i nuovi
|
|
193
|
+
for (const tm of tid_mids.filter(tm => !qd?.select?.some(item => item.mid == tm.mid))) {
|
|
194
|
+
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
195
|
+
let si = new SelectItem();
|
|
196
|
+
si.visibility = SelectItemVisibilities.Visible;
|
|
197
|
+
si.tid = SQD?.masterTID;
|
|
198
|
+
si.mid = md?.id;
|
|
199
|
+
let indexMD = 0;
|
|
200
|
+
for (const m of fromDTD?.metadata ?? []) {
|
|
201
|
+
if (m.id == si.mid)
|
|
202
|
+
break;
|
|
203
|
+
if (newSelect.findIndex(o => o.mid == m.id && o.tid == SQD?.masterTID) < 0)
|
|
204
|
+
continue;
|
|
205
|
+
indexMD++;
|
|
206
|
+
}
|
|
207
|
+
newSelect.splice(indexMD, 0, si);
|
|
208
|
+
}
|
|
209
|
+
setQd({ ...qd, select: newSelect });
|
|
210
|
+
}, [qd, fromDTD?.metadata, SQD?.masterTID]);
|
|
211
|
+
const handleCloseOrderByConfig = useCallback(() => setShowOrderByConfig(false), []);
|
|
212
|
+
const handleChooseOrderBy = useCallback((tid_mids) => {
|
|
213
|
+
if (!fromDTD?.metadata)
|
|
214
|
+
return;
|
|
215
|
+
if (!tid_mids)
|
|
216
|
+
return;
|
|
217
|
+
// copia dei OrderByItems senza i rimossi
|
|
218
|
+
let newOrderBy = qd?.orderBy?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
|
|
219
|
+
// aggiungiamo i nuovi
|
|
220
|
+
for (const tm of tid_mids.filter(tm => !qd?.orderBy?.some(item => item.mid == tm.mid))) {
|
|
221
|
+
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
222
|
+
let oi = new OrderByItem();
|
|
223
|
+
oi.tid = SQD?.masterTID;
|
|
224
|
+
oi.mid = md?.id;
|
|
225
|
+
oi.asc = true;
|
|
226
|
+
newOrderBy.push(oi);
|
|
227
|
+
}
|
|
228
|
+
setQd({ ...qd, orderBy: newOrderBy });
|
|
229
|
+
}, [qd, fromDTD?.metadata, SQD?.masterTID]);
|
|
230
|
+
return (_jsxs("div", { ref: panelRef, style: { height: '100%' }, children: [_jsxs(TMPanel, { title: fromDTD?.nameLoc ?? SDKUI_Localizator.Search_Metadata, allowMaximize: !isMobile, onMaximize: isMobile ? undefined : onMaximizePanel, onHeaderDoubleClick: isMobile ? undefined : onMaximizePanel, onBack: onBack, toolbar: _jsx(_Fragment, { children: (SQD && !showSqdForm) ?
|
|
153
231
|
_jsx(TMDropDownMenu, { backgroundColor: 'white', borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, { color: 'white' }), showTooltip: false }), items: [
|
|
154
232
|
...(showBackToResultButton ? [{ icon: _jsx(IconArrowRight, {}), text: "Vai a risultato", onClick: () => { onBackToResult?.(); } }] : []),
|
|
155
233
|
{ icon: _jsx(IconAddCircleOutline, {}), beginGroup: true, text: SDKUI_Localizator.SavedQueryNew, onClick: () => { openSqdForm(FormModes.Create); } },
|
|
@@ -161,87 +239,12 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
|
|
|
161
239
|
] })
|
|
162
240
|
: _jsx(_Fragment, {}) }), children: [_jsx(ConfirmQueryParamsDialog, {}), SQD
|
|
163
241
|
? _jsxs("div", { style: { height: '100%', width: '100%', position: 'relative', display: 'flex', flexDirection: 'column', gap: 5 }, children: [showAdvancedSearch
|
|
164
|
-
? _jsx(TMQueryEditor, { formMode: FormModes.Update, showToolbar: false, inputData: qd, validateSelect: true, showApply: false, onQDChanged:
|
|
165
|
-
|
|
166
|
-
: _jsx(TMSearchQueryEditor, { qd: qd, fromDTD: fromDTD, dcmtTypesList: dcmtTypesList, isOpenDistinctValuesPanel: showDistinctValuesPanel, isExpertMode: isExpertMode, showAllMdWhere: showAllMdWhere, onQdChanged: handleQdChanged, onFocusedMetadataChanged: setFocusedTidMid, onAdvancedMenuClick: (e) => {
|
|
167
|
-
if (e.button === AdvancedMenuButtons.DistinctValues) {
|
|
168
|
-
setShowDistinctValuesPanel(true);
|
|
169
|
-
}
|
|
170
|
-
} }), _jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '80px', padding: '15px', position: 'relative' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, width: 'auto', caption: SDKUI_Localizator.Search, advancedColor: '#4A96D2', onClick: handleSearchButtonClick }), _jsx(TMButton, { btnStyle: 'advanced', advancedType: 'primary', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), width: 'auto', advancedColor: 'white', color: 'primaryOutline', onClick: clearFilters })] }), (!showAdvancedSearch && qd?.where && qd?.where?.length > initialMaxItems) &&
|
|
242
|
+
? _jsx(TMQueryEditor, { formMode: FormModes.Update, showToolbar: false, inputData: qd, validateSelect: true, showApply: false, onQDChanged: handleQdChanged })
|
|
243
|
+
: _jsx(TMSearchQueryEditor, { qd: qd, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, showAllMdWhere: showAllMdWhere, onQdChanged: handleQdChanged, onFocusedMetadataChanged: setFocusedTidMid, onAdvancedMenuClick: handleAdvancedMenuClick }), _jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '80px', padding: '15px', position: 'relative' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, width: 'auto', caption: SDKUI_Localizator.Search, advancedColor: '#4A96D2', onClick: handleSearchButtonClick }), _jsx(TMButton, { btnStyle: 'advanced', advancedType: 'primary', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), width: 'auto', advancedColor: 'white', color: 'primaryOutline', onClick: clearFilters })] }), (!showAdvancedSearch && qd?.where && qd?.where?.length > initialMaxItems) &&
|
|
171
244
|
_jsx(TMShowAllOrMaxItemsButton, { showAll: showAllMdWhere, dataSourceLength: qd?.where?.length, onClick: () => { setShowAllMdWhere(!showAllMdWhere); } })] }), showFiltersConfig &&
|
|
172
|
-
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (!tid_mids)
|
|
176
|
-
return;
|
|
177
|
-
// copia dei whereItem senza i rimossi
|
|
178
|
-
let newWhere = qd?.where?.filter(wi => tid_mids?.some(tm => tm.mid == wi.mid)) ?? [];
|
|
179
|
-
// aggiungiamo i nuovi
|
|
180
|
-
for (const tm of tid_mids.filter(tm => !qd?.where?.some(wi => wi.mid == tm.mid))) {
|
|
181
|
-
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
182
|
-
let wi = new WhereItem();
|
|
183
|
-
wi.or = false;
|
|
184
|
-
wi.leftBrackets = "(";
|
|
185
|
-
wi.tid = SQD.masterTID;
|
|
186
|
-
wi.mid = tm.mid;
|
|
187
|
-
wi.operator = getDefaultOperator(md?.dataDomain, md?.dataType);
|
|
188
|
-
wi.rightBrackets = ")";
|
|
189
|
-
let indexMD = 0;
|
|
190
|
-
for (const m of fromDTD?.metadata ?? []) {
|
|
191
|
-
if (m.id == wi.mid)
|
|
192
|
-
break;
|
|
193
|
-
if (newWhere.findIndex(o => o.mid == m.id && o.tid == SQD.masterTID) < 0)
|
|
194
|
-
continue;
|
|
195
|
-
indexMD++;
|
|
196
|
-
}
|
|
197
|
-
newWhere.splice(indexMD, 0, wi);
|
|
198
|
-
}
|
|
199
|
-
setQd({ ...qd, where: newWhere });
|
|
200
|
-
} }), showOutputConfig &&
|
|
201
|
-
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.select?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: () => setShowOutputConfig(false), onChoose: (tid_mids) => {
|
|
202
|
-
if (!fromDTD?.metadata)
|
|
203
|
-
return;
|
|
204
|
-
if (!tid_mids)
|
|
205
|
-
return;
|
|
206
|
-
// copia dei SelectItems senza i rimossi
|
|
207
|
-
let newSelect = qd?.select?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
|
|
208
|
-
// aggiungiamo i nuovi
|
|
209
|
-
for (const tm of tid_mids.filter(tm => !qd?.select?.some(item => item.mid == tm.mid))) {
|
|
210
|
-
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
211
|
-
let si = new SelectItem();
|
|
212
|
-
si.visibility = SelectItemVisibilities.Visible;
|
|
213
|
-
si.tid = SQD.masterTID;
|
|
214
|
-
si.mid = md?.id;
|
|
215
|
-
let indexMD = 0;
|
|
216
|
-
for (const m of fromDTD?.metadata ?? []) {
|
|
217
|
-
if (m.id == si.mid)
|
|
218
|
-
break;
|
|
219
|
-
if (newSelect.findIndex(o => o.mid == m.id && o.tid == SQD.masterTID) < 0)
|
|
220
|
-
continue;
|
|
221
|
-
indexMD++;
|
|
222
|
-
}
|
|
223
|
-
newSelect.splice(indexMD, 0, si);
|
|
224
|
-
}
|
|
225
|
-
setQd({ ...qd, select: newSelect });
|
|
226
|
-
} }), showOrderByConfig &&
|
|
227
|
-
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.orderBy?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: () => setShowOrderByConfig(false), onChoose: (tid_mids) => {
|
|
228
|
-
if (!fromDTD?.metadata)
|
|
229
|
-
return;
|
|
230
|
-
if (!tid_mids)
|
|
231
|
-
return;
|
|
232
|
-
// copia dei OrderByItems senza i rimossi
|
|
233
|
-
let newOrderBy = qd?.orderBy?.filter(item => tid_mids?.some(tm => tm.mid == item.mid)) ?? [];
|
|
234
|
-
// aggiungiamo i nuovi
|
|
235
|
-
for (const tm of tid_mids.filter(tm => !qd?.orderBy?.some(item => item.mid == tm.mid))) {
|
|
236
|
-
let md = fromDTD?.metadata.find(o => o.id == tm.mid);
|
|
237
|
-
let oi = new OrderByItem();
|
|
238
|
-
oi.tid = SQD.masterTID;
|
|
239
|
-
oi.mid = md?.id;
|
|
240
|
-
oi.asc = true;
|
|
241
|
-
newOrderBy.push(oi);
|
|
242
|
-
}
|
|
243
|
-
setQd({ ...qd, orderBy: newOrderBy });
|
|
244
|
-
} })] })
|
|
245
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose: handleCloseFiltersConfig, onChoose: handleChooseFilters }), showOutputConfig &&
|
|
246
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.select?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOutputConfig, onChoose: handleChooseOutput }), showOrderByConfig &&
|
|
247
|
+
_jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.orderBy?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOrderByConfig, onChoose: handleChooseOrderBy })] })
|
|
245
248
|
:
|
|
246
249
|
_jsxs(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: [_jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsxs(StyledToppyTextContainer, { children: [" ", _jsxs(StyledToppyText, { children: [" ", SDKUI_Localizator.DcmtTypeSelectOrQuickSearch, " "] }), " "] }), " "] }), _jsxs(TMLayoutItem, { width: 'max-content', height: 'max-content', children: [" ", _jsx("img", { src: Logo, width: 120, alt: '' }), " "] })] }), showSqdForm &&
|
|
247
250
|
_jsx(StyledModalContainer, { style: { backgroundColor: `${TMColors.backgroundColorHeader}12` }, children: _jsx(TMSavedQueryForm, { height: '50%', width: '50%', id: formModeSqdForm === FormModes.Create ? -1 : SQD?.id, title: 'Ricerca rapida', formMode: formModeSqdForm, showBackButton: true, qd: qd, isAdvancedSearch: showAdvancedSearch, isModal: false, onClose: () => { setShowSqdForm(false); }, onSaved: onSqdSaved }) })] }), showDistinctValuesPanel &&
|