Skip to content

Commit 7ba48aa

Browse files
Copilotrenemadsen
andcommitted
Migrate second batch of components to inject() pattern
Co-authored-by: renemadsen <[email protected]>
1 parent 9b49259 commit 7ba48aa

File tree

10 files changed

+85
-76
lines changed

10 files changed

+85
-76
lines changed

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-planning-actions/assigned-site/assigned-site-dialog.component.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {Component, DoCheck, Inject, OnInit} from '@angular/core';
1+
import {Component, DoCheck, OnInit,
2+
inject
3+
} from '@angular/core';
24
import {
35
MAT_DIALOG_DATA
46
} from '@angular/material/dialog';
@@ -24,22 +26,19 @@ import {
2426
standalone: false
2527
})
2628
export class AssignedSiteDialogComponent implements DoCheck, OnInit {
29+
private fb = inject(FormBuilder);
30+
public data = inject<AssignedSiteModel>(MAT_DIALOG_DATA);
31+
private timePlanningPnSettingsService = inject(TimePlanningPnSettingsService);
32+
private store = inject(Store);
33+
2734
assignedSiteForm!: FormGroup;
2835

2936
public selectCurrentUserIsAdmin$ = this.store.select(selectCurrentUserIsAdmin);
3037
public selectCurrentUserIsFirstUser$ = this.store.select(selectCurrentUserIsFirstUser);
3138
private previousData: AssignedSiteModel;
3239
private globalAutoBreakSettings: GlobalAutoBreakSettingsModel;
3340

34-
constructor(
35-
private fb: FormBuilder,
36-
@Inject(MAT_DIALOG_DATA) public data: AssignedSiteModel,
37-
private timePlanningPnSettingsService: TimePlanningPnSettingsService,
38-
private store: Store
39-
) {
40-
this.previousData = {...data};
41-
// this.calculateHours();
42-
}
41+
4342

4443
ngDoCheck(): void {
4544
if (this.hasDataChanged()) {
@@ -49,6 +48,8 @@ export class AssignedSiteDialogComponent implements DoCheck, OnInit {
4948
}
5049

5150
ngOnInit(): void {
51+
this.previousData = {...this.data};
52+
// this.calculateHours();
5253
this.timePlanningPnSettingsService.getGlobalAutoBreakCalculationSettings().subscribe(result => {
5354
if (result && result.success) {
5455
this.globalAutoBreakSettings = result.model;

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-planning-actions/download-excel/download-excel-dialog.component.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {Component, Inject, Input, OnDestroy, OnInit} from '@angular/core';
1+
import {Component, OnDestroy, OnInit,
2+
inject
3+
} from '@angular/core';
24
import {EMPTY, Subscription} from 'rxjs';
35
import {MatDatepickerInputEvent} from '@angular/material/datepicker';
46
import {SiteDto} from 'src/app/common/models';
@@ -21,18 +23,17 @@ import {MAT_DIALOG_DATA} from '@angular/material/dialog';
2123
standalone: false,
2224
})
2325
export class DownloadExcelDialogComponent implements OnInit, OnDestroy {
26+
public availableSites = inject<SiteDto[]>(MAT_DIALOG_DATA);
27+
private toastrService = inject(ToastrService);
28+
private workingHoursService = inject(TimePlanningPnWorkingHoursService);
29+
2430
siteId: number;
2531

2632
dateFrom: Date = null;
2733
dateTo: Date = null;
2834
downloadReportSub$: Subscription;
2935

30-
constructor(
31-
@Inject(MAT_DIALOG_DATA) public availableSites: SiteDto[] = [],
32-
private toastrService: ToastrService,
33-
private workingHoursService: TimePlanningPnWorkingHoursService,
34-
) {
35-
}
36+
3637

3738
ngOnInit(): void {
3839
// this.getAvailableSites();

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-planning-actions/workday-entity/workday-entity-dialog.component.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {Component, Inject, OnInit, TemplateRef, ViewChild} from '@angular/core';
1+
import {Component, OnInit, TemplateRef, ViewChild,
2+
inject
3+
} from '@angular/core';
24
import {MAT_DIALOG_DATA} from '@angular/material/dialog';
35
import {TranslateService} from '@ngx-translate/core';
46
import {DatePipe} from '@angular/common';
@@ -26,6 +28,15 @@ import {
2628
standalone: false
2729
})
2830
export class WorkdayEntityDialogComponent implements OnInit {
31+
private fb = inject(FormBuilder);
32+
private planningsService = inject(TimePlanningPnPlanningsService);
33+
public data = inject<{
34+
planningPrDayModels: PlanningPrDayModel,
35+
assignedSiteModel: AssignedSiteModel
36+
}>(MAT_DIALOG_DATA);
37+
protected datePipe = inject(DatePipe);
38+
private translateService = inject(TranslateService);
39+
2940
TimePlanningMessagesEnum = TimePlanningMessagesEnum;
3041
enumKeys: string[] = [];
3142
tableHeaders: MtxGridColumn[] = [];
@@ -54,17 +65,7 @@ export class WorkdayEntityDialogComponent implements OnInit {
5465
private readonly timeRegex = /^([01]\d|2[0-3]):([0-5]\d)$/;
5566
inputErrorMessages: Record<string, Record<string, string>> = {};
5667

57-
constructor(
58-
private fb: FormBuilder,
59-
private planningsService: TimePlanningPnPlanningsService,
60-
@Inject(MAT_DIALOG_DATA) public data: {
61-
planningPrDayModels: PlanningPrDayModel,
62-
assignedSiteModel: AssignedSiteModel
63-
},
64-
protected datePipe: DatePipe,
65-
private translateService: TranslateService,
66-
) {
67-
}
68+
6869

6970
ngOnInit(): void {
7071
// Enum-opsætning

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-plannings-table/time-plannings-table.component.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output,
3-
SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation
3+
SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation,
4+
inject
45
} from '@angular/core';
56
import {AssignedSiteModel, TimePlanningModel} from '../../../models';
67
import {MtxGridColumn} from '@ng-matero/extensions/grid';
@@ -23,6 +24,14 @@ import {selectAuthIsAdmin, selectCurrentUserIsFirstUser} from "src/app/state";
2324

2425
})
2526
export class TimePlanningsTableComponent implements OnInit, OnChanges {
27+
private store = inject(Store);
28+
private planningsService = inject(TimePlanningPnPlanningsService);
29+
private timePlanningPnSettingsService = inject(TimePlanningPnSettingsService);
30+
private dialog = inject(MatDialog);
31+
private translateService = inject(TranslateService);
32+
protected datePipe = inject(DatePipe);
33+
private cdr = inject(ChangeDetectorRef);
34+
2635
@Input() timePlannings: TimePlanningModel[] = [];
2736
@Input() dateFrom!: Date;
2837
@Input() dateTo!: Date;
@@ -38,16 +47,7 @@ export class TimePlanningsTableComponent implements OnInit, OnChanges {
3847
protected selectAuthIsAdmin$ = this.store.select(selectAuthIsAdmin);
3948
public selectCurrentUserIsFirstUser$ = this.store.select(selectCurrentUserIsFirstUser);
4049

41-
constructor(
42-
private store: Store,
43-
private planningsService: TimePlanningPnPlanningsService,
44-
private timePlanningPnSettingsService: TimePlanningPnSettingsService,
45-
private dialog: MatDialog,
46-
private translateService: TranslateService,
47-
protected datePipe: DatePipe,
48-
private cdr: ChangeDetectorRef
49-
) {
50-
}
50+
5151

5252
ngOnInit(): void {
5353
this.enumKeys = Object.keys(TimePlanningMessagesEnum).filter(key => isNaN(Number(key)));

eform-client/src/app/plugins/modules/time-planning-pn/modules/flexes/components/time-flexes-actions/comment-office-all-update-modal/time-flexes-comment-office-all-update-modal.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
Component,
3-
Inject,
43
OnDestroy,
54
OnInit,
5+
inject
66
} from '@angular/core';
77
import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';
88
import {TimeFlexesModel} from '../../../../../models';
@@ -12,21 +12,21 @@ import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
1212
@Component({
1313
selector: 'app-time-flexes-comment-office-all-update-modal',
1414
templateUrl: './time-flexes-comment-office-all-update-modal.component.html',
15-
styleUrls: ['./time-flexes-comment-office-all-update-modal.component.scss'],
15+
styleUrls: ['./time-flexes-comment-office-all-update-modal.component.scss',
16+
],
1617
standalone: false
1718
})
1819
export class TimeFlexesCommentOfficeAllUpdateModalComponent
1920
implements OnInit, OnDestroy {
21+
public dialogRef = inject(MatDialogRef<TimeFlexesCommentOfficeAllUpdateModalComponent>);
22+
private injectedTimeFlexes = inject<TimeFlexesModel>(MAT_DIALOG_DATA);
23+
2024
timeFlexes: TimeFlexesModel = new TimeFlexesModel();
2125

22-
constructor(
23-
public dialogRef: MatDialogRef<TimeFlexesCommentOfficeAllUpdateModalComponent>,
24-
@Inject(MAT_DIALOG_DATA) timeFlexes: TimeFlexesModel,
25-
) {
26-
this.timeFlexes = {...timeFlexes};
27-
}
26+
2827

2928
ngOnInit() {
29+
this.timeFlexes = {...this.injectedTimeFlexes};
3030
}
3131

3232
onUpdateFlexPlanning() {

eform-client/src/app/plugins/modules/time-planning-pn/modules/flexes/components/time-flexes-actions/comment-office-update-modal/time-flexes-comment-office-update-modal.component.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
Component,
3-
Inject,
43
OnDestroy,
54
OnInit,
5+
inject
66
} from '@angular/core';
77
import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';
88
import {TimeFlexesModel} from '../../../../../models';
@@ -16,16 +16,15 @@ import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
1616
standalone: false
1717
})
1818
export class TimeFlexesCommentOfficeUpdateModalComponent implements OnInit, OnDestroy {
19+
public dialogRef = inject(MatDialogRef<TimeFlexesCommentOfficeUpdateModalComponent>);
20+
private injectedTimeFlexes = inject<TimeFlexesModel>(MAT_DIALOG_DATA);
21+
1922
timeFlexes: TimeFlexesModel = new TimeFlexesModel();
2023

21-
constructor(
22-
public dialogRef: MatDialogRef<TimeFlexesCommentOfficeUpdateModalComponent>,
23-
@Inject(MAT_DIALOG_DATA) timeFlexes: TimeFlexesModel,
24-
) {
25-
this.timeFlexes = {...timeFlexes};
26-
}
24+
2725

2826
ngOnInit() {
27+
this.timeFlexes = {...this.injectedTimeFlexes};
2928
}
3029

3130
onUpdateFlexPlanning() {

eform-client/src/app/plugins/modules/time-planning-pn/modules/flexes/components/time-flexes-container/time-flexes-container.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Component, OnDestroy, OnInit } from '@angular/core';
1+
import { Component, OnDestroy, OnInit,
2+
inject
3+
} from '@angular/core';
24
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe';
35
import { Subscription } from 'rxjs';
46
import { SiteDto } from 'src/app/common/models';
@@ -17,6 +19,8 @@ import { TimePlanningPnFlexesService } from '../../../../services';
1719
standalone: false
1820
})
1921
export class TimeFlexesContainerComponent implements OnInit, OnDestroy {
22+
private planningsService = inject(TimePlanningPnFlexesService);
23+
2024
timePlanningsRequest: TimePlanningsRequestModel;
2125
availableSites: SiteDto[] = [];
2226
timePlannings: TimeFlexesModel[] = [];
@@ -25,7 +29,7 @@ export class TimeFlexesContainerComponent implements OnInit, OnDestroy {
2529
getTimePlannings$: Subscription;
2630
updateTimePlanning$: Subscription;
2731

28-
constructor(private planningsService: TimePlanningPnFlexesService) {}
32+
2933

3034
ngOnInit(): void {
3135
this.getPlannings();

eform-client/src/app/plugins/modules/time-planning-pn/modules/flexes/components/time-flexes-table/time-flexes-table.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
OnDestroy,
66
OnInit,
77
Output,
8+
inject
89
} from '@angular/core';
910
import {TimeFlexesModel} from '../../../../models';
1011
import {
@@ -27,6 +28,10 @@ import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';
2728
standalone: false
2829
})
2930
export class TimeFlexesTableComponent implements OnInit, OnDestroy {
31+
private translateService = inject(TranslateService);
32+
private dialog = inject(MatDialog);
33+
private overlay = inject(Overlay);
34+
3035
@Input() flexPlannings: TimeFlexesModel[] = [];
3136
@Output()
3237
flexPlanningChanged: EventEmitter<TimeFlexesModel> = new EventEmitter<TimeFlexesModel>();
@@ -46,12 +51,7 @@ export class TimeFlexesTableComponent implements OnInit, OnDestroy {
4651
TimeFlexesCommentOfficeUpdateModalComponentAfterClosedSub$: Subscription;
4752
TimeFlexesCommentOfficeAllUpdateModalComponentAfterClosedSub$: Subscription;
4853

49-
constructor(
50-
private translateService: TranslateService,
51-
private dialog: MatDialog,
52-
private overlay: Overlay,
53-
) {
54-
}
54+
5555

5656
ngOnInit(): void {
5757
}

eform-client/src/app/plugins/modules/time-planning-pn/modules/registration-devices/components/registration-devices-container/registration-devices-container.component.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {Component, OnInit} from '@angular/core';
1+
import {Component, OnInit,
2+
inject
3+
} from '@angular/core';
24
import {
35
TimePlanningPnRegistrationDevicesService
46
} from '../../../../services/time-planning-pn-registration-devices.service';
@@ -16,16 +18,15 @@ import {
1618
standalone: false
1719
})
1820
export class RegistrationDevicesContainerComponent implements OnInit {
21+
public dialog = inject(MatDialog);
22+
private overlay = inject(Overlay);
23+
private registrationDevicesService = inject(TimePlanningPnRegistrationDevicesService);
24+
1925
tainted: any;
2026
registrationDevices: any;
2127
getRegistrationDevices$: Subscription;
2228
createRegistrationDevicesComponentAfterClosedSub$: Subscription;
23-
constructor(
24-
public dialog: MatDialog,
25-
private overlay: Overlay,
26-
private registrationDevicesService: TimePlanningPnRegistrationDevicesService,
27-
) {
28-
}
29+
2930

3031
ngOnInit(): void {
3132
this.getRegistrationDevices();

eform-client/src/app/plugins/modules/time-planning-pn/modules/registration-devices/components/registration-devices-table/registration-devices-table.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
1+
import {Component, EventEmitter, Input, OnInit, Output,
2+
inject
3+
} from '@angular/core';
24
import {MtxGridColumn} from '@ng-matero/extensions/grid';
35
import {TranslateService} from '@ngx-translate/core';
46
import {TimePlanningRegistrationDeviceModel} from '../../../../../../modules/time-planning-pn/models';
@@ -18,6 +20,10 @@ import {Overlay} from '@angular/cdk/overlay';
1820
standalone: false
1921
})
2022
export class RegistrationDevicesTableComponent implements OnInit {
23+
private dialog = inject(MatDialog);
24+
private overlay = inject(Overlay);
25+
private translateService = inject(TranslateService);
26+
2127
get tableHeaders(): MtxGridColumn[] {
2228
return this._tableHeaders;
2329
}
@@ -30,11 +36,7 @@ export class RegistrationDevicesTableComponent implements OnInit {
3036
registrationDeviceEditModalComponentAfterClosedSub$: Subscription;
3137
registrationDeviceDeleteModalComponentAfterClosedSub$: Subscription
3238
private _tableHeaders: MtxGridColumn[];
33-
constructor(
34-
private dialog: MatDialog,
35-
private overlay: Overlay,
36-
private translateService: TranslateService) {
37-
}
39+
3840

3941
ngOnInit(): void {
4042
this._tableHeaders = [

0 commit comments

Comments
 (0)