@sapui5/sap.ushell_abap 1.97.1 → 1.99.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/package.json +1 -1
  2. package/src/main/js/sap/ushell_abap/.library +2 -2
  3. package/src/main/js/sap/ushell_abap/adapters/abap/AdapterContainer.js +1 -1
  4. package/src/main/js/sap/ushell_abap/adapters/abap/AppStateAdapter.js +2 -2
  5. package/src/main/js/sap/ushell_abap/adapters/abap/ClientSideTargetResolutionAdapter.js +2 -2
  6. package/src/main/js/sap/ushell_abap/adapters/abap/ConfigurationDefaultsAdapter.js +2 -2
  7. package/src/main/js/sap/ushell_abap/adapters/abap/ContainerAdapter.js +2 -2
  8. package/src/main/js/sap/ushell_abap/adapters/abap/LaunchPageAdapter.js +37 -4
  9. package/src/main/js/sap/ushell_abap/adapters/abap/MenuAdapter.js +1 -1
  10. package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionAdapter.js +2 -2
  11. package/src/main/js/sap/ushell_abap/adapters/abap/PageBuildingAdapter.js +2 -2
  12. package/src/main/js/sap/ushell_abap/adapters/abap/PagePersistenceAdapter.js +35 -15
  13. package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationAdapter.js +2 -2
  14. package/src/main/js/sap/ushell_abap/adapters/abap/SearchAdapter.js +2 -2
  15. package/src/main/js/sap/ushell_abap/adapters/abap/SupportTicketAdapter.js +2 -2
  16. package/src/main/js/sap/ushell_abap/adapters/abap/Ui5ComponentLoaderAdapter.js +2 -2
  17. package/src/main/js/sap/ushell_abap/adapters/abap/UserInfoAdapter.js +1 -1
  18. package/src/main/js/sap/ushell_abap/adapters/hana/ContainerAdapter.js +2 -2
  19. package/src/main/js/sap/ushell_abap/bootstrap/evo/XhrLogonEventHandler.js +1 -1
  20. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def-dev.js +1 -1
  21. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def-loader.js +7 -0
  22. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def.js +1 -1
  23. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.bootstrap.utils.js +1 -1
  24. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.configure.ushell.js +2 -2
  25. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.constants.js +1 -1
  26. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.get.server.config.Urls.js +1 -1
  27. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.js +1 -1
  28. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.load.launchpad.js +2 -17
  29. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.pageset.js +1 -1
  30. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.server.config.js +1 -1
  31. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.startup.js +1 -1
  32. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.theme.handler.js +1 -1
  33. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.ui5.boot.handler.js +1 -1
  34. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.validate.Url.js +1 -1
  35. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.xhr.handler.js +1 -1
  36. package/src/main/js/sap/ushell_abap/bootstrap/evo/boottask.js +6 -12
  37. package/src/main/js/sap/ushell_abap/library.js +3 -3
  38. package/src/main/js/sap/ushell_abap/pbServices/ui2/AllCatalogs.js +1 -1
  39. package/src/main/js/sap/ushell_abap/pbServices/ui2/Bag.js +1 -6
  40. package/src/main/js/sap/ushell_abap/pbServices/ui2/Catalog.js +1 -1
  41. package/src/main/js/sap/ushell_abap/pbServices/ui2/Chip.js +127 -15
  42. package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipDefinition.js +1 -1
  43. package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipInstance.js +14 -6
  44. package/src/main/js/sap/ushell_abap/pbServices/ui2/Error.js +1 -1
  45. package/src/main/js/sap/ushell_abap/pbServices/ui2/Factory.js +1 -1
  46. package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataService.js +1 -1
  47. package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataWrapper.js +1 -1
  48. package/src/main/js/sap/ushell_abap/pbServices/ui2/Page.js +1 -8
  49. package/src/main/js/sap/ushell_abap/pbServices/ui2/PageBuildingService.js +1 -1
  50. package/src/main/js/sap/ushell_abap/pbServices/ui2/PageSet.js +1 -1
  51. package/src/main/js/sap/ushell_abap/pbServices/ui2/RemoteCatalogService.js +1 -1
  52. package/src/main/js/sap/ushell_abap/pbServices/ui2/Utils.js +1 -8
  53. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/actions.js +1 -1
  54. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/bag.js +1 -1
  55. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configuration.js +1 -1
  56. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configurationUi.js +1 -1
  57. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/fullscreen.js +1 -1
  58. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/preview.js +1 -1
  59. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/refresh.js +1 -1
  60. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/search.js +1 -1
  61. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/types.js +1 -1
  62. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/url.js +1 -1
  63. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/visible.js +1 -1
  64. package/src/main/js/sap/ushell_abap/support/plugins/app-infra/AppInfraOnSapNetWeaverSupportPlugin.js +1 -1
  65. package/src/main/js/sap/ushell_abap/ui5appruntime/AppInfoAdapter.js +1 -1
  66. package/ui5.yaml +376 -30
  67. package/src/main/js/sap/ui2/srvc/ODataService.js +0 -267
  68. package/src/main/js/sap/ui2/srvc/ODataWrapper.js +0 -1283
  69. package/src/main/js/sap/ui2/srvc/PageBuildingService.js +0 -1508
  70. package/src/main/js/sap/ui2/srvc/RemoteCatalogService.js +0 -49
  71. package/src/main/js/sap/ui2/srvc/allcatalogs.js +0 -197
  72. package/src/main/js/sap/ui2/srvc/bag.js +0 -711
  73. package/src/main/js/sap/ui2/srvc/catalog.js +0 -946
  74. package/src/main/js/sap/ui2/srvc/chip.js +0 -1035
  75. package/src/main/js/sap/ui2/srvc/chipdefinition.js +0 -228
  76. package/src/main/js/sap/ui2/srvc/chipinstance.js +0 -944
  77. package/src/main/js/sap/ui2/srvc/contracts/actions.js +0 -239
  78. package/src/main/js/sap/ui2/srvc/contracts/bag.js +0 -145
  79. package/src/main/js/sap/ui2/srvc/contracts/configuration.js +0 -161
  80. package/src/main/js/sap/ui2/srvc/contracts/configurationUi.js +0 -326
  81. package/src/main/js/sap/ui2/srvc/contracts/fullscreen.js +0 -69
  82. package/src/main/js/sap/ui2/srvc/contracts/navigation.js +0 -48
  83. package/src/main/js/sap/ui2/srvc/contracts/preview.js +0 -289
  84. package/src/main/js/sap/ui2/srvc/contracts/refresh.js +0 -42
  85. package/src/main/js/sap/ui2/srvc/contracts/search.js +0 -109
  86. package/src/main/js/sap/ui2/srvc/contracts/searchProvider.js +0 -46
  87. package/src/main/js/sap/ui2/srvc/contracts/types.js +0 -9
  88. package/src/main/js/sap/ui2/srvc/contracts/url.js +0 -104
  89. package/src/main/js/sap/ui2/srvc/contracts/visible.js +0 -122
  90. package/src/main/js/sap/ui2/srvc/error.js +0 -54
  91. package/src/main/js/sap/ui2/srvc/factory.js +0 -656
  92. package/src/main/js/sap/ui2/srvc/page.js +0 -934
  93. package/src/main/js/sap/ui2/srvc/pageset.js +0 -466
  94. package/src/main/js/sap/ui2/srvc/utils.js +0 -923
  95. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/navigation.js +0 -50
@@ -1,711 +0,0 @@
1
- // Copyright (c) 2009-2020 SAP SE, All Rights Reserved
2
-
3
- /**
4
- * @fileOverview A wrapper for a property bag loaded from the page building service.
5
- */
6
-
7
- this.sap = this.sap || {};
8
-
9
- (function () {
10
- "use strict";
11
-
12
- // namespace "sap.ui2.srvc" **************************************************
13
- sap.ui2 = sap.ui2 || {};
14
- sap.ui2.srvc = sap.ui2.srvc || {};
15
-
16
- // Only declare the module if jQuery.sap exists. Otherwise we do not even try to require assuming
17
- // that the script has been loaded manually (before SAPUI5).
18
- // Load time branching pattern
19
- var fnRequire = String; // NOP (String exists and is free of side-effects)
20
- if (typeof jQuery === "function" && jQuery.sap) {
21
- jQuery.sap.declare("sap.ui2.srvc.bag");
22
- // avoid fnRequire = jQuery.sap.require as require cannot be spied on afterwards
23
- fnRequire = function () {
24
- jQuery.sap.require.apply(this, arguments);
25
- };
26
- }
27
-
28
- // "public class" ************************************************************
29
-
30
- /**
31
- * Constructs a new representation (wrapper) of the bag with the given
32
- * bag description as loaded from the given factory's page building service.
33
- * A property bag can be associated with a page (see {@link sap.ui2.srvc.Page#getBag}), a
34
- * CHIP instance (see {@link sap.ui2.srvc.ChipInstance#getBag}) or a CHIP
35
- * (see {@link sap.ui2.srvc.Chip#getBag}). Such bags take arbitrary name/value pairs consisting
36
- * of strings.
37
- *
38
- * @param {sap.ui2.srvc.Factory} oFactory
39
- * the factory
40
- * @param {object} oAlterEgo
41
- * the bag data including its (optional) properties as loaded via the page building service
42
- * @param {object} [oParentBag]
43
- * a bag which is asked for properties not found in this bag
44
- * @param {function(sap.ui2.srvc.Bag)} [fnChangeListener]
45
- * (since 1.21) a listener to be called (with this bag as an argument) each time this bag
46
- * changes due to save or reset; the listener is not called in case a backend request fails
47
- * completely
48
- *
49
- * @class
50
- * @since 1.3.0
51
- */
52
- sap.ui2.srvc.Bag = function (oFactory, oAlterEgo, oParentBag, fnChangeListener) {
53
- var oPropertiesByName,
54
- bResetting = false,
55
- bSaving = false,
56
- that = this;
57
-
58
- // BEWARE: constructor code below!
59
-
60
- // "private" methods ---------------------------------------------------------
61
-
62
- /**
63
- * Throws an error if the bag is currently running a <code>reset</code>.
64
- *
65
- * @private
66
- */
67
- function errorIfResetRunning () {
68
- if (bResetting) {
69
- throw new sap.ui2.srvc.Error("The previous reset operation is not finished yet",
70
- "sap.ui2.srvc.Bag");
71
- }
72
- }
73
-
74
- /**
75
- * Throws an error if the bag is currently running a <code>save</code>.
76
- *
77
- * @private
78
- */
79
- function errorIfSaveRunning () {
80
- if (bSaving) {
81
- throw new sap.ui2.srvc.Error("The previous save operation is not finished yet",
82
- "sap.ui2.srvc.Bag");
83
- }
84
- }
85
-
86
- /**
87
- * Fills the <code>oPropertiesByName</code> map based on the properties in the given bag data,
88
- * updating only the given accepted names if applicable.
89
- *
90
- * @param {object} oBagData
91
- * parsed JSON object as returned by the OData service representing this bag
92
- * @param {sap.ui2.srvc.Map} [oAcceptedNames]
93
- * map (used as a "hash set") of accepted names; if missing, all are accepted
94
- * @private
95
- */
96
- function fillPropertyMap (oBagData, oAcceptedNames) {
97
- var aProperties = (oBagData.Properties && oBagData.Properties.results)
98
- || (oBagData.ChipInstanceProperties && oBagData.ChipInstanceProperties.results)
99
- || (oBagData.ChipProperties && oBagData.ChipProperties.results)
100
- || [];
101
-
102
- oPropertiesByName = oPropertiesByName || new sap.ui2.srvc.Map();
103
- aProperties.forEach(function (oPropertyData) {
104
- var sName = oPropertyData.name,
105
- oOldProperty;
106
-
107
- if (!oAcceptedNames || oAcceptedNames.containsKey(sName)) {
108
- oOldProperty = oPropertiesByName.put(sName, oPropertyData);
109
- oPropertyData.$currentValue = oOldProperty
110
- ? oOldProperty.$currentValue // keep current value
111
- : oPropertyData.value;
112
- }
113
- });
114
-
115
- // remove relations
116
- delete oBagData.ChipInstanceProperties;
117
- delete oBagData.ChipProperties;
118
- delete oBagData.Properties;
119
- }
120
-
121
- /**
122
- * Returns the names of all translatable or non-translatable properties (as indicated) of
123
- * this bag, taking the given names from the parent bag into account. Avoids duplicates.
124
- *
125
- * @param {string[]} aNames
126
- * names from parent bag or <code>[]</code>
127
- * @param {boolean} bTranslatable
128
- * whether names of translatable text properties are requested
129
- * @returns {string[]}
130
- * an array containing all names
131
- * @private
132
- */
133
- function getNames (aNames, bTranslatable) {
134
- var oNameSet;
135
-
136
- if (aNames.length === 0) { // no parent names --> no duplicates expected, run faster code
137
- oPropertiesByName.keys().forEach(function (sKey) {
138
- if (bTranslatable === (oPropertiesByName.get(sKey).translatable === "X")) {
139
- aNames.push(sKey);
140
- }
141
- });
142
- return aNames;
143
- }
144
-
145
- // parent names present --> expect duplicates and avoid them with slower code
146
- oNameSet = new sap.ui2.srvc.Map();
147
- aNames.forEach(function (sKey) {
148
- oNameSet.put(sKey);
149
- });
150
- oPropertiesByName.keys().forEach(function (sKey) {
151
- if (bTranslatable === (oPropertiesByName.get(sKey).translatable === "X")) {
152
- oNameSet.put(sKey);
153
- }
154
- });
155
- return oNameSet.keys();
156
- }
157
-
158
- /**
159
- * Returns a mock of a parent page or CHIP instance which contains the exact IDs and nothing
160
- * else.
161
- * @returns {object} a mock of a parent page or CHIP instance
162
- *
163
- * @private
164
- */
165
- function getParentMock () {
166
- // Note: bags at Chip level are read-only and can be ignored here!
167
- if (oAlterEgo.instanceId) {
168
- return { pageId: oAlterEgo.pageId, instanceId: oAlterEgo.instanceId };
169
- }
170
- return { id: oAlterEgo.pageId };
171
- }
172
-
173
- /**
174
- * Sets the value for the given property name. If no such property exists yet, it will be
175
- * created. If <code>setProperty()</code> is called during a running {@link #save()}, the
176
- * property will <i>not</i> be saved immediately. It will only be saved with the next call to
177
- * {@link #save()}.
178
- *
179
- * @param {string} sPropertyName
180
- * the property name (which has to be a string)
181
- * @param {string} sValue
182
- * the value (which has to be a string)
183
- * @param {boolean} bTranslatable
184
- * whether this property is a translatable text property
185
- * @returns {sap.ui2.srvc.Bag}
186
- * this bag
187
- * @throws Error when called while {@link #reset()} is running.
188
- * @private
189
- */
190
- function setProperty (sPropertyName, sValue, bTranslatable) {
191
- var oProperty;
192
-
193
- if (!sPropertyName) {
194
- throw new sap.ui2.srvc.Error("Property name must not be empty", "sap.ui2.srvc.Bag");
195
- }
196
- if (typeof sPropertyName !== "string") {
197
- throw new sap.ui2.srvc.Error("Property name must be a string", "sap.ui2.srvc.Bag");
198
- }
199
- oProperty = oPropertiesByName.get(sPropertyName);
200
- if (oProperty && ((oProperty.translatable === "X") !== bTranslatable)) {
201
- throw new sap.ui2.srvc.Error(
202
- "'" + sPropertyName + "' already exists as a "
203
- + (bTranslatable ? "non-translatable" : "translatable text")
204
- + " property",
205
- "sap.ui2.srvc.Bag"
206
- );
207
- }
208
- if (typeof sValue !== "string") {
209
- throw new sap.ui2.srvc.Error("Property value must be a string", "sap.ui2.srvc.Bag");
210
- }
211
- errorIfResetRunning();
212
-
213
- if (!oProperty) {
214
- oProperty = { name: sPropertyName, translatable: (bTranslatable ? "X" : " ") };
215
- oPropertiesByName.put(sPropertyName, oProperty);
216
- }
217
- oProperty.$currentValue = sValue;
218
- return that;
219
- }
220
-
221
- // "public" methods ----------------------------------------------------------
222
-
223
- /**
224
- * Returns this bag's ID.
225
- *
226
- * @returns {string}
227
- * this bag's ID
228
- * @since 1.3.0
229
- */
230
- this.getId = function () {
231
- return oAlterEgo.id;
232
- };
233
-
234
- /**
235
- * Returns an array containing the names of the (non-translatable) properties contained in this
236
- * bag. In contrast to {@link #getPropertyNames()} the properties of the parent bag are ignored.
237
- * As long as a {@link #reset()} is running,
238
- * the "old" property names are returned.
239
- *
240
- * If {@link #resetProperty()} has been called on a not persisted property its name is not
241
- * contained in the array; for a persisted property it is contained in the array until
242
- * {@link #save()} is called on this bag.
243
- *
244
- * @returns {string[]}
245
- * array of (non-translatable) property names really stored in this bag (not the parent bag)
246
- *
247
- * @see #getOwnTextNames
248
- * @see #getPropertyNames
249
- * @private
250
- */
251
- this.getOwnPropertyNames = function () {
252
- return getNames([], false);
253
- };
254
-
255
- /**
256
- * Returns an array containing the names of the translatable text properties contained in this
257
- * bag. In contrast to {@link #getTextNames()} the text properties of the parent bag are
258
- * ignored. As long as a {@link #reset()} is running, the "old" property names are returned.
259
- * For an array of non-translatable property names see {@link #getPropertyNames}.
260
- *
261
- * @returns {string[]}
262
- * array of translatable text property names really stored in this bag (not the parent bag)
263
- *
264
- * @see #getOwnPropertyNames
265
- * @see #getTextNames
266
- * @private
267
- */
268
- this.getOwnTextNames = function () {
269
- return getNames([], true);
270
- };
271
-
272
- /**
273
- * Returns the property value for the given property name. If no such property exists, the
274
- * given default value is returned.
275
- * As long as a {@link #reset()} is running, "old" values are returned.
276
- *
277
- * @param {string} sPropertyName
278
- * the property name
279
- * @param {string} [sDefaultValue]
280
- * default value used if there is no property with given name
281
- *
282
- * @returns {string}
283
- * the property value
284
- * @throws Error if <code>sPropertyName</code> is a translatable text property name.
285
- * @since 1.3.0
286
- */
287
- this.getProperty = function (sPropertyName, sDefaultValue) {
288
- var oProperty = oPropertiesByName.get(sPropertyName);
289
-
290
- if (oProperty && (oProperty.translatable === "X")) {
291
- throw new sap.ui2.srvc.Error("'" + sPropertyName + "' is a translatable text property",
292
- "sap.ui2.srvc.Bag");
293
- }
294
-
295
- if (oProperty) {
296
- return oProperty.$currentValue;
297
- }
298
- if (oParentBag) {
299
- return oParentBag.getProperty(sPropertyName, sDefaultValue);
300
- }
301
- return sDefaultValue;
302
- };
303
-
304
- /**
305
- * Returns an array containing the names of the (non-translatable) properties contained in this
306
- * bag. As long as a {@link #reset()} is running, the "old" property names are returned.
307
- * For an array of translatable text property names see {@link #getTextNames}.
308
- *
309
- * If {@link #resetProperty()} has been called on a not persisted property its name is not
310
- * contained in the array; for a persisted property it is contained in the array until
311
- * {@link #save()} is called on this bag.
312
- *
313
- * @returns {string[]}
314
- * array of (non-translatable) property names
315
- * @since 1.3.0
316
- *
317
- * @see #getTextNames
318
- */
319
- this.getPropertyNames = function () {
320
- var aPropertyNames = oParentBag ? oParentBag.getPropertyNames() : [];
321
-
322
- return getNames(aPropertyNames, false);
323
- };
324
-
325
- /**
326
- * Returns the translatable text for the given text property name. If no such text property
327
- * exists, <code>sTextName</code> is returned again. As long as a {@link #reset()} is running,
328
- * "old" texts are returned.
329
- *
330
- * @param {string} sTextName
331
- * the text property name
332
- * @returns {string}
333
- * the translatable text
334
- * @throws Error if <code>sTextName</code> is an ordinary (non-translatable) property name.
335
- * @since 1.17.1
336
- */
337
- this.getText = function (sTextName) {
338
- var oProperty = oPropertiesByName.get(sTextName);
339
-
340
- if (oProperty && (oProperty.translatable !== "X")) {
341
- throw new sap.ui2.srvc.Error(
342
- "'" + sTextName + "' is a non-translatable property",
343
- "sap.ui2.srvc.Bag"
344
- );
345
- }
346
-
347
- if (oProperty) {
348
- return oProperty.$currentValue;
349
- }
350
- if (oParentBag) {
351
- return oParentBag.getText(sTextName);
352
- }
353
- return sTextName;
354
- };
355
-
356
- /**
357
- * Returns an array containing the names of the translatable text properties contained in this
358
- * bag. As long as a {@link #reset()} is running, the "old" property names are returned.
359
- * For an array of non-translatable property names see {@link #getPropertyNames}.
360
- *
361
- * @returns {string[]}
362
- * array of translatable text property names
363
- * @since 1.17.1
364
- *
365
- * @see #getPropertyNames
366
- */
367
- this.getTextNames = function () {
368
- var aTextNames = oParentBag ? oParentBag.getTextNames() : [];
369
-
370
- return getNames(aTextNames, true);
371
- };
372
-
373
- /**
374
- * Discards all modified properties, deletes this bag with all its properties and reloads the
375
- * bag via the factory given in the constructor. If the factory's page building service offers
376
- * different layers (like <code>sap.ui2.srvc.PageBuildingService</code>, calling them
377
- * <i>scopes</i>), the values from a lower layer will become visible.
378
- * <p>
379
- * This is an asynchronous operation. If the bag is reset successfully, the success
380
- * handler is called. If there is an error while resetting the bag, all old values are kept
381
- * and the error handler is called.
382
- *
383
- * @param {function ()} fnSuccess
384
- * no-args success handler
385
- * @param {function (string, object=)} [fnError]
386
- * error handler taking an error message and, since version 1.28.6, an
387
- * optional object containing the complete error information as delivered
388
- * by the ODataService. See fnFailure parameter of {@link sap.ui2.srvc.ODataWrapper#onError}
389
- * for more details.
390
- * If fnError is not given, the default error handler from the factory's
391
- * page building service is called.
392
- * @throws Error when called while {@link #save()} or a previous <code>reset()</code> is
393
- * running.
394
- * @since 1.3.0
395
- */
396
- this.reset = function (fnSuccess, fnError) {
397
- var oParent = getParentMock(),
398
- oPbs = oFactory.getPageBuildingService();
399
-
400
- function onReadSuccess (oBagData) {
401
- bResetting = false;
402
-
403
- oAlterEgo = oBagData;
404
- oPropertiesByName = undefined;
405
- fillPropertyMap(oAlterEgo);
406
- if (fnChangeListener) {
407
- fnChangeListener(that);
408
- }
409
- fnSuccess();
410
- }
411
-
412
- if (typeof fnSuccess !== "function") {
413
- throw new sap.ui2.srvc.Error("Missing success handler", "sap.ui2.srvc.Bag");
414
- }
415
-
416
- errorIfSaveRunning();
417
- errorIfResetRunning();
418
- bResetting = true;
419
- fnError = fnError || oPbs.getDefaultErrorHandler();
420
-
421
- if (oAlterEgo.$tmp) {
422
- // if bag is not yet persisted do not call delete and read
423
- sap.ui2.srvc.call(onReadSuccess.bind(null, oAlterEgo), fnError, true);
424
- return;
425
- }
426
-
427
- oPbs.deleteBag(oParent, oAlterEgo.id, function () {
428
- oAlterEgo.$tmp = true; // TODO not yet part of a test
429
- // if bag cannot be read because there is no bag in lower layer success handler has to be
430
- // called; oAlterEgo is passed because success handler expects oData parameter and
431
- // oAlterEgo contains required information for the bag (like page and name) and no
432
- // properties (have been deleted after property map has been filled) --> property map
433
- // is cleared in success handler and we get an empty bag
434
- oPbs.readBag(oParent, oAlterEgo.id, onReadSuccess, onReadSuccess.bind(null, oAlterEgo));
435
- }, function () {
436
- // deleteBag failed
437
- bResetting = false;
438
-
439
- // NOTE: call error handler with any arguments passed in this wrapper
440
- fnError.apply(null, arguments);
441
- });
442
- };
443
-
444
- /**
445
- * Deletes the property with the given name, no matter if it is translatable or not. If no such
446
- * property exists, nothing happens.
447
- * <p>
448
- * Otherwise, the property value is considered to be <code>undefined</code> until a
449
- * {@link #save} operation has succeeded. Note how this <code>undefined</code> value is treated
450
- * differently by {@link #getProperty} and {@link #getText}!
451
- * <p>
452
- * <b>BEWARE:</b> This transient <code>undefined</code> value can be wrong due to a number of
453
- * reasons, including different layers of storage (like
454
- * <code>sap.ui2.srvc.PageBuildingService</code>, calling them <i>scopes</i>) or parent bags
455
- * (in case of catalog pages), which cannot be taken properly into account until the next time
456
- * a {@link #save} operation succeeds!
457
- * <p>
458
- * After a successful {@link #save} operation, a deleted property may reappear from a lower
459
- * layer of storage or from a parent bag. If you need to overwrite such values, use
460
- * {@link #setProperty} instead!
461
- * <p>
462
- * If <code>resetProperty()</code> is called during a running {@link #save}, the
463
- * property will <i>not</i> be saved immediately. It will only be saved with the next call to
464
- * {@link #save}.
465
- *
466
- * @param {string} sPropertyName
467
- * the property name (which has to be a string)
468
- * @returns {sap.ui2.srvc.Bag}
469
- * this bag
470
- * @throws Error when called while {@link #reset} is running.
471
- *
472
- * @since 1.17.1
473
- */
474
- this.resetProperty = function (sPropertyName) {
475
- var oProperty;
476
-
477
- oProperty = oPropertiesByName.get(sPropertyName);
478
- if (oProperty) {
479
- oProperty.$currentValue = undefined; //undefined value is marker to delete property on save
480
- if (!Object.prototype.hasOwnProperty.call(oProperty, "value")) { // no persisted value
481
- oPropertiesByName.remove(sPropertyName);
482
- }
483
- }
484
- return this;
485
- };
486
-
487
- /**
488
- * Saves this bag with all modified properties. This is an asynchronous operation.
489
- * If all modified properties have been saved, the success handler is called. If one or more
490
- * properties cannot be saved, the error handler is called. This error handler reports which
491
- * properties could not be saved and the corresponding error messages. The properties remain
492
- * valid and the bag tries to save them again with the next call to <code>save()</code>.
493
- *
494
- * <p>
495
- * If <code>save()</code> is called when there is no modified property, the function calls the
496
- * success handler asynchronously without any further activity.
497
- *
498
- * @param {function ()} fnSuccess
499
- * no-args success handler. Errors thrown in this function will be reported to the page
500
- * building service's default error handler (not to <code>fnError</code> since the signature
501
- * does not fit)
502
- * @param {function (map<string, string>, map<string, object>)} fnError
503
- * error handler taking two maps, each mapping individual property names
504
- * to error message and complete error information respectively. Since
505
- * version 1.28.6, the second parameter is always returned,
506
- * but a property name in that object may map to
507
- * undefined values in case an error object containing the complete error
508
- * information is not available.<br />
509
- * For more details about the structure of the error information object
510
- * see {@link sap.ui2.srvc.ODataWrapper#onError}
511
- * @throws Error when called while {@link #reset()} or a previous <code>save()</code> is
512
- * running.
513
- * @since 1.3.0
514
- */
515
- this.save = function (fnSuccess, fnError) {
516
- var iNumberOfRequests = 0,
517
- oResetPropertyNames = new sap.ui2.srvc.Map(), // used as a "hash set"
518
- mMessagesByName = {},
519
- mErrorResponseByName = {},
520
- oParentMock = getParentMock(),
521
- oPbs = oFactory.getPageBuildingService();
522
-
523
- if (typeof fnSuccess !== "function") {
524
- throw new sap.ui2.srvc.Error("Missing success handler", "sap.ui2.srvc.Bag");
525
- }
526
- if (typeof fnError !== "function") {
527
- throw new sap.ui2.srvc.Error("Missing error handler", "sap.ui2.srvc.Bag");
528
- }
529
- errorIfSaveRunning();
530
- errorIfResetRunning();
531
-
532
- oPbs.openBatchQueue();
533
-
534
- oPropertiesByName.keys().forEach(function (sName) {
535
- var oUpdatedProperty,
536
- oProperty = oPropertiesByName.get(sName);
537
-
538
- function onError (sMessage, oErrorInformation) {
539
- mMessagesByName[sName] = sMessage;
540
- mErrorResponseByName[sName] = oErrorInformation;
541
- }
542
-
543
- if (oProperty.$currentValue !== oProperty.value) {
544
- iNumberOfRequests += 1;
545
- if (Object.prototype.hasOwnProperty.call(oProperty, "value")) {
546
- if (oProperty.$currentValue === undefined) {
547
- // reset property: delete it and re-read bag below
548
- oResetPropertyNames.put(sName);
549
- oPbs.deleteProperty(oProperty,
550
- function () {
551
- if (oProperty.$currentValue === undefined) { // not re-created via API
552
- oPropertiesByName.remove(sName);
553
- } else {
554
- delete oProperty.value; // not persisted anymore
555
- }
556
- }, onError);
557
- } else {
558
- // changed property: update it
559
- oUpdatedProperty = JSON.parse(JSON.stringify(oProperty));
560
- oUpdatedProperty.value = oProperty.$currentValue; // 1st update clone
561
- oPbs.updateProperty(oUpdatedProperty,
562
- function () {
563
- oProperty.value = oUpdatedProperty.value; // on success, update original
564
- }, onError);
565
- }
566
- } else {
567
- // new property: create it
568
- oPbs.createProperty(oParentMock, oAlterEgo.id, sName,
569
- oProperty.$currentValue, oProperty.translatable,
570
- function (oNewProperty) {
571
- // save alter ego because of __metadata needed for later updates
572
- oNewProperty.$currentValue = oProperty.$currentValue; // keep current value
573
- oPropertiesByName.put(sName, oNewProperty);
574
- }, onError);
575
- }
576
- }
577
- });
578
-
579
- if (oResetPropertyNames.keys().length) {
580
- // some properties were reset: re-read bag
581
- oPbs.readBag(oParentMock, oAlterEgo.id, function (oBagData) {
582
- fillPropertyMap(oBagData, oResetPropertyNames);
583
- }); // omit error handler, default one must be used here!
584
- }
585
-
586
- bSaving = true;
587
- // TODO allow to save empty bags (as they can also be the result of deleting all properties)
588
- oPbs.submitBatchQueue(function () {
589
- bSaving = false;
590
- if (fnChangeListener && iNumberOfRequests > Object.keys(mMessagesByName).length) {
591
- // at least one request must succeed
592
- fnChangeListener(that);
593
- }
594
- if (Object.keys(mMessagesByName).length > 0) {
595
- fnError(mMessagesByName, mErrorResponseByName);
596
- } else {
597
- oAlterEgo.$tmp = false;
598
- fnSuccess(); // Note: try/catch done by submitBatchQueue()!
599
- }
600
- });
601
- };
602
-
603
- /**
604
- * Sets the value for the given property name. If no such property exists yet, it will be
605
- * created. If <code>setProperty()</code> is called during a running {@link #save()}, the
606
- * property will <i>not</i> be saved immediately. It will only be saved with the next call to
607
- * {@link #save()}.
608
- *
609
- * @param {string} sPropertyName
610
- * the property name (which has to be a string)
611
- * @param {string} sValue
612
- * the value (which has to be a string)
613
- * @returns {sap.ui2.srvc.Bag}
614
- * this bag
615
- * @throws Error when called while {@link #reset()} is running.
616
- * @throws Error when called with a property name which is not of type string or the empty
617
- * string
618
- * @since 1.3.0
619
- */
620
- this.setProperty = function (sPropertyName, sValue) {
621
- return setProperty(sPropertyName, sValue, false);
622
- };
623
-
624
- /**
625
- * Sets the translatable text for the given text property name. If no such text property exists
626
- * yet, it will be created as a translatable text property. Ordinary properties and
627
- * translatable text properties share a common namespace! Once a property has been created,
628
- * it is either translatable or not and this cannot be changed by the corresponding setters.
629
- * You can only call <code>reset()</code> and start all over.
630
- * <p>
631
- * Note: You can create or modify translatable text properties only if the session language is
632
- * the same as the page's original language (see
633
- * {@link sap.ui2.srvc.Page#getOriginalLanguage}).
634
- * Also note that handling of translatable texts depends on the layer used. In some layers the
635
- * original language is important; in others it does not matter. In the latter case the empty
636
- * string (<code>""</code>) is returned, which indicates that the user is allowed to edit the
637
- * translatable texts in any language.
638
- * <p>
639
- * If <code>setText()</code> is called during a running {@link #save()}, the text property will
640
- * <i>not</i> be saved immediately. It will only be saved with the next call to {@link #save()}.
641
- *
642
- * @param {string} sTextName
643
- * the text property name (must not be empty)
644
- * @param {string} sText
645
- * the translatable text (may be empty)
646
- * @returns {sap.ui2.srvc.Bag}
647
- * this bag
648
- * @throws Error when called while {@link #reset()} is running or if an ordinary
649
- * (non-translatable) property with the same name already exists.
650
- * @since 1.17.1
651
- *
652
- * @see sap.ui2.srvc.Page#getOriginalLanguage
653
- * @see chip.bag.getOriginalLanguage
654
- */
655
- this.setText = function (sTextName, sText) {
656
- return setProperty(sTextName, sText, true);
657
- };
658
-
659
- /**
660
- * Returns this bag's string representation.
661
- *
662
- * @param {boolean} [bVerbose=false]
663
- * whether to show all properties
664
- * @returns {string}
665
- * this bag's string representation
666
- * @since 1.3.0
667
- */
668
- this.toString = function (bVerbose) {
669
- var aResult = ['sap.ui2.srvc.Bag({id:"', oAlterEgo.id,
670
- '",pageId:"', oAlterEgo.pageId
671
- ];
672
- if (oAlterEgo.instanceId) {
673
- aResult.push('",instanceId:"', oAlterEgo.instanceId);
674
- }
675
- aResult.push('"');
676
- if (bVerbose) {
677
- aResult.push(",oAlterEgo:", JSON.stringify(oAlterEgo));
678
- aResult.push(",oPropertiesByName:", oPropertiesByName.toString());
679
- aResult.push(",bResetting:", bResetting);
680
- aResult.push(",bSaving:", bSaving);
681
- }
682
- aResult.push("})");
683
- return aResult.join("");
684
- };
685
-
686
- /**
687
- * Replace all properties in this bag with given raw bag data.
688
- *
689
- * @param {object} oBagData
690
- * parsed JSON object as returned by the OData service representing this bag
691
- * @throws Error when called with bag data which does not fit to this bag.
692
- * @private
693
- */
694
- this.update = function (oBagData) {
695
- if (!oBagData || oAlterEgo.id !== oBagData.id) {
696
- throw new sap.ui2.srvc.Error("Bag data belongs to another bag",
697
- "sap.ui2.srvc.Bag");
698
- }
699
- // TODO: further tests for other key properties
700
- oPropertiesByName = undefined;
701
- fillPropertyMap(oBagData);
702
- };
703
-
704
- // constructor code -------------------------------------------------------
705
- if (!sap.ui2.srvc.Map) {
706
- fnRequire("sap.ui2.srvc.utils");
707
- }
708
- fillPropertyMap(oAlterEgo);
709
- jQuery.sap.log.debug("Created: " + this, null, "sap.ui2.srvc.Bag");
710
- };
711
- }());