Update to Angular v19 and fixing #3

Merged
sandre merged 41 commits from fix/error-after-update-angular-19 into master 2026-01-20 10:56:35 +00:00
3 changed files with 44 additions and 74 deletions
Showing only changes of commit c47fa19c69 - Show all commits

View File

@@ -5,6 +5,7 @@
(ngSubmit)="onCreateSubmit()" (ngSubmit)="onCreateSubmit()"
[formGroup]="createForm" [formGroup]="createForm"
> >
<p>
<mat-form-field> <mat-form-field>
<mat-label>{{ "LoginCreateUser_Firstname" | translate }}</mat-label> <mat-label>{{ "LoginCreateUser_Firstname" | translate }}</mat-label>
<input <input
@@ -22,31 +23,6 @@
{{ "LoginCreateUser_FirstnamePattern" | translate }} {{ "LoginCreateUser_FirstnamePattern" | translate }}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
</form>
<!-- <form
[formGroup]="createForm"
(ngSubmit)="onCreateSubmit()"
autocomplete="off"
style="padding: 10px"
>
<p>
<mat-form-field>
<mat-label>{{ "LoginCreateUser_Firstname" | translate }}</mat-label>
<input
matInput
type="text"
formControlName="firstname"
[ngClass]="{ 'is-invalid': submitted && formCtrls['firstname'].errors }"
tabindex="0"
/>
<mat-error *ngIf="formCtrls['firstname'].hasError('required')">
{{ "LoginCreateUser_FirstnameRequired" | translate }}
</mat-error>
<mat-error *ngIf="formCtrls['firstname'].hasError('minlength')">
{{ "LoginCreateUser_FirstnamePattern" | translate }}
</mat-error>
</mat-form-field>
</p> </p>
<p> <p>
<mat-form-field> <mat-form-field>
@@ -125,4 +101,4 @@
{{ "LoginCreateUser_BtnLogin" | translate }} {{ "LoginCreateUser_BtnLogin" | translate }}
</button> </button>
<div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{ error }}</div> <div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{ error }}</div>
</form> --> </form>

View File

@@ -13,12 +13,13 @@ import {
} from "@ngx-translate/core"; } from "@ngx-translate/core";
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { MatFormFieldModule } from "@angular/material/form-field"; import { MatFormFieldModule } from "@angular/material/form-field";
import { MatInputModule } from "@angular/material/input";
import { MatButtonModule } from "@angular/material/button";
import { first } from "rxjs/operators"; import { first } from "rxjs/operators";
import { AuthenticationService } from "../../services/authentication.service"; import { AuthenticationService } from "../../services/authentication.service";
import { User } from "../../models/user"; import { User } from "../../models/user";
import { MatInput, MatInputModule } from "@angular/material/input";
@Component({ @Component({
selector: "app-create-user", selector: "app-create-user",
@@ -31,6 +32,7 @@ import { MatInput, MatInputModule } from "@angular/material/input";
MatInputModule, MatInputModule,
TranslateModule, TranslateModule,
TranslatePipe, TranslatePipe,
MatButtonModule,
], ],
}) })
export class CreateUserComponent implements OnInit { export class CreateUserComponent implements OnInit {
@@ -39,7 +41,6 @@ export class CreateUserComponent implements OnInit {
public submitted = false; public submitted = false;
public returnUrl: string; public returnUrl: string;
public error: string = ""; public error: string = "";
@ViewChild("firstname") firstnameInput: MatInput;
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
@@ -54,26 +55,22 @@ export class CreateUserComponent implements OnInit {
} }
} }
ngAfterViewInit() {
this.firstnameInput.focus();
}
ngOnInit() { ngOnInit() {
this.createForm = this.formBuilder.group( this.createForm = this.formBuilder.group(
{ {
firstname: ["", [Validators.required, Validators.minLength(3)]], firstname: ["", [Validators.required, Validators.minLength(3)]],
// username: ["", [Validators.required, Validators.minLength(3)]], lastname: ["", [Validators.required, Validators.minLength(3)]],
// password: [ email: ["", [Validators.required, Validators.email]],
// "", username: ["", [Validators.required, Validators.minLength(3)]],
// [ password: [
// Validators.required, "",
// Validators.pattern( [
// "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[@$!%*#?&-_|]).{8,}$" Validators.required,
// ), Validators.pattern(
// ], "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[@$!%*#?&-_|]).{8,}$"
// ], ),
// lastname: ["", [Validators.required, Validators.minLength(3)]], ],
// email: ["", [Validators.required, Validators.email]], ],
}, },
{ updateOn: "blur" } { updateOn: "blur" }
); );
@@ -87,28 +84,28 @@ export class CreateUserComponent implements OnInit {
} }
onCreateSubmit() { onCreateSubmit() {
// this.invalidForm = false; this.invalidForm = false;
// this.submitted = true; this.submitted = true;
// if (this.createForm.invalid) { if (this.createForm.invalid) {
// this.invalidForm = true; this.invalidForm = true;
// return; return;
// } }
// let createUser = new User(); let createUser = new User();
// createUser.login = this.formCtrls["username"].value; createUser.login = this.formCtrls["username"].value;
// createUser.password = this.formCtrls["password"].value; createUser.password = this.formCtrls["password"].value;
// createUser.firstName = this.formCtrls["firstname"].value; createUser.firstName = this.formCtrls["firstname"].value;
// createUser.lastName = this.formCtrls["lastname"].value; createUser.lastName = this.formCtrls["lastname"].value;
// createUser.email = this.formCtrls["email"].value; createUser.email = this.formCtrls["email"].value;
// createUser.language = this.translateService.getCurrentLang(); createUser.language = this.translateService.getCurrentLang();
// this.authenticationService this.authenticationService
// .create(createUser) .create(createUser)
// .pipe(first()) .pipe(first())
// .subscribe({ .subscribe({
// complete: () => this.router.navigate([this.returnUrl]), complete: () => this.router.navigate([this.returnUrl]),
// error: (error) => { error: (error) => {
// this.error = error.message; this.error = error.message;
// this.invalidForm = false; this.invalidForm = false;
// }, },
// }); });
} }
} }

View File

@@ -10,6 +10,7 @@ import {
import { TranslateModule, TranslatePipe } from "@ngx-translate/core"; import { TranslateModule, TranslatePipe } from "@ngx-translate/core";
import { MatInput, MatInputModule } from "@angular/material/input"; import { MatInput, MatInputModule } from "@angular/material/input";
import { MatFormFieldModule } from "@angular/material/form-field"; import { MatFormFieldModule } from "@angular/material/form-field";
import { MatButtonModule } from "@angular/material/button";
import { first } from "rxjs/operators"; import { first } from "rxjs/operators";
@@ -26,15 +27,15 @@ import { AuthenticationService } from "../../services/authentication.service";
MatInputModule, MatInputModule,
TranslateModule, TranslateModule,
TranslatePipe, TranslatePipe,
MatButtonModule,
], ],
}) })
export class LoginUserComponent implements OnInit, AfterViewInit { export class LoginUserComponent implements OnInit {
public loginForm: FormGroup; public loginForm: FormGroup;
public loading = false; public loading = false;
public submitted = false; public submitted = false;
public returnUrl: string; public returnUrl: string;
public error: string = ""; public error: string = "";
@ViewChild("username") userNameInput: MatInput;
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
@@ -47,10 +48,6 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
} }
} }
ngAfterViewInit() {
this.userNameInput.focus();
}
ngOnInit() { ngOnInit() {
this.loginForm = this.formBuilder.group( this.loginForm = this.formBuilder.group(
{ {