Merge branch 'nicoleta' into 'master'

RED-3800: changed mutate to update.

See merge request redactmanager/red-ui!191
This commit is contained in:
Dan Percic 2023-11-16 16:20:05 +01:00
commit 5fe11a1475
2 changed files with 13 additions and 15 deletions

View File

@ -139,9 +139,10 @@ export class FileAttributeComponent extends BaseFormComponent implements OnDestr
!this.isInEditMode
) {
$event.stopPropagation();
this.fileAttributesService.openAttributeEdits.mutate(value =>
value.push({ attribute: this.fileAttribute.id, file: this.file.id }),
);
this.fileAttributesService.openAttributeEdits.update(value => [
...value,
{ attribute: this.fileAttribute.id, file: this.file.id },
]);
this.#toggleEdit();
this.fileAttributesService.setFileEdit(this.file.fileId);
this.fileAttributesService.setOpenAttributeEdit(this.fileAttribute.id);
@ -173,19 +174,16 @@ export class FileAttributeComponent extends BaseFormComponent implements OnDestr
if (this.isInEditMode) {
this.form = this.#getForm();
this.#toggleEdit();
this.fileAttributesService.openAttributeEdits.mutate(value => {
for (let index = 0; index < value.length; index++) {
if (
JSON.stringify(value[index]) ===
this.fileAttributesService.openAttributeEdits.update(value =>
value.filter(
val =>
JSON.stringify(val) !==
JSON.stringify({
attribute: this.fileAttribute.id,
file: this.file.id,
})
) {
value.splice(index, 1);
}
}
});
}),
),
);
}
}

View File

@ -35,11 +35,11 @@ export class REDAnnotationManager {
}
addToHidden(value: string) {
this.#hidden.mutate(set => set.add(value));
this.#hidden.update(set => new Set([...set, value]));
}
removeFromHidden(value: string) {
this.#hidden.mutate(set => set.delete(value));
this.#hidden.update(set => new Set([...set].filter(val => value !== val)));
}
init(annotationManager: AnnotationManager) {