Skip to content

Commit

Permalink
Merge pull request #4880 from dodona-edu/fix/save-and-edit
Browse files Browse the repository at this point in the history
Fix saving an annotation after editing it
  • Loading branch information
jorg-vr authored Aug 9, 2023
2 parents 3bc9c17 + d2c9bb6 commit ea44734
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/assets/javascripts/components/annotations/user_annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "components/saved_annotations/new_saved_annotation";
import { initTooltips } from "utilities";
import "components/saved_annotations/saved_annotation_icon";
import { annotationState } from "state/Annotations";
import { savedAnnotationState } from "state/SavedAnnotations";

/**
* This component represents a single user annotation.
Expand Down Expand Up @@ -105,6 +106,15 @@ export class UserAnnotationComponent extends i18nMixin(ShadowlessLitElement) {
annotation_text: e.detail.text,
saved_annotation_id: e.detail.savedAnnotationId || undefined,
});
if (e.detail.saveAnnotation) {
await savedAnnotationState.create( {
from: this.data.id,
saved_annotation: {
title: e.detail.savedAnnotationTitle,
annotation_text: e.detail.text,
}
});
}
this.editing = false;
} catch (e) {
this.annotationFormRef.value.hasErrors = true;
Expand Down

0 comments on commit ea44734

Please sign in to comment.