@topconsultnpm/sdkui-react-beta 6.12.42 → 6.12.43
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/grids/TMRecentsManager.d.ts +11 -0
- package/lib/components/grids/TMRecentsManager.js +45 -0
- package/lib/components/query/TMMasterDetailDcmts.d.ts +2 -6
- package/lib/components/search/TMSavedQueryForm.d.ts +9 -0
- package/lib/components/search/TMSavedQueryForm.js +41 -0
- package/lib/components/search/TMSavedQuerySelector.d.ts +16 -0
- package/lib/components/search/TMSavedQuerySelector.js +143 -0
- package/lib/components/search/TMSearch.d.ts +10 -0
- package/lib/components/search/TMSearch.js +188 -0
- package/lib/components/search/TMSearchQueryEditor.d.ts +15 -0
- package/lib/components/search/TMSearchQueryEditor.js +365 -0
- package/lib/components/search/TMSearchQueryPanel.d.ts +20 -0
- package/lib/components/search/TMSearchQueryPanel.js +296 -0
- package/lib/components/search/TMSearchResult.d.ts +2 -6
- package/lib/components/search/TMSearchResult.js +1 -1
- package/lib/components/search/TMTreeSelector.d.ts +9 -0
- package/lib/components/search/TMTreeSelector.js +125 -0
- package/lib/helper/Enum_Localizator.d.ts +2 -1
- package/lib/helper/Enum_Localizator.js +9 -1
- package/lib/helper/SDKUI_Localizator.d.ts +9 -0
- package/lib/helper/SDKUI_Localizator.js +90 -0
- package/lib/ts/types.d.ts +11 -0
- package/package.json +2 -2
@@ -0,0 +1,365 @@
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import React, { useEffect, useState } from 'react';
|
3
|
+
import { LayoutModes, DcmtTypeListCacheService, PlatformObjectValidator, MetadataDataTypes, QueryOperators, DataListCacheService, MetadataDataDomains, SDK_Localizator, UserListCacheService } from '@topconsultnpm/sdk-ts-beta';
|
4
|
+
import styled from 'styled-components';
|
5
|
+
import { LocalizeQueryOperators, getDefaultOperator, SDKUI_Localizator, IconUndo, IconPencil, IconDataList, IconFunction, IconMenuVertical, IconClearButton, displayMetadataValue } from '../../helper';
|
6
|
+
import { TMColors } from '../../utils/theme';
|
7
|
+
import { StyledDivHorizontal } from '../base/Styled';
|
8
|
+
import TMButton from '../base/TMButton';
|
9
|
+
import { useDeviceType, DeviceType } from '../base/TMDeviceProvider';
|
10
|
+
import TMDropDownMenu from '../base/TMDropDownMenu';
|
11
|
+
import TMSpinner from '../base/TMSpinner';
|
12
|
+
import { FormulaHelper } from '../editors/TMFormulaEditor';
|
13
|
+
import TMMetadataEditor, { useMetadataEditableList } from '../editors/TMMetadataEditor';
|
14
|
+
import { colorOperator, StyledItemWrapper, StyledRowItem } from '../query/TMQueryEditor';
|
15
|
+
import { TMMidViewer } from '../viewers/TMMidViewer';
|
16
|
+
const StyledMetadataListItem = styled.div `
|
17
|
+
padding: 5px;
|
18
|
+
border-radius: 8px;
|
19
|
+
height: max-content;
|
20
|
+
width: 100%;
|
21
|
+
/* box-shadow: 1px 1px 7px rgba(0,0,0,0.15); */
|
22
|
+
/* font-size: ${(props) => props.$isSelected ? '1.2rem' : '1rem'}; */
|
23
|
+
background: ${(props) => props.$isSelected ? props.$selectedColor : props.$backgroundColor};
|
24
|
+
|
25
|
+
&:hover {
|
26
|
+
background: ${(props) => props.$isSelected ? props.$selectedColor : props.$hoverColor};
|
27
|
+
cursor: pointer;
|
28
|
+
}
|
29
|
+
`;
|
30
|
+
const TMSearchQueryEditor = ({ qd, fromDTD, dcmtTypesList = [], isOpenDistinctValuesPanel, showAdvancedMenu, showAllMdWhere, onQdChanged, onFocusedMetadataChanged }) => {
|
31
|
+
const [dynDataListsToBeRefreshed, setDynDataListsToBeRefreshed] = useState([]);
|
32
|
+
const [showDistinctValuesPanel, setShowDistinctValuesPanel] = useState(false);
|
33
|
+
const [currentEditingMID, setCurrentEditingMID] = useState(0);
|
34
|
+
const [isEditableList, addOrRemoveEditableList] = useMetadataEditableList();
|
35
|
+
const [focusedTidMid, setFocusedTidMid] = useState();
|
36
|
+
const deviceType = useDeviceType();
|
37
|
+
let initialMaxItems = deviceType === DeviceType.MOBILE ? 8 : 12;
|
38
|
+
useEffect(() => { setShowDistinctValuesPanel(isOpenDistinctValuesPanel); }, [isOpenDistinctValuesPanel]);
|
39
|
+
useEffect(() => {
|
40
|
+
onFocusedMetadataChanged?.(focusedTidMid);
|
41
|
+
}, [focusedTidMid]);
|
42
|
+
const handleMetadataSelection = (tid, mid) => {
|
43
|
+
if (currentEditingMID !== mid)
|
44
|
+
setCurrentEditingMID(mid);
|
45
|
+
if (mid !== focusedTidMid?.mid)
|
46
|
+
setFocusedTidMid({ tid: tid, mid: mid });
|
47
|
+
};
|
48
|
+
const handleWhereItemChanged = (wi) => {
|
49
|
+
if (!wi)
|
50
|
+
return;
|
51
|
+
const whereCopy = qd?.where?.map((curItem) => {
|
52
|
+
if (curItem.mid != wi.mid)
|
53
|
+
return curItem;
|
54
|
+
return wi;
|
55
|
+
});
|
56
|
+
onQdChanged?.({ ...qd, where: whereCopy });
|
57
|
+
};
|
58
|
+
const getQueryOperatorsMenuItems = (wi, index) => {
|
59
|
+
const onChange_WhereItem_QueryOperator = (qo, index) => {
|
60
|
+
handleWhereItemChanged({ ...wi, operator: qo, value1: undefined, value2: undefined });
|
61
|
+
};
|
62
|
+
let items = [];
|
63
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Equal), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Equal, index) });
|
64
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEqual, index) });
|
65
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNull, index) });
|
66
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNotNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNotNull, index) });
|
67
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.In), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.In, index) });
|
68
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotIn), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotIn, index) });
|
69
|
+
let md = fromDTD?.metadata?.find(o => o.id == wi.mid);
|
70
|
+
let mdDataType = md?.dataType;
|
71
|
+
if (mdDataType != MetadataDataTypes.Varchar) {
|
72
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Greater), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Greater, index) });
|
73
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.GreaterOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.GreaterOrEqual, index) });
|
74
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Less), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Less, index) });
|
75
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.LessOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LessOrEqual, index) });
|
76
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenExclusive, index) });
|
77
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenInclusive, index) });
|
78
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideExclusive, index) });
|
79
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideInclusive, index) });
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Contain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Contain, index) });
|
83
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotContain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotContain, index) });
|
84
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BeginWith, index) });
|
85
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotBeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotBeginWith, index) });
|
86
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.EndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.EndWith, index) });
|
87
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEndWith, index) });
|
88
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Like), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Like, index) });
|
89
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotLike), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotLike, index) });
|
90
|
+
}
|
91
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Custom), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Custom, index) });
|
92
|
+
if (mdDataType == MetadataDataTypes.DateTime) {
|
93
|
+
items.push({
|
94
|
+
text: "Operatori speciali", items: [
|
95
|
+
{ text: LocalizeQueryOperators(QueryOperators.Yesterday), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Yesterday, index) },
|
96
|
+
{ text: LocalizeQueryOperators(QueryOperators.Today), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Today, index) },
|
97
|
+
{ text: LocalizeQueryOperators(QueryOperators.Tomorrow), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Tomorrow, index) },
|
98
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousWeek, index) },
|
99
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisWeek, index) },
|
100
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextWeek, index) },
|
101
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousMonth, index) },
|
102
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisMonth, index) },
|
103
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextMonth, index) },
|
104
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousYear, index) },
|
105
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisYear, index) },
|
106
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextYear, index) },
|
107
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXHours, index) },
|
108
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXHours, index) },
|
109
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXDays, index) },
|
110
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXDays, index) },
|
111
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXWeeks, index) },
|
112
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXWeeks, index) },
|
113
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXMonths, index) },
|
114
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXMonths, index) },
|
115
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXYears, index) },
|
116
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXYears, index) }
|
117
|
+
]
|
118
|
+
});
|
119
|
+
}
|
120
|
+
return items;
|
121
|
+
};
|
122
|
+
const getOperatorColor = (whereItem) => {
|
123
|
+
if (dcmtTypesList.length <= 0)
|
124
|
+
return 'green';
|
125
|
+
let dtd = dcmtTypesList.find(o => o.id === whereItem.tid);
|
126
|
+
let md = dtd?.metadata?.find(o => o.id === whereItem.mid);
|
127
|
+
return whereItem.operator === getDefaultOperator(md?.dataDomain, md?.dataType) ? 'green' : TMColors.tertiary;
|
128
|
+
};
|
129
|
+
const getAdvancedMenuItems = (tid, mid) => {
|
130
|
+
let isEditable = isEditableList(mid);
|
131
|
+
let dtd = dcmtTypesList.find(o => o.id == tid);
|
132
|
+
if (!dtd)
|
133
|
+
return [];
|
134
|
+
let md = dtd.metadata?.find(o => o.id == mid);
|
135
|
+
if (!md)
|
136
|
+
return [];
|
137
|
+
let menu = [
|
138
|
+
{ text: isEditable ? SDKUI_Localizator.Restore : SDKUI_Localizator.MakeEditable, icon: isEditable ? _jsx(IconUndo, {}) : _jsx(IconPencil, {}), onClick: () => { addOrRemoveEditableList(mid); } },
|
139
|
+
{ text: SDKUI_Localizator.DistinctValues, icon: _jsx(IconDataList, {}), onClick: () => { handleMetadataSelection(tid, mid); setShowDistinctValuesPanel(!showDistinctValuesPanel); } }
|
140
|
+
];
|
141
|
+
return menu;
|
142
|
+
};
|
143
|
+
return (_jsx(_Fragment, { children: deviceType === DeviceType.MOBILE ?
|
144
|
+
_jsx("div", { style: { overflow: 'auto', display: 'flex', flexDirection: 'column', height: '100%', padding: '5px', gap: '5px' }, children: qd?.where?.slice(0, showAllMdWhere ? qd?.where.length : initialMaxItems).map((wi, index) => (_jsx(StyledMetadataListItem, { id: `wi-item-${wi.mid}`, onClick: () => { handleMetadataSelection(wi.tid, wi.mid); }, onFocus: () => { handleMetadataSelection(wi.tid, wi.mid); }, "$backgroundColor": !PlatformObjectValidator.WhereItemHasValues(wi) ? `${TMColors.primary}66` : 'rgba(236, 202, 156, 1)', "$hoverColor": !PlatformObjectValidator.WhereItemHasValues(wi) ? `${TMColors.primary}33` : 'rgba(236, 202, 156, .5)', children: _jsx(TMSearchWhereItemCard, { isSelected: showDistinctValuesPanel && wi.mid === focusedTidMid?.mid, index: index, whereItem: wi, showEditor: currentEditingMID == wi.mid, isEditableList: isEditableList(wi.mid), queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid == wi.mid)?.queryParams ?? [], onCascadeRefreshDynDataLists: (ddlToBeRefreshed) => {
|
145
|
+
let newDynDataListsToBeRefreshed = [];
|
146
|
+
for (const item of dynDataListsToBeRefreshed) {
|
147
|
+
let index = ddlToBeRefreshed.findIndex(o => o.mid == item.mid || (o.mid == -1 && o.midStarter == item.midStarter));
|
148
|
+
if (index >= 0)
|
149
|
+
continue;
|
150
|
+
newDynDataListsToBeRefreshed.push(item);
|
151
|
+
}
|
152
|
+
for (const item of ddlToBeRefreshed) {
|
153
|
+
if (item.queryParams.length <= 0)
|
154
|
+
continue;
|
155
|
+
if (!item.mid)
|
156
|
+
continue;
|
157
|
+
if (item.mid <= 0)
|
158
|
+
continue;
|
159
|
+
newDynDataListsToBeRefreshed.push(item);
|
160
|
+
}
|
161
|
+
setDynDataListsToBeRefreshed(newDynDataListsToBeRefreshed);
|
162
|
+
}, onCascadeUpdateMIDs: (midsToBeUpdated) => {
|
163
|
+
for (const item of midsToBeUpdated) {
|
164
|
+
const whereItem = qd?.where?.find(o => o.mid === item.mid);
|
165
|
+
if (whereItem) {
|
166
|
+
whereItem.value1 = item.value;
|
167
|
+
handleWhereItemChanged(whereItem);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}, onWhereItemChange: (newWi) => { handleWhereItemChanged(newWi); }, onHideEditor: () => { setCurrentEditingMID(0); } }) }, `${wi.tid}_${wi.mid}_${index}`))) })
|
171
|
+
:
|
172
|
+
_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: qd?.where?.slice(0, showAllMdWhere ? qd?.where.length : initialMaxItems).map((whereItem, index) => {
|
173
|
+
return (_jsxs(React.Fragment, { children: [_jsx("div", { id: `wi-item-${whereItem.mid}`, style: { gridColumn: 1 }, children: _jsx(TMMidViewer, { 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) => {
|
174
|
+
handleWhereItemChanged({ ...whereItem, value1: values[0], value2: values[1] });
|
175
|
+
}, onCascadeRefreshDynDataLists: (ddlToBeRefreshed) => {
|
176
|
+
let newDynDataListsToBeRefreshed = [];
|
177
|
+
for (const item of dynDataListsToBeRefreshed) {
|
178
|
+
let index = ddlToBeRefreshed.findIndex(o => o.mid == item.mid || (o.mid == -1 && o.midStarter == item.midStarter));
|
179
|
+
if (index >= 0)
|
180
|
+
continue;
|
181
|
+
newDynDataListsToBeRefreshed.push(item);
|
182
|
+
}
|
183
|
+
for (const item of ddlToBeRefreshed) {
|
184
|
+
if (item.queryParams.length <= 0)
|
185
|
+
continue;
|
186
|
+
if (!item.mid)
|
187
|
+
continue;
|
188
|
+
if (item.mid <= 0)
|
189
|
+
continue;
|
190
|
+
newDynDataListsToBeRefreshed.push(item);
|
191
|
+
}
|
192
|
+
setDynDataListsToBeRefreshed(newDynDataListsToBeRefreshed);
|
193
|
+
}, onCascadeUpdateMIDs: (midsToBeUpdated) => {
|
194
|
+
for (const item of midsToBeUpdated) {
|
195
|
+
const whereItem = qd?.where?.find(o => o.mid === item.mid);
|
196
|
+
if (whereItem) {
|
197
|
+
whereItem.value1 = item.value;
|
198
|
+
handleWhereItemChanged(whereItem);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
} }), FormulaHelper.isFormula(whereItem.value1)
|
202
|
+
? _jsx(IconFunction, { color: "#1a89d3", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
203
|
+
: (isEditableList(whereItem.mid))
|
204
|
+
? _jsx(IconPencil, { color: "#138603", fontSize: 14, style: { position: "absolute", top: '-5px', left: '-10px' } })
|
205
|
+
: _jsx(_Fragment, {})] }), showAdvancedMenu && _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}`));
|
206
|
+
}) }) }));
|
207
|
+
};
|
208
|
+
export default TMSearchQueryEditor;
|
209
|
+
const TMSearchWhereItemEditor = ({ whereItem, queryParamsDynDataList, index, isSelected, isEditableList, autoFocus, openChooserBySingleClick, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
210
|
+
const [showValue1, setShowValue1] = useState(true);
|
211
|
+
const [showValue2, setShowValue2] = useState(false);
|
212
|
+
const [dataList, setDataList] = useState();
|
213
|
+
const [users, setUsers] = useState();
|
214
|
+
useEffect(() => {
|
215
|
+
let operands = PlatformObjectValidator.GetNumberOfOperands(whereItem.operator);
|
216
|
+
switch (operands) {
|
217
|
+
case 0:
|
218
|
+
setShowValue1(false);
|
219
|
+
setShowValue2(false);
|
220
|
+
break;
|
221
|
+
case 2:
|
222
|
+
setShowValue1(true);
|
223
|
+
setShowValue2(true);
|
224
|
+
break;
|
225
|
+
default:
|
226
|
+
setShowValue1(true);
|
227
|
+
setShowValue2(false);
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
getMetadata().then((mdOut) => {
|
231
|
+
switch (mdOut?.dataDomain) {
|
232
|
+
case MetadataDataDomains.DataList:
|
233
|
+
if (dataList != undefined)
|
234
|
+
return;
|
235
|
+
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.DataList} ...` });
|
236
|
+
mdOut.dataListID && DataListCacheService.GetAsync(mdOut.dataListID).then((dataList) => {
|
237
|
+
TMSpinner.hide();
|
238
|
+
setDataList(dataList);
|
239
|
+
});
|
240
|
+
break;
|
241
|
+
case MetadataDataDomains.UserID:
|
242
|
+
if (users !== undefined)
|
243
|
+
return;
|
244
|
+
TMSpinner.show({ description: `${SDKUI_Localizator.Loading} - ${SDK_Localizator.Users} ...` });
|
245
|
+
UserListCacheService.GetAllAsync().then((resultUsers) => {
|
246
|
+
TMSpinner.hide();
|
247
|
+
setUsers(resultUsers ?? []);
|
248
|
+
});
|
249
|
+
break;
|
250
|
+
default: break;
|
251
|
+
}
|
252
|
+
});
|
253
|
+
}, [whereItem]);
|
254
|
+
const getMetadata = async () => {
|
255
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(whereItem.tid, true);
|
256
|
+
return dtd?.metadata?.find(o => o.id === whereItem.mid);
|
257
|
+
};
|
258
|
+
const normalizeValue = (value, isForValue1 = true) => {
|
259
|
+
let newValues = [];
|
260
|
+
let newValue = value;
|
261
|
+
if (isForValue1) {
|
262
|
+
newValues.push(newValue);
|
263
|
+
newValues.push(whereItem.value2);
|
264
|
+
}
|
265
|
+
else {
|
266
|
+
newValues.push(whereItem.value1);
|
267
|
+
newValues.push(newValue);
|
268
|
+
}
|
269
|
+
onValueChanged?.(newValues);
|
270
|
+
};
|
271
|
+
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); } })] }));
|
272
|
+
};
|
273
|
+
const TMSearchWhereItemCard = ({ index, whereItem, isSelected, queryParamsDynDataList, showEditor, showCompleteMetadataName, showId, isEditableList, onWhereItemChange, onHideEditor, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
|
274
|
+
const [isOpen, setIsOpen] = useState(false);
|
275
|
+
const [md, setMd] = useState();
|
276
|
+
useEffect(() => { getMetadata().then((mdOut) => { setMd(mdOut); }); }, [whereItem]);
|
277
|
+
useEffect(() => { setIsOpen(showEditor); }, [showEditor]);
|
278
|
+
const onChange_WhereItem_QueryOperator = (qo, index) => {
|
279
|
+
onWhereItemChange?.({ ...whereItem, operator: qo, value1: undefined, value2: undefined });
|
280
|
+
};
|
281
|
+
const getMetadata = async () => {
|
282
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(whereItem.tid, true);
|
283
|
+
return dtd?.metadata?.find(o => o.id === whereItem.mid);
|
284
|
+
};
|
285
|
+
const getQueryOperatorsMenuItems = (wi, index) => {
|
286
|
+
let items = [];
|
287
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Equal), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Equal, index) });
|
288
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEqual, index) });
|
289
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNull, index) });
|
290
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.IsNotNull), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.IsNotNull, index) });
|
291
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.In), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.In, index) });
|
292
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotIn), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotIn, index) });
|
293
|
+
let mdDataType = md?.dataType;
|
294
|
+
if (mdDataType != MetadataDataTypes.Varchar) {
|
295
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Greater), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Greater, index) });
|
296
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.GreaterOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.GreaterOrEqual, index) });
|
297
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Less), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Less, index) });
|
298
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.LessOrEqual), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LessOrEqual, index) });
|
299
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenExclusive, index) });
|
300
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BetweenInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BetweenInclusive, index) });
|
301
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideExclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideExclusive, index) });
|
302
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.OutsideInclusive), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.OutsideInclusive, index) });
|
303
|
+
}
|
304
|
+
else {
|
305
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Contain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Contain, index) });
|
306
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotContain), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotContain, index) });
|
307
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.BeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.BeginWith, index) });
|
308
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotBeginWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotBeginWith, index) });
|
309
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.EndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.EndWith, index) });
|
310
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotEndWith), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotEndWith, index) });
|
311
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Like), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Like, index) });
|
312
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.NotLike), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NotLike, index) });
|
313
|
+
}
|
314
|
+
items.push({ text: LocalizeQueryOperators(QueryOperators.Custom), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Custom, index) });
|
315
|
+
if (mdDataType == MetadataDataTypes.DateTime) {
|
316
|
+
items.push({
|
317
|
+
text: SDKUI_Localizator.SpecialOperators, items: [
|
318
|
+
{ text: LocalizeQueryOperators(QueryOperators.Yesterday), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Yesterday, index) },
|
319
|
+
{ text: LocalizeQueryOperators(QueryOperators.Today), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Today, index) },
|
320
|
+
{ text: LocalizeQueryOperators(QueryOperators.Tomorrow), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.Tomorrow, index) },
|
321
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousWeek, index) },
|
322
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisWeek, index) },
|
323
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextWeek), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextWeek, index) },
|
324
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousMonth, index) },
|
325
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisMonth, index) },
|
326
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextMonth), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextMonth, index) },
|
327
|
+
{ text: LocalizeQueryOperators(QueryOperators.PreviousYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.PreviousYear, index) },
|
328
|
+
{ text: LocalizeQueryOperators(QueryOperators.ThisYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.ThisYear, index) },
|
329
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextYear), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextYear, index) },
|
330
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXHours, index) },
|
331
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXHours), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXHours, index) },
|
332
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXDays, index) },
|
333
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXDays), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXDays, index) },
|
334
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXWeeks, index) },
|
335
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXWeeks), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXWeeks, index) },
|
336
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXMonths, index) },
|
337
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXMonths), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXMonths, index) },
|
338
|
+
{ text: LocalizeQueryOperators(QueryOperators.LastXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.LastXYears, index) },
|
339
|
+
{ text: LocalizeQueryOperators(QueryOperators.NextXYears), onClick: () => onChange_WhereItem_QueryOperator(QueryOperators.NextXYears, index) }
|
340
|
+
]
|
341
|
+
});
|
342
|
+
}
|
343
|
+
return items;
|
344
|
+
};
|
345
|
+
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 &&
|
346
|
+
_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 })] }) })] }));
|
347
|
+
};
|
348
|
+
const TMSearchWhereItemViewer = ({ isSelected = false, whereItem, showCompleteMetadataName, showId, showValue }) => {
|
349
|
+
const [numberOfOperands, setNumberOfOperands] = useState(0);
|
350
|
+
const [md, setMd] = useState();
|
351
|
+
useEffect(() => {
|
352
|
+
let operands = PlatformObjectValidator.GetNumberOfOperands(whereItem?.operator);
|
353
|
+
setNumberOfOperands(operands);
|
354
|
+
getMetadata().then((mdOut) => { setMd(mdOut); });
|
355
|
+
}, [whereItem]);
|
356
|
+
const getMetadata = async () => {
|
357
|
+
let dtd = await DcmtTypeListCacheService.GetAsync(whereItem?.tid, true);
|
358
|
+
return dtd?.metadata?.find(o => o.id === whereItem?.mid);
|
359
|
+
};
|
360
|
+
return (_jsxs("div", { style: { width: "100%", gap: 5, fontSize: '1rem', userSelect: 'none', display: 'flex', flexDirection: 'row' }, children: [_jsx(TMMidViewer, { isMetadataSelected: isSelected, showIcon: true, showCompleteName: showCompleteMetadataName, showId: showId, tid_mid: { tid: whereItem?.tid, mid: whereItem?.mid, aliasTID: whereItem?.alias } }), whereItem && showValue && PlatformObjectValidator.WhereItemHasValues(whereItem) && _jsx(StyledItemWrapper, { style: { padding: 0, color: 'green' }, children: LocalizeQueryOperators(whereItem.operator) }), whereItem && showValue && PlatformObjectValidator.WhereItemHasValues(whereItem) &&
|
361
|
+
_jsx(StyledItemWrapper, { style: { padding: 0, fontWeight: 900 }, children: numberOfOperands == 11 || numberOfOperands == 12 || numberOfOperands == 99
|
362
|
+
? _jsx(_Fragment, { children: whereItem.value1 })
|
363
|
+
// ? <>{numberOfOperands == 11 ? whereItem.value1?.split(',').map((item: string) => !item.startsWith("'") ? item : item.slice(1, -1)).join(",") : whereItem.value1}</>
|
364
|
+
: _jsxs(_Fragment, { children: [displayMetadataValue(md, whereItem.value1, ""), numberOfOperands == 2 && (whereItem.value2 && whereItem.value2 != '' ? ` - ${displayMetadataValue(md, whereItem.value2, "")}` : ' - ?')] }) })] }));
|
365
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DcmtTypeDescriptor, QueryDescriptor, SavedQueryDescriptor, SearchResultDescriptor } from '@topconsultnpm/sdk-ts-beta';
|
3
|
+
import { TID_MID } from '../../ts';
|
4
|
+
import { ITMRightSidebarItem } from '../base/TMRightSidebar';
|
5
|
+
interface ITMSearchQueryPanelProps {
|
6
|
+
fromDTD?: DcmtTypeDescriptor;
|
7
|
+
SQD?: SavedQueryDescriptor;
|
8
|
+
isOpenDistinctValuesPanel?: boolean;
|
9
|
+
rightSidebarItems?: ITMRightSidebarItem[];
|
10
|
+
onRightSidebarItemClick?: (item: string) => void;
|
11
|
+
onSqdSaved?: (newSqd: SavedQueryDescriptor) => void;
|
12
|
+
onFocusedMetadataChanged?: (tid_mid: TID_MID | undefined) => void;
|
13
|
+
onCloseDistinctValuesPanel?: () => void;
|
14
|
+
onSearchCompleted?: (searchResult: SearchResultDescriptor[], qd: QueryDescriptor | undefined) => void;
|
15
|
+
}
|
16
|
+
declare const TMSearchQueryPanel: React.FunctionComponent<ITMSearchQueryPanelProps>;
|
17
|
+
export default TMSearchQueryPanel;
|
18
|
+
export declare const refreshLastSearch: (qd: QueryDescriptor | undefined) => Promise<SearchResultDescriptor[] | undefined>;
|
19
|
+
export declare const StyledToppyTextContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
20
|
+
export declare const StyledToppyText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
|