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-04-01 11:29:47 +02:00
|
|
|
import { roles } from "stores/backend"
|
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-04-20 15:06:33 +02:00
|
|
|
import { Modal, Select, Input, Tabs, Tab } 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
|
2021-04-16 11:18:39 +02:00
|
|
|
$: selected = tabs.find(t => t.key === $params.assetType).title
|
2020-12-02 14:41:00 +01:00
|
|
|
|
2020-12-14 12:14:16 +01:00
|
|
|
const navigate = ({ detail }) => {
|
2021-04-16 11:18:39 +02:00
|
|
|
const { key } = tabs.find(t => t.title === detail)
|
|
|
|
$goto(`../${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 => {
|
2021-04-15 20:42:58 +02:00
|
|
|
const role = event.detail
|
2020-12-14 12:14:16 +01:00
|
|
|
|
|
|
|
// 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">
|
2021-04-16 11:18:39 +02:00
|
|
|
<Tabs {selected} on:select={navigate}>
|
|
|
|
<Tab title="Screens">
|
|
|
|
<div class="tab-content-padding">
|
|
|
|
<div class="role-select">
|
|
|
|
<Select
|
|
|
|
on:change={updateAccessRole}
|
|
|
|
value={$selectedAccessRole}
|
2021-04-20 15:06:33 +02:00
|
|
|
label="Filter by Access"
|
|
|
|
getOptionLabel={role => role.name}
|
|
|
|
getOptionValue={role => role._id}
|
|
|
|
options={$roles} />
|
2021-04-16 11:18:39 +02:00
|
|
|
<div class="search-screens">
|
|
|
|
<Input
|
|
|
|
placeholder="Enter a route to search"
|
|
|
|
label="Search Screens"
|
|
|
|
bind:value={$screenSearchString} />
|
|
|
|
<i
|
|
|
|
class="ri-close-line"
|
|
|
|
on:click={() => ($screenSearchString = null)} />
|
|
|
|
</div>
|
2021-04-20 15:06:33 +02:00
|
|
|
</div>
|
|
|
|
<div class="nav-items-container">
|
|
|
|
<ComponentNavigationTree />
|
2021-03-11 16:53:31 +01:00
|
|
|
</div>
|
2021-04-20 15:06:33 +02:00
|
|
|
<Modal bind:this={modal}>
|
|
|
|
<NewScreenModal />
|
|
|
|
</Modal>
|
2020-12-09 19:18:47 +01:00
|
|
|
</div>
|
2021-04-16 11:18:39 +02:00
|
|
|
</Tab>
|
|
|
|
<Tab title="Layouts">
|
|
|
|
<div class="tab-content-padding">
|
|
|
|
<i
|
2021-04-20 15:06:33 +02:00
|
|
|
on:click={modal.show}
|
|
|
|
data-cy="new-layout"
|
|
|
|
class="ri-add-circle-fill" />
|
|
|
|
{#each $store.layouts as layout, idx (layout._id)}
|
|
|
|
<Layout {layout} border={idx > 0} />
|
|
|
|
{/each}
|
|
|
|
<Modal bind:this={modal}>
|
|
|
|
<NewLayoutModal />
|
|
|
|
</Modal>
|
2020-12-14 12:14:16 +01:00
|
|
|
</div>
|
2021-04-16 11:18:39 +02:00
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
2021-04-20 15:06:33 +02:00
|
|
|
<i on:click={modal.show} data-cy="new-screen" class="ri-add-circle-fill" />
|
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;
|
2021-04-16 11:18:39 +02:00
|
|
|
top: var(--spacing-l);
|
|
|
|
right: var(--spacing-l);
|
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
|
|
|
|
2021-04-16 11:18:39 +02:00
|
|
|
.tab-content-padding {
|
|
|
|
padding: 0 var(--spacing-s);
|
|
|
|
}
|
|
|
|
|
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>
|