Moves responsability of sending value to tag from each filter to parent component.

This commit is contained in:
Mateus Machado Luna 2019-10-07 12:44:01 -03:00
parent 78223b3e38
commit d5851b71b8
12 changed files with 43 additions and 103 deletions

View File

@ -155,10 +155,7 @@
instance.label = item.title;
instance.selected = item.title;
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: instance.filter.id,
value: instance.label
});
this.$emit( 'sendValuesToTags', instance.label);
})
.catch(error => {
this.$console.log(error);
@ -168,10 +165,7 @@
instance.label = metadata.value;
instance.selected = metadata.value;
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: instance.filter.id,
value: metadata.value
});
this.$emit( 'sendValuesToTags', metadata.value);
}
} else {
return false;

View File

@ -153,10 +153,7 @@
}
}
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: onlyLabels.length ? onlyLabels : this.selected,
});
this.$emit( 'sendValuesToTags', onlyLabels.length ? onlyLabels : this.selected);
},
selectedValues() {
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
@ -220,10 +217,7 @@
value: this.selected
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.selected
});
this.$emit( 'sendValuesToTags', this.selected);
this.selectedValues();
}

View File

@ -193,12 +193,8 @@
this.isValid = true;
}
if (metadata.value[0] != undefined && metadata.value[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.parseDateToNavigatorLanguage(metadata.value[0]) + ' - ' + this.parseDateToNavigatorLanguage(metadata.value[1])
});
}
if (metadata.value[0] != undefined && metadata.value[1] != undefined)
this.$emit( 'sendValuesToTags', this.parseDateToNavigatorLanguage(metadata.value[0]) + ' - ' + this.parseDateToNavigatorLanguage(metadata.value[1]));
} else {
return false;
@ -302,12 +298,8 @@
value: values
});
if (values[0] != undefined && values[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.parseDateToNavigatorLanguage(values[0]) + ' - ' + this.parseDateToNavigatorLanguage(values[1])
});
}
if (values[0] != undefined && values[1] != undefined)
this.$emit( 'sendValuesToTags', this.parseDateToNavigatorLanguage(values[0]) + ' - ' + this.parseDateToNavigatorLanguage(values[1]));
}
},
beforeDestroy() {

View File

@ -196,10 +196,7 @@
this.value = new Date(textValue);
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat)
});
this.$emit('sendValuesToTags', this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat));
}
} else {
@ -261,10 +258,7 @@
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
value: valueQuery
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat)
});
this.$emit('sendValuesToTags', this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat));
},
onChangeComparator(newComparator) {

View File

@ -98,12 +98,8 @@
value: values
});
if (values[0] != undefined && values[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: values[0] + ' - ' + values[1]
});
}
if (values[0] != undefined && values[1] != undefined)
this.$emit('sendValuesToTags', values[0] + ' - ' + values[1]);
},
selectedValues(){
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
@ -117,12 +113,8 @@
this.valueEnd = metaquery.value[1];
}
if (metaquery.value[0] != undefined && metaquery.value[1] != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.valueInit + ' - ' + this.valueEnd
});
}
if (metaquery.value[0] != undefined && metaquery.value[1] != undefined)
this.$emit( 'sendValuesToTags', this.valueInit + ' - ' + this.valueEnd);
} else {
return false;

View File

@ -85,10 +85,7 @@
if (values[0] != undefined && values[1] != undefined) {
let labelValue = this.filterTypeOptions.intervals[this.selectedInterval].label + (this.filterTypeOptions.showIntervalOnTag ? `(${values[0]}-${values[1]})` : '');
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: labelValue
});
this.$emit( 'sendValuesToTags', labelValue);
}
},
selectedValues(){
@ -113,10 +110,7 @@
);
let labelValue = this.filterTypeOptions.intervals[this.selectedInterval].label + (this.filterTypeOptions.showIntervalOnTag ? `(${this.valueInit}-${this.valueEnd})` : '');
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: labelValue
});
this.$emit( 'sendValuesToTags', labelValue);
} else {
return false;
}

View File

@ -147,12 +147,8 @@
if ( metadata.compare)
this.comparator = metadata.compare;
if (this.value != undefined) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.comparator + ' ' + this.value
});
}
if (this.value != undefined)
this.$emit('sendValuesToTags', this.comparator + ' ' + this.value);
} else {
return false;
@ -193,10 +189,7 @@
type: 'NUMERIC'
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.comparator + ' ' + this.value
});
this.$emit('sendValuesToTags', this.comparator + ' ' + this.value);
},
onChangeComparator(newComparator) {

View File

@ -78,12 +78,8 @@
mixins: [filter_type_mixin],
watch: {
selected(value) {
if (value) {
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: value
});
}
if (value)
this.$emit('sendValuesToTags', value);
}
},
computed: {

View File

@ -110,10 +110,7 @@
value: values
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: labels
});
this.$emit( 'sendValuesToTags', labels);
}
},
methods: {
@ -205,10 +202,7 @@
value: values
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: labels
});
this.$emit( 'sendValuesToTags', labels);
}
}
}

View File

@ -39,7 +39,8 @@
:filter="filter"
:query="query"
:is-repository-level="isRepositoryLevel"
@input="listen( $event )"/>
@input="onInput"
@sendValuesToTags="onSendValuesToTags"/>
</div>
</b-collapse>
</b-field>
@ -60,8 +61,16 @@
}
},
methods: {
listen( inputEvent ){
this.$eventBusSearch.$emit( 'input', ( inputEvent.metadatum_id ) ? inputEvent : inputEvent.detail[0] );
onInput(inputEvent){
this.$eventBusSearch.$emit(
'input', ( inputEvent.metadatum_id ) ? inputEvent : inputEvent.detail[0]
);
},
onSendValuesToTags(values) {
this.$eventBusSearch.$emit('sendValuesToTags', {
filterId: this.filter.id,
value: values
});
}
}
}

View File

@ -58,7 +58,7 @@
this.type = this.filter.metadatum.metadata_type;
this.loadOptions();
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTag);
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
if (this.isUsingElasticSearch)
this.$eventBusSearch.$on('isLoadingItems', this.updatesIsLoading);
@ -254,10 +254,7 @@
}
}
this.$eventBusSearch.$emit("sendValuesToTags", {
filterId: this.filter.id,
value: onlyLabels
});
this.$emit("sendValuesToTags", onlyLabels);
},
openCheckboxModal(parent) {
this.$buefy.modal.open({
@ -283,7 +280,7 @@
trapFocus: true
});
},
cleanSearchFromTag(filterTag) {
cleanSearchFromTags(filterTag) {
if (filterTag.filterId == this.filter.id) {
let selectedOption = this.options.find(option => option.label == filterTag.singleValue);
@ -304,10 +301,7 @@
terms: this.selected
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: this.selected
});
this.$emit( 'sendValuesToTags', this.selected);
this.selectedValues();
}

View File

@ -57,7 +57,7 @@
this.selectedValues( metadatum.metadata_type_options.taxonomy_id );
});
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTag);
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
},
data(){
return {
@ -101,10 +101,7 @@
terms: values
});
this.$eventBusSearch.$emit("sendValuesToTags", {
filterId: this.filter.id,
value: labels
});
this.$emit("sendValuesToTags", labels);
}
},
methods: {
@ -185,7 +182,7 @@
this.$console.log(error);
});
},
cleanSearchFromTag(filterTag) {
cleanSearchFromTags(filterTag) {
if (filterTag.filterId == this.filter.id) {
@ -209,10 +206,7 @@
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
terms: values
});
this.$eventBusSearch.$emit( 'sendValuesToTags', {
filterId: this.filter.id,
value: labels
});
this.$emit( 'sendValuesToTags', labels);
}
}
}