From 2be88b8fa497a772898d843d8550398b832a404a Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 25 Mar 2020 10:48:46 -0300 Subject: [PATCH] Solves issue where page was reset to one after leaving items list. This was caused by the event bus, now the responsability of reseting the page when a filter is clicked is handled by each filter component. #375. --- .../filter-types/autocomplete/Autocomplete.vue | 2 +- .../components/filter-types/checkbox/Checkbox.vue | 1 + .../filter-types/date-interval/DateInterval.vue | 2 +- .../admin/components/filter-types/date/Date.vue | 4 ++-- .../numeric-interval/NumericInterval.vue | 4 ++-- .../numeric-list-interval/NumericListInterval.vue | 2 +- .../components/filter-types/numeric/Numeric.vue | 4 ++-- .../filter-types/selectbox/Selectbox.vue | 2 +- .../components/filter-types/taginput/Taginput.vue | 2 +- .../components/filter-types/taxonomy/Checkbox.vue | 5 +++-- .../components/filter-types/taxonomy/Taginput.vue | 2 +- .../components/modals/checkbox-radio-modal.vue | 14 ++++++++++++-- .../admin/components/search/filters-tags-list.vue | 3 ++- src/views/admin/js/event-bus-search.js | 6 ++++-- src/views/admin/js/filter-types-mixin.js | 5 +++++ 15 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/views/admin/components/filter-types/autocomplete/Autocomplete.vue b/src/views/admin/components/filter-types/autocomplete/Autocomplete.vue index 1672c768d..04607d96f 100644 --- a/src/views/admin/components/filter-types/autocomplete/Autocomplete.vue +++ b/src/views/admin/components/filter-types/autocomplete/Autocomplete.vue @@ -8,7 +8,7 @@ :data="options" expanded :loading="isLoadingOptions" - @input="search" + @input="($event) => { resetPage(); search($event); }" field="label" @select="onSelect" clearable diff --git a/src/views/admin/components/filter-types/checkbox/Checkbox.vue b/src/views/admin/components/filter-types/checkbox/Checkbox.vue index 69460b45b..b7a2c2c2d 100644 --- a/src/views/admin/components/filter-types/checkbox/Checkbox.vue +++ b/src/views/admin/components/filter-types/checkbox/Checkbox.vue @@ -14,6 +14,7 @@ diff --git a/src/views/admin/components/filter-types/date-interval/DateInterval.vue b/src/views/admin/components/filter-types/date-interval/DateInterval.vue index a72df606b..0897f1da0 100644 --- a/src/views/admin/components/filter-types/date-interval/DateInterval.vue +++ b/src/views/admin/components/filter-types/date-interval/DateInterval.vue @@ -5,7 +5,7 @@ :placeholder="$i18n.get('label_selectbox_init')" v-model="dateInit" @focus="isTouched = true" - @input="validadeValues()" + @input="($event) => { resetPage(); validadeValues($event) }" editable :trap-focus="false" :date-formatter="(date) => dateFormatter(date)" diff --git a/src/views/admin/components/filter-types/date/Date.vue b/src/views/admin/components/filter-types/date/Date.vue index a7811345c..a51c3e29a 100644 --- a/src/views/admin/components/filter-types/date/Date.vue +++ b/src/views/admin/components/filter-types/date/Date.vue @@ -2,7 +2,7 @@
diff --git a/src/views/admin/components/filter-types/selectbox/Selectbox.vue b/src/views/admin/components/filter-types/selectbox/Selectbox.vue index f905c52a4..dce98c523 100644 --- a/src/views/admin/components/filter-types/selectbox/Selectbox.vue +++ b/src/views/admin/components/filter-types/selectbox/Selectbox.vue @@ -6,7 +6,7 @@ v-if="!isLoadingOptions" :value="selected" :aria-labelledby="'filter-label-id-' + filter.id" - @input="onSelect($event)" + @input="($event) => { resetPage(); onSelect($event) }" :placeholder="$i18n.get('label_selectbox_init')" expanded> diff --git a/src/views/admin/components/filter-types/taginput/Taginput.vue b/src/views/admin/components/filter-types/taginput/Taginput.vue index f1641e33f..a547e6a11 100644 --- a/src/views/admin/components/filter-types/taginput/Taginput.vue +++ b/src/views/admin/components/filter-types/taginput/Taginput.vue @@ -11,7 +11,7 @@ :remove-on-keys="[]" field="label" attached - @input="onSelect" + @input="($event) => { resetPage(); onSelect($event) }" @typing="search" :aria-close-label="$i18n.get('remove_value')" :aria-labelledby="'filter-label-id-' + filter.id" diff --git a/src/views/admin/components/filter-types/taxonomy/Checkbox.vue b/src/views/admin/components/filter-types/taxonomy/Checkbox.vue index 9f05ca9c2..bb003d114 100644 --- a/src/views/admin/components/filter-types/taxonomy/Checkbox.vue +++ b/src/views/admin/components/filter-types/taxonomy/Checkbox.vue @@ -20,6 +20,7 @@ class="b-checkbox checkbox is-small"> @@ -78,7 +79,6 @@ const isEqual = (newVal.length == oldVal.length) && newVal.every((element, index) => { return element === oldVal[index]; }); - if (!isEqual) this.onSelect(); }, @@ -257,7 +257,8 @@ this.$emit('sendValuesToTags', { label: onlyLabels, taxonomy: this.taxonomy, value: this.selected }); }, - onSelect(){ + onSelect() { + this.$emit('input', { filter: 'checkbox', taxonomy: this.taxonomy, diff --git a/src/views/admin/components/filter-types/taxonomy/Taginput.vue b/src/views/admin/components/filter-types/taxonomy/Taginput.vue index a30ed273e..67d6153f8 100644 --- a/src/views/admin/components/filter-types/taxonomy/Taginput.vue +++ b/src/views/admin/components/filter-types/taxonomy/Taginput.vue @@ -15,7 +15,7 @@ :aria-labelledby="'filter-label-id-' + filter.id" :class="{'has-selected': selected != undefined && selected != []}" @typing="search" - @input="onSelect" + @input="($event) => { resetPage(); onSelect($event) }" :placeholder="$i18n.get('info_type_to_add_terms')" check-infinite-scroll @infinite-scroll="searchMore"> diff --git a/src/views/admin/components/modals/checkbox-radio-modal.vue b/src/views/admin/components/modals/checkbox-radio-modal.vue index 78f2a21cf..9e79c07fb 100644 --- a/src/views/admin/components/modals/checkbox-radio-modal.vue +++ b/src/views/admin/components/modals/checkbox-radio-modal.vue @@ -690,6 +690,8 @@ applyFilter() { this.$parent.close(); + this.$eventBusSearch.resetPageOnStore(); + if (this.isTaxonomy && this.isFilter) { this.$eventBusSearch.$emit('input', { filter: 'checkbox', @@ -756,7 +758,15 @@ .tainacan-modal-content { width: auto; - min-height: 600px; + min-height: 550px; + + .b-tabs { + margin-bottom: 0 !important; + + .tab-content { + padding: 0.5em; + } + } } .tainacan-modal-title { @@ -847,7 +857,7 @@ display: flex; overflow: auto; padding: 0 !important; - min-height: 253px; + min-height: 232px; max-height: 35vh; &:focus { diff --git a/src/views/admin/components/search/filters-tags-list.vue b/src/views/admin/components/search/filters-tags-list.vue index 3674fb676..32c66f49b 100644 --- a/src/views/admin/components/search/filters-tags-list.vue +++ b/src/views/admin/components/search/filters-tags-list.vue @@ -45,6 +45,7 @@ 'getFilterTags' ]), removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId }) { + this.$eventBusSearch.resetPageOnStore(); this.$eventBusSearch.removeMetaFromFilterTag({ filterId: filterId, singleLabel: singleLabel, @@ -55,7 +56,7 @@ }); }, clearAllFilters() { - // this.$eventBusSearch.clearAllFilters(); + this.$eventBusSearch.resetPageOnStore(); for (let tag of this.filterTags) { this.removeMetaQuery(tag); } diff --git a/src/views/admin/js/event-bus-search.js b/src/views/admin/js/event-bus-search.js index b7306918b..b99aa5be3 100644 --- a/src/views/admin/js/event-bus-search.js +++ b/src/views/admin/js/event-bus-search.js @@ -15,8 +15,6 @@ export default { }, created() { this.$on('input', data => { - - this.$store.dispatch('search/setPage', 1); if (data.taxonomy) this.addTaxquery(data); else @@ -235,6 +233,10 @@ export default { this.$store.dispatch('search/setPage', page); this.updateURLQueries(); }, + resetPageOnStore() { + console.log('resetei') + this.$store.dispatch('search/setPage', 1); + }, setItemsPerPage(itemsPerPage) { this.$store.dispatch('search/setItemsPerPage', itemsPerPage); this.updateURLQueries(); diff --git a/src/views/admin/js/filter-types-mixin.js b/src/views/admin/js/filter-types-mixin.js index fde47c81a..a77b71da5 100644 --- a/src/views/admin/js/filter-types-mixin.js +++ b/src/views/admin/js/filter-types-mixin.js @@ -25,6 +25,11 @@ export const filterTypeMixin = { this.metadatumId = this.filter.metadatum.metadatum_id ? this.filter.metadatum.metadatum_id : this.metadatumId; this.filterTypeOptions = this.filter.filter_type_options ? this.filter.filter_type_options : this.filterTypeOptions; this.metadatumType = this.filter.metadatum.metadata_type_object && this.filter.metadatum.metadata_type_object.className ? this.filter.metadatum.metadata_type_object.className : this.metadatumType; + }, + methods: { + resetPage() { + this.$eventBusSearch.resetPageOnStore() + } } };