1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

update tables select method

This commit is contained in:
Keviin Åberg Kultalahti 2021-03-23 12:04:01 +01:00
parent a440e7631b
commit 0afc55f4cb

View file

@ -19,13 +19,21 @@ function createTablesStore() {
const tables = await tablesResponse.json() const tables = await tablesResponse.json()
update(state => ({...state, list: tables})) update(state => ({...state, list: tables}))
}, },
select: table => select: table => {
update(state => ({ if (!table) {
...state, update(state => ({
selected: table, ...state,
draft: cloneDeep(table), selected: {}
view: { name: `all_${table._id}` } }))
})), } else {
update(state => ({
...state,
selected: table,
draft: cloneDeep(table),
view: { name: `all_${table._id}` }
}))
}
},
save: async table => { save: async table => {
const updatedTable = cloneDeep(table) const updatedTable = cloneDeep(table)
const oldTable = get(store).list.filter(t => t._id === table._id)[0] const oldTable = get(store).list.filter(t => t._id === table._id)[0]