Fixes conflict with advanced search and simple search

Removes simple search when doing advanced search
Refactoring removePostQuery method
This commit is contained in:
weryques 2018-10-17 10:15:05 -03:00
parent b75109315d
commit c7f9f4f549
3 changed files with 29 additions and 51 deletions

33
package-lock.json generated
View File

@ -1421,15 +1421,6 @@
"util.promisify": "^1.0.0"
}
},
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@ -2243,11 +2234,6 @@
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=",
"dev": true
},
"core-js": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz",
"integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs="
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
@ -4373,11 +4359,6 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"hammerjs": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz",
"integrity": "sha1-BO93hiz/K7edMPdpIJWTAiK/YPE="
},
"handle-thing": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz",
@ -6945,11 +6926,6 @@
}
}
},
"regenerator-runtime": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz",
"integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A=="
},
"regenerator-transform": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.13.3.tgz",
@ -8997,15 +8973,6 @@
"resolved": "https://registry.npmjs.org/vue-the-mask/-/vue-the-mask-0.11.1.tgz",
"integrity": "sha512-UquSfnSWejD0zAfcD+3jJ1chUAkOAyoxya9Lxh9acCRtrlmGcAIvd0cQYraWqKenbuZJUdum+S174atv2AuEHQ=="
},
"vue2-hammer": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/vue2-hammer/-/vue2-hammer-2.0.1.tgz",
"integrity": "sha512-JDNHFKgc0tPGyreFfzC1cBIAtAb2lXr7b98zqHErgM/OeDlGa9Axv0iUc6UfvZ06ZuG98D2mvkG1G3tBQIzmXg==",
"requires": {
"babel-runtime": "^6.26.0",
"hammerjs": "^2.0.8"
}
},
"vuedraggable": {
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-2.16.0.tgz",

View File

@ -8,6 +8,7 @@ export const set_postquery = ({ commit }, postquery ) => {
};
export const set_advanced_query = ({commit}, advancedSearchQuery) => {
commit('removePostQueryAttribute', 'search');
commit('setAdvancedSearchQuery', advancedSearchQuery);
};
@ -74,7 +75,7 @@ export const setStatus= ({ commit }, status ) => {
// Sorting queries
export const setOrderBy = ({ state, commit }, orderBy ) => {
commit('cleanPostQueryAttribute', { attr: 'orderby' } );
commit('removePostQueryAttribute', 'orderby');
// Primitive Types: string, date, item, term, compound, float
if (orderBy.slug == 'creation_date') {

View File

@ -4,8 +4,8 @@ export const setPostQueryAttribute = ( state, { attr, value }) => {
Vue.set( state.postquery, attr , value );
};
export const cleanPostQueryAttribute = ( state, { attr }) => {
Vue.set( state.postquery, attr , null );
export const removePostQueryAttribute = ( state, attr) => {
delete state.postquery[`${attr}`];
};
export const setPostQuery = ( state, postquery ) => {
@ -30,7 +30,7 @@ export const addMetaQuery = ( state, filter ) => {
compare: filter.compare,
type: filter.type
} );
} else{
} else {
state.postquery.metaquery.push({
key: filter.metadatum_id,
value: filter.value,
@ -42,14 +42,16 @@ export const addMetaQuery = ( state, filter ) => {
export const addTaxQuery = ( state, filter ) => {
state.postquery.taxquery = ( ! state.postquery.taxquery || state.postquery.taxquery.length == undefined ) ? [] : state.postquery.taxquery;
let index = state.postquery.taxquery.findIndex( item => item.taxonomy === filter.taxonomy);
if ( index >= 0 ){
Vue.set( state.postquery.taxquery, index, {
taxonomy: filter.taxonomy,
terms: filter.terms,
compare: filter.compare
} );
}else{
} else {
state.postquery.taxquery.push({
taxonomy: filter.taxonomy,
terms: filter.terms,
@ -68,11 +70,13 @@ export const addFetchOnly = ( state, metadatum ) => {
};
export const addFetchOnlyMeta = ( state, metadatum ) => {
state.postquery.fetch_only = ( ! state.postquery.fetch_only ) ? { '0': 'thumbnail', 'meta': [], '1': 'creation_date', '2': 'author_name' } : state.postquery.fetch_only;
// console.log(state.postquery.fetch_only);
// console.log(state.postquery.fetch_only);
//console.log(state.postquery.fetch_only['meta']);
state.postquery.fetch_only['meta'] = ( ! state.postquery.fetch_only['meta'] ) ? [] : state.postquery.fetch_only['meta'];
let index = state.postquery.fetch_only['meta'].findIndex( item => item == metadatum);
if ( index >= 0 ){
if ( index >= 0 ){
state.postquery.fetch_only['meta'][index] = metadatum;
} else {
state.postquery.fetch_only['meta'].push(metadatum);
@ -90,6 +94,7 @@ export const removeFetchOnly = ( state, metadatum ) => {
export const removeFetchOnlyMeta = ( state, metadatum ) => {
if(state.postquery.fetch_only['meta'] != undefined) {
let index = state.postquery.fetch_only['meta'].findIndex( item => item == metadatum);
if (index >= 0) {
state.postquery.fetch_only['meta'].splice(index, 1);
}
@ -98,7 +103,9 @@ export const removeFetchOnlyMeta = ( state, metadatum ) => {
export const removeMetaQuery = ( state, filter ) => {
state.postquery.metaquery = ( ! state.postquery.metaquery ) ? [] : state.postquery.metaquery;
let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id);
if (index >= 0) {
state.postquery.metaquery.splice(index, 1);
}
@ -106,15 +113,12 @@ export const removeMetaQuery = ( state, filter ) => {
export const removeTaxQuery = ( state, filter ) => {
let index = state.postquery.taxquery.findIndex( item => item.taxonomy == filter.taxonomy);
if (index >= 0) {
state.postquery.taxquery.splice(index, 1);
}
};
export const removePostQueryAttribute = ( state, attribute) => {
Vue.set( state.postquery, attribute , '');
};
export const setTotalItems = ( state, total ) => {
state.totalItems = total;
};
@ -125,10 +129,11 @@ export const setTotalPages = ( state, totalPages ) => {
export const setSearchQuery = ( state, searchQuery ) => {
if (searchQuery != '')
if (searchQuery != '') {
state.postquery.search = searchQuery;
else
state.postquery.search = undefined;
} else {
delete state.postquery.search;
}
};
export const setStatus = ( state, status ) => {
@ -145,16 +150,21 @@ export const setAdminViewMode = ( state, adminViewMode ) => {
export const addFilterTag = ( state, filterTag ) => {
state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags;
let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId);
if ( index >= 0 )
Vue.set( state.filter_tags, index, filterTag );
else
if ( index >= 0 ) {
Vue.set(state.filter_tags, index, filterTag);
} else {
state.filter_tags.push(filterTag);
}
};
export const removeFilterTag = ( state, filterTag ) => {
state.filter_tags = ( ! state.filter_tags ) ? [] : state.filter_tags;
let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId);
if (index >= 0) {
state.filter_tags.splice(index, 1);
}
@ -173,5 +183,5 @@ export const cleanTaxQueries = (state) => {
};
export const cleanFetchOnly = (state) => {
state.postquery.fetch_only = undefined;
delete state.postquery.fetch_only;
};