feat(user-update): Konstante Variablen zur Bestimmung der zulässigen Datumsformate in den Umgebungen erstellt.

- Zugelassene Datumsformate in Combobox als Optionen mit Angular for-Schleife hinzugefügt
This commit is contained in:
Developer 02 2024-10-31 09:03:19 +01:00
parent 2800392be3
commit faac31b3bb
4 changed files with 47 additions and 10 deletions

View File

@ -43,11 +43,11 @@
<mat-form-field> <mat-form-field>
<mat-label>Datumsformat</mat-label> <mat-label>Datumsformat</mat-label>
<mat-select [(value)]="user.dateFormat" [(ngModel)]="user.dateFormat"> <mat-select [(value)]="user.dateFormat" [(ngModel)]="user.dateFormat">
<mat-option value="dd.MM.yyyy">dd.MM.yyyy</mat-option> @for (format of allowedDateFormats; track format) {
<mat-option value="MM.dd.yyyy">MM.dd.yyyy</mat-option> <mat-option [value]="format.value">{{format.name}}</mat-option>
<mat-option value="yyyy-MM-dd">yyyy-MM-dd</mat-option> }
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<!-- comment --> <!-- comment -->
<div class="dd-row input-row"> <div class="dd-row input-row">

View File

@ -15,6 +15,7 @@ import { UserService } from '../../../services/api/user.service';
import { RefreshService } from '../../../services/button/refresh.service'; import { RefreshService } from '../../../services/button/refresh.service';
import Swal from 'sweetalert2'; import Swal from 'sweetalert2';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { env } from '../../../../environments/environment'
@Component({ @Component({
selector: 'app-user-update-form', selector: 'app-user-update-form',
@ -29,6 +30,10 @@ export class UserUpdateFormComponent {
readonly user: User = inject(MAT_DIALOG_DATA); readonly user: User = inject(MAT_DIALOG_DATA);
get allowedDateFormats(): Array<{ value: string, name: string }> {
return env.constants.date_formats;
}
readonly username = new FormControl(this.user.username, [Validators.required]); readonly username = new FormControl(this.user.username, [Validators.required]);
readonly email = new FormControl(this.user.email, [Validators.required, Validators.email]); readonly email = new FormControl(this.user.email, [Validators.required, Validators.email]);
readonly name = new FormControl(this.user.prename, [Validators.required]); readonly name = new FormControl(this.user.prename, [Validators.required]);
@ -79,7 +84,7 @@ export class UserUpdateFormComponent {
this.user.name = this.surname.value!; this.user.name = this.surname.value!;
this.user.shortname = this.shortname.value!; this.user.shortname = this.shortname.value!;
this.user.comment = this.comment.value!; this.user.comment = this.comment.value!;
this.uService.update(this.user).subscribe({ this.uService.update(this.user).subscribe({
next: () => { next: () => {
this.rService.executeAll(); this.rService.executeAll();

View File

@ -53,7 +53,7 @@ export const env = {
field: 'email' field: 'email'
}, },
{ {
header:'Kommentar', header: 'Kommentar',
field: 'comment' field: 'comment'
}, },
{ {
@ -199,5 +199,21 @@ export const env = {
}, },
] ]
}, },
config_url: "/assets/config.json" config_url: "/assets/config.json",
constants: {
date_formats: [
{
value: "dd.MM.yyyy",
name: "dd.MM.yyyy",
},
{
value: "MM.dd.yyyy",
name: "MM.dd.yyyy",
},
{
value: "yyyy-MM-dd",
name: "yyyy-MM-dd",
}
]
}
}; };

View File

@ -53,7 +53,7 @@ export const env = {
field: 'email' field: 'email'
}, },
{ {
header:'Kommentar', header: 'Kommentar',
field: 'comment' field: 'comment'
}, },
{ {
@ -195,5 +195,21 @@ export const env = {
}, },
] ]
}, },
config_url: "/assets/config.json" config_url: "/assets/config.json",
}; constants: {
date_formats: [
{
value: "dd.MM.yyyy",
name: "dd.MM.yyyy",
},
{
value: "MM.dd.yyyy",
name: "MM.dd.yyyy",
},
{
value: "yyyy-MM-dd",
name: "yyyy-MM-dd",
}
]
}
};