Refactor third-party handling for consistency and improved data flow.

- Renamed `categories` to `category` in `Thirdparty` and related types for clarity and type safety.
- Updated `ThirdPartyRenderBox.vue` and `CreateModal.vue` to align with new type definitions.
- Enhanced `AddPersons.vue` to handle `onThirdPartyCreated` event properly and extend functionality for third-party creation.
This commit is contained in:
2025-10-24 16:41:08 +02:00
parent 71e146e4f0
commit f1bf6023ff
4 changed files with 22 additions and 9 deletions

View File

@@ -24,8 +24,8 @@ const onPersonCreated = ({person}: {person: Person}): void => {
emit("onPersonCreated", {person}); emit("onPersonCreated", {person});
}; };
const onThirdPartyCreated = ({tp}: {tp: Thirdparty}): void => { const onThirdPartyCreated = ({thirdParty}: {thirdParty: Thirdparty}): void => {
emit("onThirdPartyCreated", {thirdParty: tp}); emit("onThirdPartyCreated", {thirdParty: thirdParty});
} }
function save(): void { function save(): void {

View File

@@ -31,6 +31,7 @@
modalTitle="test" modalTitle="test"
@close="closeModalCreate" @close="closeModalCreate"
@onPersonCreated="onPersonCreated" @onPersonCreated="onPersonCreated"
@onThirdPartyCreated="onThirdPartyCreated"
></CreateModal> ></CreateModal>
<CreateModal <CreateModal
@@ -42,6 +43,7 @@
:query="''" :query="''"
@close="closeModalCreate" @close="closeModalCreate"
@onPersonCreated="onPersonCreated" @onPersonCreated="onPersonCreated"
@onThirdPartyCreated="onThirdPartyCreated"
></CreateModal> ></CreateModal>
</template> </template>
@@ -58,7 +60,7 @@ import type {
import { marked } from "marked"; import { marked } from "marked";
import options = marked.options; import options = marked.options;
import CreateModal from "ChillMainAssets/vuejs/OnTheFly/components/CreateModal.vue"; import CreateModal from "ChillMainAssets/vuejs/OnTheFly/components/CreateModal.vue";
import {ThirdpartyCompany} from "../../../../../ChillThirdPartyBundle/Resources/public/types"; import {Thirdparty, ThirdpartyCompany} from "../../../../../ChillThirdPartyBundle/Resources/public/types";
interface AddPersonsConfig { interface AddPersonsConfig {
suggested?: Suggestion[]; suggested?: Suggestion[];
@@ -78,15 +80,15 @@ const props = withDefaults(defineProps<AddPersonsConfig>(), {
}); });
const emit = const emit =
defineEmits< defineEmits<{
(e: "addNewPersons", payload: { selected: Suggestion[] }) => void (e: "addNewPersons", payload: { selected: Suggestion[] }): void;
}
>(); >();
const showModalChoose = ref(false); const showModalChoose = ref(false);
const showModalCreate = ref(false); const showModalCreate = ref(false);
const query = ref(""); const query = ref("");
const thirdPartyParentAddContact = ref<ThirdpartyCompany|null>(null); const thirdPartyParentAddContact = ref<ThirdpartyCompany|null>(null);
const allowedTypesAddContact = ['addContact'];
const getClassButton = computed(() => { const getClassButton = computed(() => {
const size = props.options?.button?.size ?? ""; const size = props.options?.button?.size ?? "";
@@ -149,6 +151,17 @@ function onPersonCreated(payload: { person: Person }) {
}; };
emit("addNewPersons", { selected: [suggestion] }); emit("addNewPersons", { selected: [suggestion] });
} }
function onThirdPartyCreated(payload: {thirdParty: Thirdparty}) {
console.log("onThirdPartyCreated", payload);
showModalCreate.value = false;
const suggestion = {
result: payload.thirdParty,
relevance: 999999,
key: "thirdparty",
};
emit("addNewPersons", { selected: [suggestion] });
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -33,7 +33,7 @@ export interface ThirdpartyCompany extends BaseThirdParty {
text: string; text: string;
acronym: string | null; acronym: string | null;
children: Thirdparty[]; children: Thirdparty[];
categories: ThirdpartyCategory[]; category: ThirdpartyCategory[];
thirdPartyTypes: ThirdpartyType[] | null; thirdPartyTypes: ThirdpartyType[] | null;
address: Address | null; address: Address | null;
} }
@@ -75,7 +75,7 @@ export function isThirdpartyChild(
export interface ThirdpartyContact extends BaseThirdParty { export interface ThirdpartyContact extends BaseThirdParty {
kind: "contact"; kind: "contact";
civility: Civility | null; civility: Civility | null;
categories: ThirdpartyCategory[]; category: ThirdpartyCategory[];
thirdPartyTypes: ThirdpartyType[] | null; thirdPartyTypes: ThirdpartyType[] | null;
profession: string; profession: string;
firstname: string; firstname: string;

View File

@@ -175,7 +175,7 @@ const getProfession = computed<string[]>(() => {
} }
if (!isThirdpartyChild(t)) { if (!isThirdpartyChild(t)) {
for (const c of t.categories) { for (const c of t.category) {
prof.push(localizeString(c.name)); prof.push(localizeString(c.name));
} }
} }