From 13154b84cab92127c4c7cedcb0aad9596a163a07 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Fri, 17 Jan 2025 12:04:31 +0100 Subject: [PATCH 1/4] feat: share taxnomy component between synthese info and tab-taxonomy --- frontend/cypress/e2e/synthese-spec.js | 8 +- .../form/taxonomy/taxonomy.component.ts | 1 + .../home-discussions-table.component.ts | 1 + .../synthese-info-obs.component.html | 85 +------------------ .../synthese-info-obs.component.ts | 3 +- .../taxonomy/taxonomy.component.html | 55 ++++++------ .../taxonomy/taxonomy.component.scss | 2 +- .../taxonomy/taxonomy.component.ts | 42 ++++++++- .../tab-taxonomy/tab-taxonomy.component.html | 5 +- 9 files changed, 85 insertions(+), 117 deletions(-) diff --git a/frontend/cypress/e2e/synthese-spec.js b/frontend/cypress/e2e/synthese-spec.js index c598f4d83c..3bb6264378 100644 --- a/frontend/cypress/e2e/synthese-spec.js +++ b/frontend/cypress/e2e/synthese-spec.js @@ -142,7 +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-familly"]').invoke('text').should('not.equal', ''); + 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', ''); + // vérification de la présence de l'onglet zonage cy.get('.mat-mdc-tab').contains('Zonage').click({ force: true }); cy.get('[data-qa="synthese-obs-detail-area"]'); diff --git a/frontend/src/app/GN2CommonModule/form/taxonomy/taxonomy.component.ts b/frontend/src/app/GN2CommonModule/form/taxonomy/taxonomy.component.ts index dc3ca24f40..8343a497dd 100644 --- a/frontend/src/app/GN2CommonModule/form/taxonomy/taxonomy.component.ts +++ b/frontend/src/app/GN2CommonModule/form/taxonomy/taxonomy.component.ts @@ -37,6 +37,7 @@ export interface Taxon { phylum?: string; status?: any[]; synonymes?: any[]; + attributs?: any[]; } /** diff --git a/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts b/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts index e68a10536f..8dd08120ef 100644 --- a/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts +++ b/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts @@ -134,6 +134,7 @@ export class HomeDiscussionsTableComponent implements OnInit, OnDestroy { } private _formatObservation(synthese: any): string { + console.log(synthese); return ` Nom Cité: ${synthese.nom_cite || 'N/A'}
Observateurs: ${synthese.observers || 'N/A'}
diff --git a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.html b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.html index 876dfde2c8..6afe82e81d 100644 --- a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.html +++ b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/synthese-info-obs.component.html @@ -389,90 +389,7 @@

- - - - - - - - - - - - - -
- Groupe taxonomique - {{ selectedObsTaxonDetail?.classe }}
- Ordre - {{ selectedObsTaxonDetail?.ordre }}
- Famille - - {{ selectedObsTaxonDetail?.famille }} -
- -
Attribut(s) Taxonomique(s) locaux
- - - - - -
- {{ attr?.bib_attribut?.label_attribut }} - {{ attr.valeur_attribut }}
- -
Statuts
- - - - - - - - - -
{{ status.value.display }}
-
    -
  • - - -
    - ({{ text.value.lb_adm_tr }} - {{ text.value.cd_sig }}) -
    - - Voir / Télécharger - - -
  • -
  • - - - {{ value.value.code_statut }} - - {{ value.value.label_statut }} - {{ value.value.rq_statut }} - -
  • -
-
-

Aucun

+
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 fa7c775bed..7bb9dd9476 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 @@ -12,6 +12,7 @@ import { ModuleService } from '@geonature/services/module.service'; import { ConfigService } from '@geonature/services/config.service'; import { ActivatedRoute, Router } from '@angular/router'; import { Location } from '@angular/common'; +import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component'; @Component({ selector: 'pnx-synthese-info-obs', @@ -31,7 +32,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges { public selectedObs: any; public validationHistory: Array = []; - public selectedObsTaxonDetail: any; + public selectedObsTaxonDetail: Taxon; @ViewChild('tabGroup') tabGroup; public selectedGeom; // public chartType = 'line'; 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 d3350df06b..c6454ca066 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 @@ -1,46 +1,47 @@
Classification
- +
- - - - - - - - - - + +
Groupe taxonomique{{ taxon?.classe }}
Ordre{{ taxon?.ordre }}
Famille
{{ information.label }} - {{ taxon?.famille }} + {{ taxon[information.field] }}
+

Aucune

- - + + + {{ attr.label_attribut }} + + {{ attr.valeur_attribut }} + + +

Aucun

+
Statuts
- + diff --git a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.scss b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.scss index 2ad0c2cd00..d0fb0b4d70 100644 --- a/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.scss +++ b/frontend/src/app/shared/syntheseSharedModule/synthese-info-obs/taxonomy/taxonomy.component.scss @@ -17,7 +17,7 @@ } &__value { width: 100%; - padding-left: 1rem; + padding-left: 3rem; } } } 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 52a5bc2c12..d3c1e24994 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,8 +1,11 @@ import { Component, Input, OnInit } from '@angular/core'; -import { GN2CommonModule } from '@geonature_common/GN2Common.module'; -import { CommonModule } from '@angular/common'; import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component'; +interface TaxonInformation { + label: string; + field: keyof Taxon; +} + @Component({ selector: 'pnx-synthese-taxonomy', templateUrl: 'taxonomy.component.html', @@ -11,5 +14,40 @@ import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component'; export class TaxonomyComponent { @Input() taxon: Taxon | null = null; + + @Input() + hideLocalAttributesOnEmpty: boolean = false; + constructor() {} + + readonly INFORMATIONS: Array = [ + { + label: 'Groupe taxonomique', + field: 'classe', + }, + { + label: 'Ordre', + field: 'ordre', + }, + { + label: 'Famille', + field: 'famille', + }, + { + label: 'cd nom', + field: 'cd_nom', + }, + { + label: 'lb nom', + field: 'lb_nom', + }, + { + label: 'cd ref', + field: 'cd_ref', + }, + { + label: 'Nom cite', + field: 'nom_complet', + }, + ]; } diff --git a/frontend/src/app/syntheseModule/taxon-sheet/tab-taxonomy/tab-taxonomy.component.html b/frontend/src/app/syntheseModule/taxon-sheet/tab-taxonomy/tab-taxonomy.component.html index 94da0dd149..b699bd38a0 100644 --- a/frontend/src/app/syntheseModule/taxon-sheet/tab-taxonomy/tab-taxonomy.component.html +++ b/frontend/src/app/syntheseModule/taxon-sheet/tab-taxonomy/tab-taxonomy.component.html @@ -1,3 +1,6 @@
- +
From b398d175e57b412d20993ee3547f3d9d2e42f319 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Fri, 17 Jan 2025 13:29:30 +0100 Subject: [PATCH 2/4] 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..961ca67628 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" >
- - + + 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]); + } } From c4e2c4e5b3b40675d9d40e9875db7251e1a2f320 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Fri, 17 Jan 2025 15:13:41 +0100 Subject: [PATCH 3/4] feat: adjust order --- .../synthese-info-obs/taxonomy/taxonomy.component.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 19aa3d944c..f472c1ee08 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 @@ -33,18 +33,22 @@ export class TaxonomyComponent { label: 'Famille', field: 'famille', }, - { - label: 'cd nom', - field: 'cd_nom', - }, { label: 'lb nom', field: 'lb_nom', }, + { + label: 'cd nom', + field: 'cd_nom', + }, { label: 'cd ref', field: 'cd_ref', }, + { + label: 'Nom valide', + field: 'nom_valide', + }, { label: 'Nom cite', field: 'nom_cite', From 13c589f07eca4ab7196c09419f848298a183b611 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Tue, 21 Jan 2025 09:38:49 +0100 Subject: [PATCH 4/4] fix: remove console.log --- .../home-discussions-table/home-discussions-table.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts b/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts index 8dd08120ef..e68a10536f 100644 --- a/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts +++ b/frontend/src/app/components/home-content/home-discussions/home-discussions-table/home-discussions-table.component.ts @@ -134,7 +134,6 @@ export class HomeDiscussionsTableComponent implements OnInit, OnDestroy { } private _formatObservation(synthese: any): string { - console.log(synthese); return ` Nom Cité: ${synthese.nom_cite || 'N/A'}
Observateurs: ${synthese.observers || 'N/A'}
{{ status.value.display }}
{{ information.label }}
+ {{ information.label }} + {{ taxon[information.field] }}