Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     loadCatalogs(client) {
  2.         this.catalogServ.getAssetsApiVehicleBrandsForCatalog(client).subscribe(res => {
  3.             this.brandList = JSON.parse(res['_body']);
  4.             this.catalogServ.getApiModelsForCatalog(client).subscribe(res => {
  5.                 this.modelList = JSON.parse(res['_body']);
  6.                 this.catalogServ.getApiYearsForCatalog(client).subscribe(res => {
  7.                     this.yearList = JSON.parse(res['_body']);
  8.                     this.brandList.forEach(elementBrand => {
  9.                         this.modelList.forEach(elementModel => {
  10.                             this.yearList.forEach(elementYear => {
  11.                                 if (elementYear.modelId == elementModel.modelId) {
  12.                                     elementYear.model = elementModel;
  13.                                     elementModel.tieneAño = true;
  14.                                 }
  15.                             });
  16.                             if (elementModel.brandId == elementBrand.brandId) {
  17.                                 elementModel.brand = elementBrand;
  18.                                 elementBrand.tieneModelo = true;
  19.                             }
  20.                         });
  21.                     });
  22.                     this.yearList.forEach(element => {
  23.                         this.finalList.push(element);
  24.                     });
  25.                     this.brandList.forEach(element => {
  26.                         if (!element.tieneModelo) {
  27.                             this.finalList.push({ year: "-", model: { name: "-", brand: { name: element.name, brandId: element.brandId } } });
  28.                         }
  29.                     });
  30.                     console.log(this.finalList);
  31.                     this.makeList();
  32.                     this.clearList(this.finalList);
  33.                 });
  34.             });
  35.         });
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement