@openui5/sap.ui.mdc 1.110.0 → 1.111.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.
Files changed (202) hide show
  1. package/package.json +4 -4
  2. package/src/sap/ui/mdc/.library +1 -1
  3. package/src/sap/ui/mdc/ActionToolbar.js +1 -1
  4. package/src/sap/ui/mdc/AggregationBaseDelegate.js +20 -2
  5. package/src/sap/ui/mdc/Chart.js +121 -3
  6. package/src/sap/ui/mdc/ChartRenderer.js +9 -6
  7. package/src/sap/ui/mdc/Control.js +1 -1
  8. package/src/sap/ui/mdc/Element.js +1 -1
  9. package/src/sap/ui/mdc/Field.js +2 -2
  10. package/src/sap/ui/mdc/FilterBar.js +1 -1
  11. package/src/sap/ui/mdc/FilterBarDelegate.js +96 -4
  12. package/src/sap/ui/mdc/FilterField.js +2 -2
  13. package/src/sap/ui/mdc/Link.js +9 -2
  14. package/src/sap/ui/mdc/MultiValueField.js +1 -1
  15. package/src/sap/ui/mdc/Table.js +136 -74
  16. package/src/sap/ui/mdc/ValueHelp.js +7 -40
  17. package/src/sap/ui/mdc/actiontoolbar/ActionToolbarAction.js +1 -1
  18. package/src/sap/ui/mdc/chart/ChartImplementationContainer.js +1 -1
  19. package/src/sap/ui/mdc/chart/ChartImplementationContainerRenderer.js +1 -1
  20. package/src/sap/ui/mdc/chart/ChartSelectionDetails.js +1 -1
  21. package/src/sap/ui/mdc/chart/ChartSettings.js +7 -3
  22. package/src/sap/ui/mdc/chart/ChartToolbar.js +37 -6
  23. package/src/sap/ui/mdc/chart/PropertyHelper.js +1 -1
  24. package/src/sap/ui/mdc/condition/Condition.js +1 -1
  25. package/src/sap/ui/mdc/condition/ConditionConverter.js +1 -1
  26. package/src/sap/ui/mdc/condition/ConditionModel.js +1 -1
  27. package/src/sap/ui/mdc/condition/FilterConverter.js +1 -1
  28. package/src/sap/ui/mdc/condition/FilterOperatorUtil.js +2 -2
  29. package/src/sap/ui/mdc/condition/Operator.js +1 -1
  30. package/src/sap/ui/mdc/condition/OperatorDynamicDateOption.js +1 -1
  31. package/src/sap/ui/mdc/condition/RangeOperator.js +1 -1
  32. package/src/sap/ui/mdc/designtime/chart/Chart.designtime.js +3 -0
  33. package/src/sap/ui/mdc/designtime/table/Table.designtime.js +3 -1
  34. package/src/sap/ui/mdc/enum/FilterBarValidationStatus.js +56 -0
  35. package/src/sap/ui/mdc/enum/ReasonMode.js +53 -0
  36. package/src/sap/ui/mdc/field/ConditionType.js +19 -33
  37. package/src/sap/ui/mdc/field/ConditionsType.js +1 -3
  38. package/src/sap/ui/mdc/field/CustomFieldInfo.js +1 -1
  39. package/src/sap/ui/mdc/field/DefineConditionPanel.js +2 -4
  40. package/src/sap/ui/mdc/field/DynamicDateRangeConditionsType.js +1 -3
  41. package/src/sap/ui/mdc/field/FieldBase.js +60 -100
  42. package/src/sap/ui/mdc/field/FieldBaseDelegate.js +28 -69
  43. package/src/sap/ui/mdc/field/FieldInfoBase.js +1 -1
  44. package/src/sap/ui/mdc/field/FieldInput.js +1 -1
  45. package/src/sap/ui/mdc/field/FieldInputRenderUtil.js +1 -1
  46. package/src/sap/ui/mdc/field/FieldMultiInput.js +1 -1
  47. package/src/sap/ui/mdc/field/ListFieldHelpItem.js +1 -1
  48. package/src/sap/ui/mdc/field/MultiValueFieldItem.js +1 -1
  49. package/src/sap/ui/mdc/field/TokenDisplay.js +1 -1
  50. package/src/sap/ui/mdc/field/TokenizerDisplay.js +1 -1
  51. package/src/sap/ui/mdc/field/content/ContentFactory.js +66 -9
  52. package/src/sap/ui/mdc/field/content/DateContent.js +3 -2
  53. package/src/sap/ui/mdc/filterbar/FilterBarBase.js +172 -112
  54. package/src/sap/ui/mdc/filterbar/PropertyHelper.js +1 -1
  55. package/src/sap/ui/mdc/filterbar/p13n/AdaptationFilterBar.js +18 -3
  56. package/src/sap/ui/mdc/filterbar/vh/FilterBar.js +2 -2
  57. package/src/sap/ui/mdc/flexibility/AggregateFlex.js +16 -4
  58. package/src/sap/ui/mdc/flexibility/Chart.flexibility.js +1 -1
  59. package/src/sap/ui/mdc/flexibility/ChartTypeFlex.js +14 -3
  60. package/src/sap/ui/mdc/flexibility/ConditionFlex.js +17 -5
  61. package/src/sap/ui/mdc/flexibility/FilterBar.flexibility.js +1 -1
  62. package/src/sap/ui/mdc/flexibility/FilterItemFlex.js +1 -1
  63. package/src/sap/ui/mdc/flexibility/GroupFlex.js +9 -3
  64. package/src/sap/ui/mdc/flexibility/ItemBaseFlex.js +71 -8
  65. package/src/sap/ui/mdc/flexibility/SortFlex.js +10 -4
  66. package/src/sap/ui/mdc/flexibility/Util.js +5 -3
  67. package/src/sap/ui/mdc/flexibility/xConfigFlex.js +11 -3
  68. package/src/sap/ui/mdc/library.js +2 -18
  69. package/src/sap/ui/mdc/link/ContactDetails.js +1 -1
  70. package/src/sap/ui/mdc/link/ContactDetailsAddressItem.js +1 -1
  71. package/src/sap/ui/mdc/link/ContactDetailsEmailItem.js +1 -1
  72. package/src/sap/ui/mdc/link/ContactDetailsItem.js +1 -1
  73. package/src/sap/ui/mdc/link/ContactDetailsPhoneItem.js +1 -1
  74. package/src/sap/ui/mdc/link/Factory.js +1 -1
  75. package/src/sap/ui/mdc/link/FakeFlpConnector.js +1 -1
  76. package/src/sap/ui/mdc/link/LinkItem.js +1 -1
  77. package/src/sap/ui/mdc/link/Panel.js +1 -1
  78. package/src/sap/ui/mdc/link/PanelItem.js +1 -1
  79. package/src/sap/ui/mdc/link/SemanticObjectMapping.js +1 -1
  80. package/src/sap/ui/mdc/link/SemanticObjectMappingItem.js +1 -1
  81. package/src/sap/ui/mdc/link/SemanticObjectUnavailableAction.js +1 -1
  82. package/src/sap/ui/mdc/messagebundle.properties +7 -3
  83. package/src/sap/ui/mdc/messagebundle_ar.properties +5 -3
  84. package/src/sap/ui/mdc/messagebundle_bg.properties +5 -3
  85. package/src/sap/ui/mdc/messagebundle_ca.properties +5 -3
  86. package/src/sap/ui/mdc/messagebundle_cs.properties +5 -3
  87. package/src/sap/ui/mdc/messagebundle_cy.properties +5 -3
  88. package/src/sap/ui/mdc/messagebundle_da.properties +5 -3
  89. package/src/sap/ui/mdc/messagebundle_de.properties +5 -3
  90. package/src/sap/ui/mdc/messagebundle_el.properties +5 -3
  91. package/src/sap/ui/mdc/messagebundle_en.properties +5 -2
  92. package/src/sap/ui/mdc/messagebundle_en_GB.properties +5 -3
  93. package/src/sap/ui/mdc/messagebundle_en_US_sappsd.properties +5 -3
  94. package/src/sap/ui/mdc/messagebundle_en_US_saprigi.properties +12 -2
  95. package/src/sap/ui/mdc/messagebundle_en_US_saptrc.properties +5 -3
  96. package/src/sap/ui/mdc/messagebundle_es.properties +5 -3
  97. package/src/sap/ui/mdc/messagebundle_es_MX.properties +5 -3
  98. package/src/sap/ui/mdc/messagebundle_et.properties +5 -3
  99. package/src/sap/ui/mdc/messagebundle_fi.properties +5 -3
  100. package/src/sap/ui/mdc/messagebundle_fr.properties +6 -4
  101. package/src/sap/ui/mdc/messagebundle_fr_CA.properties +5 -3
  102. package/src/sap/ui/mdc/messagebundle_hi.properties +5 -3
  103. package/src/sap/ui/mdc/messagebundle_hr.properties +5 -3
  104. package/src/sap/ui/mdc/messagebundle_hu.properties +5 -3
  105. package/src/sap/ui/mdc/messagebundle_id.properties +5 -3
  106. package/src/sap/ui/mdc/messagebundle_it.properties +5 -3
  107. package/src/sap/ui/mdc/messagebundle_iw.properties +5 -3
  108. package/src/sap/ui/mdc/messagebundle_ja.properties +5 -3
  109. package/src/sap/ui/mdc/messagebundle_kk.properties +5 -3
  110. package/src/sap/ui/mdc/messagebundle_ko.properties +4 -2
  111. package/src/sap/ui/mdc/messagebundle_lt.properties +5 -3
  112. package/src/sap/ui/mdc/messagebundle_lv.properties +5 -3
  113. package/src/sap/ui/mdc/messagebundle_ms.properties +5 -3
  114. package/src/sap/ui/mdc/messagebundle_nl.properties +5 -3
  115. package/src/sap/ui/mdc/messagebundle_no.properties +5 -3
  116. package/src/sap/ui/mdc/messagebundle_pl.properties +5 -3
  117. package/src/sap/ui/mdc/messagebundle_pt.properties +5 -3
  118. package/src/sap/ui/mdc/messagebundle_pt_PT.properties +5 -3
  119. package/src/sap/ui/mdc/messagebundle_ro.properties +5 -3
  120. package/src/sap/ui/mdc/messagebundle_ru.properties +5 -3
  121. package/src/sap/ui/mdc/messagebundle_sh.properties +5 -3
  122. package/src/sap/ui/mdc/messagebundle_sk.properties +5 -3
  123. package/src/sap/ui/mdc/messagebundle_sl.properties +5 -3
  124. package/src/sap/ui/mdc/messagebundle_sv.properties +5 -3
  125. package/src/sap/ui/mdc/messagebundle_th.properties +5 -3
  126. package/src/sap/ui/mdc/messagebundle_tr.properties +5 -3
  127. package/src/sap/ui/mdc/messagebundle_uk.properties +5 -3
  128. package/src/sap/ui/mdc/messagebundle_vi.properties +5 -3
  129. package/src/sap/ui/mdc/messagebundle_zh_CN.properties +5 -3
  130. package/src/sap/ui/mdc/messagebundle_zh_TW.properties +5 -3
  131. package/src/sap/ui/mdc/mixin/AdaptationMixin.js +1 -1
  132. package/src/sap/ui/mdc/mixin/DelegateMixin.js +12 -1
  133. package/src/sap/ui/mdc/mixin/FilterIntegrationMixin.js +29 -3
  134. package/src/sap/ui/mdc/mixin/PromiseMixin.js +1 -1
  135. package/src/sap/ui/mdc/mixin/PropertyHelperMixin.js +96 -77
  136. package/src/sap/ui/mdc/odata/TypeUtil.js +1 -1
  137. package/src/sap/ui/mdc/odata/v4/FieldBaseDelegate.js +0 -32
  138. package/src/sap/ui/mdc/odata/v4/TableDelegate.js +3 -0
  139. package/src/sap/ui/mdc/odata/v4/TypeUtil.js +1 -1
  140. package/src/sap/ui/mdc/odata/v4/vizChart/ChartDelegate.js +6 -5
  141. package/src/sap/ui/mdc/p13n/Engine.js +1 -1
  142. package/src/sap/ui/mdc/p13n/PropertyHelper.js +1 -1
  143. package/src/sap/ui/mdc/p13n/UIManager.js +1 -1
  144. package/src/sap/ui/mdc/p13n/panels/FilterPanel.js +1 -1
  145. package/src/sap/ui/mdc/p13n/subcontroller/BaseController.js +1 -1
  146. package/src/sap/ui/mdc/table/Column.js +5 -2
  147. package/src/sap/ui/mdc/table/ColumnSettings.js +1 -1
  148. package/src/sap/ui/mdc/table/CreationRow.js +1 -1
  149. package/src/sap/ui/mdc/table/GridTableType.js +1 -16
  150. package/src/sap/ui/mdc/table/PropertyHelper.js +50 -12
  151. package/src/sap/ui/mdc/table/ResponsiveColumnSettings.js +1 -1
  152. package/src/sap/ui/mdc/table/ResponsiveTableType.js +1 -15
  153. package/src/sap/ui/mdc/table/RowActionItem.js +1 -1
  154. package/src/sap/ui/mdc/table/RowSettings.js +1 -1
  155. package/src/sap/ui/mdc/table/TableSettings.js +14 -13
  156. package/src/sap/ui/mdc/table/TreeTableType.js +2 -19
  157. package/src/sap/ui/mdc/table/V4AnalyticsPropertyHelper.js +34 -2
  158. package/src/sap/ui/mdc/themes/base/FieldBase.less +12 -25
  159. package/src/sap/ui/mdc/util/FilterUtil.js +24 -1
  160. package/src/sap/ui/mdc/util/InfoBar.js +118 -0
  161. package/src/sap/ui/mdc/util/InfoBarRenderer.js +35 -0
  162. package/src/sap/ui/mdc/util/PromiseCache.js +1 -1
  163. package/src/sap/ui/mdc/util/PropertyHelper.js +41 -41
  164. package/src/sap/ui/mdc/util/TypeUtil.js +3 -1
  165. package/src/sap/ui/mdc/valuehelp/Dialog.js +1 -1
  166. package/src/sap/ui/mdc/valuehelp/Popover.js +1 -1
  167. package/src/sap/ui/mdc/valuehelp/base/Container.js +1 -3
  168. package/src/sap/ui/mdc/valuehelp/base/Content.js +2 -4
  169. package/src/sap/ui/mdc/valuehelp/base/DialogTab.js +1 -1
  170. package/src/sap/ui/mdc/valuehelp/base/FilterableListContent.js +1 -1
  171. package/src/sap/ui/mdc/valuehelp/base/ListContent.js +2 -23
  172. package/src/sap/ui/mdc/valuehelp/content/Bool.js +1 -1
  173. package/src/sap/ui/mdc/valuehelp/content/Conditions.js +1 -1
  174. package/src/sap/ui/mdc/valuehelp/content/FixedList.js +1 -1
  175. package/src/sap/ui/mdc/valuehelp/content/MDCTable.js +19 -21
  176. package/src/sap/ui/mdc/valuehelp/content/MTable.js +1 -1
  177. package/test/sap/ui/mdc/testutils/opa/field/Actions.js +4 -2
  178. package/test/sap/ui/mdc/testutils/opa/filterfield/Actions.js +4 -2
  179. package/test/sap/ui/mdc/testutils/opa/filterfield/TestObjects.js +0 -11
  180. package/test/sap/ui/mdc/testutils/opa/valueHelp/Assertions.js +16 -0
  181. package/test/sap/ui/mdc/testutils/opa/valueHelp/JSDoc.md +98 -9
  182. package/test/sap/ui/mdc/testutils/opa/valueHelp/TestObjects.js +85 -0
  183. package/test/sap/ui/mdc/testutils/opa/valueHelp/doWait.js +2 -2
  184. package/src/sap/ui/mdc/enum/OutParameterMode.js +0 -39
  185. package/src/sap/ui/mdc/field/BoolFieldHelp.js +0 -437
  186. package/src/sap/ui/mdc/field/ConditionFieldHelp.js +0 -325
  187. package/src/sap/ui/mdc/field/CustomFieldHelp.js +0 -101
  188. package/src/sap/ui/mdc/field/FieldHelpBase.js +0 -1517
  189. package/src/sap/ui/mdc/field/FieldHelpBaseDelegate.js +0 -55
  190. package/src/sap/ui/mdc/field/FieldValueHelp.js +0 -2834
  191. package/src/sap/ui/mdc/field/FieldValueHelpContentWrapperBase.js +0 -525
  192. package/src/sap/ui/mdc/field/FieldValueHelpDelegate.js +0 -171
  193. package/src/sap/ui/mdc/field/FieldValueHelpMTableWrapper.js +0 -359
  194. package/src/sap/ui/mdc/field/FieldValueHelpMdcTableWrapper.js +0 -416
  195. package/src/sap/ui/mdc/field/FieldValueHelpTableWrapperBase.js +0 -977
  196. package/src/sap/ui/mdc/field/FieldValueHelpUITableWrapper.js +0 -329
  197. package/src/sap/ui/mdc/field/InParameter.js +0 -229
  198. package/src/sap/ui/mdc/field/ListFieldHelp.js +0 -620
  199. package/src/sap/ui/mdc/field/OutParameter.js +0 -75
  200. package/src/sap/ui/mdc/field/ValueHelpPanel.control.xml +0 -71
  201. package/src/sap/ui/mdc/field/ValueHelpPanel.js +0 -525
  202. package/src/sap/ui/mdc/odata/v4/FieldValueHelpDelegate.js +0 -125
@@ -1,2834 +0,0 @@
1
- /*!
2
- * OpenUI5
3
- * (c) Copyright 2009-2023 SAP SE or an SAP affiliate company.
4
- * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
- */
6
-
7
- sap.ui.define([
8
- 'sap/ui/mdc/field/FieldHelpBase',
9
- 'sap/ui/mdc/condition/Condition',
10
- 'sap/ui/mdc/condition/FilterOperatorUtil',
11
- 'sap/ui/mdc/enum/OutParameterMode',
12
- 'sap/ui/mdc/enum/ConditionValidated',
13
- 'sap/ui/mdc/condition/FilterConverter',
14
- 'sap/ui/base/ManagedObjectObserver',
15
- 'sap/ui/base/SyncPromise',
16
- 'sap/base/util/ObjectPath',
17
- 'sap/base/util/deepEqual',
18
- 'sap/base/util/merge',
19
- 'sap/ui/model/resource/ResourceModel',
20
- 'sap/ui/model/Context',
21
- 'sap/ui/Device',
22
- 'sap/m/library',
23
- 'sap/m/VariantItem',
24
- 'sap/ui/core/library',
25
- "sap/ui/mdc/util/loadModules",
26
- "sap/ui/events/KeyCodes"
27
- ], function(
28
- FieldHelpBase,
29
- Condition,
30
- FilterOperatorUtil,
31
- OutParameterMode,
32
- ConditionValidated,
33
- FilterConverter,
34
- ManagedObjectObserver,
35
- SyncPromise,
36
- ObjectPath,
37
- deepEqual,
38
- merge,
39
- ResourceModel,
40
- Context,
41
- Device,
42
- mobileLibrary,
43
- VariantItem,
44
- coreLibrary,
45
- loadModules,
46
- KeyCodes
47
- ) {
48
- "use strict";
49
-
50
- var Dialog;
51
- var Button;
52
- var ValueHelpPanel;
53
- var DefineConditionPanel;
54
- var ManagedObjectModel;
55
- var FilterBar;
56
- var FilterField;
57
- var CollectiveSearchSelect;
58
- var Item;
59
-
60
- // shortcut for sap.m.ButtonType
61
- var ButtonType = mobileLibrary.ButtonType;
62
- var OpenState = coreLibrary.OpenState;
63
-
64
- /**
65
- * Constructor for a new <code>FieldValueHelp</code>.
66
- *
67
- * If a more complex value help is needed, the application can add a table to this field help.
68
- * As the behavior depends on the used table control in this case,
69
- * a wrapper is used between the used control and the <code>FieldValueHelp</code> element.
70
- *
71
- * <b>Note:</b> If a <code>FieldValueHelp</code> element is connected to a field, it gets the <code>BindingContext</code> of this field.
72
- * So the in and out parameters are done in this context. Therefore bind the content table in such a way that that it finds
73
- * its data also in the <code>BindingContext</code> of the field.
74
- *
75
- * @param {string} [sId] ID for the new control, generated automatically if no ID is given
76
- * @param {object} [mSettings] Initial settings for the new control
77
- * @class A field help used in the <code>FieldHelp</code> association of controls based on {@link sap.ui.mdc.field.FieldBase FieldBase} that shows a value help dialog.
78
- * @extends sap.ui.mdc.field.FieldHelpBase
79
- * @version 1.110.0
80
- * @constructor
81
- * @private
82
- * @ui5-restricted sap.fe
83
- * @MDC_PUBLIC_CANDIDATE
84
- * @since 1.58.0
85
- * @deprecated As of version 1.110, replaced by {@link sap.ui.mdc.ValueHelp ValueHelp}
86
- * @alias sap.ui.mdc.field.FieldValueHelp
87
- */
88
- var FieldValueHelp = FieldHelpBase.extend("sap.ui.mdc.field.FieldValueHelp", /** @lends sap.ui.mdc.field.FieldValueHelp.prototype */
89
- {
90
- metadata: {
91
- library: "sap.ui.mdc",
92
- properties: {
93
-
94
- /**
95
- * Defines the module path of the metadata delegate.
96
- */
97
- delegate: {
98
- type: "object",
99
- group: "Data",
100
- defaultValue: {
101
- name: "sap/ui/mdc/field/FieldValueHelpDelegate"
102
- }
103
- },
104
-
105
- /**
106
- * The fields based on which the table data is filtered. For filtering the value of the <code>filterValue</code> property is used.
107
- *
108
- * If set to <code>$search</code> and the used binding supports search requests, a $search request is used for filtering.
109
- *
110
- * If set to one or more properties, the filters for these properties are used for filtering.
111
- * These filters are set on the <code>ListBinding</code> used.
112
- * The properties need to be separated by commas and enclosed by "*" characters. (<code>"*Property1,Property2*"</code>)
113
- *
114
- * If it is empty, no suggestion is available.
115
- */
116
- filterFields: {
117
- type: "string",
118
- defaultValue: ""
119
- },
120
-
121
- /**
122
- * The path of the key field in the content binding.
123
- * If a table is used as content, this is the binding path of the key of the items.
124
- *
125
- * If not set, the FieldPath of the assigned field is used.
126
- */
127
- keyPath: {
128
- type: "string",
129
- defaultValue: ""
130
- },
131
-
132
- /**
133
- * The path of the description field in the content binding.
134
- * If a table is used as content, this is the binding path of the description of the items.
135
- */
136
- descriptionPath: {
137
- type: "string",
138
- defaultValue: ""
139
- },
140
-
141
- /**
142
- * Determines if a condition panel is shown.
143
- *
144
- * @since 1.60.0
145
- */
146
- showConditionPanel: {
147
- type: "boolean",
148
- defaultValue: false
149
- },
150
-
151
- /**
152
- * Title text that appears in the dialog header.
153
- *
154
- * @since 1.60.0
155
- */
156
- title: {
157
- type: "string",
158
- group: "Appearance",
159
- defaultValue: ""
160
- },
161
-
162
- /**
163
- * If set, the field help doesn't open a value help dialog, but just displays the content.
164
- * It behaves like in the case of a suggestion but without any search.
165
- *
166
- * @since 1.60.0
167
- */
168
- noDialog: {
169
- type: "boolean",
170
- group: "Appearance",
171
- defaultValue: false
172
- },
173
-
174
- /**
175
- * If this property is set to <code>true</code>, the filtering for user input is always case-sensitive.
176
- * Otherwise user input is checked case-insensitively.
177
- * If <code>$search</code> is used, this property has no effect on the <code>$search</code> request.
178
- *
179
- * If the used back-end service supports a case-insensitive search, set this property to <code>false</code>.
180
- *
181
- * @since 1.89.0
182
- */
183
- caseSensitive: {
184
- type: "boolean",
185
- defaultValue: true
186
- },
187
-
188
- /**
189
- * Internal property to bind the OK button to enable or disable it.
190
- */
191
- _enableOK: {
192
- type: "boolean",
193
- group: "Appearance",
194
- defaultValue: true,
195
- visibility: "hidden"
196
- }
197
- },
198
- aggregations: {
199
- /**
200
- * Content of the field help.
201
- *
202
- * To support different types of content (for example <code>sap.m.Table</code>), a specific wrapper is used
203
- * to map the functionality of the content control to the field help. The content control
204
- * is assigned to the wrapper.
205
- *
206
- * The filter logic must be implemented in the wrapper control.
207
- * The filtering is triggered by user interaction (type-ahead, search request, or search from <code>FilterBar</code>).
208
- * (If <code>FilterBar</code> is in <code>LiveMode</code> and in parameters are used, this also triggers filtering.)
209
- *
210
- * @since 1.60.0
211
- */
212
- content: {
213
- type: "sap.ui.mdc.field.FieldValueHelpContentWrapperBase",
214
- multiple: false
215
- },
216
-
217
- /**
218
- * Content for suggestion.
219
- *
220
- * To support different types of content (for example <code>sap.m.Table</code>), a specific wrapper is used
221
- * to map the functionality of the content control to the field help. The content control
222
- * is assigned to the wrapper.
223
- *
224
- * The filter logic must be implemented in the wrapper control.
225
- * The filtering is triggered by user interaction (type-ahead, search request, or search from <code>FilterBar</code>).
226
- * (If <code>FilterBar</code> is in <code>LiveMode</code> and in parameters are used, this also triggers filtering.)
227
- *
228
- * <b>Note:</b> If no special content for suggestion is provided, the content of the <code>content</code> aggregation is used.
229
- *
230
- * @since 1.88.0
231
- * @experimental As of version 1.88
232
- */
233
- suggestContent: {
234
- type: "sap.ui.mdc.field.FieldValueHelpContentWrapperBase",
235
- multiple: false
236
- },
237
-
238
- /**
239
- * Content for dialog.
240
- *
241
- * To support different types of content (for example <code>sap.m.Table</code>), a specific wrapper is used
242
- * to map the functionality of the content control to the field help. The content control
243
- * is assigned to the wrapper.
244
- *
245
- * The filter logic must be implemented in the wrapper control.
246
- * The filtering is triggered by user interaction (type-ahead, search request, or search from <code>FilterBar</code>).
247
- * (If <code>FilterBar</code> is in <code>LiveMode</code> and in parameters are used, this also triggers filtering.)
248
- *
249
- * <b>Note:</b> If no special content for the dialog is provided, the content of the <code>content</code> aggregation is used.
250
- *
251
- * @since 1.88.0
252
- * @experimental As of version 1.88
253
- */
254
- dialogContent: {
255
- type: "sap.ui.mdc.field.FieldValueHelpContentWrapperBase",
256
- multiple: false
257
- },
258
-
259
- /**
260
- * <code>FilterBar</code> control of the field help.
261
- *
262
- * @since 1.60.0
263
- */
264
- filterBar: {
265
- type: "sap.ui.mdc.filterbar.FilterBarBase",
266
- multiple: false
267
- },
268
-
269
- /**
270
- * Sets the in parameters of a field help.
271
- *
272
- * If set, the field help reads the data of these entities in the model and uses it to filter in the value help.
273
- * @since 1.66.0
274
- */
275
- inParameters: {
276
- type: "sap.ui.mdc.field.InParameter",
277
- group: "Data",
278
- multiple: true
279
- },
280
-
281
- /**
282
- * Sets the out parameters of a field help.
283
- *
284
- * If set, the fields sets the data of these entities in the model based to the selected values.
285
- * @since 1.66.0
286
- */
287
- outParameters: {
288
- type: "sap.ui.mdc.field.OutParameter",
289
- group: "Data",
290
- multiple: true
291
- },
292
-
293
- /**
294
- * internal dialog
295
- */
296
- _dialog: {
297
- type: "sap.m.Dialog",
298
- multiple: false,
299
- visibility: "hidden"
300
- },
301
-
302
- /**
303
- * Internal <code>FilterBar</code> control of the field help. (If no external <code>FilterBar</code> used.)
304
- *
305
- * @since 1.86.0
306
- */
307
- _filterBar: {
308
- type: "sap.ui.mdc.filterbar.FilterBarBase",
309
- multiple: false,
310
- visibility: "hidden"
311
- },
312
-
313
- /**
314
- * Items for collective searches.
315
- *
316
- * If used, a field to switch value helps will be shown. If the value help is switched, the
317
- * <code>contentRequest</code> function of the delegate is called and the chosen key is provided.
318
- *
319
- * <b>Note:</b> Icons are not supported.
320
- * @since 1.87.0
321
- */
322
- collectiveSearchItems: {
323
- type: "sap.ui.core.Item",
324
- multiple: true,
325
- singularName : "collectiveSearchItem"
326
- }
327
- },
328
- defaultAggregation: "content",
329
- events: {
330
- /**
331
- * This event is fired when a description for a key or a key for a description is requested, and
332
- * no data table with list binding is assigned.
333
- *
334
- * This is the case if a <code>Field</code> or <code>FilterField</code> shows the description of the value.
335
- * and the value is formatted or a new input is parsed.
336
- *
337
- * @since 1.67.0
338
- */
339
- dataRequested: {}
340
- }
341
- }
342
- });
343
-
344
- // private function to initialize globals for qUnit tests
345
- FieldValueHelp._init = function() {
346
-
347
- FieldHelpBase._init.apply(this, arguments);
348
-
349
- Dialog = undefined;
350
- Button = undefined;
351
- ValueHelpPanel = undefined;
352
- DefineConditionPanel = undefined;
353
- ManagedObjectModel = undefined;
354
-
355
- };
356
-
357
- FieldValueHelp.prototype.init = function() {
358
-
359
- FieldHelpBase.prototype.init.apply(this, arguments);
360
-
361
- this._oObserver = new ManagedObjectObserver(_observeChanges.bind(this));
362
-
363
- this._oObserver.observe(this, {
364
- properties: ["filterValue", "conditions", "showConditionPanel", "filterFields"],
365
- aggregations: ["content", "suggestContent", "dialogContent", "filterBar", "_filterBar", "inParameters", "collectiveSearchItems"]
366
- });
367
-
368
- this.setBindingContext(null); // don't inherit from parent as this could have a invalid BindingContent to read InParameters...
369
-
370
- this._oConditions = {}; // if no FilterBar is used store Conditions for search and InParameters locally
371
-
372
- };
373
-
374
- FieldValueHelp.prototype.exit = function() {
375
-
376
- FieldHelpBase.prototype.exit.apply(this, arguments);
377
-
378
- if (this._oManagedObjectModel) {
379
- this._oManagedObjectModel.destroy();
380
- delete this._oManagedObjectModel;
381
- }
382
-
383
- this._oObserver.disconnect();
384
- this._oObserver = undefined;
385
-
386
- delete this._oConditions;
387
-
388
- if (this._iUpdateTimer) {
389
- clearTimeout(this._iUpdateTimer);
390
- this._iUpdateTimer = null;
391
- }
392
-
393
- if (this._iFilterTimer) {
394
- clearTimeout(this._iFilterTimer);
395
- this._iFilterTimer = null;
396
- }
397
-
398
- if (this._iSearchFieldTimer) {
399
- clearTimeout(this._iSearchFieldTimer);
400
- this._iSearchFieldTimer = null;
401
- }
402
-
403
- if (this._oCollectiveSearchSelect) {
404
- this._oCollectiveSearchSelect.destroy();
405
- delete this._oCollectiveSearchSelect;
406
- }
407
-
408
- if (this._oResourceBundleM) {
409
- this._oResourceBundleM = null;
410
- }
411
-
412
- if (this._oResourceBundle) {
413
- this._oResourceBundle = null;
414
- }
415
- };
416
-
417
- FieldValueHelp.prototype.invalidate = function(oOrigin) {
418
-
419
- if (oOrigin) {
420
- var oSuggetWrapper = _getWrapper.call(this, true);
421
- var oDialogWrapper = _getWrapper.call(this, false);
422
- var oDialog = this.getAggregation("_dialog");
423
-
424
- if ((oSuggetWrapper && oOrigin === oSuggetWrapper) || (oDialogWrapper && oOrigin === oDialogWrapper)) {
425
- // Wrapper invalidation might need re-rendering (e.g. selection table item leads to re-rendering of CheckBox)
426
- // --> invalidate rendering parent (ValueHelpPanel or Popover)
427
- var oPopover = this.getAggregation("_popover");
428
- if (oDialog && oDialog.isOpen()) {
429
- var oValueHelpPanel = oDialog.getContent()[0];
430
- oValueHelpPanel.invalidate(oOrigin);
431
- } else if (oPopover && oPopover.isOpen()) {
432
- oPopover.invalidate(oOrigin);
433
- }
434
- return;
435
- }
436
-
437
- var oFilterBar = this._getFilterBar();
438
- if ((oDialog && oOrigin === oDialog) ||
439
- (oFilterBar && oOrigin === oFilterBar)) {
440
- if (oOrigin.bOutput && !this._bIsBeingDestroyed) {
441
- // Content changed but no UiArea found, this should not happen.
442
- // now invalidate parent to trigger re-rendering somehow.
443
- var oParent = this.getParent();
444
- if (oParent) {
445
- oParent.invalidate(this);
446
- }
447
- }
448
- return;
449
- }
450
- }
451
-
452
- FieldHelpBase.prototype.invalidate.apply(this, arguments);
453
-
454
- };
455
-
456
- FieldValueHelp.prototype.connect = function(oField) {
457
-
458
- FieldHelpBase.prototype.connect.apply(this, arguments);
459
-
460
- // update BindingContext for in/out-parameter
461
- _updateBindingContext.call(this);
462
-
463
- // new Field might not support define conditions
464
- _toggleDefineConditions.call(this, this.getShowConditionPanel());
465
-
466
- return this;
467
-
468
- };
469
-
470
- FieldValueHelp.prototype.getIcon = function() {
471
-
472
- if (this.getNoDialog()) {
473
- return "sap-icon://slim-arrow-down";
474
- } else {
475
- return "sap-icon://value-help";
476
- }
477
-
478
- };
479
-
480
- FieldValueHelp.prototype._createPopover = function() {
481
-
482
- var oPopover = FieldHelpBase.prototype._createPopover.apply(this, arguments);
483
-
484
- var fnOpenDialogFromPopover = function (oEvent) {
485
- this.fireSwitchToValueHelp();
486
- }.bind(this);
487
-
488
- if (oPopover) { // empty if loaded async
489
- oPopover.addDelegate({onsapshow: fnOpenDialogFromPopover});
490
-
491
- // use Wrapper content in Popover -> overwrite hook
492
- var oWrapper = _getWrapper.call(this, true);
493
- if (oWrapper) {
494
- SyncPromise.resolve(oWrapper.initialize(true)).then(function () {
495
- if (oWrapper.enableShowAllItems()) {
496
- loadModules(["sap/m/Button", "sap/m/Toolbar", "sap/m/ToolbarSpacer"]).then(function (aModules) {
497
- var Button = aModules[0];
498
- var Toolbar = aModules[1];
499
- var ToolbarSpacer = aModules[2];
500
- var sapMResourceBundle = getSAPMResourceBundle.apply(this);
501
- var oShowAllItemsButton = new Button(this.getId() + "-showAllItems", {
502
- text: sapMResourceBundle.getText("INPUT_SUGGESTIONS_SHOW_ALL"),
503
- press: fnOpenDialogFromPopover
504
- });
505
- var aToolbarContent = [new ToolbarSpacer(this.getId() + "-Spacer")].concat(oShowAllItemsButton);
506
- var oFooter = new Toolbar(this.getId() + "-TB", {
507
- content: aToolbarContent,
508
- visible: !oWrapper.getAllItemsShown()
509
- }).setModel(this._oFooterModel, "$config");
510
- oPopover.setFooter(oFooter);
511
- }.bind(this));
512
- }
513
- }.bind(this));
514
- }
515
-
516
- oPopover._getAllContent = function() {
517
- var oParent = this.getParent();
518
- var aContent = [];
519
-
520
- if (oParent) {
521
- var oContent = _getSuggestionContent.call(oParent);
522
- if (oContent) {
523
- aContent.push(oContent);
524
- }
525
- }
526
- return aContent;
527
- };
528
-
529
- if (this._bNavigate) {
530
- this.navigate(this._iStep);
531
- }
532
- }
533
-
534
- return oPopover;
535
-
536
- };
537
-
538
- FieldValueHelp.prototype._handleAfterOpen = function(oEvent) {
539
-
540
- FieldHelpBase.prototype._handleAfterOpen.apply(this, arguments);
541
-
542
- var oWrapper = _getWrapper.call(this, true);
543
- if (oWrapper) {
544
- oWrapper.fieldHelpOpen(true);
545
- }
546
-
547
- };
548
-
549
- FieldValueHelp.prototype.open = function(bSuggestion) {
550
-
551
- if (this.getNoDialog() && !bSuggestion) {
552
- bSuggestion = true;
553
- }
554
-
555
- // as BindingContext of Field might change (happens in table) update if needed
556
- _updateBindingContext.call(this);
557
-
558
- if (this._bOpenAfterPromise) {
559
- this._bSuggestion = bSuggestion;
560
- return; // already wait for opening
561
- }
562
-
563
- var oWrapper = _getWrapper.call(this, bSuggestion);
564
-
565
- // trigger content loading in event or delegate
566
- var fnOpen = function() {
567
- if (this._bOpenAfterPromise) {
568
- delete this._bOpenAfterPromise;
569
- this.open(this._bSuggestion);
570
- delete this._bSuggestion;
571
- }
572
- }.bind(this);
573
- var bSync = this._bOpen ? this._callContentRequest(!!bSuggestion, fnOpen) : this._fireOpen(!!bSuggestion, fnOpen); // no open event of Popover async loaded
574
- delete this._bOpen; // set it new if still needed
575
- if (!bSync) {
576
- // open after delegates promise is resolved
577
- // but trigger loading of Popover or Dialog to use the pending time (otherwise we run in the next async loading afterwards)
578
- this._bSuggestion = bSuggestion;
579
- if (bSuggestion) {
580
- this._getPopover();
581
- } else {
582
- _getDialog.call(this);
583
- }
584
-
585
- this._bOpenAfterPromise = true;
586
-
587
- return;
588
- }
589
-
590
- this._bOpenHandled = true; // prevent double event and delegate call
591
-
592
- oWrapper = _getWrapper.call(this, bSuggestion); // as Wrapper could be added synchronously in open event
593
- if (oWrapper && oWrapper.getFilterEnabled() && !this._bNavigateRunning) { //in running navigation already filtered
594
- this._bApplyFilter = false; // initialize
595
- if (!oWrapper.isSuspended() || bSuggestion || this.getFilterValue()) {// in suggestion applyFilter even if suspended (resume), if FilterValue set, filter always
596
- // apply use in-parameter filters
597
- this._bApplyFilter = true;
598
- }
599
- _initializeFilters.call(this);
600
- }
601
-
602
- if (this._bUpdateFilterAfterClose) {
603
- // filter was updated by closing -> perform it now
604
- this._bUpdateFilterAfterClose = false;
605
- _filterContent.call(this, this.getFilterValue());
606
- }
607
-
608
- if (bSuggestion) {
609
- if (!oWrapper) {
610
- // do not create Popover if no content
611
- this._bOpenIfContent = true;
612
- } else {
613
- //call the fieldHelpOpen before the open to update the table width and avoid rerender and flickering of suggest popover
614
- oWrapper.fieldHelpOpen(bSuggestion);
615
- if (!this.getFilterValue() && !this._bNavigateRunning) {
616
- // if no filter call filters to search for all (use in-parameters)
617
- _applyFilters.call(this, true);
618
- }
619
- FieldHelpBase.prototype.open.apply(this, [bSuggestion]);
620
- }
621
- } else {
622
- var oPopover = this.getAggregation("_popover");
623
- if (oPopover) {
624
- if (oPopover.isOpen()) {
625
- this.close();
626
- this._bSwitchToDialog = true;
627
- }
628
- oPopover.$().remove(); // destroy DOM of Wrapper content to not have it twice
629
- }
630
-
631
- var oDialog = _getDialog.call(this);
632
-
633
- if (oDialog) {
634
- // create SearchField if needed
635
- _initializeSearchField.call(this);
636
-
637
- // add collectiveSearch if needed
638
- _assignCollectiveSearch.call(this, true);
639
-
640
- // use FilterBar filters
641
- _updateFiltersFromFilterBar.call(this);
642
-
643
- var oValueHelpPanel = oDialog.getContent()[0];
644
- oValueHelpPanel.setShowTokenizer(this.getMaxConditions() !== 1 && !!oWrapper);
645
- oValueHelpPanel.setFormatOptions(this._getFormatOptions());
646
- oValueHelpPanel.bindProperty("conditions", {path: "$help>/conditions"});
647
-
648
- if (oWrapper) {
649
- oWrapper.fieldHelpOpen(false);
650
- _updateSelectedItems.call(this);
651
- }
652
- this._aOldConditions = this.getConditions();
653
- oDialog.open();
654
- this._bDialogOpen = true; // to know already during opening animation
655
- } else {
656
- this._bOpen = true;
657
- }
658
- }
659
-
660
- this._bOpenHandled = false;
661
-
662
- return;
663
-
664
- };
665
-
666
- FieldValueHelp.prototype.toggleOpen = function(bSuggestion) {
667
-
668
- if (this.getNoDialog() && !bSuggestion) {
669
- bSuggestion = true;
670
- }
671
-
672
- if (bSuggestion) {
673
- FieldHelpBase.prototype.toggleOpen.apply(this, [bSuggestion]);
674
- } else if (this._bOpen || this._bOpenIfContent || this._bOpenAfterPromise) {
675
- // dialog is requested and open is pending -> skip opening
676
- delete this._bOpen;
677
- delete this._bSuggestion;
678
- delete this._bOpenIfContent;
679
- delete this._bOpenAfterPromise;
680
- } else {
681
- var oDialog = _getDialog.call(this);
682
-
683
- if (oDialog) {
684
- if (oDialog.isOpen()) {
685
- var eOpenState = oDialog.oPopup.getOpenState();
686
- if (eOpenState !== "CLOSED" && eOpenState !== "CLOSING") { // TODO: better logic
687
- this.close();
688
- } else {
689
- this._bReopen = true;
690
- }
691
- } else {
692
- this.open(bSuggestion);
693
- }
694
- } else {
695
- // it is closed -> just open
696
- this.open(bSuggestion);
697
- }
698
- }
699
-
700
- };
701
-
702
- FieldValueHelp.prototype.close = function() {
703
-
704
- if (!this._bDialogOpen) {
705
- FieldHelpBase.prototype.close.apply(this, arguments);
706
- } else {
707
- var oDialog = this.getAggregation("_dialog");
708
-
709
- if (oDialog) {
710
- this._bClosing = true;
711
- oDialog.close();
712
-
713
- var oValueHelpPanel = oDialog.getContent()[0];
714
- // remove binding of conditions to prevent updates on ValueHelpPanel and DefineConditionPanel while closed. (e.g. empty row)
715
- oValueHelpPanel.unbindProperty("conditions", true);
716
- if (oValueHelpPanel._oDefineConditionPanel) { //TODO: use API?
717
- oValueHelpPanel._oDefineConditionPanel.cleanUp();
718
- }
719
- }
720
-
721
- this._bReopen = false;
722
- this._bSwitchToDialog = false;
723
- delete this._bOpen;
724
- delete this._bOpenAfterPromise;
725
- }
726
-
727
- };
728
-
729
- FieldValueHelp.prototype.isOpen = function(bCheckClosing) {
730
-
731
- var bIsOpen = FieldHelpBase.prototype.isOpen.apply(this, arguments);
732
-
733
- if (!bIsOpen && (!bCheckClosing || !this._bClosing)) { //
734
- var oDialog = this.getAggregation("_dialog");
735
- if (oDialog) {
736
- bIsOpen = oDialog.isOpen();
737
- }
738
- }
739
-
740
- return bIsOpen;
741
-
742
- };
743
-
744
- FieldValueHelp.prototype.getDomRef = function() {
745
-
746
- if (!this._bDialogOpen) {
747
- return FieldHelpBase.prototype.getDomRef.apply(this, arguments);
748
- } else {
749
- var oDialog = this.getAggregation("_dialog");
750
-
751
- if (oDialog) {
752
- return oDialog.getDomRef();
753
- }
754
- }
755
-
756
- };
757
-
758
- function _cleanupFilters() { // TODO: really needed or better use single requests if needed by getText or description?
759
-
760
- // remove filters: update table only if filter exist
761
- var oFilterBar = this._getFilterBar();
762
- var oConditions;
763
-
764
- if (oFilterBar) {
765
- oConditions = oFilterBar.getInternalConditions();
766
- } else {
767
- oConditions = this._oConditions;
768
- }
769
-
770
- var bRemove = false;
771
- for (var sMyFieldPath in oConditions) {
772
- if (oConditions[sMyFieldPath].length > 0) {
773
- _removeConditions.call(this, sMyFieldPath);
774
- bRemove = true;
775
- }
776
- }
777
-
778
- if (bRemove) {
779
- _applyFilters.call(this, true);
780
- }
781
-
782
- }
783
-
784
- FieldValueHelp.prototype._handleAfterClose = function(oEvent) {
785
-
786
- var oDialog = this.getAggregation("_dialog");
787
- var bSuggestion = !oDialog || oEvent.getSource() !== oDialog;
788
-
789
- var oWrapper = _getWrapper.call(this, bSuggestion);
790
-
791
- if (oWrapper) {
792
- if (!oWrapper.getAsyncKeyText()) {
793
- // to have the full list if key or text are requested only from table
794
- _cleanupFilters.call(this);
795
- }
796
- oWrapper.fieldHelpClose();
797
- }
798
-
799
- if (!this.isOpen()) { // maybe Popover closed while Dialog opens -> here Filter needs to be applied
800
- this._bApplyFilter = false;
801
- }
802
-
803
- this._bNavigateRunning = false; // just to be sure - navigation cannot run after popover closed
804
-
805
- FieldHelpBase.prototype._handleAfterClose.apply(this, arguments);
806
-
807
- };
808
-
809
- function _observeChanges(oChanges) {
810
-
811
- if (oChanges.object == this) { // FieldValueHelp
812
- var oDialog;
813
-
814
- if (oChanges.name === "content") {
815
- _contentChanged.call(this, oChanges.mutation, oChanges.child, oChanges.name);
816
- }
817
-
818
- if (oChanges.name === "suggestContent") {
819
- _contentChanged.call(this, oChanges.mutation, oChanges.child, oChanges.name);
820
- }
821
-
822
- if (oChanges.name === "dialogContent") {
823
- _contentChanged.call(this, oChanges.mutation, oChanges.child, oChanges.name);
824
- }
825
-
826
- if (oChanges.name === "filterBar") {
827
- if (oChanges.mutation === "insert" && this.getAggregation("_filterBar")) {
828
- this.destroyAggregation("_filterBar");
829
- delete this._oSearchField; // as SearchField is destroyed too
830
- }
831
- _updateFilterBar.call(this, oChanges.mutation, oChanges.child, false);
832
- }
833
-
834
- if (oChanges.name === "_filterBar") {
835
- _updateFilterBar.call(this, oChanges.mutation, oChanges.child, true);
836
- }
837
-
838
- if (oChanges.name === "conditions") {
839
- _updateConditions.call(this, oChanges.current);
840
- }
841
-
842
- if (oChanges.name === "filterValue") {
843
- if (this._bClosing) {
844
- this._bUpdateFilterAfterClose = true;
845
- } else {
846
- _filterContent.call(this, oChanges.current);
847
- }
848
- }
849
-
850
- if (oChanges.name === "showConditionPanel") {
851
- _toggleDefineConditions.call(this, oChanges.current);
852
- }
853
-
854
- if (oChanges.name === "filterFields") {
855
- oDialog = this.getAggregation("_dialog");
856
- if (oDialog) {
857
- if (oDialog.isOpen()) {
858
- if (oChanges.current) {
859
- _initializeSearchField.call(this);
860
- } else if (this.getAggregation("_filterBar")) {
861
- this.destroyAggregation("_filterBar");
862
- }
863
- }
864
- }
865
- }
866
-
867
- if (oChanges.name === "inParameters") {
868
- _inParametersChanged.call(this, oChanges.child, oChanges.mutation);
869
- }
870
-
871
- if (oChanges.name === "collectiveSearchItems") {
872
- _assignCollectiveSearch.call(this, false);
873
- }
874
- } else if (oChanges.object.isA("sap.ui.mdc.field.InParameter")){
875
- if (oChanges.name === "value") {
876
- _inParameterValueChanged.call(this, oChanges.object.getHelpPath(), oChanges.current, oChanges.old, oChanges.object.getUseConditions(), oChanges.object.getInitialValueFilterEmpty());
877
- }
878
- if (oChanges.name === "helpPath") {
879
- _inParameterPathChanged.call(this, oChanges.current, oChanges.old, oChanges.object.getValue(), oChanges.object.getUseConditions(), oChanges.object.getInitialValueFilterEmpty());
880
- }
881
- }
882
-
883
- }
884
-
885
- FieldValueHelp.prototype.openByTyping = function() {
886
-
887
- if (!this._bDetermineSearchSupportedCalled && !this.isOpen() && !this._bOpen && !this._bOpenIfContent && !this._bOpenAfterPromise) {
888
- // call delegate. But don't wait for result as this needs to be checked synchronously.
889
- // It makes no sense to open the suggestion if typing finished and user already left field.
890
- // Only call delegate once. FilterFields must not be changed after set once.
891
- // Only check if not already opened. If opened everything must be set. While opening we still
892
- // waiting for the settings, so calling again makes no sense.
893
- if (!this.bDelegateInitialized && !this.bDelegateLoading) {
894
- this.initControlDelegate();
895
- }
896
-
897
- if (this.bDelegateInitialized) {
898
- return _checkSearchSupported.call(this);
899
- } else {
900
- this._bDetermineSearchSupportedCalled = true; // don't trigger twice
901
- return this.awaitControlDelegate().then(function() {
902
- return _checkSearchSupported.call(this);
903
- }.bind(this));
904
- }
905
- }
906
-
907
- // if no search is defined no suggestion is possible
908
- return !!this.getFilterFields();
909
-
910
- };
911
-
912
- function _checkSearchSupported() {
913
-
914
- this.fireOpen({suggestion: true}); // TODO: remove after delegate is implemented
915
- this._bDetermineSearchSupportedCalled = true;
916
- var oPromise = this.getControlDelegate().determineSearchSupported(this.getPayload(), this);
917
- if (oPromise instanceof Promise) {
918
- return oPromise.then( function() {
919
- return !!this.getFilterFields();
920
- }.bind(this));
921
- } else {
922
- return !!this.getFilterFields();
923
- }
924
-
925
- }
926
-
927
- FieldValueHelp.prototype.isFocusInHelp = function() {
928
-
929
- if (!this.getNoDialog()) {
930
- var oDialog = this.getAggregation("_dialog");
931
- if ((oDialog && oDialog.isOpen()) || (this._bDialogRequested && this._bOpen) || (this._bOpenAfterPromise && !this._bSuggestion)) {
932
- return true;
933
- }
934
- }
935
-
936
- if (this._bFocusPopover) {
937
- // focus should be set in popover (while navigation in multi-suggestion)
938
- return true;
939
- }
940
-
941
- return false; // as default let focus stay on Field
942
-
943
- };
944
-
945
- FieldValueHelp.prototype.removeFocus = function() {
946
-
947
- var oWrapper = _getWrapper.call(this, true); // only needed in suggestion because of navigation
948
- if (oWrapper) {
949
- oWrapper.removeFocus();
950
- }
951
-
952
- };
953
-
954
- FieldValueHelp.prototype.navigate = function(iStep) {
955
-
956
- var oWrapper = _getWrapper.call(this, true); // navigate only in suggestion
957
- var oPopover = this.getAggregation("_popover");
958
-
959
- // as BindingContext of Field might change (happens in table) update if needed
960
- _updateBindingContext.call(this);
961
-
962
- if (!oPopover || !oPopover.isOpen()) {
963
- // trigger content loading in event or delegate
964
- var fnNavigate = function() {this.navigate(iStep);}.bind(this);
965
- var bSync = this._bNavigate ? this._callContentRequest(true, fnNavigate) : this._fireOpen(true, fnNavigate); // no open event of Popover async loaded
966
- if (!bSync) {
967
- // navigate after delegates promise is resolved
968
- // but trigger loading of Popover to use the pending time (otherwise we run in the next async loading afterwards)
969
- oWrapper = _getWrapper.call(this, true);
970
- this._bNavigate = false; // will be new set if still needed
971
- this._iStep = null;
972
- if (oWrapper) {
973
- this._getPopover();
974
- }
975
- return;
976
- }
977
- }
978
-
979
- this._bNavigate = false; // will be new set if still needed
980
- this._iStep = null;
981
- oWrapper = _getWrapper.call(this, true);
982
-
983
- if (oWrapper) {
984
- // only create popover if content
985
- oPopover = this._getPopover();
986
- // apply use in-parameter filters
987
- this._bApplyFilter = true;
988
- this._bNavigateRunning = true;
989
- _initializeFilters.call(this);
990
- _applyFilters.call(this, true); // if no filter set and no in-parameters, trigger initial select (if suspended)
991
- }
992
-
993
- if (!oPopover) {
994
- // Popover not loaded right now
995
- this._bNavigate = true;
996
- this._iStep = iStep;
997
- return;
998
- }
999
-
1000
- if (oWrapper) {
1001
- oWrapper.navigate(iStep, oPopover.isOpen());
1002
- }
1003
-
1004
- };
1005
-
1006
- function _handleNavigate(oEvent) {
1007
-
1008
- var oPopover = this._getPopover();
1009
- var bDisableFocus = oEvent.getParameter("disableFocus");
1010
-
1011
- var vKey = oEvent.getParameter("key");
1012
- var sDescription = oEvent.getParameter("description");
1013
- var oInParameters = oEvent.getParameter("inParameters");
1014
- var oOutParameters = oEvent.getParameter("outParameters");
1015
- var bLeave = oEvent.getParameter("leave");
1016
- var sItemId = oEvent.getParameter("itemId");
1017
- var oCondition;
1018
-
1019
- if (bLeave) {
1020
- // leave field help and focus Field
1021
- this.fireNavigate({key: undefined, value: undefined, condition: undefined, itemId: undefined, leaveFocus: bLeave});
1022
- return;
1023
- }
1024
-
1025
- if (vKey === undefined && !bDisableFocus) {
1026
- // no real navigation, just open
1027
- this._bFocusPopover = true;
1028
- }
1029
-
1030
- if (!oPopover.isOpen()) {
1031
- this._bOpenHandled = true; // prevent double event and delegate call
1032
- this.open(true); // as navigation opens suggestion
1033
- this._bOpenHandled = false;
1034
- }
1035
-
1036
- this._bNavigateRunning = false;
1037
-
1038
- if (vKey === undefined) {
1039
- // only focus set, no real navigation
1040
- this._bFocusPopover = false;
1041
- return;
1042
- }
1043
-
1044
- if (oInParameters) {
1045
- oInParameters = _mapInParametersToField.call(this, oInParameters);
1046
- }
1047
- if (oOutParameters) {
1048
- oOutParameters = _mapOutParametersToField.call(this, oOutParameters);
1049
- }
1050
- oCondition = this._createCondition(vKey, sDescription, oInParameters, oOutParameters);
1051
- this.setProperty("conditions", [oCondition], true); // do not invalidate whole FieldHelp
1052
- this.fireNavigate({value: sDescription, key: vKey, condition: oCondition, itemId: sItemId, leaveFocus: bLeave});
1053
-
1054
- }
1055
-
1056
- FieldValueHelp.prototype._getTextOrKey = function(vValue, bKey, oBindingContext, oInParameters, oOutParameters, bNoRequest, oConditionModel, sConditionModelName, vParsedValue, bKeyAndDescription, bCaseSensitive) {
1057
-
1058
- var vResult = "";
1059
- var oWrapper = _getWrapper.call(this, true); // use suggest wrapper to determine text or key
1060
-
1061
- if (oWrapper) {
1062
- var oListBinding = oWrapper.getListBinding();
1063
-
1064
- if (!oListBinding) {
1065
- this.fireDataRequested();
1066
- }
1067
-
1068
- if (oBindingContext && !oBindingContext.getModel()) {
1069
- // BindingContext without model cannot bring any data and might be destroyed -> ignore as request is probably outdated
1070
- return null;
1071
- }
1072
-
1073
- // if backend don't support case insensitive filtering, filter case sensitive
1074
- bCaseSensitive = bCaseSensitive || this.getCaseSensitive();
1075
-
1076
- /*
1077
- * If the description should be displayed inside a Field this description will be determined using this function.
1078
- * If InParameters are used, they are needed to find the right description.
1079
- * It could happen taht the Binding of the InParameter is still pending, so the value is not known right now.
1080
- * In this case we need to wait until the Binding has read the value. This is model specific. Only in oData V4
1081
- * Bindings there is a requestValue function. So the logic is implemented in the Delegate.
1082
- *
1083
- * If the Field is inside a Table, the Description is requested for every table row. Every table row has a different BindingContext.
1084
- * So the InParamer value needs to be read for every BindingContext. If the value is already read Context.getValue() will return it.
1085
- * In oData V4 the property is only read in the Context if a Binding exists. So a new Binding to read the value of the InParameter
1086
- * is created for the BindingContext. (Only if the inParameter is bound to the same BindingContext as the whole FieldValueHelp.
1087
- * Otherwise the original Binding is used.)
1088
- */
1089
- var oMyBindingContext = this.oBindingContexts[undefined]; // as getBindingContext returns propagated Context if own context don't fit to model
1090
- var aInParameters = this.getInParameters();
1091
- var bBindingChanged = false;
1092
-
1093
- if (oBindingContext && Context.hasChanged(oMyBindingContext, oBindingContext)) {
1094
- bBindingChanged = true;
1095
- }
1096
-
1097
- var aInBindings = _getParameterBinding.call(this, aInParameters, bBindingChanged, oBindingContext, oMyBindingContext, oConditionModel, sConditionModelName);
1098
- // Out Parameter binding not used, only given outParameter value
1099
-
1100
- vResult = SyncPromise.resolve().then(function() {
1101
- return _checkBindingsPending.call(this, aInBindings);
1102
- }.bind(this)).then(function() {
1103
- return SyncPromise.resolve().then(function() {
1104
- if (oBindingContext && !oBindingContext.getModel()) {
1105
- // BindingContext without model cannot bring any data and might be destroyed -> ignore as request is probably outdated
1106
- return null;
1107
- } else if (bKeyAndDescription) {
1108
- return oWrapper.getKeyAndText(vParsedValue, vValue, _mapParametersToHelp.call(this, oInParameters, aInParameters, false, aInBindings, oBindingContext, true), _mapParametersToHelp.call(this, oOutParameters, this.getOutParameters(), true, undefined, undefined, true), bCaseSensitive);
1109
- } else if (bKey) {
1110
- return oWrapper.getTextForKey(vValue, _mapParametersToHelp.call(this, oInParameters, aInParameters, false, aInBindings, oBindingContext, true), _mapParametersToHelp.call(this, oOutParameters, this.getOutParameters(), true, undefined, undefined, true), bNoRequest, bCaseSensitive);
1111
- } else {
1112
- // use default in-parameters for check
1113
- return oWrapper.getKeyForText(vValue, _mapParametersToHelp.call(this, undefined, aInParameters, false, aInBindings, oBindingContext, true), bNoRequest, bCaseSensitive);
1114
- }
1115
- }.bind(this)).then(function(vResult) {
1116
- _cleanupParameterBinding.call(this, aInBindings, bBindingChanged);
1117
- return _adjustWrapperResult.call(this, vResult);
1118
- }.bind(this)).unwrap();
1119
- }.bind(this)).unwrap();
1120
- }
1121
-
1122
- return vResult;
1123
-
1124
- };
1125
-
1126
- function _getParameterBinding(aParameters, bNewBinding, oBindingContext, oMyBindingContext, oConditionModel, sConditionModelName) {
1127
-
1128
- var aBindings = [];
1129
-
1130
- for (var i = 0; i < aParameters.length; i++) {
1131
- var oParameter = aParameters[i];
1132
- var oBinding = oParameter.getBinding("value");
1133
-
1134
- if (oParameter.getUseConditions() && oConditionModel) {
1135
- // if ConditionModel is used, check if Binding is OK and same ConditionModel is used
1136
- var oMyConditionModel = this.getModel(sConditionModelName);
1137
- if (oMyConditionModel !== oConditionModel) {
1138
- // no or different ConditionModel -> create new binding on given ConditionModel
1139
- aBindings.push(oConditionModel.bindProperty("/" + oParameter.getFieldPath()));
1140
- }
1141
- } else if (oBinding) {
1142
- var sPath = oBinding.getPath();
1143
- var oParameterBindingContext = oBinding.getContext();
1144
-
1145
- if (bNewBinding && oBinding.isRelative() && (oParameterBindingContext === oMyBindingContext || (!oParameterBindingContext && oMyBindingContext))) {
1146
- // InParameter is bound and uses the same BindingContext like the FieldHelp or has no BindingContext right now.
1147
- // If InParameter is bound to a different BindingContext just use this one.
1148
- if (oBindingContext.getProperty(sPath) === undefined) {
1149
- // if value is already known in BindingContext from other existing Binding, don't request again.
1150
- var oModel = oBinding.getModel();
1151
- aBindings.push(oModel.bindProperty(sPath, oBindingContext));
1152
- }
1153
- } else if ((!oParameterBindingContext && oBinding.isRelative()) // we don't have a BindingContext but need one -> need to wait for one
1154
- || (oParameterBindingContext && oParameterBindingContext.getProperty(sPath) === undefined) // the BindingContext has no data right now -> need to wait for update
1155
- || oBinding.getValue() === undefined // the Binding has no data right now, need to wait for update
1156
- || (oParameterBindingContext && !deepEqual(oParameter.validateProperty("value", oParameterBindingContext.getProperty(sPath)), oParameter.getValue()))) { // value not alreday set
1157
- // Property not already known on BindingContext or not already updated in Parameter value
1158
- // use validateProperty as null might be converted to undefined, if invalid value don't run into a check
1159
- // use deepEqual as, depending on type, the value could be complex (same logic as in setProperty)
1160
- aBindings.push(oBinding);
1161
- }
1162
- }
1163
- }
1164
-
1165
- return aBindings;
1166
-
1167
- }
1168
-
1169
- function _cleanupParameterBinding(aBindings, bNewBinding) {
1170
-
1171
- if (!bNewBinding) {
1172
- return;
1173
- }
1174
-
1175
- for (var i = 0; i < aBindings.length; i++) {
1176
- aBindings[i].destroy();
1177
- }
1178
-
1179
- }
1180
-
1181
- function _checkBindingsPending(aBindings) {
1182
-
1183
- if (aBindings.length === 0) {
1184
- return null;
1185
- }
1186
-
1187
- if (!this.bDelegateInitialized && !this.bDelegateLoading) {
1188
- this.initControlDelegate();
1189
- }
1190
-
1191
- if (this.bDelegateInitialized) {
1192
- return this.getControlDelegate().checkBindingsPending(this.getPayload(), aBindings);
1193
- } else {
1194
- return this.awaitControlDelegate().then(function() {
1195
- return this.getControlDelegate().checkBindingsPending(this.getPayload(), aBindings);
1196
- }.bind(this));
1197
- }
1198
-
1199
- }
1200
-
1201
- function _adjustWrapperResult(vResult) {
1202
-
1203
- if (vResult && typeof vResult === "object") {
1204
- // map in/out parameters to external keys
1205
- vResult = merge({}, vResult); // do not modify original object, could have strange side effects
1206
- if (vResult.inParameters) {
1207
- vResult.inParameters = _mapInParametersToField.call(this, vResult.inParameters);
1208
- }
1209
- if (vResult.outParameters) {
1210
- vResult.outParameters = _mapOutParametersToField.call(this, vResult.outParameters);
1211
- }
1212
- }
1213
-
1214
- return vResult;
1215
-
1216
- }
1217
-
1218
- FieldValueHelp.prototype._isTextOrKeyRequestSupported = function() {
1219
-
1220
- // only possible if Wrapper added
1221
- var oWrapper = _getWrapper.call(this, true); // use suggest wrapper to determine text or key
1222
- return !!oWrapper;
1223
-
1224
- };
1225
-
1226
- FieldValueHelp.prototype.isUsableForValidation = function() {
1227
-
1228
- // if no wrapper only a defineDonditionPanel might be used -> therefore no input validation is possible
1229
- var oWrapper = _getWrapper.call(this, true); // use suggest wrapper to determine text or key
1230
- return !!oWrapper;
1231
-
1232
- };
1233
-
1234
- function _handleSelectionChange(oEvent) {
1235
-
1236
- var aSelectedItems = oEvent.getParameter("selectedItems");
1237
- var bItemPress = oEvent.getParameter("itemPress");
1238
- var oItem;
1239
- var aConditions = this.getConditions();
1240
- var oCondition;
1241
- var i = 0;
1242
- var j = 0;
1243
- var bFound = false;
1244
- var iMaxConditions = this.getMaxConditions();
1245
- var oOperator = this._getOperator();
1246
-
1247
- // try to keep order stable
1248
- // remove only EQ selections that can be changed from content control
1249
- for (i = aConditions.length - 1; i >= 0; i--) {
1250
- oCondition = aConditions[i];
1251
- oCondition.inParameters = _mapInParametersToHelp.call(this, oCondition.inParameters);
1252
- oCondition.outParameters = _mapOutParametersToHelp.call(this, oCondition.outParameters);
1253
- if (oCondition.operator === oOperator.name && oCondition.validated === ConditionValidated.Validated) { // only conditions of used operator supported
1254
- bFound = false;
1255
- for (j = 0; j < aSelectedItems.length; j++) {
1256
- oItem = aSelectedItems[j];
1257
- if (oCondition.values[0] === oItem.key
1258
- && (!oCondition.inParameters || !oItem.inParameters || deepEqual(oCondition.inParameters, oItem.inParameters))
1259
- && (!oCondition.outParameters || !oItem.outParameters || deepEqual(oCondition.outParameters, oItem.outParameters))) {
1260
- bFound = true;
1261
- if (oCondition.values[1] !== oItem.description && oItem.description) {
1262
- // use description of selected item (might be changed)
1263
- if (oCondition.values.length === 1) {
1264
- oCondition.values.push(oItem.description);
1265
- } else {
1266
- oCondition.values[1] = oItem.description;
1267
- }
1268
- }
1269
- break;
1270
- }
1271
- }
1272
- if (!bFound) {
1273
- aConditions.splice(i, 1);
1274
- }
1275
- }
1276
- }
1277
-
1278
- for (i = 0; i < aSelectedItems.length; i++) {
1279
- oItem = aSelectedItems[i];
1280
- bFound = false;
1281
-
1282
- for (j = 0; j < aConditions.length; j++) {
1283
- oCondition = aConditions[j];
1284
- if (oCondition.operator === oOperator.name && oCondition.validated === ConditionValidated.Validated && oCondition.values[0] === oItem.key // only conditions of used operator supported
1285
- && (!oCondition.inParameters || deepEqual(oCondition.inParameters, oItem.inParameters))
1286
- && (!oCondition.outParameters || deepEqual(oCondition.outParameters, oItem.outParameters))) {
1287
- bFound = true;
1288
- oCondition.inParameters = oItem.inParameters; // to add if not already set
1289
- oCondition.outParameters = oItem.outParameters; // to add if not already set
1290
- break;
1291
- }
1292
- }
1293
-
1294
- if (!bFound) {
1295
- oCondition = this._createCondition(oItem.key, oItem.description, oItem.inParameters, oItem.outParameters);
1296
- aConditions.push(oCondition);
1297
- }
1298
- }
1299
-
1300
- if (iMaxConditions > 0 && aConditions.length > iMaxConditions) {
1301
- aConditions.splice(0, aConditions.length - iMaxConditions);
1302
- }
1303
-
1304
- for (i = 0; i < aConditions.length; i++) {
1305
- oCondition = aConditions[i];
1306
- if (oCondition.inParameters) {
1307
- oCondition.inParameters = _mapInParametersToField.call(this, oCondition.inParameters);
1308
- } else {
1309
- delete oCondition.inParameters;
1310
- }
1311
- if (oCondition.outParameters) {
1312
- oCondition.outParameters = _mapOutParametersToField.call(this, oCondition.outParameters);
1313
- } else {
1314
- delete oCondition.outParameters;
1315
- }
1316
- }
1317
-
1318
- if (this._bDialogOpen) {
1319
- this.setProperty("conditions", aConditions, true); // do not invalidate whole FieldHelp
1320
- } else {
1321
- // suggestion -> fire select event directly
1322
- var bAdd = false;
1323
- var bClose = false;
1324
- if (this.getMaxConditions() === 1 || bItemPress) { // in single selection mode close
1325
- this.close();
1326
- bClose = true;
1327
- }
1328
- if (this.getMaxConditions() === 1) {
1329
- bAdd = true; // in single selection mode conditions are just added
1330
- }
1331
- this.setProperty("conditions", aConditions, true); // do not invalidate whole FieldHelp
1332
- this.fireSelect({conditions: aConditions, add: bAdd, close: bClose});
1333
- }
1334
-
1335
- }
1336
-
1337
- function _handleDataUpdate(oEvent) {
1338
-
1339
- var bContentChange = oEvent.getParameter("contentChange");
1340
- var oWrapper = oEvent.getSource();
1341
- var oPopover;
1342
-
1343
- if (oWrapper.enableShowAllItems()) {
1344
- oPopover = this.getAggregation("_popover");
1345
- var oShowAllItemsFooter = oPopover && oPopover.getFooter();
1346
- if (oShowAllItemsFooter) {
1347
- oShowAllItemsFooter.setVisible(!oWrapper.getAllItemsShown());
1348
- }
1349
- }
1350
-
1351
- if (bContentChange) {
1352
- oPopover = oPopover || this.getAggregation("_popover");
1353
- var oDialog = this.getAggregation("_dialog");
1354
- if (oPopover && this._bOpenIfContent) {
1355
- oWrapper = _getWrapper.call(this, true);
1356
- if (oWrapper) {
1357
- var oField = this._getField();
1358
- if (oField) {
1359
- oWrapper.fieldHelpOpen(true);
1360
- oPopover.openBy(this._getControlForSuggestion());
1361
- // apply filters now
1362
- _applyFilters.call(this);
1363
- }
1364
- this._bOpenIfContent = false;
1365
- }
1366
- } else if (oDialog) {
1367
- oWrapper = _getWrapper.call(this, false);
1368
- if (oWrapper) {
1369
- var oValueHelpPanel = oDialog.getContent()[0];
1370
- _setContentOnValueHelpPanel.call(this, oValueHelpPanel, oWrapper.getDialogContent());
1371
- if (!this._bApplyFilter && !this._bClosing && (this.isOpen() || this._bOpen) && !oWrapper.isSuspended()) {
1372
- // in case ListBinding changed or is not longer suspended
1373
- this._bApplyFilter = true;
1374
- }
1375
- }
1376
- }
1377
- }
1378
-
1379
- if (!oWrapper || !oWrapper.getAsyncKeyText()) {
1380
- // if asynchronously loading of key or description is supported fields needs no update on data change
1381
- // Format or parse promise waits until table is set and request returned.
1382
- this.fireDataUpdate();
1383
- }
1384
-
1385
- }
1386
-
1387
- function _updateConditions(aConditions) {
1388
-
1389
- // validate flag must be set in the right way to show right conditions on DefineConditionPanel
1390
- var bUpdate = false;
1391
- for (var i = 0; i < aConditions.length; i++) {
1392
- var oCondition = aConditions[i];
1393
- if (!oCondition.validated) {
1394
- FilterOperatorUtil.checkConditionValidated(oCondition);
1395
- bUpdate = true;
1396
- }
1397
- }
1398
-
1399
- if (bUpdate) {
1400
- this.setConditions(aConditions);
1401
- } else {
1402
- _updateSelectedItems.call(this);
1403
- }
1404
-
1405
- }
1406
-
1407
- function _updateSelectedItems() {
1408
-
1409
- if (!this._oField) {
1410
- return; // makes only sense if connected
1411
- }
1412
-
1413
- // TODO: only for the needed wrapper
1414
- _updateSelectedItemsOnWrapper.call(this, _getWrapper.call(this, true));
1415
- _updateSelectedItemsOnWrapper.call(this, _getWrapper.call(this, false));
1416
-
1417
- }
1418
-
1419
- function _updateSelectedItemsOnWrapper(oWrapper) {
1420
-
1421
- if (oWrapper) {
1422
- var oOperator = this._getOperator();
1423
- var aConditions = this.getConditions();
1424
- var aItems = [];
1425
- for (var i = 0; i < aConditions.length; i++) {
1426
- var oCondition = aConditions[i];
1427
- if (oCondition.operator === oOperator.name && oCondition.validated === ConditionValidated.Validated) { // only conditions of used operator supported
1428
- aItems.push({
1429
- key: oCondition.values[0],
1430
- description: oCondition.values[1],
1431
- inParameters: _mapInParametersToHelp.call(this, oCondition.inParameters),
1432
- outParameters: _mapOutParametersToHelp.call(this, oCondition.outParameters)
1433
- });
1434
- }
1435
- }
1436
- if (!deepEqual(aItems, oWrapper.getSelectedItems())) {
1437
- oWrapper.setSelectedItems(aItems);
1438
- }
1439
- }
1440
-
1441
- }
1442
-
1443
- function _filterContent(sFilterText) {
1444
-
1445
- var sFilterFields = this.getFilterFields();
1446
-
1447
- if (!sFilterFields) {
1448
- return; // we don't know how to filter
1449
- }
1450
-
1451
- var aConditions = _getConditions.call(this, sFilterFields);
1452
- var sFilterValue = aConditions.length > 0 ? aConditions[0].values[0] : "";
1453
- if (sFilterText === sFilterValue) {
1454
- // not changed
1455
- return;
1456
- }
1457
-
1458
- _removeConditions.call(this, sFilterFields);
1459
- sFilterText = sFilterText.trim();
1460
- if (sFilterText) {
1461
- this._bOwnFilterChange = false;
1462
- var oCondition = Condition.createCondition("StartsWith", [sFilterText], undefined, undefined, ConditionValidated.NotValidated);
1463
- _addCondition.call(this, sFilterFields, oCondition);
1464
- }
1465
-
1466
- _applyFilters.call(this, true);
1467
-
1468
- }
1469
-
1470
- // IN/OUT handling
1471
- function _inParametersChanged(oInParameter, sMutation) {
1472
-
1473
- var sFilterPath = oInParameter.getHelpPath();
1474
- var bUpdate = false;
1475
-
1476
- if (sMutation === "remove") {
1477
- this._oObserver.unobserve(oInParameter);
1478
- if (this._getField() && this.isOpen()) {
1479
- bUpdate = _removeInFilter.call(this, sFilterPath);
1480
- }
1481
- } else {
1482
- this._oObserver.observe(oInParameter, {properties: true});
1483
- if (this._getField() && this.isOpen()) {
1484
- var vValue = oInParameter.getValue();
1485
- var bUseConditions = oInParameter.getUseConditions();
1486
- var bInitialValueFilterEmpty = oInParameter.getInitialValueFilterEmpty();
1487
- bUpdate = _removeInFilter.call(this, sFilterPath); // if exist, remove old filter
1488
- bUpdate = _addInFilter.call(this, sFilterPath, vValue, bUseConditions, bInitialValueFilterEmpty) || bUpdate; // eslint-disable-line
1489
- _updateSelectedItems.call(this); // as mapping of in-parameters could change
1490
- }
1491
- }
1492
-
1493
- _applyFilters.call(this, true); // call async to handle more inParamers at one time
1494
-
1495
- }
1496
-
1497
- function _addInFilter(sFilterPath, vValue, bUseConditions, bInitialValueFilterEmpty) {
1498
-
1499
- var oCondition;
1500
- var bUpdate = false;
1501
-
1502
- if (sFilterPath && (vValue || (bInitialValueFilterEmpty && !bUseConditions))) { // TODO: support boolean?
1503
- if (bUseConditions) {
1504
- if (Array.isArray(vValue)) {
1505
- for (var i = 0; i < vValue.length; i++) {
1506
- oCondition = merge({}, vValue[i]);
1507
- // change paths of in- and out-parameters
1508
- if (oCondition.inParameters) {
1509
- oCondition.inParameters = _mapInParametersToHelp.call(this, oCondition.inParameters, true);
1510
- }
1511
- if (oCondition.outParameters) {
1512
- oCondition.outParameters = _mapOutParametersToHelp.call(this, oCondition.outParameters, false, true);
1513
- }
1514
-
1515
- _addCondition.call(this, sFilterPath, oCondition);
1516
- bUpdate = true;
1517
- }
1518
- }
1519
- } else {
1520
- if (!vValue && bInitialValueFilterEmpty) {
1521
- oCondition = Condition.createCondition("Empty", []);
1522
- oCondition.isEmpty = false; // no explicit check needed
1523
- } else {
1524
- // TODO: way to provide description on InParameter
1525
- // validated to let FilterField determine description if visible on FilterBar.
1526
- // Also to show it as selected on table in FieldHelp of FilterField.
1527
- oCondition = Condition.createItemCondition(vValue);
1528
- oCondition.validated = ConditionValidated.Validated;
1529
- }
1530
- _addCondition.call(this, sFilterPath, oCondition);
1531
- bUpdate = true;
1532
- }
1533
- }
1534
-
1535
- return bUpdate;
1536
-
1537
- }
1538
-
1539
- function _removeInFilter(sFilterPath) {
1540
-
1541
- var bUpdate = false;
1542
-
1543
- if (sFilterPath && _getConditions.call(this, sFilterPath).length > 0) {
1544
- _removeConditions.call(this, sFilterPath); // TODO: remove only filters from In-parameters, not from FilterBar
1545
- bUpdate = true;
1546
- }
1547
-
1548
- return bUpdate;
1549
-
1550
- }
1551
-
1552
- function _inParameterValueChanged(sFilterPath, vValue, vOldValue, bUseConditions, bInitialValueFilterEmpty) {
1553
-
1554
- if (this._bNoInOutFilterUpdate) {
1555
- // just a updaste of BindingContext during formatting/parsing -> do not update Filter as it will changed back soon.
1556
- return;
1557
- }
1558
-
1559
- if (!this._iUpdateTimer) { // do async as it can take a while until model updates all bindings.
1560
- this._iUpdateTimer = setTimeout(function() {
1561
- this._iUpdateTimer = undefined;
1562
- this.fireDataUpdate(); // to update text
1563
- }.bind(this), 0);
1564
- }
1565
-
1566
- if (!this._getField() || !this.isOpen()) {
1567
- return;
1568
- }
1569
-
1570
- var bUpdate = false;
1571
-
1572
- bUpdate = _removeInFilter.call(this, sFilterPath); // if exist, remove old filter
1573
- bUpdate = _addInFilter.call(this, sFilterPath, vValue, bUseConditions, bInitialValueFilterEmpty) || bUpdate; // eslint-disable-line
1574
- _updateSelectedItems.call(this); // as default in-parameters could change
1575
-
1576
- _applyFilters.call(this, true); // call async to handle more inParamers at one time
1577
-
1578
- }
1579
-
1580
- function _inParameterPathChanged(sFilterPath, sOldFilterPath, vValue, bUseConditions, bInitialValueFilterEmpty) {
1581
-
1582
- if (!this._getField() || !this.isOpen()) {
1583
- return;
1584
- }
1585
-
1586
- var bUpdate = false;
1587
-
1588
- bUpdate = _removeInFilter.call(this, sOldFilterPath); // if exist, remove old filter
1589
- bUpdate = _addInFilter.call(this, sFilterPath, vValue, bUseConditions, bInitialValueFilterEmpty) || bUpdate; // eslint-disable-line
1590
-
1591
- _applyFilters.call(this, true); // call async to handle more inParamers at one time
1592
-
1593
- }
1594
-
1595
- function _setInParameterFilters() { // if closed, InParameters are not added to FilterBar or conditions, so do it here
1596
-
1597
- var aInParameters = this.getInParameters();
1598
- var bUpdate = false;
1599
-
1600
- for (var i = 0; i < aInParameters.length; i++) {
1601
- var oInParameter = aInParameters[i];
1602
- var sFilterPath = oInParameter.getHelpPath();
1603
- var vValue = oInParameter.getValue();
1604
- var bUseConditions = oInParameter.getUseConditions();
1605
- var bInitialValueFilterEmpty = oInParameter.getInitialValueFilterEmpty();
1606
- bUpdate = _removeInFilter.call(this, sFilterPath) || bUpdate; // if exist, remove old filter
1607
- bUpdate = _addInFilter.call(this, sFilterPath, vValue, bUseConditions, bInitialValueFilterEmpty) || bUpdate;
1608
- }
1609
-
1610
- if (bUpdate || (this._bApplyFilter && this._bPendingFilterUpdate)) {
1611
- // updated or maybe filter change while closed, so trigger check now
1612
- this._bPendingFilterUpdate = false;
1613
- _applyFilters.call(this, true);
1614
- }
1615
-
1616
- }
1617
-
1618
- FieldValueHelp.prototype.onFieldChange = function() {
1619
-
1620
- // apply out-parameters
1621
- var aOutParameters = this.getOutParameters();
1622
-
1623
- // as BindingContext of Field might change (happens if fast typed and FieldHelp not opened) update if needed
1624
- _updateBindingContext.call(this);
1625
-
1626
-
1627
- // if OutParameters are bound and binding is pending, wait until finished
1628
- var aOutBindings = _getParameterBinding.call(this, aOutParameters, false);
1629
- SyncPromise.resolve().then(function() {
1630
- return _checkBindingsPending.call(this, aOutBindings);
1631
- }.bind(this)).then(function() {
1632
- if (this.bIsDestroyed) {
1633
- return; // id festroyed meanwhile, don't update
1634
- }
1635
- var aConditions = this.getConditions();
1636
- for (var i = 0; i < aConditions.length; i++) {
1637
- var oCondition = aConditions[i];
1638
- if (oCondition.outParameters) {
1639
- for ( var sPath in oCondition.outParameters) {
1640
- for (var j = 0; j < aOutParameters.length; j++) {
1641
- var oOutParameter = aOutParameters[j];
1642
- var vValue = oOutParameter.getValue();
1643
- var bUseConditions = oOutParameter.getUseConditions();
1644
- var bUpdate = true;
1645
- if (oOutParameter.getMode() === OutParameterMode.WhenEmpty) {
1646
- if (bUseConditions) {
1647
- bUpdate = !vValue || (Array.isArray(vValue) && vValue.length === 0);
1648
- } else {
1649
- bUpdate = !vValue;
1650
- }
1651
- }
1652
- if (bUpdate) {
1653
- if (bUseConditions) {
1654
- var oNewCondition;
1655
- if (!oOutParameter.getHelpPath()) {
1656
- oNewCondition = Condition.createCondition("EQ", [oOutParameter.getFixedValue()], undefined, undefined, ConditionValidated.NotValidated);
1657
- } else if (oOutParameter.getFieldPath() === sPath) { // in Conditions fieldPath is used
1658
- oNewCondition = Condition.createCondition("EQ", [oCondition.outParameters[sPath]], undefined, undefined, ConditionValidated.Validated); // as choosen from help -> validated
1659
-
1660
- // TODO: handle in/out Parameters in ConditionModel (to let the condition know it's out-Parameters)
1661
- // var oBinding = oOutParameter.getBinding("value");
1662
- // var oCM = oBinding && oBinding.getModel();
1663
-
1664
- // if (oCM && oCM.isA("sap.ui.mdc.condition.ConditionModel")) {
1665
- // // TODO: what if In-parameters are set late (by open) ?
1666
- // var oFilterField = oCM.getFilterField(sPath);
1667
- // var sFieldHelpID = oFilterField && oFilterField.getFieldHelp();
1668
- // var oFieldHelp = sFieldHelpID && sap.ui.getCore().byId(sFieldHelpID);
1669
-
1670
- // if (oFieldHelp) {
1671
- // // set in/out parameter to new condition.
1672
- // var aParameters = oFieldHelp.getInParameters();
1673
- // var k = 0;
1674
- // var sFieldPath;
1675
- // var oFilterFieldParameter;
1676
- // for (k = 0; k < aParameters.length; k++) {
1677
- // oFilterFieldParameter = aParameters[k];
1678
- // sFieldPath = oFilterFieldParameter.getFieldPath();
1679
- // if (oCondition.outParameters[sFieldPath]) {
1680
- // if (!oNewCondition.inParameters) {
1681
- // oNewCondition.inParameters = {};
1682
- // }
1683
- // oNewCondition.inParameters[sFieldPath] = oCondition.outParameters[sFieldPath];
1684
- // }
1685
- // }
1686
- // aParameters = oFieldHelp.getOutParameters();
1687
- // for (k = 0; k < aParameters.length; k++) {
1688
- // oFilterFieldParameter = aParameters[k];
1689
- // sFieldPath = oFilterFieldParameter.getFieldPath();
1690
- // if (oCondition.outParameters[sFieldPath]) {
1691
- // if (!oNewCondition.outParameters) {
1692
- // oNewCondition.outParameters = {};
1693
- // }
1694
- // oNewCondition.outParameters[sFieldPath] = oCondition.outParameters[sFieldPath];
1695
- // }
1696
- // }
1697
- // }
1698
- // }
1699
- } else {
1700
- continue;
1701
- }
1702
- if (!vValue) {
1703
- vValue = [];
1704
- }
1705
- if (!Array.isArray(vValue)) {
1706
- throw new Error("Value on OutParameter must be an array " + oOutParameter);
1707
- }
1708
- if (FilterOperatorUtil.indexOfCondition(oNewCondition, vValue) < 0) {
1709
- oNewCondition.validated = ConditionValidated.Validated; // out-parameters are validated
1710
- vValue.push(oNewCondition);
1711
- oOutParameter.setValue(vValue);
1712
- }
1713
- } else if (!oOutParameter.getHelpPath()) {
1714
- oOutParameter.setValue(oOutParameter.getFixedValue());
1715
- } else if (oOutParameter.getFieldPath() === sPath) { // in Conditions fieldPath is used
1716
- oOutParameter.setValue(oCondition.outParameters[sPath]);
1717
- }
1718
- }
1719
- }
1720
- }
1721
- }
1722
- }
1723
- }.bind(this)).unwrap();
1724
-
1725
- };
1726
-
1727
- function _mapInParametersToField(oInParameters) {
1728
-
1729
- return _mapParametersToField.call(this, oInParameters, this.getInParameters());
1730
-
1731
- }
1732
-
1733
- function _mapOutParametersToField(oOutParameters) {
1734
-
1735
- return _mapParametersToField.call(this, oOutParameters, this.getOutParameters());
1736
-
1737
- }
1738
-
1739
- function _mapParametersToField(oParameters, aParameters) {
1740
-
1741
- if (!oParameters || aParameters.length === 0) {
1742
- return null;
1743
- }
1744
-
1745
- var oFieldParameters = {};
1746
-
1747
- for (var i = 0; i < aParameters.length; i++) {
1748
- var oParameter = aParameters[i];
1749
- var sHelpPath = oParameter.getHelpPath();
1750
- var sFieldPath = oParameter.getFieldPath();
1751
- if (sHelpPath && sFieldPath) {
1752
- for (var sMyFieldPath in oParameters) {
1753
- if (sHelpPath === sMyFieldPath) {
1754
- oFieldParameters[sFieldPath] = oParameters[sMyFieldPath];
1755
- break;
1756
- }
1757
- }
1758
- } else if (!sHelpPath && sFieldPath && oParameter.getFixedValue) {
1759
- // if helpPath is not set we expect a fix value for out-parameter
1760
- oFieldParameters[sFieldPath] = oParameter.getFixedValue();
1761
- }
1762
- }
1763
-
1764
- return oFieldParameters;
1765
-
1766
- }
1767
-
1768
- function _mapInParametersToHelp(oInParameters, bNested) {
1769
-
1770
- return _mapParametersToHelp.call(this, oInParameters, this.getInParameters(), false, undefined, undefined, false, bNested);
1771
-
1772
- }
1773
-
1774
- function _mapOutParametersToHelp(oOutParameters, bNoDefault, bNested) {
1775
-
1776
- return _mapParametersToHelp.call(this, oOutParameters, this.getOutParameters(), bNoDefault, undefined, undefined, false, bNested);
1777
-
1778
- }
1779
-
1780
- function _mapParametersToHelp(oParameters, aParameters, bNoDefault, aBindings, oBindingContext, bFilters, bNested) {
1781
-
1782
- var oHelpParameters;
1783
- var oParameter;
1784
- var sHelpPath;
1785
- var sFieldPath;
1786
- var i = 0;
1787
- var oCondition;
1788
-
1789
- if (aParameters.length > 0) {
1790
- if (!oParameters) {
1791
- if (!bNoDefault) {
1792
- // use current values of in/out-parameters as default
1793
- // in case of getTextForKey only out-parameters set by condition are from interest (To find manual selected entry again if no in-paramters are used)
1794
- // in this case only provided parameters are from interest.
1795
- // If Bindings are provided (from different BindingContext) use the value of this Binding
1796
- var oMyBindingContext = this.getBindingContext();
1797
- for (i = 0; i < aParameters.length; i++) {
1798
- oParameter = aParameters[i];
1799
- sHelpPath = bNested ? "conditions/" + oParameter.getHelpPath() : oParameter.getHelpPath(); // if InParameter of InParameter it is part of the same FilterBar
1800
- var vValue = oParameter.getValue();
1801
- var bUseConditions = oParameter.getUseConditions();
1802
- var bInitialValueFilterEmpty = oParameter.getInitialValueFilterEmpty();
1803
- var j = 0;
1804
- if (aBindings || oBindingContext) {
1805
- var oBinding = oParameter.getBinding("value");
1806
- var bFound = false;
1807
- if (oBinding || bUseConditions) {
1808
- sFieldPath = oParameter.getFieldPath();
1809
- for (j = 0; j < aBindings.length; j++) {
1810
- if ((oBinding && oBinding.getPath() === aBindings[j].getPath()) ||
1811
- (bUseConditions && aBindings[j].getPath() === "/" + sFieldPath)) {
1812
- vValue = aBindings[j].getValue();
1813
- bFound = true;
1814
- break;
1815
- }
1816
- }
1817
- if (!bFound && !bUseConditions && oBindingContext && oBinding && oBinding.isRelative() && (!oBinding.getContext() || (oBinding.getContext() !== oBindingContext && oBinding.getContext() === oMyBindingContext))) {
1818
- // no new binding created and different BindingContext -> use propery from BindingConext (was already read before)
1819
- vValue = oBindingContext.getProperty(oBinding.getPath());
1820
- }
1821
- }
1822
- }
1823
-
1824
- if (sHelpPath) {
1825
- if (!oHelpParameters) {
1826
- oHelpParameters = {};
1827
- }
1828
- if (bFilters) {
1829
- // create Filter statements here as here the data type of the Parameters can be determined
1830
- // allow multiple values
1831
- // ignore empty conditions for filtering
1832
- oHelpParameters[sHelpPath] = [];
1833
- if (bUseConditions) { // just use conditions
1834
- if (!vValue) {
1835
- vValue = []; // if ConditionModel Binding not initilaized in the moment
1836
- }
1837
- for (j = 0; j < vValue.length; j++) {
1838
- oCondition = merge({}, vValue[j]);
1839
- // change paths of in- and out-parameters
1840
- if (oCondition.inParameters) {
1841
- oCondition.inParameters = _mapInParametersToHelp.call(this, oCondition.inParameters, true);
1842
- }
1843
- if (oCondition.outParameters) {
1844
- oCondition.outParameters = _mapOutParametersToHelp.call(this, oCondition.outParameters, false, true);
1845
- }
1846
- oHelpParameters[sHelpPath].push(oCondition);
1847
- }
1848
- } else {
1849
- if (!vValue && bInitialValueFilterEmpty) {
1850
- oCondition = Condition.createCondition("Empty", []);
1851
- oCondition.isEmpty = false; // no explicit check needed
1852
- } else if (vValue) {
1853
- oCondition = Condition.createItemCondition(vValue);
1854
- oCondition.validated = ConditionValidated.Validated;
1855
- }
1856
- if (oCondition) {
1857
- oHelpParameters[sHelpPath].push(oCondition);
1858
- }
1859
- }
1860
- oCondition = undefined;
1861
- } else { // also add empty values to InParameter to allow comparison
1862
- if (bUseConditions) {
1863
- // TODO: What if there are multiple conditions or not EQ?
1864
- if (vValue && vValue.length > 0) {
1865
- oHelpParameters[sHelpPath] = vValue[0].values[0];
1866
- }
1867
- } else {
1868
- oHelpParameters[sHelpPath] = vValue;
1869
- }
1870
- }
1871
- }
1872
- }
1873
- }
1874
- } else {
1875
- for (var sMyFieldPath in oParameters) {
1876
- for (i = 0; i < aParameters.length; i++) {
1877
- oParameter = aParameters[i];
1878
- sHelpPath = bNested ? "conditions/" + oParameter.getHelpPath() : oParameter.getHelpPath(); // if InParameter of InParameter it is part of the same FilterBar
1879
- sFieldPath = oParameter.getFieldPath();
1880
- if (sFieldPath && (sFieldPath === sMyFieldPath || sFieldPath === "conditions/" + sMyFieldPath) && sHelpPath) { // support also old saved conditions without "conditions/" in name
1881
- if (!oHelpParameters) {
1882
- oHelpParameters = {};
1883
- }
1884
- if (bFilters) { // create conditions
1885
- oHelpParameters[sHelpPath] = [];
1886
- oCondition = Condition.createItemCondition(oParameters[sMyFieldPath]);
1887
- oCondition.validated = ConditionValidated.Validated;
1888
- oHelpParameters[sHelpPath].push(oCondition);
1889
- } else {
1890
- oHelpParameters[sHelpPath] = oParameters[sMyFieldPath];
1891
- }
1892
- }
1893
- }
1894
- }
1895
- }
1896
- if (bFilters) {
1897
- // return filters for filtering
1898
- var oConditionTypes = this._getTypesForConditions(oHelpParameters);
1899
- var oFilter = FilterConverter.createFilters(oHelpParameters, oConditionTypes);
1900
- oHelpParameters = oFilter;
1901
- }
1902
- }
1903
-
1904
- return oHelpParameters;
1905
-
1906
- }
1907
-
1908
- function _applyFilters(bAsync) {
1909
-
1910
- if (bAsync) {
1911
- if (!this._iFilterTimer) {
1912
- this._iFilterTimer = setTimeout(function() {
1913
- this._iFilterTimer = undefined;
1914
- _applyFilters.call(this);
1915
- }.bind(this), 0);
1916
- }
1917
- return;
1918
- } else if (this._iFilterTimer) {
1919
- clearTimeout(this._iFilterTimer);
1920
- this._iFilterTimer = undefined;
1921
- }
1922
-
1923
- if ((!this.isOpen() && !this._bNavigateRunning && !this._bOpen) || (this._bClosing && !this._bSwitchToDialog) || !this._bApplyFilter) {
1924
- // apply filters only if open (no request on closed FieldHelp)
1925
- this._bPendingFilterUpdate = true;
1926
- return;
1927
- }
1928
-
1929
- if (this._bFilterWaitingForBinding) {
1930
- // there is already a pending request, this will use the current filters. Don't rigger an additional request.
1931
- return;
1932
- }
1933
-
1934
- // if InParameter value is pending -> wait until it is set
1935
- var aInParameters = this.getInParameters();
1936
- var aInBindings = _getParameterBinding.call(this, aInParameters, false);
1937
- var oBindingPendingPromise = _checkBindingsPending.call(this, aInBindings); // If curently resolved do not check again
1938
-
1939
- if (oBindingPendingPromise instanceof Promise) {
1940
- oBindingPendingPromise.then(function() {
1941
- // promise on binding is resolved before property updated on InParameter or update triggered in ConditionModel
1942
- this._bFilterWaitingForBinding = false;
1943
- _applyFilters.call(this, true); // trigger after the InParameter "value" property was updated and even if InParameter is empty
1944
- }.bind(this));
1945
- this._bFilterWaitingForBinding = true;
1946
- return;
1947
- }
1948
-
1949
- // TODO: better way to detrmine what wrapper to use
1950
- var oDialog = this.getAggregation("_dialog");
1951
- var bSuggestion = (!oDialog || !oDialog.isOpen()) && !(this._bClosing && this._bSwitchToDialog); // if switching to dialog use dialog-wrapper
1952
-
1953
- var oWrapper = _getWrapper.call(this, bSuggestion);
1954
- if (oWrapper) {
1955
- var oFilterBar = this._getFilterBar();
1956
- var oConditions;
1957
-
1958
- if (oFilterBar) {
1959
- oConditions = oFilterBar.getInternalConditions();
1960
- } else {
1961
- // no FilterBar used - use lokal condition
1962
- oConditions = this._oConditions;
1963
- }
1964
-
1965
- var oConditionTypes = this._getTypesForConditions(oConditions);
1966
- var oFilter = FilterConverter.createFilters( oConditions, oConditionTypes, undefined, this.getCaseSensitive());
1967
- var aFilters = [];
1968
- var aSearchConditions = oConditions["$search"];
1969
- var sSearch;
1970
-
1971
- if (oFilter) {
1972
- aFilters.push(oFilter);
1973
- }
1974
-
1975
- if (aSearchConditions && aSearchConditions.length > 0) {
1976
- sSearch = aSearchConditions[0].values[0];
1977
- }
1978
-
1979
- oWrapper.applyFilters(aFilters, sSearch, oFilterBar);
1980
- }
1981
-
1982
- }
1983
-
1984
- /**
1985
- * Returns a condition type map for the valuehelp filterbar
1986
- *
1987
- * @returns {object} condition types map
1988
- * @private
1989
- * @ui5-restricted sap.ui.mdc.field.FieldValueHelpContentWrapperBase
1990
- */
1991
- FieldValueHelp.prototype._getTypesForConditions = function (oConditions) {
1992
-
1993
- var oFilterBar = this.getFilterBar();
1994
- var aInParameters = this.getInParameters();
1995
- var oConditionTypes;
1996
- var sFieldPath;
1997
-
1998
- if (oFilterBar) {
1999
- oConditionTypes = FilterConverter.createConditionTypesMapFromFilterBar( oConditions, oFilterBar);
2000
- } else {
2001
- // collect condition Fieldpaths here
2002
- oConditionTypes = {};
2003
- for (sFieldPath in oConditions) {
2004
- oConditionTypes[sFieldPath] = {type: null};
2005
- }
2006
- }
2007
-
2008
- // try to find missing type from InParameter
2009
- for (sFieldPath in oConditionTypes) {
2010
- if (!oConditionTypes[sFieldPath].type) {
2011
- for (var i = 0; i < aInParameters.length; i++) {
2012
- var oInParameter = aInParameters[i];
2013
- if (oInParameter.getHelpPath() === sFieldPath) {
2014
- oConditionTypes[sFieldPath].type = oInParameter.getDataType();
2015
- break;
2016
- }
2017
- }
2018
- }
2019
- }
2020
-
2021
- return oConditionTypes;
2022
-
2023
- };
2024
-
2025
-
2026
- FieldValueHelp.prototype.getMaxConditions = function() {
2027
-
2028
- if (this._oField && this._oField.getMaxConditionsForHelp) {
2029
- // if Field or FilterField -> use it's MaxConditions
2030
- return this._oField.getMaxConditionsForHelp();
2031
- } else if (this._oField && this._oField.getMaxConditions) {
2032
- // if Field or FilterField -> use it's MaxConditions
2033
- return this._oField.getMaxConditions();
2034
- } else {
2035
- // TODO: how to set if field not provide MaxConditions?
2036
- return 1;
2037
- }
2038
-
2039
- };
2040
-
2041
- FieldValueHelp.prototype.getDisplay = function() {
2042
-
2043
- if (this._oField && this._oField.getDisplay) {
2044
- // if Field or FilterField -> use it's Display
2045
- return this._oField.getDisplay();
2046
- }
2047
-
2048
- };
2049
-
2050
- FieldValueHelp.prototype.getRequired = function() {
2051
-
2052
- if (this._oField && this._oField.getRequired) {
2053
- // if Field or FilterField -> use it's Required
2054
- return this._oField.getRequired();
2055
- } else {
2056
- // TODO: default false?
2057
- return false;
2058
- }
2059
-
2060
- };
2061
-
2062
- FieldValueHelp.prototype.getDataType = function() {
2063
-
2064
- if (this._oField.getDataType) {
2065
- // if Field or FilterField -> use it's DataType
2066
- return this._oField.getDataType();
2067
- } else {
2068
- // TODO: default case?
2069
- return "sap.ui.model.type.String";
2070
- }
2071
-
2072
- };
2073
-
2074
- /**
2075
- * Return field-internal information stored in <code>FormatOptions</code>.
2076
- *
2077
- * @returns {object} formatOptions of the field
2078
- * @private
2079
- * @ui5-restricted sap.ui.mdc.field.FieldValueHelpContentWrapperBase
2080
- */
2081
- FieldValueHelp.prototype._getFormatOptions = function() {
2082
-
2083
- if (this._oField && this._oField._getFormatOptions) {
2084
- // if Field or FilterField -> use it's DataType, Delegate....
2085
- return this._oField._getFormatOptions();
2086
- } else {
2087
- return {};
2088
- }
2089
-
2090
- };
2091
-
2092
- /**
2093
- * Returns the path of the key field inside the content control (for example, table).
2094
- *
2095
- * @returns {string} Key path
2096
- * @private
2097
- * @ui5-restricted sap.ui.mdc.field.FieldValueHelpContentWrapperBase
2098
- */
2099
- FieldValueHelp.prototype._getKeyPath = function() {
2100
-
2101
- var sKeyPath = this.getKeyPath();
2102
-
2103
- if (!sKeyPath && this._oField && this._oField.getFieldPath && this._oField.getFieldPath()) {
2104
- sKeyPath = this._oField.getFieldPath();
2105
- }
2106
-
2107
- return sKeyPath;
2108
-
2109
- };
2110
-
2111
-
2112
- /**
2113
- * Returns the relevant filterbar of this valuehelp.
2114
- *
2115
- * @returns {sap.ui.mdc.FilterBar} relevant filterbar
2116
- * @private
2117
- * @ui5-restricted sap.ui.mdc.field.FieldValueHelpContentWrapperBase
2118
- */
2119
- FieldValueHelp.prototype._getFilterBar = function() {
2120
-
2121
- var oFilterBar = this.getFilterBar();
2122
-
2123
- if (!oFilterBar) {
2124
- oFilterBar = this.getAggregation("_filterBar");
2125
- }
2126
-
2127
- return oFilterBar;
2128
-
2129
- };
2130
-
2131
- FieldValueHelp.prototype.clone = function(sIdSuffix, aLocalIds) {
2132
-
2133
- // detach event handler before cloning to not have it twice on the clone
2134
- // attach it after clone again
2135
- var aWrappers = [this.getContent(), this.getSuggestContent(), this.getDialogContent()];
2136
- var oFilterBar = this.getFilterBar();
2137
- var i = 0;
2138
- var oWrapper;
2139
-
2140
- for (i = 0; i < aWrappers.length; i++) {
2141
- oWrapper = aWrappers[i];
2142
- if (oWrapper) {
2143
- oWrapper.detachEvent("navigate", _handleNavigate, this);
2144
- oWrapper.detachEvent("selectionChange", _handleSelectionChange, this);
2145
- oWrapper.detachEvent("dataUpdate", _handleDataUpdate, this);
2146
- }
2147
- }
2148
-
2149
- if (oFilterBar) {
2150
- oFilterBar.detachEvent("search", _updateFiltersFromFilterBar, this);
2151
- }
2152
-
2153
- var oClone = FieldHelpBase.prototype.clone.apply(this, arguments);
2154
-
2155
- for (i = 0; i < aWrappers.length; i++) {
2156
- oWrapper = aWrappers[i];
2157
- if (oWrapper) {
2158
- oWrapper.attachEvent("navigate", _handleNavigate, this);
2159
- oWrapper.attachEvent("selectionChange", _handleSelectionChange, this);
2160
- oWrapper.attachEvent("dataUpdate", _handleDataUpdate, this);
2161
- }
2162
- }
2163
-
2164
- if (oFilterBar) {
2165
- oFilterBar.attachEvent("search", _updateFiltersFromFilterBar, this);
2166
- }
2167
-
2168
- return oClone;
2169
-
2170
- };
2171
-
2172
- function _createDialog() {
2173
-
2174
- var oDialog;
2175
-
2176
- if ((!Dialog || !Button || !ValueHelpPanel || !DefineConditionPanel || !ManagedObjectModel || !FilterBar || !FilterField || !CollectiveSearchSelect || !Item) && !this._bDialogRequested) {
2177
- Dialog = sap.ui.require("sap/m/Dialog");
2178
- Button = sap.ui.require("sap/m/Button");
2179
- ValueHelpPanel = sap.ui.require("sap/ui/mdc/field/ValueHelpPanel");
2180
- DefineConditionPanel = sap.ui.require("sap/ui/mdc/field/DefineConditionPanel"); // TODO: load only if needed
2181
- ManagedObjectModel = sap.ui.require("sap/ui/model/base/ManagedObjectModel");
2182
- FilterBar = sap.ui.require("sap/ui/mdc/filterbar/vh/FilterBar");
2183
- FilterField = sap.ui.require("sap/ui/mdc/FilterField");
2184
- CollectiveSearchSelect = sap.ui.require("sap/ui/mdc/filterbar/vh/CollectiveSearchSelect");
2185
- Item = sap.ui.require("sap/ui/core/Item");
2186
- if (!Dialog || !Button || !ValueHelpPanel || !DefineConditionPanel || !ManagedObjectModel || !FilterBar || !FilterField || !CollectiveSearchSelect || !Item) {
2187
- sap.ui.require(["sap/m/Dialog", "sap/m/Button", "sap/ui/mdc/field/ValueHelpPanel",
2188
- "sap/ui/mdc/field/DefineConditionPanel", "sap/ui/model/base/ManagedObjectModel",
2189
- "sap/ui/mdc/filterbar/vh/FilterBar", "sap/ui/mdc/FilterField",
2190
- "sap/ui/mdc/filterbar/vh/CollectiveSearchSelect", "sap/ui/core/Item"], _DialogLoaded.bind(this));
2191
- this._bDialogRequested = true;
2192
- }
2193
- }
2194
- if (Dialog && Button && ValueHelpPanel && DefineConditionPanel && ManagedObjectModel && FilterBar && FilterField && CollectiveSearchSelect && Item && !this._bDialogRequested) {
2195
- if (!this._oResourceBundle) {
2196
- this._oResourceBundle = sap.ui.getCore().getLibraryResourceBundle("sap.ui.mdc");
2197
- }
2198
-
2199
- var oButtonOK = new Button(this.getId() + "-ok", {
2200
- text: this._oResourceBundle.getText("valuehelp.OK"),
2201
- enabled: "{$help>/_enableOK}",
2202
- type: ButtonType.Emphasized,
2203
- press: _dialogOk.bind(this)
2204
- });
2205
-
2206
- var oButtonCancel = new Button(this.getId() + "-cancel", {
2207
- text: this._oResourceBundle.getText("valuehelp.CANCEL"),
2208
- press: _dialogCancel.bind(this)
2209
- });
2210
-
2211
- this._oManagedObjectModel = new ManagedObjectModel(this);
2212
-
2213
- var oValueHelpPanel = _createValueHelpPanel.call(this);
2214
-
2215
- oDialog = new Dialog(this.getId() + "-dialog", {
2216
- contentHeight: _getContentHeight(),
2217
- contentWidth: _getContentWidth(),
2218
- horizontalScrolling: false,
2219
- verticalScrolling: false,
2220
- title: "{$help>/title}",
2221
- stretch: Device.system.phone,
2222
- resizable: true,
2223
- draggable: true,
2224
- content: [oValueHelpPanel],
2225
- afterOpen: _handleDialogAfterOpen.bind(this),
2226
- afterClose: _handleDialogAfterClose.bind(this),
2227
- buttons: [oButtonOK, oButtonCancel]
2228
- }).setModel(this._oManagedObjectModel, "$help");
2229
-
2230
- oDialog.isPopupAdaptationAllowed = function () {
2231
- return false;
2232
- };
2233
-
2234
- oDialog.addStyleClass("sapMdcValueHelpTitle");
2235
-
2236
- this.setAggregation("_dialog", oDialog, true);
2237
- // TODO
2238
- this.setModel(new ResourceModel({ bundleName: "sap/ui/mdc/messagebundle", async: false }), "$i18n");
2239
-
2240
- _toggleDefineConditions.call(this, this.getShowConditionPanel());
2241
- }
2242
-
2243
- return oDialog;
2244
-
2245
- }
2246
-
2247
- function _getContentHeight() {
2248
- if (Device.system.desktop) {
2249
- return "700px";
2250
- }
2251
- if (Device.system.tablet) {
2252
- return Device.orientation.landscape ? "600px" : "600px";
2253
- }
2254
- }
2255
-
2256
- function _getContentWidth() {
2257
- if (Device.system.desktop) {
2258
- return "1080px";
2259
- }
2260
- if (Device.system.tablet) {
2261
- return Device.orientation.landscape ? "920px" : "600px";
2262
- }
2263
- }
2264
-
2265
- function _DialogLoaded(fnDialog, fnButton, fnValueHelpPanel, fnDefineConditionPanel, fnManagedObjectModel, fnFilterBar, fnFilterField, fnCollectiveSearchSelect, fnItem) {
2266
-
2267
- Dialog = fnDialog;
2268
- Button = fnButton;
2269
- ValueHelpPanel = fnValueHelpPanel;
2270
- DefineConditionPanel = fnDefineConditionPanel;
2271
- ManagedObjectModel = fnManagedObjectModel;
2272
- FilterBar = fnFilterBar;
2273
- FilterField = fnFilterField;
2274
- CollectiveSearchSelect = fnCollectiveSearchSelect;
2275
- Item = fnItem;
2276
- this._bDialogRequested = false;
2277
-
2278
- if (!this._bIsBeingDestroyed) {
2279
- _createDialog.call(this);
2280
- if (this._bOpen) {
2281
- this.open();
2282
- }
2283
- }
2284
-
2285
- }
2286
-
2287
- function _createValueHelpPanel() {
2288
-
2289
- var oWrapper = _getWrapper.call(this, false);
2290
- var oFilterBar = this._getFilterBar();
2291
-
2292
- var oValueHelpPanel = new ValueHelpPanel(this.getId() + "-VHP", {
2293
- height: "100%",
2294
- showFilterbar: !!oFilterBar,
2295
- formatOptions: this._getFormatOptions(),
2296
- inputOK: "{$help>/_enableOK}"
2297
- });
2298
- oValueHelpPanel.setModel(this._oManagedObjectModel, "$help");
2299
-
2300
- if (oWrapper) {
2301
- oWrapper.initialize(false);
2302
- _setContentOnValueHelpPanel.call(this, oValueHelpPanel, oWrapper.getDialogContent());
2303
- }
2304
- if (oFilterBar) {
2305
- oValueHelpPanel.setFilterbar(oFilterBar);
2306
- }
2307
-
2308
- return oValueHelpPanel;
2309
-
2310
- }
2311
-
2312
- function _setContentOnValueHelpPanel(oValueHelpPanel, oContent) {
2313
- oValueHelpPanel.setTable(oContent);
2314
- }
2315
-
2316
- function _contentChanged(sMutation, oWrapper, sName) {
2317
-
2318
- var oPopover = this.getAggregation("_popover");
2319
- var oDialog = this.getAggregation("_dialog");
2320
- if (sMutation === "remove") {
2321
- oWrapper.detachEvent("navigate", _handleNavigate, this);
2322
- oWrapper.detachEvent("selectionChange", _handleSelectionChange, this);
2323
- oWrapper.detachEvent("dataUpdate", _handleDataUpdate, this);
2324
- oWrapper = undefined;
2325
- } else {
2326
- oWrapper.attachEvent("navigate", _handleNavigate, this);
2327
- oWrapper.attachEvent("selectionChange", _handleSelectionChange, this);
2328
- oWrapper.attachEvent("dataUpdate", _handleDataUpdate, this);
2329
- _updateSelectedItems.call(this);
2330
- }
2331
- this.fireDataUpdate();
2332
- if (this._bNavigate) {
2333
- this.navigate(this._iStep);
2334
- } else if (oPopover) {
2335
- oPopover.invalidate();
2336
- var sFilterValue = this.getFilterValue();
2337
- if (sFilterValue) {
2338
- _filterContent.call(this, sFilterValue);
2339
- }
2340
- _setInParameterFilters.call(this);
2341
-
2342
- if (oWrapper && this._bOpenIfContent) {
2343
- oWrapper.initialize(true);
2344
-
2345
- var oField = this._getField();
2346
- if (oField) {
2347
- oWrapper.fieldHelpOpen(true);
2348
- oPopover.openBy(this._getControlForSuggestion());
2349
- }
2350
- this._bOpenIfContent = false;
2351
- }
2352
- } else if (oWrapper && this._bOpenIfContent) {
2353
- this._bOpenIfContent = false;
2354
- this.open(true);
2355
- }
2356
- if (oDialog && sName !== "suggestContent" && !(sName === "content" && this.getDialogContent())) {
2357
- // update ValueHelpPanel
2358
- if (oWrapper) {
2359
- oWrapper.initialize(false);
2360
- var oValueHelpPanel = oDialog.getContent()[0];
2361
- oValueHelpPanel.setShowTokenizer(this.getMaxConditions() !== 1);
2362
- _setContentOnValueHelpPanel.call(this, oValueHelpPanel, oWrapper.getDialogContent());
2363
- if (oDialog.isOpen() || this._bOpen) {
2364
- oWrapper.fieldHelpOpen(false);
2365
- }
2366
- }
2367
- }
2368
-
2369
- }
2370
-
2371
- function _getDialog() {
2372
-
2373
- var oDialog = this.getAggregation("_dialog");
2374
-
2375
- if (!oDialog) {
2376
- oDialog = _createDialog.call(this);
2377
- }
2378
-
2379
- return oDialog;
2380
-
2381
- }
2382
-
2383
- function _dialogOk(oEvent) {
2384
-
2385
- this.close();
2386
-
2387
- var aConditions = this.getConditions();
2388
- aConditions = Condition._removeEmptyConditions(aConditions);
2389
- aConditions = Condition._removeInitialFlags(aConditions);
2390
- FilterOperatorUtil.updateConditionsValues(aConditions); // to remove static text from static conditions
2391
-
2392
- this.setProperty("conditions", aConditions, true); // do not invalidate whole FieldHelp
2393
-
2394
- // fire select event after Dialog is closed because inside applyFocusInfo is called
2395
- // that might reset cursor and selection of field -> update it after this
2396
- this._bOK = true;
2397
-
2398
- }
2399
-
2400
- function _dialogCancel(oEvent) {
2401
-
2402
- this.close();
2403
-
2404
- this.setProperty("conditions", this._aOldConditions, true); // do not invalidate whole FieldHelp
2405
-
2406
- }
2407
-
2408
- function _handleDialogAfterOpen(oEvent) {
2409
-
2410
- this._bSwitchToDialog = false;
2411
-
2412
- }
2413
-
2414
- function _handleDialogAfterClose(oEvent) {
2415
-
2416
- var aConditions = this.getConditions(); // get conditions here as they might be modified in a close handler
2417
- this._bDialogOpen = false;
2418
- this._aOldConditions = undefined;
2419
-
2420
- this._handleAfterClose(oEvent);
2421
-
2422
- if (this._bOK) {
2423
- // fire select event after Dialog is closed because inside applyFocusInfo is called
2424
- // that might reset cursor and selection of field -> update it after this
2425
- this.fireSelect({conditions: aConditions, add: false, close: true});
2426
- }
2427
- this._bOK = undefined;
2428
-
2429
- this.setProperty("_enableOK", true, true); // initialize
2430
-
2431
- }
2432
-
2433
- function _toggleDefineConditions(bActive) {
2434
- var oDialog = this.getAggregation("_dialog");
2435
- if (oDialog && this._oField) {
2436
- var oValueHelpPanel = oDialog.getContent()[0];
2437
- if (bActive) { // sow DefineConditions too if only EQ is allowes to suppoer free input. If not wanted, showConditionPanel should be set to false
2438
- if (!oValueHelpPanel._oDefineConditionPanel) { //TODO: use API?
2439
- var oDefineConditionPanel = new DefineConditionPanel(this.getId() + "-DCP", {label: "{$help>/title}"});
2440
- oValueHelpPanel.setDefineConditions(oDefineConditionPanel);
2441
- }
2442
- } else {
2443
- oValueHelpPanel.setDefineConditions();
2444
- }
2445
- }
2446
- }
2447
-
2448
- function _updateFilterBar(sMutation, oFilterBar, bInternalFilterBar) {
2449
-
2450
- if (sMutation === "remove") {
2451
- oFilterBar.detachEvent("search", _updateFiltersFromFilterBar, this);
2452
- if (!bInternalFilterBar) { // internal FilterBar is completely destroyed
2453
- var oSearchField = oFilterBar.getBasicSearchField();
2454
- if (oSearchField && oSearchField._bCreadedByFVH) { // remove own SearchField
2455
- oFilterBar.setBasicSearchField();
2456
- }
2457
- if (oFilterBar.getCollectiveSearch && oFilterBar.getCollectiveSearch()) { // remove collectiveSearch
2458
- oFilterBar.setCollectiveSearch();
2459
- }
2460
- }
2461
-
2462
- oFilterBar = undefined;
2463
- } else {
2464
- oFilterBar.attachEvent("search", _updateFiltersFromFilterBar, this);
2465
- _assignCollectiveSearch.call(this, false);
2466
- }
2467
-
2468
- var oDialog = this.getAggregation("_dialog");
2469
- if (oDialog) {
2470
- var oValueHelpPanel = oDialog.getContent()[0];
2471
- oValueHelpPanel.setFilterbar(oFilterBar);
2472
- oValueHelpPanel.setShowFilterbar(!!oFilterBar);
2473
- if (this.isOpen()) { // add current InParameterFilters and Filtervalue to Filterbar or internal condition to have right filters
2474
- _initializeFilters.call(this);
2475
- if (!bInternalFilterBar || sMutation === "remove") { // on creating internal FilterBar SearchField is already created
2476
- _initializeSearchField.call(this, sMutation === "remove"); // async in removing to prevent creating internal FilterBar while removing old one and adding new one
2477
- }
2478
- }
2479
- }
2480
-
2481
- }
2482
-
2483
- function _updateFiltersFromFilterBar(oEvent) {
2484
-
2485
- var oFilterBar = this._getFilterBar();
2486
-
2487
- if (oFilterBar) {
2488
- // update FilterValue from SearchField
2489
- var sFilterFields = this.getFilterFields();
2490
- if (sFilterFields && !this._bUpdateFilterAfterClose) { // filter changed while closing -> condition not updated
2491
- var aConditions = _getConditions.call(this, sFilterFields);
2492
- var sFilterValue = aConditions.length > 0 ? aConditions[0].values[0] : "";
2493
- if (sFilterValue !== this.getFilterValue()) {
2494
- this.setProperty("filterValue", sFilterValue, true);
2495
- }
2496
- }
2497
-
2498
- // If event fired from Filterbar the filter must set active
2499
- if (this._bApplyFilter || (!this._bApplyFilter && (oEvent || oFilterBar.getLiveMode()))) {
2500
- // user triggers search or liveMode -> resume
2501
- this._bApplyFilter = true; // applyFilter even if suspended (resume)
2502
- _applyFilters.call(this, true);
2503
- }
2504
- }
2505
-
2506
- }
2507
-
2508
- function _initializeFilters() {
2509
-
2510
- var oFilterBar = this._getFilterBar();
2511
- if (oFilterBar) {
2512
- // remove old conditions
2513
- oFilterBar.setInternalConditions(Object.keys(oFilterBar.getConditions()).reduce(function (oResult, sKey) {
2514
- oResult[sKey] = [];
2515
- return oResult;
2516
- }, {}));
2517
- }
2518
-
2519
- // add conditions from In-Parameters and Filter
2520
- _filterContent.call(this, this.getFilterValue());
2521
- _setInParameterFilters.call(this);
2522
-
2523
- }
2524
-
2525
- function _getConditions(sFieldPath) {
2526
-
2527
- var oFilterBar = this._getFilterBar();
2528
- var oConditions;
2529
-
2530
- if (oFilterBar) {
2531
- oConditions = oFilterBar.getInternalConditions();
2532
- } else {
2533
- oConditions = this._oConditions;
2534
- }
2535
-
2536
- return oConditions[sFieldPath] || [];
2537
-
2538
- }
2539
-
2540
- function _addCondition(sFieldPath, oCondition) {
2541
-
2542
- var oFilterBar = this._getFilterBar();
2543
- var oConditions;
2544
-
2545
- if (oFilterBar) {
2546
- oConditions = oFilterBar.getInternalConditions();
2547
- } else {
2548
- oConditions = this._oConditions;
2549
- }
2550
-
2551
- if (!oConditions[sFieldPath]) {
2552
- oConditions[sFieldPath] = [];
2553
- }
2554
- oConditions[sFieldPath].push(oCondition); // use FieldHelp paths in FilterBar too
2555
-
2556
- if (oFilterBar) {
2557
- oFilterBar.setInternalConditions(oConditions);
2558
- }
2559
-
2560
- }
2561
-
2562
- function _removeConditions(sFieldPath) {
2563
-
2564
- var oFilterBar = this._getFilterBar();
2565
- var oConditions;
2566
-
2567
- if (oFilterBar) {
2568
- oConditions = oFilterBar.getInternalConditions();
2569
- } else {
2570
- oConditions = this._oConditions;
2571
- }
2572
-
2573
- if (oConditions[sFieldPath] && oConditions[sFieldPath].length > 0) {
2574
- oConditions[sFieldPath] = [];
2575
- }
2576
-
2577
- if (oFilterBar) {
2578
- oFilterBar.setInternalConditions(oConditions);
2579
- }
2580
- }
2581
-
2582
- /* if search is supported a SearchField is needed on the Dialog. (not on the suggest-popover)
2583
- * If there is a FilterBar given, add the SearchField to it.
2584
- * If there is no FilterBar given, create a new one and add the SearchField.
2585
- */
2586
- function _initializeSearchField(bAsync) {
2587
-
2588
- if (bAsync) {
2589
- if (!this._iSearchFieldTimer) {
2590
- this._iSearchFieldTimer = setTimeout(function() {
2591
- this._iSearchFieldTimer = undefined;
2592
- _initializeSearchField.call(this, false);
2593
- }.bind(this), 0);
2594
- }
2595
- return;
2596
- } else if (this._iSearchFieldTimer) { // in case of a pending timeOut but sync calling, skip pending timeout
2597
- clearTimeout(this._iSearchFieldTimer);
2598
- this._iSearchFieldTimer = null;
2599
- }
2600
-
2601
- var sFilterFields = this.getFilterFields();
2602
- var oWrapper = _getWrapper.call(this, false); // without content it makes no sense to have a SearchField
2603
-
2604
- if (sFilterFields && oWrapper) {
2605
- var oFilterBar = this._getFilterBar();
2606
-
2607
- if (!oFilterBar) {
2608
- oFilterBar = new FilterBar(this.getId() + "-FB", {
2609
- liveMode: !oWrapper.isSuspended(), // if suspended, no live search
2610
- showGoButton: false
2611
- });
2612
- oFilterBar.setInternalConditions(this._oConditions); // if already InParameter or SearchValue set, move it to FilterBar
2613
- this._oConditions = {};
2614
- this.setAggregation("_filterBar", oFilterBar, true);
2615
- }
2616
-
2617
- if (!oFilterBar.getBasicSearchField()) {
2618
- if (!this._oSearchField) { // reuse SearchField if just FilterBar switched (CollectiveSearch case)
2619
- this._oSearchField = new FilterField(this.getId() + "-search", {
2620
- conditions: "{$filters>/conditions/" + sFilterFields + "}",
2621
- placeholder:"{$i18n>filterbar.SEARCH}",
2622
- label:"{$i18n>filterbar.SEARCH}", // TODO: do we want a label?
2623
- maxConditions: 1,
2624
- width: "50%"
2625
- });
2626
- this._oSearchField._bCreadedByFVH = true; // to only remove own SearchFields
2627
- } else {
2628
- this._oSearchField.setConditions([]); // initialize
2629
- }
2630
-
2631
- oFilterBar.setBasicSearchField(this._oSearchField);
2632
- }
2633
- }
2634
-
2635
- if (this._oSearchField && !this._oSearchField.getParent()) {
2636
- // not longer needed -> destroy
2637
- this._oSearchField.destroy();
2638
- delete this._oSearchField;
2639
- }
2640
-
2641
- }
2642
-
2643
-
2644
- function _getSuggestionContent() {
2645
-
2646
- var oWrapper = _getWrapper.call(this, true);
2647
- if (oWrapper) {
2648
- return oWrapper.getSuggestionContent();
2649
- }
2650
-
2651
- }
2652
-
2653
- function _updateBindingContext() {
2654
-
2655
- var oBindingContext = this._oField ? this._oField.getBindingContext() : null; // if not connected use no BindingContext
2656
- this.setBindingContext(oBindingContext);
2657
-
2658
- // in FilterField case also set right ConditionModel
2659
- var oFormatOptions = this._getFormatOptions();
2660
- if (oFormatOptions.conditionModel && this.getModel(oFormatOptions.conditionModelName) !== oFormatOptions.conditionModel) { // don't update propagated model
2661
- this.setModel(oFormatOptions.conditionModel, oFormatOptions.conditionModelName);
2662
- }
2663
-
2664
- }
2665
-
2666
- function getSAPMResourceBundle () {
2667
- if (!this._oResourceBundleM) {
2668
- this._oResourceBundleM = sap.ui.getCore().getLibraryResourceBundle("sap.m");
2669
- }
2670
- return this._oResourceBundleM;
2671
- }
2672
- FieldValueHelp.prototype.getScrollDelegate = function () {
2673
-
2674
- var oDialog = this.getAggregation("_dialog");
2675
-
2676
- if (oDialog && (oDialog.isOpen() || oDialog.oPopup.getOpenState() === OpenState.OPENING)) { // TODO: better way to get opening state
2677
- var oWrapper = _getWrapper.call(this, false);
2678
- var oContent = oWrapper && oWrapper.getDialogContent();
2679
- if (oContent && oContent.getScrollDelegate) {
2680
- return oContent.getScrollDelegate();
2681
- } else {
2682
- return undefined;
2683
- }
2684
- } else {
2685
- return FieldHelpBase.prototype.getScrollDelegate.apply(this, arguments);
2686
- }
2687
-
2688
- };
2689
-
2690
- FieldValueHelp.prototype._fireOpen = function(bSuggestion) {
2691
-
2692
- if (!this._bOpenHandled) { // to prevent double execution
2693
- return FieldHelpBase.prototype._fireOpen.apply(this, arguments);
2694
- }
2695
-
2696
- return true;
2697
-
2698
- };
2699
-
2700
- FieldValueHelp.prototype.getRoleDescription = function(iMaxConditions) {
2701
-
2702
- if (!iMaxConditions || iMaxConditions === 1) {
2703
- return null;
2704
- } else if (!_getWrapper.call(this, false) && this.getShowConditionPanel() && !this.getNoDialog()) { // no table, only condition panel -> no comboBox
2705
- return null;
2706
- } else {
2707
- var sapMResourceBundle = getSAPMResourceBundle.apply(this);
2708
- return sapMResourceBundle.getText("MULTICOMBOBOX_ARIA_ROLE_DESCRIPTION");
2709
- }
2710
-
2711
- };
2712
-
2713
- FieldValueHelp.prototype.getAriaHasPopup = function() {
2714
-
2715
- if (this.getNoDialog()) {
2716
- return "listbox";
2717
- } else if (this.getShowConditionPanel()) {
2718
- return "dialog";
2719
- } else {
2720
- return "listbox"; // as list is only content in Popover (it has both, popver and dialog, but on typing and with arrow keys the list is opend)
2721
- }
2722
-
2723
- };
2724
-
2725
- FieldValueHelp.prototype.getValueHelpEnabled = function() {
2726
-
2727
- if (this.getNoDialog()) {
2728
- return false;
2729
- } else {
2730
- return true;
2731
- }
2732
-
2733
- };
2734
-
2735
- FieldValueHelp.prototype._getContenRequestProperties = function(bSuggestion) {
2736
-
2737
- var oProperties = {};
2738
- var aCollectiveSearchItems = this.getCollectiveSearchItems();
2739
-
2740
- if (aCollectiveSearchItems.length > 0) {
2741
- var oDialog = this.getAggregation("_dialog");
2742
- if (oDialog && oDialog.isOpen() && this._oCollectiveSearchSelect) {
2743
- var vKey = this._oCollectiveSearchSelect.getSelectedItemKey();
2744
- oProperties.collectiveSearchKey = vKey;
2745
- } else {
2746
- // use first item
2747
- oProperties.collectiveSearchKey = aCollectiveSearchItems[0].getKey();
2748
- }
2749
- }
2750
-
2751
- return oProperties;
2752
-
2753
- };
2754
-
2755
- function _createCollectiveSearch() {
2756
-
2757
- if (!this._oCollectiveSearchSelect) {
2758
- // check if collective search is supported
2759
- var oItemTemplate = new VariantItem(this.getId() + "-collSearchItem", {
2760
- key: "{$help>key}",
2761
- text: "{$help>text}",
2762
- textDirection: "{$help>textDirection}"
2763
- });
2764
-
2765
- this._oCollectiveSearchSelect = new CollectiveSearchSelect(this.getId() + "-collSearch", {
2766
- title:"{$i18n>COL_SEARCH_SEL_TITLE}",
2767
- items: {path: "$help>/collectiveSearchItems", template: oItemTemplate},
2768
- select: _handleCollectiveSearchSelect.bind(this)
2769
- }).setModel(this._oManagedObjectModel, "$help");
2770
- }
2771
-
2772
- return this._oCollectiveSearchSelect;
2773
-
2774
- }
2775
-
2776
- function _handleCollectiveSearchSelect(oEvent) {
2777
-
2778
- var fnCallback = function() {
2779
- // apply Filters after change of Table and/or FilterBar
2780
- _applyFilters.call(this, true);
2781
- }.bind(this);
2782
-
2783
- this.setProperty("filterValue", "", true); // initialize SearchField
2784
- var bSync = this._callContentRequest(false, fnCallback);
2785
-
2786
- if (bSync) {
2787
- fnCallback();
2788
- }
2789
-
2790
- }
2791
-
2792
- function _assignCollectiveSearch(bInitializeKey) {
2793
-
2794
- var oDialog = this.getAggregation("_dialog");
2795
- var oFilterBar = this._getFilterBar();
2796
- if (oDialog && oFilterBar) {
2797
- var aCollectiveSearchItems = this.getCollectiveSearchItems();
2798
- if (aCollectiveSearchItems.length <= 1) {
2799
- if (oFilterBar.getCollectiveSearch && oFilterBar.getCollectiveSearch()) {
2800
- oFilterBar.setCollectiveSearch(); // no items or only one item -> no collective search
2801
- }
2802
- } else {
2803
- if (oFilterBar.getCollectiveSearch && !oFilterBar.getCollectiveSearch()) {
2804
- oFilterBar.setCollectiveSearch(_createCollectiveSearch.call(this));
2805
- }
2806
- if (bInitializeKey && this._oCollectiveSearchSelect) {
2807
- //reset collectiveSearch to first item
2808
- this._oCollectiveSearchSelect.setSelectedItemKey(aCollectiveSearchItems[0].getKey());
2809
- }
2810
- }
2811
- }
2812
-
2813
- }
2814
-
2815
- function _getWrapper(bSuggestion) {
2816
-
2817
- var oWrapper;
2818
-
2819
- if (bSuggestion) {
2820
- oWrapper = this.getSuggestContent();
2821
- } else {
2822
- oWrapper = this.getDialogContent();
2823
- }
2824
-
2825
- if (!oWrapper) {
2826
- oWrapper = this.getContent();
2827
- }
2828
- return oWrapper;
2829
-
2830
- }
2831
-
2832
- return FieldValueHelp;
2833
-
2834
- });