@sapui5/sap.rules.ui 1.107.0 → 1.108.1

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.
Files changed (70) hide show
  1. package/package.json +1 -1
  2. package/src/sap/rules/ui/.library +1 -1
  3. package/src/sap/rules/ui/AstExpressionBasic.js +27 -6
  4. package/src/sap/rules/ui/AstExpressionBasicRenderer.js +71 -55
  5. package/src/sap/rules/ui/AutoCompleteSuggestionContent.js +5 -3
  6. package/src/sap/rules/ui/AutoCompleteSuggestionContentRenderer.js +39 -40
  7. package/src/sap/rules/ui/BindingSpy.js +1 -1
  8. package/src/sap/rules/ui/DecisionTable.js +2157 -2154
  9. package/src/sap/rules/ui/DecisionTableCell.js +7 -4
  10. package/src/sap/rules/ui/DecisionTableCellAstExpressionBasic.js +7 -4
  11. package/src/sap/rules/ui/DecisionTableCellAstExpressionBasicRenderer.js +5 -3
  12. package/src/sap/rules/ui/DecisionTableCellExpressionAdvanced.js +238 -236
  13. package/src/sap/rules/ui/DecisionTableCellExpressionAdvancedRenderer.js +6 -4
  14. package/src/sap/rules/ui/DecisionTableCellExpressionBasic.js +29 -22
  15. package/src/sap/rules/ui/DecisionTableCellExpressionBasicRenderer.js +6 -4
  16. package/src/sap/rules/ui/DecisionTableCellRenderer.js +10 -10
  17. package/src/sap/rules/ui/DecisionTableConfiguration.js +1 -1
  18. package/src/sap/rules/ui/DecisionTableRenderer.js +163 -161
  19. package/src/sap/rules/ui/DecisionTableSettings.js +6 -4
  20. package/src/sap/rules/ui/DecisionTableSettingsOld.js +963 -961
  21. package/src/sap/rules/ui/DecisionTableSettingsOldRenderer.js +9 -10
  22. package/src/sap/rules/ui/DecisionTableSettingsRenderer.js +9 -10
  23. package/src/sap/rules/ui/ExpressionAdvanced.js +1726 -1724
  24. package/src/sap/rules/ui/ExpressionAdvancedRenderer.js +8 -8
  25. package/src/sap/rules/ui/ExpressionBase.js +1 -1
  26. package/src/sap/rules/ui/ExpressionBasic.js +7 -4
  27. package/src/sap/rules/ui/ExpressionBasicRenderer.js +8 -7
  28. package/src/sap/rules/ui/InstructionRenderer.js +73 -33
  29. package/src/sap/rules/ui/RuleBase.js +1 -1
  30. package/src/sap/rules/ui/RuleBuilder.js +433 -430
  31. package/src/sap/rules/ui/RuleBuilderRenderer.js +8 -9
  32. package/src/sap/rules/ui/TextRule.js +7 -4
  33. package/src/sap/rules/ui/TextRuleConfiguration.js +1 -1
  34. package/src/sap/rules/ui/TextRuleRenderer.js +45 -44
  35. package/src/sap/rules/ui/TextRuleSettings.js +6 -4
  36. package/src/sap/rules/ui/TextRuleSettingsRenderer.js +9 -9
  37. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAdvancedFunctionPanel.js +4 -3
  38. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAdvancedFunctionPanelRenderer.js +10 -11
  39. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAggregateFunctionPanel.js +100 -98
  40. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAggregateFunctionPanelRenderer.js +9 -10
  41. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionArrayOperatorPanel.js +4 -3
  42. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionArrayOperatorPanelRenderer.js +10 -10
  43. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionComparisionOperatorPanel.js +109 -107
  44. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionComparisionOperatorPanelRenderer.js +39 -40
  45. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionDateAndTimePanel.js +5 -3
  46. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionDateAndTimePanelRenderer.js +10 -10
  47. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFixedValuePanel.js +840 -838
  48. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFixedValuePanelRenderer.js +40 -40
  49. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFunctionalOperatorPanel.js +4 -3
  50. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFunctionalOperatorPanelRenderer.js +10 -11
  51. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLogicalOperatorPanel.js +112 -110
  52. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLogicalOperatorPanelRenderer.js +39 -40
  53. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLoopFunctionPanel.js +100 -98
  54. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLoopFunctionPanelRenderer.js +9 -10
  55. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMathematicalOperatorPanel.js +122 -119
  56. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMathematicalOperatorPanelRenderer.js +39 -40
  57. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMiscellaneousOperatorPanel.js +5 -2
  58. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMiscellaneousOperatorPanelRenderer.js +10 -11
  59. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionOperationsPanel.js +4 -3
  60. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionOperationsPanelRenderer.js +10 -11
  61. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionRangeOperatorPanel.js +4 -3
  62. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionRangeOperatorPanelRenderer.js +10 -11
  63. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionSelectFunctionPanel.js +108 -106
  64. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionSelectFunctionPanelRenderer.js +40 -40
  65. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionTimeAndDurationFunctionPanel.js +254 -252
  66. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionTimeAndDurationFunctionPanelRenderer.js +40 -40
  67. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionVocabularyPanel.js +631 -629
  68. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionVocabularyPanelRenderer.js +40 -40
  69. package/src/sap/rules/ui/library.js +31 -10
  70. package/src/sap/rules/ui/type/ExpressionAbs.js +1 -1
@@ -1,838 +1,840 @@
1
- sap.ui.define([
2
- "sap/ui/thirdparty/jquery",
3
- "../../library",
4
- "sap/ui/core/Control",
5
- "sap/m/List",
6
- "sap/ui/model/json/JSONModel",
7
- "sap/m/ListMode",
8
- "sap/ui/core/CustomData",
9
- "sap/ui/model/Sorter",
10
- "sap/rules/ui/parser/infrastructure/util/utilsBase",
11
- "sap/ui/core/LocaleData",
12
- "sap/rules/ui/Constants",
13
- "sap/m/DatePicker",
14
- "sap/m/DateTimePicker",
15
- "sap/m/TimePicker",
16
- "sap/m/Dialog",
17
- "sap/m/Button"
18
- ], function (jQuery, library, Control, List, JSONModel, ListMode, CustomData, Sorter, infraUtils,
19
- LocaleData, Constants, DatePicker , DateTimePicker , TimePicker, Dialog, Button ) {
20
- "use strict";
21
-
22
- var autoSuggestionFixedValuePanel = Control.extend("sap.rules.ui.ast.autoCompleteContent.AutoSuggestionFixedValuePanel", {
23
- metadata: {
24
- library: "sap.rules.ui",
25
- properties: {
26
- reference: {
27
- type: "object",
28
- defaultValue: null,
29
- },
30
- vocabularyInfo: {
31
- type: "object",
32
- defaultValue: null
33
- },
34
- data: {
35
- type: "object",
36
- defaultValue: null
37
- },
38
- dialogOpenedCallbackReference: {
39
- type: "object",
40
- defaultValue: null,
41
- },
42
- inputValue: {
43
- type: "string",
44
- defaultValue: ""
45
- }
46
-
47
- },
48
- aggregations: {
49
- PanelLayout: {
50
- type: "sap.m.Panel",
51
- multiple: false
52
- }
53
- },
54
- events: {}
55
- },
56
-
57
- init: function () {
58
- this.infraUtils = new sap.rules.ui.parser.infrastructure.util.utilsBase.utilsBaseLib();
59
- this.needCreateLayout = true;
60
- this.businessDataType = "S";
61
- this._propertyValue = "Value";
62
- this._propertyDescription = "Description";
63
- this.oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.rules.ui.i18n");
64
- this.vocabularyInfo = this.getVocabularyInfo();
65
- this.autoSuggestionData = this.getData();
66
-
67
- // Date instance which is used to convert the selected date from calendar control to short format
68
- var oLocale = sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale();
69
- var oLocaleData = LocaleData.getInstance(oLocale);
70
-
71
- this.oFormatDate = sap.ui.core.format.DateFormat.getInstance({
72
- pattern: oLocaleData.getDatePattern('short'),
73
- calendarType: sap.ui.core.CalendarType.Gregorian
74
- },
75
- oLocale
76
- );
77
- },
78
- onBeforeRendering: function () {
79
- this._reference = this.getReference();
80
- this._dialogOpenedCallbackReference = this.getDialogOpenedCallbackReference();
81
- this.vocabularyInfo = this.getVocabularyInfo();
82
- this.valueHelpData = this.getData();
83
- if (this.needCreateLayout) {
84
- var layout = this._createLayout(this.vocabularyInfo);
85
- this.setAggregation("PanelLayout", layout, true);
86
- this.needCreateLayout = false;
87
- }
88
- },
89
-
90
- onAfterRendering: function () {
91
- var sId = "#" + this.fixedValueTextArea.getId();
92
- $(sId).on('keydown', function (event) {
93
- if (event.key == 'Enter') {
94
- event.preventDefault();
95
- }
96
- });
97
- },
98
-
99
- initializeVariables: function () {
100
-
101
- },
102
-
103
- _createLayout: function (vocabularyInfo) {
104
- var that = this;
105
- var hasValueSource = false;
106
- if (this.getData().valuehelp) {
107
- hasValueSource = true;
108
- } else {
109
- hasValueSource = false;
110
- }
111
- //The invisible text is introduced to identify the input field by screen reader.
112
- this._invisibleText = new sap.ui.core.InvisibleText({
113
- text:this.oBundle.getText("fixedValueInvisibleText")
114
- });
115
- this.fixedValueTextArea = new sap.m.Input({
116
- showValueHelp: hasValueSource,
117
- showSuggestion: true,
118
- autocomplete: false,
119
- ariaLabelledBy: this._invisibleText.getId(),
120
- valueHelpRequest: function () {
121
- that._dialogOpenedCallbackReference(true);
122
- that._setModal(true);
123
- that._generateValueHelpInfoAndCreateDialog(vocabularyInfo)
124
- },
125
- value: this.getInputValue(),
126
- change: function (event) {
127
- that._setModal(false);
128
- var oEvent = that._formatText(event);
129
- oEvent.oSource.mProperties.forceFireChange = true;
130
- that._reference(oEvent);
131
- }.bind(this),
132
- width: "auto"
133
- });
134
-
135
- var fixedValuePanel = new sap.m.Panel({
136
- headerText: this.oBundle.getText("fixedValuePanelTitle"),
137
- expandable: true,
138
- expanded: false,
139
- content: [this._invisibleText, this.fixedValueTextArea],
140
- width: "auto"
141
- })
142
-
143
- this.toolBarSpacerAfterInput = new sap.m.ToolbarSpacer({width: "1em"});
144
- this.toolBarSpacerAfterDateLink = new sap.m.ToolbarSpacer({width: "1em"});
145
- this.dateContent = this._createDateLink();
146
- this.timeContent = this._createTimeStampLink();
147
- fixedValuePanel.addContent(this.toolBarSpacerAfterInput);
148
- fixedValuePanel.addContent(this.dateContent);
149
- fixedValuePanel.addContent(this.toolBarSpacerAfterDateLink);
150
- fixedValuePanel.addContent(this.timeContent);
151
-
152
- return fixedValuePanel;
153
- },
154
-
155
- _setModal: function (value) {
156
- var pop = sap.ui.getCore().byId("popover");
157
- if (pop) {
158
- pop.setModal(value);
159
- }
160
- },
161
-
162
- /* ------------------ Value Help related functions ---------------------------*/
163
- _generateValueHelpInfoAndCreateDialog: function (vocabularyInfo) {
164
- var that = this;
165
- var valueHelpInfo = this.getData().valuehelp;
166
- if (valueHelpInfo) {
167
- valueHelpInfo.expressionLanguage = vocabularyInfo;
168
- valueHelpInfo.HasValueSource = true;
169
- if (valueHelpInfo.sourceType === "U") {
170
- valueHelpInfo.entitySet = "Enumerations";
171
- valueHelpInfo.serviceURL = "/Enumerations";
172
- } else {
173
- valueHelpInfo.entitySet = "ExternalValues";
174
- valueHelpInfo.serviceURL = "/ExternalValues";
175
- }
176
-
177
- var basePath = vocabularyInfo.getModel().sServiceUrl;
178
- that._createDialog(basePath, valueHelpInfo);
179
- }
180
- },
181
-
182
- _createDialog: function (basePath, valueHelpInfo, businessDataType) {
183
- this._createValueHelpDialog(basePath, valueHelpInfo);
184
- this._createSmartFilterBar(basePath, valueHelpInfo);
185
- this.oValueHelpDialog.setFilterBar(this.oFilterBar);
186
- this._openValueHelpDialog();
187
-
188
- },
189
-
190
- _openValueHelpDialog: function () {
191
- this.oValueHelpDialog.open();
192
- this.oValueHelpDialog.getTable().setBusy(true);
193
- },
194
-
195
- /*
196
- * Creates the Value Help Dialog.
197
- */
198
-
199
- _createValueHelpDialog: function (basePath, valueHelpInfo) {
200
- var that = this;
201
- var expressionData = valueHelpInfo.expressionLanguage.getModel();
202
- var attributePath = "Attributes(Id='" + valueHelpInfo.attributeId + "',VocabularyId='" + valueHelpInfo.vocabularyId +
203
- "',DataObjectId='" + valueHelpInfo.dataObjectId + "')";
204
- if(attributePath.includes(":")) {
205
- attributePath = attributePath = attributePath.replace(":","%3A");
206
- }
207
- this.attributeName = valueHelpInfo.attributeName;
208
- if(!expressionData.oData[attributePath]){
209
- valueHelpInfo.dataObjectId = this._getStructureObjectForTableType(valueHelpInfo.attributeId, valueHelpInfo);
210
- }
211
- sap.ui.core.BusyIndicator.show(0);
212
- this.oValueHelpDialog = new sap.ui.comp.valuehelpdialog.ValueHelpDialog({
213
- supportMultiselect: false,
214
- supportRanges: false,
215
- horizontalScrolling: false,
216
- title: that.attributeName,
217
- resizable: false,
218
- beforeOpen: function () {
219
- that._bindTable(basePath, valueHelpInfo);
220
- },
221
- ok: function (oEvt) {
222
- var oSelRow = oEvt.getParameter("tokens")[0].data("row");
223
- var value = oSelRow.Value;
224
- if (that.businessDataType === "D" || that.businessDataType === "U") {
225
- value = that._getValidValue(value);
226
- }
227
- var updatedToken = this._syncToken(value, that.businessDataType);
228
- oEvt.getParameter("tokens")[0].data("row").Value = updatedToken;
229
- oEvt.oSource.mProperties.forceFireChange = true;
230
- that._dialogOpenedCallbackReference(false);
231
- that.oValueHelpDialog.close();
232
- that._setModal(false);
233
- that.oValueHelpDialog.destroy();
234
- sap.ui.core.BusyIndicator.hide();
235
- that._reference(oEvt);
236
- }.bind(this),
237
- cancel: function () {
238
- that.oFilterBar.destroy();
239
- that._setModal(false);
240
- that.oValueHelpDialog.close();
241
- that.oValueHelpDialog.destroy();
242
- sap.ui.core.BusyIndicator.hide();
243
- },
244
- afterClose: function () {
245
- that._dialogOpenedCallbackReference(false);
246
- that.oFilterBar.destroy();
247
- sap.ui.core.BusyIndicator.hide();
248
- }
249
- });
250
- },
251
-
252
- _getStructureObjectForTableType: function(attributeId, valueHelpInfo){
253
- var valueSources = valueHelpInfo.expressionLanguage.getData().ValueSources;
254
- for(var entry in valueSources){
255
- if(attributeId === valueSources[entry].AttributeId){
256
- return valueSources[entry].DataObjectId;
257
- }
258
- }
259
- return valueHelpInfo.dataObjectId;
260
- },
261
-
262
- _syncToken: function (textEntered, businessDataType) {
263
- var addStartQuote = false;
264
- var addEndQuote = false;
265
- businessDataType = this.getData().valuehelp.attributeDataType;
266
- //truncate single and double quotes if the user has entered it
267
- if (businessDataType != "G") {
268
- var newValue = textEntered.replace(/'/g, "").replace(/"/g, "");
269
- } else {
270
- newValue = "'" + textEntered + "'";
271
- }
272
-
273
- //Handling for passing number when no context is available
274
- if (businessDataType === "N") {
275
- var newIntValue = parseFloat(newValue);
276
- var stringFormOfIntValue = newIntValue.toString();
277
- // Some text is truncated by parse int
278
- if (stringFormOfIntValue != newValue) {
279
- businessDataType = "Operations"
280
- } else if (stringFormOfIntValue === "NaN") {
281
- businessDataType = "S"
282
- } else {
283
- newValue = newIntValue;
284
- }
285
-
286
- }
287
-
288
- if (businessDataType === "S" || businessDataType === "D" || businessDataType === "U") {
289
- if (!(businessDataType === "S")) {
290
- if (businessDataType === "D") {
291
- this._dateBusinessDataType = "D";
292
- } else if (businessDataType === "U") {
293
- this._dateBusinessDataType = "U";
294
- }
295
- newValue = this._getValidDateValue(newValue);
296
- }
297
-
298
- newValue = newValue.toString();
299
- if (newValue === "'") {
300
- addStartQuote = true;
301
- } // add only quote for this special case
302
- if (newValue.substr(0, "'") !== "'") {
303
- addStartQuote = true;
304
- }
305
- if (newValue.substr(newValue.length - 1, "'") !== "'") {
306
- addEndQuote = true;
307
- }
308
-
309
- if (addStartQuote) {
310
- newValue = "'" + newValue;
311
- }
312
- if (addEndQuote) {
313
- newValue = newValue + "'";
314
- }
315
-
316
- }
317
-
318
- if (businessDataType === "B") {
319
- newValue = (newValue === "true");
320
- }
321
- return newValue;
322
- },
323
-
324
- _getValidDateValue: function (sValue) {
325
- var date, formatter;
326
- var sDateFormatted = "";
327
- var formatterParsing = this._getDateTimeFormatterForParsing();
328
- if (formatterParsing) {
329
- date = formatterParsing.parse(sValue);
330
- }
331
- if (this._dateBusinessDataType === "D") {
332
- formatter = sap.ui.core.format.DateFormat.getDateInstance({
333
- pattern: "yyyy-MM-dd"
334
- });
335
- sDateFormatted = formatter.format(date);
336
- } else if (this._dateBusinessDataType === "U") {
337
- formatter = sap.ui.core.format.DateFormat.getDateTimeInstance({
338
- pattern: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
339
- });
340
- sDateFormatted = formatter.format(date);
341
- }
342
- if (sDateFormatted !== "") {
343
- sDateFormatted;
344
- }
345
- return sValue;
346
- },
347
-
348
- /*
349
- * Creates the necessary control os SmartFilterBar for the ValueHelp Dialog.
350
- */
351
- _createSmartFilterBar: function (basePath, valueHelpInfo) {
352
- var that = this;
353
- this.oFilterBar = new sap.ui.comp.smartfilterbar.SmartFilterBar({
354
- entitySet: valueHelpInfo.entitySet,
355
- enableBasicSearch: true,
356
- advancedMode: true,
357
- filterBarExpanded: true,
358
- search: function () {
359
- that.onSearch(basePath, valueHelpInfo);
360
-
361
- },
362
- filterChange: function (oEvent) {
363
- that.setValueStateFilter(oEvent);
364
- },
365
- controlConfiguration: [that._createControlConfiguration()]
366
- });
367
- var oModel = new sap.ui.model.odata.v2.ODataModel(basePath);
368
- this.oFilterBar.setModel(oModel);
369
- },
370
-
371
- /*
372
- * Creating the Control Configuration for the smartFilter of the valueHelp Dialog.
373
- */
374
- _createControlConfiguration: function () {
375
- var aControlConfiguration = [new sap.ui.comp.smartfilterbar.ControlConfiguration({
376
- hasValueHelpDialog: true,
377
- key: "Value",
378
- label: this.oBundle.getText("value"),
379
- visibleInAdvancedArea: true,
380
- width: "100px",
381
- index: 1
382
-
383
- }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
384
- hasValueHelpDialog: true,
385
- key: "Description",
386
- label: this.oBundle.getText("description"),
387
- visibleInAdvancedArea: true,
388
- width: "100px",
389
- index: 2
390
-
391
- }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
392
- hasValueHelpDialog: true,
393
- key: "VocabularyId",
394
- label: "VocabularyId",
395
- width: "100px",
396
- visible: false,
397
- index: 3
398
-
399
- }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
400
- hasValueHelpDialog: true,
401
- key: "DataObjectId",
402
- label: "DataObjectId",
403
- visible: false,
404
- width: "100px",
405
- groupId: "abc",
406
- index: 4
407
-
408
- }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
409
- hasValueHelpDialog: true,
410
- key: "AttributeId",
411
- label: "AttributeId",
412
- visible: false,
413
- width: "100px",
414
- index: 5
415
-
416
- }),
417
- new sap.ui.comp.smartfilterbar.ControlConfiguration({
418
- hasValueHelpDialog: true,
419
- key: "Version",
420
- label: "Version",
421
- visible: false,
422
- width: "100px",
423
- index: 6
424
-
425
- })
426
- ];
427
- return aControlConfiguration;
428
- },
429
-
430
- /*
431
- * Called when the search is triggered in SmartFilter.
432
- */
433
- onSearch: function (basePath, valueHelpInfo) {
434
- this.oValueHelpDialog.getTable().setBusy(true);
435
- this._unBindTable();
436
- this._bindTable(basePath, valueHelpInfo);
437
- },
438
-
439
- /*
440
- * Binds the table taking current filters parameters into account.
441
- */
442
- _bindTable: function (basePath, valueHelpInfo) {
443
- var serviceUrl = valueHelpInfo.serviceURL;
444
- var aFilterParams = this._fetchFilterParams(valueHelpInfo);
445
- var mEntities = {
446
- valueHelp: {
447
- collection: serviceUrl,
448
- properties: [this._propertyValue, this._propertyDescription]
449
- }
450
- };
451
-
452
- var oTable = this.oValueHelpDialog.getTable();
453
- oTable.setThreshold(10);
454
-
455
- for (var i = 0; i < mEntities.valueHelp.properties.length; i++) {
456
- var sColumnName = "";
457
- if (mEntities.valueHelp.properties[i] === "Value") {
458
- sColumnName = this.oBundle.getText("value");
459
- } else if(mEntities.valueHelp.properties[i] === "Description") {
460
- sColumnName = this.oBundle.getText("description");
461
- }
462
- this._addValueHelpColumn(mEntities.valueHelp.properties[i], oTable, sColumnName);
463
- }
464
-
465
- var oModel = new sap.ui.model.odata.v2.ODataModel(basePath);
466
- oTable.setModel(oModel);
467
- oTable.bindRows(mEntities.valueHelp.collection, null, aFilterParams);
468
- oTable.getBinding("rows").attachDataReceived(this._handleRowsDataReceived, this);
469
- },
470
-
471
- //handles the Busy State of the busy state for the data recieved.
472
- _handleRowsDataReceived: function (oEvent) {
473
- var that = this;
474
- var data = oEvent.getParameter("data");
475
- if (jQuery.isEmptyObject(data) || (data && data.results && data.results.length === 0)) {
476
- this.oValueHelpDialog.getTable().setNoData(that.oBundle.getText("no_data"));
477
- } else {
478
- this.oValueHelpDialog.getTable().setNoData(that.oBundle.getText("searching"));
479
- }
480
- this.oValueHelpDialog.getTable().setBusy(false);
481
- },
482
-
483
- // Utility function to create columns for the table.
484
- _addValueHelpColumn: function (oColumName, oTable, sColumnName) {
485
- var oColumn = new sap.ui.table.Column().setLabel(new sap.m.Label({
486
- text: sColumnName
487
- }));
488
- if (oColumName === this._propertyValue) {
489
- oColumn.setSortProperty(sColumnName);
490
- }
491
- oTable.addColumn(oColumn.setTemplate(new sap.m.Text().bindProperty("text", oColumName)));
492
- },
493
-
494
- /*
495
- * unBind the table Rows.
496
- */
497
- _unBindTable: function () {
498
- var oTable = this.oValueHelpDialog.getTable();
499
- oTable.destroyColumns();
500
- oTable.unbindRows();
501
-
502
- },
503
-
504
- /*
505
- * fetch the latest filter parmas depending on the filter or the search param set.
506
- */
507
- _fetchFilterParams: function (valueHelpInfo) {
508
- var that = this;
509
- var aSearchParams = [];
510
- var aFilterParams = [new sap.ui.model.Filter("AttributeId", sap.ui.model.FilterOperator.EQ, valueHelpInfo.attributeId),
511
- new sap.ui.model.Filter("DataObjectId", sap.ui.model.FilterOperator.EQ, valueHelpInfo.dataObjectId),
512
- new sap.ui.model.Filter("VocabularyId", sap.ui.model.FilterOperator.EQ, valueHelpInfo.vocabularyId)
513
- ];
514
-
515
- var aFilters = this.oFilterBar.getFilters();
516
- var searchParam = this.oFilterBar.getParameters();
517
- //When both search and filter is selected
518
- if (!jQuery.isEmptyObject(searchParam) && aFilters && aFilters.length > 0) {
519
- searchParam = this.oFilterBar.getParameters().custom.search;
520
- aSearchParams = this._getSearchFilters(searchParam);
521
- aFilters = that._formatFilterParams(aFilters, valueHelpInfo.sourceType);
522
- aFilterParams.push(new sap.ui.model.Filter({
523
- filters: [new sap.ui.model.Filter(aFilters), new sap.ui.model.Filter(aSearchParams)],
524
- and: true
525
- }));
526
- } else if (!jQuery.isEmptyObject(searchParam)) {
527
- //when only Search is selected.
528
- searchParam = this.oFilterBar.getParameters().custom.search;
529
- aSearchParams = this._getSearchFilters(searchParam);
530
- aFilterParams.push(aSearchParams);
531
- } else if (aFilters && aFilters.length > 0) {
532
- //When only filters is selected.
533
- aFilters = that._formatFilterParams(aFilters, valueHelpInfo.sourceType);
534
- aFilterParams.push(aFilters[0]);
535
- }
536
- return aFilterParams;
537
- },
538
-
539
- /*
540
- * format the filterParams to support Contains and Between.
541
- */
542
- _formatFilterParams: function (aFilters, valuehelpSourceType) {
543
- var that = this;
544
- if (aFilters[0] && aFilters.length === 1 && aFilters[0].aFilters[0] && aFilters[0].aFilters[0].sOperator) {
545
- aFilters = that._formatSingleFilter(aFilters, valuehelpSourceType);
546
- } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[0].aFilters[0] && aFilters[0].aFilters[0].aFilters[0].aFilters &&
547
- aFilters[0].aFilters[1].aFilters[0].aFilters) {
548
- aFilters = that._formatMultiFilter(aFilters, 0, true, valuehelpSourceType);
549
- aFilters = that._formatMultiFilter(aFilters, 1, true, valuehelpSourceType);
550
-
551
- } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[1] && aFilters[0].aFilters[0].aFilters[0] && aFilters[0].aFilters[
552
- 0].aFilters[0].aFilters && aFilters[0].aFilters[1].aFilters) {
553
- aFilters = that._formatMultiFilter(aFilters, 0, true, valuehelpSourceType);
554
- aFilters = that._formatMultiFilter(aFilters, 1, false, valuehelpSourceType);
555
-
556
- } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[1] && aFilters[0].aFilters[1].aFilters[0] && aFilters[0].aFilters[
557
- 0].aFilters && aFilters[0].aFilters[1].aFilters[0].aFilters) {
558
- aFilters = that._formatMultiFilter(aFilters, 0, false, valuehelpSourceType);
559
- aFilters = that._formatMultiFilter(aFilters, 1, true, valuehelpSourceType);
560
-
561
- } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[1] && aFilters[0].aFilters[0].aFilters && aFilters[0].aFilters[
562
- 1].aFilters) {
563
- aFilters = that._formatMultiFilter(aFilters, 0, false, valuehelpSourceType);
564
- aFilters = that._formatMultiFilter(aFilters, 1, false, valuehelpSourceType);
565
-
566
- }
567
-
568
- return aFilters;
569
- },
570
-
571
- _formatSingleFilter: function (aFilters, valuehelpSourceType) {
572
- var that = this;
573
- var _valueField = null;
574
-
575
- for (var iterator = 0; iterator < aFilters[0].aFilters.length; iterator++) {
576
- if (aFilters[0].aFilters[iterator].sOperator === "Contains" && valuehelpSourceType === "U") {
577
- aFilters[0].aFilters[iterator].sOperator = "EQ";
578
- } else if (aFilters[0].aFilters[iterator].sOperator === "Contains") {
579
- _valueField = (aFilters[0].aFilters[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
580
- _valueField.setValueState("Error");
581
- _valueField.setValueStateText(aFilters[0].aFilters[iterator].sOperator + " operator not supported");
582
- } else if (aFilters[0].aFilters[iterator].sOperator === "BT") {
583
-
584
- var convertedFilterParam = that._manageParam(aFilters[0].aFilters[iterator].sPath, aFilters[0].aFilters[iterator].sOperator,
585
- aFilters[0].aFilters[iterator].oValue1, aFilters[0].aFilters[iterator].oValue2);
586
- delete aFilters[0].aFilters[iterator];
587
- aFilters[0].aFilters[iterator] = convertedFilterParam;
588
- } else if (aFilters[0].aFilters[iterator].sOperator === "StartsWith") {
589
- _valueField = (aFilters[0].aFilters[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
590
- _valueField.setValueState("Error");
591
- _valueField.setValueStateText(aFilters[0].aFilters[iterator].sOperator + " operator not supported");
592
- } else if (aFilters[0].aFilters[iterator].sOperator === "EndsWith") {
593
- _valueField = (aFilters[0].aFilters[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
594
- _valueField.setValueState("Error");
595
- _valueField.setValueStateText(aFilters[0].aFilters[iterator].sOperator + " operator not supported");
596
- }
597
-
598
- }
599
- return aFilters;
600
-
601
- },
602
-
603
- _formatMultiFilter: function (aFilters, index, bMultifilter, valuehelpSourceType) {
604
- var that = this;
605
- var _valueField = null;
606
- var aComputeFilterParma = [];
607
- if (bMultifilter) {
608
- aComputeFilterParma = aFilters[0].aFilters[index].aFilters[0].aFilters;
609
- } else {
610
- aComputeFilterParma = aFilters[0].aFilters[index].aFilters;
611
- }
612
- for (var iterator = 0; iterator < aComputeFilterParma.length; iterator++) {
613
- if (aComputeFilterParma[iterator].sOperator === "Contains" && valuehelpSourceType === "U") {
614
- aComputeFilterParma[iterator].sOperator = "EQ";
615
- } else if (aComputeFilterParma[iterator].sOperator === "Contains") {
616
- _valueField = (aComputeFilterParma[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
617
- _valueField.setValueState("Error");
618
- _valueField.setValueStateText(aComputeFilterParma[iterator].sOperator + " operator not supported");
619
- } else if (aComputeFilterParma[iterator].sOperator === "BT") {
620
-
621
- var convertedFilterParam = that._manageParam(aComputeFilterParma[iterator].sPath, aComputeFilterParma[iterator].sOperator,
622
- aComputeFilterParma[iterator].oValue1, aComputeFilterParma[iterator].oValue2);
623
- delete aComputeFilterParma[iterator];
624
- aComputeFilterParma[iterator] = convertedFilterParam;
625
-
626
- } else if (aComputeFilterParma[iterator].sOperator === "StartsWith") {
627
- _valueField = (aComputeFilterParma[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
628
- _valueField.setValueState("Error");
629
- _valueField.setValueStateText(aComputeFilterParma[iterator].sOperator + " operator not supported");
630
- } else if (aComputeFilterParma[iterator].sOperator === "EndsWith") {
631
- _valueField = (aComputeFilterParma[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
632
- _valueField.setValueState("Error");
633
- _valueField.setValueStateText(aComputeFilterParma[iterator].sOperator + " operator not supported");
634
- }
635
- }
636
- return aFilters;
637
- },
638
-
639
- /*
640
- * Converts the Between Operator to Less than and Equal to Operator.
641
- */
642
- _manageParam: function (sPath, operator, value1, value2) {
643
- var filterParam = [];
644
- if (value1 && value2) {
645
- filterParam = new sap.ui.model.Filter({
646
- filters: [new sap.ui.model.Filter(sPath, sap.ui.model.FilterOperator.GT, value1),
647
- new sap.ui.model.Filter(sPath, sap.ui.model.FilterOperator.LT, value2)
648
- ],
649
- and: true
650
- });
651
- }
652
- return filterParam;
653
- },
654
-
655
- // Utility function to form the search filter params.
656
- _getSearchFilters: function (searchParam) {
657
- return new sap.ui.model.Filter({
658
- filters: [new sap.ui.model.Filter(this._propertyValue, sap.ui.model.FilterOperator.EQ, searchParam),
659
- new sap.ui.model.Filter(this._propertyDescription, sap.ui.model.FilterOperator.EQ, searchParam)
660
- ],
661
- and: false
662
- });
663
- },
664
-
665
- setValueStateFilter: function (oEvent) {
666
- var sId = oEvent.getSource().sId;
667
- this._valueFieldValue = sap.ui.getCore().byId(sId + "-filterItemControlA_-Value");
668
- if (this._valueFieldValue) {
669
- this._valueFieldValue.setValueState("None");
670
- this._valueFieldValue.setValueStateText("");
671
- }
672
- this._valueFieldDescription = sap.ui.getCore().byId(sId + "-filterItemControlA_-Description");
673
- if (this._valueFieldDescription) {
674
- this._valueFieldDescription.setValueState("None");
675
- this._valueFieldDescription.setValueStateText("");
676
- }
677
- },
678
-
679
- _formatText: function (oEvent) {
680
- var that = this;
681
- var businessDataTypeList = this.getData().businessDataTypeList;
682
- if (businessDataTypeList && businessDataTypeList.length > 0) {
683
- this.businessDataType = this.getData().businessDataTypeList[0];
684
- } else {
685
- this.businessDataType = "N"
686
- }
687
- var token = oEvent.getSource().getValue();
688
- oEvent.getSource().setValue(token);
689
- return oEvent;
690
- },
691
-
692
- /* ------------------------------- Date and Time related functions -------------------------- */
693
- _createDateLink : function(){
694
- var that = this;
695
- this.dateContent = new sap.m.Link({
696
- wrapping: true,
697
- text: this.oBundle.getText("select_date"),
698
- press: function (oEvent) {
699
- that.dateContext = "D";
700
- that._createDateTimeDialog();
701
- }
702
- });
703
- return this.dateContent;
704
- },
705
-
706
- _createTimeStampLink : function() {
707
- var that = this;
708
- this.timeContent = new sap.m.Link({
709
- wrapping: true,
710
- text: this.oBundle.getText("select_date_time"),
711
- press: function (oEvent) {
712
- that.dateContext = "U";
713
- that._createDateTimeDialog();
714
- }
715
- });
716
- return this.timeContent;
717
- },
718
-
719
- //creates calender control
720
- _createDateTimeDialog: function () {
721
- var that = this;
722
- var oLocale = sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale();
723
- var oLocaleData = LocaleData.getInstance(oLocale);
724
- var dateFormatted = oLocaleData.getDatePattern('medium');
725
- var timeFormat = oLocaleData.getTimePattern('medium');
726
- var sValueFormat = dateFormatted + " " + timeFormat;
727
-
728
- if(this.dateContext){
729
- this._dateBusinessDataType = this.dateContext;
730
- }
731
- if (this._dateBusinessDataType === "D") {
732
- this.control = new DatePicker({
733
- width: "auto",
734
- valueFormat: dateFormatted
735
- });
736
- }
737
-
738
- if (this._dateBusinessDataType === "U") {
739
- var that = this;
740
- this.control = new DateTimePicker({
741
- width: "auto",
742
- valueFormat: sValueFormat
743
- });
744
-
745
- }
746
-
747
- this._oSelectNewDateDialog = new Dialog({
748
- title: this.oBundle.getText("calendarTitle"),
749
- afterClose: function () {
750
- that._dialogOpenedCallbackReference(false);
751
- },
752
- content: [
753
- this.control
754
- ],
755
- beginButton: new Button({
756
- text: this.oBundle.getText("okBtn"),
757
- enabled: true,
758
- press: function (oEvt) {
759
- var date = this._updateText(this.control);
760
- oEvt.oSource.mProperties.value = "'" + date + "'";
761
- oEvt.oSource.mProperties.dateSelected = this._dateBusinessDataType;
762
- oEvt.oSource.mProperties.forceFireChange = true;
763
- that._reference(oEvt);
764
- that._setModal(false);
765
- that._oSelectNewDateDialog.close();
766
- }.bind(this)
767
- }),
768
- endButton: new Button({
769
- text: this.oBundle.getText("clsBtn"),
770
- press: function () {
771
- that._setModal(false);
772
- that._oSelectNewDateDialog.close();
773
- }.bind(this)
774
- })
775
- });
776
- this._dialogOpenedCallbackReference(true);
777
- this._setModal(true);
778
- this._oSelectNewDateDialog.open();
779
-
780
- },
781
-
782
- // Utility function to format date and timestamp
783
- _updateText: function (oCalendar) {
784
- var aSelectedDates = oCalendar._getInputValue();
785
- var formattedDate = this._getValidValue(aSelectedDates);
786
- return formattedDate; //aSelectedDates;//formattedDate;
787
- },
788
-
789
- _getValidValue: function (sValue) {
790
- var date, formatter;
791
- var sDateFormatted = "";
792
- if (this.dateContext) {
793
- this._dateBusinessDataType = this.dateContext;
794
- }
795
- var formatterParsing = this._getDateTimeFormatterForParsing();
796
- if (formatterParsing) {
797
- date = formatterParsing.parse(sValue);
798
- }
799
- if (this._dateBusinessDataType === "D") {
800
- formatter = sap.ui.core.format.DateFormat.getDateInstance({
801
- pattern: "yyyy-MM-dd"
802
- });
803
- sDateFormatted = formatter.format(date);
804
- } else if (this._dateBusinessDataType === "U") {
805
- formatter = sap.ui.core.format.DateFormat.getDateTimeInstance({
806
- pattern: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
807
- });
808
- sDateFormatted = formatter.format(date);
809
- }
810
- if (sDateFormatted !== "") {
811
- return sDateFormatted;
812
- }
813
- return sValue;
814
- },
815
-
816
- _getDateTimeFormatterForParsing: function () {
817
- var formatter;
818
- var oLocale = sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale();
819
- var oLocaleData = LocaleData.getInstance(oLocale);
820
- var datePattern = oLocaleData.getDatePattern('medium');
821
- var timePattern = oLocaleData.getTimePattern('medium');
822
- if (this.dateContext === "D") {
823
- formatter = sap.ui.core.format.DateFormat.getDateInstance({
824
- pattern: datePattern
825
- });
826
- } else if (this.dateContext === "U") {
827
- formatter = sap.ui.core.format.DateFormat.getDateTimeInstance({
828
- pattern: datePattern + " " + timePattern
829
- });
830
- }
831
- return formatter;
832
- }
833
-
834
-
835
- });
836
-
837
- return autoSuggestionFixedValuePanel;
838
- }, /* bExport= */ true);
1
+ sap.ui.define([
2
+ "sap/ui/thirdparty/jquery",
3
+ "../../library",
4
+ "sap/ui/core/Control",
5
+ "sap/m/List",
6
+ "sap/ui/model/json/JSONModel",
7
+ "sap/m/ListMode",
8
+ "sap/ui/core/CustomData",
9
+ "sap/ui/model/Sorter",
10
+ "sap/rules/ui/parser/infrastructure/util/utilsBase",
11
+ "sap/ui/core/LocaleData",
12
+ "sap/rules/ui/Constants",
13
+ "sap/m/DatePicker",
14
+ "sap/m/DateTimePicker",
15
+ "sap/m/TimePicker",
16
+ "sap/m/Dialog",
17
+ "sap/m/Button",
18
+ "./AutoSuggestionFixedValuePanelRenderer"
19
+ ], function (jQuery, library, Control, List, JSONModel, ListMode, CustomData, Sorter, infraUtils,
20
+ LocaleData, Constants, DatePicker , DateTimePicker , TimePicker, Dialog, Button, AutoSuggestionFixedValuePanelRenderer) {
21
+ "use strict";
22
+
23
+ var autoSuggestionFixedValuePanel = Control.extend("sap.rules.ui.ast.autoCompleteContent.AutoSuggestionFixedValuePanel", {
24
+ metadata: {
25
+ library: "sap.rules.ui",
26
+ properties: {
27
+ reference: {
28
+ type: "object",
29
+ defaultValue: null,
30
+ },
31
+ vocabularyInfo: {
32
+ type: "object",
33
+ defaultValue: null
34
+ },
35
+ data: {
36
+ type: "object",
37
+ defaultValue: null
38
+ },
39
+ dialogOpenedCallbackReference: {
40
+ type: "object",
41
+ defaultValue: null,
42
+ },
43
+ inputValue: {
44
+ type: "string",
45
+ defaultValue: ""
46
+ }
47
+
48
+ },
49
+ aggregations: {
50
+ PanelLayout: {
51
+ type: "sap.m.Panel",
52
+ multiple: false
53
+ }
54
+ },
55
+ events: {}
56
+ },
57
+
58
+ init: function () {
59
+ this.infraUtils = new sap.rules.ui.parser.infrastructure.util.utilsBase.utilsBaseLib();
60
+ this.needCreateLayout = true;
61
+ this.businessDataType = "S";
62
+ this._propertyValue = "Value";
63
+ this._propertyDescription = "Description";
64
+ this.oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.rules.ui.i18n");
65
+ this.vocabularyInfo = this.getVocabularyInfo();
66
+ this.autoSuggestionData = this.getData();
67
+
68
+ // Date instance which is used to convert the selected date from calendar control to short format
69
+ var oLocale = sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale();
70
+ var oLocaleData = LocaleData.getInstance(oLocale);
71
+
72
+ this.oFormatDate = sap.ui.core.format.DateFormat.getInstance({
73
+ pattern: oLocaleData.getDatePattern('short'),
74
+ calendarType: sap.ui.core.CalendarType.Gregorian
75
+ },
76
+ oLocale
77
+ );
78
+ },
79
+ onBeforeRendering: function () {
80
+ this._reference = this.getReference();
81
+ this._dialogOpenedCallbackReference = this.getDialogOpenedCallbackReference();
82
+ this.vocabularyInfo = this.getVocabularyInfo();
83
+ this.valueHelpData = this.getData();
84
+ if (this.needCreateLayout) {
85
+ var layout = this._createLayout(this.vocabularyInfo);
86
+ this.setAggregation("PanelLayout", layout, true);
87
+ this.needCreateLayout = false;
88
+ }
89
+ },
90
+
91
+ onAfterRendering: function () {
92
+ var sId = "#" + this.fixedValueTextArea.getId();
93
+ $(sId).on('keydown', function (event) {
94
+ if (event.key == 'Enter') {
95
+ event.preventDefault();
96
+ }
97
+ });
98
+ },
99
+
100
+ initializeVariables: function () {
101
+
102
+ },
103
+
104
+ _createLayout: function (vocabularyInfo) {
105
+ var that = this;
106
+ var hasValueSource = false;
107
+ if (this.getData().valuehelp) {
108
+ hasValueSource = true;
109
+ } else {
110
+ hasValueSource = false;
111
+ }
112
+ //The invisible text is introduced to identify the input field by screen reader.
113
+ this._invisibleText = new sap.ui.core.InvisibleText({
114
+ text:this.oBundle.getText("fixedValueInvisibleText")
115
+ });
116
+ this.fixedValueTextArea = new sap.m.Input({
117
+ showValueHelp: hasValueSource,
118
+ showSuggestion: true,
119
+ autocomplete: false,
120
+ ariaLabelledBy: this._invisibleText.getId(),
121
+ valueHelpRequest: function () {
122
+ that._dialogOpenedCallbackReference(true);
123
+ that._setModal(true);
124
+ that._generateValueHelpInfoAndCreateDialog(vocabularyInfo)
125
+ },
126
+ value: this.getInputValue(),
127
+ change: function (event) {
128
+ that._setModal(false);
129
+ var oEvent = that._formatText(event);
130
+ oEvent.oSource.mProperties.forceFireChange = true;
131
+ that._reference(oEvent);
132
+ }.bind(this),
133
+ width: "auto"
134
+ });
135
+
136
+ var fixedValuePanel = new sap.m.Panel({
137
+ headerText: this.oBundle.getText("fixedValuePanelTitle"),
138
+ expandable: true,
139
+ expanded: false,
140
+ content: [this._invisibleText, this.fixedValueTextArea],
141
+ width: "auto"
142
+ })
143
+
144
+ this.toolBarSpacerAfterInput = new sap.m.ToolbarSpacer({width: "1em"});
145
+ this.toolBarSpacerAfterDateLink = new sap.m.ToolbarSpacer({width: "1em"});
146
+ this.dateContent = this._createDateLink();
147
+ this.timeContent = this._createTimeStampLink();
148
+ fixedValuePanel.addContent(this.toolBarSpacerAfterInput);
149
+ fixedValuePanel.addContent(this.dateContent);
150
+ fixedValuePanel.addContent(this.toolBarSpacerAfterDateLink);
151
+ fixedValuePanel.addContent(this.timeContent);
152
+
153
+ return fixedValuePanel;
154
+ },
155
+
156
+ _setModal: function (value) {
157
+ var pop = sap.ui.getCore().byId("popover");
158
+ if (pop) {
159
+ pop.setModal(value);
160
+ }
161
+ },
162
+
163
+ /* ------------------ Value Help related functions ---------------------------*/
164
+ _generateValueHelpInfoAndCreateDialog: function (vocabularyInfo) {
165
+ var that = this;
166
+ var valueHelpInfo = this.getData().valuehelp;
167
+ if (valueHelpInfo) {
168
+ valueHelpInfo.expressionLanguage = vocabularyInfo;
169
+ valueHelpInfo.HasValueSource = true;
170
+ if (valueHelpInfo.sourceType === "U") {
171
+ valueHelpInfo.entitySet = "Enumerations";
172
+ valueHelpInfo.serviceURL = "/Enumerations";
173
+ } else {
174
+ valueHelpInfo.entitySet = "ExternalValues";
175
+ valueHelpInfo.serviceURL = "/ExternalValues";
176
+ }
177
+
178
+ var basePath = vocabularyInfo.getModel().sServiceUrl;
179
+ that._createDialog(basePath, valueHelpInfo);
180
+ }
181
+ },
182
+
183
+ _createDialog: function (basePath, valueHelpInfo, businessDataType) {
184
+ this._createValueHelpDialog(basePath, valueHelpInfo);
185
+ this._createSmartFilterBar(basePath, valueHelpInfo);
186
+ this.oValueHelpDialog.setFilterBar(this.oFilterBar);
187
+ this._openValueHelpDialog();
188
+
189
+ },
190
+
191
+ _openValueHelpDialog: function () {
192
+ this.oValueHelpDialog.open();
193
+ this.oValueHelpDialog.getTable().setBusy(true);
194
+ },
195
+
196
+ /*
197
+ * Creates the Value Help Dialog.
198
+ */
199
+
200
+ _createValueHelpDialog: function (basePath, valueHelpInfo) {
201
+ var that = this;
202
+ var expressionData = valueHelpInfo.expressionLanguage.getModel();
203
+ var attributePath = "Attributes(Id='" + valueHelpInfo.attributeId + "',VocabularyId='" + valueHelpInfo.vocabularyId +
204
+ "',DataObjectId='" + valueHelpInfo.dataObjectId + "')";
205
+ if(attributePath.includes(":")) {
206
+ attributePath = attributePath = attributePath.replace(":","%3A");
207
+ }
208
+ this.attributeName = valueHelpInfo.attributeName;
209
+ if(!expressionData.oData[attributePath]){
210
+ valueHelpInfo.dataObjectId = this._getStructureObjectForTableType(valueHelpInfo.attributeId, valueHelpInfo);
211
+ }
212
+ sap.ui.core.BusyIndicator.show(0);
213
+ this.oValueHelpDialog = new sap.ui.comp.valuehelpdialog.ValueHelpDialog({
214
+ supportMultiselect: false,
215
+ supportRanges: false,
216
+ horizontalScrolling: false,
217
+ title: that.attributeName,
218
+ resizable: false,
219
+ beforeOpen: function () {
220
+ that._bindTable(basePath, valueHelpInfo);
221
+ },
222
+ ok: function (oEvt) {
223
+ var oSelRow = oEvt.getParameter("tokens")[0].data("row");
224
+ var value = oSelRow.Value;
225
+ if (that.businessDataType === "D" || that.businessDataType === "U") {
226
+ value = that._getValidValue(value);
227
+ }
228
+ var updatedToken = this._syncToken(value, that.businessDataType);
229
+ oEvt.getParameter("tokens")[0].data("row").Value = updatedToken;
230
+ oEvt.oSource.mProperties.forceFireChange = true;
231
+ that._dialogOpenedCallbackReference(false);
232
+ that.oValueHelpDialog.close();
233
+ that._setModal(false);
234
+ that.oValueHelpDialog.destroy();
235
+ sap.ui.core.BusyIndicator.hide();
236
+ that._reference(oEvt);
237
+ }.bind(this),
238
+ cancel: function () {
239
+ that.oFilterBar.destroy();
240
+ that._setModal(false);
241
+ that.oValueHelpDialog.close();
242
+ that.oValueHelpDialog.destroy();
243
+ sap.ui.core.BusyIndicator.hide();
244
+ },
245
+ afterClose: function () {
246
+ that._dialogOpenedCallbackReference(false);
247
+ that.oFilterBar.destroy();
248
+ sap.ui.core.BusyIndicator.hide();
249
+ }
250
+ });
251
+ },
252
+
253
+ _getStructureObjectForTableType: function(attributeId, valueHelpInfo){
254
+ var valueSources = valueHelpInfo.expressionLanguage.getData().ValueSources;
255
+ for(var entry in valueSources){
256
+ if(attributeId === valueSources[entry].AttributeId){
257
+ return valueSources[entry].DataObjectId;
258
+ }
259
+ }
260
+ return valueHelpInfo.dataObjectId;
261
+ },
262
+
263
+ _syncToken: function (textEntered, businessDataType) {
264
+ var addStartQuote = false;
265
+ var addEndQuote = false;
266
+ businessDataType = this.getData().valuehelp.attributeDataType;
267
+ //truncate single and double quotes if the user has entered it
268
+ if (businessDataType != "G") {
269
+ var newValue = textEntered.replace(/'/g, "").replace(/"/g, "");
270
+ } else {
271
+ newValue = "'" + textEntered + "'";
272
+ }
273
+
274
+ //Handling for passing number when no context is available
275
+ if (businessDataType === "N") {
276
+ var newIntValue = parseFloat(newValue);
277
+ var stringFormOfIntValue = newIntValue.toString();
278
+ // Some text is truncated by parse int
279
+ if (stringFormOfIntValue != newValue) {
280
+ businessDataType = "Operations"
281
+ } else if (stringFormOfIntValue === "NaN") {
282
+ businessDataType = "S"
283
+ } else {
284
+ newValue = newIntValue;
285
+ }
286
+
287
+ }
288
+
289
+ if (businessDataType === "S" || businessDataType === "D" || businessDataType === "U") {
290
+ if (!(businessDataType === "S")) {
291
+ if (businessDataType === "D") {
292
+ this._dateBusinessDataType = "D";
293
+ } else if (businessDataType === "U") {
294
+ this._dateBusinessDataType = "U";
295
+ }
296
+ newValue = this._getValidDateValue(newValue);
297
+ }
298
+
299
+ newValue = newValue.toString();
300
+ if (newValue === "'") {
301
+ addStartQuote = true;
302
+ } // add only quote for this special case
303
+ if (newValue.substr(0, "'") !== "'") {
304
+ addStartQuote = true;
305
+ }
306
+ if (newValue.substr(newValue.length - 1, "'") !== "'") {
307
+ addEndQuote = true;
308
+ }
309
+
310
+ if (addStartQuote) {
311
+ newValue = "'" + newValue;
312
+ }
313
+ if (addEndQuote) {
314
+ newValue = newValue + "'";
315
+ }
316
+
317
+ }
318
+
319
+ if (businessDataType === "B") {
320
+ newValue = (newValue === "true");
321
+ }
322
+ return newValue;
323
+ },
324
+
325
+ _getValidDateValue: function (sValue) {
326
+ var date, formatter;
327
+ var sDateFormatted = "";
328
+ var formatterParsing = this._getDateTimeFormatterForParsing();
329
+ if (formatterParsing) {
330
+ date = formatterParsing.parse(sValue);
331
+ }
332
+ if (this._dateBusinessDataType === "D") {
333
+ formatter = sap.ui.core.format.DateFormat.getDateInstance({
334
+ pattern: "yyyy-MM-dd"
335
+ });
336
+ sDateFormatted = formatter.format(date);
337
+ } else if (this._dateBusinessDataType === "U") {
338
+ formatter = sap.ui.core.format.DateFormat.getDateTimeInstance({
339
+ pattern: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
340
+ });
341
+ sDateFormatted = formatter.format(date);
342
+ }
343
+ if (sDateFormatted !== "") {
344
+ sDateFormatted;
345
+ }
346
+ return sValue;
347
+ },
348
+
349
+ /*
350
+ * Creates the necessary control os SmartFilterBar for the ValueHelp Dialog.
351
+ */
352
+ _createSmartFilterBar: function (basePath, valueHelpInfo) {
353
+ var that = this;
354
+ this.oFilterBar = new sap.ui.comp.smartfilterbar.SmartFilterBar({
355
+ entitySet: valueHelpInfo.entitySet,
356
+ enableBasicSearch: true,
357
+ advancedMode: true,
358
+ filterBarExpanded: true,
359
+ search: function () {
360
+ that.onSearch(basePath, valueHelpInfo);
361
+
362
+ },
363
+ filterChange: function (oEvent) {
364
+ that.setValueStateFilter(oEvent);
365
+ },
366
+ controlConfiguration: [that._createControlConfiguration()]
367
+ });
368
+ var oModel = new sap.ui.model.odata.v2.ODataModel(basePath);
369
+ this.oFilterBar.setModel(oModel);
370
+ },
371
+
372
+ /*
373
+ * Creating the Control Configuration for the smartFilter of the valueHelp Dialog.
374
+ */
375
+ _createControlConfiguration: function () {
376
+ var aControlConfiguration = [new sap.ui.comp.smartfilterbar.ControlConfiguration({
377
+ hasValueHelpDialog: true,
378
+ key: "Value",
379
+ label: this.oBundle.getText("value"),
380
+ visibleInAdvancedArea: true,
381
+ width: "100px",
382
+ index: 1
383
+
384
+ }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
385
+ hasValueHelpDialog: true,
386
+ key: "Description",
387
+ label: this.oBundle.getText("description"),
388
+ visibleInAdvancedArea: true,
389
+ width: "100px",
390
+ index: 2
391
+
392
+ }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
393
+ hasValueHelpDialog: true,
394
+ key: "VocabularyId",
395
+ label: "VocabularyId",
396
+ width: "100px",
397
+ visible: false,
398
+ index: 3
399
+
400
+ }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
401
+ hasValueHelpDialog: true,
402
+ key: "DataObjectId",
403
+ label: "DataObjectId",
404
+ visible: false,
405
+ width: "100px",
406
+ groupId: "abc",
407
+ index: 4
408
+
409
+ }), new sap.ui.comp.smartfilterbar.ControlConfiguration({
410
+ hasValueHelpDialog: true,
411
+ key: "AttributeId",
412
+ label: "AttributeId",
413
+ visible: false,
414
+ width: "100px",
415
+ index: 5
416
+
417
+ }),
418
+ new sap.ui.comp.smartfilterbar.ControlConfiguration({
419
+ hasValueHelpDialog: true,
420
+ key: "Version",
421
+ label: "Version",
422
+ visible: false,
423
+ width: "100px",
424
+ index: 6
425
+
426
+ })
427
+ ];
428
+ return aControlConfiguration;
429
+ },
430
+
431
+ /*
432
+ * Called when the search is triggered in SmartFilter.
433
+ */
434
+ onSearch: function (basePath, valueHelpInfo) {
435
+ this.oValueHelpDialog.getTable().setBusy(true);
436
+ this._unBindTable();
437
+ this._bindTable(basePath, valueHelpInfo);
438
+ },
439
+
440
+ /*
441
+ * Binds the table taking current filters parameters into account.
442
+ */
443
+ _bindTable: function (basePath, valueHelpInfo) {
444
+ var serviceUrl = valueHelpInfo.serviceURL;
445
+ var aFilterParams = this._fetchFilterParams(valueHelpInfo);
446
+ var mEntities = {
447
+ valueHelp: {
448
+ collection: serviceUrl,
449
+ properties: [this._propertyValue, this._propertyDescription]
450
+ }
451
+ };
452
+
453
+ var oTable = this.oValueHelpDialog.getTable();
454
+ oTable.setThreshold(10);
455
+
456
+ for (var i = 0; i < mEntities.valueHelp.properties.length; i++) {
457
+ var sColumnName = "";
458
+ if (mEntities.valueHelp.properties[i] === "Value") {
459
+ sColumnName = this.oBundle.getText("value");
460
+ } else if(mEntities.valueHelp.properties[i] === "Description") {
461
+ sColumnName = this.oBundle.getText("description");
462
+ }
463
+ this._addValueHelpColumn(mEntities.valueHelp.properties[i], oTable, sColumnName);
464
+ }
465
+
466
+ var oModel = new sap.ui.model.odata.v2.ODataModel(basePath);
467
+ oTable.setModel(oModel);
468
+ oTable.bindRows(mEntities.valueHelp.collection, null, aFilterParams);
469
+ oTable.getBinding("rows").attachDataReceived(this._handleRowsDataReceived, this);
470
+ },
471
+
472
+ //handles the Busy State of the busy state for the data recieved.
473
+ _handleRowsDataReceived: function (oEvent) {
474
+ var that = this;
475
+ var data = oEvent.getParameter("data");
476
+ if (jQuery.isEmptyObject(data) || (data && data.results && data.results.length === 0)) {
477
+ this.oValueHelpDialog.getTable().setNoData(that.oBundle.getText("no_data"));
478
+ } else {
479
+ this.oValueHelpDialog.getTable().setNoData(that.oBundle.getText("searching"));
480
+ }
481
+ this.oValueHelpDialog.getTable().setBusy(false);
482
+ },
483
+
484
+ // Utility function to create columns for the table.
485
+ _addValueHelpColumn: function (oColumName, oTable, sColumnName) {
486
+ var oColumn = new sap.ui.table.Column().setLabel(new sap.m.Label({
487
+ text: sColumnName
488
+ }));
489
+ if (oColumName === this._propertyValue) {
490
+ oColumn.setSortProperty(sColumnName);
491
+ }
492
+ oTable.addColumn(oColumn.setTemplate(new sap.m.Text().bindProperty("text", oColumName)));
493
+ },
494
+
495
+ /*
496
+ * unBind the table Rows.
497
+ */
498
+ _unBindTable: function () {
499
+ var oTable = this.oValueHelpDialog.getTable();
500
+ oTable.destroyColumns();
501
+ oTable.unbindRows();
502
+
503
+ },
504
+
505
+ /*
506
+ * fetch the latest filter parmas depending on the filter or the search param set.
507
+ */
508
+ _fetchFilterParams: function (valueHelpInfo) {
509
+ var that = this;
510
+ var aSearchParams = [];
511
+ var aFilterParams = [new sap.ui.model.Filter("AttributeId", sap.ui.model.FilterOperator.EQ, valueHelpInfo.attributeId),
512
+ new sap.ui.model.Filter("DataObjectId", sap.ui.model.FilterOperator.EQ, valueHelpInfo.dataObjectId),
513
+ new sap.ui.model.Filter("VocabularyId", sap.ui.model.FilterOperator.EQ, valueHelpInfo.vocabularyId)
514
+ ];
515
+
516
+ var aFilters = this.oFilterBar.getFilters();
517
+ var searchParam = this.oFilterBar.getParameters();
518
+ //When both search and filter is selected
519
+ if (!jQuery.isEmptyObject(searchParam) && aFilters && aFilters.length > 0) {
520
+ searchParam = this.oFilterBar.getParameters().custom.search;
521
+ aSearchParams = this._getSearchFilters(searchParam);
522
+ aFilters = that._formatFilterParams(aFilters, valueHelpInfo.sourceType);
523
+ aFilterParams.push(new sap.ui.model.Filter({
524
+ filters: [new sap.ui.model.Filter(aFilters), new sap.ui.model.Filter(aSearchParams)],
525
+ and: true
526
+ }));
527
+ } else if (!jQuery.isEmptyObject(searchParam)) {
528
+ //when only Search is selected.
529
+ searchParam = this.oFilterBar.getParameters().custom.search;
530
+ aSearchParams = this._getSearchFilters(searchParam);
531
+ aFilterParams.push(aSearchParams);
532
+ } else if (aFilters && aFilters.length > 0) {
533
+ //When only filters is selected.
534
+ aFilters = that._formatFilterParams(aFilters, valueHelpInfo.sourceType);
535
+ aFilterParams.push(aFilters[0]);
536
+ }
537
+ return aFilterParams;
538
+ },
539
+
540
+ /*
541
+ * format the filterParams to support Contains and Between.
542
+ */
543
+ _formatFilterParams: function (aFilters, valuehelpSourceType) {
544
+ var that = this;
545
+ if (aFilters[0] && aFilters.length === 1 && aFilters[0].aFilters[0] && aFilters[0].aFilters[0].sOperator) {
546
+ aFilters = that._formatSingleFilter(aFilters, valuehelpSourceType);
547
+ } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[0].aFilters[0] && aFilters[0].aFilters[0].aFilters[0].aFilters &&
548
+ aFilters[0].aFilters[1].aFilters[0].aFilters) {
549
+ aFilters = that._formatMultiFilter(aFilters, 0, true, valuehelpSourceType);
550
+ aFilters = that._formatMultiFilter(aFilters, 1, true, valuehelpSourceType);
551
+
552
+ } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[1] && aFilters[0].aFilters[0].aFilters[0] && aFilters[0].aFilters[
553
+ 0].aFilters[0].aFilters && aFilters[0].aFilters[1].aFilters) {
554
+ aFilters = that._formatMultiFilter(aFilters, 0, true, valuehelpSourceType);
555
+ aFilters = that._formatMultiFilter(aFilters, 1, false, valuehelpSourceType);
556
+
557
+ } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[1] && aFilters[0].aFilters[1].aFilters[0] && aFilters[0].aFilters[
558
+ 0].aFilters && aFilters[0].aFilters[1].aFilters[0].aFilters) {
559
+ aFilters = that._formatMultiFilter(aFilters, 0, false, valuehelpSourceType);
560
+ aFilters = that._formatMultiFilter(aFilters, 1, true, valuehelpSourceType);
561
+
562
+ } else if (aFilters[0] && aFilters[0].aFilters[0] && aFilters[0].aFilters[1] && aFilters[0].aFilters[0].aFilters && aFilters[0].aFilters[
563
+ 1].aFilters) {
564
+ aFilters = that._formatMultiFilter(aFilters, 0, false, valuehelpSourceType);
565
+ aFilters = that._formatMultiFilter(aFilters, 1, false, valuehelpSourceType);
566
+
567
+ }
568
+
569
+ return aFilters;
570
+ },
571
+
572
+ _formatSingleFilter: function (aFilters, valuehelpSourceType) {
573
+ var that = this;
574
+ var _valueField = null;
575
+
576
+ for (var iterator = 0; iterator < aFilters[0].aFilters.length; iterator++) {
577
+ if (aFilters[0].aFilters[iterator].sOperator === "Contains" && valuehelpSourceType === "U") {
578
+ aFilters[0].aFilters[iterator].sOperator = "EQ";
579
+ } else if (aFilters[0].aFilters[iterator].sOperator === "Contains") {
580
+ _valueField = (aFilters[0].aFilters[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
581
+ _valueField.setValueState("Error");
582
+ _valueField.setValueStateText(aFilters[0].aFilters[iterator].sOperator + " operator not supported");
583
+ } else if (aFilters[0].aFilters[iterator].sOperator === "BT") {
584
+
585
+ var convertedFilterParam = that._manageParam(aFilters[0].aFilters[iterator].sPath, aFilters[0].aFilters[iterator].sOperator,
586
+ aFilters[0].aFilters[iterator].oValue1, aFilters[0].aFilters[iterator].oValue2);
587
+ delete aFilters[0].aFilters[iterator];
588
+ aFilters[0].aFilters[iterator] = convertedFilterParam;
589
+ } else if (aFilters[0].aFilters[iterator].sOperator === "StartsWith") {
590
+ _valueField = (aFilters[0].aFilters[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
591
+ _valueField.setValueState("Error");
592
+ _valueField.setValueStateText(aFilters[0].aFilters[iterator].sOperator + " operator not supported");
593
+ } else if (aFilters[0].aFilters[iterator].sOperator === "EndsWith") {
594
+ _valueField = (aFilters[0].aFilters[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
595
+ _valueField.setValueState("Error");
596
+ _valueField.setValueStateText(aFilters[0].aFilters[iterator].sOperator + " operator not supported");
597
+ }
598
+
599
+ }
600
+ return aFilters;
601
+
602
+ },
603
+
604
+ _formatMultiFilter: function (aFilters, index, bMultifilter, valuehelpSourceType) {
605
+ var that = this;
606
+ var _valueField = null;
607
+ var aComputeFilterParma = [];
608
+ if (bMultifilter) {
609
+ aComputeFilterParma = aFilters[0].aFilters[index].aFilters[0].aFilters;
610
+ } else {
611
+ aComputeFilterParma = aFilters[0].aFilters[index].aFilters;
612
+ }
613
+ for (var iterator = 0; iterator < aComputeFilterParma.length; iterator++) {
614
+ if (aComputeFilterParma[iterator].sOperator === "Contains" && valuehelpSourceType === "U") {
615
+ aComputeFilterParma[iterator].sOperator = "EQ";
616
+ } else if (aComputeFilterParma[iterator].sOperator === "Contains") {
617
+ _valueField = (aComputeFilterParma[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
618
+ _valueField.setValueState("Error");
619
+ _valueField.setValueStateText(aComputeFilterParma[iterator].sOperator + " operator not supported");
620
+ } else if (aComputeFilterParma[iterator].sOperator === "BT") {
621
+
622
+ var convertedFilterParam = that._manageParam(aComputeFilterParma[iterator].sPath, aComputeFilterParma[iterator].sOperator,
623
+ aComputeFilterParma[iterator].oValue1, aComputeFilterParma[iterator].oValue2);
624
+ delete aComputeFilterParma[iterator];
625
+ aComputeFilterParma[iterator] = convertedFilterParam;
626
+
627
+ } else if (aComputeFilterParma[iterator].sOperator === "StartsWith") {
628
+ _valueField = (aComputeFilterParma[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
629
+ _valueField.setValueState("Error");
630
+ _valueField.setValueStateText(aComputeFilterParma[iterator].sOperator + " operator not supported");
631
+ } else if (aComputeFilterParma[iterator].sOperator === "EndsWith") {
632
+ _valueField = (aComputeFilterParma[iterator].sPath === this._propertyValue) ? this._valueFieldValue : this._valueFieldDescription;
633
+ _valueField.setValueState("Error");
634
+ _valueField.setValueStateText(aComputeFilterParma[iterator].sOperator + " operator not supported");
635
+ }
636
+ }
637
+ return aFilters;
638
+ },
639
+
640
+ /*
641
+ * Converts the Between Operator to Less than and Equal to Operator.
642
+ */
643
+ _manageParam: function (sPath, operator, value1, value2) {
644
+ var filterParam = [];
645
+ if (value1 && value2) {
646
+ filterParam = new sap.ui.model.Filter({
647
+ filters: [new sap.ui.model.Filter(sPath, sap.ui.model.FilterOperator.GT, value1),
648
+ new sap.ui.model.Filter(sPath, sap.ui.model.FilterOperator.LT, value2)
649
+ ],
650
+ and: true
651
+ });
652
+ }
653
+ return filterParam;
654
+ },
655
+
656
+ // Utility function to form the search filter params.
657
+ _getSearchFilters: function (searchParam) {
658
+ return new sap.ui.model.Filter({
659
+ filters: [new sap.ui.model.Filter(this._propertyValue, sap.ui.model.FilterOperator.EQ, searchParam),
660
+ new sap.ui.model.Filter(this._propertyDescription, sap.ui.model.FilterOperator.EQ, searchParam)
661
+ ],
662
+ and: false
663
+ });
664
+ },
665
+
666
+ setValueStateFilter: function (oEvent) {
667
+ var sId = oEvent.getSource().sId;
668
+ this._valueFieldValue = sap.ui.getCore().byId(sId + "-filterItemControlA_-Value");
669
+ if (this._valueFieldValue) {
670
+ this._valueFieldValue.setValueState("None");
671
+ this._valueFieldValue.setValueStateText("");
672
+ }
673
+ this._valueFieldDescription = sap.ui.getCore().byId(sId + "-filterItemControlA_-Description");
674
+ if (this._valueFieldDescription) {
675
+ this._valueFieldDescription.setValueState("None");
676
+ this._valueFieldDescription.setValueStateText("");
677
+ }
678
+ },
679
+
680
+ _formatText: function (oEvent) {
681
+ var that = this;
682
+ var businessDataTypeList = this.getData().businessDataTypeList;
683
+ if (businessDataTypeList && businessDataTypeList.length > 0) {
684
+ this.businessDataType = this.getData().businessDataTypeList[0];
685
+ } else {
686
+ this.businessDataType = "N"
687
+ }
688
+ var token = oEvent.getSource().getValue();
689
+ oEvent.getSource().setValue(token);
690
+ return oEvent;
691
+ },
692
+
693
+ /* ------------------------------- Date and Time related functions -------------------------- */
694
+ _createDateLink : function(){
695
+ var that = this;
696
+ this.dateContent = new sap.m.Link({
697
+ wrapping: true,
698
+ text: this.oBundle.getText("select_date"),
699
+ press: function (oEvent) {
700
+ that.dateContext = "D";
701
+ that._createDateTimeDialog();
702
+ }
703
+ });
704
+ return this.dateContent;
705
+ },
706
+
707
+ _createTimeStampLink : function() {
708
+ var that = this;
709
+ this.timeContent = new sap.m.Link({
710
+ wrapping: true,
711
+ text: this.oBundle.getText("select_date_time"),
712
+ press: function (oEvent) {
713
+ that.dateContext = "U";
714
+ that._createDateTimeDialog();
715
+ }
716
+ });
717
+ return this.timeContent;
718
+ },
719
+
720
+ //creates calender control
721
+ _createDateTimeDialog: function () {
722
+ var that = this;
723
+ var oLocale = sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale();
724
+ var oLocaleData = LocaleData.getInstance(oLocale);
725
+ var dateFormatted = oLocaleData.getDatePattern('medium');
726
+ var timeFormat = oLocaleData.getTimePattern('medium');
727
+ var sValueFormat = dateFormatted + " " + timeFormat;
728
+
729
+ if(this.dateContext){
730
+ this._dateBusinessDataType = this.dateContext;
731
+ }
732
+ if (this._dateBusinessDataType === "D") {
733
+ this.control = new DatePicker({
734
+ width: "auto",
735
+ valueFormat: dateFormatted
736
+ });
737
+ }
738
+
739
+ if (this._dateBusinessDataType === "U") {
740
+ var that = this;
741
+ this.control = new DateTimePicker({
742
+ width: "auto",
743
+ valueFormat: sValueFormat
744
+ });
745
+
746
+ }
747
+
748
+ this._oSelectNewDateDialog = new Dialog({
749
+ title: this.oBundle.getText("calendarTitle"),
750
+ afterClose: function () {
751
+ that._dialogOpenedCallbackReference(false);
752
+ },
753
+ content: [
754
+ this.control
755
+ ],
756
+ beginButton: new Button({
757
+ text: this.oBundle.getText("okBtn"),
758
+ enabled: true,
759
+ press: function (oEvt) {
760
+ var date = this._updateText(this.control);
761
+ oEvt.oSource.mProperties.value = "'" + date + "'";
762
+ oEvt.oSource.mProperties.dateSelected = this._dateBusinessDataType;
763
+ oEvt.oSource.mProperties.forceFireChange = true;
764
+ that._reference(oEvt);
765
+ that._setModal(false);
766
+ that._oSelectNewDateDialog.close();
767
+ }.bind(this)
768
+ }),
769
+ endButton: new Button({
770
+ text: this.oBundle.getText("clsBtn"),
771
+ press: function () {
772
+ that._setModal(false);
773
+ that._oSelectNewDateDialog.close();
774
+ }.bind(this)
775
+ })
776
+ });
777
+ this._dialogOpenedCallbackReference(true);
778
+ this._setModal(true);
779
+ this._oSelectNewDateDialog.open();
780
+
781
+ },
782
+
783
+ // Utility function to format date and timestamp
784
+ _updateText: function (oCalendar) {
785
+ var aSelectedDates = oCalendar._getInputValue();
786
+ var formattedDate = this._getValidValue(aSelectedDates);
787
+ return formattedDate; //aSelectedDates;//formattedDate;
788
+ },
789
+
790
+ _getValidValue: function (sValue) {
791
+ var date, formatter;
792
+ var sDateFormatted = "";
793
+ if (this.dateContext) {
794
+ this._dateBusinessDataType = this.dateContext;
795
+ }
796
+ var formatterParsing = this._getDateTimeFormatterForParsing();
797
+ if (formatterParsing) {
798
+ date = formatterParsing.parse(sValue);
799
+ }
800
+ if (this._dateBusinessDataType === "D") {
801
+ formatter = sap.ui.core.format.DateFormat.getDateInstance({
802
+ pattern: "yyyy-MM-dd"
803
+ });
804
+ sDateFormatted = formatter.format(date);
805
+ } else if (this._dateBusinessDataType === "U") {
806
+ formatter = sap.ui.core.format.DateFormat.getDateTimeInstance({
807
+ pattern: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
808
+ });
809
+ sDateFormatted = formatter.format(date);
810
+ }
811
+ if (sDateFormatted !== "") {
812
+ return sDateFormatted;
813
+ }
814
+ return sValue;
815
+ },
816
+
817
+ _getDateTimeFormatterForParsing: function () {
818
+ var formatter;
819
+ var oLocale = sap.ui.getCore().getConfiguration().getFormatSettings().getFormatLocale();
820
+ var oLocaleData = LocaleData.getInstance(oLocale);
821
+ var datePattern = oLocaleData.getDatePattern('medium');
822
+ var timePattern = oLocaleData.getTimePattern('medium');
823
+ if (this.dateContext === "D") {
824
+ formatter = sap.ui.core.format.DateFormat.getDateInstance({
825
+ pattern: datePattern
826
+ });
827
+ } else if (this.dateContext === "U") {
828
+ formatter = sap.ui.core.format.DateFormat.getDateTimeInstance({
829
+ pattern: datePattern + " " + timePattern
830
+ });
831
+ }
832
+ return formatter;
833
+ },
834
+ renderer: AutoSuggestionFixedValuePanelRenderer
835
+
836
+
837
+ });
838
+
839
+ return autoSuggestionFixedValuePanel;
840
+ }, /* bExport= */ true);