Guest User

Untitled

a guest
Mar 5th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. loadUnits(index: number): Promise<number> {
  2.  
  3.         if (this.products[index].unitsLoaded) {
  4.             //return Promise.resolve(index);
  5.         }
  6.  
  7.         return this.requestUnits(this.products[index].id).then((res: b2b.UnitResponse[]) => {
  8.  
  9.             if (!this.products[index].units) {
  10.                this.products[index].units = new Map<number, b2b.UnitMapElement>();
  11.             }
  12.  
  13.             res.forEach(item => {
  14.  
  15.                 if (!this.products[index].units.has(item.no)) {
  16.  
  17.                     this.products[index].units.set(item.no, {
  18.                        auxiliaryUnit: item.unit
  19.                     });
  20.                 }
  21.             });
  22.  
  23.             this.products[index].unitsLoaded = true;
  24.  
  25.             return index;
  26.  
  27.         });
  28.  
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment