Commit 0c08d877 authored by Jérémy Destin's avatar Jérémy Destin
Browse files

fix: Fix the two call sending to elasticSearch to get the result of the...

fix: Fix the two call sending to elasticSearch to get the result of the germplasm-result-page.component. Minor fixes GNP-4309
parent ecd2710c
<ng-container *ngIf="germplasm && germplasm.length>0">
<ng-container *ngIf="germplasms && germplasms.length>0">
<div class="container mb-3">
<div class="row result align-content-center">
......@@ -34,7 +34,7 @@
<faidare-card-section
class="col-12 col-lg"
header="Germplasm data: "
[test]="germplasm">
[test]="germplasms">
<ng-template>
<div class="table-responsive table-card-body">
<table class="table table-sm table-striped">
......@@ -57,14 +57,14 @@
</tr>
</thead>
<tbody>
<ng-container *ngFor="let accession of germplasm">
<ng-container *ngFor="let germplasm of germplasms">
<tr>
<td>{{ accession.germplasmName }}</td>
<td>{{ accession.accessionNumber }}</td>
<td>{{ accession.genusSpecies }}</td>
<td>{{ accession.instituteName }}</td>
<td>{{ accession.biologicalStatusOfAccessionCode }}</td>
<td>{{ accession.countryOfOriginCode }}</td>
<td>{{ germplasm.germplasmName }}</td>
<td>{{ germplasm.accessionNumber }}</td>
<td>{{ germplasm.genusSpecies }}</td>
<td>{{ germplasm.instituteName }}</td>
<td>{{ germplasm.biologicalStatusOfAccessionCode }}</td>
<td>{{ germplasm.countryOfOriginCode }}</td>
</tr>
</ng-container>
</tbody>
......@@ -75,7 +75,7 @@
<div class="container text-right"
style="margin-top: -30px"
*ngIf="germplasm">
*ngIf="germplasms">
<div ngbDropdown class="dropdown-container">
<button class="btn btn-outline-secondary btn-sm"
ngbDropdownToggle>Results per page : {{ pagination.pageSize }}
......@@ -109,7 +109,7 @@
</ng-container>
<div *ngIf="germplasm.length == 0"
<div *ngIf="germplasms.length == 0"
id="no-results" class="text-center">
<div class="no-result-icon">
<span class="fa fa-meh-o"></span>
......
......@@ -280,7 +280,7 @@ describe('GermplasmResultPageComponent', () => {
component.germplasmSearchCriteria$.next(criteria);
expect(component.localCriteria).toEqual(criteria);
expect(gnpisService.germplasmSearch).toHaveBeenCalledWith(criteria);
expect(component.germplasm).toEqual(germplasmSearchResult.result.data);
expect(component.germplasms).toEqual(germplasmSearchResult.result.data);
});
......
......@@ -23,7 +23,7 @@ import { BehaviorSubject } from 'rxjs';
export class GermplasmResultPageComponent implements OnInit {
germplasm: Germplasm[];
germplasms: Germplasm[];
localCriteria: GermplasmSearchCriteria = DataDiscoveryCriteriaUtils.emptyGermplasmSearchCriteria();
@Input() criteriaFromForm$: BehaviorSubject<DataDiscoveryCriteria>;
......@@ -90,7 +90,7 @@ export class GermplasmResultPageComponent implements OnInit {
searchGermplasm(criteria: GermplasmSearchCriteria) {
this.service.germplasmSearch(criteria)
.subscribe(({ metadata, facets, result }) => {
this.germplasm = result.data;
this.germplasms = result.data;
this.germplasmFacets$.next(facets);
DataDiscoveryCriteriaUtils.updatePagination(this.pagination, metadata.pagination);
});
......@@ -120,8 +120,6 @@ export class GermplasmResultPageComponent implements OnInit {
sources: asArray(criteria.sources)
};
this.germplasmSearchCriteria$.next(this.localCriteria);
}
exportPlantMaterial(criteria: GermplasmSearchCriteria) {
......
......@@ -65,16 +65,6 @@ export class ResultPageComponent implements OnInit {
});
}
// TODO : delete because move to DataDiscoveryCriteriaUtils
/*private updatePagination({ currentPage, pageSize, totalCount, totalPages }) {
this.pagination.currentPage = currentPage;
this.pagination.pageSize = pageSize;
this.pagination.totalPages = totalPages;
this.pagination.startResult = pageSize * currentPage + 1;
this.pagination.endResult = this.pagination.startResult + pageSize - 1;
this.pagination.totalResult = totalCount;
}*/
ngOnInit(): void {
const queryParams = this.route.snapshot.queryParams;
this.router.events.subscribe((event) => {
......@@ -90,22 +80,6 @@ export class ResultPageComponent implements OnInit {
this.criteriaIsEmpty = DataDiscoveryCriteriaUtils.checkCriteriaIsEmpty(initialCriteria);
// TODO : delete because move to DataDiscoveryCriteriaUtils
/*this.criteria$.subscribe(criteria => {
this.criteriaIsEmpty = true;
for (const field of Object.keys(criteria)) {
if (field === 'facetFields') {
// Ignore facet fields criteria
continue;
}
if (criteria[field] && criteria[field].length) {
this.criteriaIsEmpty = false;
break;
}
}
});*/
this.form.traitWidgetInitialized.subscribe(() => {
this.fetchDocumentsAndFacets();
});
......@@ -130,11 +104,6 @@ export class ResultPageComponent implements OnInit {
this.displayGermplasmResult$.next(this.displayGermplasmResult);
});
/*this.displayGermplasmResult$.subscribe(value => {
this.displayGermplasmResult = value;
});
this.displayGermplasmResult$.next(this.displayGermplasmResult);*/
this.germplasmfacets$.subscribe(facets => {
this.germplasmfacets = facets;
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment