Skip to content

Commit

Permalink
feat(showcase): adapt generic-search demo to use public results$ va…
Browse files Browse the repository at this point in the history
…riable directly in template
  • Loading branch information
SuperITMan committed Nov 17, 2021
1 parent 54fb29a commit 733e236
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 translate>SHOWCASE.DEMO.SHARED.EXAMPLE_VIEWER_LIST</h1>
htmlId="demo-generic-search-table"
[columnProperties]="columnsProperties"
[paginationConfig]="paginationConfig"
[data]="searchResults"
[data]="results$ | async"
[starkProgressIndicator]="progressIndicatorConfig"
>
<header><h1 class="mb0" translate>SHOWCASE.DEMO.GENERIC_SEARCH.SEARCH_RESULTS</h1></header>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -15,9 +15,7 @@ import { DemoGenericService } from "./services";
selector: "demo-generic-search",
templateUrl: "./demo-generic-search-page.component.html"
})
export class DemoGenericSearchPageComponent
extends AbstractStarkSearchComponent<HeroMovie, HeroMovieSearchCriteria>
implements OnInit, OnDestroy {
export class DemoGenericSearchPageComponent extends AbstractStarkSearchComponent<HeroMovie, HeroMovieSearchCriteria> {
public hideSearch = false;

public columnsProperties: StarkTableColumnProperties[] = [
Expand All @@ -40,7 +38,6 @@ export class DemoGenericSearchPageComponent
isSortable: true
}
];
public searchResults?: HeroMovie[];
public paginationConfig: StarkPaginationConfig = {
isExtended: false,
itemsPerPage: 10,
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 733e236

Please sign in to comment.