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

Changes to allow for a single form per tile #160

Merged
merged 8 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<script setup lang="ts">
import { onBeforeUpdate, onUpdated, ref } from "vue";
import { onBeforeUpdate, ref, watch } from "vue";
import { useGettext } from "vue3-gettext";
import Button from "primevue/button";

import Tabs from "primevue/tabs";
import TabList from "primevue/tablist";
import Tab from "primevue/tab";
import TabPanels from "primevue/tabpanels";
import TabPanel from "primevue/tabpanel";
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";
Expand All @@ -17,28 +11,48 @@ const { $gettext } = useGettext();
const EDIT = "edit";
const props = defineProps<{
editorMax: boolean;
activeTab: string;
editorForm: string;
tileId?: string;
}>();

type SchemeComponent = {
component: SectionTypes;
id: string;
editorName: string;
};

const childRefs = ref<Array<SectionTypes>>([]);
const currentEditor = ref<SchemeComponent>();
const schemeComponents = [
{
component: SchemeLabel,
id: "label",
editorTabName: $gettext("Scheme Label"),
editorName: $gettext("Scheme Label"),
},
{
component: SchemeNamespace,
id: "namespace",
editorTabName: $gettext("Scheme Namespace"),
editorName: $gettext("Scheme Namespace"),
},
{
component: SchemeStandard,
id: "standard",
editorTabName: $gettext("Scheme Standards Followed"),
editorName: $gettext("Scheme Standards Followed"),
},
];

watch(
props,
(newValue) => {
if (newValue) {
currentEditor.value = schemeComponents.find((component) => {
return component.id === newValue.editorForm;
});
}
},
{ immediate: true },
);

const emit = defineEmits(["maximize", "side", "close", "updated"]);

onBeforeUpdate(() => {
Expand All @@ -53,17 +67,7 @@ function toggleSize() {
}
}

function getRef(el: object | null, index: number) {
if (el != null) childRefs.value[index] = el as SectionTypes;
}

async function updateScheme() {
await Promise.all(
childRefs.value.map(async (ref) => {
return ref.save();
}),
);

function onSectionUpdate() {
emit("updated");
}
</script>
Expand Down Expand Up @@ -98,38 +102,16 @@ async function updateScheme() {
</div>
</div>
</div>
<div class="content">
<Tabs :value="activeTab">
<TabList>
<template
v-for="component in schemeComponents"
:key="component.id"
>
<Tab :value="component.id">{{
component.editorTabName
}}</Tab>
</template>
</TabList>
<TabPanels>
<template
v-for="(component, index) in schemeComponents"
:key="component.id"
>
<TabPanel :value="component.id">
<component
:is="component.component"
v-bind="{ mode: EDIT, tileId: props.tileId }"
:ref="(el) => getRef(el, index)"
v-on="{ updated: onUpdated }"
/>
</TabPanel>
</template>
</TabPanels>
</Tabs>
<Button
:label="$gettext('Update')"
@click="updateScheme"
></Button>
<div
v-if="currentEditor"
class="content"
>
<h3>{{ currentEditor.editorName }}</h3>
<component
:is="currentEditor.component"
v-bind="{ mode: EDIT, tileId: tileId }"
v-on="{ updated: onSectionUpdate }"
/>
</div>
</template>
<style scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import { useGettext } from "vue3-gettext";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
const { $gettext } = useGettext();
const save = () => {
console.log("save");
};

const getSectionValue = async () => {
console.log("update");
};
defineExpose({ save, getSectionValue });
defineExpose({ getSectionValue });
</script>

<template>
<SchemeReportSection :title-text="$gettext('Trusted Authorities')">
abc
todo
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ withDefaults(
},
);

defineExpose({ save, getSectionValue });
defineExpose({ getSectionValue });

const emits = defineEmits([OPEN_EDITOR]);

Expand Down Expand Up @@ -90,9 +90,9 @@ function editSectionValue(tileId: string) {
}
}

async function save() {
// todo for Johnathan. This function will save the values of the form back to arches.
}
// async function save() {
// // todo for Johnathan. This function will save the values of the form back to arches.
// }

// async function update() {
// // todo for Johnathan. This function will handle the update emit when the user changes values in your form - you store those values in this section.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ const { $gettext } = useGettext();

<template>
<SchemeReportSection :title-text="$gettext('License')">
abc
todo
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { useGettext } from "vue3-gettext";

import Button from "primevue/button";
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue";
import NonLocalizedString from "@/arches_lingo/components/generic/NonLocalizedString.vue";
import {
fetchSchemeNamespace,
updateSchemeNamespace,
} from "@/arches_lingo/api.ts";
import {
VIEW,
EDIT,
OPEN_EDITOR,
ERROR,
UPDATED,
} from "@/arches_lingo/constants.ts";
import { useToast } from "primevue/usetoast";
import type {
DataComponentMode,
SchemeNamespaceUpdate,
SchemeInstance,
} from "@/arches_lingo/types";
import { VIEW, EDIT, OPEN_EDITOR, ERROR } from "@/arches_lingo/constants.ts";
import { useToast } from "primevue/usetoast";

const toast = useToast();
const { $gettext } = useGettext();
Expand All @@ -26,9 +32,9 @@ defineProps<{
mode?: DataComponentMode;
}>();

defineEmits([OPEN_EDITOR]);
const emit = defineEmits([OPEN_EDITOR, UPDATED]);

defineExpose({ save, getSectionValue });
defineExpose({ getSectionValue });

onMounted(async () => {
getSectionValue();
Expand All @@ -52,6 +58,7 @@ async function save() {
),
});
}
emit(UPDATED);
}

async function getSectionValue() {
Expand Down Expand Up @@ -91,7 +98,7 @@ function onNamespaceNameUpdate(val: string) {
<div v-if="!mode || mode === VIEW">
<SchemeReportSection
:title-text="$gettext('Scheme Namespace')"
@open-editor="$emit(OPEN_EDITOR)"
@open-editor="emit(OPEN_EDITOR)"
>
<NonLocalizedString
:value="schemeInstance?.namespace?.namespace_name"
Expand All @@ -107,6 +114,10 @@ function onNamespaceNameUpdate(val: string) {
:mode="EDIT"
@update="onNamespaceNameUpdate"
/>
<Button
chrabyrd marked this conversation as resolved.
Show resolved Hide resolved
:label="$gettext('Update')"
@click="save"
></Button>
</div>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ const { $gettext } = useGettext();

<template>
<SchemeReportSection :title-text="$gettext('Scheme Notes')">
abc
todo
</SchemeReportSection>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { inject, onMounted, ref, type Ref } from "vue";
import { useRoute } from "vue-router";
import { useGettext } from "vue3-gettext";
import Button from "primevue/button";
import type {
DataComponentMode,
ResourceInstanceReference,
Expand All @@ -20,6 +21,7 @@ import {
VIEW,
EDIT,
OPEN_EDITOR,
UPDATED,
ERROR,
} from "@/arches_lingo/constants.ts";
import type { Language } from "@/arches_vue_utils/types.ts";
Expand All @@ -36,9 +38,9 @@ const { mode = VIEW } = defineProps<{
mode?: DataComponentMode;
}>();

const emits = defineEmits([OPEN_EDITOR]);
const emits = defineEmits([OPEN_EDITOR, UPDATED]);

defineExpose({ save, getSectionValue });
defineExpose({ getSectionValue });

onMounted(async () => {
getSectionValue();
Expand Down Expand Up @@ -139,14 +141,13 @@ function onCreationUpdate(val: string[]) {
</script>

<template>
<div v-if="!mode || mode === VIEW">
<div v-if="mode === VIEW">
<SchemeReportSection
:title-text="$gettext('Scheme Standards Followed')"
@open-editor="emits(OPEN_EDITOR)"
>
<ResourceInstanceRelationships
:value="schemeInstance?.creation?.creation_sources"
:mode="VIEW"
/>
<!-- Discussion of namespace_type indicated it should not be displayed or edited manually,
if this changes, the ControlledListItem widget can be used.-->
Expand All @@ -159,5 +160,9 @@ function onCreationUpdate(val: string[]) {
:mode="EDIT"
@update="onCreationUpdate"
/>
<Button
:label="$gettext('Update')"
@click="save"
></Button>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const { $gettext } = useGettext();

<template>
<SchemeReportSection :title-text="$gettext('Scheme URI')">
abc
todo
</SchemeReportSection>
</template>
1 change: 1 addition & 0 deletions arches_lingo/src/arches_lingo/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const CONTRAST = "contrast";
export const EDIT = "edit";
export const VIEW = "view";
export const OPEN_EDITOR = "openEditor";
export const UPDATED = "updated";

export const DEFAULT_ERROR_TOAST_LIFE = 8000;
export const SEARCH_RESULTS_PER_PAGE = 25;
Expand Down
10 changes: 5 additions & 5 deletions arches_lingo/src/arches_lingo/pages/SchemePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { SectionTypes } from "@/arches_lingo/types.ts";

const editorVisible = ref(false);
const sectionVisible = ref(true);
const editorTab = ref<string>();
const editorForm = ref<string>();
const editorTileId = ref<string>();

const childRefs = ref<Array<SectionTypes>>([]);
Expand All @@ -33,8 +33,8 @@ const onClose = () => {
sectionVisible.value = true;
};

const onOpenEditor = (tab: string, tileId: string) => {
editorTab.value = tab;
const onOpenEditor = (form: string, tileId: string) => {
editorForm.value = form;
editorVisible.value = true;
sectionVisible.value = true;
editorTileId.value = tileId;
Expand Down Expand Up @@ -84,9 +84,9 @@ const getRef = (el: object | null, index: number) => {
:size="25"
>
<SchemeEditor
v-if="editorTab"
v-if="editorForm"
:editor-max="sectionVisible"
:active-tab="editorTab"
:editor-form="editorForm"
:tile-id="editorTileId"
@maximize="onMaximize"
@side="onSide"
Expand Down
14 changes: 7 additions & 7 deletions arches_lingo/src/arches_lingo/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Ref } from "vue";
import type { TreeNode } from "primevue/treenode";
import type { Label } from "@/arches_vue_utils/types.ts";
import SchemeLabel from "@/arches_lingo/components/scheme/report/SchemeLabel.vue";
import SchemeNamespace from "@/arches_lingo/components/scheme/report/SchemeNamespace.vue";
import SchemeLicense from "@/arches_lingo/components/scheme/report/SchemeLicense.vue";
import SchemeStandard from "@/arches_lingo/components/scheme/report/SchemeStandard.vue";
import SchemeAuthority from "@/arches_lingo/components/scheme/report/SchemeAuthority.vue";
import SchemeNote from "@/arches_lingo/components/scheme/report/SchemeNote.vue";
import type { EDIT, VIEW } from "@/constants.ts";
import type { EDIT, VIEW } from "./constants";
import SchemeNamespace from "@/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNamespace.vue";
import SchemeLabel from "@/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue";
import SchemeLicense from "@/arches_lingo/src/arches_lingo/components/scheme/report/SchemeLicense.vue";
import SchemeStandard from "@/arches_lingo/src/arches_lingo/components/scheme/report/SchemeStandard.vue";
import SchemeAuthority from "@/arches_lingo/src/arches_lingo/components/scheme/report/SchemeAuthority.vue";
import SchemeNote from "@/arches_lingo/src/arches_lingo/components/scheme/report/SchemeNote.vue";

export interface User {
first_name: string;
Expand Down
Loading