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 { 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]);
}

View File

@ -4,89 +4,84 @@
<div class="dialog-content redaction">
<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 }}
</div>
<iqser-details-radio
[options]="options"
(extraOptionChanged)="extraOptionChanged($event)"
[options]="options"
formControlName="option"
></iqser-details-radio>
<ng-container *deny="roles.getRss; if: !dictionaryRequest">
<div class="iqser-input-group required w-450">
<label [translate]="'redact-text.dialog.content.reason'"></label>
<mat-form-field>
<mat-select
[placeholder]="'redact-text.dialog.content.reason-placeholder' | translate"
class="full-width"
formControlName="reason"
<div *ngIf="!dictionaryRequest" class="iqser-input-group required w-450">
<label [translate]="'redact-text.dialog.content.reason'"></label>
<mat-form-field>
<mat-select
[placeholder]="'redact-text.dialog.content.reason-placeholder' | translate"
class="full-width"
formControlName="reason"
>
<mat-option
*ngFor="let option of legalOptions"
[matTooltip]="option.description"
[value]="option"
matTooltipPosition="after"
>
<mat-option
*ngFor="let option of legalOptions"
[matTooltip]="option.description"
[value]="option"
matTooltipPosition="after"
>
{{ option.label }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
{{ option.label }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="iqser-input-group w-450">
<label [translate]="'redact-text.dialog.content.legal-basis'"></label>
<input [value]="form.get('reason').value?.legalBasis" disabled type="text" />
</div>
</ng-container>
<div *ngIf="!dictionaryRequest" class="iqser-input-group w-450">
<label [translate]="'redact-text.dialog.content.legal-basis'"></label>
<input [value]="form.get('reason').value?.legalBasis" disabled type="text" />
</div>
<ng-container *deny="roles.getRss; if: dictionaryRequest">
<div class="iqser-input-group required w-450">
<label [translate]="'redact-text.dialog.content.type'"></label>
<div *ngIf="dictionaryRequest" class="iqser-input-group required w-450">
<label [translate]="'redact-text.dialog.content.type'"></label>
<mat-form-field>
<mat-select formControlName="dictionary" [placeholder]="'redact-text.dialog.content.type-placeholder' | translate">
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
<mat-option
*ngFor="let dictionary of dictionaries"
[matTooltip]="dictionary.description"
[value]="dictionary.type"
(click)="typeChanged()"
matTooltipPosition="after"
>
<span> {{ dictionary.label }} </span>
</mat-option>
</mat-select>
</mat-form-field>
</div>
</ng-container>
<mat-form-field>
<mat-select [placeholder]="'redact-text.dialog.content.type-placeholder' | translate" formControlName="dictionary">
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
<mat-option
(click)="typeChanged()"
*ngFor="let dictionary of dictionaries"
[matTooltip]="dictionary.description"
[value]="dictionary.type"
matTooltipPosition="after"
>
<span> {{ dictionary.label }} </span>
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div *ngIf="!dictionaryRequest" class="iqser-input-group w-450">
<label [translate]="'redact-text.dialog.content.comment'"></label>
<textarea
[placeholder]="'redact-text.dialog.content.comment-placeholder' | translate"
formControlName="comment"
iqserHasScrollbar
name="comment"
rows="4"
type="text"
[placeholder]="'redact-text.dialog.content.comment-placeholder' | translate"
></textarea>
</div>
</div>
<div class="dialog-actions">
<iqser-icon-button
[disabled]="disabled"
[label]="'redact-text.dialog.actions.save' | translate"
[submit]="true"
[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>
</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>

View File

@ -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<RedactTextDialogComponent, RedactTextData, RedactTextResult>
implements OnInit
{
#manualRedactionTypeExists = true;
#applyToAllDossiers: boolean;
readonly #dossier: Dossier;
readonly roles = Roles;
readonly iconButtonTypes = IconButtonTypes;
readonly options: DetailsRadioOption<RedactOrHintOption>[];
@ -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);

View File

@ -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<RemoveRedactionOption>[];
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]],