Merge branch 'RED-8795' into 'master'
RED-8795: changed default options for add and remove dialogs. Closes RED-8795 See merge request redactmanager/red-ui!353
This commit is contained in:
commit
345ed64bb1
@ -40,6 +40,16 @@ export class RedactTextDialogComponent
|
||||
readonly #manualRedactionTypeExists = inject(DictionaryService).hasManualType(this.#dossier.dossierTemplateId);
|
||||
#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
|
||||
|
||||
get defaultOption() {
|
||||
const inDossierOption = this.options.find(option => option.value === RedactOrHintOptions.IN_DOSSIER);
|
||||
this.dictionaryRequest = !!inDossierOption && !inDossierOption.disabled;
|
||||
if (this.dictionaryRequest) {
|
||||
this.#setDictionaries();
|
||||
return inDossierOption;
|
||||
}
|
||||
return this.options[0];
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly _justificationsService: JustificationsService,
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
@ -49,6 +59,7 @@ export class RedactTextDialogComponent
|
||||
|
||||
this.options = getRedactOrHintOptions(this.#dossier, this.#applyToAllDossiers, this.data.isApprover, this.data.isPageExcluded);
|
||||
this.form = this.#getForm();
|
||||
this.#setupValidators(this.dictionaryRequest ? RedactOrHintOptions.IN_DOSSIER : RedactOrHintOptions.ONLY_HERE);
|
||||
|
||||
this.form.controls.option.valueChanges
|
||||
.pipe(
|
||||
@ -152,10 +163,10 @@ export class RedactTextDialogComponent
|
||||
#getForm(): FormGroup {
|
||||
return this._formBuilder.group({
|
||||
selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value,
|
||||
reason: [null as LegalBasisOption, Validators.required],
|
||||
reason: [null as LegalBasisOption],
|
||||
comment: [null],
|
||||
dictionary: [this.#manualRedactionTypeExists ? SuperTypes.ManualRedaction : null],
|
||||
option: this.options[0],
|
||||
option: this.defaultOption,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { getRemoveRedactionOptions, RemoveAnnotationOptions, RemoveRedactionOption } from '../../utils/dialog-options';
|
||||
import {
|
||||
getRemoveRedactionOptions,
|
||||
RemoveAnnotationOptions,
|
||||
RemoveRedactionOption,
|
||||
RemoveRedactionOptions,
|
||||
} from '../../utils/dialog-options';
|
||||
import { RemoveRedactionData, RemoveRedactionResult } from '../../utils/dialog-types';
|
||||
import { Roles } from '@users/roles';
|
||||
import { DialogHelpModeKeys } from '../../utils/constants';
|
||||
@ -17,7 +20,6 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
|
||||
RemoveRedactionData,
|
||||
RemoveRedactionResult
|
||||
> {
|
||||
#applyToAllDossiers: boolean;
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
readonly options: DetailsRadioOption<RemoveRedactionOption>[];
|
||||
readonly recommendation: boolean;
|
||||
@ -35,21 +37,6 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
|
||||
this.options = getRemoveRedactionOptions(this.data);
|
||||
this.redactedTexts = this.data.redactions.map(annotation => annotation.value);
|
||||
this.form = this.#getForm();
|
||||
this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
|
||||
|
||||
this.form
|
||||
.get('option')
|
||||
.valueChanges.pipe(
|
||||
tap(() => {
|
||||
for (const option of this.options) {
|
||||
if (option.extraOption) {
|
||||
option.extraOption.checked = this.#applyToAllDossiers;
|
||||
}
|
||||
}
|
||||
}),
|
||||
takeUntilDestroyed(),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
get isFalsePositive(): boolean {
|
||||
@ -58,17 +45,23 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
|
||||
|
||||
get helpButtonKey() {
|
||||
if (this.hint) {
|
||||
return DialogHelpModeKeys.HINT_REMOVE
|
||||
return DialogHelpModeKeys.HINT_REMOVE;
|
||||
}
|
||||
if (this.recommendation) {
|
||||
return DialogHelpModeKeys.RECOMMENDATION_REMOVE
|
||||
return DialogHelpModeKeys.RECOMMENDATION_REMOVE;
|
||||
}
|
||||
if (this.skipped) {
|
||||
return DialogHelpModeKeys.SKIPPED_REMOVE
|
||||
return DialogHelpModeKeys.SKIPPED_REMOVE;
|
||||
}
|
||||
return DialogHelpModeKeys.REDACTION_REMOVE;
|
||||
}
|
||||
|
||||
get defaultOption() {
|
||||
const removeHereOption = this.options.find(option => option.value === RemoveRedactionOptions.ONLY_HERE);
|
||||
if (!!removeHereOption && !removeHereOption.disabled) return removeHereOption;
|
||||
return this.options[0];
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.close(this.form.getRawValue());
|
||||
}
|
||||
@ -76,7 +69,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
|
||||
#getForm() {
|
||||
return this._formBuilder.group({
|
||||
comment: [null],
|
||||
option: [this.options[0]],
|
||||
option: [this.defaultOption],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,14 +177,14 @@ export const getRemoveRedactionOptions = (
|
||||
extraOption: !isDocumine
|
||||
? {
|
||||
label: translations.IN_DOSSIER.extraOptionLabel,
|
||||
checked: applyToAllDossiers ?? true,
|
||||
checked: redactions[0].isRecommendation && applyToAllDossiers,
|
||||
hidden: !isApprover,
|
||||
}
|
||||
: null,
|
||||
});
|
||||
}
|
||||
if (permissions.canMarkAsFalsePositive) {
|
||||
if (data.redactions[0].isRecommendation) {
|
||||
if (redactions[0].isRecommendation) {
|
||||
options.push({
|
||||
label: translations.DO_NOT_RECOMMEND.label,
|
||||
description: isBulk ? translations.DO_NOT_RECOMMEND.descriptionBulk : translations.DO_NOT_RECOMMEND.description,
|
||||
@ -198,7 +198,7 @@ export const getRemoveRedactionOptions = (
|
||||
extraOption: !isDocumine
|
||||
? {
|
||||
label: translations.DO_NOT_RECOMMEND.extraOptionLabel,
|
||||
checked: applyToAllDossiers ?? true,
|
||||
checked: applyToAllDossiers,
|
||||
hidden: !isApprover,
|
||||
}
|
||||
: null,
|
||||
@ -217,7 +217,7 @@ export const getRemoveRedactionOptions = (
|
||||
extraOption: !isDocumine
|
||||
? {
|
||||
label: translations.FALSE_POSITIVE.extraOptionLabel,
|
||||
checked: applyToAllDossiers ?? true,
|
||||
checked: false,
|
||||
hidden: !isApprover,
|
||||
}
|
||||
: null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user