Skip to content

Commit

Permalink
updates with components for individual sections
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongundel committed Nov 21, 2024
1 parent a9ea8ca commit 874b141
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 73 deletions.
15 changes: 0 additions & 15 deletions arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ export const fetchUser = async () => {
return parsed;
};

export const fetchSchemeResource = async (id: string | string[]) => {
const resourceRequest = await fetch(
`${arches.urls.api_resources(id)}?format=json&v=beta&hide_empty_nodes=false`,
);
try {
const resource = await resourceRequest.json();
if (resourceRequest.ok) {
return resource;
}
throw new Error(resource.message);
} catch (error) {
throw new Error((error as Error).message || resourceRequest.statusText);
}
};

export const fetchSearchResults = async (
searchTerm: string,
items: number,
Expand Down
26 changes: 0 additions & 26 deletions arches_lingo/src/arches_lingo/components/detail/SchemeSection.vue

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
const { $gettext } = useGettext();
</script>

<template>
<SchemeReportSection :title-text="$gettext('Trusted Authorities')">
abc
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
const { $gettext } = useGettext();
</script>

<template>
<SchemeReportSection :title-text="$gettext('License')">
abc
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
const { $gettext } = useGettext();
</script>

<template>
<SchemeReportSection :title-text="$gettext('Scheme Notes')">
abc
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import Button from "primevue/button";
const { $gettext } = useGettext();
const props = defineProps<{
titleText: string;
}>();
const buttonText = $gettext(`Add ${props.titleText}`);
</script>

<template>
<div class="section">
<div class="header">
<h2>{{ props.titleText }}</h2>
<div>
<Button
:label="buttonText"
@click="$emit('openEditor')"
></Button>
</div>
</div>
<div class="content">
<slot></slot>
</div>
</div>
</template>

<style scoped>
.section {
margin: 0 1rem;
}
.section .header {
display: flex;
align-items: center;
border-bottom: 1px solid #ddd;
}
.section .header h2 {
flex: 1;
}
.content {
margin: 1rem 0;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
const { $gettext } = useGettext();
</script>

<template>
<SchemeReportSection :title-text="$gettext('Scheme Standards Followed')">
abc
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
const { $gettext } = useGettext();
</script>

<template>
<SchemeReportSection :title-text="$gettext('Scheme URI')">
abc
</SchemeReportSection>
</template>
42 changes: 17 additions & 25 deletions arches_lingo/src/arches_lingo/pages/SchemeReport.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { fetchSchemeResource } from "@/arches_lingo/api.ts";
import type { SchemeResource } from "@/arches_lingo/types.ts";
import SchemeSection from "@/arches_lingo/components/detail/SchemeSection.vue";
const route = useRoute();
const schemeResource = ref<SchemeResource | null>(null);
onMounted(async () => {
const resource = (await fetchSchemeResource(
route.params.id,
)) as SchemeResource;
schemeResource.value = resource;
});
import Splitter from "primevue/splitter";
import SplitterPanel from "primevue/splitterpanel";
import SchemeLicense from "@/arches_lingo/components/scheme/report/SchemeLicense.vue";
import SchemeNote from "@/arches_lingo/components/scheme/report/SchemeNote.vue";
import SchemeUri from "@/arches_lingo/components/scheme/report/SchemeUri.vue";
import SchemeStandard from "@/arches_lingo/components/scheme/report/SchemeStandard.vue";
import SchemeAuthority from "@/arches_lingo/components/scheme/report/SchemeAuthority.vue";
</script>

<template>
<div v-if="schemeResource">
<div
v-for="(section, resourceKey) in schemeResource.resource"
:key="resourceKey"
>
<SchemeSection
:section="section"
:resource-key="resourceKey"
/>
</div>
<div>
<Splitter>
<SplitterPanel>
<SchemeNote />
<SchemeAuthority />
<SchemeStandard />
<SchemeLicense />
<SchemeUri />
</SplitterPanel>
</Splitter>
</div>
</template>
7 changes: 0 additions & 7 deletions arches_lingo/src/arches_lingo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ export interface Scheme {
top_concepts: Concept[];
}

export interface SchemeResource {
[key: string]: object;
resource: {
[key: string]: Array<object>;
};
}

export interface NodeAndParentInstruction {
node: TreeNode;
shouldHideSiblings: boolean;
Expand Down

0 comments on commit 874b141

Please sign in to comment.