Skip to content

Commit

Permalink
feat: update status and taxonomy in species-page
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Sep 17, 2024
1 parent 4365d25 commit 2b7f293
Show file tree
Hide file tree
Showing 21 changed files with 264 additions and 115 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
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,84 @@
<div class="Taxonomy">
<table class="font-xs table table-striped table-sm">
<tr>
<td>
<b>Groupe taxonomique</b>
</td>
<td>{{ taxon?.classe }}</td>
</tr>
<tr>
<td>
<b>Ordre</b>
</td>
<td>{{ taxon?.ordre }}</td>
</tr>
<tr>
<td>
<b>Famille</b>
</td>
<td data-qa="synthese-obs-detail-taxo-familly">{{ taxon?.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 taxon?.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="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,2 @@
.Taxonomy {
}
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 {}
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<div class="Infos">
<div class="Infos__infos">
<div
class="Infos__infosCompleteName"
*ngIf="taxon?.nom_complet"
>
{{ taxon?.nom_complet }}
</div>
<div
class="Infos__infosVernacularName"
*ngIf="taxon?.nom_vern"
>
{{ taxon?.nom_vern }}
</div>
</div>
<taxonomy [taxon]="taxon"></taxonomy>
<status [taxon]="taxon"></status>
</div>
<div
class="card"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
.Infos {
display: flex;
flex-flow: row nowrap;
flex-flow: column;
justify-content: flex-start;
column-gap: 1rem;

&__infos {
display: flex;
flex-flow: column;
&CompleteName {
font-weight: lighter;
font-style: italic;
}
&VernacularName {
font-size: 1.5rem;
font-weight: bold;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { DataFormService } from '@geonature_common/form/data-form.service';
import { ConfigService } from '@geonature/services/config.service';
import { TaxonSheetService } from '../taxon-sheet.service';

import { StatusComponent } from './status/status.component';
import { TaxonomyComponent } from './taxonomy/taxonomy.component';

@Component({
standalone: true,
selector: 'infos',
templateUrl: 'infos.component.html',
styleUrls: ['infos.component.scss'],
imports: [CommonModule],
imports: [CommonModule, StatusComponent, TaxonomyComponent],
})
export class InfosComponent implements OnInit {
mediaUrl: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="Status">
<div class="Status__header">Statuts</div>
<span
class="badge badge-secondary"
*ngFor="let status of status; let isLast = last"
matTooltip="{{ status.longName }}"
>
{{ status.shortName }}
</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.Status {
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
column-gap: 0.5rem;
line-height: 1;

&__header {
vertical-align: middle;
}
.badge {
line-height: inherit;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core';
import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component';
import { GN2CommonModule } from '@geonature_common/GN2Common.module';

interface Status {
shortName: string;
longName: string;
}

@Component({
standalone: true,
selector: 'status',
templateUrl: 'status.component.html',
styleUrls: ['status.component.scss'],
imports: [CommonModule, GN2CommonModule],
})
export class StatusComponent {
status: Array<Status> = [];
@Input()
set taxon(taxon: Taxon | null) {
if (!taxon) {
this.status = [];
return;
}
this.status = Object.values(taxon.status).map((status) => {
return {
shortName: status.cd_type_statut,
longName: status.lb_type_statut,
};
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="Taxonomy">
<div class="Taxonomy__completeName">
{{ taxon?.nom_complet }}
</div>
<div class="Taxonomy__vernacularName">
{{ taxon?.nom_vern }}
</div>
</div>
Loading

0 comments on commit 2b7f293

Please sign in to comment.