Skip to content

Commit

Permalink
feat: add taxonomy tab + status badges to species page
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Sep 26, 2024
1 parent d5cca73 commit a0c1b4a
Show file tree
Hide file tree
Showing 25 changed files with 405 additions and 673 deletions.
4 changes: 4 additions & 0 deletions backend/geonature/core/gn_synthese/synthese_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class DefaultProfile:
]


class DefaultTaxonomy:
ENABLED = True


class DefaultGeographicOverview:
pass

Expand Down
6 changes: 6 additions & 0 deletions backend/geonature/utils/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DEFAULT_LIST_COLUMN,
DefaultGeographicOverview,
DefaultProfile,
DefaultTaxonomy,
DefaultSpeciesSheet,
)
from geonature.utils.env import GEONATURE_VERSION, BACKEND_DIR, ROOT_DIR
Expand Down Expand Up @@ -277,6 +278,10 @@ class ExportObservationSchema(Schema):
geojson_local_field = fields.String(load_default="geojson_local")


class SpeciesSheetTaxonomy(Schema):
ENABLED = fields.Boolean(load_default=DefaultTaxonomy.ENABLED)


class SpeciesSheetProfile(Schema):
ENABLED = fields.Boolean(load_default=DefaultProfile.ENABLED)
LIST_INDICATORS = fields.List(fields.Dict, load_default=DefaultProfile.LIST_INDICATORS)
Expand All @@ -295,6 +300,7 @@ class SpeciesSheet(Schema):
load_default=SpeciesSheetGeographicOverview().load({})
) # rename
PROFILE = fields.Nested(SpeciesSheetProfile, load_default=SpeciesSheetProfile().load({}))
TAXONOMY = fields.Nested(SpeciesSheetTaxonomy, load_default=SpeciesSheetTaxonomy().load({}))


class Synthese(Schema):
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/GN2CommonModule/form/data-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ export class DataFormService {
});
}

fetchStatusSymbology() {
return this._http.get<any>(`${this.config.API_TAXHUB}/bdc_statuts/status_symbologies`);
}

getTaxonAttributsAndMedia(cd_nom: number, id_attributs?: Array<number>) {
let query_string = new HttpParams();
if (id_attributs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface Taxon {
nom_vern?: string;
ordre?: string;
phylum?: string;
statuts_protection?: any[];
status?: any[];
synonymes?: any[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,88 +382,7 @@ <h4 class="mr-auto gn-color">
</mat-tab>

<mat-tab label="Taxonomie">
<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 selectObsTaxonInfo?.attributs"
>
<td>
<b>{{ attr.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" />
</mat-tab>
<ng-container *ngIf="selectedObs?.medias?.length">
<mat-tab label="Médias">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<div class="Taxonomy">
<h5 class="Taxonomy__subtitle">Classification</h5>
<table 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>
<td
class="Classification__value"
data-qa="synthese-obs-detail-taxo-familly"
>
{{ taxon?.famille }}
</td>
</tr>
</tbody>
</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 taxon?.attributs"
>
<td>
<b>{{ attr.label_attribut }}</b>
</td>
<td>{{ attr.valeur_attribut }}</td>
</tr>
</table> -->

<h5 class="Taxonomy__subtitle">Statuts</h5>
<table
class="font-xs table table-sm"
*ngIf="taxon?.status; else noStatus"
>
<ng-container *ngFor="let status of taxon?.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>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.Taxonomy {
display: flex;
flex-flow: column;
justify-content: flex-start;
row-gap: 0.5rem;

&__subtitle {
text-decoration: underline;
text-decoration-color: currentColor;
text-underline-offset: 0.4rem;
text-decoration-thickness: 2px;
}
.Classification {
&__name {
font-weight: bold;
white-space: nowrap;
}
&__value {
width: 100%;
padding-left: 1rem;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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';

@Component({
selector: 'pnx-synthese-taxonomy',
templateUrl: 'taxonomy.component.html',
styleUrls: ['taxonomy.component.scss'],
})
export class TaxonomyComponent {
@Input()
taxon: Taxon | null = null;
constructor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@ import { ClipboardModule } from '@angular/cdk/clipboard';
import { SyntheseInfoObsComponent } from './synthese-info-obs/synthese-info-obs.component';
import { DiscussionCardComponent } from '../discussionCardModule/discussion-card.component';
import { AlertInfoComponent } from '../alertInfoModule/alert-Info.component';
import { TaxonomyComponent } from './synthese-info-obs/taxonomy/taxonomy.component';

@NgModule({
imports: [CommonModule, GN2CommonModule, NgChartsModule, RouterModule, ClipboardModule],
exports: [SyntheseInfoObsComponent, DiscussionCardComponent, AlertInfoComponent],
declarations: [SyntheseInfoObsComponent, DiscussionCardComponent, AlertInfoComponent],
exports: [
SyntheseInfoObsComponent,
DiscussionCardComponent,
AlertInfoComponent,
TaxonomyComponent,
],
declarations: [
SyntheseInfoObsComponent,
DiscussionCardComponent,
AlertInfoComponent,
TaxonomyComponent,
],
providers: [],
})
export class SharedSyntheseModule {}
Loading

0 comments on commit a0c1b4a

Please sign in to comment.