orders sites on mount

This commit is contained in:
buttle 2021-11-04 16:22:17 +01:00
parent 9a53ea45d0
commit c7c096d3c4
2 changed files with 10 additions and 7 deletions

View File

@ -131,8 +131,7 @@ export default {
data() { data() {
return { return {
columns_order: {'title': 'asc', 'artist': 'asc', 'collection': 'asc', 'date': 'asc'}, columns_order: {'title': 'asc', 'artist': 'asc', 'collection': 'asc', 'date': 'asc'},
active_column: 'title', active_column: 'date',
column_order: 'asc',
faSortAlphaUp: faSortAlphaUp, faSortAlphaUp: faSortAlphaUp,
faSortAlphaDown: faSortAlphaDown, faSortAlphaDown: faSortAlphaDown,
}; };
@ -144,7 +143,11 @@ export default {
}, },
mounted() { 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: { methods: {
@ -154,7 +157,7 @@ export default {
} else { } else {
this.active_column = name 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) { isActiveCol: function(name) {
return name == this.active_column ? true : false return name == this.active_column ? true : false

View File

@ -22,8 +22,8 @@ const store = new Vuex.Store({
setSearchText(state, text) { setSearchText(state, text) {
state.search_text = text state.search_text = text
}, },
setSites(state, sites) { setSites(state, payload) {
state.sites = sites state.sites = _.sortBy(payload.sites, payload.column_name)
}, },
setFilteredSites(state, filtered_site_ids) { setFilteredSites(state, filtered_site_ids) {
console.log(filtered_site_ids) console.log(filtered_site_ids)
@ -38,7 +38,7 @@ const store = new Vuex.Store({
state.filtered_sites = sites state.filtered_sites = sites
}, },
setColumnOrder(state, payload) { setColumnOrder(state, payload) {
var column_name = payload.name var column_name = payload.column_name
var order = payload.order var order = payload.order
state.sites = _.sortBy(state.sites, column_name) state.sites = _.sortBy(state.sites, column_name)
state.filtered_sites = _.sortBy(state.filtered_sites, column_name) state.filtered_sites = _.sortBy(state.filtered_sites, column_name)