From c7c096d3c47ee45ac8f5a7ad57e865a8cf06e4fa Mon Sep 17 00:00:00 2001 From: buttle Date: Thu, 4 Nov 2021 16:22:17 +0100 Subject: [PATCH] orders sites on mount --- src/components/archiveList.vue | 11 +++++++---- src/store.js | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/archiveList.vue b/src/components/archiveList.vue index 06f4ddf..f244f4e 100644 --- a/src/components/archiveList.vue +++ b/src/components/archiveList.vue @@ -131,8 +131,7 @@ export default { data() { return { columns_order: {'title': 'asc', 'artist': 'asc', 'collection': 'asc', 'date': 'asc'}, - active_column: 'title', - column_order: 'asc', + active_column: 'date', faSortAlphaUp: faSortAlphaUp, faSortAlphaDown: faSortAlphaDown, }; @@ -144,7 +143,11 @@ export default { }, mounted() { - this.setSites(JSON.parse(this.collections)) + var payload = { + 'sites': JSON.parse(this.collections), + 'column_name': 'date', + 'order': this.columns_order['date']} + this.setSites(payload) }, methods: { @@ -154,7 +157,7 @@ export default { } else { this.active_column = name } - this.setColumnOrder({'name': name, 'order': this.columns_order[name]}) + this.setColumnOrder({'column_name': name, 'order': this.columns_order[name]}) }, isActiveCol: function(name) { return name == this.active_column ? true : false diff --git a/src/store.js b/src/store.js index fd1677e..19dadf2 100644 --- a/src/store.js +++ b/src/store.js @@ -22,8 +22,8 @@ const store = new Vuex.Store({ setSearchText(state, text) { state.search_text = text }, - setSites(state, sites) { - state.sites = sites + setSites(state, payload) { + state.sites = _.sortBy(payload.sites, payload.column_name) }, setFilteredSites(state, filtered_site_ids) { console.log(filtered_site_ids) @@ -38,7 +38,7 @@ const store = new Vuex.Store({ state.filtered_sites = sites }, setColumnOrder(state, payload) { - var column_name = payload.name + var column_name = payload.column_name var order = payload.order state.sites = _.sortBy(state.sites, column_name) state.filtered_sites = _.sortBy(state.filtered_sites, column_name)