@sapui5/sap.ui.export 1.101.0 → 1.102.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 (61) hide show
  1. package/package.json +1 -1
  2. package/src/sap/ui/export/.library +1 -1
  3. package/src/sap/ui/export/ExportBase.js +29 -7
  4. package/src/sap/ui/export/ExportDialog.js +30 -22
  5. package/src/sap/ui/export/ExportHandler.js +453 -0
  6. package/src/sap/ui/export/ExportUtils.js +167 -90
  7. package/src/sap/ui/export/PortableDocument.js +35 -24
  8. package/src/sap/ui/export/Spreadsheet.js +35 -22
  9. package/src/sap/ui/export/SpreadsheetExport.js +1 -1
  10. package/src/sap/ui/export/fragments/SettingsDialog.fragment.xml +24 -17
  11. package/src/sap/ui/export/library.js +27 -2
  12. package/src/sap/ui/export/messagebundle.properties +34 -4
  13. package/src/sap/ui/export/messagebundle_ar.properties +22 -2
  14. package/src/sap/ui/export/messagebundle_bg.properties +22 -2
  15. package/src/sap/ui/export/messagebundle_ca.properties +22 -2
  16. package/src/sap/ui/export/messagebundle_cs.properties +22 -2
  17. package/src/sap/ui/export/messagebundle_cy.properties +22 -2
  18. package/src/sap/ui/export/messagebundle_da.properties +22 -2
  19. package/src/sap/ui/export/messagebundle_de.properties +22 -2
  20. package/src/sap/ui/export/messagebundle_el.properties +22 -2
  21. package/src/sap/ui/export/messagebundle_en.properties +22 -2
  22. package/src/sap/ui/export/messagebundle_en_GB.properties +22 -2
  23. package/src/sap/ui/export/messagebundle_en_US_sappsd.properties +20 -2
  24. package/src/sap/ui/export/messagebundle_en_US_saprigi.properties +22 -2
  25. package/src/sap/ui/export/messagebundle_en_US_saptrc.properties +22 -2
  26. package/src/sap/ui/export/messagebundle_es.properties +22 -2
  27. package/src/sap/ui/export/messagebundle_es_MX.properties +22 -2
  28. package/src/sap/ui/export/messagebundle_et.properties +22 -2
  29. package/src/sap/ui/export/messagebundle_fi.properties +22 -2
  30. package/src/sap/ui/export/messagebundle_fr.properties +22 -2
  31. package/src/sap/ui/export/messagebundle_fr_CA.properties +22 -2
  32. package/src/sap/ui/export/messagebundle_hi.properties +22 -2
  33. package/src/sap/ui/export/messagebundle_hr.properties +22 -2
  34. package/src/sap/ui/export/messagebundle_hu.properties +22 -2
  35. package/src/sap/ui/export/messagebundle_id.properties +23 -3
  36. package/src/sap/ui/export/messagebundle_it.properties +22 -2
  37. package/src/sap/ui/export/messagebundle_iw.properties +22 -2
  38. package/src/sap/ui/export/messagebundle_ja.properties +22 -2
  39. package/src/sap/ui/export/messagebundle_kk.properties +22 -2
  40. package/src/sap/ui/export/messagebundle_ko.properties +22 -2
  41. package/src/sap/ui/export/messagebundle_lt.properties +22 -2
  42. package/src/sap/ui/export/messagebundle_lv.properties +22 -2
  43. package/src/sap/ui/export/messagebundle_ms.properties +22 -2
  44. package/src/sap/ui/export/messagebundle_nl.properties +22 -2
  45. package/src/sap/ui/export/messagebundle_no.properties +22 -2
  46. package/src/sap/ui/export/messagebundle_pl.properties +22 -2
  47. package/src/sap/ui/export/messagebundle_pt.properties +22 -2
  48. package/src/sap/ui/export/messagebundle_pt_PT.properties +22 -2
  49. package/src/sap/ui/export/messagebundle_ro.properties +22 -2
  50. package/src/sap/ui/export/messagebundle_ru.properties +22 -2
  51. package/src/sap/ui/export/messagebundle_sh.properties +22 -2
  52. package/src/sap/ui/export/messagebundle_sk.properties +22 -2
  53. package/src/sap/ui/export/messagebundle_sl.properties +22 -2
  54. package/src/sap/ui/export/messagebundle_sv.properties +22 -2
  55. package/src/sap/ui/export/messagebundle_th.properties +22 -2
  56. package/src/sap/ui/export/messagebundle_tr.properties +22 -2
  57. package/src/sap/ui/export/messagebundle_uk.properties +22 -2
  58. package/src/sap/ui/export/messagebundle_vi.properties +22 -2
  59. package/src/sap/ui/export/messagebundle_zh_CN.properties +22 -2
  60. package/src/sap/ui/export/messagebundle_zh_TW.properties +22 -2
  61. package/src/sap/ui/export/provider/DataProviderBase.js +10 -10
@@ -23,9 +23,11 @@ sap.ui.define([
23
23
  var ValueState = coreLibrary.ValueState;
24
24
  var FileType = library.FileType;
25
25
  var EdmType = library.EdmType;
26
+ var Destination = library.Destination;
26
27
  var uiVersion = null;
27
28
 
28
29
  /* Async call to resource bundle */
30
+ var oResourceBundle;
29
31
  var oResourceBundlePromise = Core.getLibraryResourceBundle('sap.ui.export', true);
30
32
 
31
33
  var CLASS_NAME = 'sap.ui.export.ExportUtils';
@@ -44,16 +46,20 @@ sap.ui.define([
44
46
  });
45
47
 
46
48
  /* Returns the Export Settings used by the User Settings Dialog */
47
- function getDefaultSettings(oCustomConfig, oResourceBundle, oExportCapabilities) {
49
+ function getDefaultSettings(oCustomConfig, oResourceBundle, oExportCapabilities, bRemoteDestination) {
48
50
  var sSelectedKey;
49
51
  var aSupportedFormats = Object.keys(oExportCapabilities);
50
52
 
51
53
  var oDefaultConfig = {
52
54
  fileName: 'Standard',
53
- fileType: [],
54
- selectedFileType: 'XLSX',
55
- selectedPaperSize: 'DIN_A4',
56
- selectedOrientation: 'LANDSCAPE',
55
+ fileTypeCollection: [],
56
+ fileType: 'XLSX',
57
+ destinationCollection: [
58
+ {key: Destination.LOCAL, text: oResourceBundle.getText('DESTINATION_LOCAL')}
59
+ ],
60
+ destination: Destination.LOCAL,
61
+ paperSize: 'DIN_A4',
62
+ orientation: 'LANDSCAPE',
57
63
  splitCells: false,
58
64
  includeFilterSettings: false,
59
65
  addDateTime: false,
@@ -61,11 +67,11 @@ sap.ui.define([
61
67
  pdfArchive: false,
62
68
  capabilities: oExportCapabilities,
63
69
  fitToPage: false,
64
- paperSize: [
70
+ paperSizeCollection: [
65
71
  {key: "DIN_A4", text: oResourceBundle.getText("PAPER_SIZE_A4")},
66
72
  {key: "US_LETTER", text: oResourceBundle.getText("PAPER_SIZE_US_LETTER")}
67
73
  ],
68
- orientation: [
74
+ orientationCollection: [
69
75
  {key:"LANDSCAPE", text: oResourceBundle.getText("ORIENTATION_LAND")},
70
76
  {key:"PORTRAIT", text: oResourceBundle.getText("ORIENTATION_PORT")}
71
77
  ],
@@ -75,23 +81,30 @@ sap.ui.define([
75
81
  };
76
82
 
77
83
  aSupportedFormats.forEach(function(sFormat) {
78
- oDefaultConfig.fileType.push({key: sFormat.toUpperCase()});
84
+ oDefaultConfig.fileTypeCollection.push({key: sFormat.toUpperCase()});
79
85
  });
80
86
 
87
+ if (bRemoteDestination) {
88
+ oDefaultConfig.destinationCollection.push({
89
+ key: 'REMOTE',
90
+ text: oResourceBundle.getText('DESTINATION_REMOTE')
91
+ });
92
+ }
93
+
81
94
  var oExportConfig = Object.assign({}, oDefaultConfig, oCustomConfig || {});
82
95
 
83
- for (var i = 0; i < oExportConfig.fileType.length; i++) {
96
+ for (var i = 0; i < oExportConfig.fileTypeCollection.length; i++) {
84
97
  sSelectedKey = null;
85
98
 
86
- if (!oExportConfig.fileType[i].text) {
87
- oExportConfig.fileType[i].text = oResourceBundle.getText(oExportConfig.fileType[i].key + '_FILETYPE');
99
+ if (!oExportConfig.fileTypeCollection[i].text) {
100
+ oExportConfig.fileTypeCollection[i].text = oResourceBundle.getText(oExportConfig.fileTypeCollection[i].key + '_FILETYPE');
88
101
  }
89
- if (oExportConfig.fileType[i].key === oExportConfig.selectedFileType) {
90
- sSelectedKey = oExportConfig.fileType[i].key;
102
+ if (oExportConfig.fileTypeCollection[i].key === oExportConfig.fileType) {
103
+ sSelectedKey = oExportConfig.fileTypeCollection[i].key;
91
104
  }
92
105
  }
93
106
  if (!sSelectedKey) {
94
- oExportConfig.selectedFileType = oExportConfig.fileType[0].key;
107
+ oExportConfig.fileType = oExportConfig.fileTypeCollection[0].key;
95
108
  }
96
109
 
97
110
  return oExportConfig;
@@ -100,7 +113,7 @@ sap.ui.define([
100
113
  function processExportSettings(oSettings) {
101
114
  var oFinalSettings = {};
102
115
 
103
- ["fileName", "selectedFileType", "selectedPaperSize", "selectedOrientation", "splitCells", "includeFilterSettings", "addDateTime", "doEnableAccessibility", "fitToPage", "fontSize", "signature", "signatureReason", "pdfArchive"].forEach(function(sProperty) {
116
+ ["fileName", "fileType", "paperSize", "orientation", "splitCells", "includeFilterSettings", "addDateTime", "doEnableAccessibility", "fitToPage", "fontSize", "signature", "signatureReason", "pdfArchive", 'destination'].forEach(function(sProperty) {
104
117
  oFinalSettings[sProperty] = oSettings[sProperty];
105
118
  });
106
119
 
@@ -111,7 +124,7 @@ sap.ui.define([
111
124
  * Utilities related to export to enable reuse in integration scenarios (e.g. tables).
112
125
  *
113
126
  * @author SAP SE
114
- * @version 1.101.0
127
+ * @version 1.102.0
115
128
  *
116
129
  * @since 1.59
117
130
  * @name sap.ui.export.ExportUtils
@@ -162,8 +175,9 @@ sap.ui.define([
162
175
  /**
163
176
  * Creates the Export settings dialog that can be used for configuring the spreadsheet before exporting.
164
177
  *
165
- * @param {Object} mCustomConfig Initial configuration of the settings dialog
166
- * @param {Object} oExportCapabilities Definition of supported export features
178
+ * @param {object} mCustomConfig Initial configuration of the settings dialog
179
+ * @param {object} oExportCapabilities Definition of supported export features
180
+ * @param {boolean} [bRemoteDestination] Activates remote destinations for export
167
181
  * @param {sap.ui.core.Control} [oOpener] The opener of the dialog
168
182
  * @param {function(sap.m.Dialog)} [fnCallback] Handler function that is called once the dialog has been opened. A reference to the dialog is passed as parameter
169
183
  *
@@ -171,14 +185,22 @@ sap.ui.define([
171
185
  *
172
186
  * @static
173
187
  */
174
- getExportSettingsViaDialog: function(mCustomConfig, oExportCapabilities, oOpener, fnCallback) {
188
+ getExportSettingsViaDialog: function(mCustomConfig, oExportCapabilities, bRemoteDestination, oOpener, fnCallback) {
175
189
  return new Promise(function (fnResolve, fnReject) {
176
190
  var oExportSettingsDialog;
177
191
 
192
+ // Shift optional arguments
193
+ if (typeof bRemoteDestination === 'object') {
194
+ fnCallback = oOpener;
195
+ oOpener = bRemoteDestination;
196
+ } else if (typeof bRemoteDestination === 'function') {
197
+ fnCallback = bRemoteDestination;
198
+ }
199
+
178
200
  oResourceBundlePromise.then(function (oResourceBundle) {
179
201
  var oExportConfigModel = new JSONModel();
180
202
 
181
- oExportConfigModel.setData(getDefaultSettings(mCustomConfig, oResourceBundle, oExportCapabilities));
203
+ oExportConfigModel.setData(getDefaultSettings(mCustomConfig, oResourceBundle, oExportCapabilities, bRemoteDestination));
182
204
 
183
205
  Fragment.load({
184
206
  name: 'sap.ui.export.fragments.SettingsDialog',
@@ -190,6 +212,12 @@ sap.ui.define([
190
212
  isXLSX: function(sValue) {
191
213
  return sValue === FileType.XLSX;
192
214
  },
215
+ hasDestinations: function(sFileType, aDestinationCollection) {
216
+ return sFileType === FileType.XLSX && aDestinationCollection.length > 1;
217
+ },
218
+ formatExportButton: function(sDestination) {
219
+ return sDestination === Destination.LOCAL ? oResourceBundle.getText('EXPORT_BUTTON') : oResourceBundle.getText('DIALOG_BUTTON_CLOUD_DESTINATION');
220
+ },
193
221
  onCancel: function() {
194
222
  oExportSettingsDialog.close();
195
223
  },
@@ -225,10 +253,11 @@ sap.ui.define([
225
253
  oExportBtn.setEnabled(!bValidate);
226
254
  },
227
255
  onFileTypeChange: function(oEvent) {
228
- var oSelectedItem = oEvent.getParameter("selectedItem");
256
+ var oSelectedItem = oEvent.getParameter('selectedItem');
229
257
  if (oSelectedItem && oSelectedItem.getKey() === FileType.PDF) {
230
- oExportConfigModel.setProperty("/splitCells", true);
231
- oExportConfigModel.setProperty("/includeFilterSettings", false);
258
+ oExportConfigModel.setProperty('/splitCells', true);
259
+ oExportConfigModel.setProperty('/includeFilterSettings', false);
260
+ oExportConfigModel.setProperty('/destination', Destination.LOCAL);
232
261
  } else {
233
262
  Core.byId('exportSettingsDialog-signatureReason').setVisible(false);
234
263
  Core.byId('exportSettingsDialog-signatureReasonLabel').setVisible(false);
@@ -299,7 +328,7 @@ sap.ui.define([
299
328
  * Combines the filter operator with the value and
300
329
  * creates a textual representation.
301
330
  *
302
- * @param {Object} oFilter A single filter object according to ListBinding#getFilterInfo
331
+ * @param {object} oFilter A single filter object according to ListBinding#getFilterInfo
303
332
  * @returns {string} Textual representation of the filter operation and value
304
333
  * @private
305
334
  */
@@ -329,7 +358,7 @@ sap.ui.define([
329
358
  /**
330
359
  * Parse filter tree recursively.
331
360
  *
332
- * @param {Object} oFilter Filter configuration according to ListBinding#getFilterInfo
361
+ * @param {object} oFilter Filter configuration according to ListBinding#getFilterInfo
333
362
  * @returns {Array} Array of filter entries
334
363
  * @private
335
364
  */
@@ -352,7 +381,7 @@ sap.ui.define([
352
381
  * Parses a logical filter and concatenates all
353
382
  * subsequent filters.
354
383
  *
355
- * @param {Object} oLogicalFilter Filter object according to ListBinding#getFilterInfo
384
+ * @param {object} oLogicalFilter Filter object according to ListBinding#getFilterInfo
356
385
  * @returns {Array} Array containing evaluated filter settings
357
386
  * @private
358
387
  */
@@ -414,7 +443,7 @@ sap.ui.define([
414
443
  * Parses a binary filter and returns an Array that
415
444
  * contains this explicit filter item.
416
445
  *
417
- * @param {Object} oBinaryFilter Filter object according to ListBinding#getFilterInfo
446
+ * @param {object} oBinaryFilter Filter object according to ListBinding#getFilterInfo
418
447
  * @returns {Array} Array containing this explicit filter setting
419
448
  * @private
420
449
  */
@@ -434,7 +463,7 @@ sap.ui.define([
434
463
  * Parses an unary filter and returns a modified
435
464
  * subsequent filter.
436
465
  *
437
- * @param {Object} oUnaryFilter Filter object according to ListBinding#getFilterInfo
466
+ * @param {object} oUnaryFilter Filter object according to ListBinding#getFilterInfo
438
467
  * @returns {Array} Array containing the modified subsequent filter
439
468
  * @private
440
469
  */
@@ -455,7 +484,7 @@ sap.ui.define([
455
484
  * Parses an call filter and returns an Array containing
456
485
  * this particular filter configuration.
457
486
  *
458
- * @param {Object} oCallFilter Filter object according to ListBinding#getFilterInfo
487
+ * @param {object} oCallFilter Filter object according to ListBinding#getFilterInfo
459
488
  * @returns {Array} Array containing this explicit filter setting
460
489
  * @private
461
490
  */
@@ -540,41 +569,6 @@ sap.ui.define([
540
569
  });
541
570
  },
542
571
 
543
- /**
544
- * Queries the Fiori Launchpad service for available cloud
545
- * export targets. If no cloud service is available or the
546
- * the user has no cloud export subscription, the Promise
547
- * returns an empty Array.
548
- *
549
- * @returns {Promise}
550
- * Array of available targets
551
- */
552
- getAvailableCloudExportTargets: function() {
553
- var servicePromise = Utils.getCloudExportService();
554
-
555
- return servicePromise.then(function(service) {
556
- return service && service.getSupportedTargets ? service.getSupportedTargets() : [];
557
- }).catch(function() {
558
- return [];
559
- });
560
- },
561
-
562
- /**
563
- * Returns the cloud export service. The availability of the service is
564
- * independent of a cloud export subscription. If no cloud export
565
- * service is available, which is the case on an On-Premise system, the
566
- * function returns null.
567
- *
568
- * @returns {Promise}
569
- * Promise that returns the cloud export service once it is resolved
570
- */
571
- getCloudExportService: function() {
572
- return sap.ushell
573
- && sap.ushell.Container
574
- && sap.ushell.Container.getServiceAsync
575
- ? sap.ushell.Container.getServiceAsync('ProductivityIntegration') : Promise.reject();
576
- },
577
-
578
572
  /**
579
573
  * This function saves the provided Blob to the local file system.
580
574
  * The parameter name is optional and depending on the browser it
@@ -633,33 +627,24 @@ sap.ui.define([
633
627
  * can lead to throwing an <code>Error</code>. Missing or incorrect information might get adjusted by either
634
628
  * default values or by truncating the original value.
635
629
  *
636
- * @param {Object} mSettings Export settings that will be validated
630
+ * @param {object} mSettings Export settings that will be validated
637
631
  * @param {number} mSettings.count Expected amount of data that will be available on the service
638
- * @param {Object} mSettings.dataSource DataSource configuration that will be used to fetch the data
632
+ * @param {object} mSettings.dataSource DataSource configuration that will be used to fetch the data
639
633
  * @param {string} mSettings.fileName Name of the exported file
640
634
  * @param {string} mSettings.fileType Member of sap.ui.export.FileType
641
635
  * @param {boolean} mSettings.showProgress Controls whether the progress dialog will be shown during export or not
642
- * @param {Object} mSettings.workbook Export settings that are relevant for the file structure
636
+ * @param {object} mSettings.workbook Export settings that are relevant for the file structure
643
637
  * @param {boolean} mSettings.worker Controls whether the export will be run in a dedicated Web Worker or not
644
- * @param {Object} mSettings.customizing Contains export customizing like currency and unit scale settings
638
+ * @param {object} mSettings.customizing Contains export customizing like currency and unit scale settings
645
639
  *
646
640
  * @since 1.78
647
641
  */
648
642
  validateSettings: function(mSettings) {
649
- var sExtension;
650
643
 
651
644
  /* Validate dataSource */
652
645
  Utils._validateDataSource(mSettings.dataSource);
653
646
 
654
- /* Validate fileName and fileType */
655
- mSettings.fileType = FileType[mSettings.fileType] ? mSettings.fileType : FileType.XLSX;
656
- sExtension = '.' + mSettings.fileType.toLowerCase();
657
- mSettings.fileName = mSettings.fileName || 'export' + sExtension;
658
-
659
- if (!mSettings.fileName.endsWith(sExtension)) {
660
- mSettings.fileName += sExtension;
661
- Log.warning(CLASS_NAME + ': fileName was missing the proper file extension - extension has been added');
662
- }
647
+ Utils.validateFileSettings(mSettings);
663
648
 
664
649
  /* Validate showProgress */
665
650
  if (typeof mSettings.showProgress !== 'boolean') {
@@ -679,10 +664,24 @@ sap.ui.define([
679
664
  Utils._validateScaleCustomizing(mSettings.customizing, 'unit');
680
665
  },
681
666
 
667
+ validateFileSettings: function(mSettings) {
668
+ var sExtension;
669
+
670
+ /* Validate fileName and fileType */
671
+ mSettings.fileType = FileType[mSettings.fileType] ? mSettings.fileType : FileType.XLSX;
672
+ sExtension = '.' + mSettings.fileType.toLowerCase();
673
+ mSettings.fileName = mSettings.fileName || 'export' + sExtension;
674
+
675
+ if (!mSettings.fileName.endsWith(sExtension)) {
676
+ mSettings.fileName += sExtension;
677
+ Log.info(CLASS_NAME + ': fileName was missing the proper file extension - extension has been added');
678
+ }
679
+ },
680
+
682
681
  /**
683
682
  * Validates the datasource configuration.
684
683
  *
685
- * @param {Object} mDataSource DataSource configuration that will be used to fetch the data
684
+ * @param {object} mDataSource DataSource configuration that will be used to fetch the data
686
685
  * @param {number|null} mDataSource.count Amount of data that will be requested from the service
687
686
  * @param {Array} [mDataSource.data] Array of data that will be exported
688
687
  * @param {string} [mDataSource.dataUrl] URL that is used to request the data from the backend
@@ -766,9 +765,9 @@ sap.ui.define([
766
765
  * Validates the workbook configuration that contains information about the columns,
767
766
  * the hierarchyLevel and meta information.
768
767
  *
769
- * @param {Object} mWorkbook Configuration of the Spreadsheet workbook
768
+ * @param {object} mWorkbook Configuration of the Spreadsheet workbook
770
769
  * @param {Array} mWorkbook.columns Column definition of the worksheet
771
- * @param {Object} mWorkbook.context Meta information that is written to the generated file
770
+ * @param {object} mWorkbook.context Meta information that is written to the generated file
772
771
  * @param {string} mWorkbook.hierarchyLevel Name of the property that contains the hierarchy level information
773
772
  *
774
773
  * @since 1.78
@@ -933,7 +932,7 @@ sap.ui.define([
933
932
  /**
934
933
  * Validates and fixes the type definition of a particular column if possible.
935
934
  *
936
- * @param {Object} oColumn Export settings of a particular column
935
+ * @param {object} oColumn Export settings of a particular column
937
936
  * @since 1.84
938
937
  * @private
939
938
  */
@@ -973,9 +972,9 @@ sap.ui.define([
973
972
  /**
974
973
  * Validates the context object on the workbook definition.
975
974
  *
976
- * @param {Object} oContext Context object
975
+ * @param {object} oContext Context object
977
976
  * @param {string} [oContext.application] Name of the application (default: "SAP UI5")
978
- * @param {string} [oContext.version] Application version (default: "1.101.0")
977
+ * @param {string} [oContext.version] Application version (default: "1.102.0")
979
978
  * @param {string} [oContext.title] Title that will be written to the file (NOT the filename)
980
979
  * @param {string} [oContext.modifiedBy] Optional user context that will be written to the file
981
980
  * @param {string} [oContext.sheetName] Name of the data sheet - Maximum length of 31 characters
@@ -1019,7 +1018,7 @@ sap.ui.define([
1019
1018
  * the value will be adjusted or discarded and the function writes an entry to the Log. If the property value
1020
1019
  * exceeds the maximum allowed length, it will be truncated.
1021
1020
  *
1022
- * @param {Object} oContext Context on which the property is defined
1021
+ * @param {object} oContext Context on which the property is defined
1023
1022
  * @param {string} sProperty Name of the property
1024
1023
  * @param {string} sDefaultValue Default value that gets applied in case of an invalid value - null if not defined
1025
1024
  * @param {number} [iMaxLength] Maximum allowed length.
@@ -1052,7 +1051,7 @@ sap.ui.define([
1052
1051
  * Once the property value does not meet the criteria, the value will be discarded and
1053
1052
  * the function writes an entry to the Log.
1054
1053
  *
1055
- * @param {Object} oContext Context on which the property is defined
1054
+ * @param {object} oContext Context on which the property is defined
1056
1055
  * @param {string} sProperty Name of the property
1057
1056
  * @param {string} sType Expected type of the property
1058
1057
  * @param {Any} [defaultValue] Default value that gets applied if the initial value is invalid
@@ -1076,9 +1075,9 @@ sap.ui.define([
1076
1075
  * Validates the unit specific scale settings and ensures
1077
1076
  * that the format is according to the definition.
1078
1077
  *
1079
- * @param {Object} oCustomizing General export customizing
1080
- * @param {Object} oCustomizing.currency Currency specific customizing
1081
- * @param {Object} oCustomizing.unit Unit of measure specific customizing
1078
+ * @param {object} oCustomizing General export customizing
1079
+ * @param {object} oCustomizing.currency Currency specific customizing
1080
+ * @param {object} oCustomizing.unit Unit of measure specific customizing
1082
1081
  * @param {string} sProperty Key property of the specific customizing setting
1083
1082
  * @private
1084
1083
  */
@@ -1112,7 +1111,7 @@ sap.ui.define([
1112
1111
  * by FileType. The default class is sap/ui/export/Spreadsheet when
1113
1112
  * no specific FileType is defined in the export settings.
1114
1113
  *
1115
- * @param {Object} mSettings Export configuration with optional FileType
1114
+ * @param {object} mSettings Export configuration with optional FileType
1116
1115
  * @returns {Promise} A Promise that gets resolved with the requested instance
1117
1116
  */
1118
1117
  getExportInstance: function(mSettings) {
@@ -1159,6 +1158,84 @@ sap.ui.define([
1159
1158
  }
1160
1159
 
1161
1160
  return iCount;
1161
+ },
1162
+
1163
+ /**
1164
+ * Splits up all column settings that reference multiple
1165
+ * properties as well as amounts and currency codes.
1166
+ *
1167
+ * The function returns an array with the updated column
1168
+ * configuration for the export.
1169
+ *
1170
+ * @param {Array} aColumns Export-related column configuration that will be split up if necessary
1171
+ * @param {function} [fnResolveColumnLabel] Resolves the label for a particular column that is not directly reflected
1172
+ * @returns {Array} Updated column configuration
1173
+ */
1174
+ splitColumns: function(aColumns, fnResolveColumnLabel) {
1175
+ var aResult = [];
1176
+
1177
+ aColumns.forEach(function(oColumn) {
1178
+ var aSplittedColumns, oUpdatedColumn, oAdditionalColumn, sColumnLabel;
1179
+
1180
+ /* Split EdmType.String columns with multiple properties */
1181
+ if (Array.isArray(oColumn.property) && oColumn.property.length > 1) {
1182
+ oUpdatedColumn = Object.assign({}, oColumn);
1183
+ aSplittedColumns = [oUpdatedColumn];
1184
+
1185
+ /* Ignore the leading property */
1186
+ oUpdatedColumn.property.slice(1).forEach(function(sProperty, iIndex) {
1187
+ sColumnLabel = typeof fnResolveColumnLabel === 'function' ? fnResolveColumnLabel(sProperty) : null;
1188
+ oAdditionalColumn = {
1189
+ property: sProperty,
1190
+ label: sColumnLabel || oColumn.label + ' (' + (iIndex + 1) + ')'
1191
+ };
1192
+
1193
+ aSplittedColumns.push(oAdditionalColumn);
1194
+ });
1195
+
1196
+ oUpdatedColumn.property = oUpdatedColumn.property[0];
1197
+ delete oUpdatedColumn.template;
1198
+ }
1199
+
1200
+ /* Split EdmType.Currency and EdmType.Number columns */
1201
+ if (oColumn.unitProperty && oColumn.displayUnit !== false) { // displayUnit is assumed to be true by default - so undefined needs to be treated like true
1202
+ oUpdatedColumn = Object.assign({}, oColumn);
1203
+ sColumnLabel = typeof fnResolveColumnLabel === 'function' ? fnResolveColumnLabel(oColumn.unitProperty) : null;
1204
+ aSplittedColumns = [oUpdatedColumn, {
1205
+ property: oColumn.unitProperty,
1206
+ label: sColumnLabel || oColumn.label + ' (1)'
1207
+ }];
1208
+
1209
+ if (oUpdatedColumn.type === EdmType.Currency) {
1210
+ oUpdatedColumn.displayUnit = false;
1211
+ }
1212
+
1213
+ if (oUpdatedColumn.type === EdmType.Number) {
1214
+ delete oUpdatedColumn.unitProperty;
1215
+ }
1216
+ }
1217
+
1218
+ aResult.push(aSplittedColumns || oColumn);
1219
+ });
1220
+
1221
+ return aResult.flat();
1222
+ },
1223
+
1224
+ /**
1225
+ * Returns a <code>Promise</code> that resolves with the
1226
+ * <code>ResourceBundle</code> of the sap.ui.export library.
1227
+ *
1228
+ * @returns {Promise} <code>Promise</code> with the <code>ResourceBundle</code>
1229
+ */
1230
+ getResourceBundle: function() {
1231
+ if (!oResourceBundle) {
1232
+ return Core.getLibraryResourceBundle('sap.ui.export', true).then(function(oBundle) {
1233
+ oResourceBundle = oBundle;
1234
+
1235
+ return oResourceBundle;
1236
+ });
1237
+ }
1238
+ return Promise.resolve(oResourceBundle);
1162
1239
  }
1163
1240
  };
1164
1241
 
@@ -5,18 +5,19 @@
5
5
 
6
6
  sap.ui.define([
7
7
  'sap/base/Log',
8
+ 'sap/m/MessageToast',
8
9
  'sap/ui/core/Core',
9
10
  'sap/ui/export/ExportBase',
10
11
  'sap/ui/export/ExportUtils',
11
12
  'sap/ui/model/odata/v4/ODataModel'
12
- ], function(Log, Core, ExportBase, ExportUtils, ODataModel) {
13
+ ], function(Log, MessageToast, Core, ExportBase, ExportUtils, ODataModel) {
13
14
  'use strict';
14
15
 
15
16
  /**
16
17
  * @constructor The <code>sap.ui.export.PortableDocument</code> class allows you to export table data from a UI5 application to a Portable Document Format (*.PDF) file.
17
18
  *
18
19
  * @author SAP SE
19
- * @version 1.101.0
20
+ * @version 1.102.0
20
21
  *
21
22
  * @since 1.96
22
23
  * @alias sap.ui.export.PortableDocument
@@ -42,9 +43,9 @@ sap.ui.define([
42
43
  * Sets the data source configuration that will be used for exporting the data. If the passed parameter is null,
43
44
  * the call will be ignored.
44
45
  *
45
- * @param {Object|sap.ui.model.ListBinding|sap.ui.model.TreeBinding} oDataSource Possible types are a data
46
+ * @param {object|sap.ui.model.ListBinding|sap.ui.model.TreeBinding} oDataSource Possible types are a data
46
47
  * source configuration, a <code>sap.ui.model.ListBinding</code> or <code>sap.ui.model.TreeBinding</code>
47
- * @returns {Object|null} - Valid dataSource object or null in case the dataSource configuration is not supported
48
+ * @returns {object|null} - Valid dataSource object or null in case the dataSource configuration is not supported
48
49
  *
49
50
  * @since 1.96
50
51
  * @public
@@ -78,7 +79,7 @@ sap.ui.define([
78
79
  * Creates a valid dataSource configuration
79
80
  *
80
81
  * @param {sap.ui.model.ListBinding|sap.ui.model.TreeBinding} oBinding - A subclass of <code>sap.ui.model.ListBinding</code> or <code>sap.ui.model.TreeBinding</code>
81
- * @returns {Object} - Valid data source configuration built upon the ListBinding
82
+ * @returns {object} - Valid data source configuration built upon the ListBinding
82
83
  */
83
84
  PortableDocument.prototype.createDataSourceFromBinding = function(oBinding) {
84
85
 
@@ -135,8 +136,8 @@ sap.ui.define([
135
136
  * Creates the DocumentDescription based on the given export
136
137
  * settings and assigns a unique Id to it.
137
138
  *
138
- * @param {Object} mSettings Export settings
139
- * @returns {Object} DocumentDescription object that contains all relevant export settings
139
+ * @param {object} mSettings Export settings
140
+ * @returns {object} DocumentDescription object that contains all relevant export settings
140
141
  * @private
141
142
  */
142
143
  PortableDocument.prototype._createDocumentDescription = function(mSettings) {
@@ -199,7 +200,7 @@ sap.ui.define([
199
200
  }
200
201
  }
201
202
 
202
- /* Eliminate duplicates and navigation properties before adding columns */
203
+ /* Eliminate duplicates before adding columns */
203
204
  oWorkbook.columns.filter(function(oColumn, iIndex, aArray) {
204
205
  var sProperty = Array.isArray(oColumn.property) ? oColumn.property[0] : oColumn.property;
205
206
 
@@ -207,7 +208,7 @@ sap.ui.define([
207
208
  var sOtherProperty = Array.isArray(oOtherColumn.property) ? oOtherColumn.property[0] : oOtherColumn.property;
208
209
 
209
210
  return sProperty === sOtherProperty;
210
- }) === iIndex && !/^to_\w+\/\w+/.test(sProperty);
211
+ }) === iIndex;
211
212
  }).forEach(function(oColumn) {
212
213
  oDocumentDescription["TableColumns"].push({
213
214
  "Name": Array.isArray(oColumn.property) ? oColumn.property[0] : oColumn.property,
@@ -221,7 +222,7 @@ sap.ui.define([
221
222
  /**
222
223
  * Returns the name of the EntitySet that is being used with the given OData version.
223
224
  *
224
- * @param {Object} mDataSource DataSource object containing information about OData version
225
+ * @param {object} mDataSource DataSource object containing information about OData version
225
226
  * @returns {string} Name of the EntitySet according to the OData version
226
227
  */
227
228
  PortableDocument.prototype._getEntitySetName = function(mDataSource) {
@@ -233,7 +234,7 @@ sap.ui.define([
233
234
  /**
234
235
  * Returns the specific ODataModel that is being used for binding to the DocumentDescription EntitySet
235
236
  *
236
- * @param {Object} oDataSource DataSource settings of the export configuration
237
+ * @param {object} oDataSource DataSource settings of the export configuration
237
238
  * @returns {ODataModel} ODataModel, either V2 or V4.
238
239
  */
239
240
  PortableDocument.prototype._getModel = function(oDataSource) {
@@ -248,7 +249,7 @@ sap.ui.define([
248
249
  /**
249
250
  * Applies default settings to the export configuration.
250
251
  *
251
- * @param {Object} mSettings Export configuration object
252
+ * @param {object} mSettings Export configuration object
252
253
  * @returns {Promise} Promise that gets resolved when the default settings have been applied
253
254
  */
254
255
  PortableDocument.prototype.setDefaultExportSettings = function(mSettings) {
@@ -272,8 +273,8 @@ sap.ui.define([
272
273
  * DocumentDescription. The corresponding Id is assigned by
273
274
  * the backend and passed to the event handler functions.
274
275
  *
275
- * @param {Object} oDocumentDescription DocumentDescription instance that is being created
276
- * @param {Object} oDataSource DataSource settings of the export configuration
276
+ * @param {object} oDocumentDescription DocumentDescription instance that is being created
277
+ * @param {object} oDataSource DataSource settings of the export configuration
277
278
  *
278
279
  * @returns {Promise} A Promise that resolves with the newly created Id of the DocumentDescription
279
280
  */
@@ -325,7 +326,7 @@ sap.ui.define([
325
326
  * Triggers the export process and returns a Promise the
326
327
  * gets resolved as soon as the export is finished.
327
328
  *
328
- * @param {Object} mSettings Export settings
329
+ * @param {object} mSettings Export settings
329
330
  * @returns {Promise} Promise that is being resolved as soon as the PDF export is finished
330
331
  */
331
332
  PortableDocument.prototype.createBuildPromise = function(mSettings) {
@@ -335,11 +336,11 @@ sap.ui.define([
335
336
  var oResourceBundle = Core.getLibraryResourceBundle('sap.ui.export');
336
337
 
337
338
  oBusyDialog = new sap.m.BusyDialog('PDFExportBusyDialog', {
338
- title: oResourceBundle.getText("PROGRESS_TITLE"),
339
- text: oResourceBundle.getText("PDF_GENERATION_IN_PROGRESS"),
339
+ title: oResourceBundle.getText('PROGRESS_TITLE'),
340
+ text: oResourceBundle.getText('PDF_GENERATION_IN_PROGRESS'),
340
341
  showCancelButton: true,
341
342
  close: function(oEvent) {
342
- if (oEvent.getParameter("cancelPressed")) {
343
+ if (oEvent.getParameter('cancelPressed')) {
343
344
  that.cancel();
344
345
  oBusyDialog.destroy();
345
346
  oBusyDialog = null;
@@ -351,12 +352,13 @@ sap.ui.define([
351
352
 
352
353
  return that.postDocumentDescription(oDocumentDescription, mSettings.dataSource).then(function(sDocumentDescriptionId) {
353
354
  oBusyDialog.open();
355
+
354
356
  return oBusyDialog && that.sendRequest(mSettings.dataSource.dataUrl, sDocumentDescriptionId).then(function(response) {
355
357
  ExportUtils.saveAsFile(response, mSettings.fileName);
356
- oBusyDialog && oBusyDialog.destroy();
357
- }).catch(function(e) {
358
- oBusyDialog && oBusyDialog.destroy();
359
- new sap.m.MessageToast.show("Error during PDF export!");
358
+ oBusyDialog.destroy();
359
+ }).catch(function(oError) {
360
+ oBusyDialog.destroy();
361
+ sap.m.MessageToast.show('Error during PDF export!');
360
362
  });
361
363
  });
362
364
  };
@@ -375,8 +377,8 @@ sap.ui.define([
375
377
  /* Send GET request to receive PDF file */
376
378
  oXHR.open('GET', sUrl);
377
379
  oXHR.responseType = 'blob';
378
- oXHR.setRequestHeader("Accept", "application/pdf");
379
- oXHR.setRequestHeader("SAP-Document-Description-Id", sDocumentDescriptionId);
380
+ oXHR.setRequestHeader('Accept', this.getMimeType());
381
+ oXHR.setRequestHeader('SAP-Document-Description-Id', sDocumentDescriptionId);
380
382
 
381
383
  oXHR.addEventListener('abort', function() {
382
384
  fnReject('Request aborted');
@@ -400,6 +402,15 @@ sap.ui.define([
400
402
  }.bind(this));
401
403
  };
402
404
 
405
+ /**
406
+ * Returns the specific MIME type
407
+ *
408
+ * @returns {string} MIME type for Portable Document Format
409
+ */
410
+ PortableDocument.prototype.getMimeType = function() {
411
+ return 'application/pdf';
412
+ };
413
+
403
414
  /**
404
415
  * Cancels the active request. If the request has not been sent
405
416
  * or the response has been received already, this function has