1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00
This commit is contained in:
mike12345567 2021-01-21 11:32:26 +00:00
parent 3d33199f16
commit 8ecabc91cc
14 changed files with 95 additions and 74 deletions

View file

@ -11,9 +11,7 @@
on:click
class:big={subtitle != null}
{...$$restProps}>
{#if icon}
<i class={icon} />
{/if}
{#if icon}<i class={icon} />{/if}
<div class="content">
<div class="title">{title}</div>
{#if subtitle != null}

View file

@ -1,12 +1,6 @@
<script>
import groupBy from "lodash/fp/groupBy"
import {
Button,
TextArea,
Drawer,
Heading,
Spacer,
} from "@budibase/bbui"
import { Button, TextArea, Drawer, Heading, Spacer } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
@ -38,7 +32,9 @@
<Heading extraSmall>Tables</Heading>
<ul>
{#each context as { readableBinding }}
<li on:click={() => addToText(readableBinding)}>{readableBinding}</li>
<li on:click={() => addToText(readableBinding)}>
{readableBinding}
</li>
{/each}
</ul>
{/if}
@ -46,7 +42,9 @@
<Heading extraSmall>Components</Heading>
<ul>
{#each instance as { readableBinding }}
<li on:click={() => addToText(readableBinding)}>{readableBinding}</li>
<li on:click={() => addToText(readableBinding)}>
{readableBinding}
</li>
{/each}
</ul>
{/if}

View file

@ -1,9 +1,11 @@
<script context="module">
import iconData from "./icons.js"
const categories = Object.keys(iconData)
const icons = Object.keys(iconData).reduce((acc, cat) => [...acc, ...Object.keys(iconData[cat])], [])
const categories = Object.keys(iconData)
const icons = Object.keys(iconData).reduce(
(acc, cat) => [...acc, ...Object.keys(iconData[cat])],
[]
)
</script>
<script>
@ -285,4 +287,4 @@
.page-btn:hover {
cursor: pointer;
}
</style>
</style>

View file

@ -19,7 +19,7 @@
export let onChange = () => {}
let bindingDrawer
let temporaryBindableValue = value
let bindableProperties = []
let anchor
@ -103,20 +103,24 @@
</div>
<Drawer bind:this={bindingDrawer} title="Bindings">
<div slot="description"><Body extraSmall grey>Add the objects on the left to enrich your text.</Body></div>
<div slot="description">
<Body extraSmall grey>
Add the objects on the left to enrich your text.
</Body>
</div>
<heading slot="buttons">
<Button thin blue on:click={handleClose}>Save</Button>
</heading>
<div slot="body">
<BindingPanel {...handlevalueKey(value)}
close={handleClose}
on:update={e => (temporaryBindableValue = e.detail)}
{bindableProperties} />
<BindingPanel
{...handlevalueKey(value)}
close={handleClose}
on:update={e => (temporaryBindableValue = e.detail)}
{bindableProperties} />
</div>
</Drawer>
<style>
.property-control {
position: relative;
display: flex;

View file

@ -1,5 +1,12 @@
<script>
import { Button, Icon, DropdownMenu, Spacer, Heading, Drawer } from "@budibase/bbui"
import {
Button,
Icon,
DropdownMenu,
Spacer,
Heading,
Drawer,
} from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
import { store, backendUiStore, currentAsset } from "builderStore"
import { notifier } from "builderStore/store/notifications"
@ -91,34 +98,34 @@
</div>
{#if value.type === 'query'}
<i class="ri-settings-5-line" on:click={drawer.show} />
<Drawer title={'Query'}>
<div slot="buttons">
<Button
blue
thin
on:click={() => {
notifier.success('Query parameters saved.')
handleSelected(value)
drawer.hide()
}}>
Save
</Button>
</div>
<div class="drawer-contents" slot="body">
<IntegrationQueryEditor
query={value}
schema={fetchDatasourceSchema(value)}
editable={false} />
<Spacer large />
{#if value.parameters.length > 0}
<ParameterBuilder
bind:customParams={value.queryParams}
parameters={queries.find(query => query._id === value._id).parameters}
bindings={queryBindableProperties} />
{/if}
</div>
</Drawer>
{/if}
<Drawer title={'Query'}>
<div slot="buttons">
<Button
blue
thin
on:click={() => {
notifier.success('Query parameters saved.')
handleSelected(value)
drawer.hide()
}}>
Save
</Button>
</div>
<div class="drawer-contents" slot="body">
<IntegrationQueryEditor
query={value}
schema={fetchDatasourceSchema(value)}
editable={false} />
<Spacer large />
{#if value.parameters.length > 0}
<ParameterBuilder
bind:customParams={value.queryParams}
parameters={queries.find(query => query._id === value._id).parameters}
bindings={queryBindableProperties} />
{/if}
</div>
</Drawer>
{/if}
<DropdownMenu bind:this={dropdownRight} anchor={anchorRight}>
<div class="dropdown">
<div class="title">

View file

@ -14,10 +14,10 @@ const saveRowHandler = async (action, context) => {
const deleteRowHandler = async (action, context) => {
const { tableId, revId, rowId } = action.parameters
const [ enrichTable, enrichRow, enrichRev ] = await Promise.all([
const [enrichTable, enrichRow, enrichRev] = await Promise.all([
enrichDataBinding(tableId, context),
enrichDataBinding(rowId, context),
enrichDataBinding(revId, context)
enrichDataBinding(revId, context),
])
await deleteRow({
tableId: enrichTable,

View file

@ -22,7 +22,9 @@
<title>{title}</title>
<link rel="icon" type="image/png" href={favicon} />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
<link href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet">
<link
href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css"
rel="stylesheet" />
<style>
html,
body {

View file

@ -10,6 +10,4 @@
export let color = "#000"
</script>
<i
style={`color: ${color};`}
class={`${icon} ${size}`} />
<i style={`color: ${color};`} class={`${icon} ${size}`} />

View file

@ -191,4 +191,4 @@ module.exports = {
// Whether to use watchman for file crawling
// watchman: true,
};
}

View file

@ -11,7 +11,7 @@ export default {
name: "string-templates",
exports: "named",
globals: {
"fs": "fs",
fs: "fs",
},
},
external: ["fs"],

View file

@ -1,5 +1,10 @@
const { HelperFunctions } = require("../helpers")
const { swapStrings, isAlphaNumeric, FIND_HBS_REGEX, includesAny } = require("../utilities")
const {
swapStrings,
isAlphaNumeric,
FIND_HBS_REGEX,
includesAny,
} = require("../utilities")
function handleProcessor(string, match, fn) {
const output = fn(match)
@ -27,7 +32,9 @@ function handleSpacesInProperties(statement) {
// find all the parts split by spaces
const splitBySpaces = statement.split(" ")
// remove the excluded elements
const propertyParts = splitBySpaces.filter(part => exclusions.indexOf(part) === -1)
const propertyParts = splitBySpaces.filter(
part => exclusions.indexOf(part) === -1
)
// rebuild to get the full property
const fullProperty = propertyParts.join(" ")
// now work out the dot notation layers and split them up
@ -35,7 +42,12 @@ function handleSpacesInProperties(statement) {
// find the layers which need to be wrapped and wrap them
for (let layer of propertyLayers) {
if (layer.indexOf(" ") !== -1) {
statement = swapStrings(statement, statement.indexOf(layer), layer.length, `[${layer}]`)
statement = swapStrings(
statement,
statement.indexOf(layer),
layer.length,
`[${layer}]`
)
}
}
// remove the edge case of double brackets being entered (in-case user already has specified)
@ -67,7 +79,7 @@ function finalise(statement) {
* @param {string} string The string which *may* contain handlebars statements, it is OK if it does not contain any.
* @returns {string} The string that was input with processed up handlebars statements as required.
*/
module.exports.preprocess = (string) => {
module.exports.preprocess = string => {
let preprocessors = [swapToDotNotation, handleSpacesInProperties, finalise]
for (let processor of preprocessors) {
// re-run search each time incase previous cleaner update/removed a match
@ -81,4 +93,4 @@ module.exports.preprocess = (string) => {
}
}
return string
}
}

View file

@ -12,7 +12,7 @@ const HelperFunctionBuiltin = [
"#each",
"#with",
"lookup",
"log"
"log",
]
const HelperFunctionNames = {
@ -27,17 +27,19 @@ const HELPERS = [
}),
// this help is applied to all statements
new Helper(HelperFunctionNames.ALL, value => {
let text = new SafeString(unescape(value).replace(/&amp;/g, '&'))
let text = new SafeString(unescape(value).replace(/&amp;/g, "&"))
if (text == null || typeof text !== "string") {
return text
}
return text.replace(/[<>]/g, tag => {
return HTML_SWAPS[tag] || tag
})
})
}),
]
module.exports.HelperFunctions = Object.values(HelperFunctionNames).concat(HelperFunctionBuiltin)
module.exports.HelperFunctions = Object.values(HelperFunctionNames).concat(
HelperFunctionBuiltin
)
module.exports.registerAll = handlebars => {
for (let helper of HELPERS) {

View file

@ -30,8 +30,7 @@ module.exports.processObject = async (object, context) => {
let val = object[key]
if (typeof val === "string") {
object[key] = await module.exports.processString(object[key], context)
}
else if (typeof val === "object") {
} else if (typeof val === "object") {
object[key] = await module.exports.processObject(object[key], context)
}
}
@ -64,8 +63,7 @@ module.exports.processObjectSync = (object, context) => {
let val = object[key]
if (typeof val === "string") {
object[key] = module.exports.processStringSync(object[key], context)
}
else if (typeof val === "object") {
} else if (typeof val === "object") {
object[key] = module.exports.processObjectSync(object[key], context)
}
}

View file

@ -2,7 +2,7 @@ const ALPHA_NUMERIC_REGEX = /^[A-Za-z0-9]+$/g
module.exports.FIND_HBS_REGEX = /{{[^}}]*}}/g
module.exports.isAlphaNumeric = (char) => {
module.exports.isAlphaNumeric = char => {
return char.match(ALPHA_NUMERIC_REGEX)
}