@infrab4a/connect-angular 4.0.1 → 4.0.2-beta.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.
@@ -1583,7 +1583,7 @@ class CategoryService {
1583
1583
  .find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
1584
1584
  .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1585
1585
  }
1586
- async fetchFilterOptions(category, filters) {
1586
+ async fetchFilterOptions(category) {
1587
1587
  return await this.categoryFilterRepository
1588
1588
  .find({ filters: { categoryId: +category.id } })
1589
1589
  .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
@@ -1647,42 +1647,41 @@ class UtilHelper {
1647
1647
  }
1648
1648
 
1649
1649
  class NewCategoryStructureAdapter {
1650
- constructor(categoryRepository, categoryCollectionChildrenRepository) {
1650
+ constructor(categoryRepository) {
1651
1651
  this.categoryRepository = categoryRepository;
1652
- this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1653
1652
  }
1654
1653
  async buildProductFilterByCategory(category) {
1655
- const categoriesIds = (await this.isCollection(category))
1656
- ? await this.getAllCategoriesIdFromCollection(category)
1657
- : [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1658
- return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1654
+ const loadedCategory = await this.getCategory(category);
1655
+ if (loadedCategory.isCollection)
1656
+ return { id: { operator: Where.IN, value: loadedCategory.products } };
1657
+ const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1658
+ return {
1659
+ category: {
1660
+ id: {
1661
+ operator: Where.IN,
1662
+ value: categoryIds,
1663
+ },
1664
+ },
1665
+ };
1659
1666
  }
1660
1667
  async getAllCategoriesIdFromCategory(category) {
1661
1668
  return this.categoryRepository
1662
1669
  .getChildren(+category.id)
1663
1670
  .then((categories) => categories.map((category) => category.id.toString()));
1664
1671
  }
1665
- async getAllCategoriesIdFromCollection(category) {
1666
- return this.categoryCollectionChildrenRepository
1667
- .find({ filters: { collectionId: +category.id } })
1668
- .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1669
- }
1670
- async isCollection(category) {
1671
- return !isNil(category.isCollection)
1672
- ? category.isCollection
1673
- : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1672
+ async getCategory(category) {
1673
+ return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
1674
+ ? this.categoryRepository.get({ id: category.id })
1675
+ : category;
1674
1676
  }
1675
1677
  }
1676
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1678
+ NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1677
1679
  NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1678
1680
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1679
1681
  type: Injectable
1680
1682
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1681
1683
  type: Inject,
1682
1684
  args: ['CategoryRepository']
1683
- }] }, { type: undefined, decorators: [{
1684
- type: Inject,
1685
- args: ['CategoryCollectionChildrenRepository']
1686
1685
  }] }]; } });
1687
1686
 
1688
1687
  class OldCategoryStructureAdapter {
@@ -1706,10 +1705,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1706
1705
  }] }]; } });
1707
1706
 
1708
1707
  class WishlistService {
1709
- constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, productIndex) {
1708
+ constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, productIndex) {
1710
1709
  this.wishlistRepository = wishlistRepository;
1711
1710
  this.shop = shop;
1712
- const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
1711
+ const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1713
1712
  this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
1714
1713
  this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1715
1714
  }
@@ -1780,7 +1779,7 @@ class WishlistService {
1780
1779
  return wishlist;
1781
1780
  }
1782
1781
  }
1783
- WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }, { token: i1$3.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1782
+ WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: i1$3.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1784
1783
  WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1785
1784
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1786
1785
  type: Injectable
@@ -1796,9 +1795,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1796
1795
  }] }, { type: undefined, decorators: [{
1797
1796
  type: Inject,
1798
1797
  args: ['CategoryFilterRepository']
1799
- }] }, { type: undefined, decorators: [{
1800
- type: Inject,
1801
- args: ['CategoryCollectionChildrenRepository']
1802
1798
  }] }, { type: i1$3.ProductsIndex }]; } });
1803
1799
 
1804
1800
  class CheckoutSubscriptionService {