Add new DetailScreenSelect component for selecting only detail screens and update detail linking in grids

This commit is contained in:
Andrew Kingston 2020-10-16 15:16:29 +01:00
parent 6694d33cfb
commit 8149ad848f
5 changed files with 63 additions and 20 deletions

View File

@ -0,0 +1,49 @@
<script>
import { DataList } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
import { store } from "builderStore"
const dispatch = createEventDispatcher()
export let value = ""
$: urls = getUrls()
const handleBlur = () => dispatch("change", value)
const getUrls = () => {
return [
...$store.screens
.filter(
screen =>
screen.props._component.endsWith("/rowdetail") ||
screen.route.endsWith(":id")
)
.map(screen => ({
name: screen.props._instanceName,
url: screen.route,
sort: screen.props._component,
})),
]
}
</script>
<div>
<DataList editable secondary thin on:blur={handleBlur} on:change bind:value>
<option value="" />
{#each urls as url}
<option value={url.url}>{url.name}</option>
{/each}
</DataList>
</div>
<style>
div {
flex: 1 1 auto;
display: flex;
flex-direction: row;
}
div :global(> div) {
flex: 1 1 auto;
}
</style>

View File

@ -6,6 +6,7 @@ import TableViewSelect from "components/userInterface/TableViewSelect.svelte"
import TableViewFieldSelect from "components/userInterface/TableViewFieldSelect.svelte" import TableViewFieldSelect from "components/userInterface/TableViewFieldSelect.svelte"
import Event from "components/userInterface/EventsEditor/EventPropertyControl.svelte" import Event from "components/userInterface/EventsEditor/EventPropertyControl.svelte"
import ScreenSelect from "components/userInterface/ScreenSelect.svelte" import ScreenSelect from "components/userInterface/ScreenSelect.svelte"
import DetailScreenSelect from "components/userInterface/DetailScreenSelect.svelte"
import { IconSelect } from "components/userInterface/IconSelect" import { IconSelect } from "components/userInterface/IconSelect"
import Colorpicker from "@budibase/colorpicker" import Colorpicker from "@budibase/colorpicker"
@ -328,10 +329,9 @@ export default {
control: TableViewSelect, control: TableViewSelect,
}, },
{ {
label: "Table URL", label: "Detail URL",
key: "detailUrl", key: "detailUrl",
placeholder: "tableName", control: DetailScreenSelect,
control: ScreenSelect,
}, },
{ {
label: "Editable", label: "Editable",

View File

@ -94,7 +94,7 @@
sortable: false, sortable: false,
cellRenderer: getRenderer({ cellRenderer: getRenderer({
type: "_id", type: "_id",
options: detailUrl, options: { detailUrl },
}), }),
autoHeight: true, autoHeight: true,
pinned: "left", pinned: "left",
@ -179,15 +179,9 @@
</div> </div>
<style> <style>
.container :global(.ag-pinned-left-header) {
border-right-color: #dde2eb !important;
}
.container :global(.ag-pinned-left-header .ag-header-cell-label) { .container :global(.ag-pinned-left-header .ag-header-cell-label) {
justify-content: center; justify-content: center;
} }
.container :global(.ag-cell-last-left-pinned) {
border-right-color: #dde2eb !important;
}
.controls { .controls {
min-height: 15px; min-height: 15px;

View File

@ -1,14 +1,11 @@
<script> <script>
import { createEventDispatcher } from "svelte" import { Button } from "@budibase/bbui"
import { Icon, Button } from "@budibase/bbui"
const dispatch = createEventDispatcher()
export let url export let url
let link let link
</script> </script>
<a href={url} bind:this={link} /> <a href={url} bind:this={link} />
<Button small secondary on:click={() => link.click()}>View</Button> <Button small translucent on:click={() => link.click()}>View</Button>
<style> <style>
a { a {

View File

@ -6,6 +6,7 @@ import ViewDetails from "./ViewDetails/Cell.svelte"
import Select from "./Select/Wrapper.svelte" import Select from "./Select/Wrapper.svelte"
import DatePicker from "./DateTime/Wrapper.svelte" import DatePicker from "./DateTime/Wrapper.svelte"
import RelationshipDisplay from "./Relationship/RelationshipDisplay.svelte" import RelationshipDisplay from "./Relationship/RelationshipDisplay.svelte"
import { detailUrl } from "./Component.svelte"
const renderers = new Map([ const renderers = new Map([
["boolean", booleanRenderer], ["boolean", booleanRenderer],
@ -80,8 +81,7 @@ function dateRenderer(options, constraints, editable) {
} }
// Options need to be passed in with minTime and maxTime! Needs bbui update. // Options need to be passed in with minTime and maxTime! Needs bbui update.
new DatePicker({
const datePickerInstance = new DatePicker({
target: container, target: container,
props: { props: {
value: params.value, value: params.value,
@ -144,11 +144,14 @@ function viewDetailsRenderer(options, constraints, editable) {
container.style.alignItems = "center" container.style.alignItems = "center"
container.style.height = "100%" container.style.height = "100%"
let url = "/"
if (options.detailUrl) {
url = options.detailUrl.replace(":id", params.data._id)
}
new ViewDetails({ new ViewDetails({
target: container, target: container,
props: { props: { url },
url: `${options}/${params.data._id}`,
},
}) })
return container return container