From 6a9627e067b6139d02cab646d6460b93cbf60718 Mon Sep 17 00:00:00 2001 From: Johnathan Clementi Date: Fri, 3 Jan 2025 19:13:00 -0500 Subject: [PATCH] Save / update scheme labels #147 --- arches_lingo/src/arches_lingo/api.ts | 24 +++++- .../components/generic/LabelEditor.vue | 81 +++++++++++++++---- .../components/scheme/report/SchemeLabel.vue | 28 +++---- 3 files changed, 101 insertions(+), 32 deletions(-) diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 45afef2d..ab9ccd4e 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -1,7 +1,6 @@ import arches from "arches"; import Cookies from "js-cookie"; - -import type { SchemeInstance } from "@/arches_lingo/types"; +import type { AppellativeStatus, SchemeInstance } from "@/arches_lingo/types"; function getToken() { const token = Cookies.get("csrftoken"); @@ -101,6 +100,27 @@ export const deleteSchemeLabelTile = async ( } }; +export const updateSchemeLabel = async ( + schemeId: string, + tileId: string, + appellative_status: AppellativeStatus, +) => { + const response = await fetch( + arches.urls.api_scheme_label_tile(schemeId, tileId), + { + method: "PATCH", + headers: { + "X-CSRFTOKEN": getToken(), + "Content-Type": "application/json", + }, + body: JSON.stringify(appellative_status), + }, + ); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + export const fetchSchemeNotes = async (schemeId: string) => { const response = await fetch(arches.urls.api_scheme_note(schemeId)); const parsed = await response.json(); diff --git a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue index ba6f6061..f3419f65 100644 --- a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue +++ b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue @@ -1,10 +1,16 @@