From 59fbd1f78fcf10c11bc5d5e6172f9c8b895f4912 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 29 Nov 2023 17:05:59 +0200 Subject: [PATCH] updates --- .../initials-avatar.component.ts | 22 +++++++++---------- src/lib/users/name.pipe.ts | 14 +++++------- tsconfig.json | 3 +-- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/lib/users/components/initials-avatar/initials-avatar.component.ts b/src/lib/users/components/initials-avatar/initials-avatar.component.ts index 892781e..0e37f98 100644 --- a/src/lib/users/components/initials-avatar/initials-avatar.component.ts +++ b/src/lib/users/components/initials-avatar/initials-avatar.component.ts @@ -1,8 +1,8 @@ -import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, inject, Input, OnChanges, OnInit } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; +import { IqserUser } from '../../iqser-user.model'; import { IqserUserService } from '../../services/iqser-user.service'; import { NamePipeOptions } from '../../types/name-pipe-options'; -import { IqserUser } from '../../iqser-user.model'; import { IIqserUser } from '../../types/user.response'; @Component({ @@ -14,20 +14,18 @@ import { IIqserUser } from '../../types/user.response'; export class InitialsAvatarComponent implements OnInit, OnChanges { + readonly #translateService = inject(TranslateService); @Input() color = 'lightgray'; @Input() size: 'small' | 'large' = 'small'; @Input() withName = false; @Input() showYou = false; @Input() tooltipPosition: 'below' | 'above' = 'above'; - @Input() defaultValue: string = this._translateService.instant('initials-avatar.unassigned'); + @Input() defaultValue: string = this.#translateService.instant('initials-avatar.unassigned'); @Input() showTooltip = true; colorClass?: string; namePipeOptions?: NamePipeOptions; - constructor( - private readonly _userService: IqserUserService, - private readonly _translateService: TranslateService, - ) {} + constructor(private readonly _userService: IqserUserService) {} _user?: Class; @@ -45,14 +43,14 @@ export class InitialsAvatarComponent(user: T) => boolean = user => user.isSpecial; ngOnChanges(): void { - if (this._isSystemUser) { + if (this.#isSystemUser) { this.colorClass = 'primary-white primary'; return; } - this.colorClass = this._colorClass; + this.colorClass = this.#colorClass; } ngOnInit(): void { diff --git a/src/lib/users/name.pipe.ts b/src/lib/users/name.pipe.ts index c48cf83..353cf2d 100644 --- a/src/lib/users/name.pipe.ts +++ b/src/lib/users/name.pipe.ts @@ -1,8 +1,8 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { inject, Pipe, PipeTransform } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; +import { IqserUser } from './iqser-user.model'; import { IqserUserService } from './services/iqser-user.service'; import { NamePipeOptions } from './types/name-pipe-options'; -import { IqserUser } from './iqser-user.model'; function getInitials(name: string) { if (name.toLowerCase() === 'system') { @@ -20,16 +20,14 @@ function getInitials(name: string) { name: 'name', }) export class NamePipe implements PipeTransform { + readonly #translateService = inject(TranslateService); protected readonly _defaultOptions: Required = { - defaultValue: this._translateService.instant('unknown') as string, + defaultValue: this.#translateService.instant('unknown') as string, showYou: false, showInitials: false, }; - constructor( - private readonly _userService: IqserUserService, - private readonly _translateService: TranslateService, - ) {} + constructor(private readonly _userService: IqserUserService) {} transform(value: IqserUser | string, options: NamePipeOptions = this._defaultOptions): string { if (!value || value === 'undefined') { @@ -43,7 +41,7 @@ export class NamePipe implements PipeTransform { } if (options.showYou && this._isCurrentUser(value)) { - name = `${name} (${this._translateService.instant('initials-avatar.you')})`; + name = `${name} (${this.#translateService.instant('initials-avatar.you')})`; } return options.showInitials ? getInitials(name) : name; diff --git a/tsconfig.json b/tsconfig.json index b132006..85a2090 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,6 @@ "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "sourceMap": true, - "downlevelIteration": true, "experimentalDecorators": true, "moduleResolution": "node", "importHelpers": true, @@ -24,7 +23,7 @@ "@biesbjerg/ngx-translate-extract-marker": ["src/lib/translations/ngx-translate-extract-marker"] } }, - "include": ["./**/*"], + "include": ["./src/**/*"], "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, "strictInjectionParameters": true,