2019-08-07 10:03:49 +02:00
|
|
|
<script>
|
2021-11-10 17:04:27 +01:00
|
|
|
import { store } from "builderStore"
|
2021-08-26 11:11:48 +02:00
|
|
|
import { tables } from "stores/backend"
|
2021-11-09 10:33:34 +01:00
|
|
|
import { ModalContent, Body, Detail, Layout, Icon } from "@budibase/bbui"
|
2020-10-08 16:46:29 +02:00
|
|
|
import getTemplates from "builderStore/store/screenTemplates"
|
2020-10-08 15:53:06 +02:00
|
|
|
|
2021-11-10 17:04:27 +01:00
|
|
|
export let screenNameModal
|
|
|
|
export let navigationSelectionModal
|
|
|
|
export let selectedScreens = []
|
2021-11-09 10:33:34 +01:00
|
|
|
|
2021-11-10 17:04:27 +01:00
|
|
|
const blankScreen = "createFromScratch"
|
|
|
|
$: blankSelected = selectedScreens.find(x => x.id === blankScreen)
|
2021-11-09 10:33:34 +01:00
|
|
|
$: autoSelected = selectedScreens.length > 0 && !blankSelected
|
2020-02-25 16:21:23 +01:00
|
|
|
|
2021-08-26 11:11:48 +02:00
|
|
|
$: templates = getTemplates($store, $tables.list)
|
2021-11-10 17:04:27 +01:00
|
|
|
const toggleScreenSelection = table => {
|
|
|
|
if (selectedScreens.find(s => s.name.includes(table.name))) {
|
|
|
|
selectedScreens = selectedScreens.filter(
|
|
|
|
screen => !screen.name.includes(table.name)
|
|
|
|
)
|
2021-11-09 10:33:34 +01:00
|
|
|
} else {
|
2021-11-10 17:04:27 +01:00
|
|
|
const templates = getTemplates($store, $tables.list).filter(template =>
|
|
|
|
template.name.includes(table.name)
|
|
|
|
)
|
|
|
|
selectedScreens = [...templates, ...selectedScreens]
|
2020-02-25 11:01:07 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-07 10:03:49 +02:00
|
|
|
</script>
|
|
|
|
|
2021-11-09 10:33:34 +01:00
|
|
|
<ModalContent
|
|
|
|
title="Add screens"
|
|
|
|
confirmText="Add Screens"
|
|
|
|
cancelText="Cancel"
|
2021-11-10 17:04:27 +01:00
|
|
|
onConfirm={() =>
|
|
|
|
autoSelected ? navigationSelectionModal.show() : screenNameModal.show()}
|
2021-11-09 10:33:34 +01:00
|
|
|
disabled={!selectedScreens.length}
|
|
|
|
size="L"
|
|
|
|
>
|
|
|
|
<Body size="XS"
|
|
|
|
>Please select the screens you would like to add to your application.
|
|
|
|
Autogenerated screens come with CRUD functionality.</Body
|
|
|
|
>
|
|
|
|
|
|
|
|
<Layout noPadding>
|
|
|
|
<Detail size="S">Blank screen</Detail>
|
|
|
|
<div
|
|
|
|
class="item"
|
2021-11-10 17:04:27 +01:00
|
|
|
class:selected={selectedScreens.find(x => x.id.includes(blankScreen))}
|
|
|
|
on:click={() =>
|
|
|
|
toggleScreenSelection(templates.find(t => t.id === blankScreen))}
|
2021-11-09 10:33:34 +01:00
|
|
|
class:disabled={autoSelected}
|
|
|
|
>
|
2021-11-15 12:03:09 +01:00
|
|
|
<div data-cy="blank-screen" class="content">
|
2021-11-09 10:33:34 +01:00
|
|
|
<Body size="S">Blank</Body>
|
|
|
|
</div>
|
|
|
|
<div style="color: var(--spectrum-global-color-green-600); float: right">
|
2021-11-10 17:04:27 +01:00
|
|
|
{#if selectedScreens.find(x => x.id === blankScreen)}
|
2021-11-09 10:33:34 +01:00
|
|
|
<Icon size="S" name="CheckmarkCircleOutline" />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<Detail size="S">Autogenerated Screens</Detail>
|
|
|
|
|
2021-11-10 17:04:27 +01:00
|
|
|
{#each $tables.list.filter(table => table.type !== "external") as table}
|
2021-11-09 10:33:34 +01:00
|
|
|
<div
|
|
|
|
class:disabled={blankSelected}
|
2021-11-10 17:04:27 +01:00
|
|
|
class:selected={selectedScreens.find(x => x.name.includes(table.name))}
|
|
|
|
on:click={() => toggleScreenSelection(table)}
|
2021-11-09 10:33:34 +01:00
|
|
|
class="item"
|
|
|
|
>
|
|
|
|
<div class="content">
|
2021-11-10 17:04:27 +01:00
|
|
|
{table.name}
|
2021-11-09 10:33:34 +01:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
style="color: var(--spectrum-global-color-green-600); float: right"
|
|
|
|
>
|
2021-11-10 17:04:27 +01:00
|
|
|
{#if selectedScreens.find(x => x.name.includes(table.name))}
|
2021-11-09 10:33:34 +01:00
|
|
|
<Icon size="S" name="CheckmarkCircleOutline" />
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</Layout>
|
2020-10-08 10:34:22 +02:00
|
|
|
</ModalContent>
|
2021-11-09 10:33:34 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.disabled {
|
|
|
|
opacity: 0.3;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.content {
|
|
|
|
padding-left: 10px;
|
|
|
|
letter-spacing: 0px;
|
|
|
|
color: #2c2c2c;
|
|
|
|
}
|
|
|
|
.item {
|
|
|
|
cursor: pointer;
|
|
|
|
grid-gap: var(--spectrum-alias-grid-margin-xsmall);
|
|
|
|
padding: var(--spectrum-alias-item-padding-s);
|
|
|
|
background: var(--background);
|
|
|
|
transition: 0.3s all;
|
|
|
|
border: solid var(--spectrum-alias-border-color);
|
|
|
|
border-radius: 2px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border-width: 1px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
height: 60px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item:hover,
|
|
|
|
.selected {
|
|
|
|
background: var(--spectrum-alias-background-color-tertiary);
|
|
|
|
}
|
|
|
|
</style>
|