TagInput for taxonomy now also sends tags to tags filters bar.

This commit is contained in:
Mateus Machado Luna 2018-07-05 13:57:56 -03:00
parent fc1f2d29cb
commit 6fc2f9f2b3
4 changed files with 21 additions and 19 deletions

View File

@ -1,7 +1,8 @@
<template> <template>
<div class="is-inline-flex"> <div
class="is-inline-flex"
v-if="filterTags != undefined && filterTags.length > 0">
<b-tag <b-tag
v-if="filterTags != undefined && filterTags.length > 0"
v-for="(filterTag, index) of filterTags" v-for="(filterTag, index) of filterTags"
:key="index" :key="index"
attached attached

View File

@ -12,7 +12,7 @@
} }
.tag { .tag {
background: none !important; background-color: white;
margin-bottom: 0 !important; margin-bottom: 0 !important;
max-width: calc(100% - 21px); max-width: calc(100% - 21px);
justify-content: flex-start; justify-content: flex-start;

View File

@ -48,10 +48,10 @@
if (filterTag.filterId == this.filter.id) { if (filterTag.filterId == this.filter.id) {
let filterIndex = this.selected.findIndex(filter => filter.label == filterTag.singleValue); let selectedIndex = this.selected.findIndex(option => option.label == filterTag.singleValue);
if (filterIndex >= 0) { if (selectedIndex >= 0) {
this.selected.splice(filterIndex, 1); this.selected.splice(selectedIndex, 1);
let values = []; let values = [];
let labels = []; let labels = [];

View File

@ -38,19 +38,18 @@
if (filterTag.filterId == this.filter.id) { if (filterTag.filterId == this.filter.id) {
// let selectedIndex = this.selected.findIndex(option => option.value == filterTag.singleValue); let selectedIndex = this.selected.findIndex(option => option.label == filterTag.singleValue);
// if (selectedIndex >= 0) { if (selectedIndex >= 0) {
this.selected.splice(selectedIndex, 1);
let values = []; let values = [];
let labels = []; let labels = [];
if( this.selected.length > 0 ){
for(let val of this.selected){ for(let val of this.selected){
if (val.label != filterTag.singleValue) {
values.push( val.value ); values.push( val.value );
labels.push( val.label ); labels.push( val.label );
} }
}
}
this.$emit('input', { this.$emit('input', {
filter: 'taginput', filter: 'taginput',
compare: 'IN', compare: 'IN',
@ -63,8 +62,8 @@
filterId: this.filter.id, filterId: this.filter.id,
value: labels value: labels
}); });
this.selectedValues();
// } }
} }
}); });
}, },
@ -96,10 +95,13 @@
watch: { watch: {
selected( value ){ selected( value ){
this.selected = value; this.selected = value;
let values = []; let values = [];
let labels = [];
if( this.selected.length > 0 ){ if( this.selected.length > 0 ){
for(let val of this.selected){ for(let val of this.selected){
values.push( val.value ); values.push( val.value );
labels.push( val.label );
} }
} }
this.$emit('input', { this.$emit('input', {
@ -111,10 +113,9 @@
terms: values terms: values
}); });
let onlyLabels = this.selected.map((selected => selected.label))
this.$eventBusSearch.$emit("sendValuesToTags", { this.$eventBusSearch.$emit("sendValuesToTags", {
filterId: this.filter.id, filterId: this.filter.id,
value: onlyLabels value: labels
}); });
} }
}, },