diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py index 95ca4f07..d8078f90 100644 --- a/arches_lingo/serializers.py +++ b/arches_lingo/serializers.py @@ -34,6 +34,22 @@ class Meta: fields = "__all__" +class SchemeLabelSerializer(ArchesModelSerializer): + class Meta: + model = ResourceInstance + graph_slug = "scheme" + nodegroups = ["appellative_status"] + fields = "__all__" + + +class SchemeLabelTileSerializer(ArchesTileSerializer): + class Meta: + model = TileModel + graph_slug = "scheme" + root_node = "appellative_status" + fields = "__all__" + + class TextualWorkRdmSystemSerializer(ArchesModelSerializer): class Meta: model = ResourceInstance diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 318dfcb3..d28c04d8 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -59,6 +59,27 @@ export const fetchSchemeCreation = async (schemeId: string) => { return parsed; }; +export const fetchSchemeLabel = async (schemeId: string) => { + const response = await fetch(arches.urls.api_scheme_label(schemeId)); + const parsed = await response.json(); + if (!response.ok) throw new Error(parsed.message || response.statusText); + return parsed; +}; + +export const deleteSchemeLabelTile = async (tileId: string) => { + const response = await fetch(arches.urls.api_scheme_label_tile(tileId), { + method: "DELETE", + headers: { "X-CSRFTOKEN": getToken() }, + }); + + if (!response.ok) { + const parsed = await response.json(); + throw new Error(parsed.message || response.statusText); + } else { + return true; + } +}; + export const updateSchemeCreation = async ( schemeId: string, schemeInstance: SchemeInstance, diff --git a/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue b/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue index 695c0398..2dc64268 100644 --- a/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue +++ b/arches_lingo/src/arches_lingo/components/generic/ControlledListItem.vue @@ -3,12 +3,12 @@ import type { ControlledListItem, DataComponentMode, } from "@/arches_lingo/types"; -import ControlledListItemViewer from "@/arches_lingo/components/generic/ControlledListItemViewer.vue"; +import ControlledListItemViewer from "@/arches_lingo/components/generic/controlled-list-item/ControlledListItemViewer.vue"; import { EDIT, VIEW } from "@/arches_lingo/constants.ts"; -const { mode = EDIT } = defineProps<{ +const { mode = VIEW } = defineProps<{ mode?: DataComponentMode; - value?: ControlledListItem; + value?: ControlledListItem | ControlledListItem[]; }>(); defineEmits(["update"]); diff --git a/arches_lingo/src/arches_lingo/components/generic/ControlledListItemViewer.vue b/arches_lingo/src/arches_lingo/components/generic/ControlledListItemViewer.vue deleted file mode 100644 index 063e6465..00000000 --- a/arches_lingo/src/arches_lingo/components/generic/ControlledListItemViewer.vue +++ /dev/null @@ -1,8 +0,0 @@ - - diff --git a/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue b/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue index e69de29b..ae304908 100644 --- a/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue +++ b/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue @@ -0,0 +1,163 @@ + + + + diff --git a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue index cf2ae836..0f665e19 100644 --- a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue +++ b/arches_lingo/src/arches_lingo/components/generic/NonLocalizedString.vue @@ -1,10 +1,10 @@ - diff --git a/arches_lingo/src/arches_lingo/components/generic/controlled-list-item/ControlledListItemViewer.vue b/arches_lingo/src/arches_lingo/components/generic/controlled-list-item/ControlledListItemViewer.vue new file mode 100644 index 00000000..a863750f --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/controlled-list-item/ControlledListItemViewer.vue @@ -0,0 +1,28 @@ + + diff --git a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringEditor.vue b/arches_lingo/src/arches_lingo/components/generic/non-localized-string/NonLocalizedStringEditor.vue similarity index 100% rename from arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringEditor.vue rename to arches_lingo/src/arches_lingo/components/generic/non-localized-string/NonLocalizedStringEditor.vue diff --git a/arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringViewer.vue b/arches_lingo/src/arches_lingo/components/generic/non-localized-string/NonLocalizedStringViewer.vue similarity index 100% rename from arches_lingo/src/arches_lingo/components/generic/NonLocalizedStringViewer.vue rename to arches_lingo/src/arches_lingo/components/generic/non-localized-string/NonLocalizedStringViewer.vue diff --git a/arches_lingo/src/arches_lingo/components/generic/ResourceInstanceRelationshipsEditor.vue b/arches_lingo/src/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsEditor.vue similarity index 100% rename from arches_lingo/src/arches_lingo/components/generic/ResourceInstanceRelationshipsEditor.vue rename to arches_lingo/src/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsEditor.vue diff --git a/arches_lingo/src/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsViewer.vue b/arches_lingo/src/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsViewer.vue new file mode 100644 index 00000000..f5757350 --- /dev/null +++ b/arches_lingo/src/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsViewer.vue @@ -0,0 +1,31 @@ + + + + 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 11ca725a..b8cf522f 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue @@ -1,4 +1,5 @@ + diff --git a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue index c5b01449..a4733ba5 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue @@ -14,17 +14,19 @@ import type { SchemeNamespaceUpdate, SchemeInstance, } from "@/arches_lingo/types"; -import { VIEW, EDIT } from "@/arches_lingo/constants.ts"; +import { VIEW, EDIT, OPEN_EDITOR, ERROR } from "@/arches_lingo/constants.ts"; +import { useToast } from "primevue/usetoast"; +const toast = useToast(); const { $gettext } = useGettext(); -const schemeNamespace = ref(); +const schemeInstance = ref(); const route = useRoute(); defineProps<{ mode?: DataComponentMode; }>(); -defineEmits(["openEditor"]); +defineEmits([OPEN_EDITOR]); defineExpose({ save, getSectionValue }); @@ -33,19 +35,45 @@ onMounted(async () => { }); async function save() { - await updateSchemeNamespace( - route.params.id as string, - schemeNamespace.value as SchemeInstance, - ); + try { + await updateSchemeNamespace( + route.params.id as string, + schemeInstance.value as SchemeInstance, + ); + } catch (error) { + toast.add({ + severity: ERROR, + summary: $gettext("Error"), + detail: + error instanceof Error + ? error.message + : $gettext( + "Could not update the namespace for the resource", + ), + }); + } } async function getSectionValue() { - const response = await fetchSchemeNamespace(route.params.id as string); - schemeNamespace.value = response; + try { + const response = await fetchSchemeNamespace(route.params.id as string); + schemeInstance.value = response; + } catch (error) { + toast.add({ + severity: ERROR, + summary: $gettext("Error"), + detail: + error instanceof Error + ? error.message + : $gettext( + "Could not fetch the namespace for the resource", + ), + }); + } } function onNamespaceNameUpdate(val: string) { - const namespaceValue = schemeNamespace.value as SchemeNamespaceUpdate; + const namespaceValue = schemeInstance.value as SchemeNamespaceUpdate; if (!namespaceValue?.namespace) { namespaceValue.namespace = { namespace_name: val, @@ -63,10 +91,10 @@ function onNamespaceNameUpdate(val: string) {