@openui5/sap.ui.dt 1.97.1 → 1.100.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 (47) hide show
  1. package/.reuse/dep5 +25 -30
  2. package/THIRDPARTY.txt +15 -22
  3. package/package.json +2 -2
  4. package/src/sap/ui/dt/.library +1 -1
  5. package/src/sap/ui/dt/AggregationDesignTimeMetadata.js +1 -1
  6. package/src/sap/ui/dt/AggregationOverlay.js +2 -1
  7. package/src/sap/ui/dt/ControlObserver.js +1 -1
  8. package/src/sap/ui/dt/DOMUtil.js +3 -6
  9. package/src/sap/ui/dt/DesignTime.js +38 -15
  10. package/src/sap/ui/dt/DesignTimeMetadata.js +6 -7
  11. package/src/sap/ui/dt/ElementDesignTimeMetadata.js +3 -3
  12. package/src/sap/ui/dt/ElementOverlay.js +3 -1
  13. package/src/sap/ui/dt/ElementUtil.js +6 -8
  14. package/src/sap/ui/dt/ManagedObjectObserver.js +1 -1
  15. package/src/sap/ui/dt/MetadataPropagationUtil.js +3 -4
  16. package/src/sap/ui/dt/MutationObserver.js +1 -1
  17. package/src/sap/ui/dt/Overlay.js +39 -38
  18. package/src/sap/ui/dt/OverlayRegistry.js +3 -6
  19. package/src/sap/ui/dt/OverlayUtil.js +4 -5
  20. package/src/sap/ui/dt/Plugin.js +30 -1
  21. package/src/sap/ui/dt/ScrollbarSynchronizer.js +2 -2
  22. package/src/sap/ui/dt/SelectionManager.js +2 -2
  23. package/src/sap/ui/dt/SelectionMode.js +1 -1
  24. package/src/sap/ui/dt/TaskManager.js +57 -42
  25. package/src/sap/ui/dt/TaskRunner.js +15 -15
  26. package/src/sap/ui/dt/Util.js +4 -7
  27. package/src/sap/ui/dt/enablement/ElementEnablementTest.js +1 -1
  28. package/src/sap/ui/dt/enablement/Test.js +5 -4
  29. package/src/sap/ui/dt/enablement/Util.js +1 -1
  30. package/src/sap/ui/dt/enablement/libraryTest.js +1 -1
  31. package/src/sap/ui/dt/enablement/report/LibraryReport.js +1 -1
  32. package/src/sap/ui/dt/enablement/report/QUnitReport.js +1 -1
  33. package/src/sap/ui/dt/enablement/report/Statistic.js +1 -1
  34. package/src/sap/ui/dt/enablement/report/StatisticRenderer.js +2 -2
  35. package/src/sap/ui/dt/enablement/report/Table.js +2 -2
  36. package/src/sap/ui/dt/enablement/report/TableRenderer.js +2 -2
  37. package/src/sap/ui/dt/library.js +2 -2
  38. package/src/sap/ui/dt/plugin/ContextMenu.js +1 -1
  39. package/src/sap/ui/dt/plugin/ControlDragDrop.js +1 -1
  40. package/src/sap/ui/dt/plugin/CutPaste.js +1 -1
  41. package/src/sap/ui/dt/plugin/DragDrop.js +1 -1
  42. package/src/sap/ui/dt/plugin/ElementMover.js +2 -2
  43. package/src/sap/ui/dt/plugin/MouseSelection.js +1 -1
  44. package/src/sap/ui/dt/plugin/TabHandling.js +1 -1
  45. package/src/sap/ui/dt/plugin/ToolHooks.js +1 -1
  46. package/src/sap/ui/dt/themes/base/ContextMenu.less +1 -0
  47. package/src/sap/ui/dt/util/ZIndexManager.js +2 -3
@@ -15,7 +15,7 @@ sap.ui.define([
15
15
  "sap/ui/dt/Util",
16
16
  "sap/base/Log",
17
17
  "sap/ui/dt/util/ZIndexManager"
18
- ], function (
18
+ ], function(
19
19
  jQuery,
20
20
  Element,
21
21
  MutationObserver,
@@ -44,7 +44,7 @@ sap.ui.define([
44
44
  * @extends sap.ui.core.Element
45
45
  *
46
46
  * @author SAP SE
47
- * @version 1.97.1
47
+ * @version 1.100.0
48
48
  *
49
49
  * @constructor
50
50
  * @private
@@ -189,7 +189,7 @@ sap.ui.define([
189
189
  }
190
190
  }
191
191
  },
192
- constructor: function () {
192
+ constructor: function() {
193
193
  this._aStyleClasses = this._aStyleClasses.slice(0);
194
194
  this._oScrollbarSynchronizers = new Map();
195
195
  this._aBindParameters = [];
@@ -207,7 +207,7 @@ sap.ui.define([
207
207
  }
208
208
 
209
209
  this.asyncInit()
210
- .then(function () {
210
+ .then(function() {
211
211
  // Can happen that destroy() is called during asynchronous initialization
212
212
  if (this._bShouldBeDestroyed) {
213
213
  this.fireInitFailed({
@@ -238,9 +238,9 @@ sap.ui.define([
238
238
  }.bind(this));
239
239
 
240
240
  // Attach stored browser events
241
- this.attachEventOnce("afterRendering", function (oEvent) {
241
+ this.attachEventOnce("afterRendering", function(oEvent) {
242
242
  var $DomRef = jQuery(oEvent.getParameter("domRef"));
243
- this._aBindParameters.forEach(function (mBrowserEvent) {
243
+ this._aBindParameters.forEach(function(mBrowserEvent) {
244
244
  $DomRef.on(mBrowserEvent.sEventType, mBrowserEvent.fnProxy);
245
245
  });
246
246
  }, this);
@@ -335,7 +335,7 @@ sap.ui.define([
335
335
  // Prototype methods
336
336
  // ========================================================
337
337
 
338
- Overlay.prototype.asyncInit = function () {
338
+ Overlay.prototype.asyncInit = function() {
339
339
  return Promise.resolve();
340
340
  };
341
341
 
@@ -344,7 +344,7 @@ sap.ui.define([
344
344
  * @returns {{id: string, "data-sap-ui": string, class: string, tabindex: *}} Object with attributes
345
345
  * @protected
346
346
  */
347
- Overlay.prototype._getAttributes = function () {
347
+ Overlay.prototype._getAttributes = function() {
348
348
  return {
349
349
  id: this.getId(),
350
350
  "data-sap-ui": this.getId(),
@@ -353,14 +353,14 @@ sap.ui.define([
353
353
  };
354
354
  };
355
355
 
356
- Overlay.prototype._renderChildren = function () {
357
- return this.getChildren().map(function (oChild) {
356
+ Overlay.prototype._renderChildren = function() {
357
+ return this.getChildren().map(function(oChild) {
358
358
  // If a rendered element is being moved to a parent that was just created, it should not be rendered again
359
359
  return oChild.isRendered() ? oChild.$() : oChild.render();
360
360
  });
361
361
  };
362
362
 
363
- Overlay.prototype.render = function (bSuppressEvent) {
363
+ Overlay.prototype.render = function(bSuppressEvent) {
364
364
  if (this.isRendered()) {
365
365
  return this.getDomRef();
366
366
  }
@@ -384,20 +384,20 @@ sap.ui.define([
384
384
  return this._$DomRef;
385
385
  };
386
386
 
387
- Overlay.prototype.isInit = function () {
387
+ Overlay.prototype.isInit = function() {
388
388
  return this._bInit;
389
389
  };
390
390
 
391
- Overlay.prototype.isRendered = function () {
391
+ Overlay.prototype.isRendered = function() {
392
392
  return this._bRendered;
393
393
  };
394
394
 
395
- Overlay.prototype.isReady = function () {
395
+ Overlay.prototype.isReady = function() {
396
396
  return this.isInit() && this.isRendered();
397
397
  };
398
398
 
399
399
 
400
- Overlay.prototype.addStyleClass = function (sClassName) {
400
+ Overlay.prototype.addStyleClass = function(sClassName) {
401
401
  if (!this.hasStyleClass(sClassName)) {
402
402
  this._aStyleClasses.push(sClassName);
403
403
  if (this.isReady()) {
@@ -406,13 +406,13 @@ sap.ui.define([
406
406
  }
407
407
  };
408
408
 
409
- Overlay.prototype.hasStyleClass = function (sClassName) {
409
+ Overlay.prototype.hasStyleClass = function(sClassName) {
410
410
  return this._aStyleClasses.indexOf(sClassName) !== -1;
411
411
  };
412
412
 
413
- Overlay.prototype.removeStyleClass = function (sClassName) {
413
+ Overlay.prototype.removeStyleClass = function(sClassName) {
414
414
  if (this.hasStyleClass(sClassName)) {
415
- this._aStyleClasses = this._aStyleClasses.filter(function (sItem) {
415
+ this._aStyleClasses = this._aStyleClasses.filter(function(sItem) {
416
416
  return sItem !== sClassName;
417
417
  });
418
418
  if (this.isReady()) {
@@ -421,11 +421,11 @@ sap.ui.define([
421
421
  }
422
422
  };
423
423
 
424
- Overlay.prototype.toggleStyleClass = function (sClassName) {
424
+ Overlay.prototype.toggleStyleClass = function(sClassName) {
425
425
  this[(this.hasStyleClass(sClassName) ? "remove" : "add") + "StyleClass"](sClassName);
426
426
  };
427
427
 
428
- Overlay.prototype.setElement = function (vElement) {
428
+ Overlay.prototype.setElement = function(vElement) {
429
429
  if (!this.getElement()) {
430
430
  this.setAssociation("element", vElement);
431
431
  if (this._designTimeMetadataCache) {
@@ -435,7 +435,7 @@ sap.ui.define([
435
435
  }
436
436
  };
437
437
 
438
- Overlay.prototype.destroy = function () {
438
+ Overlay.prototype.destroy = function() {
439
439
  if (this.bIsDestroyed) {
440
440
  Log.error("FIXME: Do not destroy overlay twice (overlayId = " + this.getId() + ")!");
441
441
  return;
@@ -451,7 +451,7 @@ sap.ui.define([
451
451
  * @protected
452
452
  */
453
453
  Overlay.prototype.exit = function() {
454
- this._oScrollbarSynchronizers.forEach(function (oScrollbarSynchronizer) {
454
+ this._oScrollbarSynchronizers.forEach(function(oScrollbarSynchronizer) {
455
455
  oScrollbarSynchronizer.destroy();
456
456
  });
457
457
  this._oScrollbarSynchronizers.clear();
@@ -464,7 +464,7 @@ sap.ui.define([
464
464
  this.fireDestroyed();
465
465
  };
466
466
 
467
- Overlay.prototype.setDesignTimeMetadata = function (vMetadata) {
467
+ Overlay.prototype.setDesignTimeMetadata = function(vMetadata) {
468
468
  if (!this.getElement()) {
469
469
  this._designTimeMetadataCache = vMetadata;
470
470
  } else {
@@ -481,7 +481,7 @@ sap.ui.define([
481
481
  return this.$().get(0);
482
482
  };
483
483
 
484
- Overlay.prototype.getChildrenDomRef = function () {
484
+ Overlay.prototype.getChildrenDomRef = function() {
485
485
  return this._$Children.get(0);
486
486
  };
487
487
 
@@ -490,7 +490,7 @@ sap.ui.define([
490
490
  * @return {jQuery} - jQuery with DOM Element inside
491
491
  * @public
492
492
  */
493
- Overlay.prototype.$ = function () {
493
+ Overlay.prototype.$ = function() {
494
494
  return this._$DomRef || jQuery();
495
495
  };
496
496
 
@@ -518,7 +518,7 @@ sap.ui.define([
518
518
  * @return {sap.ui.Element} associated Element
519
519
  * @public
520
520
  */
521
- Overlay.prototype.getElement = function () {
521
+ Overlay.prototype.getElement = function() {
522
522
  return ElementUtil.getElementInstance(this.getAssociation("element"));
523
523
  };
524
524
 
@@ -563,7 +563,7 @@ sap.ui.define([
563
563
  * @returns {jQuery|null} Parent jQuery object or null, if there is none
564
564
  * @protected
565
565
  */
566
- Overlay.prototype._getRenderingParent = function () {
566
+ Overlay.prototype._getRenderingParent = function() {
567
567
  return this.isRoot() ? null : this.getParent().$();
568
568
  };
569
569
 
@@ -575,7 +575,7 @@ sap.ui.define([
575
575
  * @returns {Promise} Resolves as soon as <code>applyStyles</code> is done
576
576
  * @public
577
577
  */
578
- Overlay.prototype.applyStyles = function (bForceScrollbarSync) {
578
+ Overlay.prototype.applyStyles = function(bForceScrollbarSync) {
579
579
  this.fireBeforeGeometryChanged();
580
580
 
581
581
  if (!this.isRendered() || this._bIsBeingDestroyed || this.getShouldBeDestroyed()) {
@@ -595,7 +595,7 @@ sap.ui.define([
595
595
  this.getParent()._oScrollbarSynchronizers.forEach(function(oScrollbarSynchronizer) {
596
596
  if (oScrollbarSynchronizer.isSyncing()) {
597
597
  aPromises.push(
598
- new Promise(function (fnResolve) {
598
+ new Promise(function(fnResolve) {
599
599
  oScrollbarSynchronizer.attachEventOnce("synced", fnResolve);
600
600
  oScrollbarSynchronizer.attachEventOnce("destroyed", fnResolve);
601
601
  })
@@ -603,7 +603,7 @@ sap.ui.define([
603
603
  }
604
604
  });
605
605
  if (aPromises.length) {
606
- oGeometryChangedPromise = Promise.all(aPromises).then(function () {
606
+ oGeometryChangedPromise = Promise.all(aPromises).then(function() {
607
607
  return this._applySizes(oGeometry, $RenderingParent, bForceScrollbarSync);
608
608
  }.bind(this));
609
609
  } else {
@@ -621,31 +621,31 @@ sap.ui.define([
621
621
 
622
622
  // TODO: refactor geometryChanged event
623
623
  return oGeometryChangedPromise
624
- .catch(function (vError) {
624
+ .catch(function(vError) {
625
625
  Log.error(Util.createError(
626
626
  "Overlay#applyStyles",
627
627
  "Error occured during applySizes calculation: " + vError
628
628
  ));
629
629
  })
630
- .then(function () {
630
+ .then(function() {
631
631
  this.fireGeometryChanged();
632
632
  }.bind(this));
633
633
  };
634
634
 
635
- Overlay.prototype._applySizes = function (oGeometry, $RenderingParent, bForceScrollbarSync) {
635
+ Overlay.prototype._applySizes = function(oGeometry, $RenderingParent, bForceScrollbarSync) {
636
636
  this._setPosition(this.$(), oGeometry, $RenderingParent, bForceScrollbarSync);
637
637
  if (oGeometry.domRef) {
638
638
  this._setZIndex(oGeometry, this.$());
639
639
  }
640
640
  // We need to know when all our children have correct positions
641
641
  var aPromises = this.getChildren()
642
- .filter(function (oChild) {
642
+ .filter(function(oChild) {
643
643
  return oChild.isRendered();
644
644
  })
645
645
  .map(function(oChild) {
646
646
  var mParameters = {};
647
647
  mParameters.bForceScrollbarSync = bForceScrollbarSync;
648
- return new Promise(function (fnResolve) {
648
+ return new Promise(function(fnResolve) {
649
649
  oChild.attachEventOnce("geometryChanged", fnResolve);
650
650
  oChild.fireApplyStylesRequired(mParameters);
651
651
  });
@@ -661,7 +661,7 @@ sap.ui.define([
661
661
  * @param {object} oGeometry - Geometry object to get reference z-index from
662
662
  * @param {jQuery} $overlayDomRef - DOM element to receive the z-index
663
663
  */
664
- Overlay.prototype._setZIndex = function (oGeometry, $overlayDomRef) {
664
+ Overlay.prototype._setZIndex = function(oGeometry, $overlayDomRef) {
665
665
  var oOriginalDomRef = oGeometry.domRef;
666
666
  var iZIndex = DOMUtil.getZIndex(oOriginalDomRef);
667
667
  if (Util.isInteger(iZIndex)) {
@@ -779,7 +779,7 @@ sap.ui.define([
779
779
  this._oScrollbarSynchronizers.delete($TargetDomRef.get(0));
780
780
  if (
781
781
  oTargetOverlay._oScrollbarSynchronizers.size === 0
782
- && !oTargetOverlay.getChildren().some(function (oAggregationOverlay) {
782
+ && !oTargetOverlay.getChildren().some(function(oAggregationOverlay) {
783
783
  return oAggregationOverlay._oScrollbarSynchronizers.size > 0;
784
784
  })
785
785
  ) {
@@ -906,6 +906,7 @@ sap.ui.define([
906
906
  bVisible = !!bVisible;
907
907
  if (this.getVisible() !== bVisible) {
908
908
  this.setProperty("visible", bVisible);
909
+ this.$().css("visibility", bVisible ? "" : "hidden");
909
910
  this.fireVisibleChanged({
910
911
  visible: bVisible
911
912
  });
@@ -924,7 +925,7 @@ sap.ui.define([
924
925
  );
925
926
  };
926
927
 
927
- Overlay.prototype.setIsRoot = function (bValue) {
928
+ Overlay.prototype.setIsRoot = function(bValue) {
928
929
  bValue = !!bValue;
929
930
 
930
931
  if (this.getIsRoot() !== bValue) {
@@ -19,16 +19,13 @@ function(
19
19
  "use strict";
20
20
 
21
21
  /**
22
- * Class for OverlayRegistry.
23
- *
24
- * @class
25
- * Static registry for Overlays
22
+ * Static registry for Overlays.
26
23
  *
24
+ * @namespace
27
25
  * @author SAP SE
28
- * @version 1.97.1
26
+ * @version 1.100.0
29
27
  *
30
28
  * @private
31
- * @static
32
29
  * @since 1.30
33
30
  * @alias sap.ui.dt.OverlayRegistry
34
31
  * @experimental Since 1.30. This class is experimental and provides only limited functionality. Also the API might be changed in future.
@@ -18,13 +18,12 @@ function(
18
18
  "use strict";
19
19
 
20
20
  /**
21
- * Class for Overlay Util.
21
+ * Utility functionality to work with overlays.
22
22
  *
23
- * @class Utility functionality to work with overlays
23
+ * @namespace
24
24
  * @author SAP SE
25
- * @version 1.97.1
25
+ * @version 1.100.0
26
26
  * @private
27
- * @static
28
27
  * @since 1.30
29
28
  * @alias sap.ui.dt.OverlayUtil
30
29
  * @experimental Since 1.30. This class is experimental and provides only limited functionality. Also the API might be changed in future.
@@ -644,7 +643,7 @@ function(
644
643
  /**
645
644
  * The AggregationBindingInfo contains the overlay ID and the aggregation name of the bound control together with stack containing
646
645
  * information about the traversed elements for an overlay which is part of an aggregation binding.
647
- * @typedef {Object} sap.ui.dt.OverlayUtil.AggregationBindingInfo
646
+ * @typedef {object} sap.ui.dt.OverlayUtil.AggregationBindingInfo
648
647
  * @property {string} overlayId - ID of the bound overlay that contains binding aggregation template overlays
649
648
  * @property {string} aggregation - Name of the bound aggregation
650
649
  * @property {Object[]} stack - Array of objects containing element, element type, aggregation name, and index of the element in
@@ -26,7 +26,7 @@ function(
26
26
  * @extends sap.ui.base.ManagedObject
27
27
  *
28
28
  * @author SAP SE
29
- * @version 1.97.1
29
+ * @version 1.100.0
30
30
  *
31
31
  * @constructor
32
32
  * @private
@@ -64,6 +64,8 @@ function(
64
64
 
65
65
  Plugin.prototype._bProcessingCounter = 0;
66
66
 
67
+ Plugin.prototype._oBusyPromise = {};
68
+
67
69
  /**
68
70
  * Called when the Plugin is initialized
69
71
  * @protected
@@ -236,6 +238,33 @@ function(
236
238
  */
237
239
  Plugin.prototype.isBusy = Plugin.prototype.getBusy;
238
240
 
241
+ /**
242
+ * Setter for the busy property. Sets a promise internally to be able to wait for a busy plugin
243
+ *
244
+ * @param {boolean} bBusy - Value for the busy state
245
+ * @returns {this} Returns <code>this</code>
246
+ */
247
+ Plugin.prototype.setBusy = function(bBusy) {
248
+ if (bBusy && !this.getBusy()) {
249
+ this._oBusyPromise.promise = new Promise(function(resolve) {
250
+ this._oBusyPromise.resolveFunction = resolve;
251
+ }.bind(this));
252
+ } else if (!bBusy && this.getBusy() && this._oBusyPromise.resolveFunction) {
253
+ this._oBusyPromise.resolveFunction();
254
+ }
255
+ this.setProperty("busy", bBusy);
256
+ return this;
257
+ };
258
+
259
+ /**
260
+ * Waits for the busy promise and resolves as soon as the plugin is not busy anymore
261
+ *
262
+ * @returns {Promise<undefined>} Resolves with undefined
263
+ */
264
+ Plugin.prototype.waitForBusyAction = function() {
265
+ return this._oBusyPromise.promise || Promise.resolve();
266
+ };
267
+
239
268
  /**
240
269
  * @param {boolean} bProcessing - processing state to set
241
270
  */
@@ -24,7 +24,7 @@ function(
24
24
  * @extends sap.ui.base.ManagedObject
25
25
  *
26
26
  * @author SAP SE
27
- * @version 1.97.1
27
+ * @version 1.100.0
28
28
  *
29
29
  * @constructor
30
30
  * @private
@@ -116,7 +116,7 @@ function(
116
116
  /**
117
117
  * Check if a Dom Node is a target for this Scrollbar Synchronizer
118
118
  * @param {Element} oDomNode Element to be checked
119
- * @return {Boolean} Returns true if the node is a target
119
+ * @return {boolean} Returns true if the node is a target
120
120
  */
121
121
  ScrollbarSynchronizer.prototype.hasTarget = function (oDomNode) {
122
122
  return this.getTargets().indexOf(oDomNode) > -1;
@@ -34,7 +34,7 @@ function (
34
34
  * @extends sap.ui.base.ManagedObject
35
35
  *
36
36
  * @author SAP SE
37
- * @version 1.97.1
37
+ * @version 1.100.0
38
38
  *
39
39
  * @constructor
40
40
  * @private
@@ -118,7 +118,7 @@ function (
118
118
 
119
119
  /**
120
120
  * Replaces current selection with specified list of overlays/controls.
121
- * @param {sap.ui.dt.ElementOverlay|sap.ui.dt.ElementOverlay[]|sap.ui.core.Control|sap.ui.core.Control[]} vSelection
121
+ * @param {sap.ui.dt.ElementOverlay|sap.ui.dt.ElementOverlay[]|sap.ui.core.Control|sap.ui.core.Control[]} vObjects
122
122
  * Objects which should be selected can be:
123
123
  * - a single overlay
124
124
  * - an array of overlays
@@ -16,7 +16,7 @@ sap.ui.define(function() {
16
16
  * @namespace
17
17
  * @name sap.ui.dt.SelectionMode
18
18
  * @author SAP SE
19
- * @version 1.97.1
19
+ * @version 1.100.0
20
20
  * @experimental This class is experimental and provides only limited functionality. Also the API might be changed in future.
21
21
  * @private
22
22
  */
@@ -21,7 +21,7 @@ function(
21
21
  * The TaskManager keeps list of task and allows to manage them via simple API.
22
22
  *
23
23
  * @author SAP SE
24
- * @version 1.97.1
24
+ * @version 1.100.0
25
25
  *
26
26
  * @constructor
27
27
  * @private
@@ -65,7 +65,7 @@ function(
65
65
  _iTaskCounter: 0
66
66
  });
67
67
 
68
- TaskManager.prototype._validateTask = function(mTask) {
68
+ function validateTask(mTask) {
69
69
  if (
70
70
  !isPlainObject(mTask)
71
71
  || !mTask.type
@@ -73,35 +73,50 @@ function(
73
73
  ) {
74
74
  throw new Error("Invalid task specified");
75
75
  }
76
- };
76
+ }
77
77
 
78
- TaskManager.prototype._removeOutdatedTasks = function(mTask, vDoubleIdentifier) {
79
- if (vDoubleIdentifier) {
80
- var fnDoubleIdentifier;
81
- if (typeof vDoubleIdentifier === "string") {
82
- fnDoubleIdentifier = function (mTask) { return mTask[vDoubleIdentifier]; };
83
- } else if (typeof vDoubleIdentifier === "function") {
84
- fnDoubleIdentifier = vDoubleIdentifier;
85
- } else {
86
- throw new Error("Validator needs to be a function or a string");
87
- }
88
- var aTaskList = this._mQueuedTasks[mTask.type];
89
- var sNewTaskIdentifier = fnDoubleIdentifier(mTask);
90
- if (
91
- aTaskList
92
- && sNewTaskIdentifier
93
- ) {
94
- this._mQueuedTasks[mTask.type] = aTaskList.filter(function (oTask) {
95
- if (fnDoubleIdentifier(oTask) === sNewTaskIdentifier) {
96
- this._iTaskCounter--;
97
- return false;
98
- }
99
- return true;
100
- }.bind(this));
78
+ function getTaskIdentifierFunction(vTaskIdentifier) {
79
+ var fnTaskIdentifier;
80
+ if (typeof vTaskIdentifier === "string") {
81
+ fnTaskIdentifier = function (mTask) { return mTask[vTaskIdentifier]; };
82
+ } else if (typeof vTaskIdentifier === "function") {
83
+ fnTaskIdentifier = vTaskIdentifier;
84
+ } else {
85
+ throw new Error("Validator needs to be a function or a string");
86
+ }
87
+ return fnTaskIdentifier;
88
+ }
89
+
90
+ function filterTasks(fnTaskIdentifier, sNewTaskIdentifier, oTask) {
91
+ if (fnTaskIdentifier(oTask) === sNewTaskIdentifier) {
92
+ this._iTaskCounter--;
93
+ return false;
94
+ }
95
+ return true;
96
+ }
97
+
98
+ TaskManager.prototype._removeTasksByIdentifier = function(mTask, vTaskIdentifier, sListName) {
99
+ if (vTaskIdentifier) {
100
+ var fnTaskIdentifier = getTaskIdentifierFunction(vTaskIdentifier);
101
+ var sNewTaskIdentifier = fnTaskIdentifier(mTask);
102
+ if (this[sListName][mTask.type] && sNewTaskIdentifier) {
103
+ this[sListName][mTask.type] = this[sListName][mTask.type].filter(filterTasks.bind(this, fnTaskIdentifier, sNewTaskIdentifier));
101
104
  }
102
105
  }
103
106
  };
104
107
 
108
+ TaskManager.prototype._removeTaskById = function (iTaskId, sListName) {
109
+ Object.keys(this[sListName]).forEach(function (sTypeName) {
110
+ this[sListName][sTypeName] = this[sListName][sTypeName].filter(function (mTask) {
111
+ if (mTask.id === iTaskId) {
112
+ this._iTaskCounter--;
113
+ return false;
114
+ }
115
+ return true;
116
+ }.bind(this));
117
+ }, this);
118
+ };
119
+
105
120
  TaskManager.prototype._addTask = function(mTask) {
106
121
  var iTaskId = this._iNextId++;
107
122
  this._mQueuedTasks[mTask.type] = this._mQueuedTasks[mTask.type] || [];
@@ -127,29 +142,16 @@ function(
127
142
  * @return {number} Task ID
128
143
  */
129
144
  TaskManager.prototype.add = function (mTask, vDoubleIdentifier) {
130
- this._validateTask(mTask);
131
- this._removeOutdatedTasks(mTask, vDoubleIdentifier);
145
+ validateTask(mTask);
146
+ this._removeTasksByIdentifier(mTask, vDoubleIdentifier, "_mQueuedTasks");
132
147
  return this._addTask(mTask);
133
148
  };
134
149
 
135
- TaskManager.prototype._removeTaskById = function (iTaskId, sListName) {
136
- Object.keys(this[sListName]).forEach(function (sTypeName) {
137
- this[sListName][sTypeName] = this[sListName][sTypeName].filter(function (mTask) {
138
- if (mTask.id === iTaskId) {
139
- this._iTaskCounter--;
140
- return false;
141
- }
142
- return true;
143
- }.bind(this));
144
- }, this);
145
- };
146
-
147
150
  /**
148
151
  * Completes the task by its ID
149
152
  * @param {number} iTaskId - Task ID
150
153
  */
151
154
  TaskManager.prototype.complete = function (iTaskId) {
152
- // TODO: performance improvements?
153
155
  this._removeTaskById(iTaskId, "_mQueuedTasks");
154
156
  this._removeTaskById(iTaskId, "_mPendingTasks");
155
157
  if (!this.getSuppressEvents()) {
@@ -166,7 +168,7 @@ function(
166
168
  * @param {object} mTask.type - Task type
167
169
  */
168
170
  TaskManager.prototype.completeBy = function (mTask) {
169
- this._validateTask(mTask);
171
+ validateTask(mTask);
170
172
  var aCompledTaskIds = [];
171
173
  // TODO: get rid of filtering other task parameters then type for performance reasons
172
174
  var _removeTasksByDefinition = function (aTasks) {
@@ -199,6 +201,19 @@ function(
199
201
  this.complete(iTaskId);
200
202
  };
201
203
 
204
+ /**
205
+ * Cancels the task typespecific by its parameters defined by the callbackfunction
206
+ *
207
+ * @param {object} mTask - Task definition map
208
+ * @param {string} mTask.type - Task type
209
+ * @param {string} sTaskIdentifier - Identifier for tasks in <code>TaskManager</code> related to the specific task type.
210
+ * The existing tasks that are identified by <code>sTaskIdentifier</code> are removed
211
+ */
212
+ TaskManager.prototype.cancelBy = function (mTask, sTaskIdentifier) {
213
+ this._removeTasksByIdentifier(mTask, sTaskIdentifier, "_mQueuedTasks");
214
+ this._removeTasksByIdentifier(mTask, sTaskIdentifier, "_mPendingTasks");
215
+ };
216
+
202
217
  /**
203
218
  * Checks if the queue is empty
204
219
  * @return {boolean} <code>true</code> if there is no pending task
@@ -24,7 +24,7 @@ function(
24
24
  * TaskRunner run tasks defined in sap.ui.dt.TaskManager.
25
25
  *
26
26
  * @author SAP SE
27
- * @version 1.97.1
27
+ * @version 1.100.0
28
28
  *
29
29
  * @constructor
30
30
  * @private
@@ -59,9 +59,10 @@ function(
59
59
  TaskRunner.prototype._observe = function (oEvent) {
60
60
  this._oTaskPromise = this._oTaskPromise.then(function() {
61
61
  if (this._shouldObserveBreak()) {
62
- return this.stop();
62
+ this.stop();
63
+ } else {
64
+ this._runTasksFromManager(oEvent);
63
65
  }
64
- this._runTasksFromManager(oEvent);
65
66
  }.bind(this));
66
67
  };
67
68
 
@@ -73,19 +74,18 @@ function(
73
74
  };
74
75
 
75
76
  TaskRunner.prototype._runTasks = function (aTasks) {
76
- var aTaskPromises = [];
77
- for (var i = 0, n = aTasks.length; i < n; i++) {
78
- if (aTasks[i].callbackFn) {
79
- try {
80
- aTaskPromises.push(
81
- aTasks[i].callbackFn()
82
- .then(this._oTaskManager.complete.bind(this._oTaskManager, aTasks[i].id))
83
- );
84
- } catch (vError) {
85
- BaseLog.error(DtUtil.errorToString(vError));
86
- }
77
+ aTasks.forEach(function (oTask) {
78
+ if (oTask.callbackFn) {
79
+ oTask.callbackFn()
80
+ .then(function () {
81
+ this._oTaskManager.complete(oTask.id);
82
+ }.bind(this))
83
+ .catch(function (vError) {
84
+ this._oTaskManager.complete(oTask.id);
85
+ BaseLog.error(DtUtil.errorToString(vError) + " / related task: " + JSON.stringify(oTask));
86
+ }.bind(this));
87
87
  }
88
- }
88
+ }.bind(this));
89
89
  };
90
90
 
91
91
  TaskRunner.prototype.run = function (sTaskType) {
@@ -18,16 +18,13 @@ sap.ui.define([
18
18
  "use strict";
19
19
 
20
20
  /**
21
- * Class for Utils.
22
- *
23
- * @class
24
- * Utilities for sap.ui.dt library
21
+ * Utilities for sap.ui.dt library.
25
22
  *
23
+ * @namespace
26
24
  * @author SAP SE
27
- * @version 1.97.1
25
+ * @version 1.100.0
28
26
  *
29
27
  * @private
30
- * @static
31
28
  * @since 1.54
32
29
  * @alias sap.ui.dt.DOMUtil
33
30
  * @experimental Since 1.54. This class is experimental and provides only limited functionality. Also the API might be changed in future.
@@ -239,7 +236,7 @@ sap.ui.define([
239
236
 
240
237
  /**
241
238
  * Webkit can be safari or chrome mobile
242
- * @return {Boolean} Returns true if the device browser uses webkit
239
+ * @return {boolean} Returns true if the device browser uses webkit
243
240
  */
244
241
  Util.isWebkit = function() {
245
242
  return Device.browser.webkit && (Device.browser.safari || Device.browser.chrome && Device.browser.mobile);
@@ -37,7 +37,7 @@ sap.ui.define([
37
37
  * @extends sap.ui.dt.test.Test
38
38
  *
39
39
  * @author SAP SE
40
- * @version 1.97.1
40
+ * @version 1.100.0
41
41
  *
42
42
  * @constructor
43
43
  * @private