Skip to content

Commit

Permalink
No temp injection #10557
Browse files Browse the repository at this point in the history
To avoid the temptation of mis-using directly
  • Loading branch information
PowerKiKi committed Oct 8, 2024
1 parent 7b3e54b commit 10663fd
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 105 deletions.
4 changes: 1 addition & 3 deletions client/app/admin/accounts/account/account.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export class AccountComponent extends NaturalAbstractDetail<AccountService, Natu
public readonly AccountType = AccountType;

public constructor() {
const accountService = inject(AccountService);

super('account', accountService);
super('account', inject(AccountService));
}

public override ngOnInit(): void {
Expand Down
4 changes: 1 addition & 3 deletions client/app/admin/accounts/accounts/accounts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ export class AccountsComponent extends NaturalAbstractNavigableList<AccountServi
};

public constructor() {
const accountService = inject(AccountService);

super(accountService);
super(inject(AccountService));

this.naturalSearchFacets = accounts();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import {MatDividerModule} from '@angular/material/divider';
})
export class BookableTagComponent extends NaturalAbstractDetail<BookableTagService, NaturalSeoResolveData> {
public constructor() {
const bookableTagService = inject(BookableTagService);

super('bookableTag', bookableTagService);
super('bookableTag', inject(BookableTagService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export class BookableTagsComponent extends NaturalAbstractList<BookableTagServic
{id: 'name', label: 'Nom'},
];
public constructor() {
const bookableTagService = inject(BookableTagService);

super(bookableTagService);
super(inject(BookableTagService));
}
}
4 changes: 1 addition & 3 deletions client/app/admin/bookables/bookable/bookable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class BookableComponent extends NaturalAbstractDetail<BookableService, Na
public readonly availableColumnsForBookingsWithOwnerOnlyTrainers = availableColumnsForBookingsWithOwnerOnlyTrainers;

public constructor() {
const bookableService = inject(BookableService);

super('bookable', bookableService);
super('bookable', inject(BookableService));
}

public override ngOnInit(): void {
Expand Down
10 changes: 1 addition & 9 deletions client/app/admin/bookables/bookables/bookables.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {Bookables} from '../../../shared/generated-types';
import {BookableService} from '../services/bookable.service';
import {PermissionsService} from '../../../shared/services/permissions.service';
import {ParentComponent} from './parent.component';
import {BookingService} from '../../bookings/services/booking.service';
import {MatPaginatorModule} from '@angular/material/paginator';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {RouterLink} from '@angular/router';
Expand All @@ -22,8 +21,6 @@ import {
NaturalTableButtonComponent,
} from '@ecodev/natural';
import {CommonModule, DatePipe} from '@angular/common';
import {MatDialog} from '@angular/material/dialog';
import {MatSnackBar} from '@angular/material/snack-bar';

@Component({
selector: 'app-bookables',
Expand Down Expand Up @@ -55,12 +52,7 @@ export class BookablesComponent extends ParentComponent<BookableService> impleme
@Output() public readonly bookableClick = new EventEmitter<Bookables['bookables']['items'][0]>();

public constructor() {
const bookableService = inject(BookableService);
const dialog = inject(MatDialog);
const snackbar = inject(MatSnackBar);
const bookingService = inject(BookingService);

super(bookableService, dialog, snackbar, bookingService);
super(inject(BookableService));
this.naturalSearchFacets = this.route.snapshot.data.isEquipment ? equipment() : bookables();
}

Expand Down
10 changes: 4 additions & 6 deletions client/app/admin/bookables/bookables/parent.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export abstract class ParentComponent<T extends UsageBookableService | BookableS
public readonly availabilityText = availabilityText;
public readonly usageStatus = usageStatusFunc;
public readonly usageText = usageText;
private readonly dialog = inject(MatDialog);
private readonly snackbar = inject(MatSnackBar);
private readonly bookingService = inject(BookingService);

/**
* The user who will be the owner of the booking when we create it via the `createApplication` button
Expand All @@ -73,12 +76,7 @@ export abstract class ParentComponent<T extends UsageBookableService | BookableS
}),
);

protected constructor(
service: T,
private readonly dialog: MatDialog,
private readonly snackbar: MatSnackBar,
private readonly bookingService: BookingService,
) {
protected constructor(service: T) {
super(service);

this.futureOwner$.pipe(takeUntilDestroyed()).subscribe(futureOwner => (this.futureOwner = futureOwner));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@ecodev/natural';
import {CommonModule, DatePipe} from '@angular/common';
import {UsageBookables} from '../../../shared/generated-types';
import {BookingService} from '../../bookings/services/booking.service';
import {switchMap} from 'rxjs/operators';
import {UserService} from '../../users/services/user.service';
import {ParentComponent} from './parent.component';
Expand All @@ -25,8 +24,6 @@ import {FlagComponent} from '../../../shared/components/flag/flag.component';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatSortModule} from '@angular/material/sort';
import {MatTableModule} from '@angular/material/table';
import {MatDialog} from '@angular/material/dialog';
import {MatSnackBar} from '@angular/material/snack-bar';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {admin_approved, bookables, storage} from '../../../shared/natural-search/natural-search-facets.service';

Expand Down Expand Up @@ -72,12 +69,7 @@ export class UsageBookablesComponent extends ParentComponent<UsageBookableServic
private searchInitialized = false;

public constructor() {
const usageBookableService = inject(UsageBookableService);
const dialog = inject(MatDialog);
const snackbar = inject(MatSnackBar);
const bookingService = inject(BookingService);

super(usageBookableService, dialog, snackbar, bookingService);
super(inject(UsageBookableService));

if (this.route.snapshot.data.isAdmin) {
let facets = bookables();
Expand Down
4 changes: 1 addition & 3 deletions client/app/admin/bookings/booking/booking.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ export class BookingComponent extends NaturalAbstractDetail<BookingService, Natu
public newBooking: CreateBooking['createBooking'] | null = null;

public constructor() {
const bookingService = inject(BookingService);

super('booking', bookingService);
super('booking', inject(BookingService));
}

public override ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ export class BookingsWithOwnerComponent extends AbstractBookings<BookingWithOwne
);

public constructor() {
const bookingWithOwnerService = inject(BookingWithOwnerService);

super(bookingWithOwnerService);
super(inject(BookingWithOwnerService));
this.naturalSearchFacets = bookingsForBookable();
}
}
4 changes: 1 addition & 3 deletions client/app/admin/bookings/bookings/bookings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ export class BookingsComponent extends AbstractBookings<BookingService> {
public readonly permissionsService = inject(PermissionsService);

public constructor() {
const bookingService = inject(BookingService);

super(bookingService);
super(inject(BookingService));
this.naturalSearchFacets = this.route.snapshot.data.advancedFacets ? bookingsAdvanced() : bookings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ export class ExpenseClaimComponent
public viewer!: NonNullable<CurrentUserForProfile['viewer']>;

public constructor() {
const expenseClaimService = inject(ExpenseClaimService);

super('expenseClaim', expenseClaimService);
super('expenseClaim', inject(ExpenseClaimService));
}

public override ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export class ExpenseClaimsComponent extends NaturalAbstractList<ExpenseClaimServ
];

public constructor() {
const expenseClaimService = inject(ExpenseClaimService);

super(expenseClaimService);
super(inject(ExpenseClaimService));

this.naturalSearchFacets = expenseClaims();
}
Expand Down
4 changes: 1 addition & 3 deletions client/app/admin/licenses/license/license.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export class LicenseComponent extends NaturalAbstractDetail<LicenseService> {
public readonly bookableService = inject(BookableService);

public constructor() {
const licenseService = inject(LicenseService);

super('license', licenseService);
super('license', inject(LicenseService));
}
}
4 changes: 1 addition & 3 deletions client/app/admin/licenses/licenses/licenses.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export class LicensesComponent extends NaturalAbstractList<LicenseService> imple
public override availableColumns: AvailableColumn[] = [{id: 'name', label: 'Nom'}];

public constructor() {
const licenseService = inject(LicenseService);

super(licenseService);
super(inject(LicenseService));
}
}
4 changes: 1 addition & 3 deletions client/app/admin/logs/logs/logs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import {CommonModule} from '@angular/common';
})
export class LogsComponent extends NaturalAbstractList<LogService> implements OnInit {
public constructor() {
const logService = inject(LogService);

super(logService);
super(inject(LogService));

this.naturalSearchFacets = logs();
this.forcedVariables = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import {MatDividerModule} from '@angular/material/divider';
})
export class TransactionTagComponent extends NaturalAbstractDetail<TransactionTagService, NaturalSeoResolveData> {
public constructor() {
const transactionTagService = inject(TransactionTagService);

super('transactionTag', transactionTagService);
super('transactionTag', inject(TransactionTagService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export class TransactionTagsComponent extends NaturalAbstractList<TransactionTag
{id: 'transactions', label: 'Transactions'},
];
public constructor() {
const transactionTagService = inject(TransactionTagService);

super(transactionTagService);
super(inject(TransactionTagService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ export class EditableTransactionLinesComponent extends NaturalAbstractEditableLi
];

public constructor() {
const transactionLineService = inject(TransactionLineService);

super(transactionLineService);
super(inject(TransactionLineService));

this.input$
.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export class TransactionComponent
public transactionLines: EditableTransactionLinesInput = {mode: 'empty'};

public constructor() {
const transactionService = inject(TransactionService);

super('transaction', transactionService);
super('transaction', inject(TransactionService));
}

public override ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ export class TransactionLinesComponent extends NaturalAbstractList<TransactionLi
@Input() public hideFab = false;

public constructor() {
const transactionLineService = inject(TransactionLineService);

super(transactionLineService);
super(inject(TransactionLineService));

this.naturalSearchFacets = transactionLines();
}
Expand Down
4 changes: 1 addition & 3 deletions client/app/admin/userTags/userTag/userTag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export class UserTagComponent extends NaturalAbstractDetail<UserTagService, Natu
public readonly userService = inject(UserService);

public constructor() {
const userTagService = inject(UserTagService);

super('userTag', userTagService);
super('userTag', inject(UserTagService));
}
}
4 changes: 1 addition & 3 deletions client/app/admin/userTags/userTags/userTags.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export class UserTagsComponent extends NaturalAbstractList<UserTagService> imple
];

public constructor() {
const userTagService = inject(UserTagService);

super(userTagService);
super(inject(UserTagService));
}
}
4 changes: 1 addition & 3 deletions client/app/admin/users/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ export class UserComponent extends NaturalAbstractDetail<UserService, NaturalSeo
public readonly UserStatus = UserStatus;

public constructor() {
const userService = inject(UserService);

super('user', userService);
super('user', inject(UserService));
}

public override ngOnInit(): void {
Expand Down
4 changes: 1 addition & 3 deletions client/app/admin/users/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ export class UsersComponent extends NaturalAbstractList<UserService> implements
public readonly welcoming = new Map<Users['users']['items'][0], true>();

public constructor() {
const userService = inject(UserService);

super(userService);
super(inject(UserService));

this.naturalSearchFacets = users();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export class CreateExpenseClaimComponent
public ExpenseClaimType = ExpenseClaimType;

public constructor() {
const expenseClaimService = inject(ExpenseClaimService);

super('expenseClaim', expenseClaimService);
super('expenseClaim', inject(ExpenseClaimService));
}

public override ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export class FamilyMemberComponent extends NaturalAbstractDetail<FamilyUserServi
public loaded = false;

public constructor() {
const userService = inject(FamilyUserService);

super('user', userService);
super('user', inject(FamilyUserService));
}

/**
Expand Down
4 changes: 1 addition & 3 deletions client/app/profile/components/finances/finances.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export class FinancesComponent extends NaturalAbstractList<ExpenseClaimService>
public override persistSearch = false;

public constructor() {
const expenseClaimService = inject(ExpenseClaimService);

super(expenseClaimService);
super(inject(ExpenseClaimService));
}

public ngOnChanges(changes: SimpleChanges): void {
Expand Down
4 changes: 1 addition & 3 deletions client/app/safety/safety.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export class SafetyComponent extends AbstractBookings<SafetyBookingService> {
public readonly permissionsService = inject(PermissionsService);

public constructor() {
const safetyBookingService = inject(SafetyBookingService);

super(safetyBookingService);
super(inject(SafetyBookingService));
this.naturalSearchFacets = bookings();
}
}
4 changes: 1 addition & 3 deletions client/app/shared/testing/MockApolloProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import {apolloDefaultOptions, cacheConfig} from '../config/apollo-options.provid
})
class MockApollo extends Apollo {
public constructor() {
const ngZone = inject(NgZone);

super(ngZone);
super(inject(NgZone));
this.client = this.createMockClient();
}

Expand Down

0 comments on commit 10663fd

Please sign in to comment.