mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-25 22:52:48 +00:00
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:
@@ -24,8 +24,8 @@ const onPersonCreated = ({person}: {person: Person}): void => {
|
||||
emit("onPersonCreated", {person});
|
||||
};
|
||||
|
||||
const onThirdPartyCreated = ({tp}: {tp: Thirdparty}): void => {
|
||||
emit("onThirdPartyCreated", {thirdParty: tp});
|
||||
const onThirdPartyCreated = ({thirdParty}: {thirdParty: Thirdparty}): void => {
|
||||
emit("onThirdPartyCreated", {thirdParty: thirdParty});
|
||||
}
|
||||
|
||||
function save(): void {
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
modalTitle="test"
|
||||
@close="closeModalCreate"
|
||||
@onPersonCreated="onPersonCreated"
|
||||
@onThirdPartyCreated="onThirdPartyCreated"
|
||||
></CreateModal>
|
||||
|
||||
<CreateModal
|
||||
@@ -42,6 +43,7 @@
|
||||
:query="''"
|
||||
@close="closeModalCreate"
|
||||
@onPersonCreated="onPersonCreated"
|
||||
@onThirdPartyCreated="onThirdPartyCreated"
|
||||
></CreateModal>
|
||||
</template>
|
||||
|
||||
@@ -58,7 +60,7 @@ import type {
|
||||
import { marked } from "marked";
|
||||
import options = marked.options;
|
||||
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 {
|
||||
suggested?: Suggestion[];
|
||||
@@ -78,15 +80,15 @@ const props = withDefaults(defineProps<AddPersonsConfig>(), {
|
||||
});
|
||||
|
||||
const emit =
|
||||
defineEmits<
|
||||
(e: "addNewPersons", payload: { selected: Suggestion[] }) => void
|
||||
defineEmits<{
|
||||
(e: "addNewPersons", payload: { selected: Suggestion[] }): void;
|
||||
}
|
||||
>();
|
||||
|
||||
const showModalChoose = ref(false);
|
||||
const showModalCreate = ref(false);
|
||||
const query = ref("");
|
||||
const thirdPartyParentAddContact = ref<ThirdpartyCompany|null>(null);
|
||||
const allowedTypesAddContact = ['addContact'];
|
||||
|
||||
const getClassButton = computed(() => {
|
||||
const size = props.options?.button?.size ?? "";
|
||||
@@ -149,6 +151,17 @@ function onPersonCreated(payload: { person: Person }) {
|
||||
};
|
||||
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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface ThirdpartyCompany extends BaseThirdParty {
|
||||
text: string;
|
||||
acronym: string | null;
|
||||
children: Thirdparty[];
|
||||
categories: ThirdpartyCategory[];
|
||||
category: ThirdpartyCategory[];
|
||||
thirdPartyTypes: ThirdpartyType[] | null;
|
||||
address: Address | null;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ export function isThirdpartyChild(
|
||||
export interface ThirdpartyContact extends BaseThirdParty {
|
||||
kind: "contact";
|
||||
civility: Civility | null;
|
||||
categories: ThirdpartyCategory[];
|
||||
category: ThirdpartyCategory[];
|
||||
thirdPartyTypes: ThirdpartyType[] | null;
|
||||
profession: string;
|
||||
firstname: string;
|
||||
|
||||
@@ -175,7 +175,7 @@ const getProfession = computed<string[]>(() => {
|
||||
}
|
||||
|
||||
if (!isThirdpartyChild(t)) {
|
||||
for (const c of t.categories) {
|
||||
for (const c of t.category) {
|
||||
prof.push(localizeString(c.name));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user