Skip to content

Commit

Permalink
feat: share taxnomy component between synthese info and tab-taxonomy
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Jan 17, 2025
1 parent ed1a93f commit 13154b8
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 117 deletions.
8 changes: 7 additions & 1 deletion frontend/cypress/e2e/synthese-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface Taxon {
phylum?: string;
status?: any[];
synonymes?: any[];
attributs?: any[];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class HomeDiscussionsTableComponent implements OnInit, OnDestroy {
}

private _formatObservation(synthese: any): string {
console.log(synthese);
return `
<strong>Nom Cité:</strong> ${synthese.nom_cite || 'N/A'}<br>
<strong>Observateurs:</strong> ${synthese.observers || 'N/A'}<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,90 +389,7 @@ <h4 class="mr-auto gn-color">
</ng-container>

<ng-container *ngSwitchCase="'taxonomy'">
<table class="font-xs table table-striped table-sm">
<tr>
<td>
<b>Groupe taxonomique</b>
</td>
<td>{{ selectedObsTaxonDetail?.classe }}</td>
</tr>
<tr>
<td>
<b>Ordre</b>
</td>
<td>{{ selectedObsTaxonDetail?.ordre }}</td>
</tr>
<tr>
<td>
<b>Famille</b>
</td>
<td data-qa="synthese-obs-detail-taxo-familly">
{{ selectedObsTaxonDetail?.famille }}
</td>
</tr>
</table>

<h5 class="underlined underlined-sm main-color">Attribut(s) Taxonomique(s) locaux</h5>
<table class="font-xs table table-striped table-sm">
<tr
class="font-xs"
*ngFor="let attr of selectedObsTaxonDetail?.attributs"
>
<td>
<b>{{ attr?.bib_attribut?.label_attribut }}</b>
</td>
<td>{{ attr.valeur_attribut }}</td>
</tr>
</table>

<h5 class="underlined underlined-sm main-color">Statuts</h5>
<table
class="font-xs table table-sm"
*ngIf="selectedObsTaxonDetail?.status; else noStatus"
>
<ng-container *ngFor="let status of selectedObsTaxonDetail?.status | keyvalue">
<tr class="table-primary">
<th>{{ status.value.display }}</th>
</tr>
<tr *ngFor="let text of status.value.text | keyvalue">
<td>
<ul class="list-unstyled mt-2">
<li
*ngIf="text.value.full_citation"
class="d-flex w-100 justify-content-between"
>
<span class="flex-shrink-1 w-75">
<strong [innerHtml]="text.value.full_citation | safeHTML"></strong>
<br />
({{ text.value.lb_adm_tr }} - {{ text.value.cd_sig }})
</span>
<a
*ngIf="text.value.doc_url"
class="btn align-self-start"
href="{{ text.value.doc_url }}"
mat-stroked-button
color="primary"
target="_blank"
>
Voir / Télécharger
<mat-icon aria-hidden="true">launch</mat-icon>
</a>
</li>
<li>
<span *ngFor="let value of text.value.values | keyvalue">
<strong *ngIf="value.value.code != 'true'">
{{ value.value.code_statut }}
</strong>
{{ value.value.label_statut }}
{{ value.value.rq_statut }}
</span>
</li>
</ul>
</td>
</tr>
</ng-container>
</table>
<ng-template #noStatus><p>Aucun</p></ng-template>
<pnx-synthese-taxonomy [taxon]="selectedObsTaxonDetail" />
</ng-container>

<ng-container *ngSwitchCase="'media'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -31,7 +32,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {

public selectedObs: any;
public validationHistory: Array<any> = [];
public selectedObsTaxonDetail: any;
public selectedObsTaxonDetail: Taxon;
@ViewChild('tabGroup') tabGroup;
public selectedGeom;
// public chartType = 'line';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
<div class="Taxonomy">
<h5 class="Taxonomy__subtitle">Classification</h5>
<table class="Classification font-xs table table-striped table-sm">
<table
*ngIf="taxon; else noClassification"
class="Classification font-xs table table-striped table-sm"
>
<tbody>
<tr>
<td class="Classification__name">Groupe taxonomique</td>
<td class="Classification__value">{{ taxon?.classe }}</td>
</tr>
<tr>
<td class="Classification__name">Ordre</td>
<td class="Classification__value">{{ taxon?.ordre }}</td>
</tr>
<tr>
<td class="Classification__name">Famille</td>
<tr *ngFor="let information of INFORMATIONS">
<td class="Classification__name">{{ information.label }}</td>
<td
class="Classification__value"
data-qa="synthese-obs-detail-taxo-familly"
[data-qa]="'synthese-obs-detail-taxo-' + taxon.field"
>
{{ taxon?.famille }}
{{ taxon[information.field] }}
</td>
</tr>
</tbody>
</table>
<ng-template #noClassification><p>Aucune</p></ng-template>

<!-- <h5 class="underlined underlined-sm main-color">Attribut(s) Taxonomique(s) locaux</h5>
<table class="font-xs table table-striped table-sm">
<tr
class="font-xs"
*ngFor="let attr of taxon?.attributs"
<div *ngIf="taxon?.attributs && (taxon.status.length || !hideLocalAttributesOnEmpty)">
<h5 class="Taxonomy__subtitle">Attribut(s) Taxonomique(s) locaux</h5>
<table
*ngIf="taxon?.attributs && taxon.status.length; else noLocalAttributes"
class="font-xs table table-striped table-sm"
>
<td>
<b>{{ attr.label_attribut }}</b>
</td>
<td>{{ attr.valeur_attribut }}</td>
</tr>
</table> -->

<tr
class="font-xs"
*ngFor="let attr of taxon?.attributs"
>
<td>
<b>{{ attr.label_attribut }}</b>
</td>
<td>{{ attr.valeur_attribut }}</td>
</tr>
</table>
<ng-template #noLocalAttributes><p>Aucun</p></ng-template>
</div>
<h5 class="Taxonomy__subtitle">Statuts</h5>
<table
class="font-xs table table-sm"
*ngIf="taxon?.status; else noStatus"
*ngIf="taxon?.status && taxon.status.length > 0; else noStatus"
>
<ng-container *ngFor="let status of taxon?.status | keyvalue">
<ng-container *ngFor="let status of taxon.status | keyvalue">
<tr class="table-primary">
<th>{{ status.value.display }}</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
&__value {
width: 100%;
padding-left: 1rem;
padding-left: 3rem;
}
}
}
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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<TaxonInformation> = [
{
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',
},
];
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<div class="Taxonomy">
<pnx-synthese-taxonomy [taxon]="taxon" />
<pnx-synthese-taxonomy
[taxon]="taxon"
[hideLocalAttributesOnEmpty]="true"
/>
</div>

0 comments on commit 13154b8

Please sign in to comment.