Make new screen a dedicated route and remove duplication. Fix some issues when deleting selected screens
This commit is contained in:
parent
607a36e2e4
commit
38e8ff879a
|
@ -42,11 +42,13 @@
|
||||||
onDestroy(stopSyncing)
|
onDestroy(stopSyncing)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if routeComponentId === "screen"}
|
{#if $selectedScreen}
|
||||||
<ScreenSettingsPanel />
|
{#if routeComponentId === "screen"}
|
||||||
{:else if routeComponentId === "navigation"}
|
<ScreenSettingsPanel />
|
||||||
<NavigationPanel />
|
{:else if routeComponentId === "navigation"}
|
||||||
{:else}
|
<NavigationPanel />
|
||||||
<ComponentSettingsPanel />
|
{:else}
|
||||||
|
<ComponentSettingsPanel />
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
const deleteScreen = async () => {
|
const deleteScreen = async () => {
|
||||||
try {
|
try {
|
||||||
await store.actions.screens.delete(screen)
|
await store.actions.screens.delete(screen)
|
||||||
notifications.success("Deleted screen successfully.")
|
notifications.success("Deleted screen successfully")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error("Error deleting screen")
|
notifications.error("Error deleting screen")
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,9 @@
|
||||||
import NavItem from "components/common/NavItem.svelte"
|
import NavItem from "components/common/NavItem.svelte"
|
||||||
import RoleIndicator from "./RoleIndicator.svelte"
|
import RoleIndicator from "./RoleIndicator.svelte"
|
||||||
import DropdownMenu from "./DropdownMenu.svelte"
|
import DropdownMenu from "./DropdownMenu.svelte"
|
||||||
import NewScreen from "components/design/NewScreen/index.svelte"
|
|
||||||
import { onMount, tick } from "svelte"
|
import { onMount, tick } from "svelte"
|
||||||
import { beforeUrlChange } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
|
|
||||||
let newScreen = false
|
|
||||||
let search = false
|
let search = false
|
||||||
let resizing = false
|
let resizing = false
|
||||||
let searchValue = ""
|
let searchValue = ""
|
||||||
|
@ -26,14 +24,6 @@
|
||||||
|
|
||||||
$: filteredScreens = getFilteredScreens($sortedScreens, searchValue)
|
$: filteredScreens = getFilteredScreens($sortedScreens, searchValue)
|
||||||
|
|
||||||
// Close new screen when URL changes
|
|
||||||
$beforeUrlChange(() => {
|
|
||||||
if (newScreen) {
|
|
||||||
newScreen = false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||||
|
|
||||||
const openSearch = async () => {
|
const openSearch = async () => {
|
||||||
|
@ -66,17 +56,13 @@
|
||||||
if (search) {
|
if (search) {
|
||||||
closeSearch()
|
closeSearch()
|
||||||
} else {
|
} else {
|
||||||
newScreen = true
|
$goto("../new")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onKeyDown = e => {
|
const onKeyDown = e => {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
if (newScreen) {
|
closeSearch()
|
||||||
newScreen = false
|
|
||||||
} else {
|
|
||||||
closeSearch()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,29 +170,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="newScreen" class:newScreenVisible={newScreen}>
|
|
||||||
<NewScreen
|
|
||||||
onClose={() => {
|
|
||||||
console.log("close")
|
|
||||||
newScreen = false
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.newScreen {
|
|
||||||
display: none;
|
|
||||||
width: 100vw;
|
|
||||||
bottom: 0;
|
|
||||||
position: absolute;
|
|
||||||
height: calc(100vh - 58px);
|
|
||||||
z-index: 2;
|
|
||||||
background-color: var(--background);
|
|
||||||
}
|
|
||||||
.newScreenVisible {
|
|
||||||
display: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
.screens {
|
.screens {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
@ -67,7 +67,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select and go to new screen
|
// Go to new screen
|
||||||
|
$goto(`./${screenId}`)
|
||||||
store.actions.screens.select(screenId)
|
store.actions.screens.select(screenId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
@ -1,5 +1,23 @@
|
||||||
<script>
|
<script>
|
||||||
import NewScreen from "components/design/NewScreen/index.svelte"
|
import NewScreen from "./_components/NewScreen/index.svelte"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
|
||||||
|
$: onClose = getOnClose($store)
|
||||||
|
|
||||||
|
const getOnClose = ({ screens, selectedScreenId }) => {
|
||||||
|
if (!screens?.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (selectedScreenId) {
|
||||||
|
return () => {
|
||||||
|
$goto(`./${selectedScreenId}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
$goto(`./${screens[0]._id}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NewScreen />
|
<NewScreen {onClose} />
|
||||||
|
|
Loading…
Reference in New Issue