@veloceapps/sdk 3.0.11 → 3.0.13

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.
@@ -1809,7 +1809,20 @@
1809
1809
  }
1810
1810
  };
1811
1811
  FlowUpdateService.prototype.delete = function (lineItems, id) {
1812
- var filtered = lineItems.filter(function (lineItem) { return lineItem.id !== id; });
1812
+ var idsToRemove = [id];
1813
+ var topLevelLineItem = lineItems.find(function (li) { return li.id === id; });
1814
+ if (topLevelLineItem) {
1815
+ // find term-related line items (which are only top level)
1816
+ // expired term line items won't be deleted
1817
+ var foundTermLineItem_1 = topLevelLineItem;
1818
+ while (foundTermLineItem_1) {
1819
+ foundTermLineItem_1 = lineItems.find(function (li) { return foundTermLineItem_1 && li.rampInstanceId === foundTermLineItem_1.id; });
1820
+ if (foundTermLineItem_1) {
1821
+ idsToRemove.push(foundTermLineItem_1.id);
1822
+ }
1823
+ }
1824
+ }
1825
+ var filtered = lineItems.filter(function (lineItem) { return !idsToRemove.includes(lineItem.id); });
1813
1826
  return filtered.map(function (lineItem) { return new LineItemWorker(lineItem).remove(id).li; });
1814
1827
  };
1815
1828
  FlowUpdateService.prototype.updateQty = function (rootLineItem, params) {
@@ -1914,30 +1927,24 @@
1914
1927
  if (context) {
1915
1928
  _this.contextService.update({ properties: context.properties });
1916
1929
  }
1917
- }), rxjs.catchError(function (error) { return _this.handleError(error); }));
1930
+ }), this.handleError());
1918
1931
  };
1919
1932
  FlowConfigurationService.prototype.calculate = function (currentState) {
1920
1933
  this.calculate$(currentState).subscribe();
1921
1934
  };
1922
1935
  FlowConfigurationService.prototype.update$ = function (params) {
1923
1936
  var _this = this;
1924
- return rxjs.of([]).pipe(rxjs.map(function () { return _this.lineItems.value.map(function (li) { return _this.updateService.update(li, params); }); }), rxjs.catchError(function (error) { return _this.handleError(error); }), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1937
+ return rxjs.of([]).pipe(rxjs.map(function () { return _this.lineItems.value.map(function (li) { return _this.updateService.update(li, params); }); }), this.handleError(), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1925
1938
  };
1926
1939
  FlowConfigurationService.prototype.update = function (params) {
1927
1940
  this.update$(params).subscribe();
1928
1941
  };
1929
- FlowConfigurationService.prototype.delete$ = function (id) {
1942
+ FlowConfigurationService.prototype.delete$ = function (ids) {
1930
1943
  var _this = this;
1931
- return rxjs.of([]).pipe(rxjs.map(function () { return _this.updateService.delete(_this.lineItems.value, id); }), rxjs.catchError(function (error) { return _this.handleError(error); }), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1932
- };
1933
- FlowConfigurationService.prototype.deleteAll$ = function () {
1934
- return this.calculate$([]);
1944
+ return rxjs.of([]).pipe(rxjs.map(function () { return ids.reduce(function (result, id) { return _this.updateService.delete(result, id); }, _this.lineItems.value); }), this.handleError(), rxjs.switchMap(function (currentState) { return _this.calculate$(currentState); }));
1935
1945
  };
1936
- FlowConfigurationService.prototype.delete = function (id) {
1937
- this.delete$(id).subscribe();
1938
- };
1939
- FlowConfigurationService.prototype.deleteAll = function () {
1940
- this.deleteAll$().subscribe();
1946
+ FlowConfigurationService.prototype.delete = function (ids) {
1947
+ this.delete$(ids).subscribe();
1941
1948
  };
1942
1949
  FlowConfigurationService.prototype.get = function () {
1943
1950
  return this.lineItems.asObservable().pipe(rxjs.shareReplay());
@@ -1973,12 +1980,17 @@
1973
1980
  enumerable: false,
1974
1981
  configurable: true
1975
1982
  });
1976
- FlowConfigurationService.prototype.handleError = function (error) {
1977
- console.error(error);
1978
- this.messageService.add({ severity: 'error', summary: error });
1979
- // bounce back if configuration call has failed
1980
- this.lineItems.next(this.lineItems.value.slice());
1981
- return rxjs.throwError(function () { return error; });
1983
+ FlowConfigurationService.prototype.handleError = function () {
1984
+ var _this = this;
1985
+ return function (source$) {
1986
+ return source$.pipe(rxjs.catchError(function (error) {
1987
+ console.error(error);
1988
+ _this.messageService.add({ severity: 'error', summary: error });
1989
+ // bounce back if configuration call has failed
1990
+ _this.lineItems.next(_this.lineItems.value.slice());
1991
+ return rxjs.throwError(function () { return error; });
1992
+ }));
1993
+ };
1982
1994
  };
1983
1995
  return FlowConfigurationService;
1984
1996
  }());