diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index 4fb816b28..8ccf1d6e1 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -291,6 +291,8 @@ display: display } ); + this.$eventBusSearch.addFetchOnlyMeta(field.id); + } } diff --git a/src/js/event-bus-search.js b/src/js/event-bus-search.js index 744f64a0f..70217fbbc 100644 --- a/src/js/event-bus-search.js +++ b/src/js/event-bus-search.js @@ -56,6 +56,9 @@ export default { this.$store.dispatch('search/add_taxquery', data ); } }, + addFetchOnlyMeta( field ){ + this.$store.dispatch('search/add_fecthonly_meta', field ); + }, getErrors( filter_id ){ let error = this.errors.find( errorItem => errorItem.field_id === filter_id ); return ( error ) ? error.errors : false diff --git a/src/js/store/modules/search/actions.js b/src/js/store/modules/search/actions.js index a2f4b87ba..d771da0d0 100644 --- a/src/js/store/modules/search/actions.js +++ b/src/js/store/modules/search/actions.js @@ -16,6 +16,23 @@ export const add_metaquery = ( { commit }, filter ) => { } }; +// Fetch Only for item attributes limiting on results +export const add_fetchonly = ( { commit }, field ) => { + if( field && field.length === 0 ){ + commit('removeFetchOnly', field ); + } else { + commit('addFetchOnly', field ); + } +}; +// Fetch Only for metadata limiting on results +export const add_fetchonly_meta = ( { commit }, field ) => { + if( field && field.length === 0 ){ + commit('removeFetchOnlyMeta', field ); + } else { + commit('addFetchOnlyMeta', field ); + } +}; + // Tax Queries from filters export const add_taxquery = ( { commit }, filter ) => { if( filter && filter.terms.length === 0 ){ diff --git a/src/js/store/modules/search/getters.js b/src/js/store/modules/search/getters.js index 89f1e16f8..01825e0f4 100644 --- a/src/js/store/modules/search/getters.js +++ b/src/js/store/modules/search/getters.js @@ -34,6 +34,11 @@ export const getSearchQuery = state => { return state.postquery.search; } +<<<<<<< HEAD export const getStatus = state => { return state.postquery.status; +======= +export const getFecthOnly = state => { + return state.postquery.fetchonly; +>>>>>>> Begins implementation of FetchOnly for displayed fields in item page. } \ No newline at end of file diff --git a/src/js/store/modules/search/index.js b/src/js/store/modules/search/index.js index 70aa98282..ebfe67895 100644 --- a/src/js/store/modules/search/index.js +++ b/src/js/store/modules/search/index.js @@ -10,6 +10,9 @@ const state = { perpage: 12, status: '', search: '', + fetchonly: [ + {'meta': [] } + ], post_type: [], metaquery: [], taxquery: [] diff --git a/src/js/store/modules/search/mutations.js b/src/js/store/modules/search/mutations.js index 5a985ce11..60a451214 100644 --- a/src/js/store/modules/search/mutations.js +++ b/src/js/store/modules/search/mutations.js @@ -46,6 +46,25 @@ export const addTaxQuery = ( state, filter ) => { } }; +export const addFetchOnly = ( state, field ) => { + state.postquery.fechonly = ( ! state.postquery.fechonly ) ? [{'meta': []}] : state.postquery.fechonly; + let index = state.postquery.fechonly.findIndex( item => item === field); + if ( index >= 0 ){ + Vue.set( state.postquery.fechonly, index, field); + } else { + state.postquery.fechonly.push(field); + } +}; +export const addFetchOnlyMeta = ( state, field ) => { + state.postquery.fechonly['meta'] = ( ! state.postquery.fechonly['meta'] ) ? [] : state.postquery.fechonly['meta']; + let index = state.postquery.fechonly['meta'].findIndex( item => item === field); + if ( index >= 0 ){ + Vue.set( state.postquery.fechonly['meta'], index, field); + } else { + state.postquery.fechonly['meta'].push(field); + } +}; + export const removeMetaQuery = ( state, filter ) => { let index = state.postquery.metaquery.findIndex( item => item.key === filter.field_id); if (index >= 0) { @@ -60,8 +79,25 @@ export const removeTaxQuery = ( state, filter ) => { } }; +<<<<<<< HEAD export const removePostQueryAttribute = ( state, attribute) => { Vue.set( state.postquery, attribute , ''); +======= +export const removeFetchOnly = ( state, field ) => { + let index = state.postquery.fetchonly.findIndex( item => item === field); + if (index >= 0) { + state.postquery.metaquery.splice(index, 1); + } +}; + +export const removeFetchOnlyMeta = ( state, field ) => { + if(state.postquery.fetchonly['meta'] != undefined) { + let index = state.postquery.fetchonly['meta'].findIndex( item => item === field); + if (index >= 0) { + state.postquery.metaquery.splice(index, 1); + } + } +>>>>>>> Begins implementation of FetchOnly for displayed fields in item page. }; export const setTotalItems = ( state, total ) => { @@ -72,6 +108,11 @@ export const setSearchQuery = ( state, searchQuery ) => { state.postquery.search = searchQuery; }; +<<<<<<< HEAD export const setStatus = ( state, status ) => { state.status = status; +======= +export const setSearchQueryMeta = ( state, searchQueryMeta ) => { + state.postquery.search['meta'] = searchQueryMeta; +>>>>>>> Begins implementation of FetchOnly for displayed fields in item page. }; \ No newline at end of file