From 65e2f950b9032494773e137c93dadda71b958dfb Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 14 Nov 2024 14:54:06 +0100 Subject: [PATCH] chore: try use quasar bus --- src/boot/removeBus.js | 7 +++++++ src/components/common/VnInput.vue | 5 +++++ src/components/ui/VnFilterPanel.vue | 13 ++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/boot/removeBus.js diff --git a/src/boot/removeBus.js b/src/boot/removeBus.js new file mode 100644 index 000000000..05f299f24 --- /dev/null +++ b/src/boot/removeBus.js @@ -0,0 +1,7 @@ +import { EventBus } from 'quasar'; +import { boot } from 'quasar/wrappers'; + +export default boot(({ app }) => { + const bus = new EventBus(); + app.provide('remove', bus); +}); diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 7979b6d6e..633ac812b 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -4,6 +4,9 @@ import { useI18n } from 'vue-i18n'; import { useRequired } from 'src/composables/useRequired'; const $attrs = useAttrs(); +import { inject } from 'vue'; + +const bus = inject('bus'); // inside setup() const { isRequired, requiredFieldRule } = useRequired($attrs); const { t } = useI18n(); const emit = defineEmits([ @@ -107,6 +110,8 @@ const mixinRules = [ value = null; vnInputRef.focus(); emit('remove'); + console.log('HOLA'); + bus.emit('some-event', 'hola'); } " > diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index a8aca49dd..1f4c32b16 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -5,7 +5,13 @@ import { useArrayData } from 'composables/useArrayData'; import { useRoute } from 'vue-router'; import toDate from 'filters/toDate'; import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue'; +import { inject } from 'vue'; +const bus = inject('bus'); // inside setup() +console.log('bus: ', bus); +bus.on('some-event', (arg1, arg2, arg3) => { + console.log('REMOVED'); +}); const { t } = useI18n(); const $props = defineProps({ modelValue: { @@ -294,7 +300,12 @@ defineExpose({ search, sanitizer, userParams }); - +