@openui5/sap.ui.integration 1.101.0 → 1.102.2

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 (182) hide show
  1. package/THIRDPARTY.txt +1 -1
  2. package/package.json +3 -3
  3. package/src/sap/ui/integration/.library +1 -1
  4. package/src/sap/ui/integration/ActionDefinition.js +1 -1
  5. package/src/sap/ui/integration/Designtime.js +1 -1
  6. package/src/sap/ui/integration/Extension.js +1 -1
  7. package/src/sap/ui/integration/Host.js +1 -1
  8. package/src/sap/ui/integration/cards/AdaptiveContent.js +1 -1
  9. package/src/sap/ui/integration/cards/AnalyticalContent.js +2 -1
  10. package/src/sap/ui/integration/cards/AnalyticsCloudContent.js +1 -1
  11. package/src/sap/ui/integration/cards/BaseContent.js +1 -1
  12. package/src/sap/ui/integration/cards/BaseListContent.js +1 -1
  13. package/src/sap/ui/integration/cards/CalendarContent.js +1 -1
  14. package/src/sap/ui/integration/cards/ComponentContent.js +1 -1
  15. package/src/sap/ui/integration/cards/Footer.js +1 -1
  16. package/src/sap/ui/integration/cards/Header.js +1 -1
  17. package/src/sap/ui/integration/cards/ListContent.js +1 -1
  18. package/src/sap/ui/integration/cards/NumericHeader.js +1 -1
  19. package/src/sap/ui/integration/cards/ObjectContent.js +1 -1
  20. package/src/sap/ui/integration/cards/TableContent.js +1 -1
  21. package/src/sap/ui/integration/cards/TimelineContent.js +1 -1
  22. package/src/sap/ui/integration/cards/WebPageContent.js +1 -1
  23. package/src/sap/ui/integration/cards/actions/CardActions.js +1 -1
  24. package/src/sap/ui/integration/cards/adaptivecards/elements/UI5InputChoiceSet.js +1 -1
  25. package/src/sap/ui/integration/cards/adaptivecards/elements/UI5InputDate.js +1 -1
  26. package/src/sap/ui/integration/cards/adaptivecards/elements/UI5InputNumber.js +1 -1
  27. package/src/sap/ui/integration/cards/adaptivecards/elements/UI5InputText.js +1 -1
  28. package/src/sap/ui/integration/cards/adaptivecards/elements/UI5InputToggle.js +1 -1
  29. package/src/sap/ui/integration/cards/filters/BaseFilter.js +1 -1
  30. package/src/sap/ui/integration/cards/filters/DateRangeFilter.js +1 -1
  31. package/src/sap/ui/integration/cards/filters/FilterBar.js +1 -1
  32. package/src/sap/ui/integration/cards/filters/FilterBarFactory.js +1 -1
  33. package/src/sap/ui/integration/cards/filters/SearchFilter.js +1 -1
  34. package/src/sap/ui/integration/cards/filters/SelectFilter.js +1 -1
  35. package/src/sap/ui/integration/controls/ActionsStrip.js +1 -1
  36. package/src/sap/ui/integration/controls/ActionsToolbar.js +1 -1
  37. package/src/sap/ui/integration/controls/LinkWithIcon.js +1 -1
  38. package/src/sap/ui/integration/controls/ListContentItem.js +1 -1
  39. package/src/sap/ui/integration/controls/Microchart.js +1 -1
  40. package/src/sap/ui/integration/controls/MicrochartLegend.js +1 -1
  41. package/src/sap/ui/integration/controls/Paginator.js +1 -1
  42. package/src/sap/ui/integration/designtime/baseEditor/BaseEditor.js +1 -1
  43. package/src/sap/ui/integration/designtime/baseEditor/PropertyEditor.js +1 -1
  44. package/src/sap/ui/integration/designtime/baseEditor/PropertyEditors.js +1 -1
  45. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/BasePropertyEditor.js +1 -1
  46. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/PropertyEditorFactory.js +1 -1
  47. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/arrayEditor/ArrayEditor.js +1 -1
  48. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/booleanEditor/BooleanEditor.js +1 -1
  49. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/dateEditor/DateEditor.js +1 -1
  50. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/dateTimeEditor/DateTimeEditor.js +1 -1
  51. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/enumStringEditor/EnumStringEditor.js +1 -1
  52. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/groupEditor/GroupEditor.js +1 -1
  53. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/iconEditor/IconEditor.js +1 -1
  54. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/iconEditor/IsInIconPool.validator.js +1 -1
  55. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/integerEditor/IntegerEditor.js +1 -1
  56. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/jsonEditor/JsonEditor.js +1 -1
  57. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/listEditor/ListEditor.js +1 -1
  58. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/mapEditor/MapEditor.js +1 -1
  59. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/multiSelectEditor/MultiSelectEditor.js +1 -1
  60. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/numberEditor/NumberEditor.js +1 -1
  61. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/objectArrayEditor/ObjectArrayEditor.js +1 -1
  62. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/selectEditor/SelectEditor.js +1 -1
  63. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/separatorEditor/SeparatorEditor.js +1 -1
  64. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/stringEditor/StringEditor.js +1 -1
  65. package/src/sap/ui/integration/designtime/baseEditor/propertyEditor/textAreaEditor/TextAreaEditor.js +1 -1
  66. package/src/sap/ui/integration/designtime/baseEditor/util/binding/ObjectBinding.js +1 -1
  67. package/src/sap/ui/integration/designtime/baseEditor/util/unset.js +1 -1
  68. package/src/sap/ui/integration/designtime/baseEditor/validator/IsBoolean.js +1 -1
  69. package/src/sap/ui/integration/designtime/baseEditor/validator/IsDate.js +1 -1
  70. package/src/sap/ui/integration/designtime/baseEditor/validator/IsInteger.js +1 -1
  71. package/src/sap/ui/integration/designtime/baseEditor/validator/IsNumber.js +1 -1
  72. package/src/sap/ui/integration/designtime/baseEditor/validator/IsSelectedKey.js +1 -1
  73. package/src/sap/ui/integration/designtime/baseEditor/validator/IsStringList.js +1 -1
  74. package/src/sap/ui/integration/designtime/baseEditor/validator/IsUniqueKey.js +1 -1
  75. package/src/sap/ui/integration/designtime/baseEditor/validator/IsUniqueList.js +1 -1
  76. package/src/sap/ui/integration/designtime/baseEditor/validator/IsValidBinding.js +1 -1
  77. package/src/sap/ui/integration/designtime/baseEditor/validator/MaxLength.js +1 -1
  78. package/src/sap/ui/integration/designtime/baseEditor/validator/NotABinding.js +1 -1
  79. package/src/sap/ui/integration/designtime/baseEditor/validator/ValidatorRegistry.js +1 -1
  80. package/src/sap/ui/integration/designtime/cardEditor/propertyEditor/complexMapEditor/ComplexMapEditor.js +1 -1
  81. package/src/sap/ui/integration/designtime/cardEditor/propertyEditor/destinationsEditor/DestinationsEditor.js +1 -1
  82. package/src/sap/ui/integration/designtime/cardEditor/propertyEditor/filtersEditor/FiltersEditor.js +1 -1
  83. package/src/sap/ui/integration/designtime/cardEditor/propertyEditor/iconEditor/IconEditor.js +1 -1
  84. package/src/sap/ui/integration/designtime/cardEditor/propertyEditor/parametersEditor/ParametersEditor.js +1 -1
  85. package/src/sap/ui/integration/designtime/editor/CardEditor.js +12 -4
  86. package/src/sap/ui/integration/designtime/editor/CardPreview.js +1 -1
  87. package/src/sap/ui/integration/editor/Editor.js +145 -41
  88. package/src/sap/ui/integration/editor/EditorResourceBundles.js +1 -1
  89. package/src/sap/ui/integration/editor/Extension.js +1 -1
  90. package/src/sap/ui/integration/editor/Manifest.js +1 -1
  91. package/src/sap/ui/integration/editor/Merger.js +0 -1
  92. package/src/sap/ui/integration/editor/Settings.js +1 -1
  93. package/src/sap/ui/integration/editor/css/Editor.css +11 -5
  94. package/src/sap/ui/integration/editor/fields/BaseField.js +43 -9
  95. package/src/sap/ui/integration/editor/fields/BooleanField.js +1 -1
  96. package/src/sap/ui/integration/editor/fields/DateField.js +1 -1
  97. package/src/sap/ui/integration/editor/fields/DateTimeField.js +1 -1
  98. package/src/sap/ui/integration/editor/fields/DestinationField.js +1 -1
  99. package/src/sap/ui/integration/editor/fields/IntegerField.js +1 -1
  100. package/src/sap/ui/integration/editor/fields/NumberField.js +1 -1
  101. package/src/sap/ui/integration/editor/fields/ObjectField.js +1119 -446
  102. package/src/sap/ui/integration/editor/fields/ObjectListField.js +186 -197
  103. package/src/sap/ui/integration/editor/fields/StringField.js +36 -13
  104. package/src/sap/ui/integration/editor/fields/StringListField.js +1 -1
  105. package/src/sap/ui/integration/editor/fields/viz/ColorSelect.js +1 -1
  106. package/src/sap/ui/integration/editor/fields/viz/IconSelect.js +1 -1
  107. package/src/sap/ui/integration/editor/fields/viz/ShapeSelect.js +1 -1
  108. package/src/sap/ui/integration/library.js +5 -5
  109. package/src/sap/ui/integration/messagebundle.properties +44 -23
  110. package/src/sap/ui/integration/messagebundle_ar.properties +26 -12
  111. package/src/sap/ui/integration/messagebundle_bg.properties +26 -12
  112. package/src/sap/ui/integration/messagebundle_ca.properties +26 -12
  113. package/src/sap/ui/integration/messagebundle_cs.properties +26 -12
  114. package/src/sap/ui/integration/messagebundle_cy.properties +26 -12
  115. package/src/sap/ui/integration/messagebundle_da.properties +26 -12
  116. package/src/sap/ui/integration/messagebundle_de.properties +26 -12
  117. package/src/sap/ui/integration/messagebundle_el.properties +26 -12
  118. package/src/sap/ui/integration/messagebundle_en.properties +26 -12
  119. package/src/sap/ui/integration/messagebundle_en_GB.properties +26 -12
  120. package/src/sap/ui/integration/messagebundle_en_US_sappsd.properties +26 -12
  121. package/src/sap/ui/integration/messagebundle_en_US_saprigi.properties +26 -12
  122. package/src/sap/ui/integration/messagebundle_en_US_saptrc.properties +26 -12
  123. package/src/sap/ui/integration/messagebundle_es.properties +27 -13
  124. package/src/sap/ui/integration/messagebundle_es_MX.properties +26 -12
  125. package/src/sap/ui/integration/messagebundle_et.properties +26 -12
  126. package/src/sap/ui/integration/messagebundle_fi.properties +27 -13
  127. package/src/sap/ui/integration/messagebundle_fr.properties +26 -12
  128. package/src/sap/ui/integration/messagebundle_fr_CA.properties +26 -12
  129. package/src/sap/ui/integration/messagebundle_hi.properties +26 -12
  130. package/src/sap/ui/integration/messagebundle_hr.properties +26 -12
  131. package/src/sap/ui/integration/messagebundle_hu.properties +26 -12
  132. package/src/sap/ui/integration/messagebundle_id.properties +26 -12
  133. package/src/sap/ui/integration/messagebundle_it.properties +26 -12
  134. package/src/sap/ui/integration/messagebundle_iw.properties +26 -12
  135. package/src/sap/ui/integration/messagebundle_ja.properties +26 -12
  136. package/src/sap/ui/integration/messagebundle_kk.properties +26 -12
  137. package/src/sap/ui/integration/messagebundle_ko.properties +27 -13
  138. package/src/sap/ui/integration/messagebundle_lt.properties +26 -12
  139. package/src/sap/ui/integration/messagebundle_lv.properties +26 -12
  140. package/src/sap/ui/integration/messagebundle_ms.properties +26 -12
  141. package/src/sap/ui/integration/messagebundle_nl.properties +26 -12
  142. package/src/sap/ui/integration/messagebundle_no.properties +26 -12
  143. package/src/sap/ui/integration/messagebundle_pl.properties +26 -12
  144. package/src/sap/ui/integration/messagebundle_pt.properties +26 -12
  145. package/src/sap/ui/integration/messagebundle_pt_PT.properties +26 -12
  146. package/src/sap/ui/integration/messagebundle_ro.properties +26 -12
  147. package/src/sap/ui/integration/messagebundle_ru.properties +26 -12
  148. package/src/sap/ui/integration/messagebundle_sh.properties +26 -12
  149. package/src/sap/ui/integration/messagebundle_sk.properties +26 -12
  150. package/src/sap/ui/integration/messagebundle_sl.properties +26 -12
  151. package/src/sap/ui/integration/messagebundle_sv.properties +26 -12
  152. package/src/sap/ui/integration/messagebundle_th.properties +26 -12
  153. package/src/sap/ui/integration/messagebundle_tr.properties +26 -12
  154. package/src/sap/ui/integration/messagebundle_uk.properties +26 -12
  155. package/src/sap/ui/integration/messagebundle_vi.properties +26 -12
  156. package/src/sap/ui/integration/messagebundle_zh_CN.properties +26 -12
  157. package/src/sap/ui/integration/messagebundle_zh_TW.properties +26 -12
  158. package/src/sap/ui/integration/model/ContextModel.js +1 -1
  159. package/src/sap/ui/integration/model/ObservableModel.js +1 -1
  160. package/src/sap/ui/integration/model/PagingModelListBinding.js +1 -1
  161. package/src/sap/ui/integration/schemas/sap-card.json +73 -3
  162. package/src/sap/ui/integration/util/BaseFactory.js +1 -1
  163. package/src/sap/ui/integration/util/BindingHelper.js +1 -1
  164. package/src/sap/ui/integration/util/BindingResolver.js +1 -1
  165. package/src/sap/ui/integration/util/CardMerger.js +82 -8
  166. package/src/sap/ui/integration/util/CardObserver.js +1 -1
  167. package/src/sap/ui/integration/util/ContentFactory.js +1 -1
  168. package/src/sap/ui/integration/util/CsrfTokenHandler.js +1 -1
  169. package/src/sap/ui/integration/util/DataProvider.js +1 -1
  170. package/src/sap/ui/integration/util/DataProviderFactory.js +1 -1
  171. package/src/sap/ui/integration/util/Destinations.js +1 -1
  172. package/src/sap/ui/integration/util/ExtensionDataProvider.js +1 -1
  173. package/src/sap/ui/integration/util/HeaderFactory.js +1 -1
  174. package/src/sap/ui/integration/util/JSONBindingHelper.js +1 -1
  175. package/src/sap/ui/integration/util/LoadingProvider.js +1 -1
  176. package/src/sap/ui/integration/util/Manifest.js +2 -1
  177. package/src/sap/ui/integration/util/RequestDataProvider.js +1 -1
  178. package/src/sap/ui/integration/util/ServiceDataProvider.js +1 -1
  179. package/src/sap/ui/integration/util/ServiceManager.js +1 -1
  180. package/src/sap/ui/integration/util/SkeletonCard.js +1 -1
  181. package/src/sap/ui/integration/util/Utils.js +16 -1
  182. package/src/sap/ui/integration/widgets/Card.js +32 -10
@@ -8,54 +8,72 @@ sap.ui.define([
8
8
  "sap/ui/integration/editor/fields/BaseField",
9
9
  "sap/m/Text",
10
10
  "sap/m/TextArea",
11
- "sap/m/Title",
12
11
  "sap/m/Input",
12
+ "sap/m/NavContainer",
13
+ "sap/m/Page",
13
14
  "sap/m/Popover",
14
15
  "sap/m/OverflowToolbar",
15
16
  "sap/m/ToolbarSpacer",
16
17
  "sap/m/Button",
17
- "sap/ui/core/Core",
18
18
  "sap/ui/model/json/JSONModel",
19
19
  "sap/ui/table/Table",
20
20
  "sap/ui/table/Column",
21
21
  "sap/m/Label",
22
- "sap/m/HBox",
22
+ "sap/m/VBox",
23
23
  "sap/ui/model/Filter",
24
24
  "sap/ui/model/FilterOperator",
25
25
  "sap/base/util/deepEqual",
26
26
  "sap/ui/core/Icon",
27
27
  "sap/m/Switch",
28
28
  "sap/m/CheckBox",
29
+ "sap/m/MessageBox",
30
+ "sap/m/MessageToast",
29
31
  "sap/base/util/deepClone",
30
32
  "sap/m/Link",
31
33
  "sap/ui/layout/form/SimpleForm",
32
- "sap/base/util/merge"
34
+ "sap/base/util/merge",
35
+ "sap/m/List",
36
+ "sap/m/CustomListItem",
37
+ "sap/ui/model/Sorter",
38
+ "sap/ui/core/CustomData",
39
+ "sap/ui/integration/editor/EditorResourceBundles",
40
+ "sap/base/util/includes",
41
+ "sap/ui/integration/util/Utils"
33
42
  ], function (
34
43
  BaseField,
35
44
  Text,
36
45
  TextArea,
37
- Title,
38
46
  Input,
47
+ NavContainer,
48
+ Page,
39
49
  Popover,
40
50
  OverflowToolbar,
41
51
  ToolbarSpacer,
42
52
  Button,
43
- Core,
44
53
  JSONModel,
45
54
  Table,
46
55
  Column,
47
56
  Label,
48
- HBox,
57
+ VBox,
49
58
  Filter,
50
59
  FilterOperator,
51
60
  deepEqual,
52
61
  Icon,
53
62
  Switch,
54
63
  CheckBox,
64
+ MessageBox,
65
+ MessageToast,
55
66
  deepClone,
56
67
  Link,
57
68
  SimpleForm,
58
- merge
69
+ merge,
70
+ List,
71
+ CustomListItem,
72
+ Sorter,
73
+ CustomData,
74
+ EditorResourceBundles,
75
+ includes,
76
+ Utils
59
77
  ) {
60
78
  "use strict";
61
79
  var REGEXP_TRANSLATABLE = /\{\{(?!parameters.)(?!destinations.)([^\}\}]+)\}\}/g;
@@ -66,7 +84,7 @@ sap.ui.define([
66
84
  * @alias sap.ui.integration.editor.fields.ObjectField
67
85
  * @author SAP SE
68
86
  * @since 1.100.0
69
- * @version 1.101.0
87
+ * @version 1.102.2
70
88
  * @private
71
89
  * @experimental since 1.100.0
72
90
  * @ui5-restricted
@@ -81,7 +99,12 @@ sap.ui.define([
81
99
 
82
100
  ObjectField.prototype.initVisualization = function (oConfig) {
83
101
  var that = this;
84
- that._newObjectTemplate = {};
102
+ that._newObjectTemplate = {
103
+ "_dt": {
104
+ "_selected": true,
105
+ "_uuid": ""
106
+ }
107
+ };
85
108
  var oVisualization = oConfig.visualization;
86
109
  if (!oVisualization) {
87
110
  if (oConfig.value && !oConfig.properties && (!oConfig.values || (oConfig.values && !oConfig.values.metadata))) {
@@ -121,9 +144,12 @@ sap.ui.define([
121
144
  if (typeof oConfig.value === "object" && !deepEqual(oConfig.value, {}) && !Array.isArray(oConfig.value) && !oConfig.properties) {
122
145
  var oProperties = {};
123
146
  for (var n in oConfig.value) {
124
- var sType = typeof oConfig.value[n];
125
- var oProperty = sType === "string" ? {} : {"type": sType};
126
- oProperties[n] = oProperty;
147
+ // not show _dt property which generated and used by editor
148
+ if (n !== "_dt") {
149
+ var sType = typeof oConfig.value[n];
150
+ var oProperty = sType === "string" ? {} : {"type": sType};
151
+ oProperties[n] = oProperty;
152
+ }
127
153
  }
128
154
  if (!deepEqual(oProperties, {})) {
129
155
  oConfig.properties = oProperties;
@@ -154,12 +180,11 @@ sap.ui.define([
154
180
  type: Table,
155
181
  settings: {
156
182
  rows: "{" + sPath + "}",
157
- selectionMode: "MultiToggle",
158
- enableSelectAll: that._bIsEnableSelectAllInTable === true,
159
183
  visibleRowCount: 5,
160
184
  busy: "{currentSettings>_loading}",
161
185
  columns: columns,
162
- rowSelectionChange: that.onSelectionChange.bind(that),
186
+ selectionBehavior: "RowOnly",
187
+ rowSelectionChange: that.onTableSelectionChange.bind(that),
163
188
  toolbar: oTableToolbar,
164
189
  filter: that.onFilter.bind(that)
165
190
  }
@@ -174,10 +199,18 @@ sap.ui.define([
174
199
  var oModel = this.getAggregation("_field").getModel();
175
200
  oModel.checkUpdate(true);
176
201
  var oValue = oModel.getProperty("/value");
202
+ // generate uuid if not exists
203
+ if (!oValue._dt) {
204
+ oValue._dt = {
205
+ _uuid: Utils.generateUuidV4()
206
+ };
207
+ } else if (!oValue._dt._uuid) {
208
+ oValue._dt._uuid = Utils.generateUuidV4();
209
+ }
177
210
  oValue = deepClone(oValue, 500);
178
- this._setCurrentProperty("value", oValue);
211
+ this.setValue(oValue);
179
212
  }.bind(that);
180
- var aObjectPropertyFormContents = that.createFormContents(fnChange, "/value/");
213
+ var aObjectPropertyFormContents = that.createFormContents(fnChange, "/value/", false, that.openTranslationPopup);
181
214
  var oEditModeButton = new Button({
182
215
  icon: {
183
216
  path: '/editMode',
@@ -223,8 +256,13 @@ sap.ui.define([
223
256
  }
224
257
  },
225
258
  press: function (oEvent) {
226
- that._setCurrentProperty("value", undefined);
259
+ that.setValue(undefined);
227
260
  var oModel = that.getAggregation("_field").getModel();
261
+ // delete the translation texts when deleting the object
262
+ var oObject = oModel.getProperty("/value");
263
+ if (oObject && oObject._dt && oObject._dt._uuid) {
264
+ that.deleteTranslationValueInTexts(undefined, oObject._dt._uuid);
265
+ }
228
266
  oModel.setProperty("/value", {});
229
267
  oModel.checkUpdate(true);
230
268
  }
@@ -291,131 +329,184 @@ sap.ui.define([
291
329
  return oVisualization;
292
330
  };
293
331
 
332
+ ObjectField.prototype.buildSelectionColumnLables = function() {
333
+ var that = this;
334
+ var oConfig = that.getConfiguration();
335
+ var oResourceBundle = that.getResourceBundle();
336
+ return new Button({
337
+ icon: "sap-icon://clear-all",
338
+ type: "Transparent",
339
+ enabled: typeof oConfig.values === "undefined" ? false : "{/_hasSelected}",
340
+ tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_COLUMN_SELECTION_TOOLTIP_REMOVE"),
341
+ press: that.onUnSelectAll.bind(that)
342
+ });
343
+ };
344
+
294
345
  ObjectField.prototype.buildTableColumns = function() {
295
346
  var that = this;
296
347
  var oConfig = that.getConfiguration();
297
348
  var aColumns = [];
298
- var oCardResourceBundle = that.getModel("i18n").getResourceBundle();
299
- for (var n in oConfig.properties) {
300
- var oProperty = oConfig.properties[n];
301
- var sDefaultLabel = oProperty.label || n;
302
- var sDefaultValue = "{" + n + "}";
303
- if (oProperty.defaultValue) {
304
- that._newObjectTemplate[n] = oProperty.defaultValue;
305
- }
306
- var oColumnSettings = {
307
- "width": "7rem",
308
- "label": sDefaultLabel
309
- };
310
- if (oProperty.column) {
311
- oColumnSettings = merge(oColumnSettings, oProperty.column);
312
- }
313
- // change translate syntax {{KEY}} to {i18n>KEY}
314
- if (oColumnSettings.label.match(REGEXP_TRANSLATABLE)) {
315
- oColumnSettings.label = "{i18n>" + oColumnSettings.label.substring(2, oColumnSettings.label.length - 1);
316
- }
317
- oColumnSettings.tooltip = oColumnSettings.label;
318
-
319
- var sCellType = oProperty.cell && oProperty.cell.type ? oProperty.cell.type : oProperty.type || "Text";
320
- var oCellTemplate;
321
- var oCellSettings;
322
- var oCell = deepClone(oProperty.cell) || {};
323
- delete oCell.type;
324
- switch (sCellType) {
325
- case "int":
326
- case "number":
327
- oCellSettings = {
328
- text: sDefaultValue,
329
- wrapping: false
330
- };
331
- oCellSettings = merge(oCellSettings, oCell);
332
- oCellTemplate = new Text(oCellSettings);
333
- break;
334
- case "string":
335
- case "Text":
336
- oCellSettings = {
337
- text: sDefaultValue,
338
- wrapping: false
339
- };
340
- oCellSettings = merge(oCellSettings, oCell);
341
- var oText = oCellSettings.text;
342
- if (typeof oText === "string") {
343
- if (oText.match(REGEXP_TRANSLATABLE)) {
344
- // check the text property, if it match syntax {{KEY}}, translate it
345
- oCellSettings.text = oCardResourceBundle.getText(oText.substring(2, oText.length - 2));
346
- } else if (oText.startsWith("{i18n>") && oText.endsWith('}')) {
347
- // check the text property, if it match syntax {i18n>KEY}, translate it
348
- oCellSettings.text = oCardResourceBundle.getText(oText.substring(6, oText.length - 1));
349
- } else if (oText.startsWith('{') && oText.endsWith('}')) {
350
- oCellSettings.text = {
351
- path: oText.substring(1, oText.length - 1),
352
- formatter: function(oValue) {
353
- if (!oValue) {
354
- return undefined;
355
- } else if (oValue.match(REGEXP_TRANSLATABLE)) {
356
- // check the text property, if it match syntax {{KEY}}, translate it
357
- return oCardResourceBundle.getText(oValue.substring(2, oValue.length - 2));
358
- } else if (oValue.startsWith("{i18n>") && oValue.endsWith('}')) {
359
- // check the text property, if it match syntax {i18n>KEY}, translate it
360
- return oCardResourceBundle.getText(oValue.substring(6, oValue.length - 1));
361
- }
362
- return oValue;
349
+ var aKeys = Object.keys(oConfig.properties);
350
+ if (aKeys.length > 0) {
351
+ var oResourceBundle = that.getResourceBundle();
352
+ var oSelectionColumnLabels = that.buildSelectionColumnLables();
353
+ var oSelectionColumn = new Column({
354
+ width: "3.2rem",
355
+ hAlign: "Center",
356
+ multiLabels: [
357
+ oSelectionColumnLabels
358
+ ],
359
+ template: new CheckBox({
360
+ selected: "{_dt/_selected}",
361
+ enabled: typeof oConfig.values === "undefined" ? false : true,
362
+ tooltip: {
363
+ path: '_dt/_selected',
364
+ formatter: function(bSelected) {
365
+ if (bSelected) {
366
+ if (oConfig.type === "object") {
367
+ return oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_COLUMN_SELECTION_CELL_TOOLTIP_UNSELECT");
368
+ } else {
369
+ return oResourceBundle.getText("EDITOR_FIELD_OBJECT_LIST_TABLE_COLUMN_SELECTION_CELL_TOOLTIP_REMOVE");
363
370
  }
364
- };
371
+ } else if (oConfig.type === "object") {
372
+ return oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_COLUMN_SELECTION_CELL_TOOLTIP_SELECT");
373
+ } else {
374
+ return oResourceBundle.getText("EDITOR_FIELD_OBJECT_LIST_TABLE_COLUMN_SELECTION_CELL_TOOLTIP_ADD");
375
+ }
365
376
  }
366
- }
367
- oCellSettings.tooltip = oCell.tooltip || oCellSettings.text;
368
- oCellTemplate = new Text(oCellSettings);
369
- break;
370
- case "Icon":
371
- oCellSettings = {
372
- src: sDefaultValue
373
- };
374
- oCellSettings = merge(oCellSettings, oCell);
375
- oCellTemplate = new Icon(oCellSettings);
376
- break;
377
- case "boolean":
378
- oCellSettings = {
379
- selected: sDefaultValue,
380
- enabled: false
381
- };
382
- oCellSettings = merge(oCellSettings, oCell);
383
- oCellTemplate = new CheckBox(oCellSettings);
384
- break;
385
- case "Switch":
386
- oCellSettings = {
387
- state: sDefaultValue,
388
- enabled: false
389
- };
390
- oCellSettings = merge(oCellSettings, oCell);
391
- oCellTemplate = new Switch(oCellSettings);
392
- break;
393
- case "Link":
394
- oCellSettings = {
395
- text: sDefaultValue,
396
- target: "_blank",
397
- href: sDefaultValue
398
- };
399
- oCellSettings = merge(oCellSettings, oCell);
400
- oCellTemplate = new Link(oCellSettings);
401
- break;
402
- default:
403
- oCellTemplate = new Text({
404
- text: sDefaultValue,
405
- wrapping: false
406
- });
407
- break;
377
+ },
378
+ select: that.onSelectionChange.bind(that)
379
+ })
380
+ });
381
+ aColumns.push(oSelectionColumn);
382
+ for (var n in oConfig.properties) {
383
+ var oProperty = oConfig.properties[n];
384
+ var sDefaultLabel = oProperty.label || n;
385
+ var sDefaultValue = "{" + n + "}";
386
+ if (oProperty.defaultValue) {
387
+ that._newObjectTemplate[n] = oProperty.defaultValue;
388
+ }
389
+ var oColumnSettings = {
390
+ "width": "7rem",
391
+ "label": sDefaultLabel
392
+ };
393
+ if (oProperty.column) {
394
+ oColumnSettings = merge(oColumnSettings, oProperty.column);
395
+ }
396
+ // change translate syntax {{KEY}} to {i18n>KEY}
397
+ if (oColumnSettings.label.match(REGEXP_TRANSLATABLE)) {
398
+ oColumnSettings.label = "{i18n>" + oColumnSettings.label.substring(2, oColumnSettings.label.length - 1);
399
+ }
400
+ oColumnSettings.tooltip = oColumnSettings.label;
401
+
402
+ var sCellType = oProperty.cell && oProperty.cell.type ? oProperty.cell.type : oProperty.type || "Text";
403
+ var oCellTemplate;
404
+ var oCellSettings;
405
+ var oCell = deepClone(oProperty.cell) || {};
406
+ delete oCell.type;
407
+ switch (sCellType) {
408
+ case "int":
409
+ case "number":
410
+ oCellSettings = {
411
+ text: sDefaultValue,
412
+ wrapping: false
413
+ };
414
+ oCellSettings = merge(oCellSettings, oCell);
415
+ oCellTemplate = new Text(oCellSettings);
416
+ break;
417
+ case "string":
418
+ case "Text":
419
+ oCellSettings = {
420
+ text: sDefaultValue,
421
+ wrapping: false
422
+ };
423
+ oCellSettings = merge(oCellSettings, oCell);
424
+ var oText = oCellSettings.text;
425
+ var oTextSettingsModel = new JSONModel({
426
+ translatable: oProperty.translatable || false,
427
+ property: n
428
+ });
429
+ if (typeof oText === "string") {
430
+ var sTranslationKey = that.getTranslationKey(oText);
431
+ if (sTranslationKey) {
432
+ oCellSettings.text = oResourceBundle.getText(sTranslationKey);
433
+ } else if (oText.startsWith('{') && oText.endsWith('}')) {
434
+ oCellSettings.text = {
435
+ path: oText.substring(1, oText.length - 1),
436
+ formatter: function(oValue) {
437
+ var oBindingContext = this.getBindingContext(),
438
+ oTranslationValue,
439
+ oSettings = this.getModel("settings").getData(),
440
+ sTranslationKeyInCellValue = that.getTranslationKey(oValue);
441
+ if (oSettings.translatable || sTranslationKeyInCellValue) {
442
+ if (oBindingContext && oBindingContext.getObject() && oBindingContext.getObject()._dt) {
443
+ oTranslationValue = that.getTranslationValueInTexts(oResourceBundle.sLocale.replaceAll('_', '-'), oBindingContext.getObject()._dt._uuid, oSettings.property);
444
+ if (oTranslationValue) {
445
+ return oTranslationValue;
446
+ }
447
+ }
448
+ if (sTranslationKeyInCellValue) {
449
+ oValue = oResourceBundle.getText(sTranslationKeyInCellValue);
450
+ return oValue;
451
+ }
452
+ }
453
+ return oValue;
454
+ }
455
+ };
456
+ }
457
+ }
458
+ oCellSettings.tooltip = oCell.tooltip || oCellSettings.text;
459
+ oCellTemplate = new Text(oCellSettings);
460
+ oCellTemplate.setModel(oTextSettingsModel,"settings");
461
+ break;
462
+ case "Icon":
463
+ oCellSettings = {
464
+ src: sDefaultValue
465
+ };
466
+ oCellSettings = merge(oCellSettings, oCell);
467
+ oCellTemplate = new Icon(oCellSettings);
468
+ break;
469
+ case "boolean":
470
+ oCellSettings = {
471
+ selected: sDefaultValue,
472
+ enabled: false
473
+ };
474
+ oCellSettings = merge(oCellSettings, oCell);
475
+ oCellTemplate = new CheckBox(oCellSettings);
476
+ break;
477
+ case "Switch":
478
+ oCellSettings = {
479
+ state: sDefaultValue,
480
+ enabled: false
481
+ };
482
+ oCellSettings = merge(oCellSettings, oCell);
483
+ oCellTemplate = new Switch(oCellSettings);
484
+ break;
485
+ case "Link":
486
+ oCellSettings = {
487
+ text: sDefaultValue,
488
+ target: "_blank",
489
+ href: sDefaultValue
490
+ };
491
+ oCellSettings = merge(oCellSettings, oCell);
492
+ oCellTemplate = new Link(oCellSettings);
493
+ break;
494
+ default:
495
+ oCellTemplate = new Text({
496
+ text: sDefaultValue,
497
+ wrapping: false
498
+ });
499
+ break;
500
+ }
501
+ oColumnSettings.template = oCellTemplate;
502
+ var oColumn = new Column(oColumnSettings);
503
+ aColumns.push(oColumn);
408
504
  }
409
- oColumnSettings.template = oCellTemplate;
410
- var oColumn = new Column(oColumnSettings);
411
- aColumns.push(oColumn);
412
505
  }
413
- var oActionColumn = that.createActionColumn();
414
- aColumns.push(oActionColumn);
415
506
  return aColumns;
416
507
  };
417
508
 
418
- ObjectField.prototype.checkHasFilter = function(oConfig) {
509
+ ObjectField.prototype.checkHasFilterDefined = function(oConfig) {
419
510
  var bHasFilterDefined = true;
420
511
  if (oConfig._propertiesParsedFromValue === true) {
421
512
  bHasFilterDefined = false;
@@ -430,9 +521,9 @@ sap.ui.define([
430
521
  var that = this;
431
522
  var oResourceBundle = that.getResourceBundle();
432
523
  // check if has filterProperty defined in each column of config.properties
433
- var bHasFilterDefined = that.checkHasFilter(oConfig);
524
+ var bHasFilterDefined = that.checkHasFilterDefined(oConfig);
434
525
  var bAddButtonVisible = oConfig.enabled !== false;
435
- var sAddButtonTooltip = oConfig.addButtonTooltip || oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_ADD_TOOLTIP");
526
+ var sAddButtonTooltip = oConfig.addButtonText || oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_ADD_TOOLTIP");
436
527
  if (bAddButtonVisible && oConfig.values) {
437
528
  bAddButtonVisible = oConfig.values.allowAdd === true;
438
529
  }
@@ -443,130 +534,126 @@ sap.ui.define([
443
534
  icon: "sap-icon://add",
444
535
  visible: bAddButtonVisible,
445
536
  tooltip: sAddButtonTooltip,
446
- press: that.createNewObject.bind(that)
537
+ press: that.addNewObject.bind(that)
538
+ }),
539
+ new Button({
540
+ icon: "sap-icon://edit",
541
+ tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_EDIT_TOOLTIP"),
542
+ enabled: "{= !!${/_hasTableSelected}}",
543
+ press: that.onEditOrViewDetail.bind(that)
544
+ }),
545
+ new Button({
546
+ icon: "sap-icon://delete",
547
+ tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DELETE"),
548
+ enabled: "{= !!${/_canDelete}}",
549
+ press: that.onDelete.bind(that)
550
+ }),
551
+ new Icon({
552
+ src: "sap-icon://vertical-grip"
447
553
  }),
448
554
  new Button({
449
555
  icon: "sap-icon://clear-filter",
450
556
  visible: bHasFilterDefined,
557
+ enabled: "{= !!${/_hasFilter}}",
451
558
  tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_CLEAR_ALL_FILTERS_TOOLTIP"),
452
559
  press: that.clearAllFilters.bind(that)
560
+ }),
561
+ new Button({
562
+ icon: "sap-icon://multiselect-all",
563
+ enabled: "{= !${/_hasTableAllSelected}}",
564
+ tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_SELECT_ALL_SELETIONS_TOOLTIP"),
565
+ press: that.selectAllTableSelections.bind(that)
566
+ }),
567
+ new Button({
568
+ icon: "sap-icon://multiselect-none",
569
+ enabled: "{= !!${/_hasTableSelected}}",
570
+ tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_CLEAR_ALL_SELETIONS_TOOLTIP"),
571
+ press: that.clearAllTableSelections.bind(that)
453
572
  })
454
573
  ]
455
574
  });
456
575
  };
457
576
 
458
- ObjectField.prototype.onDelete = function(oEvent) {
577
+ ObjectField.prototype.onUnSelectAll = function(oEvent) {
459
578
  var that = this;
460
- var oControl = oEvent.getSource();
461
- var oRow = oControl.getParent().getParent();
462
- var oTable = oRow.getParent();
463
- var iRowIndex = oRow.getIndex();
464
-
465
- // get the real index via path since the rows may be filtered
466
- var oRowContexts = oTable.getBinding("rows").getContexts();
467
- var sDeletedObjectPath = oRowContexts[iRowIndex].getPath();
468
- var iRealIndex = sDeletedObjectPath.substring(sDeletedObjectPath.lastIndexOf("/") + 1);
469
-
470
- var oParameter;
471
- var bHasBeforeValue = that.checkHasValue();
472
- oParameter = {
473
- selectedIndex: oTable.getSelectedIndex(),
474
- selectedIndices: oTable.getSelectedIndices(),
475
- rowIndex: iRowIndex,
476
- realIndex: iRealIndex
477
- };
478
-
479
- // delete object in value model
579
+ var oTable = that.getAggregation("_field");
580
+ var sPath = oTable.getBindingContext().getPath();
480
581
  var oModel = oTable.getModel();
481
- var sPath = oTable.getBinding("rows").getPath();
482
582
  var oData = oModel.getProperty(sPath);
483
- oData.splice(iRealIndex, 1);
583
+ oData.forEach(function (oItem) {
584
+ oItem._dt = oItem._dt || {};
585
+ oItem._dt._selected = false;
586
+ });
587
+ oModel.setProperty("/_hasSelected", false);
484
588
  oModel.checkUpdate(true);
485
-
486
- // restore the selections since the selections are lost, BCP: 2280048930, JIRA: CPOUIFTEAMB-252
487
- if (bHasBeforeValue) {
488
- that.applyBeforeValueAndSelections("delete", oParameter);
489
- }
589
+ that.setValue(undefined);
490
590
  };
491
591
 
492
592
  ObjectField.prototype.onEditOrViewDetail = function(oEvent) {
493
593
  var that = this;
494
- var oControl = oEvent.getSource();
495
- var oItem = oControl.getBindingContext().getObject();
496
- that.openObjectDetailsPopover(oItem, oControl, oItem._editable !== false ? "update" : "view");
594
+ var oTable = that.getAggregation("_field");
595
+
596
+ var iSelectIndex = oTable.getSelectedIndex();
597
+ var oRowContexts = oTable.getBinding("rows").getContexts();
598
+ var oItem = oRowContexts[iSelectIndex].getObject();
599
+ var iFirstIndex = oTable.getFirstVisibleRow();
600
+ var oRow = oTable.getRows()[iSelectIndex - iFirstIndex];
601
+ var oCell1 = oRow.getCells()[0];
602
+ that.openObjectDetailsPopover(oItem, oCell1, !oItem._dt || oItem._dt._editable !== false ? "update" : "view");
497
603
  };
498
604
 
499
605
  ObjectField.prototype.onFilter = function(oEvent) {
500
606
  var that = this;
501
- var oControl = oEvent.getSource();
502
- // restore the selections since the selections are lost, BCP: 2280048930, JIRA: CPOUIFTEAMB-252
503
- if (that.checkHasValue()) {
504
- var oParameter = {
505
- selectedIndex: oControl.getSelectedIndex(),
506
- selectedIndices: oControl.getSelectedIndices(),
507
- column: oEvent.getParameter("column")
508
- };
509
- that.applyBeforeValueAndSelections("filter", oParameter);
607
+ var oTable = that.getAggregation("_field");
608
+ oTable.detachEvent("rowsUpdated", that.updateTable, that);
609
+ oTable.attachEventOnce("rowsUpdated", that.updateTable, that);
610
+ };
611
+
612
+ ObjectField.prototype.updateTable = function(oEvent) {
613
+ var that = this;
614
+ that.updateSelectionColumn();
615
+ that.updateToolbar();
616
+ };
617
+
618
+ ObjectField.prototype.updateSelectionColumn = function() {
619
+ var that = this;
620
+ var oTable = that.getAggregation("_field");
621
+ var oRowContexts = oTable.getBinding("rows").getContexts();
622
+ var bHasSelected = false;
623
+ for (var i = 0; i < oRowContexts.length; i++) {
624
+ var oObject = oRowContexts[i].getObject();
625
+ if (oObject._dt && oObject._dt._selected) {
626
+ bHasSelected = true;
627
+ break;
628
+ }
510
629
  }
630
+ oTable.getModel().setProperty("/_hasSelected", bHasSelected);
511
631
  };
512
632
 
513
- ObjectField.prototype.createActionColumn = function() {
633
+ ObjectField.prototype.updateToolbar = function() {
514
634
  var that = this;
515
- var oConfig = that.getConfiguration();
516
- var oResourceBundle = that.getResourceBundle();
517
- return new Column({
518
- width: "5rem",
519
- hAlign: "Center",
520
- label: new Label({
521
- text: "Actions",
522
- tooltip: "Actions"
523
- }),
524
- template: new HBox({
525
- items: [
526
- new Button({
527
- type: "Transparent",
528
- icon: {
529
- path: '_editable',
530
- formatter: function(bEditable) {
531
- if (bEditable === false) {
532
- return "sap-icon://display";
533
- } else {
534
- return "sap-icon://edit";
535
- }
536
- }
537
- },
538
- tooltip: {
539
- path: '_editable',
540
- formatter: function(bEditable) {
541
- if (bEditable === false) {
542
- return oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_DISPLAY_TOOLTIP");
543
- } else {
544
- return oResourceBundle.getText("EDITOR_FIELD_OBJECT_TABLE_BUTTON_EDIT_TOOLTIP");
545
- }
546
- }
547
- },
548
- press: that.onEditOrViewDetail.bind(that)
549
- }),
550
- new Button({
551
- type: "Transparent",
552
- icon: "sap-icon://delete",
553
- visible: oConfig.editable === false ? false : "{= ${_editable} !== false}",
554
- tooltip: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DELETE"),
555
- press: that.onDelete.bind(that)
556
- })
557
- ]
558
- })
559
- });
635
+ var oTable = that.getAggregation("_field");
636
+ var aColumns = oTable.getColumns();
637
+ var bHasFilter = false;
638
+ for (var i = 0; i < aColumns.length; i++) {
639
+ var oMenu = aColumns[i].getMenu();
640
+ var oMenuItems = oMenu.getItems();
641
+ if (oMenuItems.length > 0) {
642
+ var oFilter = oMenuItems[0];
643
+ var sValue = oFilter.getValue();
644
+ if (sValue && sValue !== "") {
645
+ bHasFilter = true;
646
+ break;
647
+ }
648
+ }
649
+ }
650
+ oTable.getModel().setProperty("/_hasFilter", bHasFilter);
560
651
  };
561
652
 
562
653
  ObjectField.prototype.columnFactory = function(sId, oContext) {
563
- var that = this;
564
654
  var sPath = oContext.getPath();
565
655
  var sName = sPath.substring(oContext.getPath().lastIndexOf("/") + 1);
566
656
  var sType = oContext.getProperty("$Type");
567
- if (sType === "Actions") {
568
- return that.createActionColumn();
569
- }
570
657
  var iLen = oContext.getProperty("$MaxLength");
571
658
  var sColumnWidth = "7rem";
572
659
 
@@ -589,31 +676,84 @@ sap.ui.define([
589
676
  });
590
677
  };
591
678
 
679
+ ObjectField.prototype.onTableSelectionChange = function (oEvent) {
680
+ var that = this;
681
+ var oTable = that.getAggregation("_field");
682
+ var oModel = oTable.getModel();
683
+ var aSelectedIndices = oTable.getSelectedIndices();
684
+ if (aSelectedIndices.length > 0) {
685
+ oModel.setProperty("/_hasTableSelected", true);
686
+ } else {
687
+ oModel.setProperty("/_hasTableSelected", false);
688
+ oModel.setProperty("/_canDelete", false);
689
+ return;
690
+ }
691
+ if (aSelectedIndices.length === oTable.getBinding("rows").getContexts().length) {
692
+ oModel.setProperty("/_hasTableAllSelected", true);
693
+ } else {
694
+ oModel.setProperty("/_hasTableAllSelected", false);
695
+ }
696
+ var aSelectedPaths = [];
697
+ var aRowContexts = oTable.getBinding("rows").getContexts();
698
+ aSelectedIndices.forEach(function (iSelectIndex) {
699
+ var oObject = aRowContexts[iSelectIndex].getObject();
700
+ if (oObject._dt && oObject._dt._editable !== false) {
701
+ var sPath = aRowContexts[iSelectIndex].getPath();
702
+ aSelectedPaths.push(sPath);
703
+ }
704
+ });
705
+ if (aSelectedPaths.length === 0) {
706
+ oModel.setProperty("/_canDelete", false);
707
+ } else {
708
+ oModel.setProperty("/_canDelete", true);
709
+ }
710
+ };
711
+
712
+ ObjectField.prototype.selectAllTableSelections = function (oEvent) {
713
+ var that = this;
714
+ var oTable = that.getAggregation("_field");
715
+ oTable.selectAll();
716
+ oTable.getModel().setProperty("/_hasTableAllSelected", true);
717
+ };
718
+
719
+ ObjectField.prototype.clearAllTableSelections = function (oEvent) {
720
+ var that = this;
721
+ var oTable = that.getAggregation("_field");
722
+ var oModel = oTable.getModel();
723
+ oTable.clearSelection();
724
+ oModel.setProperty("/_hasTableSelected", false);
725
+ oModel.setProperty("/_canDelete", false);
726
+ oModel.setProperty("/_hasTableAllSelected", false);
727
+ };
728
+
592
729
  ObjectField.prototype.onSelectionChange = function (oEvent) {
593
730
  var that = this;
594
731
  var oControl = oEvent.getSource();
595
- var bUserInteraction = oEvent.getParameter("userInteraction") || false;
596
- // only update data models if is user interaction
597
- if (bUserInteraction) {
598
- var oObject,
599
- oContext;
600
- var iSelectedIndex = oControl.getSelectedIndex();
601
- var aSelectedIndices = oControl.getSelectedIndices();
602
- if (aSelectedIndices.length >= 1) {
603
- oControl.setSelectedIndex(iSelectedIndex);
604
- oContext = oControl.getContextByIndex(iSelectedIndex);
605
- oObject = oContext.getObject();
606
- oControl._sPathOfFilteredOut = null;
607
- } else if (oControl._sPathOfFilteredOut) {
608
- oObject = oControl.getModel().getProperty(oControl._sPathOfFilteredOut);
609
- }
610
- that._setCurrentProperty("value", oObject);
732
+ var bSelected = oEvent.getParameter("selected");
733
+ var oTable = that.getAggregation("_field");
734
+ var sPath = oTable.getBindingContext().getPath();
735
+ var oModel = oTable.getModel();
736
+ if (bSelected) {
737
+ var oData = oModel.getProperty(sPath);
738
+ oData.forEach(function (oItem) {
739
+ oItem._dt = oItem._dt || {};
740
+ oItem._dt._selected = false;
741
+ });
742
+ var oObject = oControl.getBindingContext().getObject();
743
+ oObject._dt._selected = true;
744
+ var oClonedObject = deepClone(oObject);
745
+ oModel.setProperty("/_hasSelected", true);
746
+ that.setValue(oClonedObject);
747
+ } else {
748
+ oModel.setProperty("/_hasSelected", false);
749
+ that.setValue(undefined);
611
750
  }
612
751
  };
613
752
 
614
- ObjectField.prototype.createNewObject = function (oEvent) {
753
+ ObjectField.prototype.addNewObject = function (oEvent) {
615
754
  var that = this;
616
755
  var oControl = oEvent.getSource();
756
+ that._newObjectTemplate._dt._uuid = Utils.generateUuidV4();
617
757
  that.openObjectDetailsPopover(that._newObjectTemplate, oControl, "add");
618
758
  };
619
759
 
@@ -621,32 +761,53 @@ sap.ui.define([
621
761
  var that = this;
622
762
  var oConfig = that.getConfiguration();
623
763
  var oTable = that.getAggregation("_field");
764
+ var oModel = oTable.getModel();
624
765
  if (oConfig.value && (typeof oConfig.value === "object") && !deepEqual(oConfig.value, {})) {
625
- var oValue;
766
+ var oValue = deepClone(oConfig.value, 500),
767
+ sPath = oTable.getBinding("rows").getPath();
626
768
  if (Array.isArray(tResult) && tResult.length > 0) {
627
- if (oConfig.value._editable === false) {
628
- var iSelectedIndex = -1;
629
- for (var i = 0; i < tResult.length; i++) {
630
- oValue = tResult[i];
631
- if (deepEqual(oValue, oConfig.value)) {
632
- iSelectedIndex = i;
633
- break;
769
+ if (oValue._dt && oValue._dt._editable === false) {
770
+ var sUUID = oValue._dt._uuid || Utils.generateUuidV4();
771
+ delete oValue._dt._uuid;
772
+ tResult.forEach(function(oResult) {
773
+ // find the selected request result, change the uuid by the one of the value
774
+ if (deepEqual(oResult, oValue)) {
775
+ oResult._dt._selected = true;
776
+ oResult._dt._uuid = sUUID;
777
+ } else {
778
+ oResult._dt._uuid = Utils.generateUuidV4();
634
779
  }
635
- }
636
- oTable.setSelectedIndex(iSelectedIndex);
780
+ });
637
781
  } else {
638
- tResult.unshift(oConfig.value);
639
- oTable.getModel().checkUpdate();
640
- oTable.setSelectedIndex(0);
782
+ // add uuid for each request result
783
+ tResult.forEach(function(oResult) {
784
+ oResult._dt._uuid = Utils.generateUuidV4();
785
+ });
786
+ oValue._dt = oValue._dt || {};
787
+ oValue._dt._selected = true;
788
+ // add uuid for the value if not exist
789
+ oValue._dt._uuid = oValue._dt._uuid || Utils.generateUuidV4();
790
+ tResult.unshift(oValue);
641
791
  }
642
792
  } else {
643
- oValue = deepClone(oConfig.value, 500);
793
+ oValue._dt = oValue._dt || {};
794
+ oValue._dt._selected = true;
795
+ // add uuid for the value if not exist
796
+ oValue._dt._uuid = oValue._dt._uuid || Utils.generateUuidV4();
644
797
  tResult = [oValue];
645
- oTable.getModel().checkUpdate();
646
- oTable.setSelectedIndex(0);
647
798
  }
799
+ oModel.setProperty("/_hasSelected", true);
800
+ oModel.setProperty(sPath, tResult);
801
+ } else {
802
+ // add uuid for each request result
803
+ if (Array.isArray(tResult) && tResult.length > 0) {
804
+ tResult.forEach(function(oResult) {
805
+ oResult._dt._uuid = Utils.generateUuidV4();
806
+ });
807
+ }
808
+ oModel.setProperty("/_hasSelected", false);
648
809
  }
649
- return tResult;
810
+ oModel.checkUpdate();
650
811
  };
651
812
 
652
813
  ObjectField.prototype.onChangeOfTextArea = function (oEvent) {
@@ -695,10 +856,10 @@ sap.ui.define([
695
856
  }
696
857
  };
697
858
 
698
- ObjectField.prototype.createFormContents = function (fnChange, sPathPrefix, bIsInPopover) {
859
+ ObjectField.prototype.createFormContents = function (fnChange, sPathPrefix, bIsInPopover, fnNavToTranslation) {
699
860
  var that = this;
700
861
  var oConfig = that.getConfiguration();
701
- var aContentList = that.createPropertyContents(fnChange, sPathPrefix);
862
+ var aContentList = that.createPropertyContents(fnChange, sPathPrefix, fnNavToTranslation);
702
863
  aContentList.push(new Label({
703
864
  visible: false
704
865
  }).addStyleClass("sapFormLabel"));
@@ -721,17 +882,17 @@ sap.ui.define([
721
882
  return vValue;
722
883
  }
723
884
  },
724
- editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
885
+ editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
725
886
  width: "100%",
726
887
  placeholder: "{config/placeholder}",
727
888
  visible: "{= ${/editMode} === 'Json'}",
728
889
  change: bIsInPopover === true ? this.onChangeOfTextAreaInPopover.bind(that) : this.onChangeOfTextArea.bind(that),
729
- rows: bIsInPopover === true ? 15 : 7
890
+ rows: bIsInPopover === true ? 11 : 7
730
891
  }));
731
892
  return aContentList;
732
893
  };
733
894
 
734
- ObjectField.prototype.createPropertyContents = function (fnChange, sPathPrefix) {
895
+ ObjectField.prototype.createPropertyContents = function (fnChange, sPathPrefix, fnNavToTranslation) {
735
896
  var that = this;
736
897
  var oConfig = that.getConfiguration();
737
898
  var aPropertyContentList = [];
@@ -760,7 +921,7 @@ sap.ui.define([
760
921
  oProperties[m] = {
761
922
  type: "number"
762
923
  };
763
- } else if (sType !== "Actions") {
924
+ } else {
764
925
  oProperties[m] = {
765
926
  type: "string"
766
927
  };
@@ -787,13 +948,22 @@ sap.ui.define([
787
948
  });
788
949
  aPropertyContentList.push(oLable);
789
950
  var oValueControl;
951
+ var oPropertySettings = deepClone(oProperty, 500);
952
+ delete oPropertySettings.type;
953
+ delete oPropertySettings.label;
954
+ delete oPropertySettings.translatable;
955
+ delete oPropertySettings.defaultValue;
956
+ delete oPropertySettings.formatter;
957
+ delete oPropertySettings.column;
958
+ delete oPropertySettings.cell;
959
+ var oSettings;
790
960
  switch (oProperty.type) {
791
961
  case "boolean":
792
962
  if (oProperty.cell && oProperty.cell.type === "Switch") {
793
- var oSettings = {
963
+ oSettings = {
794
964
  state: "{" + sPathPrefix + n + "}",
795
965
  visible: "{= ${/editMode} === 'Properties'}",
796
- enabled: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
966
+ enabled: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
797
967
  change: fnChange
798
968
  };
799
969
  if (oProperty.cell.customTextOn) {
@@ -802,45 +972,52 @@ sap.ui.define([
802
972
  if (oProperty.cell.customTextOff) {
803
973
  oSettings.customTextOff = oProperty.cell.customTextOff;
804
974
  }
975
+ oSettings = merge(oSettings, oPropertySettings);
805
976
  oValueControl = new Switch(oSettings);
806
977
  } else {
807
- oValueControl = new CheckBox({
978
+ oSettings = {
808
979
  selected: "{" + sPathPrefix + n + "}",
809
980
  visible: "{= ${/editMode} === 'Properties'}",
810
- enabled: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
981
+ enabled: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
811
982
  select: fnChange
812
- });
983
+ };
984
+ oSettings = merge(oSettings, oPropertySettings);
985
+ oValueControl = new CheckBox(oSettings);
813
986
  }
814
987
  break;
815
988
  case "int":
816
989
  case "integer":
817
- oValueControl = new Input({
990
+ oSettings = {
818
991
  value: {
819
992
  path: sPathPrefix + n,
820
993
  type: "sap.ui.model.type.Integer",
821
994
  formatOptions: oProperty.formatter
822
995
  },
823
996
  visible: "{= ${/editMode} === 'Properties'}",
824
- editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
997
+ editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
825
998
  type: "Number",
826
999
  change: fnChange
827
- });
1000
+ };
1001
+ oSettings = merge(oSettings, oPropertySettings);
1002
+ oValueControl = new Input(oSettings);
828
1003
  break;
829
1004
  case "number":
830
- oValueControl = new Input({
1005
+ oSettings = {
831
1006
  value: {
832
1007
  path: sPathPrefix + n,
833
1008
  type: "sap.ui.model.type.Float",
834
1009
  formatOptions: oProperty.formatter
835
1010
  },
836
1011
  visible: "{= ${/editMode} === 'Properties'}",
837
- editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
1012
+ editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
838
1013
  type: "Number",
839
1014
  change: fnChange
840
- });
1015
+ };
1016
+ oSettings = merge(oSettings, oPropertySettings);
1017
+ oValueControl = new Input(oSettings);
841
1018
  break;
842
1019
  case "object":
843
- oValueControl = new TextArea({
1020
+ oSettings = {
844
1021
  value: {
845
1022
  path: sPathPrefix + n,
846
1023
  formatter: function(vValue) {
@@ -857,18 +1034,71 @@ sap.ui.define([
857
1034
  }
858
1035
  },
859
1036
  visible: "{= ${/editMode} === 'Properties'}",
860
- editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
1037
+ editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
861
1038
  change: fnChange,
862
1039
  rows: 3
863
- });
1040
+ };
1041
+ oSettings = merge(oSettings, oPropertySettings);
1042
+ oValueControl = new TextArea(oSettings);
864
1043
  break;
865
1044
  default:
866
- oValueControl = new Input({
1045
+ var oTextSettingsModel = new JSONModel({
1046
+ translatable: oProperty.translatable || false,
1047
+ uuidPath: sPathPrefix + "_dt/_uuid",
1048
+ property: n
1049
+ });
1050
+ oSettings = {
867
1051
  value: "{" + sPathPrefix + n + "}",
868
1052
  visible: "{= ${/editMode} === 'Properties'}",
869
- editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_editable} !== false}",
870
- change: fnChange
871
- });
1053
+ editable: oConfig.editable === false ? false : "{= ${" + sPathPrefix + "_dt/_editable} !== false}",
1054
+ change: function(oEvent) {
1055
+ var oControl = oEvent.getSource();
1056
+ var sValue = oEvent.getParameter("value");
1057
+ // change the translation format {{KEY}} to {i18n>KEY} since manifest will translate it, but we don't want
1058
+ // more info in JIRA DIGITALWORKPLACE-3974
1059
+ if (sValue && sValue.match(REGEXP_TRANSLATABLE)) {
1060
+ var sKey = sValue.substring(2, sValue.length - 2);
1061
+ sValue = "{i18n>" + sKey + "}";
1062
+ oControl.setValue(sValue);
1063
+ oControl.fireChange();
1064
+ } else if (fnChange) {
1065
+ fnChange(oEvent);
1066
+ }
1067
+ }
1068
+ };
1069
+ oSettings = merge(oSettings, oPropertySettings);
1070
+ // show the translation help icon of the input
1071
+ if (fnNavToTranslation) {
1072
+ oSettings.valueHelpIconSrc = "sap-icon://translate";
1073
+ oSettings.valueHelpRequest = fnNavToTranslation.bind(that, n);
1074
+ if (oProperty.translatable) {
1075
+ oSettings.showValueHelp = true;
1076
+ } else {
1077
+ oSettings.showValueHelp = {
1078
+ path: sPathPrefix + n,
1079
+ formatter: function(oValue) {
1080
+ var oSettings = this.getModel("settings").getData();
1081
+ var sUUID = this.getModel().getProperty(oSettings.uuidPath);
1082
+ var sConfigName = "translatable";
1083
+ if (that.getTranslationKey(oValue)) {
1084
+ if (!this.getShowValueHelp() && that.getObjectPropertyConfigValueInDesigntime(sUUID, oSettings.property, sConfigName) === false) {
1085
+ that.setObjectPropertyConfigValueInDesigntime(sUUID, oSettings.property, sConfigName, true);
1086
+ }
1087
+ return true;
1088
+ }
1089
+ if (this.getShowValueHelp()) {
1090
+ // clean the translation values and updated language since the translation feature is off
1091
+ that.deleteTranslationValueInTexts(undefined, sUUID, oSettings.property);
1092
+ that.setObjectPropertyConfigValueInDesigntime(sUUID, oSettings.property, sConfigName, false);
1093
+ that._oUpdatedTranslations = {};
1094
+ }
1095
+ return false;
1096
+ }
1097
+ };
1098
+ }
1099
+ }
1100
+ oValueControl = new Input(oSettings);
1101
+ oValueControl.setModel(oTextSettingsModel,"settings");
872
1102
  }
873
1103
  aPropertyContentList.push(oValueControl);
874
1104
  }
@@ -879,7 +1109,7 @@ sap.ui.define([
879
1109
  var that = this;
880
1110
  var oValueModel;
881
1111
  if (!bIsInDetailsPopover) {
882
- that._setCurrentProperty("value", oValue);
1112
+ that.setValue(oValue);
883
1113
  oValueModel = that.getAggregation("_field").getModel();
884
1114
  if (oValueModel) {
885
1115
  oValue = deepClone(oValue, 500);
@@ -910,7 +1140,7 @@ sap.ui.define([
910
1140
  oModel.checkUpdate(true);
911
1141
  var oValue = oModel.getProperty("/value");
912
1142
  oValue = deepClone(oValue, 500);
913
- that._setCurrentProperty("value", oValue);
1143
+ that.setValue(oValue);
914
1144
  };
915
1145
  var aPropertyContents = that.createPropertyContents(fnChange, "/value/");
916
1146
  aPropertyContents = aPropertyContents.concat(aContents);
@@ -919,12 +1149,58 @@ sap.ui.define([
919
1149
  });
920
1150
  };
921
1151
 
1152
+ // get origin values in i18n files
1153
+ ObjectField.prototype.getOriginTranslatedValues = function(sKey) {
1154
+ var aOriginTranslatedValues = [];
1155
+ var aEditorResourceBundles = EditorResourceBundles.getInstance();
1156
+ for (var p in aEditorResourceBundles) {
1157
+ var oResourceBundleTemp = aEditorResourceBundles[p];
1158
+ var sTranslatedValue = "";
1159
+ var sOriginValue = "";
1160
+ if (sKey && oResourceBundleTemp) {
1161
+ var sText = oResourceBundleTemp.resourceBundle && oResourceBundleTemp.resourceBundle.getText(sKey);
1162
+ sTranslatedValue = sText;
1163
+ sOriginValue = sText;
1164
+ } else {
1165
+ // if no translation key which means item defined as string value directly.
1166
+ // set the sTranslatedValue and sOriginValue for each language with item manifest value or default value.
1167
+ sTranslatedValue = "";
1168
+ sOriginValue = "";
1169
+ }
1170
+ var oLanguage = {
1171
+ "key": p,
1172
+ "desription": oResourceBundleTemp.language,
1173
+ "value": sTranslatedValue,
1174
+ "originValue": sOriginValue,
1175
+ "editable": true
1176
+ };
1177
+ aOriginTranslatedValues.push(oLanguage);
1178
+ }
1179
+ return aOriginTranslatedValues;
1180
+ };
1181
+
1182
+ // build origin translation values if translation type is "property"
1183
+ ObjectField.prototype.buildPropertyTranslationValues = function(sKey) {
1184
+ var aOriginTranslatedValues = [];
1185
+ var aEditorResourceBundles = EditorResourceBundles.getInstance();
1186
+ for (var p in aEditorResourceBundles) {
1187
+ aOriginTranslatedValues.push({
1188
+ "key": p,
1189
+ "desription": aEditorResourceBundles[p].language,
1190
+ "value": sKey,
1191
+ "originValue": sKey,
1192
+ "editable": true
1193
+ });
1194
+ }
1195
+ return aOriginTranslatedValues;
1196
+ };
1197
+
922
1198
  ObjectField.prototype.openObjectDetailsPopover = function (oItem, oControl, sMode) {
923
1199
  var that = this;
924
- var oField = that.getAggregation("_field");
925
1200
  var oResourceBundle = that.getResourceBundle();
926
1201
  var oItemCloned = deepClone(oItem, 500);
927
1202
  var oModel;
1203
+ var sPlacement = sMode === "add" && that._previewPosition !== "right" ? "Left" : "Right";
928
1204
  if (!that._oObjectDetailsPopover) {
929
1205
  var oAddButton = new Button({
930
1206
  text: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DETAILS_POPOVER_BUTTON_ADD"),
@@ -932,13 +1208,19 @@ sap.ui.define([
932
1208
  enabled: {
933
1209
  path: '/value',
934
1210
  formatter: function(vValue) {
935
- if (!vValue || vValue === "" || deepEqual(vValue, {})) {
1211
+ if (typeof vValue !== "object" || deepEqual(vValue, {})) {
936
1212
  return false;
1213
+ } else {
1214
+ var oValue = deepClone(vValue);
1215
+ delete oValue._dt;
1216
+ if (deepEqual(oValue, {})) {
1217
+ return false;
1218
+ }
937
1219
  }
938
1220
  return true;
939
1221
  }
940
1222
  },
941
- press: that.onCreate.bind(that)
1223
+ press: that.onAdd.bind(that)
942
1224
  });
943
1225
  var oUpdateButton = new Button({
944
1226
  text: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DETAILS_POPOVER_BUTTON_UPDATE"),
@@ -958,6 +1240,11 @@ sap.ui.define([
958
1240
  text: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DETAILS_POPOVER_BUTTON_CANCEL"),
959
1241
  visible: sMode !== "view",
960
1242
  press: function () {
1243
+ if (sMode === "add") {
1244
+ // clean the translations for the cancelled new object
1245
+ var oNewObject = that._oObjectDetailsPopover.getModel().getProperty("/value");
1246
+ that.deleteTranslationValueInTexts(undefined, oNewObject._dt._uuid);
1247
+ }
961
1248
  that._oObjectDetailsPopover.close();
962
1249
  }
963
1250
  });
@@ -968,27 +1255,6 @@ sap.ui.define([
968
1255
  that._oObjectDetailsPopover.close();
969
1256
  }
970
1257
  });
971
- oModel = new JSONModel({
972
- "value": oItemCloned,
973
- "editMode": "Properties"
974
- });
975
- var aObjectPropertyFormContents;
976
- var fnChangeWithDataSave = function(oEvent) {
977
- var oModel = that._oObjectDetailsPopover.getModel();
978
- oModel.checkUpdate(true);
979
- var oNewObject = oModel.getProperty("/value");
980
- if (oNewObject && oNewObject !== "" && typeof oNewObject === "object" && !deepEqual(oNewObject, {})) {
981
- oAddButton.setEnabled(true);
982
- } else {
983
- oAddButton.setEnabled(false);
984
- }
985
- };
986
- var fnChange = function() {};
987
- if (oItem._editable !== false) {
988
- aObjectPropertyFormContents = that.createFormContents(fnChangeWithDataSave, "/value/", true);
989
- } else {
990
- aObjectPropertyFormContents = that.createFormContents(fnChange, "/value/", true);
991
- }
992
1258
  var oEditModeButton = new Button({
993
1259
  icon: {
994
1260
  path: '/editMode',
@@ -1021,6 +1287,50 @@ sap.ui.define([
1021
1287
  }
1022
1288
  }
1023
1289
  });
1290
+ var aObjectPropertyFormContents;
1291
+ that._oNavContainer = new NavContainer();
1292
+ that._oObjectDetailsPage = new Page({
1293
+ title: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DETAILS_POPOVER_TITLE"),
1294
+ headerContent: oEditModeButton,
1295
+ footer: new OverflowToolbar({
1296
+ content: [
1297
+ new ToolbarSpacer(),
1298
+ oAddButton,
1299
+ oUpdateButton,
1300
+ oCancelButton,
1301
+ oCloseButton
1302
+ ]
1303
+ })
1304
+ });
1305
+ var fnNavBack = function (oEvent) {
1306
+ that._oNavContainer.back();
1307
+ that._oObjectDetailsPage.focus();
1308
+ };
1309
+ var oList = that.buildTranslationsList();
1310
+ var oTranslationsFooter = that.buildTranslationsFooter(oList, false);
1311
+ that._oTranslationListPage = new Page({
1312
+ title: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TRANSLATION_LIST_TITLE", "{languages>/property}"),
1313
+ showNavButton: true,
1314
+ navButtonPress: fnNavBack,
1315
+ content: oList,
1316
+ footer: oTranslationsFooter
1317
+ });
1318
+ var fnChangeWithDataSave = function(oEvent) {
1319
+ var oModel = that._oObjectDetailsPopover.getModel();
1320
+ oModel.checkUpdate(true);
1321
+ var oNewObject = oModel.getProperty("/value");
1322
+ if (oNewObject && oNewObject !== "" && typeof oNewObject === "object" && !deepEqual(oNewObject, {})) {
1323
+ oAddButton.setEnabled(true);
1324
+ } else {
1325
+ oAddButton.setEnabled(false);
1326
+ }
1327
+ };
1328
+ var fnChange = function() {};
1329
+ if (oItem._dt && oItem._dt._editable === false) {
1330
+ aObjectPropertyFormContents = that.createFormContents(fnChange, "/value/", true, that.navToTranslationPage);
1331
+ } else {
1332
+ aObjectPropertyFormContents = that.createFormContents(fnChangeWithDataSave, "/value/", true, that.navToTranslationPage);
1333
+ }
1024
1334
  var oForm = new SimpleForm({
1025
1335
  layout: "ResponsiveGridLayout",
1026
1336
  labelSpanXL: 4,
@@ -1037,31 +1347,24 @@ sap.ui.define([
1037
1347
  columnsM: 1,
1038
1348
  content: aObjectPropertyFormContents
1039
1349
  });
1040
- var sPlacement = oField._previewPostion === "right" ? "Right" : "Left";
1350
+ that._oObjectDetailsPage.addContent(oForm);
1351
+ that._oNavContainer.addPage(that._oObjectDetailsPage);
1352
+ /*
1353
+ _oTranslationListPage.addContent();
1354
+ */
1355
+ that._oNavContainer.addPage(that._oTranslationListPage);
1041
1356
  that._oObjectDetailsPopover = new Popover({
1042
1357
  placement: sPlacement,
1358
+ showHeader: false,
1043
1359
  contentWidth: "300px",
1044
1360
  contentHeight: "345px",
1045
- content: oForm,
1046
- customHeader: new OverflowToolbar({
1047
- content: [
1048
- new Title({
1049
- text: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DETAILS_POPOVER_TITLE")
1050
- }),
1051
- new ToolbarSpacer(),
1052
- oEditModeButton
1053
- ]
1054
- }),
1055
- footer: new OverflowToolbar({
1056
- content: [
1057
- new ToolbarSpacer(),
1058
- oAddButton,
1059
- oUpdateButton,
1060
- oCancelButton,
1061
- oCloseButton
1062
- ]
1063
- })
1361
+ modal: true,
1362
+ content: that._oNavContainer
1064
1363
  }).addStyleClass("sapUiIntegrationEditorItemObjectFieldDetailsPopover");
1364
+ oModel = new JSONModel({
1365
+ "value": oItemCloned,
1366
+ "editMode": "Properties"
1367
+ });
1065
1368
  that._oObjectDetailsPopover.setModel(oModel);
1066
1369
  that._oObjectDetailsPopover.setModel(that.getModel("i18n"), "i18n");
1067
1370
  that._oObjectDetailsPopover._oAddButton = oAddButton;
@@ -1072,6 +1375,7 @@ sap.ui.define([
1072
1375
  } else {
1073
1376
  oModel = that._oObjectDetailsPopover.getModel();
1074
1377
  oModel.setProperty("/value", oItemCloned);
1378
+ oModel.checkUpdate(true);
1075
1379
  if (sMode === "add") {
1076
1380
  that._oObjectDetailsPopover._oAddButton.setVisible(true);
1077
1381
  that._oObjectDetailsPopover._oUpdateButton.setVisible(false);
@@ -1089,70 +1393,388 @@ sap.ui.define([
1089
1393
  that._oObjectDetailsPopover._oCloseButton.setVisible(true);
1090
1394
  }
1091
1395
  that._oObjectDetailsPopover._openBy = oControl;
1396
+ that._oObjectDetailsPopover.setPlacement(sPlacement);
1397
+ // nav back to main page
1398
+ that._oNavContainer.back();
1092
1399
  }
1093
1400
  that._oObjectDetailsPopover.openBy(oControl);
1094
1401
  };
1095
1402
 
1096
- ObjectField.prototype.onCreate = function(oEvent) {
1403
+ // build the translation data of the translation list
1404
+ ObjectField.prototype.buildTranslationsData = function (sKey, sType, sUUID, sProperty) {
1097
1405
  var that = this;
1098
- var oControl = that.getAggregation("_field");
1099
- var oParameter;
1100
- var bHasBeforeValue = that.checkHasValue();
1101
- if (bHasBeforeValue) {
1102
- oParameter = {
1103
- selectedIndex: oControl.getSelectedIndex(),
1104
- selectedIndices: oControl.getSelectedIndices()
1406
+ var oResourceBundle = that.getResourceBundle();
1407
+ that._oOriginTranslatedValues = that._oOriginTranslatedValues || {};
1408
+ that._oUpdatedTranslations = that._oUpdatedTranslations || {};
1409
+ var sPropertyKey = sUUID + "_" + sProperty;
1410
+ var sTranslationKey = sKey;
1411
+ // get or build the initial translation data
1412
+ if (sType === "key") {
1413
+ if (!that._oOriginTranslatedValues[sKey]) {
1414
+ that._oOriginTranslatedValues[sKey] = that.getOriginTranslatedValues(sKey);
1415
+ }
1416
+ } else if (sType === "property") {
1417
+ sTranslationKey = sPropertyKey;
1418
+ that._oOriginTranslatedValues[sTranslationKey] = that.buildPropertyTranslationValues(sKey);
1419
+ }
1420
+ var aTempTranslatedLanguages = [];
1421
+ // merge with the current translation texts
1422
+ that._oOriginTranslatedValues[sTranslationKey].forEach(function (originTranslatedValue) {
1423
+ var oTempTranslatedValue = deepClone(originTranslatedValue, 500);
1424
+ oTempTranslatedValue.status = oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_LISTITEM_GROUP_NOTUPDATED");
1425
+ var sTranslateText = that.getTranslationValueInTexts(oTempTranslatedValue.key, sUUID, sProperty);
1426
+ if (sTranslateText) {
1427
+ oTempTranslatedValue.value = sTranslateText;
1428
+ if (includes(that._oUpdatedTranslations[sTranslationKey], oTempTranslatedValue.key)) {
1429
+ oTempTranslatedValue.value = that.getTranslationValueInTexts(oTempTranslatedValue.key, sUUID, sProperty);
1430
+ oTempTranslatedValue.status = oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_LISTITEM_GROUP_UPDATED");
1431
+ } else {
1432
+ oTempTranslatedValue.originValue = oTempTranslatedValue.value;
1433
+ }
1434
+ }
1435
+ if (oTempTranslatedValue.key === oResourceBundle.sLocale.replaceAll('_', '-')) {
1436
+ oTempTranslatedValue.desription += " (" + oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_CURRENTLANGUAGE") + ")";
1437
+ aTempTranslatedLanguages.unshift(oTempTranslatedValue);
1438
+ } else {
1439
+ aTempTranslatedLanguages.push(oTempTranslatedValue);
1440
+ }
1441
+ });
1442
+ var oTranslatedValues = {
1443
+ "isUpdated": false,
1444
+ "key": sKey,
1445
+ "translationKey": sTranslationKey,
1446
+ "translationType": sType,
1447
+ "uuid": sUUID,
1448
+ "property": sProperty,
1449
+ "translatedLanguages": aTempTranslatedLanguages
1450
+ };
1451
+ return oTranslatedValues;
1452
+ };
1453
+
1454
+ ObjectField.prototype.getTranslationKey = function (sValue) {
1455
+ var sKey;
1456
+ if (sValue && sValue.match(REGEXP_TRANSLATABLE)) {
1457
+ sKey = sValue.substring(2, sValue.length - 2);
1458
+ } else if (sValue && sValue.startsWith("{i18n>") && sValue.endsWith('}')) {
1459
+ sKey = sValue.substring(6, sValue.length - 1);
1460
+ }
1461
+ return sKey;
1462
+ };
1463
+
1464
+ ObjectField.prototype.buildTranslationsModel = function (oTranslatedValues) {
1465
+ var that = this;
1466
+ var oResourceBundle = that.getResourceBundle();
1467
+ var oTranslatonsModel = new JSONModel(oTranslatedValues);
1468
+ oTranslatonsModel.attachPropertyChange(function(oEvent) {
1469
+ //update the status of each translation for grouping
1470
+ //update the isUpdated property
1471
+ var oData = oTranslatonsModel.getData();
1472
+ var sUpdatedStr = oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_LISTITEM_GROUP_UPDATED");
1473
+ var sNotUpdatedStr = oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_LISTITEM_GROUP_NOTUPDATED");
1474
+ var bIsUpdated = false;
1475
+ oData.translatedLanguages.forEach(function(oLanguage) {
1476
+ if (oLanguage.value !== oLanguage.originValue) {
1477
+ oLanguage.status = sUpdatedStr;
1478
+ bIsUpdated = true;
1479
+ } else {
1480
+ oLanguage.status = sNotUpdatedStr;
1481
+ }
1482
+ });
1483
+ oData.isUpdated = bIsUpdated;
1484
+ oTranslatonsModel.setData(oData);
1485
+ oTranslatonsModel.checkUpdate(true);
1486
+ });
1487
+ return oTranslatonsModel;
1488
+ };
1489
+
1490
+ ObjectField.prototype.buildTranslationsList = function () {
1491
+ return new List({
1492
+ items: {
1493
+ path: "languages>/translatedLanguages",
1494
+ template: new CustomListItem({
1495
+ content: [
1496
+ new VBox({
1497
+ items: [
1498
+ new Text({
1499
+ text: "{languages>desription}"
1500
+ }),
1501
+ new Input({
1502
+ value: "{languages>value}",
1503
+ editable: "{languages>editable}"
1504
+ })
1505
+ ]
1506
+ })
1507
+ ],
1508
+ customData: [
1509
+ new CustomData({
1510
+ key: "{languages>key}",
1511
+ value: "{languages>desription}"
1512
+ })
1513
+ ]
1514
+ }),
1515
+ sorter: [new Sorter({
1516
+ path: 'status',
1517
+ descending: true,
1518
+ group: true
1519
+ })]
1520
+ }
1521
+ });
1522
+ };
1523
+
1524
+ ObjectField.prototype.buildTranslationsFooter = function (oList, bIsInTranslationPopover) {
1525
+ var that = this;
1526
+ var oResourceBundle = that.getResourceBundle();
1527
+ var sCurrentLanugae = oResourceBundle.sLocale.replaceAll('_', '-');
1528
+ var oSaveTranslationButton = new Button({
1529
+ type: "Emphasized",
1530
+ text: oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_BUTTON_SAVE"),
1531
+ enabled: "{languages>/isUpdated}",
1532
+ press: function () {
1533
+ var oTranslationModel = oList.getModel("languages");
1534
+ var oData = oTranslationModel.getData();
1535
+ //get changes in the popup
1536
+ var aUpdatedLanguages = [];
1537
+ var sKey = oData.key;
1538
+ var sTranslationKey = oData.translationKey;
1539
+ var sType = oData.translationType;
1540
+ var sUUID = oData.uuid;
1541
+ var sProperty = oData.property;
1542
+ oData.translatedLanguages.forEach(function(oLanguage) {
1543
+ if (oLanguage.value !== oLanguage.originValue) {
1544
+ that.setTranslationValueInTexts(oLanguage.key, sUUID, sProperty, oLanguage.value);
1545
+ aUpdatedLanguages.push(oLanguage.key);
1546
+ }
1547
+ });
1548
+ var bUpdateDependentFieldsAndPreview = false;
1549
+ if (aUpdatedLanguages.length > 0) {
1550
+ that._oUpdatedTranslations = that._oUpdatedTranslations || {};
1551
+ that._oUpdatedTranslations[sTranslationKey] = aUpdatedLanguages;
1552
+ if (includes(aUpdatedLanguages, sCurrentLanugae)) {
1553
+ bUpdateDependentFieldsAndPreview = true;
1554
+ }
1555
+ }
1556
+ // refresh the translation list
1557
+ oData = that.buildTranslationsData(sKey, sType, sUUID, sProperty);
1558
+ oTranslationModel.setData(oData);
1559
+ oTranslationModel.checkUpdate(true);
1560
+ // update table
1561
+ if (that.getModel()) {
1562
+ that.getModel().checkUpdate(true);
1563
+ }
1564
+ // update preview and dependent fields
1565
+ if (bUpdateDependentFieldsAndPreview && that._oValueBinding) {
1566
+ that._oValueBinding.fireEvent("change");
1567
+ }
1568
+ }
1569
+ });
1570
+ var oResetTranslationButton = new Button({
1571
+ text: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DETAILS_POPOVER_BUTTON_RESET"),
1572
+ enabled: "{languages>/isUpdated}",
1573
+ press: function(oEvent) {
1574
+ var oTranslationModel = oList.getModel("languages");
1575
+ var oData = oTranslationModel.getData();
1576
+ // set value to origin value
1577
+ oData.translatedLanguages.forEach(function (translatedValue) {
1578
+ translatedValue.value = translatedValue.originValue;
1579
+ translatedValue.status = oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_LISTITEM_GROUP_NOTUPDATED");
1580
+ });
1581
+ oData.isUpdated = false;
1582
+ oTranslationModel.setData(oData);
1583
+ oTranslationModel.checkUpdate(true);
1584
+ }
1585
+ });
1586
+ var oCancelButton = new Button({
1587
+ text: oResourceBundle.getText("EDITOR_FIELD_TRANSLATION_LIST_POPOVER_BUTTON_CANCEL"),
1588
+ visible: bIsInTranslationPopover,
1589
+ press: function () {
1590
+ that._oTranslationPopover.close();
1591
+ }
1592
+ });
1593
+ return new OverflowToolbar({
1594
+ content: [
1595
+ new ToolbarSpacer(),
1596
+ oSaveTranslationButton,
1597
+ oResetTranslationButton,
1598
+ oCancelButton
1599
+ ]
1600
+ });
1601
+ };
1602
+
1603
+ ObjectField.prototype.openTranslationPopup = function (sProperty, oEvent) {
1604
+ var that = this;
1605
+ var oControl = oEvent.getSource();
1606
+ var oResourceBundle = that.getResourceBundle();
1607
+ var oNewObject = oControl.getModel().getProperty("/value");
1608
+ if (!oNewObject._dt) {
1609
+ oNewObject._dt = {
1610
+ _uuid: Utils.generateUuidV4()
1105
1611
  };
1612
+ } else if (!oNewObject._dt._uuid) {
1613
+ oNewObject._dt._uuid = Utils.generateUuidV4();
1614
+ }
1615
+ var sValue = oControl.getValue();
1616
+ //get translation key of the value
1617
+ var sKey = that.getTranslationKey(sValue);
1618
+ var sType = "property";
1619
+ if (sKey && sKey !== "") {
1620
+ sType = "key";
1621
+ } else {
1622
+ sKey = sValue;
1106
1623
  }
1624
+ var oTranslatedValues = that.buildTranslationsData(sKey, sType, oNewObject._dt._uuid, sProperty);
1625
+ var oTranslatonsModel;
1626
+ if (!that._oTranslationPopover) {
1627
+ var oList = that.buildTranslationsList();
1628
+ var oTranslationsFooter = that.buildTranslationsFooter(oList, true);
1629
+ var sPlacement = that._previewPosition === "right" ? "Right" : "Left";
1630
+ that._oTranslationPopover = new Popover({
1631
+ placement: sPlacement,
1632
+ contentWidth: "300px",
1633
+ contentHeight: "345px",
1634
+ title: oResourceBundle.getText("EDITOR_FIELD_OBJECT_TRANSLATION_LIST_TITLE", "{languages>/property}"),
1635
+ content: oList,
1636
+ footer: oTranslationsFooter
1637
+ }).addStyleClass("sapUiIntegrationFieldTranslation");
1638
+ oTranslatonsModel = that.buildTranslationsModel(oTranslatedValues);
1639
+ that._oTranslationPopover.setModel(oTranslatonsModel, "languages");
1640
+ } else {
1641
+ oTranslatonsModel = that._oTranslationPopover.getModel("languages");
1642
+ oTranslatonsModel.setData(oTranslatedValues);
1643
+ oTranslatonsModel.checkUpdate(true);
1644
+ }
1645
+ that._oTranslationPopover.openBy(oControl._oValueHelpIcon);
1646
+ };
1647
+
1648
+ ObjectField.prototype.navToTranslationPage = function (sProperty, oEvent) {
1649
+ var that = this;
1650
+ var oNewObject = that._oObjectDetailsPopover.getModel().getProperty("/value");
1651
+ var sValue = oNewObject[sProperty];
1652
+ //get translation key of the value
1653
+ var sKey = that.getTranslationKey(sValue);
1654
+ var sType = "property";
1655
+ if (sKey && sKey !== "") {
1656
+ sType = "key";
1657
+ } else {
1658
+ sKey = sValue;
1659
+ }
1660
+ var oTranslatedValues = that.buildTranslationsData(sKey, sType, oNewObject._dt._uuid, sProperty);
1661
+ var oTranslatonsModel = that._oTranslationListPage.getModel("languages");
1662
+ if (!oTranslatonsModel) {
1663
+ oTranslatonsModel = that.buildTranslationsModel(oTranslatedValues);
1664
+ that._oTranslationListPage.setModel(oTranslatonsModel, "languages");
1665
+ } else {
1666
+ oTranslatonsModel.setData(oTranslatedValues);
1667
+ }
1668
+ that._oNavContainer.to(that._oTranslationListPage);
1669
+ that._oTranslationListPage.focus();
1670
+ };
1671
+
1672
+ ObjectField.prototype.onAdd = function(oEvent) {
1673
+ var that = this;
1674
+ var oControl = that.getAggregation("_field");
1675
+ var oModel = oControl.getModel();
1107
1676
  var oNewObject = that._oObjectDetailsPopover.getModel().getProperty("/value");
1108
1677
  var sPath = oControl.getBinding("rows").getPath();
1109
- var oData = oControl.getModel().getProperty(sPath);
1678
+ var oData = oModel.getProperty(sPath);
1679
+ oData.forEach(function (oItem) {
1680
+ if (oItem._dt._selected) {
1681
+ oItem._dt._selected = false;
1682
+ }
1683
+ });
1110
1684
  oData.push(oNewObject);
1111
- oControl.getModel().checkUpdate();
1685
+ oModel.setProperty("/_hasSelected", true);
1686
+ oModel.setProperty("/_hasTableAllSelected", false);
1687
+ oModel.setProperty("/_hasTableSelected", false);
1688
+ oModel.checkUpdate();
1689
+ that.refreshValue();
1690
+ that.updateTable();
1112
1691
  that._oObjectDetailsPopover.close();
1113
-
1114
- // restore the selections since the selections are lost, BCP: 2280048930, JIRA: CPOUIFTEAMB-252
1115
- if (bHasBeforeValue) {
1116
- that.applyBeforeValueAndSelections("add", oParameter);
1117
- }
1118
1692
  };
1119
1693
 
1120
1694
  ObjectField.prototype.onUpdate = function (oEvent) {
1121
1695
  var that = this;
1122
- var oControl = that.getAggregation("_field");
1696
+ var oTable = that.getAggregation("_field");
1123
1697
  var oObject = that._oObjectDetailsPopover.getModel().getProperty("/value");
1124
- var oModel = oControl.getModel();
1125
- var oRow = that._oObjectDetailsPopover._openBy.getParent().getParent();
1698
+ var oModel = oTable.getModel();
1699
+ var oRow = that._oObjectDetailsPopover._openBy.getParent();
1126
1700
  var iRowIndex = oRow.getIndex();
1127
1701
 
1128
1702
  // get the real index via path since the rows may be filtered
1129
- var oRowContexts = oControl.getBinding("rows").getContexts();
1130
- var sPath = oRowContexts[iRowIndex].getPath();
1131
-
1132
- var oParameter;
1133
- var bHasBeforeValue = that.checkHasValue();
1134
- if (bHasBeforeValue) {
1135
- var aRowContexts = oControl.getBinding("rows").getContexts();
1136
- oParameter = {
1137
- updatedObject: oObject,
1138
- rowIndex: iRowIndex,
1139
- path: sPath,
1140
- selectedIndex: oControl.getSelectedIndex(),
1141
- selectedIndices: oControl.getSelectedIndices(),
1142
- rowNumber: aRowContexts ? aRowContexts.length : 0
1143
- };
1144
- }
1145
-
1703
+ var aRowContexts = oTable.getBinding("rows").getContexts();
1704
+ var sPath = aRowContexts[iRowIndex].getPath();
1146
1705
  // update the object in control value model
1147
1706
  oModel.setProperty(sPath, deepClone(oObject, 500));
1148
1707
  oModel.checkUpdate();
1149
1708
 
1709
+ //update object in field value if it is selected
1710
+ if (oObject._dt && oObject._dt._selected) {
1711
+ that.refreshValue();
1712
+ }
1713
+ that.updateTable();
1714
+
1150
1715
  that._oObjectDetailsPopover.close();
1716
+ };
1151
1717
 
1152
- // restore the selections since the selections are lost, BCP: 2280048930, JIRA: CPOUIFTEAMB-252
1153
- if (bHasBeforeValue) {
1154
- that.applyBeforeValueAndSelections("update", oParameter);
1718
+ ObjectField.prototype.onDelete = function(oEvent) {
1719
+ var that = this;
1720
+ var oTable = that.getAggregation("_field");
1721
+ var oResourceBundle = that.getResourceBundle();
1722
+ var aSelectedIndices = oTable.getSelectedIndices();
1723
+ var aSelectedIndexs = [];
1724
+ var aRowContexts = oTable.getBinding("rows").getContexts();
1725
+ aSelectedIndices.forEach(function (iSelectIndex) {
1726
+ var oObject = aRowContexts[iSelectIndex].getObject();
1727
+ if (oObject._dt && oObject._dt._editable !== false) {
1728
+ var sPath = aRowContexts[iSelectIndex].getPath();
1729
+ var iRealIndex = sPath.substring(sPath.lastIndexOf("/") + 1);
1730
+ aSelectedIndexs.push(iRealIndex);
1731
+ }
1732
+ });
1733
+ if (aSelectedIndexs.length === 0) {
1734
+ MessageBox.error(oResourceBundle.getText("EDITOR_FIELD_OBJECT_DELETE_ERROR_MSG"));
1735
+ return;
1736
+ }
1737
+ MessageBox.confirm(oResourceBundle.getText("EDITOR_FIELD_OBJECT_DELETE_CONFIRM_MSG"), {
1738
+ title: oResourceBundle.getText("EDITOR_FIELD_OBJECT_DELETE_CONFIRM_TITLE"),
1739
+ onClose: function(sAction) {
1740
+ if (sAction === MessageBox.Action.OK) {
1741
+ var sPath = oTable.getBindingContext().getPath();
1742
+ var oModel = oTable.getModel();
1743
+ var oData = oModel.getProperty(sPath);
1744
+ var oNewData = [];
1745
+ for (var i = 0; i < oData.length; i++) {
1746
+ if (includes(aSelectedIndexs, i + "")) {
1747
+ that.deleteTranslationValueInTexts(undefined, oData[i]._dt._uuid);
1748
+ } else {
1749
+ oNewData.push(oData[i]);
1750
+ }
1751
+ }
1752
+ oModel.setProperty(sPath, oNewData);
1753
+ oModel.checkUpdate(true);
1754
+ that.refreshValue();
1755
+ that.updateTable();
1756
+ } else {
1757
+ MessageToast.show(oResourceBundle.getText("EDITOR_FIELD_OBJECT_DELETE_CONFIRM_CANCLE"));
1758
+ }
1759
+ }
1760
+ });
1761
+ };
1762
+
1763
+ ObjectField.prototype.refreshValue = function () {
1764
+ var that = this;
1765
+ var oTable = that.getAggregation("_field");
1766
+ var oModel = oTable.getModel();
1767
+ var sPath = oTable.getBinding("rows").getPath();
1768
+ var oData = oModel.getProperty(sPath);
1769
+ var oValue;
1770
+ for (var i = 0; i < oData.length; i++) {
1771
+ var oItem = oData[i];
1772
+ if (oItem._dt._selected) {
1773
+ oValue = deepClone(oItem);
1774
+ break;
1775
+ }
1155
1776
  }
1777
+ that.setValue(oValue);
1156
1778
  };
1157
1779
 
1158
1780
  ObjectField.prototype.clearAllFilters = function(oEvent) {
@@ -1169,93 +1791,144 @@ sap.ui.define([
1169
1791
  }
1170
1792
  };
1171
1793
 
1172
- ObjectField.prototype.checkHasValue = function() {
1794
+ ObjectField.prototype.setValue = function(oValue) {
1173
1795
  var that = this;
1174
- var oValue = that._getCurrentProperty("value");
1175
- if (typeof oValue === "object" && !deepEqual(oValue, {})) {
1176
- return true;
1796
+ that.cleanDT(oValue);
1797
+ that._setCurrentProperty("value", oValue);
1798
+ };
1799
+
1800
+ ObjectField.prototype.cleanDT = function(oValue) {
1801
+ if (oValue && oValue._dt && oValue._dt._selected) {
1802
+ delete oValue._dt._selected;
1803
+ }
1804
+ if (oValue && oValue._dt && deepEqual(oValue._dt, {})) {
1805
+ delete oValue._dt;
1177
1806
  }
1178
- return false;
1179
1807
  };
1180
1808
 
1181
- // restore the selections since the selections are lost, BCP: 2280048930, JIRA: CPOUIFTEAMB-252
1182
- ObjectField.prototype.applyBeforeValueAndSelections = function(sMode, oParameter) {
1809
+ // get the translation text
1810
+ ObjectField.prototype.getTranslationValueInTexts = function (sLanguage, sUUID, sProperty) {
1183
1811
  var that = this;
1184
- var oControl = that.getAggregation("_field");
1185
- var iSelectedIndex = oParameter.selectedIndex;
1186
- var iRowNumber = oParameter.rowNumber;
1187
- var aRowContexts = oControl.getBinding("rows").getContexts();
1188
- var iNewRowNumber = aRowContexts.length;
1189
- var iRowIndex = oParameter.rowIndex;
1190
- var sPath = oControl.getBinding("rows").getPath();
1191
- var iRealIndexOfFilteredOut;
1192
- switch (sMode) {
1193
- case "add":
1194
- if (iSelectedIndex > -1) {
1195
- oControl.setSelectedIndex(iSelectedIndex);
1196
- oControl._sPathOfFilteredOut = null;
1197
- }
1198
- break;
1199
- case "update":
1200
- //update object in field value if it is selected
1201
- if (iRowIndex === iSelectedIndex) {
1202
- that._setCurrentProperty("value", oParameter.updatedObject);
1203
- // update the selections when row number changed which means the update may cause it filter out
1204
- if (iRowNumber !== iNewRowNumber) {
1205
- oControl._sPathOfFilteredOut = oParameter.path;
1206
- }
1207
- } else if (iRowNumber !== iNewRowNumber) {
1208
- // update the selections when row number changed which means the update may cause it filter out
1209
- if (iSelectedIndex > iRowIndex) {
1210
- iSelectedIndex--;
1812
+ var oConfig = that.getConfiguration();
1813
+ var sTranslationPath = "/texts/" + sLanguage;
1814
+ var oProperty = this._settingsModel.getProperty(sTranslationPath) || {};
1815
+ var oValue = oProperty[oConfig.manifestpath];
1816
+ var sValue;
1817
+ if (oValue && oValue[sUUID]) {
1818
+ sValue = oValue[sUUID][sProperty];
1819
+ }
1820
+ return sValue;
1821
+ };
1822
+
1823
+ // set the config value of the property in designtime
1824
+ ObjectField.prototype.setObjectPropertyConfigValueInDesigntime = function (sUUID, sProperty, sConfigName, vConfigValue) {
1825
+ var that = this;
1826
+ var oConfig = that.getConfiguration();
1827
+ var sDesigntimePath = "/:designtime";
1828
+ var oData = this._settingsModel.getData();
1829
+ if (!oData) {
1830
+ return;
1831
+ }
1832
+ var oDesigntime;
1833
+ if (!oData.hasOwnProperty(":designtime")) {
1834
+ oDesigntime = {};
1835
+ } else {
1836
+ oDesigntime = deepClone(oData[":designtime"], 500);
1837
+ }
1838
+ if (!oDesigntime.hasOwnProperty(oConfig.manifestpath)) {
1839
+ oDesigntime[oConfig.manifestpath] = {};
1840
+ }
1841
+ if (!oDesigntime[oConfig.manifestpath].hasOwnProperty(sUUID)) {
1842
+ oDesigntime[oConfig.manifestpath][sUUID] = {};
1843
+ }
1844
+ if (!oDesigntime[oConfig.manifestpath][sUUID].hasOwnProperty(sProperty)) {
1845
+ oDesigntime[oConfig.manifestpath][sUUID][sProperty] = {};
1846
+ }
1847
+ oDesigntime[oConfig.manifestpath][sUUID][sProperty][sConfigName] = vConfigValue;
1848
+ this._settingsModel.setProperty(sDesigntimePath, oDesigntime);
1849
+ };
1850
+
1851
+ // get the config value of the property in designtime
1852
+ ObjectField.prototype.getObjectPropertyConfigValueInDesigntime = function (sUUID, sProperty, sConfigName) {
1853
+ var that = this;
1854
+ var vConfigValue;
1855
+ var oConfig = that.getConfiguration();
1856
+ var oData = this._settingsModel.getData();
1857
+ if (oData && oData[":designtime"]
1858
+ && oData[":designtime"][oConfig.manifestpath]
1859
+ && oData[":designtime"][oConfig.manifestpath][sUUID]
1860
+ && oData[":designtime"][oConfig.manifestpath][sUUID][sProperty]
1861
+ && oData[":designtime"][oConfig.manifestpath][sUUID][sProperty].hasOwnProperty(sConfigName)) {
1862
+ vConfigValue = oData[":designtime"][oConfig.manifestpath][sUUID][sProperty][sConfigName];
1863
+ }
1864
+ return vConfigValue;
1865
+ };
1866
+
1867
+ // set the translation text
1868
+ ObjectField.prototype.setTranslationValueInTexts = function (sLanguage, sUUID, sProperty, sValue) {
1869
+ var that = this;
1870
+ var oConfig = that.getConfiguration();
1871
+ var sTranslationPath = "/texts";
1872
+ var oData = this._settingsModel.getData();
1873
+ if (!oData) {
1874
+ return;
1875
+ }
1876
+ var oTexts;
1877
+ if (!oData.hasOwnProperty("texts")) {
1878
+ oTexts = {};
1879
+ } else {
1880
+ oTexts = deepClone(oData.texts, 500);
1881
+ }
1882
+ if (!oTexts.hasOwnProperty(sLanguage)) {
1883
+ oTexts[sLanguage] = {};
1884
+ }
1885
+ if (!oTexts[sLanguage].hasOwnProperty(oConfig.manifestpath)) {
1886
+ oTexts[sLanguage][oConfig.manifestpath] = {};
1887
+ }
1888
+ if (!oTexts[sLanguage][oConfig.manifestpath].hasOwnProperty(sUUID)) {
1889
+ oTexts[sLanguage][oConfig.manifestpath][sUUID] = {};
1890
+ }
1891
+ oTexts[sLanguage][oConfig.manifestpath][sUUID][sProperty] = sValue;
1892
+ this._settingsModel.setProperty(sTranslationPath, oTexts);
1893
+ };
1894
+
1895
+ // delete the translation text
1896
+ ObjectField.prototype.deleteTranslationValueInTexts = function (sLanguage, sUUID, sProperty) {
1897
+ var that = this;
1898
+ var oData = that._settingsModel.getData();
1899
+ if (!oData || !oData.texts || !sUUID) {
1900
+ return;
1901
+ }
1902
+ var oConfig = that.getConfiguration();
1903
+ var sTranslationPath = "/texts";
1904
+ var oTexts = deepClone(oData.texts, 500);
1905
+ if (sLanguage) {
1906
+ if (oTexts[sLanguage]
1907
+ && oTexts[sLanguage][oConfig.manifestpath]
1908
+ && oTexts[sLanguage][oConfig.manifestpath][sUUID]) {
1909
+ if (sProperty) {
1910
+ if (oTexts[sLanguage][oConfig.manifestpath][sUUID].hasOwnProperty(sProperty)) {
1911
+ delete oTexts[sLanguage][oConfig.manifestpath][sUUID][sProperty];
1912
+ if (deepEqual(oTexts[sLanguage][oConfig.manifestpath][sUUID], {})) {
1913
+ delete oTexts[sLanguage][oConfig.manifestpath][sUUID];
1914
+ }
1915
+ this._settingsModel.setProperty(sTranslationPath, oTexts);
1211
1916
  }
1212
- oControl.setSelectedIndex(iSelectedIndex);
1213
- }
1214
- break;
1215
- case "delete":
1216
- if (iSelectedIndex === iRowIndex) {
1217
- that._setCurrentProperty("value", undefined);
1218
- } else if (iSelectedIndex > iRowIndex) {
1219
- oControl.setSelectedIndex(iSelectedIndex - 1);
1220
1917
  } else {
1221
- oControl.setSelectedIndex(iSelectedIndex);
1222
- }
1223
- // update the Paths in oControl._sPathOfFilteredOut
1224
- if (oControl._sPathOfFilteredOut) {
1225
- iRealIndexOfFilteredOut = oControl._sPathOfFilteredOut.substring(oControl._sPathOfFilteredOut.lastIndexOf("/") + 1);
1226
- if (iRealIndexOfFilteredOut > oParameter.realIndex) {
1227
- iRealIndexOfFilteredOut--;
1228
- oControl._sPathOfFilteredOut = sPath + "/" + iRealIndexOfFilteredOut;
1229
- }
1230
- }
1231
- break;
1232
- case "filter":
1233
- var oColumn = oParameter.column;
1234
- if (iSelectedIndex > -1) {
1235
- oControl._sPathOfFilteredOut = aRowContexts && aRowContexts[iSelectedIndex].getPath();
1236
- }
1237
- if (oColumn._applySelection !== false && oControl._sPathOfFilteredOut) {
1238
- oControl.attachEventOnce("rowsUpdated", function() {
1239
- var aFilteredRowContexts = oControl.getBinding("rows").getContexts() || [];
1240
- var sNewIndex = -1;
1241
- if (aFilteredRowContexts.length > 0 && oControl._sPathOfFilteredOut) {
1242
- for (var i = 0; i < aFilteredRowContexts.length; i++) {
1243
- var oContext = aFilteredRowContexts[i];
1244
- if (oContext.getPath() === oControl._sPathOfFilteredOut) {
1245
- sNewIndex = i;
1246
- oControl._sPathOfFilteredOut = undefined;
1247
- break;
1248
- }
1249
- }
1250
- }
1251
- if (sNewIndex > -1) {
1252
- oControl.setSelectedIndex(sNewIndex);
1918
+ delete oTexts[sLanguage][oConfig.manifestpath][sUUID];
1919
+ if (deepEqual(oTexts[sLanguage][oConfig.manifestpath], {})) {
1920
+ delete oTexts[sLanguage][oConfig.manifestpath];
1921
+ if (deepEqual(oTexts[sLanguage], {})) {
1922
+ delete oTexts[sLanguage];
1253
1923
  }
1254
- });
1924
+ }
1925
+ this._settingsModel.setProperty(sTranslationPath, oTexts);
1255
1926
  }
1256
- delete oColumn._applySelection;
1257
- break;
1258
- default:
1927
+ }
1928
+ } else {
1929
+ for (var n in oTexts) {
1930
+ that.deleteTranslationValueInTexts(n, sUUID, sProperty);
1931
+ }
1259
1932
  }
1260
1933
  };
1261
1934