2020-05-29 14:28:12 +02:00
|
|
|
<script>
|
2020-11-18 23:04:18 +01:00
|
|
|
import { onMount } from "svelte"
|
2021-03-17 12:40:24 +01:00
|
|
|
import { goto, params } from "@roxi/routify"
|
2020-12-09 19:18:47 +01:00
|
|
|
import {
|
|
|
|
store,
|
2020-12-14 12:14:16 +01:00
|
|
|
allScreens,
|
2020-12-09 19:18:47 +01:00
|
|
|
selectedAccessRole,
|
2021-03-09 20:06:25 +01:00
|
|
|
screenSearchString,
|
2020-12-09 19:18:47 +01:00
|
|
|
} from "builderStore"
|
2021-03-26 09:50:37 +01:00
|
|
|
import { roles } from 'stores/backend/'
|
2020-12-05 13:09:58 +01:00
|
|
|
import { FrontendTypes } from "constants"
|
2021-01-14 11:03:33 +01:00
|
|
|
import ComponentNavigationTree from "components/design/NavigationPanel/ComponentNavigationTree/index.svelte"
|
|
|
|
import Layout from "components/design/NavigationPanel/Layout.svelte"
|
|
|
|
import NewScreenModal from "components/design/NavigationPanel/NewScreenModal.svelte"
|
|
|
|
import NewLayoutModal from "components/design/NavigationPanel/NewLayoutModal.svelte"
|
2021-03-09 20:06:25 +01:00
|
|
|
import { Modal, Switcher, Select, Input } from "@budibase/bbui"
|
2020-05-29 19:32:52 +02:00
|
|
|
|
2020-12-01 17:22:06 +01:00
|
|
|
const tabs = [
|
|
|
|
{
|
|
|
|
title: "Screens",
|
2020-12-05 13:09:58 +01:00
|
|
|
key: "screen",
|
2020-12-01 17:22:06 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Layouts",
|
2020-12-05 13:09:58 +01:00
|
|
|
key: "layout",
|
2020-12-01 17:22:06 +01:00
|
|
|
},
|
|
|
|
]
|
2020-11-18 23:04:18 +01:00
|
|
|
|
2020-12-01 17:22:06 +01:00
|
|
|
let modal
|
2020-11-18 23:04:18 +01:00
|
|
|
let routes = {}
|
2021-01-15 15:23:27 +01:00
|
|
|
$: tab = $params.assetType
|
2020-12-02 14:41:00 +01:00
|
|
|
|
2020-12-14 12:14:16 +01:00
|
|
|
const navigate = ({ detail }) => {
|
|
|
|
if (!detail) {
|
|
|
|
return
|
|
|
|
}
|
2020-12-07 17:06:20 +01:00
|
|
|
$goto(`../${detail.heading.key}`)
|
2020-12-02 14:41:00 +01:00
|
|
|
}
|
2020-11-18 23:04:18 +01:00
|
|
|
|
2020-12-14 12:14:16 +01:00
|
|
|
const updateAccessRole = event => {
|
|
|
|
const role = event.target.value
|
|
|
|
|
|
|
|
// Select a valid screen with this new role - otherwise we'll not be
|
|
|
|
// able to change role at all because ComponentNavigationTree will kick us
|
|
|
|
// back the current role again because the same screen ID is still selected
|
|
|
|
const firstValidScreenId = $allScreens.find(
|
|
|
|
screen => screen.routing.roleId === role
|
|
|
|
)?._id
|
|
|
|
if (firstValidScreenId) {
|
|
|
|
store.actions.screens.select(firstValidScreenId)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise clear the selected screen ID so that the first new valid screen
|
|
|
|
// can be selected by ComponentNavigationTree
|
|
|
|
else {
|
|
|
|
store.update(state => {
|
|
|
|
state.selectedScreenId = null
|
|
|
|
return state
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedAccessRole.set(role)
|
|
|
|
}
|
|
|
|
|
2020-11-18 23:04:18 +01:00
|
|
|
onMount(() => {
|
2020-11-19 22:07:25 +01:00
|
|
|
store.actions.routing.fetch()
|
2020-11-18 23:04:18 +01:00
|
|
|
})
|
2020-05-29 14:28:12 +02:00
|
|
|
</script>
|
|
|
|
|
2020-10-22 19:12:40 +02:00
|
|
|
<div class="title">
|
2020-12-03 16:15:14 +01:00
|
|
|
<Switcher headings={tabs} bind:value={tab} on:change={navigate}>
|
2020-12-05 13:09:58 +01:00
|
|
|
{#if tab === FrontendTypes.SCREEN}
|
2020-12-01 17:22:06 +01:00
|
|
|
<i
|
|
|
|
on:click={modal.show}
|
|
|
|
data-cy="new-screen"
|
|
|
|
class="ri-add-circle-fill" />
|
2020-12-09 19:18:47 +01:00
|
|
|
<div class="role-select">
|
|
|
|
<Select
|
|
|
|
extraThin
|
|
|
|
secondary
|
2020-12-14 12:14:16 +01:00
|
|
|
on:change={updateAccessRole}
|
|
|
|
value={$selectedAccessRole}
|
2020-12-09 19:18:47 +01:00
|
|
|
label="Filter by Access">
|
2021-03-22 10:55:23 +01:00
|
|
|
{#each $roles as role}
|
2020-12-09 19:18:47 +01:00
|
|
|
<option value={role._id}>{role.name}</option>
|
|
|
|
{/each}
|
|
|
|
</Select>
|
2021-03-11 16:53:31 +01:00
|
|
|
<div class="search-screens">
|
|
|
|
<Input
|
|
|
|
extraThin
|
|
|
|
placeholder="Enter a route to search"
|
|
|
|
label="Search Screens"
|
|
|
|
bind:value={$screenSearchString} />
|
|
|
|
<i
|
|
|
|
class="ri-close-line"
|
|
|
|
on:click={() => ($screenSearchString = null)} />
|
|
|
|
</div>
|
2020-12-09 19:18:47 +01:00
|
|
|
</div>
|
2020-12-14 12:14:16 +01:00
|
|
|
<div class="nav-items-container">
|
|
|
|
<ComponentNavigationTree />
|
|
|
|
</div>
|
2020-12-01 17:22:06 +01:00
|
|
|
<Modal bind:this={modal}>
|
|
|
|
<NewScreenModal />
|
|
|
|
</Modal>
|
2020-12-05 13:09:58 +01:00
|
|
|
{:else if tab === FrontendTypes.LAYOUT}
|
2020-12-05 00:16:07 +01:00
|
|
|
<i
|
|
|
|
on:click={modal.show}
|
|
|
|
data-cy="new-layout"
|
|
|
|
class="ri-add-circle-fill" />
|
2020-12-09 19:18:47 +01:00
|
|
|
{#each $store.layouts as layout, idx (layout._id)}
|
|
|
|
<Layout {layout} border={idx > 0} />
|
2020-12-02 15:49:43 +01:00
|
|
|
{/each}
|
2020-12-05 00:16:07 +01:00
|
|
|
<Modal bind:this={modal}>
|
|
|
|
<NewLayoutModal />
|
|
|
|
</Modal>
|
2020-12-01 17:22:06 +01:00
|
|
|
{/if}
|
|
|
|
</Switcher>
|
2020-05-29 14:28:12 +02:00
|
|
|
</div>
|
2020-12-01 17:22:06 +01:00
|
|
|
|
2020-10-22 19:12:40 +02:00
|
|
|
<style>
|
|
|
|
.title {
|
|
|
|
display: flex;
|
2020-12-04 15:07:56 +01:00
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
2020-12-04 15:52:40 +01:00
|
|
|
position: relative;
|
2020-10-22 19:12:40 +02:00
|
|
|
}
|
|
|
|
.title i {
|
|
|
|
font-size: 20px;
|
2020-12-04 15:52:40 +01:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
2020-10-22 19:12:40 +02:00
|
|
|
}
|
|
|
|
.title i:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--blue);
|
|
|
|
}
|
2020-12-09 19:18:47 +01:00
|
|
|
|
|
|
|
.role-select {
|
2021-03-09 20:06:25 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
2020-12-09 19:18:47 +01:00
|
|
|
margin-bottom: var(--spacing-m);
|
2021-03-09 20:06:25 +01:00
|
|
|
gap: var(--spacing-m);
|
2020-12-09 19:18:47 +01:00
|
|
|
}
|
2021-03-11 16:53:31 +01:00
|
|
|
|
|
|
|
.search-screens {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.search-screens i {
|
|
|
|
right: 2px;
|
|
|
|
bottom: 2px;
|
|
|
|
position: absolute;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: var(--spacing-s);
|
|
|
|
border-left: 1px solid var(--grey-4);
|
|
|
|
background-color: var(--grey-2);
|
|
|
|
border-top-right-radius: var(--border-radius-m);
|
|
|
|
border-bottom-right-radius: var(--border-radius-m);
|
|
|
|
color: var(--grey-7);
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 15px;
|
|
|
|
top: auto;
|
|
|
|
}
|
2020-10-22 19:12:40 +02:00
|
|
|
</style>
|