some updates

This commit is contained in:
Dan Percic 2023-08-26 00:23:45 +03:00
parent 36d9edc5b6
commit e68811863d
4 changed files with 78 additions and 92 deletions

View File

@ -1,5 +1,5 @@
import { Component, Inject, OnInit } from '@angular/core'; 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 { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { BaseDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; 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.manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId);
this.form = this._getForm(); this.form = this.#getForm();
this.initialFormValue = this.form.getRawValue(); 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.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
this._selectReason(); this.#selectReason();
if (!this.isRectangle) { if (!this.isRectangle) {
this._formatSelectedTextValue(); this.#formatSelectedTextValue();
} }
} }
save() { save() {
this._enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
try { try {
const annotations = const annotations =
this.isRectangle && !!this.form.get('multiplePages').value this.isRectangle && !!this.form.get('multiplePages').value
@ -138,7 +138,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
return wrappers; return wrappers;
} }
private _formatSelectedTextValue() { #formatSelectedTextValue() {
this.data.manualRedactionEntryWrapper.manualRedactionEntry.value = this.data.manualRedactionEntryWrapper.manualRedactionEntry.value =
this.data.manualRedactionEntryWrapper.manualRedactionEntry.value.replace( this.data.manualRedactionEntryWrapper.manualRedactionEntry.value.replace(
// eslint-disable-next-line no-control-regex,max-len // 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({ return this._formBuilder.group({
selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value, selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value,
section: [null], 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; const legalOption: LegalBasisOption = this.form.get('reason').value;
addRedactionRequest.type = this.form.get('dictionary').value; addRedactionRequest.type = this.form.get('dictionary').value;
if (legalOption) { if (legalOption) {
@ -187,7 +187,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
: this.form.get('selectedText').value; : this.form.get('selectedText').value;
} }
private _selectReason() { #selectReason() {
if (this.legalOptions.length === 1) { if (this.legalOptions.length === 1) {
this.form.get('reason').setValue(this.legalOptions[0]); this.form.get('reason').setValue(this.legalOptions[0]);
} }

View File

@ -4,18 +4,17 @@
<div class="dialog-content redaction"> <div class="dialog-content redaction">
<div class="iqser-input-group w-450"> <div class="iqser-input-group w-450">
<label class="selected-text" [translate]="'redact-text.dialog.content.selected-text'"></label> <label [translate]="'redact-text.dialog.content.selected-text'" class="selected-text"></label>
{{ form.get('selectedText').value }} {{ form.get('selectedText').value }}
</div> </div>
<iqser-details-radio <iqser-details-radio
[options]="options"
(extraOptionChanged)="extraOptionChanged($event)" (extraOptionChanged)="extraOptionChanged($event)"
[options]="options"
formControlName="option" formControlName="option"
></iqser-details-radio> ></iqser-details-radio>
<ng-container *deny="roles.getRss; if: !dictionaryRequest"> <div *ngIf="!dictionaryRequest" class="iqser-input-group required w-450">
<div class="iqser-input-group required w-450">
<label [translate]="'redact-text.dialog.content.reason'"></label> <label [translate]="'redact-text.dialog.content.reason'"></label>
<mat-form-field> <mat-form-field>
<mat-select <mat-select
@ -35,24 +34,22 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div class="iqser-input-group w-450"> <div *ngIf="!dictionaryRequest" class="iqser-input-group w-450">
<label [translate]="'redact-text.dialog.content.legal-basis'"></label> <label [translate]="'redact-text.dialog.content.legal-basis'"></label>
<input [value]="form.get('reason').value?.legalBasis" disabled type="text" /> <input [value]="form.get('reason').value?.legalBasis" disabled type="text" />
</div> </div>
</ng-container>
<ng-container *deny="roles.getRss; if: dictionaryRequest"> <div *ngIf="dictionaryRequest" class="iqser-input-group required w-450">
<div class="iqser-input-group required w-450">
<label [translate]="'redact-text.dialog.content.type'"></label> <label [translate]="'redact-text.dialog.content.type'"></label>
<mat-form-field> <mat-form-field>
<mat-select formControlName="dictionary" [placeholder]="'redact-text.dialog.content.type-placeholder' | translate"> <mat-select [placeholder]="'redact-text.dialog.content.type-placeholder' | translate" formControlName="dictionary">
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger> <mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
<mat-option <mat-option
(click)="typeChanged()"
*ngFor="let dictionary of dictionaries" *ngFor="let dictionary of dictionaries"
[matTooltip]="dictionary.description" [matTooltip]="dictionary.description"
[value]="dictionary.type" [value]="dictionary.type"
(click)="typeChanged()"
matTooltipPosition="after" matTooltipPosition="after"
> >
<span> {{ dictionary.label }} </span> <span> {{ dictionary.label }} </span>
@ -60,33 +57,31 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
</ng-container>
<div *ngIf="!dictionaryRequest" class="iqser-input-group w-450"> <div *ngIf="!dictionaryRequest" class="iqser-input-group w-450">
<label [translate]="'redact-text.dialog.content.comment'"></label> <label [translate]="'redact-text.dialog.content.comment'"></label>
<textarea <textarea
[placeholder]="'redact-text.dialog.content.comment-placeholder' | translate"
formControlName="comment" formControlName="comment"
iqserHasScrollbar iqserHasScrollbar
name="comment" name="comment"
rows="4" rows="4"
type="text" type="text"
[placeholder]="'redact-text.dialog.content.comment-placeholder' | translate"
></textarea> ></textarea>
</div> </div>
</div> </div>
<div class="dialog-actions"> <div class="dialog-actions">
<iqser-icon-button <iqser-icon-button
[disabled]="disabled"
[label]="'redact-text.dialog.actions.save' | translate" [label]="'redact-text.dialog.actions.save' | translate"
[submit]="true" [submit]="true"
[type]="iconButtonTypes.primary" [type]="iconButtonTypes.primary"
[disabled]="disabled" />
>
</iqser-icon-button>
<div class="all-caps-label cancel" mat-dialog-close [translate]="'redact-text.dialog.actions.cancel'"></div> <div [translate]="'redact-text.dialog.actions.cancel'" class="all-caps-label cancel" mat-dialog-close></div>
</div> </div>
</form> </form>
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button> <iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close" />
</section> </section>

View File

@ -1,17 +1,17 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain';
import { FormBuilder, UntypedFormGroup } from '@angular/forms'; 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 { Roles } from '@users/roles';
import { firstValueFrom } from 'rxjs'; 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 { tap } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options'; import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options';
import { RedactTextData, RedactTextResult } from '../../utils/dialog-types'; import { RedactTextData, RedactTextResult } from '../../utils/dialog-types';
import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component';
@Component({ @Component({
templateUrl: './redact-text-dialog.component.html', templateUrl: './redact-text-dialog.component.html',
@ -21,6 +21,9 @@ export class RedactTextDialogComponent
extends IqserDialogComponent<RedactTextDialogComponent, RedactTextData, RedactTextResult> extends IqserDialogComponent<RedactTextDialogComponent, RedactTextData, RedactTextResult>
implements OnInit implements OnInit
{ {
#manualRedactionTypeExists = true;
#applyToAllDossiers: boolean;
readonly #dossier: Dossier;
readonly roles = Roles; readonly roles = Roles;
readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
readonly options: DetailsRadioOption<RedactOrHintOption>[]; readonly options: DetailsRadioOption<RedactOrHintOption>[];
@ -29,24 +32,17 @@ export class RedactTextDialogComponent
dictionaries: Dictionary[] = []; dictionaries: Dictionary[] = [];
form!: UntypedFormGroup; form!: UntypedFormGroup;
#manualRedactionTypeExists = true;
#applyToAllDossiers: boolean;
readonly #dossier: Dossier;
readonly #isRss = this._iqserPermissionsService.has(Roles.getRss);
constructor( constructor(
private readonly _justificationsService: JustificationsService, private readonly _justificationsService: JustificationsService,
private readonly _activeDossiersService: ActiveDossiersService, private readonly _activeDossiersService: ActiveDossiersService,
private readonly _dictionaryService: DictionaryService, private readonly _dictionaryService: DictionaryService,
private readonly _iqserPermissionsService: IqserPermissionsService,
private readonly _formBuilder: FormBuilder, private readonly _formBuilder: FormBuilder,
) { ) {
super(); super();
this.#dossier = _activeDossiersService.find(this.data.dossierId); this.#dossier = _activeDossiersService.find(this.data.dossierId);
this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); 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(); this.form = this.#getForm();
@ -74,7 +70,7 @@ export class RedactTextDialogComponent
} }
get disabled() { get disabled() {
if (this.dictionaryRequest || this.#isRss) { if (this.dictionaryRequest) {
return !this.form.get('dictionary').value; return !this.form.get('dictionary').value;
} }
return !this.form.get('reason').value; return !this.form.get('reason').value;
@ -117,7 +113,7 @@ export class RedactTextDialogComponent
save(): void { save(): void {
this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry; const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry;
this.dialogRef.close({ this.close({
redaction, redaction,
dictionary: this.dictionaries.find(d => d.type === this.form.get('dictionary').value), 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); this.dictionaries = this._dictionaryService.getRedactTextDictionaries(this.#dossier.dossierTemplateId, !this.#applyToAllDossiers);
} }
#getForm(): UntypedFormGroup { #getForm() {
return this._formBuilder.group({ return this._formBuilder.group({
selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value, selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value,
reason: [null], reason: [null],
@ -172,9 +168,7 @@ export class RedactTextDialogComponent
#resetValues() { #resetValues() {
this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; 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) { if (this.dictionaryRequest) {
this.form.get('reason').setValue(null); this.form.get('reason').setValue(null);
this.form.get('dictionary').setValue(null); this.form.get('dictionary').setValue(null);

View File

@ -1,11 +1,10 @@
import { Component } from '@angular/core'; 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 { 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 { getRemoveRedactionOptions, RemoveRedactionOption } from '../../utils/dialog-options';
import { RemoveRedactionData, RemoveRedactionResult } from '../../utils/dialog-types';
@Component({ @Component({
templateUrl: './remove-redaction-dialog.component.html', templateUrl: './remove-redaction-dialog.component.html',
@ -16,16 +15,14 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
RemoveRedactionData, RemoveRedactionData,
RemoveRedactionResult RemoveRedactionResult
> { > {
#applyToAllDossiers: boolean;
readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
readonly options: DetailsRadioOption<RemoveRedactionOption>[]; readonly options: DetailsRadioOption<RemoveRedactionOption>[];
readonly recommendation = this.data.redaction.isRecommendation; readonly recommendation = this.data.redaction.isRecommendation;
form!: UntypedFormGroup; form!: UntypedFormGroup;
hint: boolean; hint: boolean;
#applyToAllDossiers: boolean; constructor(private readonly _formBuilder: FormBuilder) {
constructor(private readonly _formBuilder: FormBuilder, private readonly _permissionsService: PermissionsService) {
super(); super();
this.hint = this.data.redaction.hint; this.hint = this.data.redaction.hint;
this.options = getRemoveRedactionOptions(this.data); this.options = getRemoveRedactionOptions(this.data);
@ -48,10 +45,10 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
} }
save(): void { save(): void {
this.dialogRef.close(this.form.getRawValue()); this.close(this.form.getRawValue());
} }
#getForm(): UntypedFormGroup { #getForm() {
return this._formBuilder.group({ return this._formBuilder.group({
comment: [null], comment: [null],
option: [this.options[0]], option: [this.options[0]],