Skip to content

Commit

Permalink
When creating new tile, update edit session #147
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Jan 13, 2025
1 parent e41c50f commit 8ffb6c1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ const groupAndPersonOptions = ref<ResourceInstanceReference[]>();
const textualWorkOptions = ref<ResourceInstanceReference[]>();
function onUpdateString(node: keyof AppellativeStatus, val: string) {
console.log(formValue.value[node]);
(formValue.value[node] as unknown) = toRaw(val);
}
function onUpdateReferenceDatatype(
node: keyof AppellativeStatus,
val: ControlledListItem[],
) {
console.log(formValue.value[node]);
(formValue.value[node] as unknown) = val.map((item) => toRaw(item));
}
Expand All @@ -91,6 +93,7 @@ function onUpdateResourceInstance(
val: string[],
options: ResourceInstanceReference[],
) {
console.log(formValue.value[node]);
if (val.length > 0) {
const selectedOptions = options.filter((option) =>
val.includes(option.resourceId),
Expand All @@ -111,7 +114,12 @@ async function save() {
params: { id: updated.resourceinstanceid },
});
} else if (!formValue.value.tileid) {
await createSchemeLabel(route.params.id as string, formValue.value);
const schemeLabel: AppellativeStatus = await createSchemeLabel(
route.params.id as string,
formValue.value,
);
valueRef.value = schemeLabel;
emit("update", schemeLabel.tileid);
} else {
await updateSchemeLabel(
route.params.id as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ import SchemeStandard from "@/arches_lingo/components/scheme/report/SchemeStanda
import SchemeLabel from "@/arches_lingo/components/scheme/report/SchemeLabel.vue";
import SchemeNote from "@/arches_lingo/components/scheme/report/SchemeNote.vue";
import type { SectionTypes } from "@/arches_lingo/types.ts";
import {
OPEN_EDITOR,
EDIT,
UPDATED,
MAXIMIZE,
SIDE,
CLOSE,
} from "@/arches_lingo/constants.ts";
const { $gettext } = useGettext();
const EDIT = "edit";
const props = defineProps<{
editorMax: boolean;
editorForm: string;
Expand Down Expand Up @@ -59,22 +66,22 @@ watch(
{ immediate: true },
);
const emit = defineEmits(["maximize", "side", "close", "updated"]);
const emit = defineEmits([MAXIMIZE, SIDE, CLOSE, UPDATED, OPEN_EDITOR]);
onBeforeUpdate(() => {
childRefs.value = [];
});
function toggleSize() {
if (props.editorMax) {
emit("maximize");
emit(MAXIMIZE);
} else {
emit("side");
emit(SIDE);
}
}
function onSectionUpdate() {
emit("updated");
emit(UPDATED);
}
</script>

Expand All @@ -98,7 +105,7 @@ function onSectionUpdate() {
</Button>
<Button
:aria-label="$gettext('close editor')"
@click="$emit('close')"
@click="$emit(CLOSE)"
>
<i
class="pi pi-times"
Expand All @@ -116,7 +123,11 @@ function onSectionUpdate() {
<component
:is="currentEditor.component"
v-bind="{ mode: EDIT, tileId: tileId }"
v-on="{ updated: onSectionUpdate }"
v-on="{
updated: onSectionUpdate,
openEditor: (tileId: string | undefined) =>
$emit(OPEN_EDITOR, currentEditor?.id, tileId),
}"
/>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useGettext } from "vue3-gettext";
import { computed, onMounted, ref } from "vue";
import { computed, onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { useToast } from "primevue/usetoast";
Expand Down Expand Up @@ -55,6 +55,10 @@ const appellativeStatusToEdit = computed(() => {
defineExpose({ getSectionValue });
watch(props, () => {
getSectionValue();
});
const emit = defineEmits([OPEN_EDITOR, UPDATED]);
onMounted(() => {
Expand Down Expand Up @@ -117,8 +121,11 @@ function editSectionValue(tileId: string) {
}
}
function update() {
emit(UPDATED);
async function update(tileId: string | undefined) {
await emit(UPDATED);
if (tileId) {
await emit(OPEN_EDITOR, tileId);
}
}
</script>

Expand Down
3 changes: 3 additions & 0 deletions arches_lingo/src/arches_lingo/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export const VIEW = "view";
export const OPEN_EDITOR = "openEditor";
export const UPDATED = "updated";
export const NEW = "new";
export const MAXIMIZE = "maximize";
export const SIDE = "side";
export const CLOSE = "close";

export const DEFAULT_ERROR_TOAST_LIFE = 8000;
export const SEARCH_RESULTS_PER_PAGE = 25;
Expand Down
1 change: 1 addition & 0 deletions arches_lingo/src/arches_lingo/pages/SchemePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const getRef = (el: object | null, index: number) => {
@side="onSide"
@close="onClose"
@updated="onUpdated"
@open-editor="onOpenEditor"
/>
</SplitterPanel>
</Splitter>
Expand Down

0 comments on commit 8ffb6c1

Please sign in to comment.