From e68811863d73629b31cc0956e9552b7b157224aa Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Sat, 26 Aug 2023 00:23:45 +0300 Subject: [PATCH] some updates --- .../manual-annotation-dialog.component.ts | 18 ++-- .../redact-text-dialog.component.html | 97 +++++++++---------- .../redact-text-dialog.component.ts | 36 +++---- .../remove-redaction-dialog.component.ts | 19 ++-- 4 files changed, 78 insertions(+), 92 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index ff09e3c8a..829047265 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -1,5 +1,5 @@ import { Component, Inject, OnInit } from '@angular/core'; -import { UntypedFormGroup, Validators } from '@angular/forms'; +import { Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { BaseDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; @@ -50,7 +50,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme this.manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); - this.form = this._getForm(); + this.form = this.#getForm(); this.initialFormValue = this.form.getRawValue(); } @@ -88,15 +88,15 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme this.legalOptions.sort((a, b) => a.label.localeCompare(b.label)); - this._selectReason(); + this.#selectReason(); if (!this.isRectangle) { - this._formatSelectedTextValue(); + this.#formatSelectedTextValue(); } } save() { - this._enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); + this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); try { const annotations = this.isRectangle && !!this.form.get('multiplePages').value @@ -138,7 +138,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme return wrappers; } - private _formatSelectedTextValue() { + #formatSelectedTextValue() { this.data.manualRedactionEntryWrapper.manualRedactionEntry.value = this.data.manualRedactionEntryWrapper.manualRedactionEntry.value.replace( // eslint-disable-next-line no-control-regex,max-len @@ -147,7 +147,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme ); } - private _getForm(): UntypedFormGroup { + #getForm() { return this._formBuilder.group({ selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value, section: [null], @@ -161,7 +161,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme }); } - private _enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) { + #enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) { const legalOption: LegalBasisOption = this.form.get('reason').value; addRedactionRequest.type = this.form.get('dictionary').value; if (legalOption) { @@ -187,7 +187,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme : this.form.get('selectedText').value; } - private _selectReason() { + #selectReason() { if (this.legalOptions.length === 1) { this.form.get('reason').setValue(this.legalOptions[0]); } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html index 833b087ee..54ba12229 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html @@ -4,89 +4,84 @@
- + {{ form.get('selectedText').value }}
- -
- - - + + + + - - {{ option.label }} - - - -
+ {{ option.label }} + + + +
-
- - -
- +
+ + +
- -
- +
+ - - - {{ displayedDictionaryLabel }} - - {{ dictionary.label }} - - - -
- + + + {{ displayedDictionaryLabel }} + + {{ dictionary.label }} + + + +
- + /> -
+
- + diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts index 44924ea27..d35be1ccf 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts @@ -1,17 +1,17 @@ import { Component, OnInit } from '@angular/core'; -import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; -import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormBuilder, UntypedFormGroup } from '@angular/forms'; +import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; +import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain'; +import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; +import { DictionaryService } from '@services/entity-services/dictionary.service'; +import { JustificationsService } from '@services/entity-services/justifications.service'; import { Roles } from '@users/roles'; import { firstValueFrom } from 'rxjs'; -import { JustificationsService } from '@services/entity-services/justifications.service'; -import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; -import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component'; -import { DictionaryService } from '@services/entity-services/dictionary.service'; import { tap } from 'rxjs/operators'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options'; import { RedactTextData, RedactTextResult } from '../../utils/dialog-types'; +import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component'; @Component({ templateUrl: './redact-text-dialog.component.html', @@ -21,6 +21,9 @@ export class RedactTextDialogComponent extends IqserDialogComponent implements OnInit { + #manualRedactionTypeExists = true; + #applyToAllDossiers: boolean; + readonly #dossier: Dossier; readonly roles = Roles; readonly iconButtonTypes = IconButtonTypes; readonly options: DetailsRadioOption[]; @@ -29,24 +32,17 @@ export class RedactTextDialogComponent dictionaries: Dictionary[] = []; form!: UntypedFormGroup; - #manualRedactionTypeExists = true; - #applyToAllDossiers: boolean; - - readonly #dossier: Dossier; - readonly #isRss = this._iqserPermissionsService.has(Roles.getRss); - constructor( private readonly _justificationsService: JustificationsService, private readonly _activeDossiersService: ActiveDossiersService, private readonly _dictionaryService: DictionaryService, - private readonly _iqserPermissionsService: IqserPermissionsService, private readonly _formBuilder: FormBuilder, ) { super(); this.#dossier = _activeDossiersService.find(this.data.dossierId); this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); - this.options = getRedactOrHintOptions(this.#dossier, this.#isRss, false, this.#applyToAllDossiers, this.data.isApprover); + this.options = getRedactOrHintOptions(this.#dossier, false, false, this.#applyToAllDossiers, this.data.isApprover); this.form = this.#getForm(); @@ -74,7 +70,7 @@ export class RedactTextDialogComponent } get disabled() { - if (this.dictionaryRequest || this.#isRss) { + if (this.dictionaryRequest) { return !this.form.get('dictionary').value; } return !this.form.get('reason').value; @@ -117,7 +113,7 @@ export class RedactTextDialogComponent save(): void { this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry; - this.dialogRef.close({ + this.close({ redaction, dictionary: this.dictionaries.find(d => d.type === this.form.get('dictionary').value), }); @@ -127,7 +123,7 @@ export class RedactTextDialogComponent this.dictionaries = this._dictionaryService.getRedactTextDictionaries(this.#dossier.dossierTemplateId, !this.#applyToAllDossiers); } - #getForm(): UntypedFormGroup { + #getForm() { return this._formBuilder.group({ selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value, reason: [null], @@ -172,9 +168,7 @@ export class RedactTextDialogComponent #resetValues() { this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; - if (!this.#isRss) { - this.options[1].extraOption.checked = this.#applyToAllDossiers; - } + this.options[1].extraOption.checked = this.#applyToAllDossiers; if (this.dictionaryRequest) { this.form.get('reason').setValue(null); this.form.get('dictionary').setValue(null); diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts index 55d55a5c3..32f7f6276 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts @@ -1,11 +1,10 @@ import { Component } from '@angular/core'; -import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; -import { FormBuilder, UntypedFormGroup } from '@angular/forms'; -import { PermissionsService } from '@services/permissions.service'; -import { tap } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { RemoveRedactionData, RemoveRedactionResult } from '../../utils/dialog-types'; +import { FormBuilder, UntypedFormGroup } from '@angular/forms'; +import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; +import { tap } from 'rxjs/operators'; import { getRemoveRedactionOptions, RemoveRedactionOption } from '../../utils/dialog-options'; +import { RemoveRedactionData, RemoveRedactionResult } from '../../utils/dialog-types'; @Component({ templateUrl: './remove-redaction-dialog.component.html', @@ -16,16 +15,14 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< RemoveRedactionData, RemoveRedactionResult > { + #applyToAllDossiers: boolean; readonly iconButtonTypes = IconButtonTypes; readonly options: DetailsRadioOption[]; readonly recommendation = this.data.redaction.isRecommendation; - form!: UntypedFormGroup; hint: boolean; - #applyToAllDossiers: boolean; - - constructor(private readonly _formBuilder: FormBuilder, private readonly _permissionsService: PermissionsService) { + constructor(private readonly _formBuilder: FormBuilder) { super(); this.hint = this.data.redaction.hint; this.options = getRemoveRedactionOptions(this.data); @@ -48,10 +45,10 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< } save(): void { - this.dialogRef.close(this.form.getRawValue()); + this.close(this.form.getRawValue()); } - #getForm(): UntypedFormGroup { + #getForm() { return this._formBuilder.group({ comment: [null], option: [this.options[0]],