Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
967d096de1
|
@ -95,8 +95,6 @@ export default {
|
|||
isRepositoryLevel: false,
|
||||
tableFields: [],
|
||||
prefTableFields: [],
|
||||
page: 1,
|
||||
itemsPerPage: 12,
|
||||
isLoading: false
|
||||
}
|
||||
},
|
||||
|
@ -119,7 +117,10 @@ export default {
|
|||
'getFields'
|
||||
]),
|
||||
...mapGetters('search', [
|
||||
'getTotalItems'
|
||||
'getPostQuery',
|
||||
'getTotalItems',
|
||||
'getPage',
|
||||
'getItemsPerPage'
|
||||
]),
|
||||
...mapActions('fields', [
|
||||
'fetchFields'
|
||||
|
@ -129,6 +130,8 @@ export default {
|
|||
]),
|
||||
...mapActions('search', [
|
||||
'set_postquery',
|
||||
'setPage',
|
||||
'setItemsPerPage',
|
||||
'search_by_collection'
|
||||
]),
|
||||
onChangeTableFields(field) {
|
||||
|
@ -150,16 +153,22 @@ export default {
|
|||
//this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, prevValue);
|
||||
},
|
||||
onChangeItemsPerPage(value) {
|
||||
if( this.itemsPerPage == value){
|
||||
return false;
|
||||
}
|
||||
|
||||
let prevValue = this.itemsPerPage;
|
||||
this.itemsPerPage = value;
|
||||
this.setItemsPerPage( value );
|
||||
this.$userPrefs.set('items_per_page', value, prevValue);
|
||||
this.alterQueryString();
|
||||
this.loadItems();
|
||||
},
|
||||
onPageChange(page) {
|
||||
if(page == 0)
|
||||
return;
|
||||
|
||||
this.page = page;
|
||||
this.setPage( page );
|
||||
this.alterQueryString();
|
||||
this.loadItems();
|
||||
},
|
||||
loadItems() {
|
||||
|
@ -167,16 +176,17 @@ export default {
|
|||
let promisse = null;
|
||||
|
||||
if( Object.keys( this.$route.query ).length > 0 ) {
|
||||
this.page = ( this.$route.query.page ) ? this.$route.query.page : this.page;
|
||||
this.itemsPerPage = ( this.$route.query.itemsPerPage ) ? this.$route.query.itemsPerPage : this.itemsPerPage;
|
||||
this.set_postquery(this.$route.query);
|
||||
if (this.$route.params && this.$route.params.collectionId) {
|
||||
promisse = this.search_by_collection(this.$route.params.collectionId);
|
||||
}
|
||||
}
|
||||
|
||||
if(!promisse)
|
||||
if(!promisse){
|
||||
promisse = this.fetchItems({ 'collectionId': this.collectionId, 'page': this.page, 'itemsPerPage': this.itemsPerPage });
|
||||
this.alterQueryString();
|
||||
}
|
||||
|
||||
|
||||
promisse.then((res) => {
|
||||
this.isLoading = false;
|
||||
|
@ -195,6 +205,10 @@ export default {
|
|||
return 0;
|
||||
|
||||
return ( this.itemsPerPage * ( this.page - 1 ) + 1)
|
||||
},
|
||||
alterQueryString(){
|
||||
this.$router.push({ query: {} });
|
||||
this.$router.push({ query: this.getPostQuery() });
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -203,6 +217,12 @@ export default {
|
|||
},
|
||||
totalItems(){
|
||||
return this.getTotalItems();
|
||||
},
|
||||
page(){
|
||||
return this.getPage();
|
||||
},
|
||||
itemsPerPage(){
|
||||
return this.getItemsPerPage();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
|
|
@ -189,7 +189,7 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
$user_id = $user->ID;
|
||||
$metas = $field_name === 'meta' ? $meta : '';
|
||||
$metas = $field_name === 'meta' ? $meta : [];
|
||||
|
||||
$map = [
|
||||
'metakey',
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
size="is-small"
|
||||
closable
|
||||
@close="clearSearch()">
|
||||
{{ selected }}
|
||||
{{ results }}
|
||||
</b-tag>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -120,16 +120,16 @@
|
|||
axios.get('/collection/' + collectionTarget + '/items?' + query)
|
||||
.then( res => {
|
||||
for (let item of res.data) {
|
||||
instance.selected.push({ label: item.title, value: item.id, img: '' });
|
||||
// instance.selected.push({ label: item.title, value: item.id, img: '' });
|
||||
console.log(item.title);
|
||||
instance.results = item.title;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
} else {
|
||||
for (let item of metadata.value) {
|
||||
instance.selected.push({ label: item, value: item, img: '' });
|
||||
}
|
||||
instance.results = metadata.value;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -135,6 +135,11 @@
|
|||
if( metadata.value.length > 0 && this.type === 'numeric'){
|
||||
this.value_init = metadata.value[0];
|
||||
this.value_end = metadata.value[1];
|
||||
this.isValid = true;
|
||||
} else if( metadata.value.length > 0 ){
|
||||
this.date_init = new Date( metadata.value[0] );
|
||||
this.date_end = new Date( metadata.value[1] );
|
||||
|
||||
this.isValid = true;
|
||||
}
|
||||
|
||||
|
@ -189,7 +194,7 @@
|
|||
filter: 'range',
|
||||
type: type,
|
||||
compare: 'BETWEEN',
|
||||
field_id: ( vm.field_id ) ? vm.field_id : vm.filter.field,
|
||||
field_id: vm.field,
|
||||
collection_id: ( vm.collection_id ) ? vm.collection_id : vm.filter.collection_id,
|
||||
value: values
|
||||
});
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<script>
|
||||
import { eventFilterBus } from '../../js/event-bus-filters'
|
||||
import qs from 'qs';
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import router from '../../admin/js/router'
|
||||
|
||||
export default {
|
||||
name: 'TainacanFiltersList',
|
||||
|
@ -49,10 +51,17 @@
|
|||
|
||||
},
|
||||
methods: {
|
||||
...mapActions('search', [
|
||||
'setPage'
|
||||
]),
|
||||
...mapGetters('search', [
|
||||
'getPostQuery'
|
||||
]),
|
||||
listen( event ){
|
||||
eventFilterBus.$emit( 'input', ( event.detail ) ? event.detail[0] : event );
|
||||
let query = JSON.parse( JSON.stringify( this.query ) );
|
||||
this.$router.push({ query: query })
|
||||
this.setPage(1);
|
||||
eventFilterBus.$emit( 'input', ( event.field_id ) ? event : event.detail[0] );
|
||||
router.push({ query: {} });
|
||||
router.push({ query: this.getPostQuery() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,16 +348,10 @@ class Collections extends Repository {
|
|||
$caps = ['read'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $caps;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -14,8 +14,8 @@ export const eventFilterBus = new Vue({
|
|||
methods: {
|
||||
add_metaquery( data ){
|
||||
if ( data && data.collection_id ){
|
||||
this.$store.dispatch('search/add_metaquery', data );
|
||||
const promisse = this.$store.dispatch('search/search_by_collection', data.collection_id );
|
||||
store.dispatch('search/add_metaquery', data );
|
||||
const promisse = store.dispatch('search/search_by_collection', data.collection_id );
|
||||
promisse.then( response => {
|
||||
|
||||
}, error => {
|
||||
|
|
|
@ -41,3 +41,11 @@ export const remove_metaquery = ( { commit }, filter ) => {
|
|||
export const setTotalItems = ({ commit }, total ) => {
|
||||
commit('setTotalItems', total);
|
||||
};
|
||||
|
||||
export const setPage = ({ commit }, page ) => {
|
||||
commit('setPostQueryAttribute', { attr: 'paged', value: page } );
|
||||
};
|
||||
|
||||
export const setItemsPerPage = ({ commit }, page ) => {
|
||||
commit('setPostQueryAttribute', { attr: 'perpage', value: page } );
|
||||
};
|
|
@ -13,3 +13,11 @@ export const getTaxQuery = state => {
|
|||
export const getTotalItems = state => {
|
||||
return state.totalItems;
|
||||
}
|
||||
|
||||
export const getPage = state => {
|
||||
return state.postquery.paged;
|
||||
}
|
||||
|
||||
export const getItemsPerPage = state => {
|
||||
return state.postquery.perpage;
|
||||
};
|
|
@ -4,6 +4,8 @@ import * as mutations from './mutations';
|
|||
|
||||
const state = {
|
||||
postquery: {
|
||||
paged: 1,
|
||||
perpage: 12,
|
||||
post_type: [],
|
||||
metaquery: [],
|
||||
taxquery: []
|
||||
|
|
|
@ -9,6 +9,7 @@ export const setPostQuery = ( state, postquery ) => {
|
|||
};
|
||||
|
||||
export const addMetaQuery = ( state, filter ) => {
|
||||
state.postquery.metaquery = ( ! state.postquery.metaquery ) ? [] : state.postquery.metaquery;
|
||||
let index = state.postquery.metaquery.findIndex( item => item.key === filter.field_id);
|
||||
if ( index >= 0 ){
|
||||
Vue.set( state.postquery.metaquery, index, {
|
||||
|
|
Loading…
Reference in New Issue