fix some navigation issues when removing tables/datasources
This commit is contained in:
parent
b12b6b39b5
commit
a3750a2c5b
|
@ -105,7 +105,9 @@ export const getBackendUiStore = () => {
|
|||
state.datasources = state.datasources.filter(
|
||||
existing => existing._id !== datasource._id
|
||||
)
|
||||
state.selectedDatasourceId = null
|
||||
if (datasource._id === state.selectedDatasourceId) {
|
||||
state.selectedDatasourceId = null
|
||||
}
|
||||
return state
|
||||
})
|
||||
},
|
||||
|
@ -233,7 +235,9 @@ export const getBackendUiStore = () => {
|
|||
state.tables = state.tables.filter(
|
||||
existing => existing._id !== table._id
|
||||
)
|
||||
state.selectedTable = {}
|
||||
if (table._id === state.selectedTable._id) {
|
||||
state.selectedTable = {}
|
||||
}
|
||||
return state
|
||||
})
|
||||
},
|
||||
|
|
|
@ -22,9 +22,14 @@
|
|||
}
|
||||
|
||||
async function deleteDatasource() {
|
||||
const wasSelectedSource = $backendUiStore.selectedDatasourceId
|
||||
await backendUiStore.actions.datasources.delete(datasource)
|
||||
notifier.success("Datasource deleted")
|
||||
$goto('./datasource')
|
||||
// navigate to first index page if the source you are deleting is selected
|
||||
console.log('Is the same? ', wasSelectedSource === datasource._id)
|
||||
if (wasSelectedSource === datasource._id) {
|
||||
$goto('./datasource')
|
||||
}
|
||||
hideEditor()
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<script>
|
||||
import { goto } from "@sveltech/routify"
|
||||
import { backendUiStore, store, allScreens } from "builderStore"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import { DropdownMenu, Button, Input } from "@budibase/bbui"
|
||||
|
@ -36,10 +37,14 @@
|
|||
}
|
||||
|
||||
async function deleteTable() {
|
||||
const wasSelectedTable = $backendUiStore.selectedTable
|
||||
await backendUiStore.actions.tables.delete(table)
|
||||
store.actions.screens.delete(templateScreens)
|
||||
await backendUiStore.actions.tables.fetch()
|
||||
notifier.success("Table deleted")
|
||||
if (wasSelectedTable._id === table._id) {
|
||||
$goto('./table')
|
||||
}
|
||||
hideEditor()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue