Merge branch 'RED-7762' into 'master'
RED-7762: updated conditions based on specific annotation combinations. See merge request redactmanager/red-ui!179
This commit is contained in:
commit
c4d31645ce
@ -1,5 +1,5 @@
|
|||||||
import { Component, inject, OnInit } from '@angular/core';
|
import { Component, inject, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, FormControl } from '@angular/forms';
|
import { FormControl, FormGroup } from '@angular/forms';
|
||||||
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
|
import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
|
||||||
import { Dictionary, SuperTypes } from '@red/domain';
|
import { Dictionary, SuperTypes } from '@red/domain';
|
||||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||||
@ -36,7 +36,6 @@ export class EditRedactionDialogComponent
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly _justificationsService: JustificationsService,
|
private readonly _justificationsService: JustificationsService,
|
||||||
private readonly _dictionaryService: DictionaryService,
|
private readonly _dictionaryService: DictionaryService,
|
||||||
private readonly _formBuilder: FormBuilder,
|
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
const annotations = this.data.annotations;
|
const annotations = this.data.annotations;
|
||||||
@ -58,7 +57,28 @@ export class EditRedactionDialogComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get disabled() {
|
get disabled() {
|
||||||
return this.form.invalid || (this.showExtras ? !this.form.controls.reason.value : false);
|
return (
|
||||||
|
this.form.invalid ||
|
||||||
|
(this.showExtras && (!this.allSkipped || this.isRedactBasedType) ? !this.form.controls.reason.value : false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get allRedacted() {
|
||||||
|
return this.data.annotations.every(annotation => annotation.isRedacted);
|
||||||
|
}
|
||||||
|
|
||||||
|
get allSkipped() {
|
||||||
|
return this.data.annotations.every(annotation => annotation.isSkipped);
|
||||||
|
}
|
||||||
|
|
||||||
|
get redactBasedTypes() {
|
||||||
|
return this._dictionaryService
|
||||||
|
.getRedactTextDictionaries(this.#dossier.dossierTemplateId, !this.#applyToAllDossiers)
|
||||||
|
.map(dictionary => dictionary.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
get isRedactBasedType() {
|
||||||
|
return this.redactBasedTypes.includes(this.form.controls.type.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -83,6 +103,13 @@ export class EditRedactionDialogComponent
|
|||||||
typeChanged() {
|
typeChanged() {
|
||||||
const selectedDictionaryType = this.form.controls.type.value;
|
const selectedDictionaryType = this.form.controls.type.value;
|
||||||
this.#setOptions(selectedDictionaryType);
|
this.#setOptions(selectedDictionaryType);
|
||||||
|
|
||||||
|
if (this.redactBasedTypes.includes(selectedDictionaryType)) {
|
||||||
|
this.form.controls.reason.enable();
|
||||||
|
} else {
|
||||||
|
this.form.patchValue({ reason: null, option: null });
|
||||||
|
this.form.controls.reason.disable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
@ -122,10 +149,12 @@ export class EditRedactionDialogComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
#getForm() {
|
#getForm() {
|
||||||
const sameType = this.data.annotations.every(annotation => annotation.type === this.data.annotations[0].type);
|
const sameType =
|
||||||
|
this.data.annotations.every(annotation => annotation.type === this.data.annotations[0].type) &&
|
||||||
|
(this.allRedacted || this.allSkipped);
|
||||||
const sameSection = this.data.annotations.every(annotation => annotation.section === this.data.annotations[0].section);
|
const sameSection = this.data.annotations.every(annotation => annotation.section === this.data.annotations[0].section);
|
||||||
return this._formBuilder.group({
|
return new FormGroup({
|
||||||
reason: new FormControl<LegalBasisOption>(null),
|
reason: new FormControl<LegalBasisOption>({ value: null, disabled: this.allSkipped }),
|
||||||
comment: new FormControl<string>(null),
|
comment: new FormControl<string>(null),
|
||||||
type: new FormControl<string>(sameType ? this.data.annotations[0].type : null),
|
type: new FormControl<string>(sameType ? this.data.annotations[0].type : null),
|
||||||
section: new FormControl<string>(sameSection ? this.data.annotations[0].section : null),
|
section: new FormControl<string>(sameSection ? this.data.annotations[0].section : null),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user