From 6cbd03fa745707eacc7847a60fb6386e811a2d99 Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Mon, 31 Oct 2022 07:59:38 +0000 Subject: [PATCH] fix: update protection on display and fix data share consent edit --- src/app/models/structure.model.ts | 5 +++-- src/app/services/structure.service.ts | 3 --- .../data-share-consent.component.ts | 14 +++++++++++--- src/app/utils/formUtils.ts | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 8bdb053ef..2913e4112 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -187,11 +187,12 @@ export class Structure { } public getLabelTypeStructure(): StructureTypeEnum | '' { - return StructureTypeEnum[this.structureType.value] || ''; + if (this.structureType) return StructureTypeEnum[this.structureType.value] || ''; + return ''; } public getTypeStructureIcon(): StructureCategoryIconEnum { - switch (this.structureType.category) { + switch (this.structureType?.category) { case StructureCategoryEnum.public: return StructureCategoryIconEnum['public']; case StructureCategoryEnum.private: diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index f8d6af25f..0224f445a 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -35,9 +35,6 @@ export class StructureService { public editStructure(structure: Partial<Structure>, structureId?: string): Observable<Structure> { structure.updatedAt = new Date().toString(); - if (structure.dataShareConsentDate) { - structure.dataShareConsentDate = new Date().toString(); - } if (!structureId) structureId = structure._id; delete structure._id; // id should not be provided for update return this.http diff --git a/src/app/shared/components/data-share-consent/data-share-consent.component.ts b/src/app/shared/components/data-share-consent/data-share-consent.component.ts index 04717b46d..476e73811 100644 --- a/src/app/shared/components/data-share-consent/data-share-consent.component.ts +++ b/src/app/shared/components/data-share-consent/data-share-consent.component.ts @@ -78,9 +78,17 @@ export class DataShareConsentComponent implements OnInit { this.submitted = true; this.loading = true; for (let structure of this.dataConsentPendingStructures) { - this.structureService.editStructure(structure).subscribe((_s: Structure) => {}); + this.structureService + .editStructure( + { + dataShareConsentDate: structure.dataShareConsentDate, + }, + structure._id + ) + .subscribe((_s: Structure) => { + this.loading = false; + this.openned = false; + }); } - this.loading = false; - this.openned = false; } } diff --git a/src/app/utils/formUtils.ts b/src/app/utils/formUtils.ts index 005b30292..40e915ce0 100644 --- a/src/app/utils/formUtils.ts +++ b/src/app/utils/formUtils.ts @@ -125,7 +125,7 @@ export class formUtils { handicaps: this.loadArrayForCheckbox(structure.categories.handicaps, false), age: this.loadArrayForCheckbox(structure.categories.age, true), languageAndIlliteracy: this.loadArrayForCheckbox(structure.categories.languageAndIlliteracy, false), - selfServiceMaterial: this.loadArrayForCheckbox(structure.categories.selfServiceMaterial, true), + selfServiceMaterial: this.loadArrayForCheckbox(structure.categories.selfServiceMaterial, false), publicOthers: this.loadArrayForCheckbox(structure.categories.publicOthers, false), equipmentsAndServices: this.loadArrayForCheckbox(structure.categories.equipmentsServices, false), baseSkills: new UntypedFormControl(structure.categories.baseSkills), -- GitLab