Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds scheme names/labels section #153

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions arches_lingo/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
}
};

export const updateSchemeCreation = async (
schemeId: string,
schemeInstance: SchemeInstance,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<script setup lang="ts">
import type { ControlledListItem } from "@/arches_lingo/types";

const props = defineProps<{ value?: ControlledListItem }>();
withDefaults(
defineProps<{
value?: ControlledListItem[] | ControlledListItem;
}>(),
{
value: () => [],
},
);
</script>
<template>
<p>{{ props.value?.labels }}</p>
<span v-if="value instanceof Array">
<span
v-for="val in value"
:key="val.list_id"
>
<span>{{ val.labels[0].value }}</span>
</span>
</span>
<span v-else-if="value">
<span>{{ (value as ControlledListItem).labels[0].value }}</span>
</span>
<span v-else>
<span>{{ $gettext("None") }}</span>
</span>
</template>
160 changes: 160 additions & 0 deletions arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<script setup lang="ts">
import { ref } from "vue";
import DataTable from "primevue/datatable";
import Column from "primevue/column";
import Button from "primevue/button";
import ConfirmDialog from "primevue/confirmdialog";
import { useConfirm } from "primevue/useconfirm";

import type { AppellativeStatus } from "@/arches_lingo/types";
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
import ControlledListItemViewer from "@/arches_lingo/components/generic/ControlledListItemViewer.vue";
import ResourceInstanceRelationshipsViewer from "@/arches_lingo/components/generic/ResourceInstanceRelationshipsViewer.vue";

const expandedRows = ref([]);
const confirm = useConfirm();

const props = defineProps<{
value?: AppellativeStatus[];
}>();

const emits = defineEmits(["editLabel", "deleteLabel"]);

function confirmDelete(tileId: string) {
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
confirm.require({
header: "Confirmation",
message: "Are you sure you want to delete this label?",
accept: () => {
emits("deleteLabel", tileId);
},
rejectProps: {
label: "Cancel",
severity: "secondary",
outlined: true,
},
acceptProps: {
label: "Delete",
severity: "danger",
},
});
}
</script>
<template>
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
<ConfirmDialog
:pt="{ root: { style: { fontFamily: 'sans-serif' } } }"
></ConfirmDialog>
<DataTable
v-model:expanded-rows="expandedRows"
:value="props.value"
onrowexp
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
table-style="min-width: 50rem"
>
<Column
expander
style="width: 3rem"
/>
<Column
field="appellative_status_ascribed_name_content"
header="Label"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n for headers 😄

sortable
>
<template #body="slotProps">
{{
(slotProps.data as AppellativeStatus)
.appellative_status_ascribed_name_content
}}
</template>
</Column>
<Column
field="appellative_status_ascribed_relation"
header="Label Type"
sortable
>
<template #body="slotProps">
<ControlledListItemViewer
:value="
(slotProps.data as AppellativeStatus)
.appellative_status_ascribed_relation
"
>
</ControlledListItemViewer>
</template>
</Column>
<Column
field="appellative_status_ascribed_name_language"
header="Label Language"
sortable
>
<template #body="slotProps">
<ControlledListItemViewer
:value="
(slotProps.data as AppellativeStatus)
.appellative_status_ascribed_name_language
"
>
</ControlledListItemViewer>
</template>
</Column>
<Column>
<template #body="slotProps">
<div class="controls">
<Button
icon="pi pi-file-edit"
aria-label="edit"
@click="
() =>
emits(
'editLabel',
(slotProps.data as AppellativeStatus)
.tileid,
)
"
/>
<Button
icon="pi pi-trash"
aria-label="delete"
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
severity="danger"
outlined
@click="
() =>
confirmDelete(
(slotProps.data as AppellativeStatus)
.tileid,
)
"
/>
</div>
</template>
</Column>
<template #expansion="slotProps">
<div class="drawer">
<div>
Bibliographic Sources:
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
<ResourceInstanceRelationshipsViewer
:value="
(slotProps.data as AppellativeStatus)
.appellative_status_data_assignment_object_used
"
></ResourceInstanceRelationshipsViewer>
</div>
<div>
Contributors:
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
<ResourceInstanceRelationshipsViewer
:value="
(slotProps.data as AppellativeStatus)
.appellative_status_data_assignment_actor
"
></ResourceInstanceRelationshipsViewer>
</div>
</div>
</template>
</DataTable>
</template>
<style scoped>
.controls {
display: flex;
flex-direction: row;
}
.controls button {
margin: 0 0.5rem;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import type { ResourceInstanceReference } from "@/arches_lingo/types";
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
import arches from "arches";

const props = defineProps<{ value?: ResourceInstanceReference[] }>();
const { $gettext } = useGettext();

withDefaults(defineProps<{ value?: ResourceInstanceReference[] }>(), {
value: (): ResourceInstanceReference[] => [],
});
</script>
<template>
<div v-if="props.value">
<div
v-for="val in props.value"
<span v-if="value">
<span
v-for="val in value"
:key="val.resourceXresourceId"
class="resource-instance-relationship-view"
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
>
{{ val.display_value }}
</div>
</div>
<a :href="`${arches.urls.resource_editor}${val.resourceId}`">
{{ val.display_value }}
</a>
</span>
</span>
<span v-else>{{ $gettext("None") }}</span>
</template>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { onBeforeUpdate, onUpdated, ref } from "vue";
import { useGettext } from "vue3-gettext";
import Button from "primevue/button";

Expand All @@ -7,19 +8,25 @@ 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";
import SchemeStandard from "../report/SchemeStandard.vue";
import SchemeNamespace from "@/arches_lingo/components/scheme/report/SchemeNamespace.vue";
import SchemeStandard from "@/arches_lingo/components/scheme/report/SchemeStandard.vue";
import SchemeLabel from "@/arches_lingo/components/scheme/report/SchemeLabel.vue";
type sectionTypes = typeof SchemeNamespace;

const { $gettext } = useGettext();
const EDIT = "edit";
const props = defineProps<{
editorMax: boolean;
activeTab: string;
activeArgs: Array<object>;
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
}>();
const childRefs = ref<Array<sectionTypes>>([]);
const schemeComponents = [
{
component: SchemeLabel,
id: "label",
editorTabName: $gettext("Scheme Label"),
},
{
component: SchemeNamespace,
id: "namespace",
Expand Down Expand Up @@ -111,7 +118,7 @@ async function updateScheme() {
<TabPanel :value="component.id">
<component
:is="component.component"
v-bind="{ mode: EDIT }"
v-bind="{ mode: EDIT, args: props.activeArgs }"
:ref="(el) => getRef(el, index)"
v-on="{ updated: onUpdated }"
/>
Expand Down
Loading
Loading