Merge pull request #3581 from Budibase/feature/auto-screen-ui
Autoscreen fixes
This commit is contained in:
commit
df307ad579
|
@ -25,8 +25,7 @@
|
||||||
key: "layout",
|
key: "layout",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
let newLayoutModal
|
||||||
let modal
|
|
||||||
$: selected = tabs.find(t => t.key === $params.assetType)?.title || "Screens"
|
$: selected = tabs.find(t => t.key === $params.assetType)?.title || "Screens"
|
||||||
|
|
||||||
const navigate = ({ detail }) => {
|
const navigate = ({ detail }) => {
|
||||||
|
@ -93,14 +92,18 @@
|
||||||
{#each $store.layouts as layout, idx (layout._id)}
|
{#each $store.layouts as layout, idx (layout._id)}
|
||||||
<Layout {layout} border={idx > 0} />
|
<Layout {layout} border={idx > 0} />
|
||||||
{/each}
|
{/each}
|
||||||
<Modal bind:this={modal}>
|
<Modal bind:this={newLayoutModal}>
|
||||||
<NewLayoutModal />
|
<NewLayoutModal />
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<div class="add-button">
|
<div class="add-button">
|
||||||
<Icon hoverable name="AddCircle" on:click={showModal()} />
|
<Icon
|
||||||
|
hoverable
|
||||||
|
name="AddCircle"
|
||||||
|
on:click={selected === "Layouts" ? newLayoutModal.show() : showModal()}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,39 @@
|
||||||
ProgressCircle,
|
ProgressCircle,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import getTemplates from "builderStore/store/screenTemplates"
|
import getTemplates from "builderStore/store/screenTemplates"
|
||||||
|
import { onDestroy } from "svelte"
|
||||||
|
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let selectedScreens = []
|
|
||||||
export let chooseModal
|
export let chooseModal
|
||||||
export let save
|
export let save
|
||||||
export let showProgressCircle = false
|
export let showProgressCircle = false
|
||||||
|
|
||||||
|
let selectedScreens = []
|
||||||
|
|
||||||
const blankScreen = "createFromScratch"
|
const blankScreen = "createFromScratch"
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
function setScreens() {
|
||||||
|
dispatch("save", {
|
||||||
|
screens: selectedScreens,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
$: blankSelected = selectedScreens?.length === 1
|
$: blankSelected = selectedScreens?.length === 1
|
||||||
$: autoSelected = selectedScreens?.length > 0 && !blankSelected
|
$: autoSelected = selectedScreens?.length > 0 && !blankSelected
|
||||||
|
|
||||||
let templates = getTemplates($store, $tables.list)
|
let templates = getTemplates($store, $tables.list)
|
||||||
|
|
||||||
|
const confirm = async () => {
|
||||||
|
if (autoSelected) {
|
||||||
|
setScreens()
|
||||||
|
await save()
|
||||||
|
} else {
|
||||||
|
setScreens()
|
||||||
|
chooseModal(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
const toggleScreenSelection = table => {
|
const toggleScreenSelection = table => {
|
||||||
if (selectedScreens.find(s => s.table === table.name)) {
|
if (selectedScreens.find(s => s.table === table.name)) {
|
||||||
selectedScreens = selectedScreens.filter(
|
selectedScreens = selectedScreens.filter(
|
||||||
|
@ -32,14 +55,18 @@
|
||||||
selectedScreens = [...partialTemplates, ...selectedScreens]
|
selectedScreens = [...partialTemplates, ...selectedScreens]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
selectedScreens = []
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div style="overflow-y: auto; max-height: 1000px">
|
<div>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Add screens"
|
title="Add screens"
|
||||||
confirmText="Add Screens"
|
confirmText="Add Screens"
|
||||||
cancelText="Cancel"
|
cancelText="Cancel"
|
||||||
onConfirm={() => (autoSelected ? save() : chooseModal(1))}
|
onConfirm={() => confirm()}
|
||||||
disabled={!selectedScreens.length}
|
disabled={!selectedScreens.length}
|
||||||
size="L"
|
size="L"
|
||||||
>
|
>
|
||||||
|
@ -70,6 +97,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{#if $tables.list.filter(table => table._id !== "ta_users").length > 0}
|
||||||
<Detail size="S">Autogenerated Screens</Detail>
|
<Detail size="S">Autogenerated Screens</Detail>
|
||||||
|
|
||||||
{#each $tables.list.filter(table => table._id !== "ta_users") as table}
|
{#each $tables.list.filter(table => table._id !== "ta_users") as table}
|
||||||
|
@ -93,6 +121,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
{/if}
|
||||||
</Layout>
|
</Layout>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
{#if showProgressCircle}
|
{#if showProgressCircle}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { ModalContent, Input, ProgressCircle } from "@budibase/bbui"
|
import { ModalContent, Input, ProgressCircle } from "@budibase/bbui"
|
||||||
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
||||||
import { selectedAccessRole, allScreens } from "builderStore"
|
import { selectedAccessRole, allScreens } from "builderStore"
|
||||||
|
import { onDestroy } from "svelte"
|
||||||
|
|
||||||
export let screenName
|
export let screenName
|
||||||
export let url
|
export let url
|
||||||
|
@ -32,6 +33,11 @@
|
||||||
screen.routing.roleId === roleId
|
screen.routing.roleId === roleId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
screenName = ""
|
||||||
|
url = ""
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
||||||
import { Modal } from "@budibase/bbui"
|
import { Modal } from "@budibase/bbui"
|
||||||
import { store, selectedAccessRole, allScreens } from "builderStore"
|
import { store, selectedAccessRole, allScreens } from "builderStore"
|
||||||
import { onDestroy } from "svelte"
|
|
||||||
import analytics, { Events } from "analytics"
|
import analytics, { Events } from "analytics"
|
||||||
|
|
||||||
let newScreenModal
|
let newScreenModal
|
||||||
|
@ -34,7 +33,6 @@
|
||||||
for (let screen of createdScreens) {
|
for (let screen of createdScreens) {
|
||||||
await saveScreens(screen)
|
await saveScreens(screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
await store.actions.routing.fetch()
|
await store.actions.routing.fetch()
|
||||||
selectedScreens = []
|
selectedScreens = []
|
||||||
createdScreens = []
|
createdScreens = []
|
||||||
|
@ -42,6 +40,7 @@
|
||||||
url = ""
|
url = ""
|
||||||
showProgressCircle = false
|
showProgressCircle = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveScreens = async draftScreen => {
|
const saveScreens = async draftScreen => {
|
||||||
let existingScreenCount = $store.screens.filter(
|
let existingScreenCount = $store.screens.filter(
|
||||||
s => s.props._instanceName == draftScreen.props._instanceName
|
s => s.props._instanceName == draftScreen.props._instanceName
|
||||||
|
@ -90,17 +89,14 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy(() => {
|
|
||||||
selectedScreens = []
|
|
||||||
screenName = ""
|
|
||||||
url = ""
|
|
||||||
createdScreens = []
|
|
||||||
})
|
|
||||||
|
|
||||||
export const showModal = () => {
|
export const showModal = () => {
|
||||||
newScreenModal.show()
|
newScreenModal.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setScreens = evt => {
|
||||||
|
selectedScreens = evt.detail.screens
|
||||||
|
}
|
||||||
|
|
||||||
const chooseModal = index => {
|
const chooseModal = index => {
|
||||||
/*
|
/*
|
||||||
0 = newScreenModal
|
0 = newScreenModal
|
||||||
|
@ -119,7 +115,7 @@
|
||||||
|
|
||||||
<Modal bind:this={newScreenModal}>
|
<Modal bind:this={newScreenModal}>
|
||||||
<NewScreenModal
|
<NewScreenModal
|
||||||
bind:selectedScreens
|
on:save={setScreens}
|
||||||
{showProgressCircle}
|
{showProgressCircle}
|
||||||
{save}
|
{save}
|
||||||
{chooseModal}
|
{chooseModal}
|
||||||
|
|
Loading…
Reference in New Issue