From 27825696dfcba33df64401628e2902f537aeecbb Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Mon, 29 Jan 2018 16:30:35 -0200 Subject: [PATCH] begin error message web component --- src/admin/js/main.js | 7 ------- src/classes/field-types/text/Text.vue | 4 ++-- src/js/event-bus-web-components.js | 9 ++++----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/admin/js/main.js b/src/admin/js/main.js index 59555aeaa..59497b137 100644 --- a/src/admin/js/main.js +++ b/src/admin/js/main.js @@ -16,7 +16,6 @@ router.beforeEach((to, from, next) => { // FROM DEV // include vue-custom-element plugin to Vue -import { eventBus } from '../../js/event-bus-web-components'; import Text from '../../classes/field-types/text/Text.vue'; @@ -34,13 +33,7 @@ Vue.component('tainacan-selectbox', Selectbox); Vue.component('tainacan-checkbox', Checkbox); Vue.component('tainacan-radio', Radio); Vue.component('tainacan-numeric', Numeric); -eventBus.registerComponent( 'tainacan-numeric' ); - - Vue.component('tainacan-date', Date); -eventBus.registerComponent( 'tainacan-date' ); - -eventBus.listener(); //------------------------------------------------ diff --git a/src/classes/field-types/text/Text.vue b/src/classes/field-types/text/Text.vue index 248b6a6d3..5caeee68f 100644 --- a/src/classes/field-types/text/Text.vue +++ b/src/classes/field-types/text/Text.vue @@ -26,8 +26,8 @@ }, methods: { changeValue(){ - // this.$emit('changeValues', { item_id: this.item_id, metadata_id: this.metadata_id, values: this.valueInput } ); - eventBus.$emit('input', { item_id: this.item_id, metadata_id: this.metadata_id, values: this.valueInput } ); + this.$emit('changeValues', { item_id: this.item_id, metadata_id: this.metadata_id, values: this.valueInput } ); + eventBus.$emit('input', { item_id: this.item_id, metadata_id: this.metadata_id, values: this.valueInput, instance: this } ); }, getValue(){ try{ diff --git a/src/js/event-bus-web-components.js b/src/js/event-bus-web-components.js index 6adaa3cf6..4b0e31249 100644 --- a/src/js/event-bus-web-components.js +++ b/src/js/event-bus-web-components.js @@ -23,7 +23,6 @@ export const eventBus = new Vue({ const components = this.getAllComponents(); for (let eventElement of components){ eventElement.addEventListener('changeValues', (event) => { - console.log(event,'event') if ( event.detail[0] ){ const promisse = this.$store.dispatch('item/updateMetadata', event.detail[0] ); promisse.then( response => { @@ -40,10 +39,11 @@ export const eventBus = new Vue({ }, updateValue(data){ if ( data.item_id ){ - const promisse = this.$store.dispatch('item/updateMetadata', data ); + const promisse = this.$store.dispatch('item/updateMetadata', + { item_id: data.item_id, metadata_id: data.metadata_id, values: data.values }); promisse.then( response => { - eventElement.errorsMsg = JSON.stringify( [] ); - eventElement.value = response.value; + data.instance.message = JSON.stringify( [] ); + data.instance.value = response.value; }, error => { const metadata = this.errors.find(error => error.metadata_id === data.metadata_id ); eventElement.errorsMsg = JSON.stringify( metadata.error ); @@ -64,7 +64,6 @@ export const eventBus = new Vue({ const components = []; for( let component of this.componentsTag ){ const eventElements = document.getElementsByTagName( component ); - console.log(eventElements,eventElements.length); if( eventElements ) { for (let eventElement of eventElements){ components.push( eventElement );