From a82fcad5493696bcb11a2d4e9d6c337caf7d84c8 Mon Sep 17 00:00:00 2001 From: Aaron Gundel Date: Wed, 8 Jan 2025 11:49:37 -0700 Subject: [PATCH] Adds note editor (#177) --- arches_lingo/src/arches_lingo/api.ts | 27 +- .../components/generic/NoteEditor.vue | 243 ++++++++++++++++++ .../components/scheme/report/SchemeNote.vue | 15 +- arches_lingo/src/arches_lingo/types.ts | 4 + 4 files changed, 285 insertions(+), 4 deletions(-) create mode 100644 arches_lingo/src/arches_lingo/components/generic/NoteEditor.vue diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 4dc9213c..304d5217 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -1,6 +1,10 @@ import arches from "arches"; import Cookies from "js-cookie"; -import type { AppellativeStatus, SchemeInstance } from "@/arches_lingo/types"; +import type { + AppellativeStatus, + SchemeInstance, + SchemeStatement, +} from "@/arches_lingo/types"; function getToken() { const token = Cookies.get("csrftoken"); @@ -148,6 +152,27 @@ export const fetchSchemeNotes = async (schemeId: string) => { return parsed; }; +export const updateSchemeNote = async ( + schemeId: string, + tileId: string, + schemeStatement: SchemeStatement, +) => { + const response = await fetch( + arches.urls.api_scheme_note_tile(schemeId, tileId), + { + method: "PATCH", + headers: { + "X-CSRFTOKEN": getToken(), + "Content-Type": "application/json", + }, + body: JSON.stringify(schemeStatement), + }, + ); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + export const deleteSchemeNoteTile = async ( schemeId: string, tileId: string, diff --git a/arches_lingo/src/arches_lingo/components/generic/NoteEditor.vue b/arches_lingo/src/arches_lingo/components/generic/NoteEditor.vue new file mode 100644 index 00000000..75c2f77f --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/NoteEditor.vue @@ -0,0 +1,243 @@ + + + diff --git a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNote.vue b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNote.vue index 5fdfeb45..ebab9ffd 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNote.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNote.vue @@ -1,5 +1,5 @@