From 733e23625545acf4da1918e00b6a64ca62b0d8a9 Mon Sep 17 00:00:00 2001 From: Alexis Georges Date: Wed, 17 Nov 2021 10:04:57 +0100 Subject: [PATCH] feat(showcase): adapt generic-search demo to use public `results$` variable directly in template --- .../demo-generic-search-page.component.html | 2 +- .../demo-generic-search-page.component.ts | 22 ++----------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.html b/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.html index 2729c4a8d0..0166166561 100644 --- a/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.html +++ b/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.html @@ -26,7 +26,7 @@

SHOWCASE.DEMO.SHARED.EXAMPLE_VIEWER_LIST

htmlId="demo-generic-search-table" [columnProperties]="columnsProperties" [paginationConfig]="paginationConfig" - [data]="searchResults" + [data]="results$ | async" [starkProgressIndicator]="progressIndicatorConfig" >

SHOWCASE.DEMO.GENERIC_SEARCH.SEARCH_RESULTS

diff --git a/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.ts b/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.ts index 1cd93fd5ea..c49d05ba4b 100644 --- a/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.ts +++ b/showcase/src/app/demo-ui/pages/generic-search/demo-generic-search-page.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnDestroy, OnInit } from "@angular/core"; +import { Component, Inject } from "@angular/core"; import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core"; import { ReferenceLink } from "../../../shared"; import { @@ -15,9 +15,7 @@ import { DemoGenericService } from "./services"; selector: "demo-generic-search", templateUrl: "./demo-generic-search-page.component.html" }) -export class DemoGenericSearchPageComponent - extends AbstractStarkSearchComponent - implements OnInit, OnDestroy { +export class DemoGenericSearchPageComponent extends AbstractStarkSearchComponent { public hideSearch = false; public columnsProperties: StarkTableColumnProperties[] = [ @@ -40,7 +38,6 @@ export class DemoGenericSearchPageComponent isSortable: true } ]; - public searchResults?: HeroMovie[]; public paginationConfig: StarkPaginationConfig = { isExtended: false, itemsPerPage: 10, @@ -73,19 +70,4 @@ export class DemoGenericSearchPageComponent this.performSearchOnInit = true; // Turn on automatic search (last search criteria) this.preserveLatestResults = true; // Keep a reference to the latest results in the latestResults variable } - - /** - * Component lifecycle hook - */ - public ngOnInit(): void { - super.ngOnInit(); - this.results$.subscribe((genericObjects: HeroMovie[]) => (this.searchResults = genericObjects)); - } - - /** - * Component lifecycle hook - */ - public ngOnDestroy(): void { - super.ngOnDestroy(); - } }