diff --git a/arches_lingo/pkg/graphs/resource_models/Scheme.json b/arches_lingo/pkg/graphs/resource_models/Scheme.json index eeb75ab8..50a6675b 100644 --- a/arches_lingo/pkg/graphs/resource_models/Scheme.json +++ b/arches_lingo/pkg/graphs/resource_models/Scheme.json @@ -1463,20 +1463,13 @@ { "card_id": "92c68f1f-423c-11ee-8a8d-11afefc4bff7", "config": { - "defaultValue": { - "en": { - "direction": "ltr", - "value": "" - } - }, + "defaultValue": "", "i18n_properties": [ "placeholder" ], "label": "Namespace Name", "maxLength": null, - "placeholder": { - "en": "Enter text" - }, + "placeholder":"Enter text", "uneditable": false, "width": "100%" }, @@ -1488,7 +1481,7 @@ "sortorder": 0, "source_identifier_id": null, "visible": true, - "widget_id": "10000000-0000-0000-0000-000000000001" + "widget_id": "46ef064b-2611-4708-9f52-60136bd8a65b" }, { "card_id": "87fac835-423c-11ee-8a8d-11afefc4bff7", @@ -3196,7 +3189,7 @@ { "alias": "namespace_name", "config": {}, - "datatype": "string", + "datatype": "non-localized-string", "description": null, "exportable": false, "fieldname": null, diff --git a/arches_lingo/pkg/graphs/resource_models/scheme_rdm_system.json b/arches_lingo/pkg/graphs/resource_models/scheme_rdm_system.json index e900b711..3a9b37c7 100644 --- a/arches_lingo/pkg/graphs/resource_models/scheme_rdm_system.json +++ b/arches_lingo/pkg/graphs/resource_models/scheme_rdm_system.json @@ -3393,20 +3393,13 @@ { "card_id": "5b8894b3-48aa-11ee-8a8d-11afefc4bff7", "config": { - "defaultValue": { - "en": { - "direction": "ltr", - "value": "" - } - }, + "defaultValue": "", "i18n_properties": [ "placeholder" ], "label": "Namespace Name", "maxLength": null, - "placeholder": { - "en": "Enter text" - }, + "placeholder": "Enter text", "uneditable": false, "width": "100%" }, @@ -3417,7 +3410,7 @@ "node_id": "5b8894c0-48aa-11ee-8a8d-11afefc4bff7", "sortorder": 0, "visible": true, - "widget_id": "10000000-0000-0000-0000-000000000001" + "widget_id": "46ef064b-2611-4708-9f52-60136bd8a65b" }, { "card_id": "5b8894b6-48aa-11ee-8a8d-11afefc4bff7", diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py index 3fcd733c..07c2baba 100644 --- a/arches_lingo/serializers.py +++ b/arches_lingo/serializers.py @@ -18,6 +18,14 @@ class Meta: fields = "__all__" +class SchemeNamespaceSerializer(ArchesModelSerializer): + class Meta: + model = ResourceInstance + graph_slug = "scheme" + nodegroups = ["namespace"] + fields = "__all__" + + class ConceptStatementSerializer(ArchesTileSerializer): class Meta: model = TileModel diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index ac148ef9..a75131da 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -1,5 +1,6 @@ import arches from "arches"; import Cookies from "js-cookie"; +import type { SchemeNamespace } from "@/arches_lingo/types"; function getToken() { const token = Cookies.get("csrftoken"); @@ -37,6 +38,30 @@ export const fetchUser = async () => { return parsed; }; +export const fetchSchemeNamespace = async (schemeId: string) => { + const response = await fetch(arches.urls.api_uri_namespace(schemeId)); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + +export const updateSchemeNamespace = async ( + schemeId: string, + schemeNamespace: SchemeNamespace, +) => { + const response = await fetch(arches.urls.api_uri_namespace(schemeId), { + method: "PATCH", + headers: { + "X-CSRFTOKEN": getToken(), + "Content-Type": "application/json", + }, + body: JSON.stringify(schemeNamespace), + }); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + export const fetchSearchResults = async ( searchTerm: string, items: number, diff --git a/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue b/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue new file mode 100644 index 00000000..f530f5a7 --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue @@ -0,0 +1,23 @@ + + diff --git a/arches_lingo/src/arches_lingo/components/generic/ControlledListItemViewer.vue b/arches_lingo/src/arches_lingo/components/generic/ControlledListItemViewer.vue new file mode 100644 index 00000000..063e6465 --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/ControlledListItemViewer.vue @@ -0,0 +1,8 @@ + + diff --git a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue new file mode 100644 index 00000000..3836eb9d --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue @@ -0,0 +1,27 @@ + + diff --git a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringEditor.vue b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringEditor.vue new file mode 100644 index 00000000..c862dd9d --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringEditor.vue @@ -0,0 +1,26 @@ + + diff --git a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringViewer.vue b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringViewer.vue new file mode 100644 index 00000000..b0570b45 --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringViewer.vue @@ -0,0 +1,6 @@ + + diff --git a/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue b/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue index 3fda8c94..06f741c4 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue @@ -2,52 +2,124 @@ import { useGettext } from "vue3-gettext"; import Button from "primevue/button"; -const { $gettext } = useGettext(); +import Tabs from "primevue/tabs"; +import TabList from "primevue/tablist"; +import Tab from "primevue/tab"; +import TabPanels from "primevue/tabpanels"; +import TabPanel from "primevue/tabpanel"; +import SchemeNamespace from "../report/SchemeNamespace.vue"; +import { onBeforeUpdate, onUpdated, ref } from "vue"; + +type sectionTypes = typeof SchemeNamespace; +const { $gettext } = useGettext(); +const EDIT = "edit"; const props = defineProps<{ editorMax: boolean; + activeTab: string; }>(); +const childRefs = ref>([]); +const schemeComponents = [ + { + component: SchemeNamespace, + id: "namespace", + editorTabName: $gettext("Scheme Namespace"), + }, +]; -const emit = defineEmits(["maximize", "side", "close"]); +const emit = defineEmits(["maximize", "side", "close", "updated"]); -const toggleSize = () => { +onBeforeUpdate(() => { + childRefs.value = []; +}); + +function toggleSize() { if (props.editorMax) { emit("maximize"); } else { emit("side"); } -}; +} + +function getRef(el: object | null, index: number) { + if (el != null) childRefs.value[index] = el as sectionTypes; +} + +async function updateScheme() { + await Promise.all( + childRefs.value.map(async (ref) => { + return ref.save(); + }), + ); + + emit("updated"); +}