Removes collapse event binding from computed property function in TainacanFormItem (was causing a loop). Closes #57.

This commit is contained in:
mateuswetah 2018-06-02 02:04:35 -03:00
parent 2e8cfd5dd8
commit be7eb7b544
2 changed files with 8 additions and 9 deletions

View File

@ -5,10 +5,10 @@
:type="fieldTypeMessage"> :type="fieldTypeMessage">
<span <span
class="collapse-handle" class="collapse-handle"
@click="$emit('changeCollapse', !isCollapsed)"> @click="$emit('changeCollapse', fieldTypeMessage != 'is-danger' ? !isCollapsed : true)">
<b-icon <b-icon
type="is-secondary" type="is-secondary"
:icon="isCollapsed ? 'menu-down' : 'menu-right'" /> :icon="isCollapsed || fieldTypeMessage == 'is-danger' ? 'menu-down' : 'menu-right'" />
<label class="label">{{ field.field.name }}</label> <label class="label">{{ field.field.name }}</label>
<span <span
v-if="field.field.required == 'yes'" v-if="field.field.required == 'yes'"
@ -20,7 +20,7 @@
:message="field.field.description"/> :message="field.field.description"/>
</span> </span>
<div <div
v-show="isCollapsed" v-show="isCollapsed || fieldTypeMessage == 'is-danger'"
v-if="isTextInputComponent( field.field.field_type_object.component )"> v-if="isTextInputComponent( field.field.field_type_object.component )">
<component <component
:id="field.field.field_type_object.component + '-' + field.field.slug" :id="field.field.field_type_object.component + '-' + field.field.slug"
@ -92,7 +92,7 @@
this.setFieldTypeMessage('is-danger'); this.setFieldTypeMessage('is-danger');
for (let error of errors) { for (let error of errors) {
for (let index of Object.keys(error)) { for (let index of Object.keys(error)) {
//this.$console.log(index); // this.$console.log(index);
msg += error[index] + '\n'; msg += error[index] + '\n';
} }
} }
@ -133,8 +133,6 @@
}, },
setFieldTypeMessage( message ){ setFieldTypeMessage( message ){
this.fieldTypeMessage = message; this.fieldTypeMessage = message;
if (message != '')
this.$emit('changeCollapse', true);
} }
} }
} }

View File

@ -36,6 +36,7 @@ export const eventBus = new Vue({
}, },
updateValue(data){ updateValue(data){
if ( data.item_id ){ if ( data.item_id ){
let values = ( Array.isArray( data.values[0] ) ) ? data.values[0] : data.values ; let values = ( Array.isArray( data.values[0] ) ) ? data.values[0] : data.values ;
const promisse = this.$store.dispatch('item/updateMetadata', const promisse = this.$store.dispatch('item/updateMetadata',
{ item_id: data.item_id, field_id: data.field_id, values: values }); { item_id: data.item_id, field_id: data.field_id, values: values });
@ -62,7 +63,7 @@ export const eventBus = new Vue({
}); });
} }
}, },
getErrors(field_id){ getErrors(field_id) {
let error = this.errors.find( errorItem => errorItem.field_id == field_id ); let error = this.errors.find( errorItem => errorItem.field_id == field_id );
return ( error ) ? error.errors : false return ( error ) ? error.errors : false
}, },