diff --git a/src/app/core/facades/shopping.facade.ts b/src/app/core/facades/shopping.facade.ts index 7bb5b68c805..5b332393e80 100644 --- a/src/app/core/facades/shopping.facade.ts +++ b/src/app/core/facades/shopping.facade.ts @@ -6,7 +6,12 @@ import { debounce, debounceTime, filter, map, switchMap, tap } from 'rxjs/operat import { ProductListingID } from 'ish-core/models/product-listing/product-listing.model'; import { ProductCompletenessLevel, ProductHelper } from 'ish-core/models/product/product.model'; import { addProductToBasket } from 'ish-core/store/customer/basket'; -import { getCategoryLoading, getSelectedCategory, getTopLevelCategories } from 'ish-core/store/shopping/categories'; +import { + getCategory, + getCategoryLoading, + getNavigationCategories, + getSelectedCategory, +} from 'ish-core/store/shopping/categories'; import { addToCompare, getCompareProducts, @@ -50,10 +55,17 @@ export class ShoppingFacade { // CATEGORY - topLevelCategories$ = this.store.pipe(select(getTopLevelCategories)); selectedCategory$ = this.store.pipe(select(getSelectedCategory)); selectedCategoryLoading$ = this.store.pipe(select(getCategoryLoading), debounceTime(500)); + category$(uniqueId: string) { + return this.store.pipe(select(getCategory(uniqueId))); + } + + navigationCategories$(uniqueId?: string) { + return this.store.pipe(select(getNavigationCategories(uniqueId))); + } + // PRODUCT selectedProduct$ = this.store.pipe(select(getSelectedProduct)); diff --git a/src/app/core/models/category-tree/category-tree.helper.spec.ts b/src/app/core/models/category-tree/category-tree.helper.spec.ts index fff792d2925..05c1560cabc 100644 --- a/src/app/core/models/category-tree/category-tree.helper.spec.ts +++ b/src/app/core/models/category-tree/category-tree.helper.spec.ts @@ -5,6 +5,7 @@ import * as using from 'jasmine-data-provider'; import { CategoryData } from 'ish-core/models/category/category.interface'; import { CategoryMapper } from 'ish-core/models/category/category.mapper'; import { Category } from 'ish-core/models/category/category.model'; +import { categoryTree } from 'ish-core/utils/dev/test-data-utils'; import { CategoryTreeHelper } from './category-tree.helper'; import { CategoryTree } from './category-tree.model'; @@ -458,4 +459,188 @@ describe('Category Tree Helper', () => { } ); }); + + describe('subTree', () => { + let combined: CategoryTree; + + beforeEach(() => { + combined = categoryTree([ + { uniqueId: 'A', categoryPath: ['A'] }, + { uniqueId: 'A.1', categoryPath: ['A', 'A.1'] }, + { uniqueId: 'A.1.a', categoryPath: ['A', 'A.1', 'A.1.a'] }, + { uniqueId: 'A.2', categoryPath: ['A', 'A.2'] }, + { uniqueId: 'A.1.b', categoryPath: ['A', 'A.1', 'A.1.b'] }, + { uniqueId: 'B', categoryPath: ['B'] }, + { uniqueId: 'B.1', categoryPath: ['B', 'B.1'] }, + { uniqueId: 'B.1.a', categoryPath: ['B', 'B.1', 'B.1.a'] }, + { uniqueId: 'B.2', categoryPath: ['B', 'B.2'] }, + ] as Category[]); + }); + + it('should be created', () => { + expect(combined).toMatchInlineSnapshot(` + ├─ A + │ ├─ A.1 + │ │ ├─ A.1.a + │ │ └─ A.1.b + │ └─ A.2 + └─ B + ├─ B.1 + │ └─ B.1.a + └─ B.2 + + `); + + expect(combined.rootIds).toMatchInlineSnapshot(` + Array [ + "A", + "B", + ] + `); + expect(Object.keys(combined.nodes)).toMatchInlineSnapshot(` + Array [ + "A", + "A.1", + "A.1.a", + "A.2", + "A.1.b", + "B", + "B.1", + "B.1.a", + "B.2", + ] + `); + expect(Object.keys(combined.edges)).toMatchInlineSnapshot(` + Array [ + "A", + "A.1", + "B", + "B.1", + ] + `); + }); + + it('should return an empty tree if selected uniqueId is not part of the tree', () => { + const tree = CategoryTreeHelper.subTree(combined, 'C'); + expect(tree.rootIds).toBeEmpty(); + expect(tree.edges).toBeEmpty(); + expect(tree.nodes).toBeEmpty(); + }); + + it('should return copy of tree if selector is undefined', () => { + const tree = CategoryTreeHelper.subTree(combined, undefined); + expect(CategoryTreeHelper.equals(tree, combined)).toBeTrue(); + }); + + it('should extract sub tree for A', () => { + const tree = CategoryTreeHelper.subTree(combined, 'A'); + + expect(tree).toMatchInlineSnapshot(` + └─ A + ├─ A.1 + │ ├─ A.1.a + │ └─ A.1.b + └─ A.2 + + `); + + expect(tree.rootIds).toMatchInlineSnapshot(` + Array [ + "A", + ] + `); + expect(Object.keys(tree.nodes)).toMatchInlineSnapshot(` + Array [ + "A", + "A.1", + "A.1.a", + "A.2", + "A.1.b", + ] + `); + expect(Object.keys(tree.edges)).toMatchInlineSnapshot(` + Array [ + "A", + "A.1", + ] + `); + }); + + it('should extract sub tree for A.1', () => { + const tree = CategoryTreeHelper.subTree(combined, 'A.1'); + + expect(tree).toMatchInlineSnapshot(` + └─ dangling + └─ A.1 + ├─ A.1.a + └─ A.1.b + + `); + + expect(tree.rootIds).toBeEmpty(); + expect(Object.keys(tree.nodes)).toMatchInlineSnapshot(` + Array [ + "A.1", + "A.1.a", + "A.1.b", + ] + `); + expect(Object.keys(tree.edges)).toMatchInlineSnapshot(` + Array [ + "A.1", + ] + `); + }); + + it('should extract sub tree for A.1.a', () => { + const tree = CategoryTreeHelper.subTree(combined, 'A.1.a'); + + expect(tree).toMatchInlineSnapshot(` + └─ dangling + └─ A.1.a + + `); + + expect(tree.rootIds).toBeEmpty(); + expect(Object.keys(tree.nodes)).toMatchInlineSnapshot(` + Array [ + "A.1.a", + ] + `); + expect(Object.keys(tree.edges)).toBeEmpty(); + }); + }); + + describe('equals', () => { + const catA = { uniqueId: 'A', categoryPath: ['A'] } as Category; + const catB = { uniqueId: 'B', categoryPath: ['B'] } as Category; + + it('should return true for simple equal trees', () => { + const tree1 = categoryTree([catA]); + const tree2 = categoryTree([catA]); + + expect(CategoryTreeHelper.equals(tree1, tree2)).toBeTrue(); + }); + + it('should return true if category was copied', () => { + const tree1 = categoryTree([catA]); + const tree2 = categoryTree([{ ...catA }]); + + expect(CategoryTreeHelper.equals(tree1, tree2)).toBeTrue(); + }); + + it('should return false for simple unequal trees', () => { + const tree1 = categoryTree([catA]); + const tree2 = categoryTree([catB]); + + expect(CategoryTreeHelper.equals(tree1, tree2)).toBeFalse(); + }); + + it('should return true for simple unordered trees', () => { + const tree1 = categoryTree([catA, catB]); + const tree2 = categoryTree([catB, catA]); + + expect(CategoryTreeHelper.equals(tree1, tree2)).toBeTrue(); + }); + }); }); diff --git a/src/app/core/models/category-tree/category-tree.helper.ts b/src/app/core/models/category-tree/category-tree.helper.ts index 18f72365393..a61ce3a13e7 100644 --- a/src/app/core/models/category-tree/category-tree.helper.ts +++ b/src/app/core/models/category-tree/category-tree.helper.ts @@ -1,3 +1,5 @@ +import { isEqual, pick } from 'lodash-es'; + import { Category } from 'ish-core/models/category/category.model'; import { CategoryTree } from './category-tree.model'; @@ -131,4 +133,51 @@ export class CategoryTreeHelper { const singleCategoryTree = CategoryTreeHelper.single(category); return CategoryTreeHelper.merge(tree, singleCategoryTree); } + + /** + * Extract a sub tree. + */ + static subTree(tree: CategoryTree, uniqueId: string): CategoryTree { + if (!uniqueId) { + return tree; + } + + const select = (e: string) => e.startsWith(uniqueId); + return { + rootIds: tree.rootIds.filter(select), + edges: pick(tree.edges, ...Object.keys(tree.edges).filter(select)), + nodes: pick(tree.nodes, ...Object.keys(tree.nodes).filter(select)), + }; + } + + private static rootIdsEqual(t1: string[], t2: string[]) { + return t1.length === t2.length && t1.every(e => t2.includes(e)); + } + + private static edgesEqual(t1: { [id: string]: string[] }, t2: { [id: string]: string[] }) { + return isEqual(t1, t2); + } + + private static categoriesEqual(t1: { [id: string]: Category }, t2: { [id: string]: Category }) { + const keys1 = Object.keys(t1); + const keys2 = Object.keys(t2); + return ( + keys1.length === keys2.length && + keys1.every(id => keys2.includes(id)) && + keys1.every(id => isEqual(t1[id], t2[id])) + ); + } + + /** + * Perform check for equality. Order of items is ignored. + */ + static equals(tree1: CategoryTree, tree2: CategoryTree): boolean { + return ( + tree1 && + tree2 && + CategoryTreeHelper.rootIdsEqual(tree1.rootIds, tree2.rootIds) && + CategoryTreeHelper.edgesEqual(tree1.edges, tree2.edges) && + CategoryTreeHelper.categoriesEqual(tree1.nodes, tree2.nodes) + ); + } } diff --git a/src/app/core/models/category-view/category-view.model.spec.ts b/src/app/core/models/category-view/category-view.model.spec.ts index c5257421d25..7ac7e4402b3 100644 --- a/src/app/core/models/category-view/category-view.model.spec.ts +++ b/src/app/core/models/category-view/category-view.model.spec.ts @@ -39,8 +39,8 @@ describe('Category View Model', () => { ]); const view = createCategoryView(tree, '123'); - expect(view.hasChildren()).toBeFalse(); - expect(view.children()).toBeEmpty(); + expect(view.hasChildren).toBeFalse(); + expect(view.children).toBeEmpty(); }); const cat1 = { @@ -60,34 +60,16 @@ describe('Category View Model', () => { const tree = categoryTree([cat1, cat11]); const view = createCategoryView(tree, '123'); - expect(view.hasChildren()).toBeTrue(); - expect(view.children()).toHaveLength(1); + expect(view.hasChildren).toBeTrue(); + expect(view.children).toHaveLength(1); - expect(view.children()[0].uniqueId).toEqual('123.456'); + expect(view.children[0]).toEqual('123.456'); }); - it('should provide methods to check if a node in a deep complex tree has children', () => { - const tree = categoryTree([cat1, cat11, cat111]); - - const view = createCategoryView(tree, '123'); - expect(view.hasChildren()).toBeTrue(); - expect(view.children()).toHaveLength(1); - - const subCategory = view.children()[0]; - expect(subCategory.uniqueId).toEqual('123.456'); - expect(subCategory.hasChildren()).toBeTrue(); - expect(subCategory.children()).toHaveLength(1); - - const subSubCategory = subCategory.children()[0]; - expect(subSubCategory.uniqueId).toEqual('123.456.789'); - expect(subSubCategory.hasChildren()).toBeFalse(); - expect(subSubCategory.children()).toBeEmpty(); - }); - - it('should provide acces to the category path of a category', () => { + it('should provide access to the category path of a category', () => { const tree = categoryTree([cat1, cat11, cat111]); const view = createCategoryView(tree, '123.456.789'); - expect(view.pathCategories().map(v => v.uniqueId)).toEqual(['123', '123.456', '123.456.789']); + expect(view.categoryPath).toEqual(['123', '123.456', '123.456.789']); }); }); diff --git a/src/app/core/models/category-view/category-view.model.ts b/src/app/core/models/category-view/category-view.model.ts index 77700d423f0..81807271fcd 100644 --- a/src/app/core/models/category-view/category-view.model.ts +++ b/src/app/core/models/category-view/category-view.model.ts @@ -5,9 +5,8 @@ import { Category } from 'ish-core/models/category/category.model'; * View on a {@link Category} with additional methods for navigating to sub categories or category path */ export interface CategoryView extends Category { - children(): CategoryView[]; - hasChildren(): boolean; - pathCategories(): CategoryView[]; + children: string[]; + hasChildren: boolean; } export function createCategoryView(tree: CategoryTree, uniqueId: string): CategoryView { @@ -20,8 +19,7 @@ export function createCategoryView(tree: CategoryTree, uniqueId: string): Catego return { ...tree.nodes[uniqueId], - hasChildren: () => !!tree.edges[uniqueId] && !!tree.edges[uniqueId].length, - children: () => (tree.edges[uniqueId] || []).map(id => createCategoryView(tree, id)), - pathCategories: () => tree.nodes[uniqueId].categoryPath.map(id => createCategoryView(tree, id)), + children: tree.edges[uniqueId] || [], + hasChildren: !!tree.edges[uniqueId] && !!tree.edges[uniqueId].length, }; } diff --git a/src/app/core/models/category/category.helper.spec.ts b/src/app/core/models/category/category.helper.spec.ts index a7b2b7c8e56..8a689077a6a 100644 --- a/src/app/core/models/category/category.helper.spec.ts +++ b/src/app/core/models/category/category.helper.spec.ts @@ -4,38 +4,6 @@ import { CategoryCompletenessLevel, CategoryHelper } from './category.helper'; import { Category } from './category.model'; describe('Category Helper', () => { - describe('equals', () => { - const dataProvider = () => { - const emptyCategory = {} as Category; - const category1 = { uniqueId: '1' } as Category; - const category2 = { uniqueId: '2' } as Category; - const category3 = { name: 'dummy', uniqueId: '1' } as Category; - const category4 = { name: 'other', uniqueId: '1' } as Category; - const category5 = { name: 'd', uniqueId: '0' } as Category; - return [ - { cat1: emptyCategory, cat2: undefined, result: false }, - { cat1: emptyCategory, cat2: undefined, result: false }, - { cat1: emptyCategory, cat2: emptyCategory, result: true }, - { cat1: category1, cat2: category1, result: true }, - { cat1: category2, cat2: category1, result: false }, - { cat1: emptyCategory, cat2: category1, result: false }, - { cat1: category1, cat2: emptyCategory, result: false }, - { cat1: category5, cat2: category1, result: false }, - { cat1: category1, cat2: category5, result: false }, - { cat1: category1, cat2: category3, result: true }, - { cat1: category3, cat2: category4, result: true }, - ]; - }; - - using(dataProvider, slice => { - it(`should return ${slice.result} when comparing '${JSON.stringify(slice.cat1)}' and '${JSON.stringify( - slice.cat2 - )}'`, () => { - expect(CategoryHelper.equals(slice.cat1, slice.cat2)).toBe(slice.result); - }); - }); - }); - describe('getCategoryPath', () => { function dataProvider() { return [ diff --git a/src/app/core/models/category/category.helper.ts b/src/app/core/models/category/category.helper.ts index 3e2249f7e23..920ac4d7bf5 100644 --- a/src/app/core/models/category/category.helper.ts +++ b/src/app/core/models/category/category.helper.ts @@ -7,16 +7,6 @@ export enum CategoryCompletenessLevel { export class CategoryHelper { static uniqueIdSeparator = '.'; - /** - * @returns True if the categories are equal, false if not. - * 'equal' means - * - both categories are defined - * - the uniqueId of the categories is the same - */ - static equals(self: Category, category: Category): boolean { - return !!self && !!category && self.uniqueId === category.uniqueId; - } - /** * Converts a given uniqueId of a category in a REST API category path. * @example diff --git a/src/app/core/models/navigation-category/navigation-category.model.ts b/src/app/core/models/navigation-category/navigation-category.model.ts new file mode 100644 index 00000000000..acfa218dbfe --- /dev/null +++ b/src/app/core/models/navigation-category/navigation-category.model.ts @@ -0,0 +1,6 @@ +export interface NavigationCategory { + uniqueId: string; + name: string; + url: string; + hasChildren: boolean; +} diff --git a/src/app/core/store/shopping/categories/categories.selectors.spec.ts b/src/app/core/store/shopping/categories/categories.selectors.spec.ts index af2081be01c..c06ef8cbfd9 100644 --- a/src/app/core/store/shopping/categories/categories.selectors.spec.ts +++ b/src/app/core/store/shopping/categories/categories.selectors.spec.ts @@ -20,10 +20,11 @@ import { } from './categories.actions'; import { getBreadcrumbForCategoryPage, + getCategory, getCategoryEntities, getCategoryLoading, + getNavigationCategories, getSelectedCategory, - getTopLevelCategories, isTopLevelCategoriesLoaded, } from './categories.selectors'; @@ -75,10 +76,10 @@ describe('Categories Selectors', () => { it('should not select any selected category when used', () => { expect(getSelectedCategory(store$.state)).toBeUndefined(); + expect(getCategory(catA.uniqueId)(store$.state)).toBeUndefined(); }); - it('should not select any top level categories when used', () => { - expect(getTopLevelCategories(store$.state)).toBeEmpty(); + it('should not have any top level categories loaded when used', () => { expect(isTopLevelCategoriesLoaded(store$.state)).toBeFalse(); }); }); @@ -125,6 +126,7 @@ describe('Categories Selectors', () => { it('should return the category information when used', () => { expect(getCategoryEntities(store$.state)).toHaveProperty(catA.uniqueId); expect(getCategoryLoading(store$.state)).toBeFalse(); + expect(getCategory(catA.uniqueId)(store$.state).uniqueId).toEqual(catA.uniqueId); }); it('should not select the irrelevant category when used', () => { @@ -145,6 +147,7 @@ describe('Categories Selectors', () => { it('should return the category information when used', () => { expect(getCategoryEntities(store$.state)).toHaveProperty(catA.uniqueId); expect(getCategoryLoading(store$.state)).toBeFalse(); + expect(getCategory(catA.uniqueId)(store$.state).uniqueId).toEqual(catA.uniqueId); }); it('should select the selected category when used', () => { @@ -192,22 +195,80 @@ describe('Categories Selectors', () => { describe('loading top level categories', () => { beforeEach(() => { - store$.dispatch( - loadTopLevelCategoriesSuccess({ - categories: categoryTree([ - { uniqueId: 'A', categoryPath: ['A'] }, - { uniqueId: 'B', categoryPath: ['B'] }, - ] as Category[]), - }) - ); - }); - - it('should select root categories when used', () => { - expect(getTopLevelCategories(store$.state).map(x => x.uniqueId)).toEqual(['A', 'B']); + const cA = { name: 'name_A', uniqueId: 'A', categoryPath: ['A'] } as Category; + const cA1 = { name: 'name_A.1', uniqueId: 'A.1', categoryPath: ['A', 'A.1'] } as Category; + const cA1a = { name: 'name_A.1.a', uniqueId: 'A.1.a', categoryPath: ['A', 'A.1', 'A.1.a'] } as Category; + const cA1b = { name: 'name_A.1.b', uniqueId: 'A.1.b', categoryPath: ['A', 'A.1', 'A.1.b'] } as Category; + const cA2 = { name: 'name_A.2', uniqueId: 'A.2', categoryPath: ['A', 'A.2'] } as Category; + const cB = { name: 'name_B', uniqueId: 'B', categoryPath: ['B'] } as Category; + store$.dispatch(loadTopLevelCategoriesSuccess({ categories: categoryTree([cA, cA1, cA1a, cA1b, cA2, cB]) })); }); it('should remember if top level categories are loaded', () => { expect(isTopLevelCategoriesLoaded(store$.state)).toBeTrue(); }); + + describe('selecting navigation categories', () => { + it('should select top level categories when no argument was supplied', () => { + expect(getNavigationCategories(undefined)(store$.state)).toMatchInlineSnapshot(` + Array [ + Object { + "hasChildren": true, + "name": "name_A", + "uniqueId": "A", + "url": "/name_A-catA", + }, + Object { + "hasChildren": false, + "name": "name_B", + "uniqueId": "B", + "url": "/name_B-catB", + }, + ] + `); + }); + + it('should select sub categories when sub category is selected', () => { + expect(getNavigationCategories('A')(store$.state)).toMatchInlineSnapshot(` + Array [ + Object { + "hasChildren": true, + "name": "name_A.1", + "uniqueId": "A.1", + "url": "/name_A.1-catA.1", + }, + Object { + "hasChildren": false, + "name": "name_A.2", + "uniqueId": "A.2", + "url": "/name_A.2-catA.2", + }, + ] + `); + }); + + it('should select deeper sub categories when deeper sub category is selected', () => { + expect(getNavigationCategories('A.1')(store$.state)).toMatchInlineSnapshot(` + Array [ + Object { + "hasChildren": false, + "name": "name_A.1.a", + "uniqueId": "A.1.a", + "url": "/name_A.1.a-catA.1.a", + }, + Object { + "hasChildren": false, + "name": "name_A.1.b", + "uniqueId": "A.1.b", + "url": "/name_A.1.b-catA.1.b", + }, + ] + `); + }); + + it('should be empty when selecting leaves', () => { + expect(getNavigationCategories('A.1.a')(store$.state)).toBeEmpty(); + }); + }); }); }); diff --git a/src/app/core/store/shopping/categories/categories.selectors.ts b/src/app/core/store/shopping/categories/categories.selectors.ts index 191b33b3e6d..41d2eb2dfbc 100644 --- a/src/app/core/store/shopping/categories/categories.selectors.ts +++ b/src/app/core/store/shopping/categories/categories.selectors.ts @@ -2,8 +2,10 @@ import { Dictionary } from '@ngrx/entity'; import { createSelector, createSelectorFactory, defaultMemoize } from '@ngrx/store'; import { isEqual } from 'lodash-es'; +import { CategoryTree, CategoryTreeHelper } from 'ish-core/models/category-tree/category-tree.model'; import { CategoryView, createCategoryView } from 'ish-core/models/category-view/category-view.model'; import { Category, CategoryHelper } from 'ish-core/models/category/category.model'; +import { NavigationCategory } from 'ish-core/models/navigation-category/navigation-category.model'; import { generateCategoryUrl } from 'ish-core/routing/category/category.route'; import { selectRouteParam } from 'ish-core/store/core/router'; import { ShoppingState, getShoppingState } from 'ish-core/store/shopping/shopping-store'; @@ -17,10 +19,21 @@ export const getCategoryTree = createSelector(getCategoriesState, state => state */ export const getCategoryEntities = createSelector(getCategoryTree, tree => tree.nodes); +const getCategorySubTree = (uniqueId: string) => + createSelectorFactory(projector => + defaultMemoize(projector, CategoryTreeHelper.equals, CategoryTreeHelper.equals) + )(getCategoryTree, (tree: CategoryTree) => CategoryTreeHelper.subTree(tree, uniqueId)); + +export const getCategory = (uniqueId: string) => + createSelectorFactory(projector => defaultMemoize(projector, CategoryTreeHelper.equals, isEqual))( + getCategorySubTree(uniqueId), + (tree: CategoryTree) => createCategoryView(tree, uniqueId) + ); + /** * Retrieves the currently resolved selected category. */ -export const getSelectedCategory = createSelector( +export const getSelectedCategory = createSelectorFactory(projector => defaultMemoize(projector, undefined, isEqual))( getCategoryTree, selectRouteParam('categoryUniqueId'), createCategoryView @@ -28,10 +41,6 @@ export const getSelectedCategory = createSelector( export const getCategoryLoading = createSelector(getCategoriesState, categories => categories.loading); -export const getTopLevelCategories = createSelector(getCategoryTree, tree => - tree.rootIds.map(id => createCategoryView(tree, id)) -); - export const isTopLevelCategoriesLoaded = createSelector(getCategoriesState, state => state.topLevelLoaded); export const getBreadcrumbForCategoryPage = createSelectorFactory(projector => @@ -47,3 +56,24 @@ export const getBreadcrumbForCategoryPage = createSelectorFactory(projector => })) : undefined ); + +function mapNavigationCategoryFromId(uniqueId: string): NavigationCategory { + return { + uniqueId, + name: this.nodes[uniqueId].name, + url: generateCategoryUrl(this.nodes[uniqueId]), + hasChildren: !!this.edges[uniqueId]?.length, + }; +} + +export const getNavigationCategories = (uniqueId: string) => + createSelectorFactory(projector => defaultMemoize(projector, CategoryTreeHelper.equals, isEqual))( + getCategoryTree, + (tree: CategoryTree): NavigationCategory[] => { + if (!uniqueId) { + return tree.rootIds.map(mapNavigationCategoryFromId.bind(tree)); + } + const subTree = CategoryTreeHelper.subTree(tree, uniqueId); + return subTree.edges[uniqueId] ? subTree.edges[uniqueId].map(mapNavigationCategoryFromId.bind(subTree)) : []; + } + ); diff --git a/src/app/core/store/shopping/shopping-store.spec.ts b/src/app/core/store/shopping/shopping-store.spec.ts index 974dcac9f53..554c5651277 100644 --- a/src/app/core/store/shopping/shopping-store.spec.ts +++ b/src/app/core/store/shopping/shopping-store.spec.ts @@ -491,12 +491,8 @@ describe('Shopping Store', () => { categories: tree(A,A.123) [Categories API] Load Category Success: categories: tree(A.123,A.123.456) - [Categories Internal] Load Category: - categoryId: "A.123" [Viewconf Internal] Set Breadcrumb Data: breadcrumbData: [{"text":"nA","link":"/nA-catA"},{"text":"nA123","link":"/nA... - [Categories API] Load Category Success: - categories: tree(A.123,A.123.456) @ngrx/router-store/navigated: routerState: {"url":"/category/A.123.456","params":{"categoryUniqueId":"A... event: {"id":1,"url":"/category/A.123.456"} @@ -735,10 +731,6 @@ describe('Shopping Store', () => { categories: tree(A,A.123) [Categories API] Load Category Success: categories: tree(A.123,A.123.456) - [Categories Internal] Load Category: - categoryId: "A.123" - [Categories API] Load Category Success: - categories: tree(A.123,A.123.456) @ngrx/router-store/navigated: routerState: {"url":"/category/A.123.456/product/P1","params":{"categoryU... event: {"id":1,"url":"/category/A.123.456/product/P1"} diff --git a/src/app/pages/category/category-categories/category-categories.component.html b/src/app/pages/category/category-categories/category-categories.component.html index db11a95f65b..d3cbef4601b 100644 --- a/src/app/pages/category/category-categories/category-categories.component.html +++ b/src/app/pages/category/category-categories/category-categories.component.html @@ -2,7 +2,7 @@
diff --git a/src/app/pages/category/category-list/category-list.component.html b/src/app/pages/category/category-list/category-list.component.html index e3dd78bda4a..4f76e8d382e 100644 --- a/src/app/pages/category/category-list/category-list.component.html +++ b/src/app/pages/category/category-list/category-list.component.html @@ -1,5 +1,5 @@