Skip to content

Commit

Permalink
Merge pull request #2829 from PnX-SI/hotfix2.13
Browse files Browse the repository at this point in the history
Remove inapropriate datasetStore which cause datasets no fit with permissions
  • Loading branch information
camillemonchicourt authored Dec 15, 2023
2 parents 6f43aa9 + bec1272 commit 8869b75
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<small> {{ label }} </small>
<ng-select
[ngClass]="class"
[items]="datasetStore.datasets"
[items]="datasets"
bindLabel="dataset_name"
[bindValue]="bindValue"
placeholder="Jeux de données"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { DataFormService } from '../data-form.service';
import { GenericFormComponent } from '@geonature_common/form/genericForm.component';
import { CommonService } from '../../service/common.service';
import { DatasetStoreService } from './dataset.service';
import { ConfigService } from '@geonature/services/config.service';
import { AbstractControl, Validators } from '@angular/forms';

Expand All @@ -31,6 +30,7 @@ import { AbstractControl, Validators } from '@angular/forms';
})
export class DatasetsComponent extends GenericFormComponent implements OnInit, OnChanges, DoCheck {
public iterableDiffer: IterableDiffer<any>;
datasets: Array<Object>;
/**
* Permet de filtrer les JDD en fonction d'un tableau d'ID cadre d'acqusition. A connecter avec le formControl du composant ``pnx-acquisition-framework``.
* Utiliser cet Input lorsque le composant ``pnx-acquisition-framework`` est en mode multiselect.
Expand Down Expand Up @@ -62,7 +62,6 @@ export class DatasetsComponent extends GenericFormComponent implements OnInit, O
private _dfs: DataFormService,
private _commonService: CommonService,
private _iterableDiffers: IterableDiffers,
public datasetStore: DatasetStoreService,
public config: ConfigService
) {
super();
Expand All @@ -85,32 +84,23 @@ export class DatasetsComponent extends GenericFormComponent implements OnInit, O
if (this.creatableInModule) {
filter_param['create'] = this.creatableInModule;
}
this._dfs.getDatasets((params = filter_param)).subscribe((res) => {
this.datasetStore.filteredDataSets = res;
this.datasetStore.datasets = res;
this.valueLoaded.emit({ value: this.datasetStore.datasets });
this._dfs.getDatasets((params = filter_param)).subscribe((datasets) => {
this.datasets = datasets;
this.valueLoaded.emit({ value: datasets });
if (
res.length == 1 &&
datasets.length == 1 &&
this.parentFormControl.hasValidator(Validators.required) &&
[null, []].includes(this.parentFormControl.value)
) {
let value: number[] | number = res[0].id_dataset;
let value: number[] | number = datasets[0].id_dataset;
if (this.multiSelect) {
value = [res[0].id_dataset];
value = [datasets[0].id_dataset];
}
this.parentFormControl.patchValue(value);
}
});
}

filterItems(event) {
this.datasetStore.filteredDataSets = super.filterItems(
event,
this.datasetStore.datasets,
'dataset_shortname'
);
}

ngOnChanges(changes) {
// detetch change on input idAcquisitionFramework
// (the number, if the AFcomponent is not multiSelect) to reload datasets
Expand Down

0 comments on commit 8869b75

Please sign in to comment.