RED-7069, fix reading from undefined.

This commit is contained in:
George 2023-07-27 19:02:57 +03:00
parent 95d83d3b6d
commit 62fe3fb048
2 changed files with 9 additions and 2 deletions

View File

@ -27,6 +27,7 @@ export class EditRedactionDialogComponent
readonly isImage: boolean;
readonly initialReason: string;
readonly initialType: string;
readonly isManualRedaction: boolean;
options: DetailsRadioOption<RedactOrHintOption>[] | undefined;
legalOptions: LegalBasisOption[] = [];
dictionaries: Dictionary[] = [];
@ -51,13 +52,14 @@ export class EditRedactionDialogComponent
this.redactedText = annotations.length === 1 && !this.isImage ? firstEntry.value : null;
this.initialReason = firstEntry.legalBasis;
this.initialType = firstEntry.type;
this.isManualRedaction = firstEntry.type === SuperTypes.ManualRedaction;
this.form = this.#getForm();
this.form.valueChanges
.pipe(
tap(value => {
const reasonChanged = this.initialReason !== value.reason.legalBasis;
const typeChanged = this.initialType !== value.type;
const reasonChanged = this.initialReason !== value?.reason?.legalBasis;
const typeChanged = this.initialType !== value?.type;
if (typeChanged || reasonChanged) {
this.#setOptions(value.type, reasonChanged);
}

View File

@ -116,8 +116,13 @@ export class AnnotationActionsService {
};
const result = await this._iqserDialog.openDefault(EditRedactionDialogComponent, { data }).result();
const requests: Observable<unknown>[] = [];
if (!result) {
return;
}
const changeLegalBasisBody = annotations.map(annotation => ({
annotationId: annotation.id,
legalBasis: result.legalBasis,