Fixes checkbox filter modal.

This commit is contained in:
mateuswetah 2022-05-03 11:18:22 -03:00
parent 7f7deab0be
commit 140845de42
5 changed files with 34 additions and 12 deletions

View File

@ -43,7 +43,13 @@
:is-modal="false"
:filter="filter"
:selected="selected"
@input="(newSelected) => selected = newSelected"
@input="(newSelected) => {
const existingValue = selected.indexOf(newSelected);
if (existingValue >= 0)
selected.splice(existingValue, 1);
else
selected.push(newSelected);
}"
:metadatum-id="metadatumId"
:collection-id="collectionId"
:metadatum_type="metadatumType"
@ -73,10 +79,9 @@
},
watch: {
selected(newVal, oldVal) {
const isEqual = (newVal.length == oldVal.length) && newVal.every((element, index) => {
const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => {
return element === oldVal[index];
});
if (!isEqual)
this.onSelect();
},
@ -89,7 +94,7 @@
},
},
mounted() {
if (!this.isUsingElasticSearch && !this.filtersAsModal)
if (!this.isUsingElasticSearch)
this.loadOptions();
},
created() {

View File

@ -51,7 +51,13 @@
:filter="filter"
:taxonomy_id="taxonomyId"
:selected="selected"
@input="(newSelected) => selected = newSelected"
@input="(newSelected) => {
const existingValue = selected.indexOf(newSelected);
if (existingValue >= 0)
selected.splice(existingValue, 1);
else
selected.push(newSelected);
}"
:metadatum-id="metadatumId"
:taxonomy="taxonomy"
:collection-id="collectionId"
@ -94,7 +100,7 @@
},
watch: {
selected(newVal, oldVal) {
const isEqual = (newVal.length == oldVal.length) && newVal.every((element, index) => {
const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => {
return element === oldVal[index];
});
if (!isEqual)
@ -127,7 +133,7 @@
this.$eventBusSearch.$on('has-to-reload-facets', this.reloadOptions);
},
mounted(){
if (!this.isUsingElasticSearch && !this.filtersAsModal)
if (!this.isUsingElasticSearch)
this.loadOptions();
},
beforeDestroy() {

View File

@ -65,6 +65,7 @@
<input
@input="$emit('input', $event.target.value)"
:value="option.id ? (isNaN(Number(option.id)) ? option.id : Number(option.id)) : (isNaN(Number(option.value)) ? option.value : Number(option.value))"
:checked="isOptionSelected(option.value)"
type="checkbox">
<span class="check" />
<span class="control-label">
@ -125,6 +126,7 @@
<input
@input="$emit('input', $event.target.value)"
:value="option.value"
:checked="isOptionSelected(option.value)"
type="checkbox">
<span class="check" />
<span class="control-label">
@ -189,6 +191,7 @@
<input
@input="$emit('input', $event.target.value)"
:value="(isNaN(Number(option.value)) ? option.value : Number(option.value))"
:checked="isOptionSelected(option.value)"
type="checkbox">
<span class="check" />
<span class="control-label">
@ -791,6 +794,12 @@
});
}
},
isOptionSelected(optionValue) {
if (Array.isArray(this.selected))
return this.selected.find(aSelected => aSelected == optionValue)
else
return optionValue == this.selected;
},
applyFilter() {
if (this.isModal)
this.$parent.close();

View File

@ -17,7 +17,7 @@
</p>
<div
class="swiper"
id="tainacanFilterTagsSwiper">
:id="'tainacanFilterTagsSwiper' + (isInsideModal ? 'InsideModal' : '')">
<ul class="swiper-wrapper">
<li
v-for="(filterTag, index) of filterTags"
@ -82,6 +82,9 @@
export default {
name: 'FiltersTagsList',
props: {
isInsideModal: Boolean
},
data() {
return {
swiper: {}
@ -133,7 +136,7 @@
},
mounted() {
this.$nextTick(() => {
this.swiper = new Swiper('#tainacanFilterTagsSwiper', {
this.swiper = new Swiper('#tainacanFilterTagsSwiper' + (this.isInsideModal ? 'InsideModal' : ''), {
mousewheel: true,
observer: true,
resizeObserver: true,

View File

@ -409,9 +409,8 @@
<!-- FILTERS TAG LIST-->
<filters-tags-list
class="filter-tags-list"
v-if="!filtersAsModal &&
!hideFilters &&
hasFiltered &&
:is-inside-modal="filtersAsModal"
v-if="hasFiltered &&
!openAdvancedSearch &&
!(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen)" />