Skip to content
Snippets Groups Projects
Commit 6fc99e75 authored by Simon Malesys's avatar Simon Malesys
Browse files

Sort the tables alwayd ensure the same order

parent d1f63557
No related branches found
No related tags found
1 merge request!88Update frontend
......@@ -2,6 +2,8 @@
// across components.
// https://v2.nuxt.com/docs/directory-structure/store
const _ = require('lodash');
export const state = () => ({
initTables: {}
})
......@@ -38,24 +40,23 @@ export const mutations = {
export const actions = {
async fetchTables({ commit }) {
const initTables = {}
const initTables = []
return await this.$axios.$get('/tables')
.then((initTablesList) => {
const initMetaRequests = initTablesList.map(initTableName => {
.then((initTableslist) => {
const initMetaRequests = initTableslist.map(initTableName => {
return this.$axios
.$post('/initmeta', { initTableName })
.then(initMeta => {
initTables[initTableName] = initMeta
initMeta.tableName = initTableName
initTables.push(initMeta)
})
})
return Promise.all(initMetaRequests)
})
.then(() => {
// Store the initTables all at once to avoid partial fetching
// if one of the previous requests fail.
commit('setInitTables', initTables)
commit('setInitTables', _.orderBy(initTables, 'name'))
})
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment