diff --git a/frontend/src/app/components/condition-report-page/condition-report-details-section.html b/frontend/src/app/components/condition-report-page/condition-report-details-section.html index fbec1e0..c856228 100644 --- a/frontend/src/app/components/condition-report-page/condition-report-details-section.html +++ b/frontend/src/app/components/condition-report-page/condition-report-details-section.html @@ -2,16 +2,11 @@

Date et fuseau

@@ -27,7 +22,7 @@ Présence } @@ -57,7 +52,7 @@ + diff --git a/frontend/src/app/components/condition-report-page/condition-report-details-section.ts b/frontend/src/app/components/condition-report-page/condition-report-details-section.ts index 00573f8..2205d82 100644 --- a/frontend/src/app/components/condition-report-page/condition-report-details-section.ts +++ b/frontend/src/app/components/condition-report-page/condition-report-details-section.ts @@ -20,23 +20,19 @@ export class ConditionReportDetailsSection { readonly reportChanged = output(); readonly states = states; - setOccurredOn(occurredOn: string): void { - this.update((report) => ({ ...report, occurredOn })); + setOccurredOn(event: Event): void { + this.update((report) => ({ ...report, occurredOn: this.value(event) })); } - setTimeZone(timeZone: string): void { - this.update((report) => ({ ...report, timeZone })); + setTimeZone(event: Event): void { + this.update((report) => ({ ...report, timeZone: this.value(event) })); } - updateParticipant( - index: number, - field: 'attendance' | 'representativeName', - value: string, - ): void { + updateParticipant(index: number, field: 'attendance' | 'representativeName', event: Event): void { this.update((report) => ({ ...report, participants: report.participants.map((participant, item) => - item === index ? { ...participant, [field]: value } : participant, + item === index ? { ...participant, [field]: this.value(event) } : participant, ), })); } @@ -53,10 +49,12 @@ export class ConditionReportDetailsSection { })); } - updateZone(id: string, field: 'privateAreaId' | 'label' | 'equipment', value: string): void { + updateZone(id: string, field: 'privateAreaId' | 'label' | 'equipment', event: Event): void { this.update((report) => ({ ...report, - zones: report.zones.map((zone) => (zone.id === id ? { ...zone, [field]: value } : zone)), + zones: report.zones.map((zone) => + zone.id === id ? { ...zone, [field]: this.value(event) } : zone, + ), })); } @@ -76,11 +74,11 @@ export class ConditionReportDetailsSection { ); } - updateObservation(id: string, field: 'state' | 'observation', value: string): void { + updateObservation(id: string, field: 'state' | 'observation', event: Event): void { this.update((report) => ({ ...report, observations: report.observations.map((observation) => - observation.subjectId === id ? { ...observation, [field]: value } : observation, + observation.subjectId === id ? { ...observation, [field]: this.value(event) } : observation, ), })); } @@ -109,4 +107,13 @@ export class ConditionReportDetailsSection { private update(change: (report: PropertyConditionReport) => PropertyConditionReport): void { this.reportChanged.emit(change(this.report())); } + + private value(event: Event): string { + const target = event.target; + return target instanceof HTMLInputElement || + target instanceof HTMLSelectElement || + target instanceof HTMLTextAreaElement + ? target.value + : ''; + } } diff --git a/frontend/src/app/components/condition-report-page/condition-report-evidence-section.html b/frontend/src/app/components/condition-report-page/condition-report-evidence-section.html index 5f082af..3900b7b 100644 --- a/frontend/src/app/components/condition-report-page/condition-report-evidence-section.html +++ b/frontend/src/app/components/condition-report-page/condition-report-evidence-section.html @@ -6,10 +6,7 @@

{{ zone.label }}

diff --git a/frontend/src/app/components/condition-report-page/condition-report-evidence-section.ts b/frontend/src/app/components/condition-report-page/condition-report-evidence-section.ts index e67b7d2..7d648fe 100644 --- a/frontend/src/app/components/condition-report-page/condition-report-evidence-section.ts +++ b/frontend/src/app/components/condition-report-page/condition-report-evidence-section.ts @@ -39,7 +39,8 @@ export class ConditionReportEvidenceSection implements OnDestroy { ); } - setZoneAbsence(zoneId: string, reason: string): void { + setZoneAbsence(zoneId: string, event: Event): void { + const reason = this.value(event); this.update((report) => ({ ...report, zonePhotoAbsences: [ @@ -52,8 +53,9 @@ export class ConditionReportEvidenceSection implements OnDestroy { setEntryPhotoDisposition( entryPhotoId: string, field: keyof EntryPhotoDisposition, - value: string, + event: Event, ): void { + const value = this.value(event); this.update((report) => { const current = report.entryPhotoDispositions.find( (item) => item.entryPhotoId === entryPhotoId, @@ -148,4 +150,11 @@ export class ConditionReportEvidenceSection implements OnDestroy { private update(change: (report: PropertyConditionReport) => PropertyConditionReport): void { this.reportChanged.emit(change(this.report())); } + + private value(event: Event): string { + const target = event.target; + return target instanceof HTMLInputElement || target instanceof HTMLSelectElement + ? target.value + : ''; + } } diff --git a/frontend/src/app/components/condition-report-page/condition-report-inventory-section.html b/frontend/src/app/components/condition-report-page/condition-report-inventory-section.html index d950d2a..1708bf6 100644 --- a/frontend/src/app/components/condition-report-page/condition-report-inventory-section.html +++ b/frontend/src/app/components/condition-report-page/condition-report-inventory-section.html @@ -5,10 +5,7 @@ {{ meter.label || meter.type }} @if (meter.state === 'RECORDED') { } @@ -86,10 +73,7 @@ {{ access.destination || 'Accès' }}