| @@ -2836,7 +2836,6 @@ components: | |||||
| required: | required: | ||||
| - trip | - trip | ||||
| - user | - user | ||||
| - completed | |||||
| UserTrip.jsonld: | UserTrip.jsonld: | ||||
| type: object | type: object | ||||
| description: '' | description: '' | ||||
| @@ -2901,7 +2900,6 @@ components: | |||||
| required: | required: | ||||
| - trip | - trip | ||||
| - user | - user | ||||
| - completed | |||||
| UserTripEvent: | UserTripEvent: | ||||
| type: object | type: object | ||||
| description: '' | description: '' | ||||
| @@ -140,7 +140,7 @@ export const userTripForm = new FormGroup({ | |||||
| trip: new FormControl(null, [Validators.required]), | trip: new FormControl(null, [Validators.required]), | ||||
| user: new FormControl(null, [Validators.required]), | user: new FormControl(null, [Validators.required]), | ||||
| captainName: new FormControl(null, []), | captainName: new FormControl(null, []), | ||||
| completed: new FormControl(null, [Validators.required]), | |||||
| completed: new FormControl(null, []), | |||||
| signature: new FormControl(null, []), | signature: new FormControl(null, []), | ||||
| signatureUrl: new FormControl(null, []), | signatureUrl: new FormControl(null, []), | ||||
| completedDate: new FormControl(null, []), | completedDate: new FormControl(null, []), | ||||
| @@ -152,7 +152,7 @@ export const userTripJsonldForm = new FormGroup({ | |||||
| trip: new FormControl(null, [Validators.required]), | trip: new FormControl(null, [Validators.required]), | ||||
| user: new FormControl(null, [Validators.required]), | user: new FormControl(null, [Validators.required]), | ||||
| captainName: new FormControl(null, []), | captainName: new FormControl(null, []), | ||||
| completed: new FormControl(null, [Validators.required]), | |||||
| completed: new FormControl(null, []), | |||||
| signature: new FormControl(null, []), | signature: new FormControl(null, []), | ||||
| signatureUrl: new FormControl(null, []), | signatureUrl: new FormControl(null, []), | ||||
| completedDate: new FormControl(null, []), | completedDate: new FormControl(null, []), | ||||
| @@ -74,7 +74,6 @@ export class UserTripFormComponent extends AbstractDataFormComponent<UserTripJso | |||||
| } | } | ||||
| override onSubmit(): void { | override onSubmit(): void { | ||||
| //if (!this.form.valid) return; | |||||
| if (!this.form.valid) { | if (!this.form.valid) { | ||||
| console.log('Form is invalid:', this.form.errors); | console.log('Form is invalid:', this.form.errors); | ||||
| Object.keys(this.form.controls).forEach(key => { | Object.keys(this.form.controls).forEach(key => { | ||||
| @@ -88,12 +87,19 @@ export class UserTripFormComponent extends AbstractDataFormComponent<UserTripJso | |||||
| // Wenn keine Datei ausgewählt wurde, rufe direkt die Elternmethode auf | // Wenn keine Datei ausgewählt wurde, rufe direkt die Elternmethode auf | ||||
| if (!this.selectedFile) { | if (!this.selectedFile) { | ||||
| // Wenn keine Datei ausgewählt wurde und keine vorhandene Signature existiert, | |||||
| // setzen wir sie auf undefined (nicht null) | |||||
| const currentValue = this.form.get('signature')?.value; | |||||
| if (currentValue === null) { | |||||
| this.form.patchValue({ | |||||
| signature: undefined | |||||
| }); | |||||
| } | |||||
| super.onSubmit(); | super.onSubmit(); | ||||
| return; | return; | ||||
| } | } | ||||
| // 1. Handle file upload if a file is selected | // 1. Handle file upload if a file is selected | ||||
| // Blob direkt verwenden, keine FormData erforderlich | |||||
| this.mediaObjectService.mediaObjectsPost(this.selectedFile).subscribe({ | this.mediaObjectService.mediaObjectsPost(this.selectedFile).subscribe({ | ||||
| next: (mediaObject) => { | next: (mediaObject) => { | ||||
| // 2. Update the form data with the new mediaObject | // 2. Update the form data with the new mediaObject | ||||
| @@ -101,6 +107,8 @@ export class UserTripFormComponent extends AbstractDataFormComponent<UserTripJso | |||||
| signature: mediaObject | signature: mediaObject | ||||
| }); | }); | ||||
| console.log('Form after file upload:', this.form.value); | |||||
| // 3. Call the parent method to handle the standard save process | // 3. Call the parent method to handle the standard save process | ||||
| super.onSubmit(); | super.onSubmit(); | ||||
| }, | }, | ||||
| @@ -22,7 +22,7 @@ export interface UserTrip { | |||||
| trip: Trip; | trip: Trip; | ||||
| user: User; | user: User; | ||||
| captainName?: string | null; | captainName?: string | null; | ||||
| completed: boolean; | |||||
| completed?: boolean; | |||||
| signature?: MediaObject; | signature?: MediaObject; | ||||
| readonly signatureUrl?: string | null; | readonly signatureUrl?: string | null; | ||||
| completedDate?: string | null; | completedDate?: string | null; | ||||
| @@ -26,7 +26,7 @@ export interface UserTripJsonld { | |||||
| trip: TripJsonld; | trip: TripJsonld; | ||||
| user: UserJsonld; | user: UserJsonld; | ||||
| captainName?: string | null; | captainName?: string | null; | ||||
| completed: boolean; | |||||
| completed?: boolean; | |||||
| signature?: MediaObjectJsonld; | signature?: MediaObjectJsonld; | ||||
| readonly signatureUrl?: string | null; | readonly signatureUrl?: string | null; | ||||
| completedDate?: string | null; | completedDate?: string | null; | ||||
| @@ -95,8 +95,7 @@ class UserTripApi | |||||
| public ?string $captainName = null; | public ?string $captainName = null; | ||||
| #[Assert\NotBlank] | |||||
| public bool $completed; | |||||
| public bool $completed = false; | |||||
| /** | /** | ||||
| * @var MediaObjectApi | * @var MediaObjectApi | ||||
| @@ -54,9 +54,9 @@ class UserTripEntityToApiMapper implements MapperInterface | |||||
| MicroMapperInterface::MAX_DEPTH => 1, | MicroMapperInterface::MAX_DEPTH => 1, | ||||
| ]); | ]); | ||||
| $dto->signatureUrl = null; | |||||
| $dto->signature = null; | |||||
| if ($entity->getSignature() !== null) { | if ($entity->getSignature() !== null) { | ||||
| $dto->signatureUrl = $this->microMapper->map($entity->getSignature(), MediaObjectApi::class, [ | |||||
| $dto->signature = $this->microMapper->map($entity->getSignature(), MediaObjectApi::class, [ | |||||
| MicroMapperInterface::MAX_DEPTH => 1, | MicroMapperInterface::MAX_DEPTH => 1, | ||||
| ]); | ]); | ||||
| } | } | ||||