@openui5/sap.ui.documentation 1.120.10 → 1.121.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 (103) hide show
  1. package/.reuse/dep5 +23 -21
  2. package/THIRDPARTY.txt +6 -43
  3. package/package.json +7 -7
  4. package/src/sap/ui/documentation/.library +3 -9
  5. package/src/sap/ui/documentation/DemoAppsCardHeader.js +62 -0
  6. package/src/sap/ui/documentation/DemokitTreeItem.js +1 -0
  7. package/src/sap/ui/documentation/DemokitTreeItemRenderer.js +20 -13
  8. package/src/sap/ui/documentation/ParamText.js +2 -1
  9. package/src/sap/ui/documentation/library.js +23 -10
  10. package/src/sap/ui/documentation/messagebundle.properties +20 -20
  11. package/src/sap/ui/documentation/messagebundle_ar.properties +10 -10
  12. package/src/sap/ui/documentation/messagebundle_bg.properties +10 -10
  13. package/src/sap/ui/documentation/messagebundle_ca.properties +10 -10
  14. package/src/sap/ui/documentation/messagebundle_cnr.properties +10 -10
  15. package/src/sap/ui/documentation/messagebundle_cs.properties +10 -10
  16. package/src/sap/ui/documentation/messagebundle_cy.properties +10 -10
  17. package/src/sap/ui/documentation/messagebundle_da.properties +12 -12
  18. package/src/sap/ui/documentation/messagebundle_de.properties +16 -16
  19. package/src/sap/ui/documentation/messagebundle_el.properties +10 -10
  20. package/src/sap/ui/documentation/messagebundle_en.properties +398 -10
  21. package/src/sap/ui/documentation/messagebundle_en_GB.properties +10 -10
  22. package/src/sap/ui/documentation/messagebundle_en_US_sappsd.properties +2 -2
  23. package/src/sap/ui/documentation/messagebundle_en_US_saprigi.properties +10 -10
  24. package/src/sap/ui/documentation/messagebundle_en_US_saptrc.properties +2 -2
  25. package/src/sap/ui/documentation/messagebundle_es.properties +11 -11
  26. package/src/sap/ui/documentation/messagebundle_es_MX.properties +10 -10
  27. package/src/sap/ui/documentation/messagebundle_et.properties +10 -10
  28. package/src/sap/ui/documentation/messagebundle_fi.properties +10 -10
  29. package/src/sap/ui/documentation/messagebundle_fr.properties +10 -10
  30. package/src/sap/ui/documentation/messagebundle_fr_CA.properties +10 -10
  31. package/src/sap/ui/documentation/messagebundle_hi.properties +10 -10
  32. package/src/sap/ui/documentation/messagebundle_hr.properties +11 -11
  33. package/src/sap/ui/documentation/messagebundle_hu.properties +10 -10
  34. package/src/sap/ui/documentation/messagebundle_id.properties +10 -10
  35. package/src/sap/ui/documentation/messagebundle_it.properties +11 -11
  36. package/src/sap/ui/documentation/messagebundle_iw.properties +10 -10
  37. package/src/sap/ui/documentation/messagebundle_ja.properties +10 -10
  38. package/src/sap/ui/documentation/messagebundle_kk.properties +10 -10
  39. package/src/sap/ui/documentation/messagebundle_ko.properties +11 -11
  40. package/src/sap/ui/documentation/messagebundle_lt.properties +10 -10
  41. package/src/sap/ui/documentation/messagebundle_lv.properties +10 -10
  42. package/src/sap/ui/documentation/messagebundle_mk.properties +15 -15
  43. package/src/sap/ui/documentation/messagebundle_ms.properties +10 -10
  44. package/src/sap/ui/documentation/messagebundle_nl.properties +10 -10
  45. package/src/sap/ui/documentation/messagebundle_no.properties +10 -10
  46. package/src/sap/ui/documentation/messagebundle_pl.properties +10 -10
  47. package/src/sap/ui/documentation/messagebundle_pt.properties +10 -10
  48. package/src/sap/ui/documentation/messagebundle_pt_PT.properties +10 -10
  49. package/src/sap/ui/documentation/messagebundle_ro.properties +10 -10
  50. package/src/sap/ui/documentation/messagebundle_ru.properties +12 -12
  51. package/src/sap/ui/documentation/messagebundle_sh.properties +10 -10
  52. package/src/sap/ui/documentation/messagebundle_sk.properties +10 -10
  53. package/src/sap/ui/documentation/messagebundle_sl.properties +10 -10
  54. package/src/sap/ui/documentation/messagebundle_sr.properties +10 -10
  55. package/src/sap/ui/documentation/messagebundle_sv.properties +10 -10
  56. package/src/sap/ui/documentation/messagebundle_th.properties +10 -10
  57. package/src/sap/ui/documentation/messagebundle_tr.properties +10 -10
  58. package/src/sap/ui/documentation/messagebundle_uk.properties +10 -10
  59. package/src/sap/ui/documentation/messagebundle_vi.properties +10 -10
  60. package/src/sap/ui/documentation/messagebundle_zh_CN.properties +10 -10
  61. package/src/sap/ui/documentation/messagebundle_zh_TW.properties +10 -10
  62. package/src/sap/ui/documentation/sdk/controller/ApiMaster.controller.js +40 -30
  63. package/src/sap/ui/documentation/sdk/controller/App.controller.js +20 -12
  64. package/src/sap/ui/documentation/sdk/controller/ControlsMaster.controller.js +3 -3
  65. package/src/sap/ui/documentation/sdk/controller/DemoApps.controller.js +208 -459
  66. package/src/sap/ui/documentation/sdk/controller/LiveEditor.controller.js +9 -8
  67. package/src/sap/ui/documentation/sdk/controller/News.controller.js +3 -3
  68. package/src/sap/ui/documentation/sdk/controller/ReleaseNotes.controller.js +13 -12
  69. package/src/sap/ui/documentation/sdk/controller/Sample.controller.js +24 -18
  70. package/src/sap/ui/documentation/sdk/controller/SubApiDetail.controller.js +18 -1
  71. package/src/sap/ui/documentation/sdk/controller/util/APIInfo.js +3 -1
  72. package/src/sap/ui/documentation/sdk/controller/util/ControlsInfo.js +2 -1
  73. package/src/sap/ui/documentation/sdk/controller/util/NewsInfo.js +3 -3
  74. package/src/sap/ui/documentation/sdk/controller/util/ThemePicker.js +5 -3
  75. package/src/sap/ui/documentation/sdk/controller/util/URLUtil.js +16 -16
  76. package/src/sap/ui/documentation/sdk/cookieSettingsDialog/controller/CookieSettingsDialog.controller.js +8 -8
  77. package/src/sap/ui/documentation/sdk/images/DemoApps_intro_card.svg +8 -0
  78. package/src/sap/ui/documentation/sdk/index.js +1 -1
  79. package/src/sap/ui/documentation/sdk/model/formatter.js +323 -291
  80. package/src/sap/ui/documentation/sdk/model/libraryData.js +9 -26
  81. package/src/sap/ui/documentation/sdk/thirdparty/highlight.js/highlight.js +14905 -8737
  82. package/src/sap/ui/documentation/sdk/util/DocumentationRouter.js +6 -3
  83. package/src/sap/ui/documentation/sdk/view/AboutDialog.fragment.xml +1 -1
  84. package/src/sap/ui/documentation/sdk/view/ApiMaster.view.xml +31 -28
  85. package/src/sap/ui/documentation/sdk/view/App.view.xml +5 -4
  86. package/src/sap/ui/documentation/sdk/view/DemoApps.view.xml +189 -141
  87. package/src/sap/ui/documentation/sdk/view/SubApiDetail.view.xml +34 -30
  88. package/src/sap/ui/documentation/sdk/view/Tools.view.xml +2 -2
  89. package/src/sap/ui/documentation/themes/base/DemoApps.less +180 -0
  90. package/src/sap/ui/documentation/themes/base/DemokitTreeItem.less +20 -0
  91. package/src/sap/ui/documentation/themes/base/Documentation.less +6 -8
  92. package/src/sap/ui/documentation/themes/base/Search.less +1 -1
  93. package/src/sap/ui/documentation/themes/base/library.source.less +3 -2
  94. package/src/sap/ui/documentation/themes/sap_horizon_hcb/DemoApps.less +11 -0
  95. package/src/sap/ui/documentation/themes/sap_horizon_hcb/library.source.less +3 -1
  96. package/src/sap/ui/documentation/themes/sap_horizon_hcw/DemoApps.less +30 -0
  97. package/src/sap/ui/documentation/themes/sap_horizon_hcw/library.source.less +3 -1
  98. package/LICENSES/BSD-2-Clause.txt +0 -22
  99. package/src/sap/ui/documentation/sdk/images/DemoApps_M_and_L_cropped.jpg +0 -0
  100. package/src/sap/ui/documentation/sdk/images/DemoApps_S_cropped.jpg +0 -0
  101. package/src/sap/ui/documentation/sdk/thirdparty/esprima.js +0 -3756
  102. package/src/sap/ui/documentation/sdk/view/BlockLayoutCell.fragment.xml +0 -56
  103. package/src/sap/ui/documentation/sdk/view/BlockLayoutTeaserCell.fragment.xml +0 -60
@@ -5,468 +5,217 @@
5
5
  */
6
6
 
7
7
  sap.ui.define([
8
- "sap/base/Log",
9
- "sap/m/MessageBox",
10
- "sap/m/MessageToast",
11
- "sap/ui/Device",
12
- "sap/ui/VersionInfo",
13
- "sap/ui/documentation/sdk/controller/BaseController",
14
- "sap/ui/documentation/sdk/controller/util/ResourceDownloadUtil",
15
- "sap/ui/documentation/sdk/model/formatter",
16
- 'sap/ui/documentation/sdk/model/libraryData',
17
- "sap/ui/model/Filter",
18
- "sap/ui/model/FilterOperator",
19
- "sap/ui/model/json/JSONModel",
20
- "sap/ui/model/resource/ResourceModel",
21
- "sap/ui/thirdparty/jquery",
22
- "sap/ui/core/Fragment"
23
- ], function(Log, MessageBox, MessageToast, Device, VersionInfo, BaseController, ResourceDownloadUtil,
24
- formatter, libraryData, Filter, FilterOperator, JSONModel, ResourceModel, jQuery, Fragment) {
25
- "use strict";
26
-
27
- return BaseController.extend("sap.ui.documentation.sdk.controller.DemoApps", {
28
-
29
- formatter: formatter,
30
-
31
- /**
32
- * Called when the controller is instantiated.
33
- * @public
34
- */
35
- onInit: function () {
36
- var oModel = new JSONModel(),
37
- oMessageBundle = new ResourceModel({
38
- bundleName: "sap.ui.documentation.messagebundle"
39
- });
40
-
41
-
42
- // load demo app metadata from docuindex of all available libraries
43
- libraryData.fillJSONModel(oModel)
44
- .then(function () {
45
- return this.loadDemoAppsCellFragments(oModel);
46
- }.bind(this))
47
- .then(function (oFragments) {
48
- this._cellFragments = oFragments;
49
- this.setModel(oModel);
50
- }.bind(this));
51
-
52
- this.getView().setModel(oMessageBundle, "i18n");
53
-
54
- this.setModel(new JSONModel({
55
- demoAppsHomeLink: "topic/a3ab54ecf7ac493b91904beb2095d208"
56
- // etc
57
- }), "newWindowLinks");
58
-
59
- this.getRouter().getRoute("demoapps").attachPatternMatched(this._onMatched, this);
60
-
61
- VersionInfo.load().then(function (oVersionInfo) {
62
- var oViewModel = new JSONModel({
63
- isOpenUI5: oVersionInfo && oVersionInfo.gav && /openui5/i.test(oVersionInfo.gav)
64
- });
65
- this.getView().setModel(oViewModel, "appView");
66
- }.bind(this));
67
-
68
- // manually call the handler once at startup as device API won't do this for us
69
- this._onOrientationChange({
70
- landscape: Device.orientation.landscape
71
- });
72
- this._onResize({
73
- name: (Device.resize.width <= 600 ? "Phone" : "NoPhone")
74
- });
75
- },
76
-
77
- /**
78
- * Called before the view is rendered.
79
- * @public
80
- */
81
- onBeforeRendering: function() {
82
- this._deregisterOrientationChange();
83
- },
84
-
85
- /**
86
- * Called after the view is rendered.
87
- * @public
88
- */
89
- onAfterRendering: function() {
90
- this._registerOrientationChange();
91
- this._registerResize();
92
- },
93
-
94
- /**
95
- * Called when the controller is destroyed.
96
- * @public
97
- */
98
- onExit: function() {
99
- this._deregisterOrientationChange();
100
- this._deregisterResize();
101
- },
102
-
103
- /**
104
- * Registers an event listener on device orientation change
105
- * @private
106
- */
107
- _registerOrientationChange: function () {
108
- Device.orientation.attachHandler(this._onOrientationChange, this);
109
- },
110
-
111
- /**
112
- * Deregisters the event listener for device orientation change
113
- * @private
114
- */
115
- _deregisterOrientationChange: function () {
116
- Device.orientation.detachHandler(this._onOrientationChange, this);
117
- },
118
-
119
- /**
120
- * Registers an event listener on device resize
121
- * @private
122
- */
123
- _registerResize: function () {
124
- Device.media.attachHandler(this._onResize, this);
125
- },
126
-
127
- /**
128
- * Deregisters the event listener for device resize
129
- * @private
130
- */
131
- _deregisterResize: function () {
132
- Device.media.detachHandler(this._onResize, this);
133
- },
134
-
135
- /**
136
- * Switches the maximum height of the phone image for optimal display in landscape mode
137
- * @param {sap.ui.base.Event} oEvent Device orientation change event
138
- * @private
139
- */
140
- _onOrientationChange: function(oEvent) {
141
- this.byId("phoneImage").toggleStyleClass("phoneHeaderImageLandscape", oEvent.landscape);
142
- },
143
-
144
- /**
145
- * Switches the image to phone and hides the download icon when decreasing the window size
146
- * @param {sap.ui.base.Event} oEvent Device media change event
147
- * @private
148
- */
149
- _onResize: function(oEvent) {
150
- this.byId("phoneImage").setVisible(oEvent.name === "Phone");
151
- this.byId("desktopImage").setVisible(oEvent.name !== "Phone");
152
- this.byId("phoneImage").toggleStyleClass("phoneHeaderImageDesktop", oEvent.name === "Phone");
153
- },
154
-
155
- /**
156
- * Handles "demoapps" routing
157
- * @function
158
- * @private
159
- */
160
- _onMatched: function () {
161
- try {
162
- this.hideMasterSide();
163
- } catch (e) {
164
- // try-catch due to a bug in UI5 SplitApp, CL 1898264 should fix it
165
- Log.error(e);
166
- }
167
- },
168
-
169
- /**
170
- * Opens the download dialog
171
- * @param {sap.ui.base.Event} oEvent the Button press event
172
- * @public
173
- */
174
- onDownloadButtonPress: function (oEvent) {
175
- var oDownloadDialog = this.byId("downloadDialog"),
176
- oDownloadDialogList = this.byId("downloadDialogList");
177
- this._oDownloadButton = oEvent.getSource();
178
-
179
- oDownloadDialogList.getBinding("items").filter([]);
180
- oDownloadDialog.open();
181
- },
182
-
183
- /**
184
- * Opens more information about Demo Apps
185
- * @public
186
- */
187
- onReadMoreButtonPress: function () {
188
- var sLink = formatter.formatHttpHrefForNewWindow(this.getModel("newWindowLinks").getProperty("/demoAppsHomeLink"));
189
- window.open(sLink, "_blank");
190
- },
191
-
192
- /**
193
- * Filters the download dialog
194
- * @param {sap.ui.base.Event} oEvent the SearchField liveChange event
195
- * @public
196
- */
197
- onSearch: function (oEvent) {
198
- var oDownloadDialogList = this.byId("downloadDialogList"),
199
- sQuery = oEvent.getParameter("newValue");
200
-
201
- oDownloadDialogList.getBinding("items").filter([
202
- new Filter("name", FilterOperator.Contains, sQuery)
203
- ]);
204
- },
205
-
206
- onCloseDialog: function() {
207
- var oDownloadDialog = this.byId("downloadDialog"),
208
- oDownloadDialogSearch = this.byId("downloadDialogSearch");
209
-
210
- oDownloadDialog.close();
211
- oDownloadDialogSearch.setValue("");
212
- },
213
-
214
- /**
215
- * Downloads a demo app
216
- * @param {sap.ui.base.Event} oEvent the Button press event
217
- * @public
218
- */
219
- onDownloadPress: function (oEvent) {
220
- var oSelectedItem = oEvent.getParameters().selectedItem,
221
- oListItem = oSelectedItem ? oSelectedItem : oEvent.getSource().getParent();
222
-
223
- this._oDownloadButton.setBusy(true);
224
- sap.ui.require([
225
- "sap/ui/core/util/File",
226
- "sap/ui/thirdparty/jszip"
227
- ], function (File, JSZip) {
228
- var oZipFile = new JSZip();
229
-
230
- // load the config file from the custom data attached to the list item
231
- jQuery.getJSON(oListItem.data("config"), function (oConfig) {
232
- var aFiles = oConfig.files,
233
- aPromises = [],
234
- aFails = [];
235
-
236
- // add extra download files
237
- aFiles.forEach(function(sFilePath) {
238
- var oPromise = ResourceDownloadUtil.fetch(oConfig.cwd + sFilePath);
239
-
240
- oPromise.then(function (oContent) {
241
- if (oContent.errorMessage) {
242
- // promise gets resolved in error case since Promise.all will not wait for all fails
243
- aFails.push(oContent.errorMessage);
244
- } else {
245
- // exclude relative paths outside of the app root (e.g. common helpers, images, ...)
246
- if (!sFilePath.startsWith("../")) {
247
- oZipFile.file(sFilePath, oContent, { base64: false, binary: true });
248
- }
249
- }
250
- });
251
- aPromises.push(oPromise);
252
- });
253
-
254
- // add generic license file
255
- var sUrl = sap.ui.require.toUrl("LICENSE.txt").replace("resources/", "");
256
- var oLicensePromise = ResourceDownloadUtil.fetch(sUrl);
257
- var oLicensePromiseWrapper = new Promise(function(resolve, reject) {
258
- oLicensePromise.then(function (oContent) {
259
- oZipFile.file("LICENSE.txt", oContent);
260
- resolve();
261
- }).catch(function() {
262
- // LICENSE.txt not available in SAPUI5, continue without it
263
- resolve();
264
- });
265
- });
266
-
267
- aPromises.push(oLicensePromiseWrapper);
268
-
269
- Promise.all(aPromises).then(function () {
270
- // collect errors and show them
271
- if (aFails.length) {
272
- var sCompleteErrorMessage = aFails.reduce(function (sErrorMessage, sError) {
273
- return sErrorMessage + sError + "\n";
274
- }, "Could not locate the following download files:\n");
275
- this._handleError(sCompleteErrorMessage);
276
- }
277
-
278
- // show success message
279
- this._oDownloadButton.setBusy(false);
280
- MessageToast.show("Downloading for app \"" + oListItem.getLabel() + "\" has been started");
281
-
282
- // still make the available files ready for download
283
- var oContent = oZipFile.generate({type:"blob"});
284
- this._createArchive(File, oContent, oListItem.getLabel());
285
- }.bind(this));
286
- }.bind(this));
8
+ "sap/base/Log",
9
+ "sap/m/MessageToast",
10
+ "sap/m/MessageBox",
11
+ "sap/ui/documentation/sdk/controller/BaseController",
12
+ "sap/ui/documentation/sdk/controller/util/ResourceDownloadUtil",
13
+ "sap/ui/documentation/sdk/model/formatter",
14
+ "sap/ui/documentation/sdk/model/libraryData",
15
+ "sap/ui/model/json/JSONModel",
16
+ "sap/ui/core/util/File",
17
+ "sap/ui/thirdparty/jszip",
18
+ "sap/ui/util/openWindow"
19
+ ], function (Log, MessageToast, MessageBox, BaseController, ResourceDownloadUtil, formatter, libraryData, JSONModel, File, JSZip, openWindow) {
20
+ "use strict";
21
+
22
+ return BaseController.extend("sap.ui.documentation.sdk.controller.DemoApps", {
23
+
24
+ formatter: formatter,
25
+
26
+ /**
27
+ * Called when the controller is instantiated.
28
+ */
29
+ onInit: function () {
30
+ BaseController.prototype.onInit.call(this);
31
+
32
+ this.processDemoAppsData();
33
+
34
+ this.getRouter().getRoute("demoapps").attachPatternMatched(this.onPatternMatched, this);
35
+ },
36
+
37
+ /**
38
+ * Processes the demo apps data.
39
+ */
40
+ processDemoAppsData: function() {
41
+ libraryData.getDemoAppsData().then(function (aDemoApps) {
42
+ aDemoApps = this.flattenDemoAppsCategories(aDemoApps);
43
+
44
+ var oModel = new JSONModel(aDemoApps);
45
+ this.setModel(oModel);
46
+
47
+ this.addCategoryClassToGridItems("sapUiDemoKitDemoAppsMainContent");
48
+ }.bind(this));
49
+ },
50
+
51
+ /**
52
+ * Flattens the demo apps by category.
53
+ * @param {object} data - The demo apps data.
54
+ * @returns {object} The flattened demo apps data.
55
+ */
56
+ flattenDemoAppsCategories(data) {
57
+ data.demoAppsByCategory.forEach(function(category) {
58
+ category.rows = [].concat.apply([], category.rows);
59
+ });
60
+
61
+ return data;
62
+ },
63
+
64
+ /**
65
+ * Adds category class to each grid item.
66
+ * @param {string} gridId - The ID of the grid.
67
+ */
68
+ addCategoryClassToGridItems(gridId) {
69
+ this.byId(gridId).getItems().forEach(function(gridItem) {
70
+ var cssClass = gridItem.data("demo-apps-category");
71
+ gridItem.addStyleClass(cssClass);
72
+ });
73
+ },
74
+
75
+ /**
76
+ * Creates an archive file and triggers a download.
77
+ *
78
+ * @param {object} oContent the blob for the zip file
79
+ * @param {string} sFilename the file name
80
+ */
81
+ createArchive: function (oContent, sFilename) {
82
+ File.save(oContent, sFilename, "zip", "application/zip");
83
+ },
84
+
85
+ /**
86
+ * Handles the pattern matched event.
87
+ * Currently, it hides the master side of the UI.
88
+ */
89
+ onPatternMatched: function () {
90
+ this.hideMasterSide();
91
+ },
92
+
93
+ /**
94
+ * Opens a new window with the demo apps home link.
95
+ */
96
+ onReadMoreButtonPress: function () {
97
+ var sDemoAppsReadMoreLink = "topic/a3ab54ecf7ac493b91904beb2095d208",
98
+ sFormattedLink = formatter.formatHttpHrefForNewWindow(sDemoAppsReadMoreLink);
99
+
100
+ openWindow(sFormattedLink, "_blank");
101
+ },
102
+
103
+ /**
104
+ * Handles the download press event.
105
+ *
106
+ * @param {object} oEvent - The event object.
107
+ */
108
+ onDownloadPress: function (oEvent) {
109
+ var oListItem = oEvent.getSource().getParent();
110
+
111
+ fetch(oListItem.data("config"))
112
+ .then(function (response) {
113
+ return response.json();
114
+ })
115
+ .then(this.processFiles.bind(this, oListItem))
116
+ .catch(function (error) {
117
+ Log.error('Error: ', error);
118
+ this.handleError('An error occurred: ' + error.message);
287
119
  }.bind(this));
288
- },
289
-
290
- /* =========================================================== */
291
- /* lifecycle methods */
292
- /* =========================================================== */
293
-
294
- loadDemoAppsCellFragments: function(oModel) {
295
- var aResult = {},
296
- createDemoAppCell = this.createDemoAppCell.bind(this),
297
- demoApps = oModel.getProperty("/demoAppsByCategory");
298
-
299
- function handleCategory(category) {
300
- return Promise.all(category.rows.map(handleRow));
301
- }
302
-
303
- function handleRow(row) {
304
- return Promise.all(row.map(function (cell) {
305
- return createDemoAppCell(cell).then(function (oCell) {
306
- aResult[cell.id] = oCell;
307
- });
308
- }));
120
+ },
121
+
122
+ /**
123
+ * Processes the files for the list item.
124
+ *
125
+ * @param {object} oListItem - The list item.
126
+ * @param {object} oConfig - The app configuration.
127
+ */
128
+ processFiles: function (oListItem, oConfig) {
129
+ var aFails = [],
130
+ aPromises = [],
131
+ oZipFile = new JSZip(),
132
+ aFiles = oConfig.files;
133
+
134
+ aFiles.forEach(function (sFilePath) {
135
+ var oPromise = this.handleFilePromise(sFilePath, oZipFile, aFails, oConfig);
136
+ aPromises.push(oPromise);
137
+ }.bind(this));
138
+
139
+ this.addLicenseFileToZip(aPromises, oZipFile);
140
+ this.handlePromisesCompletion(aPromises, aFails, oZipFile, oListItem);
141
+ },
142
+
143
+ /**
144
+ * Handles the file promise.
145
+ *
146
+ * @param {string} sFilePath - The file path.
147
+ * @param {object} oZipFile - The zip file.
148
+ * @param {Array} aFails - The array of failed promises.
149
+ * @param {object} oConfig - The configuration.
150
+ *
151
+ * @returns {Promise} A promise that resolves with the file.
152
+ */
153
+ handleFilePromise: function (sFilePath, oZipFile, aFails, oConfig) {
154
+ var oPromise = ResourceDownloadUtil.fetch(oConfig.cwd + sFilePath);
155
+
156
+ oPromise.then(function (oContent) {
157
+ if (oContent.errorMessage) {
158
+ aFails.push(oContent.errorMessage);
159
+ } else if (!sFilePath.startsWith("../")) {
160
+ oZipFile.file(sFilePath, oContent, { base64: false, binary: true });
309
161
  }
310
-
311
- return new Promise(function (resolve, reject) {
312
- Promise.all(demoApps.map(handleCategory))
313
- .then(function () {
314
- resolve(aResult);
315
- })
316
- .catch(function (error) {
317
- reject(error);
318
- });
319
- });
320
- },
321
-
322
- /**
323
- * Factory function for creating the demo app cells
324
- *
325
- * @param {string} _ the id of the cell in the dom
326
- * @param {sap.ui.model.Context} oBindingContext the context for the current cell
327
- * @return {sap.ui.layout.BlockLayoutCell} either a teaser cell or a demo app cell based on the metadata in the model
328
- * @public
329
- */
330
- createDemoAppCellFactory: function (_, oBindingContext) {
331
- var id = oBindingContext.getObject().id;
332
- return this._cellFragments[id];
333
- },
334
-
335
- /**
336
- * Handler for the demo app cell creation
337
- *
338
- * @param {sap.ui.model.Context} oBindingContext the context for the current cell
339
- * @param {sap.ui.core.Control[]} aFragments the fragments for the current cell [teaser, default cell]
340
- * @return {sap.ui.layout.BlockLayoutCell} the demo app cell
341
- * @private
342
- **/
343
- onDemoAppCellCreated: function (oBindingContext, aFragments) {
344
- var oTeaser = aFragments[0],
345
- oBlockLayoutCell = aFragments[1];
346
-
347
- oBlockLayoutCell.getContent()[0].addContent(oTeaser);
348
- sap.ui.loader.config({paths:{"test-resources":null}});
349
- //sets the teaser to aria-hidden => gets ignored by screen reader
350
- oTeaser.addEventDelegate({"onAfterRendering": function() {
351
- this.getParent().getDomRef().childNodes[1].setAttribute("aria-hidden", "true");
352
- }.bind(oTeaser)});
353
-
354
- oBlockLayoutCell.setBindingContext(oBindingContext);
355
- return oBlockLayoutCell;
356
- },
357
-
358
- /**
359
- * Handler for the demo app cell creation error
360
- * Creates and returns a normal demo app cell instead as promise
361
- *
362
- * @param {sap.ui.model.Context} oBindingContext the context for the current cell
363
- * @param {Error} oException the exception that occurred during the cell creation
364
- * @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
365
- * @private
366
- **/
367
- onDemoAppCellFailed: function (oBindingContext, oException) {
368
- Log.warning("Teaser for demo app \"" + oBindingContext.name + "\" could not be loaded: " + oException);
369
- return this.createNormalDemoAppCell(oBindingContext);
370
- },
371
-
372
- /**
373
- * Creates a normal demo app cell
374
- * @param {sap.ui.model.Context} oBindingContext the context for the current cell
375
- * @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
376
- * @private
377
- **/
378
- createNormalDemoAppCell: function (oBindingContext) {
379
- return new Promise(function (resolve) {
380
- Fragment.load({
381
- id: oBindingContext.id,
382
- name: "sap.ui.documentation.sdk.view.BlockLayoutCell",
383
- controller: this
384
- }).then(function (oBlockLayoutCell) {
385
- oBlockLayoutCell.setBindingContext(oBindingContext);
386
- resolve(oBlockLayoutCell);
162
+ });
163
+
164
+ return oPromise;
165
+ },
166
+
167
+ /**
168
+ * Adds the license file to the zip file.
169
+ *
170
+ * @param {Array} aPromises - The array of promises.
171
+ * @param {object} oZipFile - The zip file.
172
+ */
173
+ addLicenseFileToZip: function (aPromises, oZipFile) {
174
+ var sUrl = sap.ui.require.toUrl("LICENSE.txt").replace("resources/", ""),
175
+ oLicensePromise = ResourceDownloadUtil.fetch(sUrl),
176
+ oLicensePromiseWrapper = new Promise(function (resolve, reject) {
177
+ oLicensePromise.then(function (oContent) {
178
+ oZipFile.file("LICENSE.txt", oContent);
179
+ resolve();
180
+ }).catch(function () {
181
+ resolve();
387
182
  });
388
- }.bind(this));
389
- },
390
-
391
- /**
392
- * Creates a demo app cell with a teaser
393
- *
394
- * @param {sap.ui.model.Context} oBindingContext the context for the current cell
395
- * @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
396
- * @private
397
- **/
398
- createDemoAppCellFromTeaser: function (oBindingContext) {
399
- sap.ui.loader.config({paths:{"test-resources":"test-resources"}});
400
- var sRelativePath = sap.ui.require.toUrl(oBindingContext.teaser),
401
- oPromiseTeaser = Fragment.load({
402
- id: oBindingContext.id,
403
- name: sRelativePath,
404
- controller: this
405
- }),
406
- oPromiseCell = Fragment.load({
407
- id: oBindingContext.id,
408
- name: "sap.ui.documentation.sdk.view.BlockLayoutTeaserCell",
409
- controller: this
410
- }),
411
- onCreated = this.onDemoAppCellCreated.bind(this, oBindingContext),
412
- onFailed = this.onDemoAppCellFailed.bind(this, oBindingContext);
413
-
414
- return Promise.all([oPromiseTeaser, oPromiseCell])
415
- .then(function (aFragments) {
416
- return onCreated(aFragments);
417
- })
418
- .catch(function (oException) {
419
- return onFailed(oException);
420
- });
421
- },
183
+ });
422
184
 
423
- /**
424
- * Creates a demo app cell or a normal considering the teaser information
425
- * @param {sap.ui.model.Context} oBindingContext the context for the current cell
426
- * @return {Promise<sap.ui.layout.BlockLayoutCell>} the demo app cell as promise
427
- * @private
428
- **/
429
- createDemoAppCell: function (oBindingContext) {
430
- if (oBindingContext.teaser) {
431
- // teaser cell (loads fragment from demo app)
432
- return this.createDemoAppCellFromTeaser(oBindingContext);
433
- } else {
434
- // normal cell
435
- return this.createNormalDemoAppCell(oBindingContext);
185
+ aPromises.push(oLicensePromiseWrapper);
186
+ },
187
+
188
+ /**
189
+ * Handles the completion of the promises.
190
+ *
191
+ * @param {Array} aPromises - The array of promises.
192
+ * @param {Array} aFails - The array of failed promises.
193
+ * @param {object} oZipFile - The zip file.
194
+ * @param {object} oListItem - The list item.
195
+ */
196
+ handlePromisesCompletion: function (aPromises, aFails, oZipFile, oListItem) {
197
+ Promise.all(aPromises).then(function () {
198
+ if (aFails.length) {
199
+ var sCompleteErrorMessage = aFails.reduce(function (sErrorMessage, sError) {
200
+ return sErrorMessage + sError + "\n";
201
+ }, "Could not locate the following download files:\n");
202
+ this.handleError(sCompleteErrorMessage);
436
203
  }
437
- },
438
-
439
- /* =========================================================== */
440
- /* helper methods */
441
- /* =========================================================== */
442
-
443
- /**
444
- * Archive creation function that can be stubbed easily in tests
445
- * @param {object} File the jszip file handle
446
- * @param {object} oContent the blob for the zip file
447
- * @param {string} sFilename the file name
448
- * @private
449
- */
450
- _createArchive: function (File, oContent, sFilename) {
451
- File.save(oContent, sFilename, "zip", "application/zip");
452
- },
453
-
454
- /**
455
- * Error handler function that can be stubbed easily in tests
456
- * @param {string} sError the error message
457
- * @private
458
- */
459
- _handleError: function (sError) {
460
- MessageBox.error(sError);
461
- },
462
204
 
463
- /**
464
- * Handles landing image load event and makes landing image headline visible
465
- * when the image has loaded.
466
- */
467
- handleLandingImageLoad: function () {
468
- this.byId("landingImageHeadline").setVisible(true);
469
- }
470
- });
471
- }
472
- );
205
+ MessageToast.show("Downloading for app \"" + oListItem.getLabel() + "\" has been started");
206
+
207
+ var oContent = oZipFile.generate({ type: "blob" });
208
+ this.createArchive(oContent, oListItem.getLabel());
209
+ }.bind(this));
210
+ },
211
+
212
+ /**
213
+ * Error handler function that can be stubbed easily in tests
214
+ * @param {string} sError the error message
215
+ * @private
216
+ */
217
+ handleError: function (sError) {
218
+ MessageBox.error(sError);
219
+ }
220
+ });
221
+ });