Replace manual usage of square brackets with string-templates makePropSafe util

This commit is contained in:
Andrew Kingston 2021-11-12 15:28:08 +00:00
parent 04e8c4a932
commit cd94f72faa
3 changed files with 8 additions and 5 deletions

View File

@ -3,6 +3,7 @@
import Block from "components/Block.svelte" import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte" import BlockComponent from "components/BlockComponent.svelte"
import { Heading } from "@budibase/bbui" import { Heading } from "@budibase/bbui"
import { makePropSafe as safe } from "@budibase/string-templates"
export let title export let title
export let dataSource export let dataSource
@ -103,7 +104,7 @@
} }
const col = linkColumn || "_id" const col = linkColumn || "_id"
const split = url.split("/:") const split = url.split("/:")
return `${split[0]}/{{ [${repeaterId}].[${col}] }}` return `${split[0]}/{{ ${safe(repeaterId)}.${safe(col)} }}`
} }
// Load the datasource schema on mount so we can determine column types // Load the datasource schema on mount so we can determine column types
@ -171,7 +172,7 @@
bind:id={repeaterId} bind:id={repeaterId}
context="repeater" context="repeater"
props={{ props={{
dataProvider: `{{ literal [${dataProviderId}] }}`, dataProvider: `{{ literal ${safe(dataProviderId)} }}`,
direction: "row", direction: "row",
hAlign: "stretch", hAlign: "stretch",
vAlign: "top", vAlign: "top",

View File

@ -3,6 +3,7 @@
import Block from "components/Block.svelte" import Block from "components/Block.svelte"
import Placeholder from "components/app/Placeholder.svelte" import Placeholder from "components/app/Placeholder.svelte"
import { getContext } from "svelte" import { getContext } from "svelte"
import { makePropSafe as safe } from "@budibase/string-templates"
export let dataSource export let dataSource
export let filter export let filter
@ -44,7 +45,7 @@
type="repeater" type="repeater"
context="repeater" context="repeater"
props={{ props={{
dataProvider: `{{ literal [${providerId}] }}`, dataProvider: `{{ literal ${safe(providerId)} }}`,
noRowsMessage, noRowsMessage,
direction, direction,
hAlign, hAlign,

View File

@ -3,6 +3,7 @@
import Block from "components/Block.svelte" import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte" import BlockComponent from "components/BlockComponent.svelte"
import { Heading } from "@budibase/bbui" import { Heading } from "@budibase/bbui"
import { makePropSafe as safe } from "@budibase/string-templates"
export let title export let title
export let dataSource export let dataSource
@ -61,7 +62,7 @@
operator: column.type === "string" ? "string" : "equal", operator: column.type === "string" ? "string" : "equal",
type: "string", type: "string",
valueType: "Binding", valueType: "Binding",
value: `{{ [${formId}].[${column.name}] }}`, value: `{{ ${safe(formId)}.${safe(column.name)} }}`,
}) })
}) })
return enrichedFilter return enrichedFilter
@ -147,7 +148,7 @@
<BlockComponent <BlockComponent
type="table" type="table"
props={{ props={{
dataProvider: `{{ literal [${dataProviderId}] }}`, dataProvider: `{{ literal ${safe(dataProviderId)} }}`,
columns: tableColumns, columns: tableColumns,
showAutoColumns, showAutoColumns,
rowCount, rowCount,