From 38dc4d9842a2bcbed64af90ab9f04665e1973563 Mon Sep 17 00:00:00 2001 From: buttle Date: Thu, 17 Mar 2022 15:01:28 +0100 Subject: [PATCH] fixes column ordering --- src/components/archiveList.vue | 8 ++++---- src/store.js | 23 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/components/archiveList.vue b/src/components/archiveList.vue index fd427a8..a567f71 100644 --- a/src/components/archiveList.vue +++ b/src/components/archiveList.vue @@ -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: { diff --git a/src/store.js b/src/store.js index dab4358..a3bb5c6 100644 --- a/src/store.js +++ b/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);