empty strings or zero will be converted to null

This commit is contained in:
Andreas Knuth 2024-09-11 11:49:47 +02:00
parent 83307684ee
commit fe759f953f
5 changed files with 19 additions and 17 deletions

View File

@ -27,8 +27,8 @@ export class ValidatedInputComponent extends BaseInputComponent {
super(validationMessagesService); super(validationMessagesService);
} }
onInputChange(event: Event): void { onInputChange(event: string): void {
this.value = event; this.value = event?.length > 0 ? event : null;
this.onChange(event); this.onChange(this.value);
} }
} }

View File

@ -41,6 +41,7 @@ export class ValidatedLocationComponent extends BaseInputComponent {
} }
onInputChange(event: Place): void { onInputChange(event: Place): void {
this.value = event; //{ ...event, longitude: parseFloat(event.longitude), latitude: parseFloat(event.latitude) }; this.value = event; //{ ...event, longitude: parseFloat(event.longitude), latitude: parseFloat(event.latitude) };
if (event) {
this.value = { this.value = {
id: event?.place_id, id: event?.place_id,
name: event?.address.city, name: event?.address.city,
@ -51,6 +52,7 @@ export class ValidatedLocationComponent extends BaseInputComponent {
latitude: event ? parseFloat(event?.lat) : undefined, latitude: event ? parseFloat(event?.lat) : undefined,
longitude: event ? parseFloat(event?.lon) : undefined, longitude: event ? parseFloat(event?.lon) : undefined,
}; };
}
this.onChange(this.value); this.onChange(this.value);
} }
private loadCities() { private loadCities() {

View File

@ -29,6 +29,6 @@ export class ValidatedPriceComponent extends BaseInputComponent {
onInputChange(event: Event): void { onInputChange(event: Event): void {
this.value = !event ? null : event; this.value = !event ? null : event;
this.onChange(event); this.onChange(this.value);
} }
} }

View File

@ -23,8 +23,8 @@ export class ValidatedTextareaComponent extends BaseInputComponent {
super(validationMessagesService); super(validationMessagesService);
} }
onInputChange(event: Event): void { onInputChange(event: string): void {
this.value = event; this.value = event?.length > 0 ? event : null;
this.onChange(this.value); this.onChange(this.value);
} }
} }

View File

@ -7,7 +7,7 @@
<div class="md:col-span-2"> <div class="md:col-span-2">
<label for="email" class="block text-sm font-medium text-gray-700">E-mail (required)</label> <label for="email" class="block text-sm font-medium text-gray-700">E-mail (required)</label>
<input type="email" id="email" name="email" [(ngModel)]="user.email" disabled class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" /> <input type="email" id="email" name="email" [(ngModel)]="user.email" disabled class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" />
<p class="text-xs text-gray-500 mt-1">You can only modify your email by contacting us at support&#64;bizwatch.net</p> <p class="text-xs text-gray-500 mt-1">You can only modify your email by contacting us at support&#64;bizmatch.net</p>
</div> </div>
@if (isProfessional || isAdmin()){ @if (isProfessional || isAdmin()){
<div class="flex flex-row items-center justify-around md:space-x-4"> <div class="flex flex-row items-center justify-around md:space-x-4">