From a09290f2116b601db523b0dbeb8fcba1746cf359 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Thu, 25 Apr 2019 16:51:40 -0700 Subject: [PATCH] catlist: autoselect first private cat --- cateditor/src/pages/list/store/index.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/cateditor/src/pages/list/store/index.js b/cateditor/src/pages/list/store/index.js index 5f19f48..eef71e0 100644 --- a/cateditor/src/pages/list/store/index.js +++ b/cateditor/src/pages/list/store/index.js @@ -31,16 +31,6 @@ export const store = new Vuex.Store({ getSelectedCatalog(state) { return state.selectedCatalog }, - // findCatalog(state) { - // return function(id) { - // let cat = state.myCatalogs.find(c => c.id === id) - // if (cat !== undefined) { - // return cat - // } else { - // return state.publicCatalogs.find(c => c.id === id) - // } - // } - // }, findCatalog: (state) => (id) => { let cat = state.myCatalogs.find(c => c.id === id) if (cat !== undefined) { @@ -49,9 +39,6 @@ export const store = new Vuex.Store({ return state.publicCatalogs.find(c => c.id === id) } }, - // CAT_SECTION: (state) => (id) => { - // return state.catalog.sections.find(s => s.id === id) - // }, }, mutations: { @@ -80,6 +67,9 @@ export const store = new Vuex.Store({ if ('catalogs' in response.data) { // console.log('recieved catalogs:', response.data.catalogs) commit('setMyCatalogs', response.data.catalogs) + if (response.data.catalogs.length > 0) { + commit('setSelectedCatalog', response.data.catalogs[0]) + } } else { // console.log('no catalogs') commit('setMyCatalogs', [])