Skip to content

Commit fdd842d

Browse files
Copilotrenemadsen
andcommitted
Refactor all constructors to use inject() function instead of constructor parameter injection
Co-authored-by: renemadsen <[email protected]>
1 parent c7b1cf2 commit fdd842d

File tree

185 files changed

+1091
-1388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+1091
-1388
lines changed

eform-client/src/app/common/guards/admin.guard.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {AuthStateService} from 'src/app/common/store';
88

99
@Injectable()
1010
export class AdminGuard {
11-
constructor(
12-
private router: Router,
13-
private store: Store,
14-
private authStateService: AuthStateService,
15-
) {
11+
private router = inject(Router);
12+
private store = inject(Store);
13+
private authStateService = inject(AuthStateService);
14+
15+
constructor() {
1616
console.debug('AdminGuard - constructor');
1717
}
1818

eform-client/src/app/common/guards/auth.guard.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212

1313
@Injectable()
1414
export class AuthGuard {
15-
constructor(
16-
private store: Store,
17-
private router: Router,
18-
) {
15+
private store = inject(Store);
16+
private router = inject(Router);
17+
18+
constructor() {
1919
this.isAuth$.subscribe(x => this.isAuth = x);
2020
this.loginRedirectUrl$.subscribe(x => this.loginRedirectUrl = x);
2121
}

eform-client/src/app/common/guards/claims.guard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {UserClaimsModel} from 'src/app/common/models';
1212

1313
@Injectable()
1414
export class ClaimsGuard {
15+
private store = inject(Store);
16+
1517

1618
private claims: UserClaimsModel;
1719
private selectCurrentUserClaims$ = this.store.select(selectCurrentUserClaims);
1820

19-
constructor(
20-
private store: Store
21-
) {
21+
constructor() {
2222
this.selectCurrentUserClaims$.subscribe(x => this.claims = x);
2323
}
2424

eform-client/src/app/common/guards/permission.guard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {Store} from '@ngrx/store';
1212

1313
@Injectable()
1414
export class PermissionGuard {
15+
private store = inject(Store);
16+
1517
private selectCurrentUserClaims$ = this.store.select(selectCurrentUserClaims);
1618

17-
constructor(
18-
private store: Store
19-
) {
19+
constructor() {
2020
console.debug('PermissionGuard - constructor');
2121
}
2222

eform-client/src/app/common/interceptors/http-error.interceptor.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,18 @@ import {
1616
} from 'rxjs';
1717
import {ToastrService} from 'ngx-toastr';
1818
import {AuthStateService} from 'src/app/common/store';
19-
import {Injectable} from '@angular/core';
19+
import { Injectable, inject } from '@angular/core';
2020
import {AuthMethods, LoaderService} from 'src/app/common/services';
2121
import {AuthResponseModel, OperationDataResult} from 'src/app/common/models';
2222
import * as Sentry from '@sentry/angular';
2323

2424

2525
@Injectable()
2626
export class HttpErrorInterceptor implements HttpInterceptor {
27+
private loaderService = inject(LoaderService);
28+
private toastrService = inject(ToastrService);
29+
private authStateService = inject(AuthStateService);
2730

28-
constructor(
29-
private loaderService: LoaderService,
30-
private toastrService: ToastrService,
31-
private authStateService: AuthStateService,
32-
) {
33-
}
3431

3532
intercept(
3633
request: HttpRequest<any>,

eform-client/src/app/common/interceptors/jwt.interceptor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
HttpInterceptor,
55
HttpRequest,
66
} from '@angular/common/http';
7-
import { Injectable } from '@angular/core';
7+
import { Injectable, inject } from '@angular/core';
88
import {Observable, of, take} from 'rxjs';
99
import { AuthStateService } from 'src/app/common/store';
1010
import {Store} from '@ngrx/store';
@@ -32,8 +32,8 @@ import {selectAuthIsAuth, selectBearerToken} from 'src/app/state/auth/auth.selec
3232
// }
3333
@Injectable()
3434
export class JwtInterceptor implements HttpInterceptor {
35-
constructor(private store: Store) {
36-
}
35+
private store = inject(Store);
36+
3737

3838
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
3939
return this.store.select(selectAuthIsAuth).pipe(

eform-client/src/app/common/interceptors/loader-interceptor.service.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from '@angular/core';
1+
import { Injectable, inject } from '@angular/core';
22
import {
33
HttpResponse,
44
HttpRequest,
@@ -14,14 +14,11 @@ import {catchError, tap} from 'rxjs/operators';
1414
// This is a class for an HTTP interceptor that intercepts HTTP requests and responses
1515
// It implements the HttpInterceptor interface from the @angular/common/http package
1616
export class LoaderInterceptor implements HttpInterceptor {
17+
private loaderService = inject(LoaderService);
18+
1719
// This is an array of HTTP requests that are currently being processed
1820
private requests: HttpRequest<any>[] = [];
1921

20-
// This is the constructor for the class
21-
// It takes a LoaderService as a parameter
22-
constructor(private loaderService: LoaderService) {
23-
}
24-
2522
// This method removes a request from the requests array
2623
// It takes an HttpRequest as a parameter
2724
removeRequest(req: HttpRequest<any>) {

eform-client/src/app/common/interceptors/user-claims.interceptor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import { Injectable, inject } from '@angular/core';
22
import {
33
HttpEvent,
44
HttpHandler,
@@ -12,8 +12,8 @@ import { AuthStateService } from 'src/app/common/store';
1212

1313
@Injectable()
1414
export class UserClaimsInterceptor implements HttpInterceptor {
15-
constructor(private authStateService: AuthStateService) {
16-
}
15+
private authStateService = inject(AuthStateService);
16+
1717

1818
intercept(
1919
request: HttpRequest<any>,

eform-client/src/app/common/modules/eform-cases/components/case-actions/case-archive-modal/case-archive-modal.component.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
Component,
3-
Inject,
4-
OnDestroy,
5-
OnInit,
6-
} from '@angular/core';
1+
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
72
import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';
83
import {CaseArchiveModel,} from 'src/app/common/models';
94
import {CasesService} from 'src/app/common/services';
@@ -17,12 +12,10 @@ import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
1712
standalone: false
1813
})
1914
export class CaseArchiveModalComponent implements OnInit, OnDestroy {
20-
constructor(
21-
private casesService: CasesService,
22-
public dialogRef: MatDialogRef<CaseArchiveModalComponent>,
23-
@Inject(MAT_DIALOG_DATA) public caseArchiveModel: CaseArchiveModel = new CaseArchiveModel()
24-
) {
25-
}
15+
private casesService = inject(CasesService);
16+
dialogRef = inject<MatDialogRef<CaseArchiveModalComponent>>(MatDialogRef);
17+
caseArchiveModel = inject<CaseArchiveModel>(MAT_DIALOG_DATA) ?? new CaseArchiveModel();
18+
2619

2720
ngOnInit() {
2821
}

eform-client/src/app/common/modules/eform-cases/components/case-actions/case-remove-modal/case-remove-modal.component.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, EventEmitter, Inject, OnInit, Output} from '@angular/core';
1+
import { Component, EventEmitter, OnInit, Output, inject } from '@angular/core';
22
import {CaseModel} from 'src/app/common/models/cases';
33
import {CasesService} from 'src/app/common/services/cases';
44
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
@@ -10,13 +10,19 @@ import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
1010
standalone: false
1111
})
1212
export class CaseRemoveModalComponent implements OnInit {
13+
private casesService = inject(CasesService);
14+
dialogRef = inject<MatDialogRef<CaseRemoveModalComponent>>(MatDialogRef);
15+
private model = inject<{
16+
caseModel: CaseModel;
17+
templateId: number;
18+
}>(MAT_DIALOG_DATA);
19+
1320
selectedTemplateId: number;
1421
selectedCaseModel: CaseModel = new CaseModel();
1522

16-
constructor(
17-
private casesService: CasesService,
18-
public dialogRef: MatDialogRef<CaseRemoveModalComponent>,
19-
@Inject(MAT_DIALOG_DATA) private model: {caseModel: CaseModel, templateId: number}) {
23+
constructor() {
24+
const model = this.model;
25+
2026
this.selectedCaseModel = model.caseModel;
2127
this.selectedTemplateId = model.templateId;
2228
}

0 commit comments

Comments
 (0)