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