From 50e92df658dbc383f35ebf2abf9f83e28ccbddee Mon Sep 17 00:00:00 2001 From: Aaron Gundel Date: Tue, 10 Dec 2024 23:25:00 -0700 Subject: [PATCH 1/3] initial commit for #146 --- arches_lingo/serializers.py | 8 ++ .../components/scheme/editor/SchemeEditor.vue | 12 ++- .../components/scheme/report/SchemeLabel.vue | 75 +++++++++++++------ .../src/arches_lingo/pages/SchemePage.vue | 3 + arches_lingo/src/arches_lingo/routes.ts | 2 +- arches_lingo/urls.py | 5 ++ 6 files changed, 78 insertions(+), 27 deletions(-) diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py index 95ca4f07..984c7afc 100644 --- a/arches_lingo/serializers.py +++ b/arches_lingo/serializers.py @@ -34,6 +34,14 @@ class Meta: fields = "__all__" +class SchemeLabelSerializer(ArchesModelSerializer): + class Meta: + model = ResourceInstance + graph_slug = "scheme" + nodegroups = ["label"] + fields = "__all__" + + class TextualWorkRdmSystemSerializer(ArchesModelSerializer): class Meta: model = ResourceInstance 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..9aa2dc94 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/pages/SchemePage.vue b/arches_lingo/src/arches_lingo/pages/SchemePage.vue index 9cf40b83..435642f7 100644 --- a/arches_lingo/src/arches_lingo/pages/SchemePage.vue +++ b/arches_lingo/src/arches_lingo/pages/SchemePage.vue @@ -2,6 +2,7 @@ import { ref } from "vue"; import Splitter from "primevue/splitter"; import SplitterPanel from "primevue/splitterpanel"; +import SchemeLabel from "@/arches_lingo/components/scheme/report/SchemeLabel.vue"; import SchemeLicense from "@/arches_lingo/components/scheme/report/SchemeLicense.vue"; import SchemeNote from "@/arches_lingo/components/scheme/report/SchemeNote.vue"; import SchemeNamespace from "@/arches_lingo/components/scheme/report/SchemeNamespace.vue"; @@ -13,6 +14,7 @@ const editorVisible = ref(false); const sectionVisible = ref(true); const editorTab = ref(); type sectionTypes = + | typeof SchemeLabel | typeof SchemeNamespace | typeof SchemeLicense | typeof SchemeStandard @@ -47,6 +49,7 @@ const onUpdated = () => { }; const components = [ + { component: SchemeLabel, id: "label", props: {} }, { component: SchemeNote, id: "note", props: {} }, { component: SchemeAuthority, id: "authority", props: {} }, { component: SchemeStandard, id: "standard", props: {} }, diff --git a/arches_lingo/src/arches_lingo/routes.ts b/arches_lingo/src/arches_lingo/routes.ts index a8d0cdab..11fc9608 100644 --- a/arches_lingo/src/arches_lingo/routes.ts +++ b/arches_lingo/src/arches_lingo/routes.ts @@ -55,7 +55,7 @@ export const routes = [ component: () => import("@/arches_lingo/pages/SchemePage.vue"), meta: { shouldShowNavigation: true, - shouldShowHierarchy: true, + shouldShowHierarchy: false, requiresAuthentication: true, }, }, diff --git a/arches_lingo/urls.py b/arches_lingo/urls.py index 2f7f96d4..484f0b1e 100644 --- a/arches_lingo/urls.py +++ b/arches_lingo/urls.py @@ -53,6 +53,11 @@ SchemeCreationView.as_view(), name="api-scheme-creation", ), + path( + "api/scheme//label", + SchemeCreationView.as_view(), + name="api-scheme-creation", + ), path( "api/textual-work", TextualWorkRdmSystemSerializerView.as_view(), From 152d5a83c656045926bc1f20e8be6419ad9a5d94 Mon Sep 17 00:00:00 2001 From: Aaron Gundel Date: Wed, 11 Dec 2024 14:18:32 -0700 Subject: [PATCH 2/3] updates to label api --- arches_lingo/serializers.py | 2 +- arches_lingo/src/arches_lingo/api.ts | 7 ++ .../components/scheme/report/SchemeLabel.vue | 78 +++++++++---------- .../scheme/report/SchemeStandard.vue | 10 ++- arches_lingo/src/arches_lingo/constants.ts | 1 + arches_lingo/src/arches_lingo/types.ts | 7 ++ arches_lingo/templates/arches_urls.htm | 1 + arches_lingo/urls.py | 5 +- arches_lingo/views/api/pythonic_models.py | 6 ++ 9 files changed, 69 insertions(+), 48 deletions(-) diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py index 984c7afc..2e4d585b 100644 --- a/arches_lingo/serializers.py +++ b/arches_lingo/serializers.py @@ -38,7 +38,7 @@ class SchemeLabelSerializer(ArchesModelSerializer): class Meta: model = ResourceInstance graph_slug = "scheme" - nodegroups = ["label"] + nodegroups = ["appellative_status"] fields = "__all__" diff --git a/arches_lingo/src/arches_lingo/api.ts b/arches_lingo/src/arches_lingo/api.ts index 318dfcb3..5360557a 100644 --- a/arches_lingo/src/arches_lingo/api.ts +++ b/arches_lingo/src/arches_lingo/api.ts @@ -59,6 +59,13 @@ 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 updateSchemeCreation = async ( schemeId: string, schemeInstance: SchemeInstance, diff --git a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue index 1e5840cd..cebbd7b9 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue @@ -1,34 +1,22 @@ diff --git a/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue b/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue index e69de29b..aa4e6740 100644 --- a/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue +++ b/arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue @@ -0,0 +1,134 @@ + + + diff --git a/arches_lingo/src/arches_lingo/components/generic/ResourceInstanceRelationshipsViewer.vue b/arches_lingo/src/arches_lingo/components/generic/ResourceInstanceRelationshipsViewer.vue index cc9cdd02..94d9737a 100644 --- a/arches_lingo/src/arches_lingo/components/generic/ResourceInstanceRelationshipsViewer.vue +++ b/arches_lingo/src/arches_lingo/components/generic/ResourceInstanceRelationshipsViewer.vue @@ -1,15 +1,25 @@ 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 9aa2dc94..c2208d31 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/editor/SchemeEditor.vue @@ -18,6 +18,7 @@ const EDIT = "edit"; const props = defineProps<{ editorMax: boolean; activeTab: string; + activeArgs: Array; }>(); const childRefs = ref>([]); const schemeComponents = [ @@ -117,7 +118,7 @@ async function updateScheme() { diff --git a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue index cebbd7b9..803e02f3 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue @@ -3,9 +3,6 @@ import { useGettext } from "vue3-gettext"; import { onMounted, ref } from "vue"; import { useRoute } from "vue-router"; -import DataTable from "primevue/datatable"; -import Column from "primevue/column"; - import { VIEW, EDIT, OPEN_EDITOR } from "@/arches_lingo/constants.ts"; import type { DataComponentMode, @@ -13,14 +10,22 @@ import type { } from "@/arches_lingo/types.ts"; import { fetchSchemeLabel } from "@/arches_lingo/api.ts"; import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue"; +import LabelViewer from "@/arches_lingo/components/generic/LabelViewer.vue"; const schemeInstance = ref(); const { $gettext } = useGettext(); const route = useRoute(); -defineProps<{ - mode?: DataComponentMode; -}>(); +const props = withDefaults( + defineProps<{ + mode?: DataComponentMode; + args?: Array; + }>(), + { + mode: VIEW, + args: () => [], + }, +); defineExpose({ save, getSectionValue }); @@ -30,13 +35,17 @@ onMounted(async () => { getSectionValue(); }); +async function deleteLabel() { + // deletes label + console.log("deleted"); +} + async function getSectionValue() { + console.log(props); const result = await fetchSchemeLabel(route.params.id as string); schemeInstance.value = { appellative_status: result.appellative_status, }; - - //schemeAsLabelTable(scheme) } async function save() { @@ -54,24 +63,21 @@ async function save() { :title-text="$gettext('Scheme Labels')" @open-editor="emits(OPEN_EDITOR)" > - - - - - + @edit-label="(...args) => emits(OPEN_EDITOR, ...args)" + @delete-label="deleteLabel" + >
abc
+ 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..f7e80b08 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue @@ -14,7 +14,7 @@ import type { SchemeNamespaceUpdate, SchemeInstance, } from "@/arches_lingo/types"; -import { VIEW, EDIT } from "@/arches_lingo/constants.ts"; +import { VIEW, EDIT, OPEN_EDITOR } from "@/arches_lingo/constants.ts"; const { $gettext } = useGettext(); const schemeNamespace = ref(); @@ -24,7 +24,7 @@ defineProps<{ mode?: DataComponentMode; }>(); -defineEmits(["openEditor"]); +defineEmits([OPEN_EDITOR]); defineExpose({ save, getSectionValue }); @@ -63,7 +63,7 @@ function onNamespaceNameUpdate(val: string) {
import { useGettext } from "vue3-gettext"; import Button from "primevue/button"; +import { OPEN_EDITOR } from "@/arches_lingo/constants.ts"; -defineEmits(["openEditor"]); +defineEmits([OPEN_EDITOR]); const { $gettext } = useGettext(); const props = defineProps<{ @@ -17,7 +18,7 @@ const props = defineProps<{
diff --git a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeStandard.vue b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeStandard.vue index 42f0acea..3e617b4e 100644 --- a/arches_lingo/src/arches_lingo/components/scheme/report/SchemeStandard.vue +++ b/arches_lingo/src/arches_lingo/components/scheme/report/SchemeStandard.vue @@ -29,7 +29,7 @@ const route = useRoute(); const selectedLanguage = inject(selectedLanguageKey) as Ref; const { $gettext } = useGettext(); -defineProps<{ +const { mode = VIEW } = defineProps<{ mode?: DataComponentMode; }>(); diff --git a/arches_lingo/src/arches_lingo/pages/SchemePage.vue b/arches_lingo/src/arches_lingo/pages/SchemePage.vue index 435642f7..8bdc3122 100644 --- a/arches_lingo/src/arches_lingo/pages/SchemePage.vue +++ b/arches_lingo/src/arches_lingo/pages/SchemePage.vue @@ -13,6 +13,8 @@ import SchemeEditor from "@/arches_lingo/components/scheme/editor/SchemeEditor.v const editorVisible = ref(false); const sectionVisible = ref(true); const editorTab = ref(); +const activeEditorArgs = ref>([]); + type sectionTypes = | typeof SchemeLabel | typeof SchemeNamespace @@ -37,10 +39,11 @@ const onClose = () => { sectionVisible.value = true; }; -const onOpenEditor = (tab: string) => { +const onOpenEditor = (tab: string, ...args: object[]) => { editorTab.value = tab; editorVisible.value = true; sectionVisible.value = true; + activeEditorArgs.value = args; }; const onUpdated = () => { childRefs.value.forEach((ref) => { @@ -76,7 +79,10 @@ const getRef = (el: object | null, index: number) => { :is="component.component" :ref="(el) => getRef(el, index)" v-bind="component.props" - @open-editor="onOpenEditor(component.id)" + @open-editor=" + (...args: object[]) => + onOpenEditor(component.id, ...args) + " /> @@ -88,6 +94,7 @@ const getRef = (el: object | null, index: number) => { v-if="editorTab" :editor-max="sectionVisible" :active-tab="editorTab" + :active-args="activeEditorArgs" @maximize="onMaximize" @side="onSide" @close="onClose" diff --git a/arches_lingo/src/arches_lingo/types.ts b/arches_lingo/src/arches_lingo/types.ts index 9cc468ff..088f5a08 100644 --- a/arches_lingo/src/arches_lingo/types.ts +++ b/arches_lingo/src/arches_lingo/types.ts @@ -72,6 +72,17 @@ export interface SchemeNamespaceUpdate { }; } +export interface AppellativeStatus { + tileid: string; + appellative_status_ascribed_name_content: string; + appellative_status_ascribed_name_language?: ControlledListItem[]; + appellative_status_ascribed_relation?: ControlledListItem[]; + appellative_status_status_metatype?: ControlledListItem[]; + appellative_status_status?: ControlledListItem[]; + appellative_status_data_assignment_object_used: ResourceInstanceReference[]; + appellative_status_data_assignment_actor: ResourceInstanceReference[]; +} + export interface SchemeInstance { namespace?: { namespace_name: string; @@ -80,13 +91,7 @@ export interface SchemeInstance { creation?: { creation_sources: ResourceInstanceReference[]; }; - appellative_status?: { - appellative_status_ascribed_name_content: string; - appellative_status_ascribed_name_language?: ControlledListItemValue[]; - appellative_status_ascribed_relation?: ControlledListItemValue[]; - appellative_status_status_metatype?: ControlledListItemValue[]; - appellative_status_status?: ControlledListItemValue[]; - }[]; + appellative_status?: AppellativeStatus[]; } export interface SchemeResource {