Skip to content

Commit 1d7167b

Browse files
authored
Merge pull request #1071 from microting/copilot/migrate-components-to-inject-pattern
Migrate all components and services from constructor-based DI to inject() pattern
2 parents 5b9b191 + d211fab commit 1d7167b

File tree

5 files changed

+33
-37
lines changed

5 files changed

+33
-37
lines changed

eform-client/src/app/plugins/modules/greate-belt-pn/components/report/report-page/report-container/report-container.component.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
1+
import {Component, inject, OnDestroy, OnInit, ViewChild} from '@angular/core';
22
import {ActivatedRoute, Params, Router} from '@angular/router';
33
import {saveAs} from 'file-saver';
44
import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';
@@ -34,6 +34,17 @@ import {
3434
standalone: false
3535
})
3636
export class ReportContainerComponent implements OnInit, OnDestroy {
37+
private reportService = inject(GreateBeltPnReportService);
38+
public reportStateService = inject(ReportStateService);
39+
public authStateService = inject(AuthStateService);
40+
private eFormService = inject(EFormService);
41+
private route = inject(ActivatedRoute);
42+
private store = inject(Store);
43+
private router = inject(Router);
44+
public dialog = inject(MatDialog);
45+
private overlay = inject(Overlay);
46+
private translateService = inject(TranslateService);
47+
3748
@ViewChild('caseRemoveModal', {static: true})
3849
caseRemoveModal: CaseRemoveModalComponent;
3950
nameSearchSubject = new Subject();
@@ -110,18 +121,7 @@ export class ReportContainerComponent implements OnInit, OnDestroy {
110121
public selectReportFiltersNameFilter$ = this.store.select(selectReportFiltersNameFilter);
111122
public selectReportPagination$ = this.store.select(selectReportPagination);
112123

113-
constructor(
114-
private reportService: GreateBeltPnReportService,
115-
public reportStateService: ReportStateService,
116-
public authStateService: AuthStateService,
117-
private eFormService: EFormService,
118-
private route: ActivatedRoute,
119-
private store: Store,
120-
private router: Router,
121-
public dialog: MatDialog,
122-
private overlay: Overlay,
123-
private translateService: TranslateService,
124-
) {
124+
constructor() {
125125
this.nameSearchSubject.pipe(debounceTime(500)).subscribe((val) => {
126126
this.reportStateService.updateNameFilter(val.toString());
127127
this.getReport();

eform-client/src/app/plugins/modules/greate-belt-pn/components/report/report-page/report-table/report-table.component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ChangeDetectionStrategy,
33
Component,
44
EventEmitter,
5+
inject,
56
Input,
67
OnInit,
78
Output, TemplateRef,
@@ -28,6 +29,11 @@ import {
2829
standalone: false
2930
})
3031
export class ReportTableComponent implements OnInit {
32+
private store = inject(Store);
33+
private router = inject(Router);
34+
public reportStateService = inject(ReportStateService);
35+
private translateService = inject(TranslateService);
36+
3137
@Input() reportModel: Paged<ReportCaseModel> = new Paged<ReportCaseModel>();
3238
@Input() tableHeaders: MtxGridColumn[];
3339
@Input() paginationTemplate!: TemplateRef<any>;
@@ -46,14 +52,6 @@ export class ReportTableComponent implements OnInit {
4652
public selectReportPaginationIsSortDsc$ = this.store.select(selectReportPaginationIsSortDsc);
4753
public selectReportPaginationSort$ = this.store.select(selectReportPaginationSort);
4854

49-
constructor(
50-
private store: Store,
51-
private router: Router,
52-
public reportStateService: ReportStateService,
53-
private translateService: TranslateService,
54-
) {
55-
}
56-
5755
ngOnInit(): void {
5856
}
5957

eform-client/src/app/plugins/modules/greate-belt-pn/components/report/store/report-state.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import {tap} from 'rxjs';
33
import {
44
CommonPaginationState,
@@ -18,14 +18,14 @@ import {
1818

1919
@Injectable({ providedIn: 'root' })
2020
export class ReportStateService {
21+
private store = inject(Store);
22+
private service = inject(GreateBeltPnReportService);
2123
private selectReportPagination$ = this.store.select(selectReportPagination);
2224
private selectReportFilters$ = this.store.select(selectReportFilters);
2325
currentPagination: CommonPaginationState;
24-
currentFilters:FiltrationStateModel;
25-
constructor(
26-
private store: Store,
27-
private service: GreateBeltPnReportService,
28-
) {
26+
currentFilters: FiltrationStateModel;
27+
28+
constructor() {
2929
this.selectReportPagination$.subscribe((x) => this.currentPagination = x);
3030
this.selectReportFilters$.subscribe((x) => this.currentFilters = x);
3131
}

eform-client/src/app/plugins/modules/greate-belt-pn/layouts/greate-belt-pn-layout.component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterContentInit, Component, OnDestroy, OnInit} from '@angular/core';
1+
import {AfterContentInit, Component, inject, OnDestroy, OnInit} from '@angular/core';
22
import {TranslateService} from '@ngx-translate/core';
33
import {translates} from './../i18n/translates';
44
import {AuthStateService} from 'src/app/common/store';
@@ -16,15 +16,13 @@ import {filter} from 'rxjs/operators';
1616
})
1717
export class GreateBeltPnLayoutComponent
1818
implements AfterContentInit, OnInit, OnDestroy {
19+
private store = inject(Store);
20+
private localeService = inject(LocaleService);
21+
private translateService = inject(TranslateService);
22+
private authStateService = inject(AuthStateService);
23+
1924
currentUserLocaleAsyncSub$: Subscription;
2025
private selectCurrentUserLocale$ = this.store.select(selectCurrentUserLocale);
21-
constructor(
22-
private store: Store,
23-
private localeService: LocaleService,
24-
private translateService: TranslateService,
25-
private authStateService: AuthStateService
26-
) {
27-
}
2826

2927
ngOnInit(): void {
3028
}

eform-client/src/app/plugins/modules/greate-belt-pn/services/greate-belt-pn-report.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { OperationDataResult, Paged } from 'src/app/common/models';
44
import { ApiBaseService } from 'src/app/common/services';
@@ -13,7 +13,7 @@ export let GreateBeltPnPropertiesMethods = {
1313
providedIn: 'root',
1414
})
1515
export class GreateBeltPnReportService {
16-
constructor(private apiBaseService: ApiBaseService) {}
16+
private apiBaseService = inject(ApiBaseService);
1717

1818
getReport(
1919
model: ReportRequestModel

0 commit comments

Comments
 (0)