show errors on form category

This commit is contained in:
Eduardo humberto 2018-03-09 09:22:20 -03:00
parent 6a5ec34ad7
commit 974eedba97
2 changed files with 35 additions and 18 deletions

View File

@ -2,13 +2,16 @@
<section <section
v-if="isReady" v-if="isReady"
:listen="setError"> :listen="setError">
<b-field :label="$i18n.get('label_select_category')"> <b-field :label="$i18n.get('label_select_category')"
:type="taxonomyType"
:message="taxonomyMessage"
>
<b-select <b-select
name="field_type_options[taxonomy_id]" name="field_type_options[taxonomy_id]"
placeholder="Select the taxonomy" placeholder="Select the taxonomy"
v-model="taxonomy_id" v-model="taxonomy_id"
@input="emitValues()" @input="emitValues()"
@change.native="emitValues()" @focus="clear"
:loading="loading"> :loading="loading">
<option value="">{{ $i18n.get('label_selectbox_init') }}...</option> <option value="">{{ $i18n.get('label_selectbox_init') }}...</option>
<option <option
@ -110,7 +113,13 @@
} }
}, },
setError(){ setError(){
if( this.errors && this.errors.taxonomy_id !== '' ){
this.taxonomyType = 'is-warning';
this.taxonomyMessage = this.errors.taxonomy_id;
} else {
this.taxonomyType = '';
this.taxonomyMessage = '';
}
} }
}, },
data(){ data(){
@ -123,6 +132,8 @@
input_type: 'tainacan-category-radio', input_type: 'tainacan-category-radio',
multiple_types: {}, multiple_types: {},
single_types: {}, single_types: {},
taxonomyType:'',
taxonomyMessage: ''
} }
}, },
methods: { methods: {
@ -146,6 +157,10 @@
labelNewTerms(){ labelNewTerms(){
return ( this.allow_new_terms === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no'); return ( this.allow_new_terms === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no');
}, },
clear(){
this.taxonomyType = '';
this.taxonomyMessage = '';
},
emitValues(){ emitValues(){
this.$emit('input',{ this.$emit('input',{
taxonomy_id: this.taxonomy_id, taxonomy_id: this.taxonomy_id,

View File

@ -2,7 +2,7 @@
<section> <section>
<b-field <b-field
:label="$i18n.get('label_collection_related')" :label="$i18n.get('label_collection_related')"
:listen="setError()" :listen="setError"
:type="collectionType" :type="collectionType"
:message="collectionMessage"> :message="collectionMessage">
<b-select <b-select
@ -83,7 +83,9 @@
hasFields: false, hasFields: false,
loadingFields: false, loadingFields: false,
modelRepeated: 'yes', modelRepeated: 'yes',
modelSearch:[] modelSearch:[],
collectionType: '',
collectionMessage: ''
} }
}, },
watch:{ watch:{
@ -117,6 +119,17 @@
this.modelRepeated = this.value.repeated; this.modelRepeated = this.value.repeated;
} }
}, },
computed: {
setError(){
if( this.errors && this.errors.collection_id !== '' ){
this.collectionType = 'is-warning';
this.collectionMessage = this.errors.collection_id;
} else {
this.collectionType = '';
this.collectionMessage = '';
}
},
},
methods:{ methods:{
fetchCollections(){ fetchCollections(){
return axios.get('/collections') return axios.get('/collections')
@ -185,20 +198,9 @@
labelRepeated(){ labelRepeated(){
return ( this.modelRepeated === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no'); return ( this.modelRepeated === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no');
}, },
setError(){
if( this.errors && this.errors.collection_id !== '' ){
this.collectionType = 'is-warning';
this.collectionMessage = this.errors.collection_id;
} else {
this.collectionType = '';
this.collectionMessage = '';
}
},
clear(){ clear(){
if( this.errors && this.errors.collection_id ){ this.collectionType = '';
this.errors.collection_id = ''; this.collectionMessage = '';
}
}, },
emitValues(){ emitValues(){
this.$emit('input',{ this.$emit('input',{