From 6b764114e4ef94dc0d95dca6bbe915791201e952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 1 Oct 2024 16:03:34 +0200 Subject: [PATCH] Add event for handling end of addNewEntity process Added new event 'addNewEntityProcessEnded' to PickEntity component. This event triggers form submission when 'submit_on_adding_new_entity' is enabled, ensuring proper flow control. --- .../Resources/public/module/pick-entity/index.js | 13 ++++++++----- .../public/vuejs/PickEntity/PickEntity.vue | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 03220630f..19194e318 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -44,7 +44,9 @@ function loadDynamicPicker(element) { ':suggested="notPickedSuggested" ' + ':label="label" ' + '@addNewEntity="addNewEntity" ' + - '@removeEntity="removeEntity">', + '@removeEntity="removeEntity" ' + + '@addNewEntityProcessEnded="addNewEntityProcessEnded"' + + '>', components: { PickEntity, }, @@ -97,10 +99,11 @@ function loadDynamicPicker(element) { } } } - - if (this.submit_on_adding_new_entity) { - input.form.submit(); - } + }, + addNewEntityProcessEnded() { + if (this.submit_on_adding_new_entity) { + input.form.submit(); + } }, removeEntity({entity}) { if (-1 === this.suggested.findIndex(e => e.type === entity.type && e.id === entity.id)) { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 75abc4fdd..e2ba91f8f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -62,7 +62,7 @@ export default { required: false, } }, - emits: ['addNewEntity', 'removeEntity'], + emits: ['addNewEntity', 'removeEntity', 'addNewEntityProcessEnded'], components: { AddPersons, }, @@ -121,6 +121,7 @@ export default { ); this.$refs.addPersons.resetSearch(); // to cast child method modal.showModal = false; + this.$emit('addNewEntityProcessEnded'); }, removeEntity(entity) { if (!this.$props.removableIfSet) {