fixes column ordering
This commit is contained in:
parent
83c645c2fb
commit
38dc4d9842
|
@ -144,8 +144,8 @@ export default {
|
|||
mounted() {
|
||||
var payload = {
|
||||
'sites': JSON.parse(this.collections),
|
||||
'column_name': this.active_column,
|
||||
'order': this.columns_order[this.active_column]}
|
||||
'active_column': this.active_column,
|
||||
'column_order': this.columns_order[this.active_column]}
|
||||
this.setSites(payload)
|
||||
if (this.url_search_text) {
|
||||
console.log('searchig for hash text: '+this.url_search_text)
|
||||
|
@ -176,10 +176,10 @@ export default {
|
|||
'getSitesForDisplay', 'getPageCount',
|
||||
]),
|
||||
...mapMutations([
|
||||
'setSites', 'setColumnOrder', 'incrementPageCount', 'setSearchText'
|
||||
'setColumnOrder', 'incrementPageCount', 'setSearchText'
|
||||
]),
|
||||
...mapActions([
|
||||
'siteSearch'
|
||||
'siteSearch', 'setSites'
|
||||
])
|
||||
},
|
||||
watched: {
|
||||
|
|
23
src/store.js
23
src/store.js
|
@ -19,14 +19,13 @@ const store = new Vuex.Store({
|
|||
sites: [],
|
||||
filtered_sites: [],
|
||||
page_count: 1,
|
||||
active_column: null,
|
||||
column_order: null
|
||||
},
|
||||
mutations: {
|
||||
setSearchText(state, text) {
|
||||
state.search_text = text
|
||||
},
|
||||
setSites(state, payload) {
|
||||
state.sites = _.sortBy(payload.sites, payload.column_name)
|
||||
},
|
||||
incrementPageCount(state) {
|
||||
state.page_count = state.page_count +1
|
||||
},
|
||||
|
@ -43,11 +42,23 @@ const store = new Vuex.Store({
|
|||
state.page_count = 1
|
||||
},
|
||||
setColumnOrder(state, payload) {
|
||||
state.sites = order_items(state.sites, payload.column_name, payload.order)
|
||||
state.filtered_sites = order_items(state.filtered_sites, payload.column_name, payload.order)
|
||||
state.active_column = payload.active_column
|
||||
state.column_order = payload.column_order
|
||||
state.sites = order_items(state.sites,
|
||||
payload.active_column,
|
||||
payload.column_order)
|
||||
state.filtered_sites = order_items(state.filtered_sites,
|
||||
payload.active_column,
|
||||
payload.column_order)
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
setSites(context, payload) {
|
||||
//state.sites = _.sortBy(payload.sites, payload.column_name)
|
||||
context.state.sites = payload.sites
|
||||
context.commit("setColumnOrder", {'active_column': payload.active_column,
|
||||
'column_order': payload.column_order})
|
||||
},
|
||||
siteSearch (context) {
|
||||
console.log('new site search')
|
||||
var api_endpoint = '/api/collections/search?fulltext_search='
|
||||
|
@ -64,6 +75,8 @@ const store = new Vuex.Store({
|
|||
console.log("merged")
|
||||
console.log(merged_results)
|
||||
context.commit("setFilteredSites", merged_results)
|
||||
context.commit("setColumnOrder", {'active_column': context.state.active_column,
|
||||
'column_order': context.state.column_order})
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
|
|
Loading…
Reference in New Issue