Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
mateuswetah 2018-03-23 11:46:27 -03:00
commit a7923b0a4d
12 changed files with 45 additions and 32 deletions

View File

@ -105,7 +105,7 @@
val.push( term_id ); val.push( term_id );
axios.patch(`/item/${this.item_id}/metadata/${this.field_id}`, { axios.patch(`/item/${this.item_id}/metadata/${this.field_id}`, {
values: val, values: val,
}).then( res => { }).then( () => {
instance.$emit('newTerm', val); instance.$emit('newTerm', val);
}) })
} }

View File

@ -42,7 +42,7 @@
value: [ Number, String, Array ] value: [ Number, String, Array ]
}, },
methods: { methods: {
onChecked(option) { onChecked() {
this.$emit('blur'); this.$emit('blur');
this.onInput(this.checked) this.onInput(this.checked)
}, },

View File

@ -38,7 +38,7 @@
value: [ Number, String, Array ] value: [ Number, String, Array ]
}, },
methods: { methods: {
onChecked(option) { onChecked() {
this.$emit('blur'); this.$emit('blur');
this.onInput(this.checked) this.onInput(this.checked)
}, },

View File

@ -23,7 +23,7 @@
} }
}, },
watch: { watch: {
terms( val ){ terms(){
this.selectedValues(); this.selectedValues();
} }
}, },

View File

@ -124,23 +124,22 @@
if( this.field && this.field.multiple === 'no' ){ if( this.field && this.field.multiple === 'no' ){
let types = Object.keys( this.single_types ); let types = Object.keys( this.single_types );
let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0; let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0;
this.input_type = ( hasValue ) ? this.value.input_type : 'tainacan-category-radio'; this.setInputType( ( hasValue ) ? this.value.input_type : 'tainacan-category-radio' );
return true; return true;
} else { } else {
let types = Object.keys( this.multiple_types ); let types = Object.keys( this.multiple_types );
let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0; let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0;
this.input_type = ( hasValue ) ? this.value.input_type : 'tainacan-category-checkbox'; this.setInputType( ( hasValue ) ? this.value.input_type : 'tainacan-category-checkbox' );
return false; return false;
} }
}, },
setError(){ setError(){
if( this.errors && this.errors.taxonomy_id !== '' ){ if( this.errors && this.errors.taxonomy_id !== '' ){
this.taxonomyType = 'is-danger'; this.setErrorsAttributes( 'is-danger', this.errors.taxonomy_id );
this.taxonomyMessage = this.errors.taxonomy_id;
} else { } else {
this.taxonomyType = ''; this.setErrorsAttributes( '', '' );
this.taxonomyMessage = '';
} }
return true;
} }
}, },
data(){ data(){
@ -158,6 +157,13 @@
} }
}, },
methods: { methods: {
setInputType( input ){
this.input_type = input;
},
setErrorsAttributes( type, message ){
this.taxonomyType = type;
this.taxonomyMessage = message;
},
fetchTaxonomies(){ fetchTaxonomies(){
return axios.get('/taxonomies') return axios.get('/taxonomies')
.then(res => { .then(res => {
@ -172,7 +178,6 @@
}) })
.catch(error => { .catch(error => {
console.log(error); console.log(error);
reject(error);
}); });
}, },
labelNewTerms(){ labelNewTerms(){

View File

@ -142,15 +142,18 @@
computed: { computed: {
setError(){ setError(){
if( this.errors && this.errors.collection_id !== '' ){ if( this.errors && this.errors.collection_id !== '' ){
this.collectionType = 'is-danger'; this.setErrorsAttributes( 'is-danger', this.errors.collection_id );
this.collectionMessage = this.errors.collection_id;
} else { } else {
this.collectionType = ''; this.setErrorsAttributes( '', '' );
this.collectionMessage = '';
} }
return true;
}, },
}, },
methods:{ methods:{
setErrorsAttributes( type, message ){
this.collectionType = type;
this.collectionType = message;
},
fetchCollections(){ fetchCollections(){
return axios.get('/collections') return axios.get('/collections')
.then(res => { .then(res => {

View File

@ -83,15 +83,10 @@
this.loading = true; this.loading = true;
this.options = []; this.options = [];
let collectionId = ( this.field && this.field.field.field_type_options.collection_id ) ? this.field.field.field_type_options.collection_id : this.collection_id; let collectionId = ( this.field && this.field.field.field_type_options.collection_id ) ? this.field.field.field_type_options.collection_id : this.collection_id;
axios.get('/collection/'+collectionId+'/items') axios.get('/collection/'+collectionId+'/items?search=' + query)
.then( res => { .then( res => {
let result = [];
this.loading = false; this.loading = false;
result = res.data.filter(item => { let result = res.data;
return item.title.toLowerCase()
.indexOf(query.toLowerCase()) > -1;
});
for (let item of result) { for (let item of result) {
this.options.push({ label: item.title, value: item.id }) this.options.push({ label: item.title, value: item.id })
} }

View File

@ -45,12 +45,11 @@
computed: { computed: {
setError(){ setError(){
if( this.errors && this.errors.options !== '' ){ if( this.errors && this.errors.options !== '' ){
this.optionType = 'is-danger'; this.setErrorsAttributes( 'is-danger', this.errors.options )
this.optionMessage = this.errors.options;
} else { } else {
this.optionType = ''; this.setErrorsAttributes( '', '' )
this.optionMessage = '';
} }
return true;
} }
}, },
methods: { methods: {
@ -62,6 +61,10 @@
this.$emit('input',{ this.$emit('input',{
options: ( this.options.length > 0 ) ? this.options.join('\n') : '' options: ( this.options.length > 0 ) ? this.options.join('\n') : ''
}) })
},
setErrorsAttributes( type, message ){
this.optionType = type;
this.optionMessage = message;
} }
} }
} }

View File

@ -48,12 +48,12 @@
let msg = ''; let msg = '';
let errors = eventBus.getErrors(this.field.field.id); let errors = eventBus.getErrors(this.field.field.id);
if ( errors) { if ( errors) {
this.fieldTypeMessage = 'is-danger'; this.setFieldTypeMessage('is-danger');
for (let index in errors) { for (let index in errors) {
msg += errors[index] + '\n'; msg += errors[index] + '\n';
} }
} else { } else {
this.fieldTypeMessage = ''; this.setFieldTypeMessage('');
} }
return msg; return msg;
} }
@ -85,6 +85,9 @@
isTextInputComponent( component ){ isTextInputComponent( component ){
let array = ['tainacan-relationship','tainacan-category']; let array = ['tainacan-relationship','tainacan-category'];
return !( array.indexOf( component ) >= 0 ); return !( array.indexOf( component ) >= 0 );
},
setFieldTypeMessage( message ){
this.fieldTypeMessage = message;
} }
} }
} }

View File

@ -37,6 +37,7 @@
<script> <script>
import { tainacan as axios } from '../../../js/axios/axios' import { tainacan as axios } from '../../../js/axios/axios'
import { filter_type_mixin } from '../filter-types-mixin' import { filter_type_mixin } from '../filter-types-mixin'
import qs from 'qs';
export default { export default {
created(){ created(){
@ -95,7 +96,7 @@
promise = this.getValuesPlainText( this.field, query ); promise = this.getValuesPlainText( this.field, query );
} }
promise.then( data => { promise.then( () => {
this.isLoading = false; this.isLoading = false;
}).catch( error => { }).catch( error => {
console.log('error select', error ); console.log('error select', error );

View File

@ -53,7 +53,7 @@
} }
}, },
methods: { methods: {
loadOptions(){deleteFile loadOptions(){
let promise = null; let promise = null;
this.isLoading = true; this.isLoading = true;

View File

@ -35,12 +35,12 @@
let msg = ''; let msg = '';
let errors = eventFilterBus.getErrors( this.filter.id ); let errors = eventFilterBus.getErrors( this.filter.id );
if ( errors) { if ( errors) {
this.filterTypeMessage = 'is-danger'; this.setFilterTypeMessage('is-danger');
for (let index in errors) { for (let index in errors) {
msg += errors[index] + '\n'; msg += errors[index] + '\n';
} }
} else { } else {
this.filterTypeMessage = ''; this.setFilterTypeMessage('');
} }
return msg; return msg;
}, },
@ -61,6 +61,9 @@
eventFilterBus.$emit( 'input', ( event.field_id ) ? event : event.detail[0] ); eventFilterBus.$emit( 'input', ( event.field_id ) ? event : event.detail[0] );
router.push({ query: {} }); router.push({ query: {} });
router.push({ query: this.getPostQuery() }); router.push({ query: this.getPostQuery() });
},
setFilterTypeMessage( message ){
this.filterTypeMessage = message;
} }
} }
} }