Cancels http request on search event bus when new request are made before previous is finished.
This commit is contained in:
parent
7d952cacd9
commit
fe9fd045cb
|
@ -638,6 +638,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.$root.$off('metadatumUpdated');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -133,11 +133,13 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created(){
|
created(){
|
||||||
|
|
||||||
this.$root.$on('closeAdvancedSearchShortcut', () => {
|
this.$root.$on('closeAdvancedSearchShortcut', () => {
|
||||||
this.$refs.advancedSearchShortcut.toggle();
|
this.$refs.advancedSearchShortcut.toggle();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.$root.$off('closeAdvancedSearchShortcut');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ import Buefy from 'buefy';
|
||||||
import VTooltip from 'v-tooltip';
|
import VTooltip from 'v-tooltip';
|
||||||
import { VueHammer } from 'vue2-hammer';
|
import { VueHammer } from 'vue2-hammer';
|
||||||
import VueMasonry from 'vue-masonry-css';
|
import VueMasonry from 'vue-masonry-css';
|
||||||
|
import draggable from 'vuedraggable';
|
||||||
|
import VueTheMask from 'vue-the-mask';
|
||||||
|
|
||||||
// Custom elements
|
// Custom elements
|
||||||
import Text from '../../classes/metadata-types/text/Text.vue';
|
import Text from '../../classes/metadata-types/text/Text.vue';
|
||||||
|
@ -38,13 +40,11 @@ import TainacanFiltersList from '../../classes/filter-types/tainacan-filter-item
|
||||||
import AdminPage from '../admin.vue'
|
import AdminPage from '../admin.vue'
|
||||||
import HelpButton from '../components/other/help-button.vue';
|
import HelpButton from '../components/other/help-button.vue';
|
||||||
import TainacanTitle from '../components/navigation/tainacan-title.vue';
|
import TainacanTitle from '../components/navigation/tainacan-title.vue';
|
||||||
import draggable from 'vuedraggable'
|
|
||||||
import store from '../../js/store/store'
|
import store from '../../js/store/store'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import eventBusSearch from '../../js/event-bus-search';
|
import eventBusSearch from '../../js/event-bus-search';
|
||||||
import termsListBus from './terms-list-bus.js';
|
import termsListBus from './terms-list-bus.js';
|
||||||
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin } from './utilities';
|
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin } from './utilities';
|
||||||
import VueTheMask from 'vue-the-mask';
|
|
||||||
|
|
||||||
// Configure and Register Plugins
|
// Configure and Register Plugins
|
||||||
Vue.use(Buefy);
|
Vue.use(Buefy);
|
||||||
|
|
|
@ -1235,6 +1235,7 @@
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.$off();
|
this.$off();
|
||||||
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
window.removeEventListener('resize', this.adjustSearchControlHeight);
|
||||||
|
this.$root.$off('openAdvancedSearch');
|
||||||
|
|
||||||
// Cancels previous Request
|
// Cancels previous Request
|
||||||
if (this.$eventBusSearch.searchCancel != undefined)
|
if (this.$eventBusSearch.searchCancel != undefined)
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
this.$console.log(error);
|
this.$console.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
this.$eventBusSearch.$on('removeFromFilterTag', (filterTag) => {
|
||||||
if (filterTag.filterId == this.filter.id)
|
if (filterTag.filterId == this.filter.id)
|
||||||
this.cleanSearch();
|
this.cleanSearch();
|
||||||
|
|
|
@ -13,5 +13,6 @@ export const wp = axios.create({
|
||||||
wp.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce;
|
wp.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce;
|
||||||
|
|
||||||
export const CancelToken = axios.CancelToken;
|
export const CancelToken = axios.CancelToken;
|
||||||
|
export const isCancel = axios.isCancel;
|
||||||
|
|
||||||
export default { tainacan, wp, CancelToken };
|
export default { tainacan, wp, CancelToken, isCancel };
|
|
@ -14,8 +14,7 @@ export default {
|
||||||
termId: undefined,
|
termId: undefined,
|
||||||
searchCancel: undefined
|
searchCancel: undefined
|
||||||
},
|
},
|
||||||
created(){
|
created() {
|
||||||
|
|
||||||
this.$on('input', data => {
|
this.$on('input', data => {
|
||||||
this.$store.dispatch('search/setPage', 1);
|
this.$store.dispatch('search/setPage', 1);
|
||||||
|
|
||||||
|
@ -213,16 +212,16 @@ export default {
|
||||||
let error = this.errors.find( errorItem => errorItem.metadatum_id === filter_id );
|
let error = this.errors.find( errorItem => errorItem.metadatum_id === filter_id );
|
||||||
return ( error ) ? error.errors : false;
|
return ( error ) ? error.errors : false;
|
||||||
},
|
},
|
||||||
listener(){
|
// listener(){
|
||||||
const components = this.getAllComponents();
|
// const components = this.getAllComponents();
|
||||||
for (let eventElement of components){
|
// for (let eventElement of components){
|
||||||
eventElement.addEventListener('input', (event) => {
|
// eventElement.addEventListener('input', (event) => {
|
||||||
if( event.detail ) {
|
// if( event.detail ) {
|
||||||
this.add_metaquery( event.detail[0] );
|
// this.add_metaquery( event.detail[0] );
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
setPage(page) {
|
setPage(page) {
|
||||||
this.$store.dispatch('search/setPage', page);
|
this.$store.dispatch('search/setPage', page);
|
||||||
this.updateURLQueries();
|
this.updateURLQueries();
|
||||||
|
|
|
@ -24,21 +24,21 @@ export const eventBus = new Vue({
|
||||||
this.componentsTag.push( name );
|
this.componentsTag.push( name );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
listener(){
|
// listener(){
|
||||||
const components = this.getAllComponents();
|
// const components = this.getAllComponents();
|
||||||
for (let eventElement of components){
|
// for (let eventElement of components){
|
||||||
eventElement.addEventListener('input', (event) => {
|
// eventElement.addEventListener('input', (event) => {
|
||||||
|
|
||||||
if (event.detail && event.detail[0] ){
|
// if (event.detail && event.detail[0] ){
|
||||||
this.updateValue({
|
// this.updateValue({
|
||||||
item_id: $(eventElement).attr("item_id"),
|
// item_id: $(eventElement).attr("item_id"),
|
||||||
metadatum_id: $(eventElement).attr("metadatum_id"),
|
// metadatum_id: $(eventElement).attr("metadatum_id"),
|
||||||
values: event.detail
|
// values: event.detail
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
updateValue(data){
|
updateValue(data){
|
||||||
|
|
||||||
this.$emit('isUpdatingValue', true);
|
this.$emit('isUpdatingValue', true);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import axios, { CancelToken } from '../../../axios/axios';
|
import axios from '../../../axios/axios';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
|
|
||||||
// THE ITEMS SEARCH
|
// THE ITEMS SEARCH
|
||||||
export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, isOnTheme, termId, taxonomy }) => {
|
export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, isOnTheme, termId, taxonomy }) => {
|
||||||
commit('cleanItems');
|
commit('cleanItems');
|
||||||
|
|
||||||
const source = CancelToken.source();
|
const source = axios.CancelToken.source();
|
||||||
|
|
||||||
return new Object({
|
return new Object({
|
||||||
request: new Promise ((resolve, reject) => {
|
request: new Promise ((resolve, reject) => {
|
||||||
|
|
Loading…
Reference in New Issue