@sapui5/sap.ui.export 1.124.0 → 1.124.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapui5/sap.ui.export",
3
- "version": "1.124.0",
3
+ "version": "1.124.2",
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-2024 SAP SE. All rights reserved.</copyright>
8
- <version>1.124.0</version>
8
+ <version>1.124.2</version>
9
9
 
10
10
  <documentation>UI5 library: sap.ui.export</documentation>
11
11
 
@@ -27,7 +27,7 @@ sap.ui.define([
27
27
  * @class 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.124.0
30
+ * @version 1.124.2
31
31
  *
32
32
  * @since 1.96
33
33
  * @alias sap.ui.export.ExportBase
@@ -197,8 +197,9 @@ sap.ui.define([
197
197
  * @returns {Promise} Promise that gets resolved once the data has been exported
198
198
  *
199
199
  * @public
200
+ * @async
200
201
  */
201
- ExportBase.prototype.build = function() {
202
+ ExportBase.prototype.build = async function() {
202
203
  var mParameters = this._mSettings;
203
204
 
204
205
  if (this.bIsDestroyed) {
@@ -208,17 +209,15 @@ sap.ui.define([
208
209
  return Promise.reject(sMessage);
209
210
  }
210
211
 
211
- return this.setDefaultExportSettings(mParameters).then(function() {
212
- const bExecuteDefaultAction = this.fireEvent('beforeExport', {exportSettings: mParameters}, true, false);
212
+ await this.setDefaultExportSettings(mParameters);
213
+ const bExecuteDefaultAction = this.fireEvent('beforeExport', {exportSettings: mParameters}, true, false);
213
214
 
214
- if (!bExecuteDefaultAction) {
215
- return Promise.resolve();
216
- }
217
-
218
- ExportUtils.validateSettings(mParameters);
215
+ if (!bExecuteDefaultAction) {
216
+ return Promise.resolve();
217
+ }
219
218
 
220
- return this.createBuildPromise(mParameters);
221
- }.bind(this));
219
+ ExportUtils.validateSettings(mParameters);
220
+ return this.createBuildPromise(mParameters);
222
221
  };
223
222
 
224
223
  return ExportBase;
@@ -18,7 +18,7 @@ sap.ui.define(['./library', './ExportUtils', './ExportDialog', './util/PDFCapabi
18
18
  * @class The <code>sap.ui.export.ExportHandler</code> class allows you to export table data from an SAPUI5 application.
19
19
  *
20
20
  * @author SAP SE
21
- * @version 1.124.0
21
+ * @version 1.124.2
22
22
  *
23
23
  * @since 1.102
24
24
  * @alias sap.ui.export.ExportHandler
@@ -147,7 +147,7 @@ sap.ui.define([
147
147
  * @class Utilities related to export to enable reuse in integration scenarios (e.g. tables).
148
148
  *
149
149
  * @author SAP SE
150
- * @version 1.124.0
150
+ * @version 1.124.2
151
151
  *
152
152
  * @since 1.59
153
153
  * @alias sap.ui.export.ExportUtils
@@ -1228,7 +1228,7 @@ sap.ui.define([
1228
1228
  *
1229
1229
  * @param {object} oContext Context object
1230
1230
  * @param {string} [oContext.application] Name of the application (default: "SAP UI5")
1231
- * @param {string} [oContext.version] Application version (default: "1.124.0")
1231
+ * @param {string} [oContext.version] Application version (default: "1.124.2")
1232
1232
  * @param {string} [oContext.title] Title that will be written to the file (NOT the filename)
1233
1233
  * @param {string} [oContext.modifiedBy] Optional user context that will be written to the file
1234
1234
  * @param {string} [oContext.sheetName] Name of the data sheet - Maximum length of 31 characters
@@ -4,16 +4,16 @@
4
4
  */
5
5
 
6
6
  sap.ui.define([
7
+ './ExportDialog',
8
+ './ExportBase',
9
+ './ExportUtils',
10
+ './library',
11
+ './util/PDFCapabilities',
7
12
  'sap/base/Log',
8
13
  'sap/ui/base/Object',
9
- 'sap/ui/export/ExportBase',
10
- 'sap/ui/export/ExportUtils',
11
- 'sap/ui/export/library',
12
- 'sap/ui/export/util/PDFCapabilities',
13
14
  'sap/ui/model/odata/v4/ODataModel',
14
- './ExportDialog',
15
15
  'sap/m/BusyDialog'
16
- ], function(Log, BaseObject, ExportBase, ExportUtils, Library, PDFCapabilities, ODataModel, ExportDialog, BusyDialog) {
16
+ ], function(ExportDialog, ExportBase, ExportUtils, Library, PDFCapabilities, Log, BaseObject, ODataModel, BusyDialog) {
17
17
  'use strict';
18
18
 
19
19
  const FileType = Library.FileType;
@@ -24,7 +24,7 @@ sap.ui.define([
24
24
  * @class 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.
25
25
  *
26
26
  * @author SAP SE
27
- * @version 1.124.0
27
+ * @version 1.124.2
28
28
  *
29
29
  * @since 1.96
30
30
  * @alias sap.ui.export.PortableDocument
@@ -203,11 +203,15 @@ sap.ui.define([
203
203
  if (oMetaInfo instanceof Array) {
204
204
  oMetaInfo.forEach(function(oGroup) {
205
205
  if (iODataVersion === 2) {
206
+ const truncateString = (sValue) => {
207
+ return sValue.length > 256 ? sValue.substring(0, 253) + '...' : sValue;
208
+ };
209
+
206
210
  oGroup.items.forEach(function(oItem) {
207
211
  const oCoverPageGroup = {
208
212
  "Title": oGroup.name,
209
213
  "Name": oItem.key,
210
- "Value": oItem.value
214
+ "Value": truncateString(oItem.value)
211
215
  };
212
216
  oDocumentDescription["CoverPage"].push(oCoverPageGroup);
213
217
  });
@@ -374,6 +378,33 @@ sap.ui.define([
374
378
  return oWarningPromise;
375
379
  };
376
380
 
381
+ /**
382
+ * Evaluates the error message from the given error parameter and shows it in a dialog.
383
+ *
384
+ * @param {string|object|Blob} vError Error object that is provided
385
+ * @returns {Promise} Shows the error message in a dialog and resolves automatically
386
+ */
387
+ PortableDocument.showErrorMessage = async (vError) => {
388
+ const oResourceBundle = await ExportUtils.getResourceBundle();
389
+
390
+ /* Handle ignore Promise rejection due to cancellation by the user */
391
+ if (!vError) {
392
+ return;
393
+ }
394
+
395
+ if (typeof vError.text === 'function') {
396
+ vError.text()
397
+ .then(function(sError) {
398
+ ExportDialog.showErrorMessage(sError);
399
+ })
400
+ .catch(function() {
401
+ ExportDialog.showErrorMessage(oResourceBundle.getText('PDF_GENERIC_ERROR'));
402
+ });
403
+ } else if (vError.message) {
404
+ ExportDialog.showErrorMessage(vError.message);
405
+ }
406
+ };
407
+
377
408
  /**
378
409
  * Adds the ResultSizeMaximum from the com.sap.vocabularies.PDF.v1.Features
379
410
  * annotation as $top to the data URL. If this property is not available on
@@ -489,16 +520,16 @@ sap.ui.define([
489
520
  * @private
490
521
  */
491
522
  PortableDocument.prototype.createBuildPromise = async function(mSettings) {
492
- const that = this;
493
523
  const oResourceBundle = await ExportUtils.getResourceBundle();
524
+ const oDocumentDescription = this._createDocumentDescription(mSettings);
494
525
 
495
526
  let oBusyDialog = new BusyDialog('PDFExportBusyDialog', {
496
527
  title: oResourceBundle.getText('PROGRESS_TITLE'),
497
528
  text: oResourceBundle.getText('PDF_GENERATION_IN_PROGRESS'),
498
529
  showCancelButton: true,
499
- close: function(oEvent) {
530
+ close: (oEvent) => {
500
531
  if (oEvent.getParameter('cancelPressed')) {
501
- that.cancel();
532
+ this.cancel();
502
533
  }
503
534
 
504
535
  oBusyDialog.destroy();
@@ -506,32 +537,20 @@ sap.ui.define([
506
537
  }
507
538
  });
508
539
 
509
- const oDocumentDescription = that._createDocumentDescription(mSettings);
510
540
  oBusyDialog.open();
511
541
 
512
- return this._showWarning(mSettings).then(function() {
513
- return that.postDocumentDescription(oDocumentDescription, mSettings.dataSource);
514
- }).then(function(sDocumentDescriptionId) {
515
- return oBusyDialog && that.sendRequest(mSettings.dataSource.dataUrl, sDocumentDescriptionId);
516
- }).then(function(response) {
542
+ try {
543
+ await this._showWarning(mSettings);
544
+ const sDocumentDescriptionId = await this.postDocumentDescription(oDocumentDescription, mSettings.dataSource);
545
+ const response = await this.sendRequest(mSettings.dataSource.dataUrl, sDocumentDescriptionId);
546
+
517
547
  ExportUtils.saveAsFile(response, mSettings.fileName);
518
548
  ExportUtils.announceExportStatus(Status.FINISHED);
519
- }).catch(function(oError) {
520
- /* Handle ignore Promise rejection due to cancellation by the user */
521
- if (!oError) {
522
- return;
523
- }
549
+ } catch (oError) {
550
+ PortableDocument.showErrorMessage(oError);
551
+ }
524
552
 
525
- oError.text()
526
- .then(function(sError) {
527
- ExportDialog.showErrorMessage(sError);
528
- })
529
- .catch(function() {
530
- ExportDialog.showErrorMessage(oResourceBundle.getText('PDF_GENERIC_ERROR'));
531
- });
532
- }).finally(function() {
533
- oBusyDialog?.close();
534
- });
553
+ oBusyDialog?.destroy();
535
554
  };
536
555
 
537
556
  /**
@@ -85,7 +85,7 @@ sap.ui.define([
85
85
  * <li><code>workbook.context</code> - Context object that will be applied to the generated file. It may contain the following fields:</li>
86
86
  * <ul>
87
87
  * <li><code>application</code> (string) - The application that creates the XLSX document (default: "SAP UI5")</li>
88
- * <li><code>version</code> (string) - Application version that creates the XLSX document (default: "1.124.0")</li>
88
+ * <li><code>version</code> (string) - Application version that creates the XLSX document (default: "1.124.2")</li>
89
89
  * <li><code>title</code> (string) - Title of the XLSX document (NOT the filename)</li>
90
90
  * <li><code>modifiedBy</code> (string) - User context for the XLSX document</li>
91
91
  * <li><code>sheetName</code> (string) - The label of the data sheet</li>
@@ -169,7 +169,7 @@ sap.ui.define([
169
169
  * columns: aColumns,
170
170
  * context: {
171
171
  * application: 'Debug Test Application',
172
- * version: '1.124.0',
172
+ * version: '1.124.2',
173
173
  * title: 'Some random title',
174
174
  * modifiedBy: 'John Doe',
175
175
  * metaSheetName: 'Custom metadata',
@@ -281,7 +281,7 @@ sap.ui.define([
281
281
  * @class The <code>sap.ui.export.Spreadsheet</code> class allows you to export table data from a UI5 application to a spreadsheet file.
282
282
  *
283
283
  * @author SAP SE
284
- * @version 1.124.0
284
+ * @version 1.124.2
285
285
  *
286
286
  * @since 1.50
287
287
  * @alias sap.ui.export.Spreadsheet
@@ -21,7 +21,7 @@ sap.ui.define(['sap/base/Log', 'sap/ui/export/ExportUtils'], function(Log, Expor
21
21
  * Utility class to perform spreadsheet export.
22
22
  *
23
23
  * @author SAP SE
24
- * @version 1.124.0
24
+ * @version 1.124.2
25
25
  *
26
26
  * @alias sap.ui.export.SpreadsheetExport
27
27
  * @private
@@ -15,7 +15,7 @@ sap.ui.define(["sap/ui/core/Lib"], function(Library) {
15
15
  * @namespace
16
16
  * @alias sap.ui.export
17
17
  * @author SAP SE
18
- * @version 1.124.0
18
+ * @version 1.124.2
19
19
  * @public
20
20
  */
21
21
 
@@ -33,7 +33,7 @@ sap.ui.define(["sap/ui/core/Lib"], function(Library) {
33
33
  interfaces: [],
34
34
  controls: [],
35
35
  elements: [],
36
- version: "1.124.0"
36
+ version: "1.124.2"
37
37
  });
38
38
 
39
39
  /**
@@ -24,7 +24,7 @@
24
24
  * @param {object} mSettings Data service related part of the export configuration
25
25
  *
26
26
  * @author SAP SE
27
- * @version 1.124.0
27
+ * @version 1.124.2
28
28
  *
29
29
  * @constructor
30
30
  * @class DataProviderBase
@@ -20,7 +20,7 @@ sap.ui.define(['sap/ui/base/Object'], function(BaseObject) {
20
20
  * convenience functions like <code>sap.ui.export.util.Filter#setType</code> to improve the result.
21
21
  *
22
22
  * @author SAP SE
23
- * @version 1.124.0
23
+ * @version 1.124.2
24
24
  *
25
25
  * @since 1.110
26
26
  * @alias sap.ui.export.util.Filter