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