diff --git a/src/lib/dialog/base-dialog.component.ts b/src/lib/dialog/base-dialog.component.ts index b2f058e..eb9ebec 100644 --- a/src/lib/dialog/base-dialog.component.ts +++ b/src/lib/dialog/base-dialog.component.ts @@ -1,14 +1,14 @@ import { AfterViewInit, Directive, HostListener, inject, OnDestroy, signal } from '@angular/core'; -import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; -import { hasFormChanged, IqserEventTarget } from '../utils'; -import { ConfirmOptions } from '.'; -import { ConfirmationDialogService } from './confirmation-dialog.service'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { debounceTime, firstValueFrom, fromEvent, merge, of, Subscription } from 'rxjs'; +import { tap } from 'rxjs/operators'; +import { ConfirmOptions } from '.'; +import { IconButtonTypes } from '../buttons'; import { LoadingService } from '../loading'; import { Toaster } from '../services'; -import { IconButtonTypes } from '../buttons'; -import { tap } from 'rxjs/operators'; +import { hasFormChanged, IqserEventTarget } from '../utils'; +import { ConfirmationDialogService } from './confirmation-dialog.service'; const TARGET_NODE = 'mat-dialog-container'; @@ -19,16 +19,21 @@ export interface SaveOptions { @Directive() export abstract class BaseDialogComponent implements AfterViewInit, OnDestroy { - readonly iconButtonTypes = IconButtonTypes; - form?: UntypedFormGroup; - initialFormValue!: Record; - protected readonly _formBuilder = inject(UntypedFormBuilder); - protected readonly _loadingService = inject(LoadingService); - protected readonly _toaster = inject(Toaster); - protected readonly _subscriptions: Subscription = new Subscription(); readonly #confirmationDialogService = inject(ConfirmationDialogService); readonly #dialog = inject(MatDialog); readonly #hasErrors = signal(true); + protected readonly _formBuilder = inject(UntypedFormBuilder); + protected readonly _loadingService = inject(LoadingService); + protected readonly _toaster = inject(Toaster); + protected readonly _subscriptions = new Subscription(); + readonly iconButtonTypes = IconButtonTypes; + form?: UntypedFormGroup; + initialFormValue!: Record; + + protected constructor( + protected readonly _dialogRef: MatDialogRef, + private readonly _isInEditMode = false, + ) {} get valid(): boolean { return !this.form || this.form.valid; @@ -42,11 +47,6 @@ export abstract class BaseDialogComponent implements AfterViewInit, OnDestroy { return !this.valid || !this.changed || this.#hasErrors(); } - protected constructor( - protected readonly _dialogRef: MatDialogRef, - private readonly _isInEditMode = false, - ) {} - ngAfterViewInit() { this._subscriptions.add(this._dialogRef.backdropClick().subscribe(() => this.close())); const valueChanges = this.form?.valueChanges ?? of(null); diff --git a/src/lib/dialog/confirmation-dialog/confirmation-dialog.component.ts b/src/lib/dialog/confirmation-dialog/confirmation-dialog.component.ts index 0f1c635..694473b 100644 --- a/src/lib/dialog/confirmation-dialog/confirmation-dialog.component.ts +++ b/src/lib/dialog/confirmation-dialog/confirmation-dialog.component.ts @@ -1,12 +1,12 @@ -import { ChangeDetectionStrategy, Component, HostListener, inject, TemplateRef } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; -import { TranslateModule, TranslateService } from '@ngx-translate/core'; -import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { CircleButtonComponent, IconButtonComponent, IconButtonTypes } from '../../buttons'; import { NgForOf, NgIf, NgTemplateOutlet } from '@angular/common'; -import { MatIconModule } from '@angular/material/icon'; +import { ChangeDetectionStrategy, Component, HostListener, inject, TemplateRef } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; +import { MatIconModule } from '@angular/material/icon'; +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; +import { CircleButtonComponent, IconButtonComponent, IconButtonTypes } from '../../buttons'; import { ValuesOf } from '../../utils'; export const TitleColors = { @@ -18,6 +18,7 @@ export type TitleColor = ValuesOf; export const ConfirmOptions = { CONFIRM: 1, + // TODO: this should be renamed to CONFIRM_WITH_ACTION SECOND_CONFIRM: 2, DISCARD_CHANGES: 3, } as const; diff --git a/src/lib/users/services/iqser-user.service.ts b/src/lib/users/services/iqser-user.service.ts index 3672efc..76800f1 100644 --- a/src/lib/users/services/iqser-user.service.ts +++ b/src/lib/users/services/iqser-user.service.ts @@ -1,29 +1,29 @@ +import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http'; import { inject, Injectable } from '@angular/core'; +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { KeycloakService } from 'keycloak-angular'; +import { KeycloakProfile } from 'keycloak-js'; import { BehaviorSubject, firstValueFrom, Observable, throwError } from 'rxjs'; import { catchError, tap } from 'rxjs/operators'; -import { BASE_HREF, List, mapEach } from '../../utils'; -import { QueryParam, Toaster } from '../../services'; +import { IProfile } from '../../../../../red-domain/src'; import { CacheApiService } from '../../caching'; import { EntitiesService } from '../../listing'; -import { IIqserUser } from '../types/user.response'; +import { IqserPermissionsService, IqserRolesService } from '../../permissions'; +import { QueryParam, Toaster } from '../../services'; +import { KeycloakStatusService } from '../../tenants'; +import { BASE_HREF, List, mapEach } from '../../utils'; +import { IqserUser } from '../iqser-user.model'; import { ICreateUserRequest } from '../types/create-user.request'; -import { IResetPasswordRequest } from '../types/reset-password.request'; import { IMyProfileUpdateRequest } from '../types/my-profile-update.request'; import { IProfileUpdateRequest } from '../types/profile-update.request'; -import { KeycloakProfile } from 'keycloak-js'; -import { IqserUser } from '../iqser-user.model'; -import { IqserPermissionsService, IqserRolesService } from '../../permissions'; -import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http'; -import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { KeycloakStatusService } from '../../tenants'; +import { IResetPasswordRequest } from '../types/reset-password.request'; +import { IIqserUser } from '../types/user.response'; @Injectable() export abstract class IqserUserService< Interface extends IIqserUser = IIqserUser, Class extends IqserUser & Interface = IqserUser & Interface, > extends EntitiesService { - readonly currentUser$: Observable; protected abstract readonly _defaultModelPath: string; protected abstract readonly _permissionsFilter: (role: string) => boolean; protected abstract readonly _rolesFilter: (role: string) => boolean; @@ -37,6 +37,7 @@ export abstract class IqserUserService< protected readonly _rolesService = inject(IqserRolesService, { optional: true }); protected readonly _baseHref = inject(BASE_HREF); protected readonly _serviceName: string = 'tenant-user-management'; + readonly currentUser$: Observable; constructor() { super();