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 date datatype #147 #171

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
50e92df
initial commit for #146
aarongundel Dec 11, 2024
152d5a8
updates to label api
aarongundel Dec 11, 2024
c57a9f4
Updates for viewers, extraction to scheme label
aarongundel Dec 13, 2024
ff87baf
adds delete
aarongundel Dec 13, 2024
4d548d9
updates to remove console log, add toast on not found label error
aarongundel Dec 16, 2024
2632583
PR comments
aarongundel Dec 20, 2024
fa7a0f7
pr feedback
aarongundel Dec 20, 2024
37af58a
standardizes passing a tile id to the editor instead of a whole objec…
aarongundel Dec 20, 2024
b56e4aa
pass editor tile down stack along with component id/tab name
aarongundel Dec 20, 2024
db4e8ba
fix missing i18n labels
aarongundel Dec 23, 2024
e2d0fe8
catch errors on api calls
aarongundel Dec 23, 2024
37d381b
do not use viewer directly
aarongundel Dec 23, 2024
b4ee6b7
restructure to try to avoid direct calls to viewer/editor
aarongundel Dec 23, 2024
4462086
fix pathing, various issues
aarongundel Dec 23, 2024
b5929c8
globalize section types
aarongundel Dec 27, 2024
78c91c7
make import flexible
johnatawnclementawn Dec 12, 2024
f459ca5
Stub out reference dt widget rename from controlledlistitem
johnatawnclementawn Dec 18, 2024
1d451fd
Stub out label viewer #147
johnatawnclementawn Dec 19, 2024
9d53b00
Parse refdt options and pass to widget component #147
johnatawnclementawn Dec 30, 2024
b194a4c
Get option labels to populate dropdown & align listitem type with til…
johnatawnclementawn Dec 31, 2024
e093cd3
Update uri ref for select component reactivity #147
johnatawnclementawn Dec 31, 2024
36ab544
Handle multiValue reference datatype in widget editor #147
johnatawnclementawn Jan 2, 2025
010ff8d
Use refdt widget in label editor #147
johnatawnclementawn Jan 2, 2025
57794f0
nits #147
johnatawnclementawn Jan 2, 2025
bd843fa
Add resource instance nodes to scheme label form #147
johnatawnclementawn Jan 2, 2025
0aa0c95
Add person_rdm slug and upgrade model to latest v8 requirements #147
johnatawnclementawn Jan 2, 2025
10b4718
pr feedback & readability improvements #147
johnatawnclementawn Jan 2, 2025
e4ddace
adds date datatype #147
chrabyrd Jan 3, 2025
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
266 changes: 173 additions & 93 deletions arches_lingo/pkg/graphs/resource_models/person_rdm_system.json

Large diffs are not rendered by default.

32 changes: 32 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 All @@ -56,3 +72,19 @@ class Meta:
graph_slug = "concept"
nodegroups = "__all__"
fields = "__all__"


class PersonRdmSystemSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
graph_slug = "person"
nodegroups = "__all__"
fields = "__all__"


class GroupRdmSystemSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
graph_slug = "group"
nodegroups = "__all__"
fields = "__all__"
42 changes: 42 additions & 0 deletions arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,48 @@ export const fetchTextualWorkRdmSystemList = async () => {
return parsed;
};

export const fetchGroupRdmSystemList = async () => {
const response = await fetch(arches.urls.api_group_list);
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

export const fetchPersonRdmSystemList = async () => {
const response = await fetch(arches.urls.api_person_list);
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

export const fetchSchemeCreation = async (schemeId: string) => {
const response = await fetch(arches.urls.api_scheme_creation(schemeId));
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
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,
Expand Down Expand Up @@ -124,3 +159,10 @@ export const fetchSchemes = async () => {
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

export const fetchControlledListOptions = async (controlledListId: string) => {
const response = await fetch(arches.urls.controlled_list(controlledListId));
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
return parsed;
};

This file was deleted.

This file was deleted.

33 changes: 33 additions & 0 deletions arches_lingo/src/arches_lingo/components/generic/DateDatatype.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script setup lang="ts">
import DateDatatypeViewer from "@/arches_lingo/components/generic/date-datatype/DateDatatypeViewer.vue";
import DateDatatypeEditor from "@/arches_lingo/components/generic/date-datatype/DateDatatypeEditor.vue";

import { EDIT, VIEW } from "@/arches_lingo/constants.ts";

import type { DataComponentMode } from "@/arches_lingo/types.ts";

const { mode = VIEW } = defineProps<{
mode?: DataComponentMode;
value?: string;
}>();

const emits = defineEmits(["update"]);

const onUpdate = (val: string) => {
emits("update", val);
};
</script>

<template>
<div>
<div v-if="mode === VIEW">
<DateDatatypeViewer :value="value" />
</div>
<div v-if="mode === EDIT">
<DateDatatypeEditor
:value="value"
@update="onUpdate"
/>
</div>
</div>
</template>
201 changes: 201 additions & 0 deletions arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<script setup lang="ts">
import { defineProps, inject, onMounted, ref, type Ref } from "vue";
import {
fetchControlledListOptions,
fetchGroupRdmSystemList,
fetchPersonRdmSystemList,
fetchTextualWorkRdmSystemList,
} from "@/arches_lingo/api.ts";

import DateDatatype from "@/arches_lingo/components/generic/DateDatatype.vue";
import NonLocalizedString from "@/arches_lingo/components/generic/NonLocalizedString.vue";
import ReferenceDatatype from "@/arches_lingo/components/generic/ReferenceDatatype.vue";
import ResourceInstanceRelationships from "@/arches_lingo/components/generic/ResourceInstanceRelationships.vue";

import {
selectedLanguageKey,
EDIT,
LANGUAGE_CONTROLLED_LIST,
LABEL_CONTROLLED_LIST,
STATUSES_CONTROLLED_LIST,
METATYPES_CONTROLLED_LIST,
EVENT_TYPES_CONTROLLED_LIST,
} from "@/arches_lingo/constants.ts";

import type {
AppellativeStatus,
ControlledListItem,
ControlledListItemResult,
ResourceInstanceReference,
ResourceInstanceResult,
} from "@/arches_lingo/types.ts";
import type { Language } from "@/arches_vue_utils/types.ts";

const selectedLanguage = inject(selectedLanguageKey) as Ref<Language>;
const props = withDefaults(
defineProps<{
value?: AppellativeStatus;
}>(),
{
value: () => ({}) as AppellativeStatus,
},
);
const value = ref(props.value);

const languageOptions = ref<ControlledListItem[]>([]);
const typeOptions = ref<ControlledListItem[]>([]);
const statusOptions = ref<ControlledListItem[]>([]);
const metatypeOptions = ref<ControlledListItem[]>([]);
const eventTypeOptions = ref<ControlledListItem[]>([]);
const groupAndPersonOptions = ref<ResourceInstanceReference[]>();
const textualWorkOptions = ref<ResourceInstanceReference[]>();

function onUpdate(newValue: string) {
console.log(newValue);
}

async function getControlledListOptions(
listId: string,
): Promise<ControlledListItem[]> {
const parsed = await fetchControlledListOptions(listId);
const options = parsed.items.map(
(item: ControlledListItemResult): ControlledListItem => ({
list_id: item.list_id,
uri: item.uri,
labels: item.values,
}),
);
return options;
}

async function getResourceInstanceOptions(
fetchOptions: () => Promise<ResourceInstanceResult[]>,
): Promise<ResourceInstanceReference[]> {
const options = await fetchOptions();
const results = options.map((option: ResourceInstanceResult) => {
const result: ResourceInstanceReference = {
display_value: option.descriptors[selectedLanguage.value.code].name,
resourceId: option.resourceinstanceid,
ontologyProperty: "ac41d9be-79db-4256-b368-2f4559cfbe55",
inverseOntologyProperty: "ac41d9be-79db-4256-b368-2f4559cfbe55",
};
return result;
});
return results;
}

onMounted(async () => {
const [languageOpts, typeOpts, statusOpts, metatypeOpts, eventTypeOpts] =
await Promise.all([
getControlledListOptions(LANGUAGE_CONTROLLED_LIST),
getControlledListOptions(LABEL_CONTROLLED_LIST),
getControlledListOptions(STATUSES_CONTROLLED_LIST),
getControlledListOptions(METATYPES_CONTROLLED_LIST),
getControlledListOptions(EVENT_TYPES_CONTROLLED_LIST),
]);

languageOptions.value = languageOpts;
typeOptions.value = typeOpts;
statusOptions.value = statusOpts;
metatypeOptions.value = metatypeOpts;
eventTypeOptions.value = eventTypeOpts;
groupAndPersonOptions.value = await getResourceInstanceOptions(
fetchGroupRdmSystemList,
);
groupAndPersonOptions.value = [
...(groupAndPersonOptions.value || []),
...(await getResourceInstanceOptions(fetchPersonRdmSystemList)),
];
textualWorkOptions.value = await getResourceInstanceOptions(
fetchTextualWorkRdmSystemList,
);
});
</script>

<template>
<!-- Label: string -->
<label for="">{{ $gettext("Label") }}</label>
<NonLocalizedString
:value="value?.appellative_status_ascribed_name_content ?? ''"
:mode="EDIT"
@update="onUpdate"
/>
<!-- Label Language: reference datatype -->
<label for="">{{ $gettext("Label Language") }}</label>
<ReferenceDatatype
:value="value?.appellative_status_ascribed_name_language"
:mode="EDIT"
:multi-value="false"
:options="languageOptions"
@update="onUpdate"
/>
<!-- Label Type: reference datatype -->
<label for="">{{ $gettext("Label Type") }}</label>
<ReferenceDatatype
:value="value?.appellative_status_ascribed_relation"
:mode="EDIT"
:multi-value="false"
:options="typeOptions"
@update="onUpdate"
/>
<!-- Label Status: reference datatype -->
<label for="">{{ $gettext("Label Status") }}</label>
<ReferenceDatatype
:value="value?.appellative_status_status"
:mode="EDIT"
:multi-value="false"
:options="statusOptions"
@update="onUpdate"
/>
<!-- Label Status Metatype: reference datatype -->
<label for="">{{ $gettext("Label Metatype") }}</label>
<ReferenceDatatype
:value="value?.appellative_status_status_metatype"
:mode="EDIT"
:multi-value="false"
:options="metatypeOptions"
@update="onUpdate"
/>

<!-- Label Temporal Validity Start: date -->
<label for="">{{ $gettext("Label Temporal Validity Start") }}</label>
<DateDatatype
:value="value?.appellative_status_timespan_begin_of_the_begin"
:mode="EDIT"
@update="onUpdate"
/>

<!-- Label Temporal Validity End: date -->
<label for="">{{ $gettext("Label Temporal Validity End") }}</label>
<DateDatatype
:value="value?.appellative_status_timespan_end_of_the_end"
:mode="EDIT"
@update="onUpdate"
/>

<!-- Contributor: resource instance -->
<label for="">{{ $gettext("Contributor") }}</label>
<ResourceInstanceRelationships
:value="value?.appellative_status_data_assignment_actor"
:mode="EDIT"
:options="groupAndPersonOptions"
@update="onUpdate"
/>
<!-- Sources: resource instance -->
<label for="">{{ $gettext("Sources") }}</label>
<ResourceInstanceRelationships
:value="value?.appellative_status_data_assignment_object_used"
:mode="EDIT"
:options="textualWorkOptions"
@update="onUpdate"
/>
<!-- Warrant Type: reference datatype -->
<label for="">{{ $gettext("Warrant Type") }}</label>
<ReferenceDatatype
:value="value?.appellative_status_data_assignment_type"
:mode="EDIT"
:multi-value="false"
:options="eventTypeOptions"
@update="onUpdate"
/>
</template>
Loading
Loading