mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-28 17:44:58 +00:00
Enhance person creation workflow: Add onPersonCreated
event handling in Create
, CreateModal
, and AddPersons
. Update type definitions and integrate event emission for streamlined person management.
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
action="create"
|
action="create"
|
||||||
:query="query"
|
:query="query"
|
||||||
ref="castPerson"
|
ref="castPerson"
|
||||||
|
@onPersonCreated="(payload) => emit('onPersonCreated', payload)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<on-the-fly-thirdparty
|
<on-the-fly-thirdparty
|
||||||
@@ -55,16 +56,19 @@ import {
|
|||||||
ONTHEFLY_CREATE_THIRDPARTY,
|
ONTHEFLY_CREATE_THIRDPARTY,
|
||||||
trans,
|
trans,
|
||||||
} from "translator";
|
} from "translator";
|
||||||
import { CreatableEntityType } from "ChillPersonAssets/types";
|
import {CreatableEntityType, Person} from "ChillPersonAssets/types";
|
||||||
import { CreateComponentConfig } from "ChillMainAssets/types";
|
import { CreateComponentConfig } from "ChillMainAssets/types";
|
||||||
import PersonEdit from "ChillPersonAssets/vuejs/_components/OnTheFly/PersonEdit.vue";
|
import PersonEdit from "ChillPersonAssets/vuejs/_components/OnTheFly/PersonEdit.vue";
|
||||||
|
|
||||||
const props = withDefaults(defineProps<CreateComponentConfig>(), {
|
const props = withDefaults(defineProps<CreateComponentConfig>(), {
|
||||||
allowedTypes: ["person", "thirdparty"],
|
allowedTypes: ["person"],
|
||||||
action: "create",
|
action: "create",
|
||||||
query: "",
|
query: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: "onPersonCreated", payload: { person: Person }): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const type = ref<CreatableEntityType | null>(null);
|
const type = ref<CreatableEntityType | null>(null);
|
||||||
|
|
||||||
|
@@ -4,8 +4,12 @@ import Create from "ChillMainAssets/vuejs/OnTheFly/components/Create.vue";
|
|||||||
import { CreateComponentConfig } from "ChillMainAssets/types";
|
import { CreateComponentConfig } from "ChillMainAssets/types";
|
||||||
import {trans, SAVE} from "translator";
|
import {trans, SAVE} from "translator";
|
||||||
import {useTemplateRef} from "vue";
|
import {useTemplateRef} from "vue";
|
||||||
|
import {Person} from "ChillPersonAssets/types";
|
||||||
|
|
||||||
const emit = defineEmits<(e: "close") => void>();
|
const emit = defineEmits<{
|
||||||
|
(e: "onPersonCreated", payload: { person: Person }): void;
|
||||||
|
(e: "close"): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const props = defineProps<CreateComponentConfig>();
|
const props = defineProps<CreateComponentConfig>();
|
||||||
const modalDialogClass = { "modal-xl": true, "modal-scrollable": true };
|
const modalDialogClass = { "modal-xl": true, "modal-scrollable": true };
|
||||||
@@ -40,6 +44,7 @@ defineExpose({save})
|
|||||||
:allowedTypes="props.allowedTypes"
|
:allowedTypes="props.allowedTypes"
|
||||||
:action="props.action"
|
:action="props.action"
|
||||||
:query="props.query"
|
:query="props.query"
|
||||||
|
@onPersonCreated="(payload) => emit('onPersonCreated', payload)"
|
||||||
></Create>
|
></Create>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
:allowed-types="creatableEntityTypes"
|
:allowed-types="creatableEntityTypes"
|
||||||
:query="query"
|
:query="query"
|
||||||
@close="closeModalCreate"
|
@close="closeModalCreate"
|
||||||
|
@onPersonCreated="onPersonCreated"
|
||||||
></CreateModal>
|
></CreateModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ import type {
|
|||||||
Suggestion,
|
Suggestion,
|
||||||
SearchOptions,
|
SearchOptions,
|
||||||
CreatableEntityType,
|
CreatableEntityType,
|
||||||
EntityType,
|
EntityType, Person,
|
||||||
} from "ChillPersonAssets/types";
|
} from "ChillPersonAssets/types";
|
||||||
import { marked } from "marked";
|
import { marked } from "marked";
|
||||||
import options = marked.options;
|
import options = marked.options;
|
||||||
@@ -49,14 +50,14 @@ interface AddPersonsConfig {
|
|||||||
modalTitle: string;
|
modalTitle: string;
|
||||||
options: SearchOptions;
|
options: SearchOptions;
|
||||||
allowCreate?: boolean;
|
allowCreate?: boolean;
|
||||||
types?: EntityType | undefined;
|
types?: EntityType[] | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<AddPersonsConfig>(), {
|
const props = withDefaults(defineProps<AddPersonsConfig>(), {
|
||||||
suggested: () => [],
|
suggested: () => [],
|
||||||
selected: () => [],
|
selected: () => [],
|
||||||
allowCreate: () => true,
|
allowCreate: () => true,
|
||||||
types: () => undefined,
|
types: () => ["person"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit =
|
const emit =
|
||||||
@@ -108,6 +109,13 @@ function closeModalChoose() {
|
|||||||
function closeModalCreate() {
|
function closeModalCreate() {
|
||||||
showModalCreate.value = false;
|
showModalCreate.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onPersonCreated(payload: { person: Person }) {
|
||||||
|
console.log("onPersonCreated", payload);
|
||||||
|
showModalCreate.value = false;
|
||||||
|
const suggestion = {result: payload.person, relevance: 999999, key: "person"};
|
||||||
|
emit("addNewPersons", {selected: [suggestion]});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Reference in New Issue
Block a user