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>
<div class="is-inline-flex">
<div
class="is-inline-flex"
v-if="filterTags != undefined && filterTags.length > 0">
<b-tag
v-if="filterTags != undefined && filterTags.length > 0"
v-for="(filterTag, index) of filterTags"
:key="index"
attached

View File

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

View File

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

View File

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