Skip to content
Snippets Groups Projects
Commit 1fb6b455 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

62063: 62063: Small Issue fixes

parent 80c7b860
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,8 @@ describe('BrowseByDecorator', () => {
const dateDecorator = rendersBrowseBy(BrowseByType.Date);
const metadataDecorator = rendersBrowseBy(BrowseByType.Metadata);
it('should have a decorator for all types', () => {
expect(titleDecorator.length).not.toBeNull();
expect(dateDecorator.length).not.toBeNull();
expect(metadataDecorator.length).not.toBeNull();
expect(titleDecorator.length).not.toEqual(0);
expect(dateDecorator.length).not.toEqual(0);
expect(metadataDecorator.length).not.toEqual(0);
});
});
<ng-container *ngComponentOutlet="getComponent() | async"></ng-container>
<ng-container *ngComponentOutlet="browseByComponent | async"></ng-container>
......@@ -16,31 +16,23 @@ import { getComponentByBrowseByType } from './browse-by-decorator';
export class BrowseBySwitcherComponent implements OnInit {
/**
* Resolved browse config
* Resolved browse-by component
*/
browseByTypeConfig: Observable<BrowseByTypeConfig>;
browseByComponent: Observable<any>;
public constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
protected route: ActivatedRoute) {
}
/**
* Fetch the correct browse config from environment.js
* Fetch the correct browse-by component by using the relevant config from environment.js
*/
ngOnInit(): void {
this.browseByTypeConfig = this.route.params.pipe(
this.browseByComponent = this.route.params.pipe(
map((params) => {
const metadata = params.metadata;
return this.config.browseBy.types.find((config: BrowseByTypeConfig) => config.metadata === metadata);
})
);
}
/**
* Fetch the component depending on the browse type
*/
getComponent() {
return this.browseByTypeConfig.pipe(
}),
map((config: BrowseByTypeConfig) => getComponentByBrowseByType(config.type))
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment