1
0
Fork 0
mirror of synced 2024-09-10 22:46:09 +12:00

On view created

This commit is contained in:
Adria Navarro 2023-07-19 23:15:28 +02:00
parent 0b17d6026a
commit df40420470
2 changed files with 7 additions and 9 deletions

View file

@ -16,13 +16,13 @@
return
}
try {
await viewsStore.create({
const newView = await viewsStore.create({
name,
tableId: $tables.selected._id,
field,
})
notifications.success(`View ${name} created`)
$goto(`../../view/${encodeURIComponent(name)}`)
$goto(`../../view/v2/${newView.id}`)
} catch (error) {
notifications.error("Error creating view")
}

View file

@ -41,19 +41,17 @@ export function createViewsStore() {
}
const create = async view => {
const savedView = await API.viewV2.create(view)
const savedViewResponse = await API.viewV2.create(view)
const savedView = savedViewResponse.data
// Update tables
tables.update(state => {
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 savedView
}
const save = async view => {