From cf824c17a8049f8be671dd6c233f90e7acc9d5db Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Fri, 17 Jan 2025 13:29:30 +0100 Subject: [PATCH] feat: handle nom_cite + fix frontend tests --- frontend/cypress/e2e/synthese-spec.js | 13 +++++++------ .../synthese-info-obs.component.ts | 13 +++++++++---- .../taxonomy/taxonomy.component.html | 8 +++++--- .../taxonomy/taxonomy.component.ts | 12 ++++++++---- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/frontend/cypress/e2e/synthese-spec.js b/frontend/cypress/e2e/synthese-spec.js index 3bb6264378..d4909d94e5 100644 --- a/frontend/cypress/e2e/synthese-spec.js +++ b/frontend/cypress/e2e/synthese-spec.js @@ -142,12 +142,13 @@ describe('Tests gn_synthese', () => { cy.get('[data-qa="synthese-obs-detail-ca"]').invoke('text').should('not.equal', ''); // vérification de la présence de l'onglet taxonomie cy.get('.mat-mdc-tab').contains('Taxonomie').click({ force: true }); - cy.get('[data-qa="synthese-obs-detail-taxo-classe"]').invoke('text').should('not.equal', ''); - cy.get('[data-qa="synthese-obs-detail-taxo-ordre"]').invoke('text').should('not.equal', ''); - cy.get('[data-qa="synthese-obs-detail-taxo-famille"]').invoke('text').should('not.equal', ''); - cy.get('[data-qa="synthese-obs-detail-taxo-cd_nom"]').invoke('text').should('not.equal', ''); - cy.get('[data-qa="synthese-obs-detail-taxo-lb_nom"]').invoke('text').should('not.equal', ''); - cy.get('[data-qa="synthese-obs-detail-taxo-cd_ref"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-classe"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-ordre"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-famille"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-cd_nom"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-lb_nom"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-cd_ref"]').invoke('text').should('not.equal', ''); + cy.get('[data-qa="taxonomy-detail-taxo-nom_cite"]').invoke('text').should('not.equal', ''); // vérification de la présence de l'onglet zonage cy.get('.mat-mdc-tab').contains('Zonage').click({ force: true }); diff --git a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.ts b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.ts index 7bb9dd9476..7b209be376 100644 --- a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.ts +++ b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.ts @@ -14,6 +14,10 @@ import { ActivatedRoute, Router } from '@angular/router'; import { Location } from '@angular/common'; import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component'; +export interface ObservedTaxon extends Taxon { + nom_cite?: string; +} + @Component({ selector: 'pnx-synthese-info-obs', templateUrl: 'synthese-info-obs.component.html', @@ -32,7 +36,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges { public selectedObs: any; public validationHistory: Array = []; - public selectedObsTaxonDetail: Taxon; + public selectedObsTaxonDetail: ObservedTaxon; @ViewChild('tabGroup') tabGroup; public selectedGeom; // public chartType = 'line'; @@ -198,11 +202,11 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges { if (this.selectedObs['unique_id_sinp']) { this.loadValidationHistory(this.selectedObs['unique_id_sinp']); } - let cdNom = this.selectedObs['cd_nom']; - let areasStatus = this.selectedObs['areas'].map((area) => area.id_area); + const cdNom = this.selectedObs['cd_nom']; + const areasStatus = this.selectedObs['areas'].map((area) => area.id_area); const taxhubFields = ['attributs', 'attributs.bib_attribut.label_attribut', 'status']; this._gnDataService.getTaxonInfo(cdNom, taxhubFields, areasStatus).subscribe((taxInfo) => { - this.selectedObsTaxonDetail = taxInfo; + this.selectedObsTaxonDetail = { ...taxInfo, nom_cite: this.selectedObs.nom_cite }; // filter attributs this.selectedObsTaxonDetail.attributs = taxInfo['attributs'].filter((v) => this.config.SYNTHESE.ID_ATTRIBUT_TAXHUB.includes(v.id_attribut) @@ -225,6 +229,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges { this.filterTabs(); this.selectedTab = this.selectedTab ? this.selectedTab : this.defaultTab; this.selectTab(this.selectedTab); + console.log(this.selectedObs); }); this._gnDataService.getProfileConsistancyData(this.idSynthese).subscribe((dataChecks) => { diff --git a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.html b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.html index c6454ca066..b597bb6b25 100644 --- a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.html +++ b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.html @@ -5,11 +5,13 @@
Classification
class="Classification font-xs table table-striped table-sm" > - - {{ information.label }} + + + {{ information.label }} + {{ taxon[information.field] }} diff --git a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.ts b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.ts index d3c1e24994..19aa3d944c 100644 --- a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.ts +++ b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.ts @@ -1,9 +1,9 @@ import { Component, Input, OnInit } from '@angular/core'; -import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component'; +import { ObservedTaxon } from '../synthese-info-obs.component'; interface TaxonInformation { label: string; - field: keyof Taxon; + field: keyof ObservedTaxon; } @Component({ @@ -13,7 +13,7 @@ interface TaxonInformation { }) export class TaxonomyComponent { @Input() - taxon: Taxon | null = null; + taxon: ObservedTaxon | null = null; @Input() hideLocalAttributesOnEmpty: boolean = false; @@ -47,7 +47,11 @@ export class TaxonomyComponent { }, { label: 'Nom cite', - field: 'nom_complet', + field: 'nom_cite', }, ]; + + get informationsFiltered() { + return this.INFORMATIONS.filter((information) => this.taxon[information.field]); + } }