Skip to content

Commit

Permalink
refact: remove unused regnes and group filters
Browse files Browse the repository at this point in the history
Reviewed-by: andriacap
  • Loading branch information
andriacap committed Dec 18, 2024
1 parent 178417b commit 6d7c90b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
<div [(ngbCollapse)]="isCollapseTaxonomy">
<div class="well well-sm well-margin">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<small class="font-sm">Règne:</small>
<select [formControl]="regneControl" class="form-control form-control-sm">
<option *ngFor="let regne of regnes" [value]="regne">{{ regne }}</option>
</select>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<div *ngIf="regneControl.value !== null">
<small class="font-sm">Groupe:</small>
<select
[formControl]="groupControl"
class="form-control form-control-sm"
id="sel1"
placeholder="Taxonomiques"
>
<option
class="clickable"
*ngFor="let group2 of regnesAndGroup[regneControl.value]"
[value]="group2"
>
{{ group2 }}
</option>
</select>
</div>
</div>
</div>
</div>
</div>
<h5 > {{ label }} </h5>
<div class="input-group">
<input
Expand All @@ -49,18 +18,8 @@ <h5 > {{ label }} </h5>
[required]="isRequired"
[placeholder]="placeholder"
/>
<div class="input-group-append" *ngIf="displayAdvancedFilters">
<button
(click)="isCollapseTaxonomy = !isCollapseTaxonomy"
[attr.aria-expanded]="!isCollapseTaxonomy"
class="btn btn-sm btn-outline-shadow"
matTooltip="Filtrer les taxons proposés à l'autocompletion par règne et groupe INPN"
>
<i class="fa fa-filter" aria-hidden="true"></i>
</button>
</div>

<ng-template #rt let-r="result" let-t="term">
<ng-template #rt let-r="result" let-t="term">
<span [innerHTML]="r.search_name"> </span>
</ng-template>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,15 @@ export class SearchAutocompleteTaxonomyComponent implements OnInit, OnChanges {
// ** Pour changer la valeur affichée */
@Input() displayedLabel = 'nom_vern';
/** Afficher ou non les filtres par regne et groupe INPN qui controle l'autocomplétion */
@Input() displayAdvancedFilters = false;
@Input() isRequired = true;
@Input() placeholder = '';
isInvalidDirty = false;
searchString: any;
filteredTaxons: any;
regnes = [];
regneControl = new FormControl(null);
groupControl = new FormControl(null);
regnesAndGroup: any;
noResult: boolean;
isLoading = false;
@Output() onChange = new EventEmitter<NgbTypeaheadSelectItemEvent>(); // renvoie l'evenement, le taxon est récupérable grâce à e.item
@Output() onDelete = new EventEmitter<TaxonBase>();
@Output() emptyInput: EventEmitter<boolean> = new EventEmitter<boolean>();

public isCollapseTaxonomy = true;

public config = MainConfig;
constructor(private _dfService: DataFormService) {}

Expand Down Expand Up @@ -113,23 +105,6 @@ export class SearchAutocompleteTaxonomyComponent implements OnInit, OnChanges {
this.onDelete.emit();
}
});

if (this.displayAdvancedFilters) {
// get regne and group2
this._dfService.getRegneAndGroup2Inpn().subscribe((data) => {
this.regnesAndGroup = data;
for (const regne in data) {
this.regnes.push(regne);
}
});
}

// put group to null if regne = null
this.regneControl.valueChanges.subscribe((value) => {
if (value === '') {
this.groupControl.patchValue(null);
}
});
}

ngOnChanges(changes) {
Expand Down Expand Up @@ -184,8 +159,6 @@ export class SearchAutocompleteTaxonomyComponent implements OnInit, OnChanges {
if (search_name.length >= this.charNumber) {
return this._dfService
.autocompleteTaxon(this.apiEndPoint, search_name, {
regne: this.regneControl.value,
group2_inpn: this.groupControl.value,
limit: this.listLength.toString(),
})
.pipe(
Expand Down

0 comments on commit 6d7c90b

Please sign in to comment.