From bec127297d21bac042954ff21d1bad70d03cc962 Mon Sep 17 00:00:00 2001 From: Andria Capai Date: Fri, 1 Dec 2023 18:02:01 +0100 Subject: [PATCH] Remove innapropriate datasetStore which cause datasets no fit with permissions [Refs_ticket]: #2815 --- .../form/datasets/dataset.service.ts | 9 ------- .../form/datasets/datasets.component.html | 2 +- .../form/datasets/datasets.component.ts | 24 ++++++------------- 3 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 frontend/src/app/GN2CommonModule/form/datasets/dataset.service.ts diff --git a/frontend/src/app/GN2CommonModule/form/datasets/dataset.service.ts b/frontend/src/app/GN2CommonModule/form/datasets/dataset.service.ts deleted file mode 100644 index e675238a33..0000000000 --- a/frontend/src/app/GN2CommonModule/form/datasets/dataset.service.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Injectable } from '@angular/core'; -import { DataFormService } from '../data-form.service'; - -@Injectable({ providedIn: 'root' }) -export class DatasetStoreService { - public filteredDataSets: Array; - public datasets: Array; - constructor() {} -} diff --git a/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.html b/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.html index 7c4b05c171..29116ba0a4 100644 --- a/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.html +++ b/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.html @@ -1,7 +1,7 @@ {{ label }} ; + datasets: Array; /** * 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. @@ -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(); @@ -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