On view created
This commit is contained in:
parent
0b17d6026a
commit
df40420470
|
@ -16,13 +16,13 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await viewsStore.create({
|
const newView = await viewsStore.create({
|
||||||
name,
|
name,
|
||||||
tableId: $tables.selected._id,
|
tableId: $tables.selected._id,
|
||||||
field,
|
field,
|
||||||
})
|
})
|
||||||
notifications.success(`View ${name} created`)
|
notifications.success(`View ${name} created`)
|
||||||
$goto(`../../view/${encodeURIComponent(name)}`)
|
$goto(`../../view/v2/${newView.id}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error creating view")
|
notifications.error("Error creating view")
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,19 +41,17 @@ export function createViewsStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const create = async view => {
|
const create = async view => {
|
||||||
const savedView = await API.viewV2.create(view)
|
const savedViewResponse = await API.viewV2.create(view)
|
||||||
|
const savedView = savedViewResponse.data
|
||||||
|
|
||||||
// Update tables
|
// Update tables
|
||||||
tables.update(state => {
|
tables.update(state => {
|
||||||
const table = state.list.find(table => table._id === view.tableId)
|
const table = state.list.find(table => table._id === view.tableId)
|
||||||
if (table) {
|
|
||||||
if (view.originalName) {
|
|
||||||
delete table.views[view.originalName]
|
|
||||||
}
|
|
||||||
table.views[view.name] = savedView
|
table.views[view.name] = savedView
|
||||||
}
|
|
||||||
return { ...state }
|
return { ...state }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return savedView
|
||||||
}
|
}
|
||||||
|
|
||||||
const save = async view => {
|
const save = async view => {
|
||||||
|
|
Loading…
Reference in New Issue