Add support for person identifiers workflow: update PersonEdit component, API methods, and modals for identifier handling during person creation. Adjust related types for improved consistency.

This commit is contained in:
2025-09-16 10:00:29 +02:00
parent 10cd0f2ccc
commit 6e9ed7f79f
6 changed files with 132 additions and 48 deletions

View File

@@ -64,6 +64,8 @@ const props = withDefaults(defineProps<CreateComponentConfig>(), {
action: "create",
query: "",
});
const type = ref<CreatableEntityType | null>(null);
const radioType = computed<CreatableEntityType | null>({
@@ -74,12 +76,14 @@ const radioType = computed<CreatableEntityType | null>({
},
});
type PersonEditComponent = InstanceType<typeof PersonEdit>;
type AnyComponentInstance =
| InstanceType<typeof OnTheFlyPerson>
| InstanceType<typeof OnTheFlyThirdparty>
| null;
const castPerson = ref<AnyComponentInstance>(null);
const castPerson = ref<PersonEditComponent>(null);
const castThirdparty = ref<AnyComponentInstance>(null);
onMounted(() => {
@@ -100,31 +104,13 @@ const containsPerson = computed<boolean>(() => {
return props.allowedTypes.includes("person");
});
// Types for data structures coming from child components are not declared in TS yet.
// We conservatively type them as any to preserve runtime behavior while enabling TS in this component.
function castDataByType(): any {
switch (radioType.value) {
case "person":
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (castPerson.value as any)?.$data?.person;
case "thirdparty": {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let data: any = (castThirdparty.value as any)?.$data?.thirdparty;
if (data && data.address !== undefined && data.address !== null) {
data.address = { id: data.address.address_id };
} else if (data) {
data.address = null;
}
return data;
}
default:
throw Error("Invalid type of entity");
}
function save(): void {
castPerson.value.postPerson();
}
defineExpose({
castDataByType,
});
defineExpose({save});
</script>
<style lang="css" scoped>

View File

@@ -2,11 +2,25 @@
import Modal from "ChillMainAssets/vuejs/_components/Modal.vue";
import Create from "ChillMainAssets/vuejs/OnTheFly/components/Create.vue";
import { CreateComponentConfig } from "ChillMainAssets/types";
import {trans, SAVE} from "translator";
import {useTemplateRef} from "vue";
const emit = defineEmits<(e: "close") => void>();
const props = defineProps<CreateComponentConfig>();
const modalDialogClass = { "modal-xl": true, "modal-scrollable": true };
type CreateComponentType = InstanceType<typeof Create>
const create = useTemplateRef<CreateComponentType>("create");
function save(): void {
console.log('save from CreateModal');
create.value?.save();
}
defineExpose({save})
</script>
<template>
@@ -22,12 +36,16 @@ const modalDialogClass = { "modal-xl": true, "modal-scrollable": true };
<template #body-head>
<div class="modal-body">
<Create
ref="create"
:allowedTypes="props.allowedTypes"
:action="props.action"
:query="props.query"
></Create>
</div>
</template>
<template #footer>
<button class="btn btn-save" type="button" @click.prevent="save">{{ trans(SAVE) }}</button>
</template>
</modal>
</teleport>
</template>