Merge pull request #3533 from Budibase/feature/auto-screen-ui

Fix issue where auto screen UI was duplicating selections
This commit is contained in:
Peter Clement 2021-11-25 10:23:50 +00:00 committed by GitHub
commit 4ede32c408
6 changed files with 13 additions and 7 deletions

View File

@ -4,6 +4,7 @@ export default {
name: `Create from scratch`, name: `Create from scratch`,
id: `createFromScratch`, id: `createFromScratch`,
create: () => createScreen(), create: () => createScreen(),
table: `Create from scratch`,
} }
const createScreen = () => { const createScreen = () => {

View File

@ -15,6 +15,7 @@ export default function (tables) {
name: `${table.name} - New`, name: `${table.name} - New`,
create: () => createScreen(table), create: () => createScreen(table),
id: NEW_ROW_TEMPLATE, id: NEW_ROW_TEMPLATE,
table: table.name,
} }
}) })
} }

View File

@ -17,6 +17,7 @@ export default function (tables) {
name: `${table.name} - Detail`, name: `${table.name} - Detail`,
create: () => createScreen(table), create: () => createScreen(table),
id: ROW_DETAIL_TEMPLATE, id: ROW_DETAIL_TEMPLATE,
table: table.name,
} }
}) })
} }

View File

@ -10,6 +10,7 @@ export default function (tables) {
name: `${table.name} - List`, name: `${table.name} - List`,
create: () => createScreen(table), create: () => createScreen(table),
id: ROW_LIST_TEMPLATE, id: ROW_LIST_TEMPLATE,
table: table.name,
} }
}) })
} }

View File

@ -21,13 +21,13 @@
$: autoSelected = selectedScreens?.length > 0 && !blankSelected $: autoSelected = selectedScreens?.length > 0 && !blankSelected
let templates = getTemplates($store, $tables.list) let templates = getTemplates($store, $tables.list)
const toggleScreenSelection = table => { const toggleScreenSelection = table => {
if (selectedScreens.find(s => s.name.includes(table.name))) { if (selectedScreens.find(s => s.table === table.name)) {
selectedScreens = selectedScreens.filter( selectedScreens = selectedScreens.filter(
screen => !screen.name.includes(table.name) screen => screen.table !== table.name
) )
} else { } else {
let partialTemplates = getTemplates($store, $tables.list).filter( let partialTemplates = getTemplates($store, $tables.list).filter(
template => template.name.includes(table.name) template => template.table === table.name
) )
selectedScreens = [...partialTemplates, ...selectedScreens] selectedScreens = [...partialTemplates, ...selectedScreens]
} }
@ -75,9 +75,7 @@
{#each $tables.list.filter(table => table._id !== "ta_users") as table} {#each $tables.list.filter(table => table._id !== "ta_users") as table}
<div <div
class:disabled={blankSelected} class:disabled={blankSelected}
class:selected={selectedScreens.find(x => class:selected={selectedScreens.find(x => x.table === table.name)}
x.name.includes(table.name)
)}
on:click={() => toggleScreenSelection(table)} on:click={() => toggleScreenSelection(table)}
class="item" class="item"
> >
@ -87,7 +85,7 @@
<div <div
style="color: var(--spectrum-global-color-green-600); float: right" style="color: var(--spectrum-global-color-green-600); float: right"
> >
{#if selectedScreens.find(x => x.name.includes(table.name))} {#if selectedScreens.find(x => x.table === table.name)}
<div class="checkmark-spacing"> <div class="checkmark-spacing">
<Icon size="S" name="CheckmarkCircleOutline" /> <Icon size="S" name="CheckmarkCircleOutline" />
</div> </div>

View File

@ -5,6 +5,7 @@
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 { onDestroy } from "svelte"
import analytics, { Events } from "analytics"
let newScreenModal let newScreenModal
let navigationSelectionModal let navigationSelectionModal
@ -21,6 +22,9 @@
for (let screen of selectedScreens) { for (let screen of selectedScreens) {
let test = screen.create() let test = screen.create()
createdScreens.push(test) createdScreens.push(test)
analytics.captureEvent(Events.SCREEN.CREATED, {
template: screen.id || screen.name,
})
} }
} }