Pull request #373: VM/RED-3687

Merge in RED/ui from VM/RED-3687 to master

* commit '7cd98b83ad638c6da6df5fa80fc83493d6b56f3c':
  RED-3686 - updated interfaces names
  RED-3687 - Remove AutoUnsubscribe directive
This commit is contained in:
Valentin-Gabriel Mihai 2022-07-22 15:26:03 +02:00
commit 61daa1e8d8
18 changed files with 31 additions and 65 deletions

View File

@ -14,7 +14,7 @@ import { firstValueFrom } from 'rxjs';
templateUrl: './user-details.component.html',
styleUrls: ['./user-details.component.scss'],
})
export class UserDetailsComponent extends BaseFormComponent implements OnChanges, OnDestroy {
export class UserDetailsComponent extends BaseFormComponent implements OnChanges {
readonly iconButtonTypes = IconButtonTypes;
@Input() user: User;

View File

@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { UntypedFormGroup, Validators } from '@angular/forms';
import { FileAttributeEncodingTypes, IFileAttributesConfig } from '@red/domain';
@ -9,7 +9,7 @@ import { BaseDialogComponent } from '@iqser/common-ui';
templateUrl: './file-attributes-configurations-dialog.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FileAttributesConfigurationsDialogComponent extends BaseDialogComponent implements OnInit {
export class FileAttributesConfigurationsDialogComponent extends BaseDialogComponent {
readonly encodingTypeOptions = Object.keys(FileAttributeEncodingTypes);
readonly translations = fileAttributeEncodingTypesTranslations;
readonly #configuration = this._data.config;

View File

@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { BaseFormComponent, LoadingService } from '@iqser/common-ui';
import { GeneralSettingsService } from '@services/general-settings.service';
import { IGeneralConfiguration } from '@red/domain';
@ -10,7 +10,7 @@ import { firstValueFrom } from 'rxjs';
selector: 'redaction-general-config-form',
templateUrl: './general-config-form.component.html',
})
export class GeneralConfigFormComponent extends BaseFormComponent implements OnInit, OnDestroy {
export class GeneralConfigFormComponent extends BaseFormComponent implements OnInit {
private _initialConfiguration: IGeneralConfiguration;
constructor(

View File

@ -11,7 +11,7 @@ import { firstValueFrom } from 'rxjs';
selector: 'redaction-smtp-form',
templateUrl: './smtp-form.component.html',
})
export class SmtpFormComponent extends BaseFormComponent implements OnInit, OnDestroy {
export class SmtpFormComponent extends BaseFormComponent implements OnInit {
readonly iconButtonTypes = IconButtonTypes;
private _initialConfiguration: ISmtpConfiguration;

View File

@ -3,15 +3,14 @@ import { Dossier, File, IComment } from '@red/domain';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { UserService } from '@services/user.service';
import { PermissionsService } from '@services/permissions.service';
import { InputWithActionComponent, LoadingService, trackByFactory } from '@iqser/common-ui';
import { InputWithActionComponent, LoadingService, trackByFactory, ContextComponent } from '@iqser/common-ui';
import { firstValueFrom, Observable } from 'rxjs';
import { CommentingService } from '../../services/commenting.service';
import { tap } from 'rxjs/operators';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { ManualRedactionService } from '../../services/manual-redaction.service';
import { ContextComponent } from '@utils/context.component';
interface CommentsTemplate {
interface CommentsContext {
dossier: Dossier;
file: File;
hiddenComments: boolean;
@ -23,7 +22,7 @@ interface CommentsTemplate {
styleUrls: ['./comments.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CommentsComponent extends ContextComponent<CommentsTemplate> implements OnInit {
export class CommentsComponent extends ContextComponent<CommentsContext> implements OnInit {
@Input() annotation: AnnotationWrapper;
readonly trackBy = trackByFactory();
readonly file$: Observable<File>;

View File

@ -1,4 +1,5 @@
<div
*ngIf="componentContext$ | async"
(click)="pageSelected.emit(number)"
(dblclick)="toggleReadState()"
[class.active]="active"

View File

@ -1,22 +1,17 @@
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output,
} from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
import { PermissionsService } from '@services/permissions.service';
import { ConfigService } from '@services/config.service';
import { ViewedPagesService } from '@services/files/viewed-pages.service';
import { IViewedPage } from '@red/domain';
import { AutoUnsubscribe } from '@iqser/common-ui';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { firstValueFrom } from 'rxjs';
import { PageRotationService } from '../../../pdf-viewer/services/page-rotation.service';
import { ContextComponent } from '@iqser/common-ui';
import { tap } from 'rxjs/operators';
interface PageIndicatorContext {
isRotated: boolean;
}
@Component({
selector: 'redaction-page-indicator',
@ -24,7 +19,7 @@ import { PageRotationService } from '../../../pdf-viewer/services/page-rotation.
styleUrls: ['./page-indicator.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy, OnChanges, OnInit {
export class PageIndicatorComponent extends ContextComponent<PageIndicatorContext> implements OnChanges, OnInit {
@Input() active = false;
@Input() showDottedIcon = false;
@Input() number: number;
@ -61,10 +56,13 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy
}
ngOnInit() {
this.addSubscription = this.pageRotationService.isRotated$(this.number).subscribe(value => {
this.isRotated = value;
this._changeDetectorRef.detectChanges();
});
const isRotated$ = this.pageRotationService.isRotated$(this.number).pipe(
tap(value => {
this.isRotated = value;
this._changeDetectorRef.detectChanges();
}),
);
super._initContext({ isRotated: isRotated$ });
}
ngOnChanges() {

View File

@ -55,7 +55,6 @@ export class AcceptRecommendationDialogComponent extends BaseDialogComponent imp
}
async ngOnInit() {
super.ngOnInit();
this.possibleDictionaries = await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id);
this.form.patchValue({
dictionary: this.possibleDictionaries.find(dict => dict.type === this.data.annotations[0].recommendationType).type,

View File

@ -33,7 +33,6 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
}
async ngOnInit() {
super.ngOnInit();
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
this.legalOptions = data

View File

@ -29,7 +29,6 @@ export class DocumentInfoDialogComponent extends BaseDialogComponent implements
}
async ngOnInit() {
super.ngOnInit();
this.attributes = (
await firstValueFrom(this._fileAttributesService.loadFileAttributesConfig(this._dossier.dossierTemplateId))
).fileAttributeConfigs.filter(attr => attr.editable);

View File

@ -40,7 +40,6 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
}
async ngOnInit() {
super.ngOnInit();
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({

View File

@ -72,7 +72,6 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
}
async ngOnInit() {
super.ngOnInit();
this.possibleDictionaries = await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id);
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({

View File

@ -25,8 +25,6 @@ export class RecategorizeImageDialogComponent extends BaseDialogComponent implem
}
ngOnInit() {
super.ngOnInit();
this.form = this._formBuilder.group({
type: [this.data.annotations[0].type, Validators.required],
comment: [null],

View File

@ -23,8 +23,6 @@ export class ResizeAnnotationDialogComponent extends BaseDialogComponent impleme
}
ngOnInit() {
super.ngOnInit();
const controlsConfig = { comment: [null] };
if (this._data.annotation.isModifyDictionary) {

View File

@ -2,7 +2,6 @@ import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from '@a
import { UserService } from '@services/user.service';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { Dossier, IDossierRequest } from '@red/domain';
import { AutoUnsubscribe } from '@iqser/common-ui';
import { EditDossierSaveResult, EditDossierSectionInterface } from '../edit-dossier-section.interface';
import { BehaviorSubject, firstValueFrom } from 'rxjs';
import { PermissionsService } from '@services/permissions.service';
@ -15,7 +14,7 @@ import { compareLists } from '@utils/functions';
styleUrls: ['./edit-dossier-team.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class EditDossierTeamComponent extends AutoUnsubscribe implements EditDossierSectionInterface, OnInit, OnDestroy {
export class EditDossierTeamComponent implements EditDossierSectionInterface, OnInit {
form: UntypedFormGroup;
searchQuery = '';
@ -31,9 +30,7 @@ export class EditDossierTeamComponent extends AutoUnsubscribe implements EditDos
private readonly _formBuilder: UntypedFormBuilder,
private readonly _dossiersService: DossiersService,
private readonly _permissionsService: PermissionsService,
) {
super();
}
) {}
get selectedOwnerId(): string {
return this.form.get('owner').value;

View File

@ -1,6 +1,5 @@
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from '@angular/core';
import { UserService } from '@services/user.service';
import { AutoUnsubscribe } from '@iqser/common-ui';
import { User } from '@red/domain';
import { TranslateService } from '@ngx-translate/core';
import { NamePipeOptions } from '@shared/pipes/name.pipe';
@ -11,7 +10,7 @@ import { NamePipeOptions } from '@shared/pipes/name.pipe';
styleUrls: ['./initials-avatar.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InitialsAvatarComponent extends AutoUnsubscribe implements OnInit, OnChanges, OnDestroy {
export class InitialsAvatarComponent implements OnInit, OnChanges {
@Input() color = 'lightgray';
@Input() size: 'small' | 'large' = 'small';
@Input() withName = false;
@ -22,9 +21,7 @@ export class InitialsAvatarComponent extends AutoUnsubscribe implements OnInit,
namePipeOptions: NamePipeOptions;
constructor(private readonly _userService: UserService, private readonly _translateService: TranslateService) {
super();
}
constructor(private readonly _userService: UserService, private readonly _translateService: TranslateService) {}
_user: User;

View File

@ -1,17 +0,0 @@
import { combineLatest, Observable, of } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { ValuesOf } from '@iqser/common-ui';
export class ContextComponent<T> {
componentContext$: Observable<T> | null = of({} as T);
protected _initContext(context: Record<string, Observable<ValuesOf<T>>>): void {
const observables = Object.values(context).map(obs => obs.pipe(startWith(null)));
const keys = Object.keys(context);
this.componentContext$ = combineLatest(observables).pipe(map(values => this._mapKeysToObs(keys, values)));
}
protected _mapKeysToObs(keys: string[], observables: ValuesOf<T>[]): T {
return keys.reduce((acc, key, index) => ({ ...acc, [key]: observables[index] }), {} as T);
}
}

@ -1 +1 @@
Subproject commit 7875f99a074704eaa3252258d7efd83c39a355b7
Subproject commit 767837c0deb93c475afe30150b3c169726168277