diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 5cf0ea51..06169eb7 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"); @@ -100,6 +104,26 @@ export const createSchemeLabel = async ( return parsed; }; +export const createSchemeNote = async ( + schemeId: string, + statement: SchemeStatement, +) => { + const response = await fetch(arches.urls.api_scheme_note_create, { + method: "POST", + headers: { + "X-CSRFTOKEN": getToken(), + "Content-Type": "application/json", + }, + body: JSON.stringify({ + resourceinstance: schemeId, + ...statement, + }), + }); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + export const deleteSchemeLabelTile = async ( schemeId: string, tileId: string, @@ -151,6 +175,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/LabelEditor.vue b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue index b486746f..59a2d19b 100644 --- a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue +++ b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue @@ -231,8 +231,7 @@ async function getResourceInstanceOptions( }); return results; } - -onMounted(async () => { +async function initializeSelectOptions() { getControlledLists(); groupAndPersonOptions.value = await getResourceInstanceOptions( fetchGroupRdmSystemList, @@ -244,7 +243,9 @@ onMounted(async () => { textualWorkOptions.value = await getResourceInstanceOptions( fetchTextualWorkRdmSystemList, ); -}); +} + +onMounted(initializeSelectOptions);