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