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 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")
} }

View File

@ -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) { table.views[view.name] = savedView
if (view.originalName) {
delete table.views[view.originalName]
}
table.views[view.name] = savedView
}
return { ...state } return { ...state }
}) })
return savedView
} }
const save = async view => { const save = async view => {