@sapui5/sap.ui.export 1.106.0 → 1.108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/package.json +1 -1
  2. package/src/sap/ui/export/.library +2 -2
  3. package/src/sap/ui/export/ExportBase.js +1 -1
  4. package/src/sap/ui/export/ExportDialog.js +14 -5
  5. package/src/sap/ui/export/ExportHandler.js +179 -70
  6. package/src/sap/ui/export/ExportUtils.js +77 -24
  7. package/src/sap/ui/export/PortableDocument.js +1 -1
  8. package/src/sap/ui/export/Spreadsheet.js +4 -4
  9. package/src/sap/ui/export/SpreadsheetExport.js +1 -1
  10. package/src/sap/ui/export/fragments/SettingsDialog.fragment.xml +2 -2
  11. package/src/sap/ui/export/js/XLSXBuilder.js +1 -1
  12. package/src/sap/ui/export/js/XLSXBuilder.js.map +1 -1
  13. package/src/sap/ui/export/library.js +10 -6
  14. package/src/sap/ui/export/messagebundle.properties +11 -8
  15. package/src/sap/ui/export/messagebundle_ar.properties +7 -5
  16. package/src/sap/ui/export/messagebundle_bg.properties +7 -5
  17. package/src/sap/ui/export/messagebundle_ca.properties +7 -5
  18. package/src/sap/ui/export/messagebundle_cs.properties +7 -5
  19. package/src/sap/ui/export/messagebundle_cy.properties +7 -5
  20. package/src/sap/ui/export/messagebundle_da.properties +7 -5
  21. package/src/sap/ui/export/messagebundle_de.properties +6 -4
  22. package/src/sap/ui/export/messagebundle_el.properties +8 -6
  23. package/src/sap/ui/export/messagebundle_en.properties +7 -5
  24. package/src/sap/ui/export/messagebundle_en_GB.properties +7 -5
  25. package/src/sap/ui/export/messagebundle_en_US_sappsd.properties +7 -5
  26. package/src/sap/ui/export/messagebundle_en_US_saprigi.properties +7 -5
  27. package/src/sap/ui/export/messagebundle_en_US_saptrc.properties +7 -5
  28. package/src/sap/ui/export/messagebundle_es.properties +7 -5
  29. package/src/sap/ui/export/messagebundle_es_MX.properties +7 -5
  30. package/src/sap/ui/export/messagebundle_et.properties +7 -5
  31. package/src/sap/ui/export/messagebundle_fi.properties +7 -5
  32. package/src/sap/ui/export/messagebundle_fr.properties +7 -5
  33. package/src/sap/ui/export/messagebundle_fr_CA.properties +7 -5
  34. package/src/sap/ui/export/messagebundle_hi.properties +7 -5
  35. package/src/sap/ui/export/messagebundle_hr.properties +7 -5
  36. package/src/sap/ui/export/messagebundle_hu.properties +7 -5
  37. package/src/sap/ui/export/messagebundle_id.properties +7 -5
  38. package/src/sap/ui/export/messagebundle_it.properties +7 -5
  39. package/src/sap/ui/export/messagebundle_iw.properties +7 -5
  40. package/src/sap/ui/export/messagebundle_ja.properties +8 -6
  41. package/src/sap/ui/export/messagebundle_kk.properties +7 -5
  42. package/src/sap/ui/export/messagebundle_ko.properties +7 -5
  43. package/src/sap/ui/export/messagebundle_lt.properties +7 -5
  44. package/src/sap/ui/export/messagebundle_lv.properties +7 -5
  45. package/src/sap/ui/export/messagebundle_ms.properties +7 -5
  46. package/src/sap/ui/export/messagebundle_nl.properties +7 -5
  47. package/src/sap/ui/export/messagebundle_no.properties +7 -5
  48. package/src/sap/ui/export/messagebundle_pl.properties +7 -5
  49. package/src/sap/ui/export/messagebundle_pt.properties +7 -5
  50. package/src/sap/ui/export/messagebundle_pt_PT.properties +7 -5
  51. package/src/sap/ui/export/messagebundle_ro.properties +7 -5
  52. package/src/sap/ui/export/messagebundle_ru.properties +7 -5
  53. package/src/sap/ui/export/messagebundle_sh.properties +7 -5
  54. package/src/sap/ui/export/messagebundle_sk.properties +7 -5
  55. package/src/sap/ui/export/messagebundle_sl.properties +7 -5
  56. package/src/sap/ui/export/messagebundle_sv.properties +7 -5
  57. package/src/sap/ui/export/messagebundle_th.properties +7 -5
  58. package/src/sap/ui/export/messagebundle_tr.properties +7 -5
  59. package/src/sap/ui/export/messagebundle_uk.properties +7 -5
  60. package/src/sap/ui/export/messagebundle_vi.properties +7 -5
  61. package/src/sap/ui/export/messagebundle_zh_CN.properties +7 -5
  62. package/src/sap/ui/export/messagebundle_zh_TW.properties +7 -5
  63. package/src/sap/ui/export/provider/DataProviderBase.js +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapui5/sap.ui.export",
3
- "version": "1.106.0",
3
+ "version": "1.108.0",
4
4
  "description": "SAPUI5 Library sap.ui.export",
5
5
  "homepage": "https://sap.github.io/ui5-tooling/pages/SAPUI5/",
6
6
  "author": "SAP SE (https://www.sap.com)",
@@ -5,7 +5,7 @@
5
5
  <vendor>SAP SE</vendor>
6
6
  <copyright>SAPUI5
7
7
  * (c) Copyright 2009-2022 SAP SE. All rights reserved.</copyright>
8
- <version>1.106.0</version>
8
+ <version>1.108.0</version>
9
9
 
10
10
  <documentation>UI5 library: sap.ui.export</documentation>
11
11
 
@@ -42,7 +42,7 @@
42
42
  </ownership>
43
43
 
44
44
  <thirdparty xmlns="http://www.sap.com/ui5/buildext/thirdparty" >
45
- <lib name="JSZip3" displayName="JSZip 3.7.1" version="3.7.1" homepage="https://github.com/Stuk/jszip" id="73555000106100074228">
45
+ <lib name="JSZip3" displayName="JSZip 3.7.1" npmName="jszip" version="3.7.1" hash="9548550e812008b802e8ea9c94cb4d34" homepage="https://github.com/Stuk/jszip" id="73555000106100074228">
46
46
  <license url="https://github.com/Stuk/jszip/blob/main/LICENSE.markdown" type="MIT"/>
47
47
  <copyright>2009-2016 Stuart Knightley &lt;stuart [at] stuartk.com&gt;</copyright>
48
48
  <pattern>sap/ui/export/js/libs/JSZip3.js</pattern>
@@ -27,7 +27,7 @@ sap.ui.define([
27
27
  * @constructor The <code>sap.ui.export.ExportBase</code> class allows you to export table data from a UI5 application to certain formats. This class is an abstract class that requires specific implementations for each file format.
28
28
  *
29
29
  * @author SAP SE
30
- * @version 1.106.0
30
+ * @version 1.108.0
31
31
  *
32
32
  * @since 1.96
33
33
  * @name sap.ui.export.ExportBase
@@ -7,8 +7,16 @@
7
7
  * Export progress dialog
8
8
  * @private
9
9
  */
10
- sap.ui.define(['sap/ui/core/library', 'sap/m/library', 'sap/m/Dialog', 'sap/m/Button', 'sap/m/ProgressIndicator', 'sap/m/Text', 'sap/m/Link', 'sap/m/VBox', 'sap/m/MessageBox', 'sap/ui/core/format/NumberFormat'],
11
- function(coreLibrary, MLibrary, Dialog, Button, ProgressIndicator, Text, Link, VBox, MessageBox, NumberFormat) {
10
+ sap.ui.define([
11
+ 'sap/ui/core/library',
12
+ 'sap/m/library',
13
+ 'sap/m/Dialog',
14
+ 'sap/m/Button',
15
+ 'sap/m/ProgressIndicator',
16
+ 'sap/m/Text',
17
+ 'sap/m/MessageBox',
18
+ 'sap/ui/core/format/NumberFormat'
19
+ ], function(coreLibrary, MLibrary, Dialog, Button, ProgressIndicator, Text, MessageBox, NumberFormat) {
12
20
  'use strict';
13
21
 
14
22
  var ValueState = coreLibrary.ValueState;
@@ -76,6 +84,7 @@ sap.ui.define(['sap/ui/core/library', 'sap/m/library', 'sap/m/Dialog', 'sap/m/Bu
76
84
 
77
85
  /* Update status text to reflect the current step (bundle instead of fetching data) */
78
86
  if (iPercentage >= 100) {
87
+ progressIndicator.setState(ValueState.Success);
79
88
  cancelButton.setEnabled(false);
80
89
  oMessage.setText(sMessage || oResourceBundle.getText("PROGRESS_BUNDLE_MSG"));
81
90
  }
@@ -189,14 +198,14 @@ sap.ui.define(['sap/ui/core/library', 'sap/m/library', 'sap/m/Dialog', 'sap/m/Bu
189
198
  }
190
199
 
191
200
  oResourceBundlePromise.then(function(oResourceBundle) {
192
- var errorMessage = sMessage || oResourceBundle.getText('PROGRESS_ERROR_DEFAULT');
201
+ var sErrorMessage = sMessage || oResourceBundle.getText('PROGRESS_ERROR_DEFAULT');
193
202
 
194
203
  // Replace technical error message in case of "out of memory"
195
204
  if (sMessage.toLowerCase().indexOf('invalid string length') > -1) {
196
- errorMessage = oResourceBundle.getText('MSG_ERROR_OUT_OF_MEMORY');
205
+ sErrorMessage = oResourceBundle.getText('MSG_ERROR_OUT_OF_MEMORY');
197
206
  }
198
207
 
199
- MessageBox.error(oResourceBundle.getText("PROGRESS_ERROR_MSG") + "\n\n" + errorMessage, {
208
+ MessageBox.error(sErrorMessage, {
200
209
  title : oResourceBundle.getText("PROGRESS_ERROR_TITLE")
201
210
  });
202
211
  });
@@ -15,7 +15,7 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
15
15
  * @constructor The <code>sap.ui.export.ExportHandler</code> class allows you to export table data from a UI5 application.
16
16
  *
17
17
  * @author SAP SE
18
- * @version 1.106.0
18
+ * @version 1.108.0
19
19
  *
20
20
  * @since 1.102
21
21
  * @name sap.ui.export.ExportHandler
@@ -26,10 +26,26 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
26
26
  */
27
27
  var ExportHandler = EventProvider.extend('sap.ui.export.ExportHandler', {
28
28
  constructor: function(mCapabilities) {
29
+ var that = this;
29
30
  EventProvider.call(this);
30
31
 
31
32
  /* Apply default capabilities if nothing is provided */
32
33
  this._mCapabilities = mCapabilities instanceof Object ? mCapabilities : { XLSX: {} };
34
+
35
+ /* Activate Google Sheet support */
36
+ this._initialized = new Promise(function(fnResolve) {
37
+ that.isGoogleSheetSupported().then(function(bSupported) {
38
+ if (bSupported) {
39
+ that._mCapabilities[FileType.GSHEET] = {};
40
+
41
+ /* Set cloud default settings */
42
+ that._mDialogSettings = {
43
+ destination: Destination.REMOTE,
44
+ fileType: FileType.GSHEET
45
+ };
46
+ }
47
+ }).finally(fnResolve);
48
+ });
33
49
  }
34
50
  });
35
51
 
@@ -89,6 +105,10 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
89
105
  return this.detachEvent('beforeExport', fnHandler, oListener);
90
106
  };
91
107
 
108
+ ExportHandler.prototype.initialized = function() {
109
+ return this._initialized;
110
+ };
111
+
92
112
  /**
93
113
  * Cleans up the internal structures and removes all event handlers.
94
114
  *
@@ -105,46 +125,39 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
105
125
  this._oModel.destroy();
106
126
  }
107
127
 
128
+ if (this._oFileShareBinding) {
129
+ this._oFileShareBinding.destroy();
130
+ }
131
+
108
132
  this._mCapabilities = null;
109
133
  this._oDataSource = null;
110
134
  this._mDialogSettings = null;
111
135
  this._oModel = null;
136
+ this._oFileShareBinding = null;
112
137
  this.bIsDestroyed = true;
113
138
  };
114
139
 
115
140
  /**
116
- * Loads the FileShareSupport module and requests
117
- * available destinations. If no FileShareSupport
118
- * module is registered or the module does not
119
- * provide a destination, the Promise resolves
120
- * without any result.
141
+ * Requests available FileShares and returns a <code>Promise</code> that
142
+ * resolves with their Contexts. If the underlying <code>ODataModel</code>
143
+ * could not be instantiated the <code>Promise</code> resolves with an
144
+ * empty array.
121
145
  *
122
- * @returns {Promise} A Promise that gets resolved with the FileShareSupport datasource or undefined if there is none
146
+ * @returns {Promise<sap.ui.model.odata.v4.Context[]>} <code>Promise</code> that gets resolved with the requested FileShare <code>Context</code> <code>Array</code>
147
+ * @private
123
148
  */
124
- ExportHandler.prototype.fetchDataSource = function() {
125
- var that = this;
126
- var sFileShareSupportModuleName;
127
-
128
- if (this._oDataSource) {
129
- return Promise.resolve(this._oDataSource);
130
- }
131
-
132
- sFileShareSupportModuleName = Core.getConfiguration().getFileShareSupport();
149
+ ExportHandler.prototype.getFileShareContexts = function() {
150
+ return this.getFileShareModel().then(function(oModel) {
151
+ if (!oModel) {
152
+ return Promise.resolve([]);
153
+ }
133
154
 
134
- if (!sFileShareSupportModuleName) {
135
- return Promise.resolve();
136
- }
155
+ if (!this._oFileShareBinding) {
156
+ this._oFileShareBinding = oModel.bindList('/FileShares');
157
+ }
137
158
 
138
- return new Promise(function(fnResolve) {
139
- sap.ui.require([sFileShareSupportModuleName], function(oFileShareSupport) {
140
- oFileShareSupport.getDataSource().then(function(oDataSource) {
141
- that._oDataSource = oDataSource;
142
- fnResolve(oDataSource);
143
- }).catch(function () {
144
- fnResolve();
145
- });
146
- });
147
- });
159
+ return this._oFileShareBinding.requestContexts(0);
160
+ }.bind(this));
148
161
  };
149
162
 
150
163
  /**
@@ -153,18 +166,25 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
153
166
  * when the user selected a particular location for
154
167
  * the file that should be created.
155
168
  *
156
- * @param {object} oDataSource DataSource object containing the serviceUrl for the CloudFilePicker
157
169
  * @param {string} [sFileName] Suggested name of the file including file extension
158
170
  * @returns {Promise} Resolves with the file location selected in the <code>CloudFilePicker</code>
159
171
  */
160
- ExportHandler.prototype.getRemoteFileLocation = function(oDataSource, sFileName) {
172
+ ExportHandler.prototype.getRemoteFileLocation = function(sFileName) {
173
+ var that = this;
174
+
161
175
  return new Promise(function(fnResolve, fnReject) {
162
- ExportUtils.getResourceBundle().then(function(oResourceBundle) {
176
+ Promise.all([
177
+ ExportUtils.getResourceBundle(),
178
+ that.getFileShareModel()
179
+ ]).then(function(aResolve) {
180
+ var oResourceBundle = aResolve[0];
181
+ var oModel = aResolve[1];
182
+
163
183
  sap.ui.require(['sap/suite/ui/commons/CloudFilePicker'], function(CloudFilePicker) {
164
184
  var oFilePicker;
165
185
 
166
186
  oFilePicker = new CloudFilePicker({
167
- serviceUrl: oDataSource.uri,
187
+ sharedModel: oModel,
168
188
  suggestedFileName: sFileName,
169
189
  enableDuplicateCheck: true,
170
190
  fileNameMandatory: true,
@@ -212,7 +232,8 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
212
232
  * @param {object} mExportSettings mExportSettings ExportSettings that are used for the export
213
233
  * @param {object} mCustomSettings Additional settings that are passed into the event
214
234
  * @param {object} mCloudFileInfo FileShareItem representation of the file
215
- * @returns {Promise} A Promise that resolves with the desired export instance
235
+ * @returns {Promise} A <code>Promise</code> that resolves with the desired export instance
236
+ * @private
216
237
  */
217
238
  ExportHandler.prototype.getExportInstance = function(mExportSettings, mCustomSettings, mCloudFileInfo) {
218
239
  var that = this;
@@ -241,6 +262,11 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
241
262
  oExportDialog = oEvent.getParameter('exportDialog');
242
263
  mCloudFileInfo['FileShareItemContentType'] = oExportInstance.getMimeType();
243
264
 
265
+ /* Enforce file conversion for Google Sheet */
266
+ if (mExportSettings.fileType === FileType.GSHEET) {
267
+ mCloudFileInfo['FileShareItemConvertToMimeType'] = 'application/vnd.google-apps.spreadsheet';
268
+ }
269
+
244
270
  var uInt8Array = new Uint8Array(aArrayBuffer);
245
271
  var stringArray = new Array(uInt8Array.length);
246
272
  for (var i = 0; i < uInt8Array.length; i++) {
@@ -269,15 +295,15 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
269
295
  * Uploads the file to the FileShareSupport OData service.
270
296
  *
271
297
  * @param {object} mCloudFileInfo FileShareItem representation of the file
272
- * @returns {Promise} A Promise that gets resolved after the generated file has been transferred to the FileShareSupport OData service
298
+ * @returns {Promise} A <code>Promise</code> that gets resolved after the generated file has been transferred to the FileShareSupport OData service
299
+ * @private
273
300
  */
274
301
  ExportHandler.prototype.uploadFile = function(mCloudFileInfo) {
275
- return this.fetchDataSource().then(function(oDestination) {
276
- var oBinding, oContext, oModel, sContentProperty, sTypeProperty, sPath;
302
+ return this.getFileShareModel().then(function(oModel) {
303
+ var oBinding, oContext, sContentProperty, sTypeProperty, sPath;
277
304
 
278
- sContentProperty = "FileShareItemContent";
305
+ sContentProperty = 'FileShareItemContent';
279
306
  sTypeProperty = 'FileShareItemContentType';
280
- oModel = this._getModel(oDestination);
281
307
 
282
308
  /* Overwrite existing file */
283
309
  if (mCloudFileInfo['FileShareItem']) {
@@ -291,8 +317,9 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
291
317
  * FileShareItemContent. Adding the <code>null</code>
292
318
  * prevents an additional PATCH for the link. It is also
293
319
  * important to set all properties without waiting for
294
- * the Promise to resolve. This allows the binding to
295
- * bundle multiple PATCH requests into a single $batch.
320
+ * the <code>Promise</code> to resolve. This allows the
321
+ * binding to bundle multiple PATCH requests into a
322
+ * single $batch.
296
323
  */
297
324
  oContext.setProperty('FileShareItemContentLink', '', null);
298
325
  oContext.setProperty(sTypeProperty, mCloudFileInfo[sTypeProperty]);
@@ -323,7 +350,7 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
323
350
  *
324
351
  * @param {sap.ui.model.odata.v4.ODataListBinding} oBinding ListBinding that is bound to the desired folder
325
352
  * @param {object} mCloudFileInfo FileShareItem representation of the file
326
- * @returns {Promise} Promise that resolves with a Link to the created file
353
+ * @returns {Promise} <code>Promise</code> that resolves with a Link to the created file
327
354
  */
328
355
  ExportHandler.prototype._createFile = function(oBinding, mCloudFileInfo) {
329
356
  return new Promise(function(fnResolve, fnReject) {
@@ -335,7 +362,7 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
335
362
 
336
363
  if (bSuccess) {
337
364
  oBinding.detachCreateCompleted(fnCreateCompleted);
338
- fnResolve(oContext.getObject()['FileShareItemContentLink']);
365
+ fnResolve(oContext.getProperty('FileShareItemContentLink'));
339
366
  } else {
340
367
  oContext.destroy();
341
368
  fnReject();
@@ -348,11 +375,16 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
348
375
  };
349
376
 
350
377
  /**
351
- * Exports the data as defined via parameter.
378
+ * Exports the data as defined via parameter. The function
379
+ * returns a <code>Promise</code> that will be resolved
380
+ * after the export process has been finished. In case of
381
+ * an error, its message will be shown in a <code>Dialog</code>
382
+ * and the <code>Promise</code> will be rejected.
352
383
  *
353
- * @param {object} mExportSettings ExportSettings that are used for the export
354
- * @returns {Promise} A Promise that gets resolved after the export process has been finished
384
+ * @param {object} mExportSettings Export settings that are used for the export
385
+ * @returns {Promise} A <code>Promise</code> that gets resolved after the export process has been finished
355
386
  *
387
+ * @name sap.ui.export.ExportHandler#export
356
388
  * @since 1.102
357
389
  * @function
358
390
  * @public
@@ -370,30 +402,35 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
370
402
  };
371
403
 
372
404
  /**
373
- * Exports the data as defined by the user. This function
374
- * will show up a export settings dialog where the user
375
- * can define certain settings that influence the output
376
- * of the export functionality.
405
+ * Exports the data as defined by the user. This function will
406
+ * show an export settings dialog where the user can define
407
+ * certain settings that influence the output of the export
408
+ * functionality.
377
409
  *
378
410
  * @param {object} oSettings General export settings containing workbook and dataSource information
379
- * @param {function} [fnResolveColumnLabel] Resolves the label for a particular column that is not directly reflected
380
- * @returns {Promise} A Promise that resolves once the data has been exported
411
+ * @param {function} [fnResolveColumnLabel] Resolves the label for a particular column that is not directly contained in the export settings
412
+ * @returns {Promise} A <code>Promise</code> that resolves once the data has been exported
381
413
  *
414
+ * @name sap.ui.export.ExportHandler#exportAs
382
415
  * @since 1.102
383
416
  * @function
384
417
  * @public
385
418
  */
386
419
  ExportHandler.prototype.exportAs = function(oSettings, fnResolveColumnLabel) {
387
420
  var that = this;
388
- var mExportSettings = Object.assign({}, oSettings, this._mDialogSettings);
421
+ var mExportSettings;
389
422
  var mUserSettings = {};
390
423
 
391
424
  if (this.bIsDestroyed) {
392
425
  return Promise.reject('ExportHandler must not be used after calling #destroy');
393
426
  }
394
427
 
395
- return this.fetchDataSource().then(function(oDestination) {
396
- return ExportUtils.getExportSettingsViaDialog(mExportSettings, that._mCapabilities, !!oDestination);
428
+ return this.initialized().then(function() {
429
+ mExportSettings = Object.assign({}, oSettings, that._mDialogSettings);
430
+
431
+ return that.getFileShareContexts();
432
+ }).then(function(aContexts) {
433
+ return ExportUtils.getExportSettingsViaDialog(mExportSettings, that._mCapabilities, aContexts.length > 0);
397
434
  }).then(function(mDialogSettings) {
398
435
 
399
436
  /* Cache settings dialog settings */
@@ -402,7 +439,7 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
402
439
  /* Merge export settings with user settings from the dialog */
403
440
  Object.assign(mExportSettings, mDialogSettings);
404
441
 
405
- if (mExportSettings.fileType !== FileType.XLSX || mExportSettings.destination !== Destination.REMOTE) {
442
+ if (mExportSettings.fileType === FileType.PDF || mExportSettings.destination !== Destination.REMOTE) {
406
443
  ExportUtils.validateFileSettings(mExportSettings);
407
444
  }
408
445
 
@@ -457,9 +494,15 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
457
494
  return Promise.resolve();
458
495
  }
459
496
 
460
- return that.fetchDataSource().then(function(oDataSource) {
461
- return that.getRemoteFileLocation(oDataSource, mExportSettings.fileName);
462
- });
497
+ return that.getRemoteFileLocation(mExportSettings.fileName);
498
+ }).then(function(mCloudFileInfo) {
499
+
500
+ /* Verify that selected FileShare is a Google Workspace */
501
+ if (mExportSettings.fileType === FileType.GSHEET) {
502
+ return that.validateFileShare(mCloudFileInfo);
503
+ }
504
+
505
+ return mCloudFileInfo;
463
506
  }).then(function(mCloudFileInfo) {
464
507
  return that.getExportInstance(mExportSettings, mUserSettings, mCloudFileInfo).then(function(oExportInstance) {
465
508
  return oExportInstance.build().finally(function() {
@@ -470,22 +513,88 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', 'sap/m/MessageToa
470
513
  };
471
514
 
472
515
  /**
473
- * Returns the <code>ODataModel</code> that is required to
474
- * create or update binding contexts.
516
+ * Ensures that the referenced FileShare is of vendor Google. This
517
+ * temporary function is required as long as the FileShare OData
518
+ * service does not provide filter capabilities via $filter.
475
519
  *
476
- * @param {object} oDataSource DataSource obtained by the FileShareSupport module
477
- * @returns {sap.ui.model.odata.v4.ODataModel} ODataModel for the FileShareSupport service
520
+ * @param {object} mCloudFileInfo FileShareItem representation that contains the reference to the FileShare
521
+ * @returns {Promise} Returns a <code>Promise</code> that either resolves with the current CloudFileInfo or rejects with an error message
522
+ * @private
478
523
  */
479
- ExportHandler.prototype._getModel = function(oDataSource) {
480
- if (!this._oModel) {
481
- this._oModel = new ODataModel({
482
- serviceUrl: oDataSource.uri,
483
- synchronizationMode: 'None',
484
- autoExpandSelect: true
524
+ ExportHandler.prototype.validateFileShare = function(mCloudFileInfo) {
525
+ return Promise.all([
526
+ ExportUtils.getResourceBundle(),
527
+ this.getFileShareContexts()
528
+ ]).then(function(aResolve) {
529
+ var oResourceBundle = aResolve[0];
530
+ var aContexts = aResolve[1];
531
+
532
+ var oFileShareContext = aContexts.find(function(oContext) {
533
+ return oContext.getProperty('FileShare') === mCloudFileInfo.FileShare;
485
534
  });
535
+
536
+ return this.isGoogleWorkspace(oFileShareContext) ? mCloudFileInfo : Promise.reject(oResourceBundle.getText('DESTINATION_ERROR_NOT_GOOGLE'));
537
+ }.bind(this));
538
+ };
539
+
540
+ /**
541
+ * Returns a <code>Promise</code> that resolves with an <code>ODataModel</code> in case
542
+ * the FileShareSupport is available and a DataSource can be obtained.
543
+ *
544
+ * @returns {Promise<sap.ui.model.odata.v4.ODataModel>} ODataModel for the FileShareSupport service
545
+ * @private
546
+ */
547
+ ExportHandler.prototype.getFileShareModel = function() {
548
+
549
+ if (this._oModel) {
550
+ return Promise.resolve(this._oModel);
486
551
  }
487
552
 
488
- return this._oModel;
553
+ return ExportUtils.fetchDataSource().then(function(oDataSource) {
554
+ if (oDataSource) {
555
+ this._oModel = new ODataModel({
556
+ serviceUrl: oDataSource.uri,
557
+ synchronizationMode: 'None',
558
+ autoExpandSelect: true
559
+ });
560
+ }
561
+
562
+ return this._oModel;
563
+ }.bind(this));
564
+ };
565
+
566
+ /**
567
+ * Evaluates whether there is any FileShare with vendor Google
568
+ *
569
+ * @returns {Promise<boolean>} Indicates whether there is a FileShare with vendor Google
570
+ * @private
571
+ */
572
+ ExportHandler.prototype.isGoogleSheetSupported = function() {
573
+ return this.getFileShareContexts().then(function(aContexts) {
574
+ return aContexts.some(this.isGoogleWorkspace);
575
+ }.bind(this));
576
+ };
577
+
578
+ /**
579
+ * Evaluates whether the given FileShare vendor is Google
580
+ *
581
+ * @param {sap.ui.model.odata.v4.Context} oContext The OData <code>Context</code> of the FileShare
582
+ * @returns {boolean} Indicates whether the FileShare vendor is Google
583
+ * @private
584
+ */
585
+ ExportHandler.prototype.isGoogleWorkspace = function(oContext) {
586
+ var sDescription, sVendorType;
587
+
588
+ sVendorType = oContext.getProperty('FileShareVendorType');
589
+
590
+ if (new URL(window.location.href).search.indexOf("sap-ui-xx-enableGoogleSheets=true") === -1) {
591
+ return sVendorType === 'GOOGLE';
592
+ }
593
+
594
+ sDescription = oContext.getProperty('FileShareDescription');
595
+
596
+ return sVendorType === 'GOOGLE'
597
+ || (typeof sDescription === 'string' && sDescription.indexOf('Google') > -1);
489
598
  };
490
599
 
491
600
  return ExportHandler;