@sapui5/sap.fe.controls 1.130.0
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/LICENSE.txt +38 -0
- package/README.md +15 -0
- package/package.json +12 -0
- package/src/sap/fe/controls/.library +47 -0
- package/src/sap/fe/controls/easyFilter/AINotice.js +57 -0
- package/src/sap/fe/controls/easyFilter/AINotice.tsx +71 -0
- package/src/sap/fe/controls/easyFilter/EasyFilterBarContainer.js +594 -0
- package/src/sap/fe/controls/easyFilter/EasyFilterBarContainer.tsx +588 -0
- package/src/sap/fe/controls/easyFilter/EasyFilterInput.js +425 -0
- package/src/sap/fe/controls/easyFilter/EasyFilterInput.tsx +455 -0
- package/src/sap/fe/controls/easyFilter/ShellHistoryProvider.js +217 -0
- package/src/sap/fe/controls/easyFilter/ShellHistoryProvider.tsx +266 -0
- package/src/sap/fe/controls/easyFilter/Token.js +437 -0
- package/src/sap/fe/controls/easyFilter/Token.tsx +437 -0
- package/src/sap/fe/controls/easyFilter/innerControls/BaseFactory.js +39 -0
- package/src/sap/fe/controls/easyFilter/innerControls/BaseFactory.ts +46 -0
- package/src/sap/fe/controls/easyFilter/innerControls/CalendarFactory.js +68 -0
- package/src/sap/fe/controls/easyFilter/innerControls/CalendarFactory.ts +67 -0
- package/src/sap/fe/controls/easyFilter/innerControls/MenuWithCheckBoxFactory.js +152 -0
- package/src/sap/fe/controls/easyFilter/innerControls/MenuWithCheckBoxFactory.ts +157 -0
- package/src/sap/fe/controls/easyFilter/innerControls/TimeFactory.js +68 -0
- package/src/sap/fe/controls/easyFilter/innerControls/TimeFactory.ts +67 -0
- package/src/sap/fe/controls/easyFilter/innerControls/ValueHelpPreviewFactory.js +135 -0
- package/src/sap/fe/controls/easyFilter/innerControls/ValueHelpPreviewFactory.ts +142 -0
- package/src/sap/fe/controls/easyFilter/utils.js +134 -0
- package/src/sap/fe/controls/easyFilter/utils.ts +154 -0
- package/src/sap/fe/controls/library.js +30 -0
- package/src/sap/fe/controls/library.ts +25 -0
- package/src/sap/fe/controls/messagebundle.properties +57 -0
- package/src/sap/fe/controls/messagebundle_ar.properties +11 -0
- package/src/sap/fe/controls/messagebundle_bg.properties +11 -0
- package/src/sap/fe/controls/messagebundle_ca.properties +11 -0
- package/src/sap/fe/controls/messagebundle_cnr.properties +11 -0
- package/src/sap/fe/controls/messagebundle_cs.properties +11 -0
- package/src/sap/fe/controls/messagebundle_cy.properties +11 -0
- package/src/sap/fe/controls/messagebundle_da.properties +11 -0
- package/src/sap/fe/controls/messagebundle_de.properties +11 -0
- package/src/sap/fe/controls/messagebundle_el.properties +11 -0
- package/src/sap/fe/controls/messagebundle_en.properties +11 -0
- package/src/sap/fe/controls/messagebundle_en_GB.properties +11 -0
- package/src/sap/fe/controls/messagebundle_en_US_saprigi.properties +11 -0
- package/src/sap/fe/controls/messagebundle_es.properties +11 -0
- package/src/sap/fe/controls/messagebundle_es_MX.properties +11 -0
- package/src/sap/fe/controls/messagebundle_et.properties +11 -0
- package/src/sap/fe/controls/messagebundle_fi.properties +11 -0
- package/src/sap/fe/controls/messagebundle_fr.properties +11 -0
- package/src/sap/fe/controls/messagebundle_fr_CA.properties +11 -0
- package/src/sap/fe/controls/messagebundle_hi.properties +11 -0
- package/src/sap/fe/controls/messagebundle_hr.properties +11 -0
- package/src/sap/fe/controls/messagebundle_hu.properties +11 -0
- package/src/sap/fe/controls/messagebundle_id.properties +11 -0
- package/src/sap/fe/controls/messagebundle_it.properties +11 -0
- package/src/sap/fe/controls/messagebundle_iw.properties +11 -0
- package/src/sap/fe/controls/messagebundle_ja.properties +11 -0
- package/src/sap/fe/controls/messagebundle_kk.properties +11 -0
- package/src/sap/fe/controls/messagebundle_ko.properties +11 -0
- package/src/sap/fe/controls/messagebundle_lt.properties +11 -0
- package/src/sap/fe/controls/messagebundle_lv.properties +11 -0
- package/src/sap/fe/controls/messagebundle_mk.properties +11 -0
- package/src/sap/fe/controls/messagebundle_ms.properties +11 -0
- package/src/sap/fe/controls/messagebundle_nl.properties +11 -0
- package/src/sap/fe/controls/messagebundle_no.properties +11 -0
- package/src/sap/fe/controls/messagebundle_pl.properties +11 -0
- package/src/sap/fe/controls/messagebundle_pt.properties +11 -0
- package/src/sap/fe/controls/messagebundle_pt_PT.properties +11 -0
- package/src/sap/fe/controls/messagebundle_ro.properties +11 -0
- package/src/sap/fe/controls/messagebundle_ru.properties +11 -0
- package/src/sap/fe/controls/messagebundle_sh.properties +11 -0
- package/src/sap/fe/controls/messagebundle_sk.properties +11 -0
- package/src/sap/fe/controls/messagebundle_sl.properties +11 -0
- package/src/sap/fe/controls/messagebundle_sr.properties +11 -0
- package/src/sap/fe/controls/messagebundle_sv.properties +11 -0
- package/src/sap/fe/controls/messagebundle_th.properties +11 -0
- package/src/sap/fe/controls/messagebundle_tr.properties +11 -0
- package/src/sap/fe/controls/messagebundle_uk.properties +11 -0
- package/src/sap/fe/controls/messagebundle_vi.properties +11 -0
- package/src/sap/fe/controls/messagebundle_zh_CN.properties +11 -0
- package/src/sap/fe/controls/messagebundle_zh_TW.properties +11 -0
- package/src/sap/fe/controls/themes/base/EasyFilter.less +85 -0
- package/src/sap/fe/controls/themes/base/Token.less +50 -0
- package/src/sap/fe/controls/themes/base/library.source.less +4 -0
- package/src/sap/fe/controls/themes/sap_belize/library.source.less +11 -0
- package/src/sap/fe/controls/themes/sap_belize_base/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_belize_hcb/library.source.less +11 -0
- package/src/sap/fe/controls/themes/sap_belize_hcw/library.source.less +11 -0
- package/src/sap/fe/controls/themes/sap_belize_plus/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_fiori_3/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_fiori_3_dark/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_fiori_3_hcb/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_fiori_3_hcw/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_horizon/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_horizon_dark/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_horizon_hcb/library.source.less +3 -0
- package/src/sap/fe/controls/themes/sap_horizon_hcw/library.source.less +3 -0
- package/ui5.yaml +17 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import Log from "sap/base/Log";
|
|
2
|
+
import type ResourceBundle from "sap/base/i18n/ResourceBundle";
|
|
3
|
+
import type { PathInModelExpression } from "sap/fe/base/BindingToolkit";
|
|
4
|
+
import { and, bindState, greaterThan, ifElse, length, lessThan } from "sap/fe/base/BindingToolkit";
|
|
5
|
+
import { aggregation, defineState, defineUI5Class, event, property, type PropertiesOf, type StateOf } from "sap/fe/base/ClassSupport";
|
|
6
|
+
import EventDelegateHook from "sap/fe/base/EventDelegateHook";
|
|
7
|
+
import jsx from "sap/fe/base/jsx-runtime/jsx";
|
|
8
|
+
import ShellHistoryProvider from "sap/fe/controls/easyFilter/ShellHistoryProvider";
|
|
9
|
+
import type { Button$PressEvent } from "sap/m/Button";
|
|
10
|
+
import Button from "sap/m/Button";
|
|
11
|
+
import CustomListItem from "sap/m/CustomListItem";
|
|
12
|
+
import FlexBox from "sap/m/FlexBox";
|
|
13
|
+
import HBox from "sap/m/HBox";
|
|
14
|
+
import IllustratedMessage from "sap/m/IllustratedMessage";
|
|
15
|
+
import IllustratedMessageSize from "sap/m/IllustratedMessageSize";
|
|
16
|
+
import IllustratedMessageType from "sap/m/IllustratedMessageType";
|
|
17
|
+
import Input from "sap/m/Input";
|
|
18
|
+
import List from "sap/m/List";
|
|
19
|
+
import type { ListBase$DeleteEvent } from "sap/m/ListBase";
|
|
20
|
+
import Popover from "sap/m/Popover";
|
|
21
|
+
import type StandardListItem from "sap/m/StandardListItem";
|
|
22
|
+
import Text from "sap/m/Text";
|
|
23
|
+
import Title from "sap/m/Title";
|
|
24
|
+
import { ButtonType, FlexAlignItems, FlexDirection, FlexJustifyContent, FlexWrap, ListMode, PlacementType } from "sap/m/library";
|
|
25
|
+
import type UI5Event from "sap/ui/base/Event";
|
|
26
|
+
import type { $ControlSettings } from "sap/ui/core/Control";
|
|
27
|
+
import Control from "sap/ui/core/Control";
|
|
28
|
+
import CustomData from "sap/ui/core/CustomData";
|
|
29
|
+
import Lib from "sap/ui/core/Lib";
|
|
30
|
+
import type RenderManager from "sap/ui/core/RenderManager";
|
|
31
|
+
import { TitleLevel, ValueState } from "sap/ui/core/library";
|
|
32
|
+
import type Context from "sap/ui/model/Context";
|
|
33
|
+
import type { EventHandler } from "../../../../../../../types/extension_types";
|
|
34
|
+
|
|
35
|
+
@defineUI5Class("sap.fe.controls.easyFilter.EasyFilterInput")
|
|
36
|
+
export default class EasyFilterInput extends Control {
|
|
37
|
+
@aggregation({ type: "sap.m.Input", multiple: false, isDefault: true })
|
|
38
|
+
$searchInput!: Input;
|
|
39
|
+
|
|
40
|
+
@property({ type: "string" })
|
|
41
|
+
appId?: string;
|
|
42
|
+
|
|
43
|
+
@property({ type: "array" })
|
|
44
|
+
recommendedValues?: string[];
|
|
45
|
+
|
|
46
|
+
@event()
|
|
47
|
+
queryChanged?: EventHandler<UI5Event<{ query: string }, EasyFilterInput>>;
|
|
48
|
+
|
|
49
|
+
@event()
|
|
50
|
+
enterPressed?: EventHandler<UI5Event<{ query: string }, EasyFilterInput>>;
|
|
51
|
+
|
|
52
|
+
private resourceBundle!: ResourceBundle;
|
|
53
|
+
|
|
54
|
+
shellHistoryProvider: ShellHistoryProvider | undefined;
|
|
55
|
+
|
|
56
|
+
$favoritePopover: Popover | undefined;
|
|
57
|
+
|
|
58
|
+
@defineState()
|
|
59
|
+
protected state: StateOf<{
|
|
60
|
+
queryChanged: boolean;
|
|
61
|
+
recentQueries: readonly { text: string; isFavorite: boolean }[];
|
|
62
|
+
isHistoryEnabled: boolean;
|
|
63
|
+
favoriteQueries: string[];
|
|
64
|
+
recommendedQueries: string[];
|
|
65
|
+
}> = {
|
|
66
|
+
queryChanged: false,
|
|
67
|
+
isHistoryEnabled: false,
|
|
68
|
+
recentQueries: [],
|
|
69
|
+
favoriteQueries: [] as string[],
|
|
70
|
+
recommendedQueries: [] as string[]
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
constructor(properties: string | ($ControlSettings & PropertiesOf<EasyFilterInput>), others?: $ControlSettings) {
|
|
74
|
+
super(properties as string, others);
|
|
75
|
+
this.initialize();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public getValue(): string {
|
|
79
|
+
return this.$searchInput.getValue();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setValue(value: string): void {
|
|
83
|
+
this.$searchInput.setPlaceholder(this.$searchInput.getValue());
|
|
84
|
+
this.$searchInput.setValue(value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
initialize(): void {
|
|
88
|
+
this.state.recommendedQueries = this.recommendedValues ?? [];
|
|
89
|
+
this.resourceBundle = Lib.getResourceBundleFor("sap.fe.controls")!;
|
|
90
|
+
this.createInput();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
setAsInvalid(message: string): void {
|
|
94
|
+
this.$searchInput.setValueState(ValueState.Warning);
|
|
95
|
+
this.$searchInput.setValueStateText(message);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
createInput(): void {
|
|
99
|
+
this.$searchInput = (
|
|
100
|
+
<Input
|
|
101
|
+
width="100%"
|
|
102
|
+
showClearIcon={true}
|
|
103
|
+
change={(e): void => {
|
|
104
|
+
this.fireEvent("queryChanged", { query: e.getParameter("value") });
|
|
105
|
+
}}
|
|
106
|
+
liveChange={(): void => {
|
|
107
|
+
this.state.queryChanged = true;
|
|
108
|
+
}}
|
|
109
|
+
placeholder={this.resourceBundle.getText("M_EASY_FILTER_PLACEHOLDER")}
|
|
110
|
+
></Input>
|
|
111
|
+
);
|
|
112
|
+
this.createFavoritePopover()
|
|
113
|
+
.then((favoritePopover) => {
|
|
114
|
+
this.$favoritePopover = favoritePopover;
|
|
115
|
+
this.$searchInput.addDependent(favoritePopover);
|
|
116
|
+
return;
|
|
117
|
+
})
|
|
118
|
+
.catch((e) => {
|
|
119
|
+
Log.error("Couldn't create the favorite popover", e);
|
|
120
|
+
});
|
|
121
|
+
this.$searchInput.addEventDelegate({
|
|
122
|
+
onkeyup: (e: KeyboardEvent) => {
|
|
123
|
+
if (e.key === "Enter") {
|
|
124
|
+
this.onEnterPressed();
|
|
125
|
+
}
|
|
126
|
+
if (this.$favoritePopover) {
|
|
127
|
+
this.$favoritePopover.close();
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
onkeydown: (e: KeyboardEvent) => {
|
|
131
|
+
if (
|
|
132
|
+
e.key === "Tab" &&
|
|
133
|
+
this.$searchInput?.getValue().length === 0 &&
|
|
134
|
+
this.$searchInput?.getValue() !== this.$searchInput?.getPlaceholder()
|
|
135
|
+
) {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
this.$searchInput?.setValue(this.$searchInput?.getPlaceholder());
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
ontap: () => {
|
|
141
|
+
this.openSuggestionPopover();
|
|
142
|
+
},
|
|
143
|
+
onfocusin: () => {
|
|
144
|
+
this.openSuggestionPopover();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private openSuggestionPopover(): void {
|
|
150
|
+
if (!this.$searchInput?.getValue() && (!this.$favoritePopover || !this.$favoritePopover?.isOpen())) {
|
|
151
|
+
// Open the easy filter popover
|
|
152
|
+
this.state.isHistoryEnabled = this.shellHistoryProvider?.isHistoryEnabled() ?? false;
|
|
153
|
+
this.state.favoriteQueries = this.shellHistoryProvider?.getFavoriteQueries() ?? [];
|
|
154
|
+
this.state.recentQueries = (this.shellHistoryProvider?.getRecentQueries() ?? []).map((query) => {
|
|
155
|
+
return {
|
|
156
|
+
text: query,
|
|
157
|
+
isFavorite: this.state.favoriteQueries.includes(query)
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
this.$favoritePopover?.openBy(this.$searchInput);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
requestFavorite(e: Button$PressEvent): void {
|
|
165
|
+
this.$favoritePopover?.close();
|
|
166
|
+
this.$searchInput?.setValue(e.getSource().getText());
|
|
167
|
+
this.onEnterPressed();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
onEnterPressed(): void {
|
|
171
|
+
this.$favoritePopover?.close();
|
|
172
|
+
this.state.queryChanged = false;
|
|
173
|
+
this.$searchInput?.setEditable(true);
|
|
174
|
+
const magicQuery = this.$searchInput?.getValue();
|
|
175
|
+
this.$searchInput?.setValueStateText("");
|
|
176
|
+
this.$searchInput?.setValueState("None");
|
|
177
|
+
this.fireEvent("enterPressed", { query: magicQuery });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
addRecentQuery(queryString: string | undefined): void {
|
|
181
|
+
const isQueryPresent = !!this.state.recentQueries.find((query) => query.text === queryString);
|
|
182
|
+
if (queryString && !isQueryPresent) {
|
|
183
|
+
this.state.recentQueries = this.state.recentQueries.concat([
|
|
184
|
+
{
|
|
185
|
+
text: queryString,
|
|
186
|
+
isFavorite: false
|
|
187
|
+
}
|
|
188
|
+
]);
|
|
189
|
+
if (this.state.recentQueries.length > 5) {
|
|
190
|
+
this.state.recentQueries = this.state.recentQueries.slice(1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
onStateChange(changedProps: string[] = []): void {
|
|
196
|
+
if (changedProps.includes("favoriteQueries") || changedProps.includes("recentQueries")) {
|
|
197
|
+
this.shellHistoryProvider?.setFavoriteQueries(this.state.favoriteQueries);
|
|
198
|
+
this.shellHistoryProvider?.setRecentQueries(this.state.recentQueries.map((query) => query.text));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async initShellHistoryProvider(): Promise<void> {
|
|
203
|
+
try {
|
|
204
|
+
this.shellHistoryProvider = await ShellHistoryProvider.getInstance(this.appId ?? "<unknownApp>");
|
|
205
|
+
} catch (error) {
|
|
206
|
+
Log.error("Error while creating ShellHistoryProvider for easy filter", error as string);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async createFavoritePopover(): Promise<Popover> {
|
|
211
|
+
await this.initShellHistoryProvider();
|
|
212
|
+
return (
|
|
213
|
+
<Popover
|
|
214
|
+
showHeader={false}
|
|
215
|
+
horizontalScrolling={false}
|
|
216
|
+
placement={PlacementType.Bottom}
|
|
217
|
+
showArrow={false}
|
|
218
|
+
initialFocus={this.$searchInput}
|
|
219
|
+
class={"sapFEControlsPopover"}
|
|
220
|
+
>
|
|
221
|
+
{{
|
|
222
|
+
content: (
|
|
223
|
+
<FlexBox direction={FlexDirection.Column} class={"sapUiContentPadding"} renderType={"Bare"}>
|
|
224
|
+
{{
|
|
225
|
+
items: [
|
|
226
|
+
<Title
|
|
227
|
+
titleStyle={TitleLevel.H6}
|
|
228
|
+
text={this.resourceBundle.getText("M_EASY_FILTER_POPOVER_SUGGESTIONS_TITLE")}
|
|
229
|
+
class={"sapFeControlsTitleBorder"}
|
|
230
|
+
visible={this.state.recommendedQueries.length > 0}
|
|
231
|
+
/>,
|
|
232
|
+
<HBox
|
|
233
|
+
class={"sapUiContentPadding"}
|
|
234
|
+
items={bindState(this.state.recommendedQueries)}
|
|
235
|
+
wrap={FlexWrap.Wrap}
|
|
236
|
+
visible={this.state.recommendedQueries.length > 0}
|
|
237
|
+
>
|
|
238
|
+
{{
|
|
239
|
+
items: (id: string, ctx: Context): StandardListItem => {
|
|
240
|
+
return (
|
|
241
|
+
<Button
|
|
242
|
+
class={"sapUiTinyMarginEnd"}
|
|
243
|
+
text={ctx.getObject()}
|
|
244
|
+
press={this.requestFavorite.bind(this)}
|
|
245
|
+
/>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
}}
|
|
249
|
+
</HBox>,
|
|
250
|
+
<Title
|
|
251
|
+
titleStyle={TitleLevel.H6}
|
|
252
|
+
text={this.resourceBundle.getText("M_EASY_FILTER_POPOVER_FAVORITE_TITLE")}
|
|
253
|
+
class={"sapFeControlsTitleBorder"}
|
|
254
|
+
visible={this.state.isHistoryEnabled}
|
|
255
|
+
/>,
|
|
256
|
+
<List
|
|
257
|
+
items={bindState(this.state.favoriteQueries)}
|
|
258
|
+
visible={this.state.isHistoryEnabled}
|
|
259
|
+
mode={ListMode.Delete}
|
|
260
|
+
delete={(e: ListBase$DeleteEvent): void => {
|
|
261
|
+
const list = e.getSource();
|
|
262
|
+
//Retaining the focus on popover doesn't make the popover close on every interaction
|
|
263
|
+
this.$favoritePopover?.focus();
|
|
264
|
+
const customListItem = e.getParameter("listItem") as CustomListItem;
|
|
265
|
+
const listIndex = list.indexOfItem(customListItem);
|
|
266
|
+
const newFavoriteQueries = this.state.favoriteQueries.concat();
|
|
267
|
+
newFavoriteQueries.splice(listIndex, 1);
|
|
268
|
+
this.state.favoriteQueries = newFavoriteQueries;
|
|
269
|
+
}}
|
|
270
|
+
>
|
|
271
|
+
{{
|
|
272
|
+
noData: (
|
|
273
|
+
<IllustratedMessage
|
|
274
|
+
title={this.resourceBundle.getText("M_EASY_FILTER_POPOVER_EMPTY_FAVORITE_TITLE")}
|
|
275
|
+
illustrationSize={IllustratedMessageSize.Dot}
|
|
276
|
+
illustrationType={IllustratedMessageType.NoEntries}
|
|
277
|
+
description={this.resourceBundle.getText(
|
|
278
|
+
"M_EASY_FILTER_POPOVER_EMPTY_FAVORITE_DESCRIPTION"
|
|
279
|
+
)}
|
|
280
|
+
/>
|
|
281
|
+
),
|
|
282
|
+
items: (id: string, ctx: Context): StandardListItem => {
|
|
283
|
+
return (
|
|
284
|
+
<CustomListItem
|
|
285
|
+
class={"sapUiSmallMarginBegin"}
|
|
286
|
+
customData={[<CustomData key={"text"} value={ctx.getObject()} />]}
|
|
287
|
+
press={(): void => {
|
|
288
|
+
this.$searchInput.setValue(ctx.getObject());
|
|
289
|
+
this.onEnterPressed();
|
|
290
|
+
}}
|
|
291
|
+
>
|
|
292
|
+
<FlexBox
|
|
293
|
+
width={"100%"}
|
|
294
|
+
direction={FlexDirection.Row}
|
|
295
|
+
alignItems={FlexAlignItems.Center}
|
|
296
|
+
justifyContent={FlexJustifyContent.SpaceBetween}
|
|
297
|
+
renderType={"Bare"}
|
|
298
|
+
id={id}
|
|
299
|
+
>
|
|
300
|
+
<Text text={ctx.getObject()} wrapping={false} class="sapFEControlsPointer">
|
|
301
|
+
{{
|
|
302
|
+
dependents: (
|
|
303
|
+
<EventDelegateHook
|
|
304
|
+
tap={(): void => {
|
|
305
|
+
this.$searchInput?.setValue(ctx.getObject());
|
|
306
|
+
this.onEnterPressed();
|
|
307
|
+
}}
|
|
308
|
+
/>
|
|
309
|
+
)
|
|
310
|
+
}}
|
|
311
|
+
</Text>
|
|
312
|
+
<Button
|
|
313
|
+
icon={"sap-icon://favorite"}
|
|
314
|
+
type={ButtonType.Transparent}
|
|
315
|
+
press={(): void => {
|
|
316
|
+
//Retaining the focus on popover doesn't make the popover close on every interaction
|
|
317
|
+
this.$favoritePopover?.focus();
|
|
318
|
+
const queryString = ctx.getObject();
|
|
319
|
+
const index = this.state.favoriteQueries.indexOf(queryString);
|
|
320
|
+
if (index !== -1) {
|
|
321
|
+
this.state.favoriteQueries = this.state.favoriteQueries.filter(
|
|
322
|
+
(query) => query !== queryString
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
this.addRecentQuery(queryString);
|
|
326
|
+
}}
|
|
327
|
+
/>
|
|
328
|
+
</FlexBox>
|
|
329
|
+
</CustomListItem>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
}}
|
|
333
|
+
</List>,
|
|
334
|
+
<Title
|
|
335
|
+
titleStyle={TitleLevel.H6}
|
|
336
|
+
text={this.resourceBundle.getText("M_EASY_FILTER_POPOVER_LAST_USED")}
|
|
337
|
+
class={"sapFeControlsTitleBorder"}
|
|
338
|
+
visible={and(
|
|
339
|
+
this.state.isHistoryEnabled,
|
|
340
|
+
greaterThan(length(bindState(this.state.recentQueries) as PathInModelExpression<unknown>), 0)
|
|
341
|
+
)}
|
|
342
|
+
/>,
|
|
343
|
+
<List
|
|
344
|
+
items={bindState(this.state.recentQueries)}
|
|
345
|
+
visible={and(
|
|
346
|
+
this.state.isHistoryEnabled,
|
|
347
|
+
greaterThan(length(bindState(this.state.recentQueries) as PathInModelExpression<unknown>), 0)
|
|
348
|
+
)}
|
|
349
|
+
mode={ListMode.Delete}
|
|
350
|
+
delete={(e: ListBase$DeleteEvent): void => {
|
|
351
|
+
//Retaining the focus on popover doesn't make the popover close on every interaction
|
|
352
|
+
this.$favoritePopover?.focus();
|
|
353
|
+
const queryString = e.getParameter("listItem")?.data("text");
|
|
354
|
+
this.state.recentQueries = this.state.recentQueries.filter(
|
|
355
|
+
(query) => query.text !== queryString
|
|
356
|
+
);
|
|
357
|
+
}}
|
|
358
|
+
>
|
|
359
|
+
{{
|
|
360
|
+
items: (id: string, ctx: Context): FlexBox => {
|
|
361
|
+
return (
|
|
362
|
+
<CustomListItem
|
|
363
|
+
press={(): void => {
|
|
364
|
+
this.$searchInput?.setValue(ctx.getObject().text);
|
|
365
|
+
this.onEnterPressed();
|
|
366
|
+
}}
|
|
367
|
+
class={"sapUiSmallMarginBegin"}
|
|
368
|
+
customData={[<CustomData key={"text"} value={ctx.getObject().text} />]}
|
|
369
|
+
>
|
|
370
|
+
<FlexBox
|
|
371
|
+
width={"100%"}
|
|
372
|
+
direction={FlexDirection.Row}
|
|
373
|
+
alignItems={FlexAlignItems.Center}
|
|
374
|
+
justifyContent={FlexJustifyContent.SpaceBetween}
|
|
375
|
+
renderType={"Bare"}
|
|
376
|
+
id={id}
|
|
377
|
+
>
|
|
378
|
+
<Text
|
|
379
|
+
text={this.state.recentQueries.text}
|
|
380
|
+
tooltip={this.state.recentQueries.text}
|
|
381
|
+
wrapping={false}
|
|
382
|
+
class="sapFEControlsPointer"
|
|
383
|
+
>
|
|
384
|
+
{{
|
|
385
|
+
dependents: (
|
|
386
|
+
<EventDelegateHook
|
|
387
|
+
tap={(): void => {
|
|
388
|
+
this.$searchInput?.setValue(ctx.getObject().text);
|
|
389
|
+
this.onEnterPressed();
|
|
390
|
+
}}
|
|
391
|
+
/>
|
|
392
|
+
)
|
|
393
|
+
}}
|
|
394
|
+
</Text>
|
|
395
|
+
<Button
|
|
396
|
+
icon={ifElse(
|
|
397
|
+
bindState<boolean>(this.state.recentQueries.isFavorite),
|
|
398
|
+
"sap-icon://favorite",
|
|
399
|
+
"sap-icon://add-favorite"
|
|
400
|
+
)}
|
|
401
|
+
enabled={lessThan(
|
|
402
|
+
length(
|
|
403
|
+
bindState(
|
|
404
|
+
this.state.favoriteQueries
|
|
405
|
+
) as PathInModelExpression<unknown>
|
|
406
|
+
),
|
|
407
|
+
5
|
|
408
|
+
)}
|
|
409
|
+
type={ButtonType.Transparent}
|
|
410
|
+
press={(): void => {
|
|
411
|
+
//Retaining the focus on popover doesn't make the popover close on every interaction
|
|
412
|
+
this.$favoritePopover?.focus();
|
|
413
|
+
const queryString = ctx.getObject().text;
|
|
414
|
+
const index = this.state.favoriteQueries.indexOf(queryString);
|
|
415
|
+
const indexOfRecentQueries =
|
|
416
|
+
this.state.recentQueries.indexOf(queryString);
|
|
417
|
+
const newRecentQueries = this.state.recentQueries.concat();
|
|
418
|
+
newRecentQueries.splice(indexOfRecentQueries, 1);
|
|
419
|
+
this.state.recentQueries = newRecentQueries;
|
|
420
|
+
if (index === -1) {
|
|
421
|
+
this.state.favoriteQueries = this.state.favoriteQueries.concat([
|
|
422
|
+
queryString
|
|
423
|
+
]);
|
|
424
|
+
} else {
|
|
425
|
+
this.state.favoriteQueries = this.state.favoriteQueries.filter(
|
|
426
|
+
(query) => query !== queryString
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
}}
|
|
430
|
+
/>
|
|
431
|
+
</FlexBox>
|
|
432
|
+
</CustomListItem>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
}}
|
|
436
|
+
</List>
|
|
437
|
+
]
|
|
438
|
+
}}
|
|
439
|
+
</FlexBox>
|
|
440
|
+
)
|
|
441
|
+
}}
|
|
442
|
+
</Popover>
|
|
443
|
+
) as Popover;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
static render(rm: RenderManager, control: EasyFilterInput): void {
|
|
447
|
+
return jsx.renderUsingRenderManager(rm, control, () => {
|
|
448
|
+
return (
|
|
449
|
+
<span ref={control} class={"sapFEEasyFilterInput"}>
|
|
450
|
+
{control.$searchInput}
|
|
451
|
+
</span>
|
|
452
|
+
);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|