Skip to content

Commit

Permalink
Merge branch 'adg/146-scheme-names' into adg/154-single-tile-forms
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongundel committed Dec 24, 2024
2 parents 71d1c40 + 4462086 commit 03a72b3
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
</script>
Expand Down
16 changes: 8 additions & 8 deletions arches_lingo/src/arches_lingo/components/generic/LabelViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Button from "primevue/button";
import ConfirmDialog from "primevue/confirmdialog";
import { useConfirm } from "primevue/useconfirm";
import ControlledListItemViewer from "@/arches_lingo/components/generic/ControlledListItemViewer.vue";
import ControlledListItem from "@/arches_lingo/components/generic/ControlledListItem.vue";
import ResourceInstanceRelationships from "@/arches_lingo/components/generic/ResourceInstanceRelationships.vue";
import type { AppellativeStatus } from "@/arches_lingo/types";
Expand Down Expand Up @@ -57,7 +57,7 @@ function confirmDelete(tileId: string) {
/>
<Column
field="appellative_status_ascribed_name_content"
header="Label"
:header="$gettext('Label')"
sortable
>
<template #body="slotProps">
Expand All @@ -69,32 +69,32 @@ function confirmDelete(tileId: string) {
</Column>
<Column
field="appellative_status_ascribed_relation"
header="Label Type"
:header="$gettext('Label Type')"
sortable
>
<template #body="slotProps">
<ControlledListItemViewer
<ControlledListItem
:value="
(slotProps.data as AppellativeStatus)
.appellative_status_ascribed_relation
"
>
</ControlledListItemViewer>
</ControlledListItem>
</template>
</Column>
<Column
field="appellative_status_ascribed_name_language"
header="Label Language"
:header="$gettext('Label Language')"
sortable
>
<template #body="slotProps">
<ControlledListItemViewer
<ControlledListItem
:value="
(slotProps.data as AppellativeStatus)
.appellative_status_ascribed_name_language
"
>
</ControlledListItemViewer>
</ControlledListItem>
</template>
</Column>
<Column>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import NonLocalizedStringViewer from "@/arches_lingo/components/generic/NonLocalizedStringViewer.vue";
import NonLocalizedStringEditor from "@/arches_lingo/components/generic/NonLocalizedStringEditor.vue";
import NonLocalizedStringViewer from "@/arches_lingo/components/generic/non-localized-string/NonLocalizedStringViewer.vue";
import NonLocalizedStringEditor from "@/arches_lingo/components/generic/non-localized-string/NonLocalizedStringEditor.vue";
import type { DataComponentMode } from "@/arches_lingo/types.ts";
import { EDIT, VIEW } from "@/arches_lingo/constants.ts";
const { mode = EDIT } = defineProps<{
const { mode = VIEW } = defineProps<{
mode?: DataComponentMode;
value?: string;
}>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import ResourceInstanceRelationshipsViewer from "@/arches_lingo/components/generic/ResourceInstanceRelationshipsViewer.vue";
import ResourceInstanceRelationshipsEditor from "@/arches_lingo/components/generic/ResourceInstanceRelationshipsEditor.vue";
import ResourceInstanceRelationshipsViewer from "@/arches_lingo/components/generic//resource-instance-relationships/ResourceInstanceRelationshipsViewer.vue";
import ResourceInstanceRelationshipsEditor from "@/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsEditor.vue";
import { EDIT, VIEW } from "@/arches_lingo/constants.ts";
import type {
DataComponentMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useGettext } from "vue3-gettext";
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { VIEW, EDIT, OPEN_EDITOR } from "@/arches_lingo/constants.ts";
import { VIEW, EDIT, OPEN_EDITOR, ERROR } from "@/arches_lingo/constants.ts";
import type {
DataComponentMode,
SchemeInstance,
Expand Down Expand Up @@ -38,14 +38,38 @@ onMounted(() => {
});
async function getSectionValue() {
const result = await fetchSchemeLabel(route.params.id as string);
schemeInstance.value = {
appellative_status: result.appellative_status,
};
try {
const result = await fetchSchemeLabel(route.params.id as string);
schemeInstance.value = {
appellative_status: result.appellative_status,
};
} catch (error) {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail:
error instanceof Error
? error.message
: $gettext("Could not fetch the labels for the resource"),
});
}
}
async function deleteSectionValue(tileId: string) {
const result = await deleteSchemeLabelTile(tileId);
let result = false;
try {
result = await deleteSchemeLabelTile(tileId);
} catch (error) {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail:
error instanceof Error
? error.message
: $gettext("Could not delete selected label"),
});
}
if (result) {
getSectionValue();
}
Expand All @@ -59,8 +83,9 @@ function editSectionValue(tileId: string) {
emits(OPEN_EDITOR, appellativeStatus.tileid);
} else {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail: $gettext("Could not find the selected label to edit."),
detail: $gettext("Could not find the selected label to edit"),
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import {
fetchSchemeNamespace,
updateSchemeNamespace,
} from "@/arches_lingo/api.ts";
import { VIEW, EDIT, OPEN_EDITOR } from "@/arches_lingo/constants.ts";
import { VIEW, EDIT, OPEN_EDITOR, ERROR } from "@/arches_lingo/constants.ts";
import { useToast } from "primevue/usetoast";
import type {
DataComponentMode,
SchemeNamespaceUpdate,
SchemeInstance,
} from "@/arches_lingo/types";
const toast = useToast();
const { $gettext } = useGettext();
const schemeNamespace = ref<SchemeInstance>();
const schemeInstance = ref<SchemeInstance>();
const route = useRoute();
defineProps<{
Expand All @@ -35,18 +37,30 @@ onMounted(async () => {
async function save() {
await updateSchemeNamespace(
route.params.id as string,
schemeNamespace.value as SchemeInstance,
schemeInstance.value as SchemeInstance,
);
emit("updated");
}
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,
Expand All @@ -67,7 +81,7 @@ function onNamespaceNameUpdate(val: string) {
@open-editor="emit(OPEN_EDITOR)"
>
<NonLocalizedString
:value="schemeNamespace?.namespace?.namespace_name"
:value="schemeInstance?.namespace?.namespace_name"
:mode="VIEW"
/>
<!-- Discussion of namespace_type indicated it should not be displayed or edited manually,
Expand All @@ -76,7 +90,7 @@ function onNamespaceNameUpdate(val: string) {
</div>
<div v-if="mode === EDIT">
<NonLocalizedString
:value="schemeNamespace?.namespace?.namespace_name ?? ''"
:value="schemeInstance?.namespace?.namespace_name ?? ''"
:mode="EDIT"
@update="onNamespaceNameUpdate"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import {
EDIT,
OPEN_EDITOR,
UPDATED,
ERROR,
} from "@/arches_lingo/constants.ts";
import type { Language } from "@/arches_vue_utils/types.ts";
import { useToast } from "primevue/usetoast";
const toast = useToast();
const schemeInstance = ref<SchemeInstance>();
const textualWorkOptions = ref<ResourceInstanceReference[]>();
const route = useRoute();
Expand Down Expand Up @@ -58,34 +61,68 @@ async function getOptions(): Promise<ResourceInstanceReference[]> {
}
async function save() {
await updateSchemeCreation(
route.params.id as string,
schemeInstance.value as SchemeInstance,
);
try {
await updateSchemeCreation(
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 save the scheme standard"),
});
}
getSectionValue();
}
async function getSectionValue() {
const options = !textualWorkOptions.value
? await getOptions()
: textualWorkOptions.value;
let options = null;
try {
options = !textualWorkOptions.value
? await getOptions()
: textualWorkOptions.value;
} catch (error) {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail:
error instanceof Error
? error.message
: $gettext("Could not fetch options for the standard"),
});
}
const scheme = await fetchSchemeCreation(route.params.id as string);
try {
const scheme = await fetchSchemeCreation(route.params.id as string);
const hydratedResults = options.map((option) => {
const savedSource = scheme.creation?.creation_sources.find(
(source: ResourceInstanceReference) =>
source.resourceId === option.resourceId,
);
if (savedSource) {
return savedSource;
} else {
return option;
}
});
textualWorkOptions.value = hydratedResults;
schemeInstance.value = scheme;
emits(UPDATED);
const hydratedResults = options?.map((option) => {
const savedSource = scheme.creation?.creation_sources.find(
(source: ResourceInstanceReference) =>
source.resourceId === option.resourceId,
);
if (savedSource) {
return savedSource;
} else {
return option;
}
});
textualWorkOptions.value = hydratedResults;
schemeInstance.value = scheme;
} catch (error) {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail:
error instanceof Error
? error.message
: $gettext("Could not fetch the scheme standard"),
});
}
}
function onCreationUpdate(val: string[]) {
Expand Down

0 comments on commit 03a72b3

Please sign in to comment.