fix for delete screens
This commit is contained in:
parent
0d32dd0719
commit
6bc9c86623
|
@ -36,6 +36,7 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
hasAppPackage: false,
|
hasAppPackage: false,
|
||||||
libraries: null,
|
libraries: null,
|
||||||
appId: "",
|
appId: "",
|
||||||
|
routes: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getFrontendStore = () => {
|
export const getFrontendStore = () => {
|
||||||
|
@ -120,6 +121,17 @@ export const getFrontendStore = () => {
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
routing: {
|
||||||
|
fetch: async () => {
|
||||||
|
const response = await api.get("/api/routing")
|
||||||
|
const json = await response.json()
|
||||||
|
|
||||||
|
store.update(state => {
|
||||||
|
state.routes = json.routes
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
screens: {
|
screens: {
|
||||||
select: screenId => {
|
select: screenId => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
|
|
|
@ -15,9 +15,10 @@
|
||||||
const deleteScreen = () => {
|
const deleteScreen = () => {
|
||||||
const screenToDelete = $allScreens.find(scr => scr._id === screen)
|
const screenToDelete = $allScreens.find(scr => scr._id === screen)
|
||||||
store.actions.screens.delete(screenToDelete)
|
store.actions.screens.delete(screenToDelete)
|
||||||
|
store.actions.routing.fetch()
|
||||||
// update the page if required
|
// update the page if required
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
if (state.currentPreviewItem._id === screen._id) {
|
if (state.currentPreviewItem._id === screen) {
|
||||||
store.actions.pages.select($store.currentPageName)
|
store.actions.pages.select($store.currentPageName)
|
||||||
notifier.success(`Screen ${screenToDelete.name} deleted successfully.`)
|
notifier.success(`Screen ${screenToDelete.name} deleted successfully.`)
|
||||||
$goto(`./:page/page-layout`)
|
$goto(`./:page/page-layout`)
|
||||||
|
|
|
@ -2,12 +2,10 @@
|
||||||
import { goto } from "@sveltech/routify"
|
import { goto } from "@sveltech/routify"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import PathTree from "./PathTree.svelte"
|
import PathTree from "./PathTree.svelte"
|
||||||
|
|
||||||
export let routes = {}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
{#each Object.keys(routes) as path}
|
{#each Object.keys($store.routes) as path}
|
||||||
<PathTree {path} route={routes[path]} />
|
<PathTree {path} route={$store.routes[path]} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,15 +12,8 @@
|
||||||
|
|
||||||
let routes = {}
|
let routes = {}
|
||||||
|
|
||||||
async function fetchRoutes() {
|
|
||||||
const response = await api.get("/api/routing")
|
|
||||||
const json = await response.json()
|
|
||||||
|
|
||||||
routes = json.routes
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
fetchRoutes()
|
store.actions.routing.fetch()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -31,7 +24,7 @@
|
||||||
<PagesList />
|
<PagesList />
|
||||||
<div class="nav-items-container">
|
<div class="nav-items-container">
|
||||||
<PageLayout layout={$store.pages[$store.currentPageName]} />
|
<PageLayout layout={$store.pages[$store.currentPageName]} />
|
||||||
<ComponentNavigationTree {routes} />
|
<ComponentNavigationTree />
|
||||||
</div>
|
</div>
|
||||||
<Modal bind:this={modal}>
|
<Modal bind:this={modal}>
|
||||||
<NewScreenModal />
|
<NewScreenModal />
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
<script>
|
|
||||||
import { goto } from "@sveltech/routify"
|
|
||||||
import { store } from "builderStore"
|
|
||||||
import { notifier } from "builderStore/store/notifications"
|
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
|
||||||
import { DropdownMenu } from "@budibase/bbui"
|
|
||||||
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
|
|
||||||
|
|
||||||
export let screen
|
|
||||||
|
|
||||||
let confirmDeleteDialog
|
|
||||||
let dropdown
|
|
||||||
let anchor
|
|
||||||
|
|
||||||
const deleteScreen = () => {
|
|
||||||
store.actions.screens.delete(screen, $store.currentPageName)
|
|
||||||
// update the page if required
|
|
||||||
store.update(state => {
|
|
||||||
if (state.currentPreviewItem._id === screen._id) {
|
|
||||||
store.actions.pages.select($store.currentPageName)
|
|
||||||
notifier.success(`Screen ${screen.name} deleted successfully.`)
|
|
||||||
$goto(`./:page/page-layout`)
|
|
||||||
}
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div bind:this={anchor} on:click|stopPropagation>
|
|
||||||
<div class="icon" on:click={() => dropdown.show()}>
|
|
||||||
<i class="ri-more-line" />
|
|
||||||
</div>
|
|
||||||
<DropdownMenu bind:this={dropdown} {anchor} align="left">
|
|
||||||
<DropdownContainer>
|
|
||||||
<DropdownItem
|
|
||||||
icon="ri-delete-bin-line"
|
|
||||||
title="Delete"
|
|
||||||
on:click={() => confirmDeleteDialog.show()} />
|
|
||||||
</DropdownContainer>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
<ConfirmDialog
|
|
||||||
bind:this={confirmDeleteDialog}
|
|
||||||
title="Confirm Deletion"
|
|
||||||
body={`Are you sure you wish to delete the screen '${screen.props._instanceName}' ?`}
|
|
||||||
okText="Delete Screen"
|
|
||||||
onOk={deleteScreen} />
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.icon i {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
</style>
|
|
Loading…
Reference in New Issue