Add explicit prettier options
This commit is contained in:
parent
f13c4f4e90
commit
556236ebce
|
@ -3,6 +3,8 @@
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": false,
|
"singleQuote": false,
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"jsxBracketSameLine": false,
|
||||||
"plugins": ["prettier-plugin-svelte"],
|
"plugins": ["prettier-plugin-svelte"],
|
||||||
"svelteSortOrder" : "options-scripts-markup-styles"
|
"svelteSortOrder" : "options-scripts-markup-styles"
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
let Pouch
|
let Pouch
|
||||||
|
|
||||||
module.exports.setDB = (pouch) => {
|
module.exports.setDB = pouch => {
|
||||||
Pouch = pouch
|
Pouch = pouch
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getDB = (dbName) => {
|
module.exports.getDB = dbName => {
|
||||||
return new Pouch(dbName)
|
return new Pouch(dbName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ exports.getGroupParams = (id = "", otherProps = {}) => {
|
||||||
* Generates a new global user ID.
|
* Generates a new global user ID.
|
||||||
* @returns {string} The new user ID which the user doc can be stored under.
|
* @returns {string} The new user ID which the user doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateGlobalUserID = (id) => {
|
exports.generateGlobalUserID = id => {
|
||||||
return `${DocumentTypes.USER}${SEPARATOR}${id || newid()}`
|
return `${DocumentTypes.USER}${SEPARATOR}${id || newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ exports.getGlobalUserParams = (globalId, otherProps = {}) => {
|
||||||
* Generates a template ID.
|
* Generates a template ID.
|
||||||
* @param ownerId The owner/user of the template, this could be global or a group level.
|
* @param ownerId The owner/user of the template, this could be global or a group level.
|
||||||
*/
|
*/
|
||||||
exports.generateTemplateID = (ownerId) => {
|
exports.generateTemplateID = ownerId => {
|
||||||
return `${DocumentTypes.TEMPLATE}${SEPARATOR}${ownerId}${newid()}`
|
return `${DocumentTypes.TEMPLATE}${SEPARATOR}${ownerId}${newid()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ const determineScopedConfig = async function (db, { type, user, group }) {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
const configs = response.rows.map((row) => {
|
const configs = response.rows.map(row => {
|
||||||
const config = row.doc
|
const config = row.doc
|
||||||
|
|
||||||
// Config is specific to a user and a group
|
// Config is specific to a user and a group
|
||||||
|
|
|
@ -4,7 +4,7 @@ const { v4 } = require("uuid")
|
||||||
|
|
||||||
const SALT_ROUNDS = env.SALT_ROUNDS || 10
|
const SALT_ROUNDS = env.SALT_ROUNDS || 10
|
||||||
|
|
||||||
exports.hash = async (data) => {
|
exports.hash = async data => {
|
||||||
const salt = await bcrypt.genSalt(SALT_ROUNDS)
|
const salt = await bcrypt.genSalt(SALT_ROUNDS)
|
||||||
return bcrypt.hash(data, salt)
|
return bcrypt.hash(data, salt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ function confirmAppId(possibleAppId) {
|
||||||
* @param {object} ctx The main request body to look through.
|
* @param {object} ctx The main request body to look through.
|
||||||
* @returns {string|undefined} If an appId was found it will be returned.
|
* @returns {string|undefined} If an appId was found it will be returned.
|
||||||
*/
|
*/
|
||||||
exports.getAppId = (ctx) => {
|
exports.getAppId = ctx => {
|
||||||
const options = [ctx.headers["x-budibase-app-id"], ctx.params.appId]
|
const options = [ctx.headers["x-budibase-app-id"], ctx.params.appId]
|
||||||
if (ctx.subdomains) {
|
if (ctx.subdomains) {
|
||||||
options.push(ctx.subdomains[1])
|
options.push(ctx.subdomains[1])
|
||||||
|
@ -41,7 +41,7 @@ exports.getAppId = (ctx) => {
|
||||||
}
|
}
|
||||||
let appPath =
|
let appPath =
|
||||||
ctx.request.headers.referrer ||
|
ctx.request.headers.referrer ||
|
||||||
ctx.path.split("/").filter((subPath) => subPath.startsWith(APP_PREFIX))
|
ctx.path.split("/").filter(subPath => subPath.startsWith(APP_PREFIX))
|
||||||
if (!appId && appPath.length !== 0) {
|
if (!appId && appPath.length !== 0) {
|
||||||
appId = confirmAppId(appPath[0])
|
appId = confirmAppId(appPath[0])
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,11 @@ exports.clearCookie = (ctx, name) => {
|
||||||
* @param {object} ctx The koa context object to be tested.
|
* @param {object} ctx The koa context object to be tested.
|
||||||
* @return {boolean} returns true if the call is from the client lib (a built app rather than the builder).
|
* @return {boolean} returns true if the call is from the client lib (a built app rather than the builder).
|
||||||
*/
|
*/
|
||||||
exports.isClient = (ctx) => {
|
exports.isClient = ctx => {
|
||||||
return ctx.headers["x-budibase-type"] === "client"
|
return ctx.headers["x-budibase-type"] === "client"
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getGlobalUserByEmail = async (email) => {
|
exports.getGlobalUserByEmail = async email => {
|
||||||
const db = getDB(StaticDatabases.GLOBAL.name)
|
const db = getDB(StaticDatabases.GLOBAL.name)
|
||||||
try {
|
try {
|
||||||
let users = (
|
let users = (
|
||||||
|
@ -114,7 +114,7 @@ exports.getGlobalUserByEmail = async (email) => {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
})
|
})
|
||||||
).rows
|
).rows
|
||||||
users = users.map((user) => user.doc)
|
users = users.map(user => user.doc)
|
||||||
return users.length <= 1 ? users[0] : users
|
return users.length <= 1 ? users[0] : users
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err != null && err.name === "not_found") {
|
if (err != null && err.name === "not_found") {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// Attaches a spectrum-ActionGroup-item class to buttons inside the div
|
// Attaches a spectrum-ActionGroup-item class to buttons inside the div
|
||||||
function group(element) {
|
function group(element) {
|
||||||
const buttons = Array.from(element.getElementsByTagName("button"))
|
const buttons = Array.from(element.getElementsByTagName("button"))
|
||||||
buttons.forEach((button) => {
|
buttons.forEach(button => {
|
||||||
button.classList.add("spectrum-ActionGroup-item")
|
button.classList.add("spectrum-ActionGroup-item")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ export default function positionDropdown(element, { anchor, align }) {
|
||||||
element.style[positionSide] = `${dimensions[positionSide]}px`
|
element.style[positionSide] = `${dimensions[positionSide]}px`
|
||||||
element.style.left = `${calcLeftPosition(dimensions).toFixed(0)}px`
|
element.style.left = `${calcLeftPosition(dimensions).toFixed(0)}px`
|
||||||
|
|
||||||
const resizeObserver = new ResizeObserver((entries) => {
|
const resizeObserver = new ResizeObserver(entries => {
|
||||||
entries.forEach(() => {
|
entries.forEach(() => {
|
||||||
dimensions = getDimensions()
|
dimensions = getDimensions()
|
||||||
element.style[positionSide] = `${dimensions[positionSide]}px`
|
element.style[positionSide] = `${dimensions[positionSide]}px`
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
function group(element) {
|
function group(element) {
|
||||||
const buttons = Array.from(element.getElementsByTagName("button"))
|
const buttons = Array.from(element.getElementsByTagName("button"))
|
||||||
buttons.forEach((button) => {
|
buttons.forEach(button => {
|
||||||
button.classList.add("spectrum-ButtonGroup-item")
|
button.classList.add("spectrum-ButtonGroup-item")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
export let placeholder = "Choose an option"
|
export let placeholder = "Choose an option"
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => extractProperty(option, "label")
|
export let getOptionLabel = option => extractProperty(option, "label")
|
||||||
export let getOptionValue = (option) => extractProperty(option, "value")
|
export let getOptionValue = option => extractProperty(option, "value")
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (event) => {
|
const onChange = event => {
|
||||||
dispatch("change", event.target.checked)
|
dispatch("change", event.target.checked)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let error = null
|
export let error = null
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = (option) => option
|
export let getOptionValue = option => option
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let open = false
|
let open = false
|
||||||
|
@ -31,16 +31,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the label if the selected option is found, otherwise raw value
|
// Render the label if the selected option is found, otherwise raw value
|
||||||
const selected = options.find((option) => getOptionValue(option) === value)
|
const selected = options.find(option => getOptionValue(option) === value)
|
||||||
return selected ? getOptionLabel(selected) : value
|
return selected ? getOptionLabel(selected) : value
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectOption = (value) => {
|
const selectOption = value => {
|
||||||
dispatch("change", value)
|
dispatch("change", value)
|
||||||
open = false
|
open = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
selectOption(e.target.value)
|
selectOption(e.target.value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
wrap: true,
|
wrap: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = event => {
|
||||||
const [dates] = event.detail
|
const [dates] = event.detail
|
||||||
dispatch("change", dates[0])
|
dispatch("change", dates[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearDateOnBackspace = (event) => {
|
const clearDateOnBackspace = event => {
|
||||||
if (["Backspace", "Clear", "Delete"].includes(event.key)) {
|
if (["Backspace", "Clear", "Delete"].includes(event.key)) {
|
||||||
dispatch("change", null)
|
dispatch("change", null)
|
||||||
flatpickr.close()
|
flatpickr.close()
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
// We need to blur both because the focus styling does not get properly
|
// We need to blur both because the focus styling does not get properly
|
||||||
// applied.
|
// applied.
|
||||||
const els = document.querySelectorAll(`#${flatpickrId} input`)
|
const els = document.querySelectorAll(`#${flatpickrId} input`)
|
||||||
els.forEach((el) => el.blur())
|
els.forEach(el => el.blur())
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"bmp",
|
"bmp",
|
||||||
"jfif",
|
"jfif",
|
||||||
]
|
]
|
||||||
const onChange = (event) => {
|
const onChange = event => {
|
||||||
dispatch("change", event.target.checked)
|
dispatch("change", event.target.checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
async function processFileList(fileList) {
|
async function processFileList(fileList) {
|
||||||
if (
|
if (
|
||||||
handleFileTooLarge &&
|
handleFileTooLarge &&
|
||||||
Array.from(fileList).some((file) => file.size >= fileSizeLimit)
|
Array.from(fileList).some(file => file.size >= fileSizeLimit)
|
||||||
) {
|
) {
|
||||||
handleFileTooLarge(fileSizeLimit, value)
|
handleFileTooLarge(fileSizeLimit, value)
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let error = null
|
export let error = null
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = (option) => option
|
export let getOptionValue = option => option
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
$: selectedLookupMap = getSelectedLookupMap(value)
|
$: selectedLookupMap = getSelectedLookupMap(value)
|
||||||
$: optionLookupMap = getOptionLookupMap(options)
|
$: optionLookupMap = getOptionLookupMap(options)
|
||||||
$: fieldText = getFieldText(value, optionLookupMap, placeholder)
|
$: fieldText = getFieldText(value, optionLookupMap, placeholder)
|
||||||
$: isOptionSelected = (optionValue) => selectedLookupMap[optionValue] === true
|
$: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true
|
||||||
$: toggleOption = makeToggleOption(selectedLookupMap, value)
|
$: toggleOption = makeToggleOption(selectedLookupMap, value)
|
||||||
|
|
||||||
const getFieldText = (value, map, placeholder) => {
|
const getFieldText = (value, map, placeholder) => {
|
||||||
|
@ -23,17 +23,17 @@
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
const vals = value.map((option) => map[option] || option).join(", ")
|
const vals = value.map(option => map[option] || option).join(", ")
|
||||||
return `(${value.length}) ${vals}`
|
return `(${value.length}) ${vals}`
|
||||||
} else {
|
} else {
|
||||||
return placeholder || "Choose some options"
|
return placeholder || "Choose some options"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSelectedLookupMap = (value) => {
|
const getSelectedLookupMap = value => {
|
||||||
let map = {}
|
let map = {}
|
||||||
if (value?.length) {
|
if (value?.length) {
|
||||||
value.forEach((option) => {
|
value.forEach(option => {
|
||||||
if (option) {
|
if (option) {
|
||||||
map[option] = true
|
map[option] = true
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOptionLookupMap = (options) => {
|
const getOptionLookupMap = options => {
|
||||||
let map = null
|
let map = null
|
||||||
if (options?.length) {
|
if (options?.length) {
|
||||||
map = {}
|
map = {}
|
||||||
|
@ -57,9 +57,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeToggleOption = (map, value) => {
|
const makeToggleOption = (map, value) => {
|
||||||
return (optionValue) => {
|
return optionValue => {
|
||||||
if (map[optionValue]) {
|
if (map[optionValue]) {
|
||||||
const filtered = value.filter((option) => option !== optionValue)
|
const filtered = value.filter(option => option !== optionValue)
|
||||||
dispatch("change", filtered)
|
dispatch("change", filtered)
|
||||||
} else {
|
} else {
|
||||||
dispatch("change", [...value, optionValue])
|
dispatch("change", [...value, optionValue])
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
export let options = []
|
export let options = []
|
||||||
export let isOptionSelected = () => false
|
export let isOptionSelected = () => false
|
||||||
export let onSelectOption = () => {}
|
export let onSelectOption = () => {}
|
||||||
export let getOptionLabel = (option) => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = (option) => option
|
export let getOptionValue = option => option
|
||||||
export let open = false
|
export let open = false
|
||||||
export let readonly = false
|
export let readonly = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onClick = (e) => {
|
const onClick = e => {
|
||||||
dispatch("click")
|
dispatch("click")
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
export let options = []
|
export let options = []
|
||||||
export let error = null
|
export let error = null
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let getOptionLabel = (option) => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = (option) => option
|
export let getOptionValue = option => option
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => dispatch("change", e.target.value)
|
const onChange = e => dispatch("change", e.target.value)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={`spectrum-FieldGroup spectrum-FieldGroup--${direction}`}>
|
<div class={`spectrum-FieldGroup spectrum-FieldGroup--${direction}`}>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let focus = false
|
let focus = false
|
||||||
|
|
||||||
const updateValue = (value) => {
|
const updateValue = value => {
|
||||||
dispatch("change", value)
|
dispatch("change", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@
|
||||||
focus = true
|
focus = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const onBlur = (event) => {
|
const onBlur = event => {
|
||||||
focus = false
|
focus = false
|
||||||
updateValue(event.target.value)
|
updateValue(event.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateValueOnEnter = (event) => {
|
const updateValueOnEnter = event => {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
updateValue(event.target.value)
|
updateValue(event.target.value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let error = null
|
export let error = null
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = (option) => option
|
export let getOptionValue = option => option
|
||||||
export let readonly = false
|
export let readonly = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
return index !== -1 ? getOptionLabel(options[index], index) : value
|
return index !== -1 ? getOptionLabel(options[index], index) : value
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectOption = (value) => {
|
const selectOption = value => {
|
||||||
dispatch("change", value)
|
dispatch("change", value)
|
||||||
open = false
|
open = false
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,6 @@
|
||||||
{getOptionValue}
|
{getOptionValue}
|
||||||
isPlaceholder={value == null || value === ""}
|
isPlaceholder={value == null || value === ""}
|
||||||
placeholderOption={placeholder}
|
placeholderOption={placeholder}
|
||||||
isOptionSelected={(option) => option === value}
|
isOptionSelected={option => option === value}
|
||||||
onSelectOption={selectOption}
|
onSelectOption={selectOption}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (event) => {
|
const onChange = event => {
|
||||||
dispatch("change", event.target.checked)
|
dispatch("change", event.target.checked)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
let focus = false
|
let focus = false
|
||||||
let textarea
|
let textarea
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (event) => {
|
const onChange = event => {
|
||||||
dispatch("change", event.target.value)
|
dispatch("change", event.target.value)
|
||||||
focus = false
|
focus = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let focus = false
|
let focus = false
|
||||||
|
|
||||||
const updateValue = (value) => {
|
const updateValue = value => {
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
focus = true
|
focus = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const onBlur = (event) => {
|
const onBlur = event => {
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
updateValue(event.target.value)
|
updateValue(event.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateValueOnEnter = (event) => {
|
const updateValueOnEnter = event => {
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
export let handleFileTooLarge = undefined
|
export let handleFileTooLarge = undefined
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = (option) => option
|
export let getOptionValue = option => option
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
export let labelPosition = "above"
|
export let labelPosition = "above"
|
||||||
export let error = null
|
export let error = null
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => extractProperty(option, "label")
|
export let getOptionLabel = option => extractProperty(option, "label")
|
||||||
export let getOptionValue = (option) => extractProperty(option, "value")
|
export let getOptionValue = option => extractProperty(option, "value")
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
export let placeholder = "Choose an option"
|
export let placeholder = "Choose an option"
|
||||||
export let options = []
|
export let options = []
|
||||||
export let getOptionLabel = (option) => extractProperty(option, "label")
|
export let getOptionLabel = option => extractProperty(option, "label")
|
||||||
export let getOptionValue = (option) => extractProperty(option, "value")
|
export let getOptionValue = option => extractProperty(option, "value")
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
export let getCaretPosition = null
|
export let getCaretPosition = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = (e) => {
|
const onChange = e => {
|
||||||
value = e.detail
|
value = e.detail
|
||||||
dispatch("change", e.detail)
|
dispatch("change", e.detail)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ export const createNotificationStore = () => {
|
||||||
const _notifications = writable([], () => {
|
const _notifications = writable([], () => {
|
||||||
return () => {
|
return () => {
|
||||||
// clear all the timers
|
// clear all the timers
|
||||||
timeoutIds.forEach((timeoutId) => {
|
timeoutIds.forEach(timeoutId => {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
})
|
})
|
||||||
_notifications.set([])
|
_notifications.set([])
|
||||||
|
@ -25,11 +25,11 @@ export const createNotificationStore = () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _id = id()
|
let _id = id()
|
||||||
_notifications.update((state) => {
|
_notifications.update(state => {
|
||||||
return [...state, { id: _id, type, message, icon }]
|
return [...state, { id: _id, type, message, icon }]
|
||||||
})
|
})
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
_notifications.update((state) => {
|
_notifications.update(state => {
|
||||||
return state.filter(({ id }) => id !== _id)
|
return state.filter(({ id }) => id !== _id)
|
||||||
})
|
})
|
||||||
}, NOTIFICATION_TIMEOUT)
|
}, NOTIFICATION_TIMEOUT)
|
||||||
|
@ -41,10 +41,10 @@ export const createNotificationStore = () => {
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
send,
|
send,
|
||||||
info: (msg) => send(msg, "info", "Info"),
|
info: msg => send(msg, "info", "Info"),
|
||||||
error: (msg) => send(msg, "error", "Alert"),
|
error: msg => send(msg, "error", "Alert"),
|
||||||
warning: (msg) => send(msg, "warning", "Alert"),
|
warning: msg => send(msg, "warning", "Alert"),
|
||||||
success: (msg) => send(msg, "success", "CheckmarkCircle"),
|
success: msg => send(msg, "success", "CheckmarkCircle"),
|
||||||
blockNotifications,
|
blockNotifications,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
$: leftover = (value?.length ?? 0) - attachments.length
|
$: leftover = (value?.length ?? 0) - attachments.length
|
||||||
|
|
||||||
const imageExtensions = ["png", "tiff", "gif", "raw", "jpg", "jpeg"]
|
const imageExtensions = ["png", "tiff", "gif", "raw", "jpg", "jpeg"]
|
||||||
const isImage = (extension) => {
|
const isImage = extension => {
|
||||||
return imageExtensions.includes(extension?.toLowerCase())
|
return imageExtensions.includes(extension?.toLowerCase())
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
longform: StringRenderer,
|
longform: StringRenderer,
|
||||||
}
|
}
|
||||||
$: type = schema?.type ?? "string"
|
$: type = schema?.type ?? "string"
|
||||||
$: customRenderer = customRenderers?.find((x) => x.column === schema?.name)
|
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
||||||
$: renderer = customRenderer?.component ?? typeMap[type]
|
$: renderer = customRenderer?.component ?? typeMap[type]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
$: relationships = value?.slice(0, displayLimit) ?? []
|
$: relationships = value?.slice(0, displayLimit) ?? []
|
||||||
$: leftover = (value?.length ?? 0) - relationships.length
|
$: leftover = (value?.length ?? 0) - relationships.length
|
||||||
|
|
||||||
const onClick = (e) => {
|
const onClick = e => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
dispatch("clickrelationship", {
|
dispatch("clickrelationship", {
|
||||||
tableId: row.tableId,
|
tableId: row.tableId,
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
timeout = null
|
timeout = null
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixSchema = (schema) => {
|
const fixSchema = schema => {
|
||||||
let fixedSchema = {}
|
let fixedSchema = {}
|
||||||
Object.entries(schema || {}).forEach(([fieldName, fieldSchema]) => {
|
Object.entries(schema || {}).forEach(([fieldName, fieldSchema]) => {
|
||||||
if (typeof fieldSchema === "string") {
|
if (typeof fieldSchema === "string") {
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortBy = (fieldSchema) => {
|
const sortBy = fieldSchema => {
|
||||||
if (fieldSchema.sortable === false) {
|
if (fieldSchema.sortable === false) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDisplayName = (schema) => {
|
const getDisplayName = schema => {
|
||||||
let name = schema?.displayName
|
let name = schema?.displayName
|
||||||
if (schema && name === undefined) {
|
if (schema && name === undefined) {
|
||||||
name = schema.name
|
name = schema.name
|
||||||
|
@ -155,10 +155,10 @@
|
||||||
return nameA < nameB ? a : b
|
return nameA < nameB ? a : b
|
||||||
})
|
})
|
||||||
.concat(autoColumns)
|
.concat(autoColumns)
|
||||||
.map((column) => column.name)
|
.map(column => column.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onScroll = (event) => {
|
const onScroll = event => {
|
||||||
nextScrollTop = event.target.scrollTop
|
nextScrollTop = event.target.scrollTop
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
return
|
return
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
const calculateFirstVisibleRow = (scrollTop) => {
|
const calculateFirstVisibleRow = scrollTop => {
|
||||||
return Math.max(Math.floor(scrollTop / (rowHeight + 1)) - rowPreload, 0)
|
return Math.max(Math.floor(scrollTop / (rowHeight + 1)) - rowPreload, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,12 +190,12 @@
|
||||||
dispatch("editrow", row)
|
dispatch("editrow", row)
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleSelectRow = (row) => {
|
const toggleSelectRow = row => {
|
||||||
if (!allowSelectRows) {
|
if (!allowSelectRows) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (selectedRows.includes(row)) {
|
if (selectedRows.includes(row)) {
|
||||||
selectedRows = selectedRows.filter((selectedRow) => selectedRow !== row)
|
selectedRows = selectedRows.filter(selectedRow => selectedRow !== row)
|
||||||
} else {
|
} else {
|
||||||
selectedRows = [...selectedRows, row]
|
selectedRows = [...selectedRows, row]
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
<svg
|
<svg
|
||||||
class="spectrum-Icon spectrum-Table-editIcon"
|
class="spectrum-Icon spectrum-Table-editIcon"
|
||||||
focusable="false"
|
focusable="false"
|
||||||
on:click={(e) => editColumn(e, field)}
|
on:click={e => editColumn(e, field)}
|
||||||
>
|
>
|
||||||
<use xlink:href="#spectrum-icon-18-Edit" />
|
<use xlink:href="#spectrum-icon-18-Edit" />
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -286,7 +286,7 @@
|
||||||
data={row}
|
data={row}
|
||||||
selected={selectedRows.includes(row)}
|
selected={selectedRows.includes(row)}
|
||||||
onToggleSelection={() => toggleSelectRow(row)}
|
onToggleSelection={() => toggleSelectRow(row)}
|
||||||
onEdit={(e) => editRow(e, row)}
|
onEdit={e => editRow(e, row)}
|
||||||
{allowSelectRows}
|
{allowSelectRows}
|
||||||
{allowEditRows}
|
{allowEditRows}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
Cypress.Commands.add("login", () => {
|
Cypress.Commands.add("login", () => {
|
||||||
cy.getCookie("budibase:auth").then((cookie) => {
|
cy.getCookie("budibase:auth").then(cookie => {
|
||||||
// Already logged in
|
// Already logged in
|
||||||
if (cookie) return
|
if (cookie) return
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ Cypress.Commands.add("login", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add("createApp", (name) => {
|
Cypress.Commands.add("createApp", name => {
|
||||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||||
// wait for init API calls on visit
|
// wait for init API calls on visit
|
||||||
cy.wait(100)
|
cy.wait(100)
|
||||||
cy.contains("Create New Web App").click()
|
cy.contains("Create New Web App").click()
|
||||||
cy.get("body")
|
cy.get("body")
|
||||||
.then(($body) => {
|
.then($body => {
|
||||||
if ($body.find("input[name=apiKey]").length) {
|
if ($body.find("input[name=apiKey]").length) {
|
||||||
// input was found, do something else here
|
// input was found, do something else here
|
||||||
cy.get("input[name=apiKey]").type(name).should("have.value", name)
|
cy.get("input[name=apiKey]").type(name).should("have.value", name)
|
||||||
|
@ -50,9 +50,9 @@ Cypress.Commands.add("createApp", (name) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add("deleteApp", (name) => {
|
Cypress.Commands.add("deleteApp", name => {
|
||||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||||
cy.get(".apps").then(($apps) => {
|
cy.get(".apps").then($apps => {
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
if ($apps.find(`[data-cy="app-${name}"]`).length) {
|
if ($apps.find(`[data-cy="app-${name}"]`).length) {
|
||||||
cy.get(`[data-cy="app-${name}"]`).contains("Open").click()
|
cy.get(`[data-cy="app-${name}"]`).contains("Open").click()
|
||||||
|
@ -78,7 +78,7 @@ Cypress.Commands.add("createTestTableWithData", () => {
|
||||||
cy.addColumn("dog", "age", "Number")
|
cy.addColumn("dog", "age", "Number")
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add("createTable", (tableName) => {
|
Cypress.Commands.add("createTable", tableName => {
|
||||||
// Enter table name
|
// Enter table name
|
||||||
cy.get("[data-cy=new-table]").click()
|
cy.get("[data-cy=new-table]").click()
|
||||||
cy.get(".spectrum-Modal").within(() => {
|
cy.get(".spectrum-Modal").within(() => {
|
||||||
|
@ -104,7 +104,7 @@ Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add("addRow", (values) => {
|
Cypress.Commands.add("addRow", values => {
|
||||||
cy.contains("Create row").click()
|
cy.contains("Create row").click()
|
||||||
cy.get(".spectrum-Modal").within(() => {
|
cy.get(".spectrum-Modal").within(() => {
|
||||||
for (let i = 0; i < values.length; i++) {
|
for (let i = 0; i < values.length; i++) {
|
||||||
|
@ -134,7 +134,7 @@ Cypress.Commands.add("addComponent", (category, component) => {
|
||||||
}
|
}
|
||||||
cy.get(`[data-cy="component-${component}"]`).click()
|
cy.get(`[data-cy="component-${component}"]`).click()
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
cy.location().then((loc) => {
|
cy.location().then(loc => {
|
||||||
const params = loc.pathname.split("/")
|
const params = loc.pathname.split("/")
|
||||||
const componentId = params[params.length - 1]
|
const componentId = params[params.length - 1]
|
||||||
cy.getComponent(componentId).should("exist")
|
cy.getComponent(componentId).should("exist")
|
||||||
|
@ -142,7 +142,7 @@ Cypress.Commands.add("addComponent", (category, component) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add("getComponent", (componentId) => {
|
Cypress.Commands.add("getComponent", componentId => {
|
||||||
return cy
|
return cy
|
||||||
.get("iframe")
|
.get("iframe")
|
||||||
.its("0.contentDocument")
|
.its("0.contentDocument")
|
||||||
|
|
|
@ -32,7 +32,7 @@ function identify(id) {
|
||||||
if (!analyticsEnabled || !id) return
|
if (!analyticsEnabled || !id) return
|
||||||
if (posthogConfigured) posthog.identify(id)
|
if (posthogConfigured) posthog.identify(id)
|
||||||
if (sentryConfigured)
|
if (sentryConfigured)
|
||||||
Sentry.configureScope((scope) => {
|
Sentry.configureScope(scope => {
|
||||||
scope.setUser({ id: id })
|
scope.setUser({ id: id })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ if (!localStorage.getItem(APP_FIRST_STARTED_KEY)) {
|
||||||
localStorage.setItem(APP_FIRST_STARTED_KEY, Date.now())
|
localStorage.setItem(APP_FIRST_STARTED_KEY, Date.now())
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFeedbackTimeElapsed = (sinceDateStr) => {
|
const isFeedbackTimeElapsed = sinceDateStr => {
|
||||||
const sinceDate = parseFloat(sinceDateStr)
|
const sinceDate = parseFloat(sinceDateStr)
|
||||||
const feedbackMilliseconds = feedbackHours * 60 * 60 * 1000
|
const feedbackMilliseconds = feedbackHours * 60 * 60 * 1000
|
||||||
return Date.now() > sinceDate + feedbackMilliseconds
|
return Date.now() > sinceDate + feedbackMilliseconds
|
||||||
|
@ -107,7 +107,7 @@ function highlightFeedbackIcon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opt In/Out
|
// Opt In/Out
|
||||||
const ifAnalyticsEnabled = (func) => () => {
|
const ifAnalyticsEnabled = func => () => {
|
||||||
if (analyticsEnabled && process.env.POSTHOG_TOKEN) {
|
if (analyticsEnabled && process.env.POSTHOG_TOKEN) {
|
||||||
return func()
|
return func()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { store } from "./index"
|
||||||
import { get as svelteGet } from "svelte/store"
|
import { get as svelteGet } from "svelte/store"
|
||||||
import { removeCookie, Cookies } from "./cookies"
|
import { removeCookie, Cookies } from "./cookies"
|
||||||
|
|
||||||
const apiCall = (method) => async (
|
const apiCall = method => async (
|
||||||
url,
|
url,
|
||||||
body,
|
body,
|
||||||
headers = { "Content-Type": "application/json" }
|
headers = { "Content-Type": "application/json" }
|
||||||
|
|
|
@ -4,7 +4,7 @@ export const Cookies = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCookie(cookieName) {
|
export function getCookie(cookieName) {
|
||||||
return document.cookie.split(";").some((cookie) => {
|
return document.cookie.split(";").some(cookie => {
|
||||||
return cookie.trim().startsWith(`${cookieName}=`)
|
return cookie.trim().startsWith(`${cookieName}=`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ export const getDataProviderComponents = (asset, componentId) => {
|
||||||
path.pop()
|
path.pop()
|
||||||
|
|
||||||
// Filter by only data provider components
|
// Filter by only data provider components
|
||||||
return path.filter((component) => {
|
return path.filter(component => {
|
||||||
const def = store.actions.components.getDefinition(component._component)
|
const def = store.actions.components.getDefinition(component._component)
|
||||||
return def?.context != null
|
return def?.context != null
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@ export const getActionProviderComponents = (asset, componentId, actionType) => {
|
||||||
path.pop()
|
path.pop()
|
||||||
|
|
||||||
// Filter by only data provider components
|
// Filter by only data provider components
|
||||||
return path.filter((component) => {
|
return path.filter(component => {
|
||||||
const def = store.actions.components.getDefinition(component._component)
|
const def = store.actions.components.getDefinition(component._component)
|
||||||
return def?.actions?.includes(actionType)
|
return def?.actions?.includes(actionType)
|
||||||
})
|
})
|
||||||
|
@ -70,7 +70,7 @@ export const getDatasourceForProvider = (asset, component) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this component has a dataProvider setting, go up the stack and use it
|
// If this component has a dataProvider setting, go up the stack and use it
|
||||||
const dataProviderSetting = def.settings.find((setting) => {
|
const dataProviderSetting = def.settings.find(setting => {
|
||||||
return setting.type === "dataProvider"
|
return setting.type === "dataProvider"
|
||||||
})
|
})
|
||||||
if (dataProviderSetting) {
|
if (dataProviderSetting) {
|
||||||
|
@ -82,7 +82,7 @@ export const getDatasourceForProvider = (asset, component) => {
|
||||||
|
|
||||||
// Extract datasource from component instance
|
// Extract datasource from component instance
|
||||||
const validSettingTypes = ["dataSource", "table", "schema"]
|
const validSettingTypes = ["dataSource", "table", "schema"]
|
||||||
const datasourceSetting = def.settings.find((setting) => {
|
const datasourceSetting = def.settings.find(setting => {
|
||||||
return validSettingTypes.includes(setting.type)
|
return validSettingTypes.includes(setting.type)
|
||||||
})
|
})
|
||||||
if (!datasourceSetting) {
|
if (!datasourceSetting) {
|
||||||
|
@ -112,7 +112,7 @@ const getContextBindings = (asset, componentId) => {
|
||||||
let bindings = []
|
let bindings = []
|
||||||
|
|
||||||
// Create bindings for each data provider
|
// Create bindings for each data provider
|
||||||
dataProviders.forEach((component) => {
|
dataProviders.forEach(component => {
|
||||||
const def = store.actions.components.getDefinition(component._component)
|
const def = store.actions.components.getDefinition(component._component)
|
||||||
const contextDefinition = def.context
|
const contextDefinition = def.context
|
||||||
let schema
|
let schema
|
||||||
|
@ -127,7 +127,7 @@ const getContextBindings = (asset, componentId) => {
|
||||||
// Static contexts are fully defined by the components
|
// Static contexts are fully defined by the components
|
||||||
schema = {}
|
schema = {}
|
||||||
const values = contextDefinition.values || []
|
const values = contextDefinition.values || []
|
||||||
values.forEach((value) => {
|
values.forEach(value => {
|
||||||
schema[value.key] = { name: value.label, type: "string" }
|
schema[value.key] = { name: value.label, type: "string" }
|
||||||
})
|
})
|
||||||
} else if (contextDefinition.type === "schema") {
|
} else if (contextDefinition.type === "schema") {
|
||||||
|
@ -148,7 +148,7 @@ const getContextBindings = (asset, componentId) => {
|
||||||
|
|
||||||
// Create bindable properties for each schema field
|
// Create bindable properties for each schema field
|
||||||
const safeComponentId = makePropSafe(component._id)
|
const safeComponentId = makePropSafe(component._id)
|
||||||
keys.forEach((key) => {
|
keys.forEach(key => {
|
||||||
const fieldSchema = schema[key]
|
const fieldSchema = schema[key]
|
||||||
|
|
||||||
// Make safe runtime binding and replace certain bindings with a
|
// Make safe runtime binding and replace certain bindings with a
|
||||||
|
@ -197,7 +197,7 @@ const getUserBindings = () => {
|
||||||
})
|
})
|
||||||
const keys = Object.keys(schema).sort()
|
const keys = Object.keys(schema).sort()
|
||||||
const safeUser = makePropSafe("user")
|
const safeUser = makePropSafe("user")
|
||||||
keys.forEach((key) => {
|
keys.forEach(key => {
|
||||||
const fieldSchema = schema[key]
|
const fieldSchema = schema[key]
|
||||||
// Replace certain bindings with a new property to help display components
|
// Replace certain bindings with a new property to help display components
|
||||||
let runtimeBoundKey = key
|
let runtimeBoundKey = key
|
||||||
|
@ -224,17 +224,17 @@ const getUserBindings = () => {
|
||||||
/**
|
/**
|
||||||
* Gets all bindable properties from URL parameters.
|
* Gets all bindable properties from URL parameters.
|
||||||
*/
|
*/
|
||||||
const getUrlBindings = (asset) => {
|
const getUrlBindings = asset => {
|
||||||
const url = asset?.routing?.route ?? ""
|
const url = asset?.routing?.route ?? ""
|
||||||
const split = url.split("/")
|
const split = url.split("/")
|
||||||
let params = []
|
let params = []
|
||||||
split.forEach((part) => {
|
split.forEach(part => {
|
||||||
if (part.startsWith(":") && part.length > 1) {
|
if (part.startsWith(":") && part.length > 1) {
|
||||||
params.push(part.replace(/:/g, "").replace(/\?/g, ""))
|
params.push(part.replace(/:/g, "").replace(/\?/g, ""))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const safeURL = makePropSafe("url")
|
const safeURL = makePropSafe("url")
|
||||||
return params.map((param) => ({
|
return params.map(param => ({
|
||||||
type: "context",
|
type: "context",
|
||||||
runtimeBinding: `${safeURL}.${makePropSafe(param)}`,
|
runtimeBinding: `${safeURL}.${makePropSafe(param)}`,
|
||||||
readableBinding: `URL.${param}`,
|
readableBinding: `URL.${param}`,
|
||||||
|
@ -250,10 +250,10 @@ export const getSchemaForDatasource = (datasource, isForm = false) => {
|
||||||
const { type } = datasource
|
const { type } = datasource
|
||||||
if (type === "query") {
|
if (type === "query") {
|
||||||
const queries = get(queriesStores).list
|
const queries = get(queriesStores).list
|
||||||
table = queries.find((query) => query._id === datasource._id)
|
table = queries.find(query => query._id === datasource._id)
|
||||||
} else {
|
} else {
|
||||||
const tables = get(tablesStore).list
|
const tables = get(tablesStore).list
|
||||||
table = tables.find((table) => table._id === datasource.tableId)
|
table = tables.find(table => table._id === datasource.tableId)
|
||||||
}
|
}
|
||||||
if (table) {
|
if (table) {
|
||||||
if (type === "view") {
|
if (type === "view") {
|
||||||
|
@ -261,7 +261,7 @@ export const getSchemaForDatasource = (datasource, isForm = false) => {
|
||||||
} else if (type === "query" && isForm) {
|
} else if (type === "query" && isForm) {
|
||||||
schema = {}
|
schema = {}
|
||||||
const params = table.parameters || []
|
const params = table.parameters || []
|
||||||
params.forEach((param) => {
|
params.forEach(param => {
|
||||||
if (param?.name) {
|
if (param?.name) {
|
||||||
schema[param.name] = { ...param, type: "string" }
|
schema[param.name] = { ...param, type: "string" }
|
||||||
}
|
}
|
||||||
|
@ -302,14 +302,14 @@ export const getSchemaForDatasource = (datasource, isForm = false) => {
|
||||||
* Builds a form schema given a form component.
|
* Builds a form schema given a form component.
|
||||||
* A form schema is a schema of all the fields nested anywhere within a form.
|
* A form schema is a schema of all the fields nested anywhere within a form.
|
||||||
*/
|
*/
|
||||||
const buildFormSchema = (component) => {
|
const buildFormSchema = component => {
|
||||||
let schema = {}
|
let schema = {}
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return schema
|
return schema
|
||||||
}
|
}
|
||||||
const def = store.actions.components.getDefinition(component._component)
|
const def = store.actions.components.getDefinition(component._component)
|
||||||
const fieldSetting = def?.settings?.find(
|
const fieldSetting = def?.settings?.find(
|
||||||
(setting) => setting.key === "field" && setting.type.startsWith("field/")
|
setting => setting.key === "field" && setting.type.startsWith("field/")
|
||||||
)
|
)
|
||||||
if (fieldSetting && component.field) {
|
if (fieldSetting && component.field) {
|
||||||
const type = fieldSetting.type.split("field/")[1]
|
const type = fieldSetting.type.split("field/")[1]
|
||||||
|
@ -317,7 +317,7 @@ const buildFormSchema = (component) => {
|
||||||
schema[component.field] = { type }
|
schema[component.field] = { type }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
component._children?.forEach((child) => {
|
component._children?.forEach(child => {
|
||||||
const childSchema = buildFormSchema(child)
|
const childSchema = buildFormSchema(child)
|
||||||
schema = { ...schema, ...childSchema }
|
schema = { ...schema, ...childSchema }
|
||||||
})
|
})
|
||||||
|
@ -348,7 +348,7 @@ function bindingReplacement(bindableProperties, textWithBindings, convertTo) {
|
||||||
return textWithBindings
|
return textWithBindings
|
||||||
}
|
}
|
||||||
const convertFromProps = bindableProperties
|
const convertFromProps = bindableProperties
|
||||||
.map((el) => el[convertFrom])
|
.map(el => el[convertFrom])
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return b.length - a.length
|
return b.length - a.length
|
||||||
})
|
})
|
||||||
|
@ -358,9 +358,7 @@ function bindingReplacement(bindableProperties, textWithBindings, convertTo) {
|
||||||
let newBoundValue = boundValue
|
let newBoundValue = boundValue
|
||||||
for (let from of convertFromProps) {
|
for (let from of convertFromProps) {
|
||||||
if (newBoundValue.includes(from)) {
|
if (newBoundValue.includes(from)) {
|
||||||
const binding = bindableProperties.find(
|
const binding = bindableProperties.find(el => el[convertFrom] === from)
|
||||||
(el) => el[convertFrom] === from
|
|
||||||
)
|
|
||||||
newBoundValue = newBoundValue.replace(from, binding[convertTo])
|
newBoundValue = newBoundValue.replace(from, binding[convertTo])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,12 @@ export const automationStore = getAutomationStore()
|
||||||
export const themeStore = getThemeStore()
|
export const themeStore = getThemeStore()
|
||||||
export const hostingStore = getHostingStore()
|
export const hostingStore = getHostingStore()
|
||||||
|
|
||||||
export const currentAsset = derived(store, ($store) => {
|
export const currentAsset = derived(store, $store => {
|
||||||
const type = $store.currentFrontEndType
|
const type = $store.currentFrontEndType
|
||||||
if (type === FrontendTypes.SCREEN) {
|
if (type === FrontendTypes.SCREEN) {
|
||||||
return $store.screens.find(
|
return $store.screens.find(screen => screen._id === $store.selectedScreenId)
|
||||||
(screen) => screen._id === $store.selectedScreenId
|
|
||||||
)
|
|
||||||
} else if (type === FrontendTypes.LAYOUT) {
|
} else if (type === FrontendTypes.LAYOUT) {
|
||||||
return $store.layouts.find(
|
return $store.layouts.find(layout => layout._id === $store.selectedLayoutId)
|
||||||
(layout) => layout._id === $store.selectedLayoutId
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
@ -36,24 +32,24 @@ export const selectedComponent = derived(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const currentAssetId = derived(store, ($store) => {
|
export const currentAssetId = derived(store, $store => {
|
||||||
return $store.currentFrontEndType === FrontendTypes.SCREEN
|
return $store.currentFrontEndType === FrontendTypes.SCREEN
|
||||||
? $store.selectedScreenId
|
? $store.selectedScreenId
|
||||||
: $store.selectedLayoutId
|
: $store.selectedLayoutId
|
||||||
})
|
})
|
||||||
|
|
||||||
export const currentAssetName = derived(currentAsset, ($currentAsset) => {
|
export const currentAssetName = derived(currentAsset, $currentAsset => {
|
||||||
return $currentAsset?.name
|
return $currentAsset?.name
|
||||||
})
|
})
|
||||||
|
|
||||||
// leave this as before for consistency
|
// leave this as before for consistency
|
||||||
export const allScreens = derived(store, ($store) => {
|
export const allScreens = derived(store, $store => {
|
||||||
return $store.screens
|
return $store.screens
|
||||||
})
|
})
|
||||||
|
|
||||||
export const mainLayout = derived(store, ($store) => {
|
export const mainLayout = derived(store, $store => {
|
||||||
return $store.layouts?.find(
|
return $store.layouts?.find(
|
||||||
(layout) => layout._id === LAYOUT_NAMES.MASTER.PRIVATE
|
layout => layout._id === LAYOUT_NAMES.MASTER.PRIVATE
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { get } from "builderStore/api"
|
||||||
* their props and other metadata from components.json.
|
* their props and other metadata from components.json.
|
||||||
* @param {string} appId - ID of the currently running app
|
* @param {string} appId - ID of the currently running app
|
||||||
*/
|
*/
|
||||||
export const fetchComponentLibDefinitions = async (appId) => {
|
export const fetchComponentLibDefinitions = async appId => {
|
||||||
const LIB_DEFINITION_URL = `/api/${appId}/components/definitions`
|
const LIB_DEFINITION_URL = `/api/${appId}/components/definitions`
|
||||||
try {
|
try {
|
||||||
const libDefinitionResponse = await get(LIB_DEFINITION_URL)
|
const libDefinitionResponse = await get(LIB_DEFINITION_URL)
|
||||||
|
|
|
@ -37,7 +37,7 @@ export default class Automation {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const stepIdx = steps.findIndex((step) => step.id === id)
|
const stepIdx = steps.findIndex(step => step.id === id)
|
||||||
if (stepIdx < 0) throw new Error("Block not found.")
|
if (stepIdx < 0) throw new Error("Block not found.")
|
||||||
steps.splice(stepIdx, 1, updatedBlock)
|
steps.splice(stepIdx, 1, updatedBlock)
|
||||||
this.automation.definition.steps = steps
|
this.automation.definition.steps = steps
|
||||||
|
@ -51,7 +51,7 @@ export default class Automation {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const stepIdx = steps.findIndex((step) => step.id === id)
|
const stepIdx = steps.findIndex(step => step.id === id)
|
||||||
if (stepIdx < 0) throw new Error("Block not found.")
|
if (stepIdx < 0) throw new Error("Block not found.")
|
||||||
steps.splice(stepIdx, 1)
|
steps.splice(stepIdx, 1)
|
||||||
this.automation.definition.steps = steps
|
this.automation.definition.steps = steps
|
||||||
|
|
|
@ -4,14 +4,14 @@ import Automation from "./Automation"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
|
|
||||||
const automationActions = (store) => ({
|
const automationActions = store => ({
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
const responses = await Promise.all([
|
const responses = await Promise.all([
|
||||||
api.get(`/api/automations`),
|
api.get(`/api/automations`),
|
||||||
api.get(`/api/automations/definitions/list`),
|
api.get(`/api/automations/definitions/list`),
|
||||||
])
|
])
|
||||||
const jsonResponses = await Promise.all(responses.map((x) => x.json()))
|
const jsonResponses = await Promise.all(responses.map(x => x.json()))
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
let selected = state.selectedAutomation?.automation
|
let selected = state.selectedAutomation?.automation
|
||||||
state.automations = jsonResponses[0]
|
state.automations = jsonResponses[0]
|
||||||
state.blockDefinitions = {
|
state.blockDefinitions = {
|
||||||
|
@ -22,7 +22,7 @@ const automationActions = (store) => ({
|
||||||
// if previously selected find the new obj and select it
|
// if previously selected find the new obj and select it
|
||||||
if (selected) {
|
if (selected) {
|
||||||
selected = jsonResponses[0].filter(
|
selected = jsonResponses[0].filter(
|
||||||
(automation) => automation._id === selected._id
|
automation => automation._id === selected._id
|
||||||
)
|
)
|
||||||
state.selectedAutomation = new Automation(selected[0])
|
state.selectedAutomation = new Automation(selected[0])
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ const automationActions = (store) => ({
|
||||||
const CREATE_AUTOMATION_URL = `/api/automations`
|
const CREATE_AUTOMATION_URL = `/api/automations`
|
||||||
const response = await api.post(CREATE_AUTOMATION_URL, automation)
|
const response = await api.post(CREATE_AUTOMATION_URL, automation)
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.automations = [...state.automations, json.automation]
|
state.automations = [...state.automations, json.automation]
|
||||||
store.actions.select(json.automation)
|
store.actions.select(json.automation)
|
||||||
return state
|
return state
|
||||||
|
@ -50,9 +50,9 @@ const automationActions = (store) => ({
|
||||||
const UPDATE_AUTOMATION_URL = `/api/automations`
|
const UPDATE_AUTOMATION_URL = `/api/automations`
|
||||||
const response = await api.put(UPDATE_AUTOMATION_URL, automation)
|
const response = await api.put(UPDATE_AUTOMATION_URL, automation)
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const existingIdx = state.automations.findIndex(
|
const existingIdx = state.automations.findIndex(
|
||||||
(existing) => existing._id === automation._id
|
existing => existing._id === automation._id
|
||||||
)
|
)
|
||||||
state.automations.splice(existingIdx, 1, json.automation)
|
state.automations.splice(existingIdx, 1, json.automation)
|
||||||
state.automations = state.automations
|
state.automations = state.automations
|
||||||
|
@ -65,9 +65,9 @@ const automationActions = (store) => ({
|
||||||
const DELETE_AUTOMATION_URL = `/api/automations/${_id}/${_rev}`
|
const DELETE_AUTOMATION_URL = `/api/automations/${_id}/${_rev}`
|
||||||
await api.delete(DELETE_AUTOMATION_URL)
|
await api.delete(DELETE_AUTOMATION_URL)
|
||||||
|
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const existingIdx = state.automations.findIndex(
|
const existingIdx = state.automations.findIndex(
|
||||||
(existing) => existing._id === _id
|
existing => existing._id === _id
|
||||||
)
|
)
|
||||||
state.automations.splice(existingIdx, 1)
|
state.automations.splice(existingIdx, 1)
|
||||||
state.automations = state.automations
|
state.automations = state.automations
|
||||||
|
@ -81,15 +81,15 @@ const automationActions = (store) => ({
|
||||||
const TRIGGER_AUTOMATION_URL = `/api/automations/${_id}/trigger`
|
const TRIGGER_AUTOMATION_URL = `/api/automations/${_id}/trigger`
|
||||||
return await api.post(TRIGGER_AUTOMATION_URL)
|
return await api.post(TRIGGER_AUTOMATION_URL)
|
||||||
},
|
},
|
||||||
select: (automation) => {
|
select: automation => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.selectedAutomation = new Automation(cloneDeep(automation))
|
state.selectedAutomation = new Automation(cloneDeep(automation))
|
||||||
state.selectedBlock = null
|
state.selectedBlock = null
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addBlockToAutomation: (block) => {
|
addBlockToAutomation: block => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const newBlock = state.selectedAutomation.addBlock(cloneDeep(block))
|
const newBlock = state.selectedAutomation.addBlock(cloneDeep(block))
|
||||||
state.selectedBlock = newBlock
|
state.selectedBlock = newBlock
|
||||||
return state
|
return state
|
||||||
|
@ -98,10 +98,10 @@ const automationActions = (store) => ({
|
||||||
name: block.name,
|
name: block.name,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteAutomationBlock: (block) => {
|
deleteAutomationBlock: block => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const idx = state.selectedAutomation.automation.definition.steps.findIndex(
|
const idx = state.selectedAutomation.automation.definition.steps.findIndex(
|
||||||
(x) => x.id === block.id
|
x => x.id === block.id
|
||||||
)
|
)
|
||||||
state.selectedAutomation.deleteBlock(block.id)
|
state.selectedAutomation.deleteBlock(block.id)
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,10 @@ export const getFrontendStore = () => {
|
||||||
const store = writable({ ...INITIAL_FRONTEND_STATE })
|
const store = writable({ ...INITIAL_FRONTEND_STATE })
|
||||||
|
|
||||||
store.actions = {
|
store.actions = {
|
||||||
initialise: async (pkg) => {
|
initialise: async pkg => {
|
||||||
const { layouts, screens, application, clientLibPath } = pkg
|
const { layouts, screens, application, clientLibPath } = pkg
|
||||||
const components = await fetchComponentLibDefinitions(application._id)
|
const components = await fetchComponentLibDefinitions(application._id)
|
||||||
store.update((state) => ({
|
store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
libraries: application.componentLibraries,
|
libraries: application.componentLibraries,
|
||||||
components,
|
components,
|
||||||
|
@ -70,7 +70,7 @@ export const getFrontendStore = () => {
|
||||||
|
|
||||||
// Initialise backend stores
|
// Initialise backend stores
|
||||||
const [_integrations] = await Promise.all([
|
const [_integrations] = await Promise.all([
|
||||||
api.get("/api/integrations").then((r) => r.json()),
|
api.get("/api/integrations").then(r => r.json()),
|
||||||
])
|
])
|
||||||
datasources.init()
|
datasources.init()
|
||||||
integrations.set(_integrations)
|
integrations.set(_integrations)
|
||||||
|
@ -82,18 +82,18 @@ export const getFrontendStore = () => {
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
const response = await api.get("/api/routing")
|
const response = await api.get("/api/routing")
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.routes = json.routes
|
state.routes = json.routes
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
screens: {
|
screens: {
|
||||||
select: (screenId) => {
|
select: screenId => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
let screens = get(allScreens)
|
let screens = get(allScreens)
|
||||||
let screen =
|
let screen =
|
||||||
screens.find((screen) => screen._id === screenId) || screens[0]
|
screens.find(screen => screen._id === screenId) || screens[0]
|
||||||
if (!screen) return state
|
if (!screen) return state
|
||||||
|
|
||||||
// Update role to the screen's role setting so that it will always
|
// Update role to the screen's role setting so that it will always
|
||||||
|
@ -107,9 +107,9 @@ export const getFrontendStore = () => {
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
create: async (screen) => {
|
create: async screen => {
|
||||||
screen = await store.actions.screens.save(screen)
|
screen = await store.actions.screens.save(screen)
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.selectedScreenId = screen._id
|
state.selectedScreenId = screen._id
|
||||||
state.selectedComponentId = screen.props._id
|
state.selectedComponentId = screen.props._id
|
||||||
state.currentFrontEndType = FrontendTypes.SCREEN
|
state.currentFrontEndType = FrontendTypes.SCREEN
|
||||||
|
@ -118,15 +118,15 @@ export const getFrontendStore = () => {
|
||||||
})
|
})
|
||||||
return screen
|
return screen
|
||||||
},
|
},
|
||||||
save: async (screen) => {
|
save: async screen => {
|
||||||
const creatingNewScreen = screen._id === undefined
|
const creatingNewScreen = screen._id === undefined
|
||||||
const response = await api.post(`/api/screens`, screen)
|
const response = await api.post(`/api/screens`, screen)
|
||||||
screen = await response.json()
|
screen = await response.json()
|
||||||
await store.actions.routing.fetch()
|
await store.actions.routing.fetch()
|
||||||
|
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const foundScreen = state.screens.findIndex(
|
const foundScreen = state.screens.findIndex(
|
||||||
(el) => el._id === screen._id
|
el => el._id === screen._id
|
||||||
)
|
)
|
||||||
if (foundScreen !== -1) {
|
if (foundScreen !== -1) {
|
||||||
state.screens.splice(foundScreen, 1)
|
state.screens.splice(foundScreen, 1)
|
||||||
|
@ -141,14 +141,14 @@ export const getFrontendStore = () => {
|
||||||
|
|
||||||
return screen
|
return screen
|
||||||
},
|
},
|
||||||
delete: async (screens) => {
|
delete: async screens => {
|
||||||
const screensToDelete = Array.isArray(screens) ? screens : [screens]
|
const screensToDelete = Array.isArray(screens) ? screens : [screens]
|
||||||
|
|
||||||
const screenDeletePromises = []
|
const screenDeletePromises = []
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
for (let screenToDelete of screensToDelete) {
|
for (let screenToDelete of screensToDelete) {
|
||||||
state.screens = state.screens.filter(
|
state.screens = state.screens.filter(
|
||||||
(screen) => screen._id !== screenToDelete._id
|
screen => screen._id !== screenToDelete._id
|
||||||
)
|
)
|
||||||
screenDeletePromises.push(
|
screenDeletePromises.push(
|
||||||
api.delete(
|
api.delete(
|
||||||
|
@ -177,8 +177,8 @@ export const getFrontendStore = () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
layouts: {
|
layouts: {
|
||||||
select: (layoutId) => {
|
select: layoutId => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const layout =
|
const layout =
|
||||||
store.actions.layouts.find(layoutId) || get(store).layouts[0]
|
store.actions.layouts.find(layoutId) || get(store).layouts[0]
|
||||||
if (!layout) return
|
if (!layout) return
|
||||||
|
@ -189,15 +189,15 @@ export const getFrontendStore = () => {
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
save: async (layout) => {
|
save: async layout => {
|
||||||
const layoutToSave = cloneDeep(layout)
|
const layoutToSave = cloneDeep(layout)
|
||||||
const creatingNewLayout = layoutToSave._id === undefined
|
const creatingNewLayout = layoutToSave._id === undefined
|
||||||
const response = await api.post(`/api/layouts`, layoutToSave)
|
const response = await api.post(`/api/layouts`, layoutToSave)
|
||||||
const savedLayout = await response.json()
|
const savedLayout = await response.json()
|
||||||
|
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
const layoutIdx = state.layouts.findIndex(
|
const layoutIdx = state.layouts.findIndex(
|
||||||
(stateLayout) => stateLayout._id === savedLayout._id
|
stateLayout => stateLayout._id === savedLayout._id
|
||||||
)
|
)
|
||||||
if (layoutIdx >= 0) {
|
if (layoutIdx >= 0) {
|
||||||
// update existing layout
|
// update existing layout
|
||||||
|
@ -216,14 +216,14 @@ export const getFrontendStore = () => {
|
||||||
|
|
||||||
return savedLayout
|
return savedLayout
|
||||||
},
|
},
|
||||||
find: (layoutId) => {
|
find: layoutId => {
|
||||||
if (!layoutId) {
|
if (!layoutId) {
|
||||||
return get(mainLayout)
|
return get(mainLayout)
|
||||||
}
|
}
|
||||||
const storeContents = get(store)
|
const storeContents = get(store)
|
||||||
return storeContents.layouts.find((layout) => layout._id === layoutId)
|
return storeContents.layouts.find(layout => layout._id === layoutId)
|
||||||
},
|
},
|
||||||
delete: async (layoutToDelete) => {
|
delete: async layoutToDelete => {
|
||||||
const response = await api.delete(
|
const response = await api.delete(
|
||||||
`/api/layouts/${layoutToDelete._id}/${layoutToDelete._rev}`
|
`/api/layouts/${layoutToDelete._id}/${layoutToDelete._rev}`
|
||||||
)
|
)
|
||||||
|
@ -231,9 +231,9 @@ export const getFrontendStore = () => {
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
throw new Error(json.message)
|
throw new Error(json.message)
|
||||||
}
|
}
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.layouts = state.layouts.filter(
|
state.layouts = state.layouts.filter(
|
||||||
(layout) => layout._id !== layoutToDelete._id
|
layout => layout._id !== layoutToDelete._id
|
||||||
)
|
)
|
||||||
if (layoutToDelete._id === state.selectedLayoutId) {
|
if (layoutToDelete._id === state.selectedLayoutId) {
|
||||||
state.selectedLayoutId = get(mainLayout)._id
|
state.selectedLayoutId = get(mainLayout)._id
|
||||||
|
@ -243,7 +243,7 @@ export const getFrontendStore = () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
select: (component) => {
|
select: component => {
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -263,13 +263,13 @@ export const getFrontendStore = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise select the component
|
// Otherwise select the component
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.selectedComponentId = component._id
|
state.selectedComponentId = component._id
|
||||||
state.currentView = "component"
|
state.currentView = "component"
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getDefinition: (componentName) => {
|
getDefinition: componentName => {
|
||||||
if (!componentName) {
|
if (!componentName) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ export const getFrontendStore = () => {
|
||||||
// Generate default props
|
// Generate default props
|
||||||
let props = { ...presetProps }
|
let props = { ...presetProps }
|
||||||
if (definition.settings) {
|
if (definition.settings) {
|
||||||
definition.settings.forEach((setting) => {
|
definition.settings.forEach(setting => {
|
||||||
if (setting.defaultValue !== undefined) {
|
if (setting.defaultValue !== undefined) {
|
||||||
props[setting.key] = setting.defaultValue
|
props[setting.key] = setting.defaultValue
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ export const getFrontendStore = () => {
|
||||||
|
|
||||||
// Save components and update UI
|
// Save components and update UI
|
||||||
await store.actions.preview.saveSelected()
|
await store.actions.preview.saveSelected()
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.currentView = "component"
|
state.currentView = "component"
|
||||||
state.selectedComponentId = componentInstance._id
|
state.selectedComponentId = componentInstance._id
|
||||||
return state
|
return state
|
||||||
|
@ -380,7 +380,7 @@ export const getFrontendStore = () => {
|
||||||
|
|
||||||
return componentInstance
|
return componentInstance
|
||||||
},
|
},
|
||||||
delete: async (component) => {
|
delete: async component => {
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ export const getFrontendStore = () => {
|
||||||
const parent = findComponentParent(asset.props, component._id)
|
const parent = findComponentParent(asset.props, component._id)
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent._children = parent._children.filter(
|
parent._children = parent._children.filter(
|
||||||
(child) => child._id !== component._id
|
child => child._id !== component._id
|
||||||
)
|
)
|
||||||
store.actions.components.select(parent)
|
store.actions.components.select(parent)
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ export const getFrontendStore = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update store with copied component
|
// Update store with copied component
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.componentToPaste = cloneDeep(component)
|
state.componentToPaste = cloneDeep(component)
|
||||||
state.componentToPaste.isCut = cut
|
state.componentToPaste.isCut = cut
|
||||||
return state
|
return state
|
||||||
|
@ -415,7 +415,7 @@ export const getFrontendStore = () => {
|
||||||
const parent = findComponentParent(selectedAsset.props, component._id)
|
const parent = findComponentParent(selectedAsset.props, component._id)
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent._children = parent._children.filter(
|
parent._children = parent._children.filter(
|
||||||
(child) => child._id !== component._id
|
child => child._id !== component._id
|
||||||
)
|
)
|
||||||
store.actions.components.select(parent)
|
store.actions.components.select(parent)
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ export const getFrontendStore = () => {
|
||||||
},
|
},
|
||||||
paste: async (targetComponent, mode) => {
|
paste: async (targetComponent, mode) => {
|
||||||
let promises = []
|
let promises = []
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
// Stop if we have nothing to paste
|
// Stop if we have nothing to paste
|
||||||
if (!state.componentToPaste) {
|
if (!state.componentToPaste) {
|
||||||
return state
|
return state
|
||||||
|
@ -444,7 +444,7 @@ export const getFrontendStore = () => {
|
||||||
if (cut) {
|
if (cut) {
|
||||||
state.componentToPaste = null
|
state.componentToPaste = null
|
||||||
} else {
|
} else {
|
||||||
const randomizeIds = (component) => {
|
const randomizeIds = component => {
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ export const getFrontendStore = () => {
|
||||||
}
|
}
|
||||||
await store.actions.preview.saveSelected()
|
await store.actions.preview.saveSelected()
|
||||||
},
|
},
|
||||||
updateCustomStyle: async (style) => {
|
updateCustomStyle: async style => {
|
||||||
const selected = get(selectedComponent)
|
const selected = get(selectedComponent)
|
||||||
selected._styles.custom = style
|
selected._styles.custom = style
|
||||||
await store.actions.preview.saveSelected()
|
await store.actions.preview.saveSelected()
|
||||||
|
@ -507,7 +507,7 @@ export const getFrontendStore = () => {
|
||||||
selected._styles = { normal: {}, hover: {}, active: {} }
|
selected._styles = { normal: {}, hover: {}, active: {} }
|
||||||
await store.actions.preview.saveSelected()
|
await store.actions.preview.saveSelected()
|
||||||
},
|
},
|
||||||
updateTransition: async (transition) => {
|
updateTransition: async transition => {
|
||||||
const selected = get(selectedComponent)
|
const selected = get(selectedComponent)
|
||||||
if (transition == null || transition === "") {
|
if (transition == null || transition === "") {
|
||||||
selected._transition = ""
|
selected._transition = ""
|
||||||
|
@ -522,7 +522,7 @@ export const getFrontendStore = () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
component[name] = value
|
component[name] = value
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.selectedComponentId = component._id
|
state.selectedComponentId = component._id
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,20 +17,18 @@ export const getHostingStore = () => {
|
||||||
api.get("/api/hosting/"),
|
api.get("/api/hosting/"),
|
||||||
api.get("/api/hosting/urls"),
|
api.get("/api/hosting/urls"),
|
||||||
])
|
])
|
||||||
const [info, urls] = await Promise.all(
|
const [info, urls] = await Promise.all(responses.map(resp => resp.json()))
|
||||||
responses.map((resp) => resp.json())
|
store.update(state => {
|
||||||
)
|
|
||||||
store.update((state) => {
|
|
||||||
state.hostingInfo = info
|
state.hostingInfo = info
|
||||||
state.appUrl = urls.app
|
state.appUrl = urls.app
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
return info
|
return info
|
||||||
},
|
},
|
||||||
save: async (hostingInfo) => {
|
save: async hostingInfo => {
|
||||||
const response = await api.post("/api/hosting", hostingInfo)
|
const response = await api.post("/api/hosting", hostingInfo)
|
||||||
const revision = (await response.json()).rev
|
const revision = (await response.json()).rev
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.hostingInfo = {
|
state.hostingInfo = {
|
||||||
...hostingInfo,
|
...hostingInfo,
|
||||||
_rev: revision,
|
_rev: revision,
|
||||||
|
@ -40,12 +38,10 @@ export const getHostingStore = () => {
|
||||||
},
|
},
|
||||||
fetchDeployedApps: async () => {
|
fetchDeployedApps: async () => {
|
||||||
let deployments = await (await get("/api/hosting/apps")).json()
|
let deployments = await (await get("/api/hosting/apps")).json()
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.deployedApps = deployments
|
state.deployedApps = deployments
|
||||||
state.deployedAppNames = Object.values(deployments).map(
|
state.deployedAppNames = Object.values(deployments).map(app => app.name)
|
||||||
(app) => app.name
|
state.deployedAppUrls = Object.values(deployments).map(app => app.url)
|
||||||
)
|
|
||||||
state.deployedAppUrls = Object.values(deployments).map((app) => app.url)
|
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
return deployments
|
return deployments
|
||||||
|
|
|
@ -12,13 +12,13 @@ export const localStorageStore = (localStorageKey, initialValue) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// New store setter which updates the store and localstorage
|
// New store setter which updates the store and localstorage
|
||||||
const set = (value) => {
|
const set = value => {
|
||||||
store.set(value)
|
store.set(value)
|
||||||
localStorage.setItem(localStorageKey, JSON.stringify(value))
|
localStorage.setItem(localStorageKey, JSON.stringify(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// New store updater which updates the store and localstorage
|
// New store updater which updates the store and localstorage
|
||||||
const update = (updaterFn) => set(updaterFn(get(store)))
|
const update = updaterFn => set(updaterFn(get(store)))
|
||||||
|
|
||||||
// Hydrates the store from localstorage
|
// Hydrates the store from localstorage
|
||||||
const hydrate = () => {
|
const hydrate = () => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ export const notificationStore = writable({
|
||||||
})
|
})
|
||||||
|
|
||||||
export function send(message, type = "default") {
|
export function send(message, type = "default") {
|
||||||
notificationStore.update((state) => {
|
notificationStore.update(state => {
|
||||||
state.notifications = [
|
state.notifications = [
|
||||||
...state.notifications,
|
...state.notifications,
|
||||||
{ id: generate(), type, message },
|
{ id: generate(), type, message },
|
||||||
|
@ -16,8 +16,8 @@ export function send(message, type = "default") {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const notifier = {
|
export const notifier = {
|
||||||
danger: (msg) => send(msg, "danger"),
|
danger: msg => send(msg, "danger"),
|
||||||
warning: (msg) => send(msg, "warning"),
|
warning: msg => send(msg, "warning"),
|
||||||
info: (msg) => send(msg, "info"),
|
info: msg => send(msg, "info"),
|
||||||
success: (msg) => send(msg, "success"),
|
success: msg => send(msg, "success"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import rowDetailScreen from "./rowDetailScreen"
|
||||||
import rowListScreen from "./rowListScreen"
|
import rowListScreen from "./rowListScreen"
|
||||||
import createFromScratchScreen from "./createFromScratchScreen"
|
import createFromScratchScreen from "./createFromScratchScreen"
|
||||||
|
|
||||||
const allTemplates = (tables) => [
|
const allTemplates = tables => [
|
||||||
...newRowScreen(tables),
|
...newRowScreen(tables),
|
||||||
...rowDetailScreen(tables),
|
...rowDetailScreen(tables),
|
||||||
...rowListScreen(tables),
|
...rowListScreen(tables),
|
||||||
|
@ -18,7 +18,7 @@ const createTemplateOverride = (frontendState, create) => () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (frontendState, tables) => {
|
export default (frontendState, tables) => {
|
||||||
const enrichTemplate = (template) => ({
|
const enrichTemplate = template => ({
|
||||||
...template,
|
...template,
|
||||||
create: createTemplateOverride(frontendState, template.create),
|
create: createTemplateOverride(frontendState, template.create),
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
} from "./utils/commonComponents"
|
} from "./utils/commonComponents"
|
||||||
|
|
||||||
export default function (tables) {
|
export default function (tables) {
|
||||||
return tables.map((table) => {
|
return tables.map(table => {
|
||||||
return {
|
return {
|
||||||
name: `${table.name} - New`,
|
name: `${table.name} - New`,
|
||||||
create: () => createScreen(table),
|
create: () => createScreen(table),
|
||||||
|
@ -19,14 +19,14 @@ export default function (tables) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const newRowUrl = (table) => sanitizeUrl(`/${table.name}/new/row`)
|
export const newRowUrl = table => sanitizeUrl(`/${table.name}/new/row`)
|
||||||
export const NEW_ROW_TEMPLATE = "NEW_ROW_TEMPLATE"
|
export const NEW_ROW_TEMPLATE = "NEW_ROW_TEMPLATE"
|
||||||
|
|
||||||
function generateTitleContainer(table, formId) {
|
function generateTitleContainer(table, formId) {
|
||||||
return makeTitleContainer("New Row").addChild(makeSaveButton(table, formId))
|
return makeTitleContainer("New Row").addChild(makeSaveButton(table, formId))
|
||||||
}
|
}
|
||||||
|
|
||||||
const createScreen = (table) => {
|
const createScreen = table => {
|
||||||
const screen = new Screen()
|
const screen = new Screen()
|
||||||
.component("@budibase/standard-components/container")
|
.component("@budibase/standard-components/container")
|
||||||
.instanceName(`${table.name} - New`)
|
.instanceName(`${table.name} - New`)
|
||||||
|
@ -52,7 +52,7 @@ const createScreen = (table) => {
|
||||||
|
|
||||||
// Add all form fields from this schema to the field group
|
// Add all form fields from this schema to the field group
|
||||||
const datasource = { type: "table", tableId: table._id }
|
const datasource = { type: "table", tableId: table._id }
|
||||||
makeDatasourceFormComponents(datasource).forEach((component) => {
|
makeDatasourceFormComponents(datasource).forEach(component => {
|
||||||
fieldGroup.addChild(component)
|
fieldGroup.addChild(component)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
} from "./utils/commonComponents"
|
} from "./utils/commonComponents"
|
||||||
|
|
||||||
export default function (tables) {
|
export default function (tables) {
|
||||||
return tables.map((table) => {
|
return tables.map(table => {
|
||||||
return {
|
return {
|
||||||
name: `${table.name} - Detail`,
|
name: `${table.name} - Detail`,
|
||||||
create: () => createScreen(table),
|
create: () => createScreen(table),
|
||||||
|
@ -23,7 +23,7 @@ export default function (tables) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ROW_DETAIL_TEMPLATE = "ROW_DETAIL_TEMPLATE"
|
export const ROW_DETAIL_TEMPLATE = "ROW_DETAIL_TEMPLATE"
|
||||||
export const rowDetailUrl = (table) => sanitizeUrl(`/${table.name}/:id`)
|
export const rowDetailUrl = table => sanitizeUrl(`/${table.name}/:id`)
|
||||||
|
|
||||||
function generateTitleContainer(table, title, formId, repeaterId) {
|
function generateTitleContainer(table, title, formId, repeaterId) {
|
||||||
// have to override style for this, its missing margin
|
// have to override style for this, its missing margin
|
||||||
|
@ -80,7 +80,7 @@ function generateTitleContainer(table, title, formId, repeaterId) {
|
||||||
return makeTitleContainer(title).addChild(deleteButton).addChild(saveButton)
|
return makeTitleContainer(title).addChild(deleteButton).addChild(saveButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
const createScreen = (table) => {
|
const createScreen = table => {
|
||||||
const provider = new Component("@budibase/standard-components/dataprovider")
|
const provider = new Component("@budibase/standard-components/dataprovider")
|
||||||
.instanceName(`Data Provider`)
|
.instanceName(`Data Provider`)
|
||||||
.customProps({
|
.customProps({
|
||||||
|
@ -122,7 +122,7 @@ const createScreen = (table) => {
|
||||||
|
|
||||||
// Add all form fields from this schema to the field group
|
// Add all form fields from this schema to the field group
|
||||||
const datasource = { type: "table", tableId: table._id }
|
const datasource = { type: "table", tableId: table._id }
|
||||||
makeDatasourceFormComponents(datasource).forEach((component) => {
|
makeDatasourceFormComponents(datasource).forEach(component => {
|
||||||
fieldGroup.addChild(component)
|
fieldGroup.addChild(component)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Component } from "./utils/Component"
|
||||||
import { makePropSafe } from "@budibase/string-templates"
|
import { makePropSafe } from "@budibase/string-templates"
|
||||||
|
|
||||||
export default function (tables) {
|
export default function (tables) {
|
||||||
return tables.map((table) => {
|
return tables.map(table => {
|
||||||
return {
|
return {
|
||||||
name: `${table.name} - List`,
|
name: `${table.name} - List`,
|
||||||
create: () => createScreen(table),
|
create: () => createScreen(table),
|
||||||
|
@ -15,7 +15,7 @@ export default function (tables) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ROW_LIST_TEMPLATE = "ROW_LIST_TEMPLATE"
|
export const ROW_LIST_TEMPLATE = "ROW_LIST_TEMPLATE"
|
||||||
export const rowListUrl = (table) => sanitizeUrl(`/${table.name}`)
|
export const rowListUrl = table => sanitizeUrl(`/${table.name}`)
|
||||||
|
|
||||||
function generateTitleContainer(table) {
|
function generateTitleContainer(table) {
|
||||||
const newButton = new Component("@budibase/standard-components/button")
|
const newButton = new Component("@budibase/standard-components/button")
|
||||||
|
@ -70,7 +70,7 @@ function generateTitleContainer(table) {
|
||||||
.addChild(newButton)
|
.addChild(newButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
const createScreen = (table) => {
|
const createScreen = table => {
|
||||||
const provider = new Component("@budibase/standard-components/dataprovider")
|
const provider = new Component("@budibase/standard-components/dataprovider")
|
||||||
.instanceName(`Data Provider`)
|
.instanceName(`Data Provider`)
|
||||||
.customProps({
|
.customProps({
|
||||||
|
|
|
@ -178,7 +178,7 @@ export function makeDatasourceFormComponents(datasource) {
|
||||||
const { schema } = getSchemaForDatasource(datasource, true)
|
const { schema } = getSchemaForDatasource(datasource, true)
|
||||||
let components = []
|
let components = []
|
||||||
let fields = Object.keys(schema || {})
|
let fields = Object.keys(schema || {})
|
||||||
fields.forEach((field) => {
|
fields.forEach(field => {
|
||||||
const fieldSchema = schema[field]
|
const fieldSchema = schema[field]
|
||||||
// skip autocolumns
|
// skip autocolumns
|
||||||
if (fieldSchema.autocolumn) {
|
if (fieldSchema.autocolumn) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default function (url) {
|
export default function (url) {
|
||||||
return url
|
return url
|
||||||
.split("/")
|
.split("/")
|
||||||
.map((part) => {
|
.map(part => {
|
||||||
// if parameter, then use as is
|
// if parameter, then use as is
|
||||||
if (part.startsWith(":")) return part
|
if (part.startsWith(":")) return part
|
||||||
return encodeURIComponent(part.replace(/ /g, "-"))
|
return encodeURIComponent(part.replace(/ /g, "-"))
|
||||||
|
|
|
@ -9,14 +9,14 @@ export const getThemeStore = () => {
|
||||||
const store = localStorageStore("bb-theme", initialValue)
|
const store = localStorageStore("bb-theme", initialValue)
|
||||||
|
|
||||||
// Update theme class when store changes
|
// Update theme class when store changes
|
||||||
store.subscribe((state) => {
|
store.subscribe(state => {
|
||||||
// Handle any old local storage values - this can be removed after the update
|
// Handle any old local storage values - this can be removed after the update
|
||||||
if (state.darkMode !== undefined) {
|
if (state.darkMode !== undefined) {
|
||||||
store.set(initialValue)
|
store.set(initialValue)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state.options.forEach((option) => {
|
state.options.forEach(option => {
|
||||||
themeElement.classList.toggle(
|
themeElement.classList.toggle(
|
||||||
`spectrum--${option}`,
|
`spectrum--${option}`,
|
||||||
option === state.theme
|
option === state.theme
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
* Recursively searches for a specific component ID
|
* Recursively searches for a specific component ID
|
||||||
*/
|
*/
|
||||||
export const findComponent = (rootComponent, id) => {
|
export const findComponent = (rootComponent, id) => {
|
||||||
return searchComponentTree(rootComponent, (comp) => comp._id === id)
|
return searchComponentTree(rootComponent, comp => comp._id === id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively searches for a specific component type
|
* Recursively searches for a specific component type
|
||||||
*/
|
*/
|
||||||
export const findComponentType = (rootComponent, type) => {
|
export const findComponentType = (rootComponent, type) => {
|
||||||
return searchComponentTree(rootComponent, (comp) => comp._component === type)
|
return searchComponentTree(rootComponent, comp => comp._component === type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +68,7 @@ export const findAllMatchingComponents = (rootComponent, selector) => {
|
||||||
}
|
}
|
||||||
let components = []
|
let components = []
|
||||||
if (rootComponent._children) {
|
if (rootComponent._children) {
|
||||||
rootComponent._children.forEach((child) => {
|
rootComponent._children.forEach(child => {
|
||||||
components = [
|
components = [
|
||||||
...components,
|
...components,
|
||||||
...findAllMatchingComponents(child, selector),
|
...findAllMatchingComponents(child, selector),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export function uuid() {
|
export function uuid() {
|
||||||
// always want to make this start with a letter, as this makes it
|
// always want to make this start with a letter, as this makes it
|
||||||
// easier to use with template string bindings in the client
|
// easier to use with template string bindings in the client
|
||||||
return "cxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
return "cxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, c => {
|
||||||
const r = (Math.random() * 16) | 0,
|
const r = (Math.random() * 16) | 0,
|
||||||
v = c == "x" ? r : (r & 0x3) | 0x8
|
v = c == "x" ? r : (r & 0x3) | 0x8
|
||||||
return v.toString(16)
|
return v.toString(16)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
$: automation = $automationStore.selectedAutomation?.automation
|
$: automation = $automationStore.selectedAutomation?.automation
|
||||||
|
|
||||||
function onSelect(block) {
|
function onSelect(block) {
|
||||||
automationStore.update((state) => {
|
automationStore.update(state => {
|
||||||
state.selectedBlock = block
|
state.selectedBlock = block
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
let webhookModal
|
let webhookModal
|
||||||
$: selectedTab = selectedIndex == null ? null : tabs[selectedIndex].value
|
$: selectedTab = selectedIndex == null ? null : tabs[selectedIndex].value
|
||||||
$: anchor = selectedIndex === -1 ? null : anchors[selectedIndex]
|
$: anchor = selectedIndex === -1 ? null : anchors[selectedIndex]
|
||||||
$: blocks = sortBy((entry) => entry[1].name)(
|
$: blocks = sortBy(entry => entry[1].name)(
|
||||||
Object.entries($automationStore.blockDefinitions[selectedTab] ?? {})
|
Object.entries($automationStore.blockDefinitions[selectedTab] ?? {})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
const tableId = inputs.tableId || inputs.row?.tableId
|
const tableId = inputs.tableId || inputs.row?.tableId
|
||||||
if (tableId) {
|
if (tableId) {
|
||||||
enrichedInputs.enriched.table = $tables.list.find(
|
enrichedInputs.enriched.table = $tables.list.find(
|
||||||
(table) => table._id === tableId
|
table => table._id === tableId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return enrichedInputs
|
return enrichedInputs
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
|
|
||||||
// Extract schema paths for any input bindings
|
// Extract schema paths for any input bindings
|
||||||
let inputPaths = formattedTagline.match(/{{\s*\S+\s*}}/g) || []
|
let inputPaths = formattedTagline.match(/{{\s*\S+\s*}}/g) || []
|
||||||
inputPaths = inputPaths.map((path) => path.replace(/[{}]/g, "").trim())
|
inputPaths = inputPaths.map(path => path.replace(/[{}]/g, "").trim())
|
||||||
const schemaPaths = inputPaths.map((path) =>
|
const schemaPaths = inputPaths.map(path =>
|
||||||
path.replace(/\./g, ".properties.")
|
path.replace(/\./g, ".properties.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
$: selected = $automationStore.selectedBlock?.id === block.id
|
$: selected = $automationStore.selectedBlock?.id === block.id
|
||||||
$: steps =
|
$: steps =
|
||||||
$automationStore.selectedAutomation?.automation?.definition?.steps ?? []
|
$automationStore.selectedAutomation?.automation?.definition?.steps ?? []
|
||||||
$: blockIdx = steps.findIndex((step) => step.id === block.id)
|
$: blockIdx = steps.findIndex(step => step.id === block.id)
|
||||||
$: allowDeleteTrigger = !steps.length
|
$: allowDeleteTrigger = !steps.length
|
||||||
|
|
||||||
function deleteStep() {
|
function deleteStep() {
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<div class="section">
|
<div class="section">
|
||||||
{#each categories as [categoryName, bindings]}
|
{#each categories as [categoryName, bindings]}
|
||||||
<Heading size="XS">{categoryName}</Heading>
|
<Heading size="XS">{categoryName}</Heading>
|
||||||
{#each bindableProperties.filter((binding) =>
|
{#each bindableProperties.filter(binding =>
|
||||||
binding.label.match(searchRgx)
|
binding.label.match(searchRgx)
|
||||||
) as binding}
|
) as binding}
|
||||||
<div class="binding" on:click={() => addToText(binding)}>
|
<div class="binding" on:click={() => addToText(binding)}>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<Heading size="XS">Helpers</Heading>
|
<Heading size="XS">Helpers</Heading>
|
||||||
{#each helpers.filter((helper) => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper}
|
{#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper}
|
||||||
<div class="binding" on:click={() => addToText(helper)}>
|
<div class="binding" on:click={() => addToText(helper)}>
|
||||||
<span class="binding__label">{helper.label}</span>
|
<span class="binding__label">{helper.label}</span>
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
if (automation.trigger) {
|
if (automation.trigger) {
|
||||||
allSteps = [automation.trigger, ...allSteps]
|
allSteps = [automation.trigger, ...allSteps]
|
||||||
}
|
}
|
||||||
const blockIdx = allSteps.findIndex((step) => step.id === block.id)
|
const blockIdx = allSteps.findIndex(step => step.id === block.id)
|
||||||
|
|
||||||
// Extract all outputs from all previous steps as available bindings
|
// Extract all outputs from all previous steps as available bindings
|
||||||
let bindings = []
|
let bindings = []
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type={"email"}
|
type={"email"}
|
||||||
value={block.inputs[key]}
|
value={block.inputs[key]}
|
||||||
on:change={(e) => (block.inputs[key] = e.detail)}
|
on:change={e => (block.inputs[key] = e.detail)}
|
||||||
{bindings}
|
{bindings}
|
||||||
/>
|
/>
|
||||||
{:else if value.customType === "table"}
|
{:else if value.customType === "table"}
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type={value.customType}
|
type={value.customType}
|
||||||
value={block.inputs[key]}
|
value={block.inputs[key]}
|
||||||
on:change={(e) => (block.inputs[key] = e.detail)}
|
on:change={e => (block.inputs[key] = e.detail)}
|
||||||
{bindings}
|
{bindings}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
export let value
|
export let value
|
||||||
export let bindings
|
export let bindings
|
||||||
|
|
||||||
$: table = $tables.list.find((table) => table._id === value?.tableId)
|
$: table = $tables.list.find(table => table._id === value?.tableId)
|
||||||
$: schemaFields = Object.entries(table?.schema ?? {})
|
$: schemaFields = Object.entries(table?.schema ?? {})
|
||||||
|
|
||||||
// Ensure any nullish tableId values get set to empty string so
|
// Ensure any nullish tableId values get set to empty string so
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
<Select
|
<Select
|
||||||
bind:value={value.tableId}
|
bind:value={value.tableId}
|
||||||
options={$tables.list}
|
options={$tables.list}
|
||||||
getOptionLabel={(table) => table.name}
|
getOptionLabel={table => table.name}
|
||||||
getOptionValue={(table) => table._id}
|
getOptionValue={table => table._id}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if schemaFields.length}
|
{#if schemaFields.length}
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<DrawerBindableInput
|
<DrawerBindableInput
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
value={value[field]}
|
value={value[field]}
|
||||||
on:change={(e) => (value[field] = e.detail)}
|
on:change={e => (value[field] = e.detail)}
|
||||||
label={field}
|
label={field}
|
||||||
type="string"
|
type="string"
|
||||||
{bindings}
|
{bindings}
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
value = newValues
|
value = newValues
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldNameChanged = (originalName) => (e) => {
|
const fieldNameChanged = originalName => e => {
|
||||||
// reconstruct using fieldsArray, so field order is preserved
|
// reconstruct using fieldsArray, so field order is preserved
|
||||||
let entries = [...fieldsArray]
|
let entries = [...fieldsArray]
|
||||||
const newName = e.detail
|
const newName = e.detail
|
||||||
if (newName) {
|
if (newName) {
|
||||||
entries.find((f) => f.name === originalName).name = newName
|
entries.find(f => f.name === originalName).name = newName
|
||||||
} else {
|
} else {
|
||||||
entries = entries.filter((f) => f.name !== originalName)
|
entries = entries.filter(f => f.name !== originalName)
|
||||||
}
|
}
|
||||||
value = entries.reduce((newVals, current) => {
|
value = entries.reduce((newVals, current) => {
|
||||||
newVals[current.name] = current.type
|
newVals[current.name] = current.type
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
value={field.type}
|
value={field.type}
|
||||||
on:change={(e) => (value[field.name] = e.target.value)}
|
on:change={e => (value[field.name] = e.target.value)}
|
||||||
options={typeOptions}
|
options={typeOptions}
|
||||||
/>
|
/>
|
||||||
<i
|
<i
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
<Select
|
<Select
|
||||||
bind:value
|
bind:value
|
||||||
options={$tables.list}
|
options={$tables.list}
|
||||||
getOptionLabel={(table) => table.name}
|
getOptionLabel={table => table.name}
|
||||||
getOptionValue={(table) => table._id}
|
getOptionValue={table => table._id}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
if ($views.selected?.name?.startsWith("all_")) {
|
if ($views.selected?.name?.startsWith("all_")) {
|
||||||
loading = true
|
loading = true
|
||||||
const loadingTableId = $tables.selected?._id
|
const loadingTableId = $tables.selected?._id
|
||||||
api.fetchDataForView($views.selected).then((rows) => {
|
api.fetchDataForView($views.selected).then(rows => {
|
||||||
loading = false
|
loading = false
|
||||||
|
|
||||||
// If we started a slow request then quickly change table, sometimes
|
// If we started a slow request then quickly change table, sometimes
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
$: data = row?.[fieldName] ?? []
|
$: data = row?.[fieldName] ?? []
|
||||||
$: linkedTableId = data?.length ? data[0].tableId : null
|
$: linkedTableId = data?.length ? data[0].tableId : null
|
||||||
$: linkedTable = $tables.list.find((table) => table._id === linkedTableId)
|
$: linkedTable = $tables.list.find(table => table._id === linkedTableId)
|
||||||
$: schema = linkedTable?.schema
|
$: schema = linkedTable?.schema
|
||||||
$: table = $tables.list.find((table) => table._id === tableId)
|
$: table = $tables.list.find(table => table._id === tableId)
|
||||||
$: fetchData(tableId, rowId)
|
$: fetchData(tableId, rowId)
|
||||||
$: {
|
$: {
|
||||||
let rowLabel = row?.[table?.primaryDisplay]
|
let rowLabel = row?.[table?.primaryDisplay]
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
component: RoleCell,
|
component: RoleCell,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
UNEDITABLE_USER_FIELDS.forEach((field) => {
|
UNEDITABLE_USER_FIELDS.forEach(field => {
|
||||||
if (schema[field]) {
|
if (schema[field]) {
|
||||||
schema[field].editable = false
|
schema[field].editable = false
|
||||||
}
|
}
|
||||||
|
@ -68,19 +68,19 @@
|
||||||
rows: selectedRows,
|
rows: selectedRows,
|
||||||
type: "delete",
|
type: "delete",
|
||||||
})
|
})
|
||||||
data = data.filter((row) => !selectedRows.includes(row))
|
data = data.filter(row => !selectedRows.includes(row))
|
||||||
notifications.success(`Successfully deleted ${selectedRows.length} rows`)
|
notifications.success(`Successfully deleted ${selectedRows.length} rows`)
|
||||||
selectedRows = []
|
selectedRows = []
|
||||||
}
|
}
|
||||||
|
|
||||||
const editRow = (row) => {
|
const editRow = row => {
|
||||||
editableRow = row
|
editableRow = row
|
||||||
if (row) {
|
if (row) {
|
||||||
editRowModal.show()
|
editRowModal.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const editColumn = (field) => {
|
const editColumn = field => {
|
||||||
editableColumn = schema?.[field]
|
editableColumn = schema?.[field]
|
||||||
if (editableColumn) {
|
if (editableColumn) {
|
||||||
editColumnModal.show()
|
editColumnModal.show()
|
||||||
|
@ -118,9 +118,9 @@
|
||||||
allowEditRows={allowEditing}
|
allowEditRows={allowEditing}
|
||||||
allowEditColumns={allowEditing}
|
allowEditColumns={allowEditing}
|
||||||
showAutoColumns={!hideAutocolumns}
|
showAutoColumns={!hideAutocolumns}
|
||||||
on:editcolumn={(e) => editColumn(e.detail)}
|
on:editcolumn={e => editColumn(e.detail)}
|
||||||
on:editrow={(e) => editRow(e.detail)}
|
on:editrow={e => editRow(e.detail)}
|
||||||
on:clickrelationship={(e) => selectRelationship(e.detail)}
|
on:clickrelationship={e => selectRelationship(e.detail)}
|
||||||
/>
|
/>
|
||||||
{/key}
|
{/key}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
async function fetchViewData(name, field, groupBy, calculation) {
|
async function fetchViewData(name, field, groupBy, calculation) {
|
||||||
const _tables = $tables.list
|
const _tables = $tables.list
|
||||||
const allTableViews = _tables.map((table) => table.views)
|
const allTableViews = _tables.map(table => table.views)
|
||||||
const thisView = allTableViews.filter(
|
const thisView = allTableViews.filter(
|
||||||
(views) => views != null && views[name] != null
|
views => views != null && views[name] != null
|
||||||
)[0]
|
)[0]
|
||||||
// don't fetch view data if the view no longer exists
|
// don't fetch view data if the view no longer exists
|
||||||
if (!thisView) {
|
if (!thisView) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
|
|
||||||
$: role = $roles.find((role) => role._id === value)
|
$: role = $roles.find(role => role._id === value)
|
||||||
$: roleName = role?.name ?? "Unknown role"
|
$: roleName = role?.name ?? "Unknown role"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
$: fields =
|
$: fields =
|
||||||
viewTable &&
|
viewTable &&
|
||||||
Object.keys(viewTable.schema).filter(
|
Object.keys(viewTable.schema).filter(
|
||||||
(field) =>
|
field =>
|
||||||
view.calculation === "count" ||
|
view.calculation === "count" ||
|
||||||
// don't want to perform calculations based on auto ID
|
// don't want to perform calculations based on auto ID
|
||||||
(viewTable.schema[field].type === "number" &&
|
(viewTable.schema[field].type === "number" &&
|
||||||
|
@ -50,8 +50,8 @@
|
||||||
<Select
|
<Select
|
||||||
bind:value={view.calculation}
|
bind:value={view.calculation}
|
||||||
options={CALCULATIONS}
|
options={CALCULATIONS}
|
||||||
getOptionLabel={(x) => x.name}
|
getOptionLabel={x => x.name}
|
||||||
getOptionValue={(x) => x.key}
|
getOptionValue={x => x.key}
|
||||||
/>
|
/>
|
||||||
{#if view.calculation}
|
{#if view.calculation}
|
||||||
<Label>Of</Label>
|
<Label>Of</Label>
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
let deletion
|
let deletion
|
||||||
|
|
||||||
$: tableOptions = $tables.list.filter(
|
$: tableOptions = $tables.list.filter(
|
||||||
(table) => table._id !== $tables.draft._id
|
table => table._id !== $tables.draft._id
|
||||||
)
|
)
|
||||||
$: required = !!field?.constraints?.presence || primaryDisplay
|
$: required = !!field?.constraints?.presence || primaryDisplay
|
||||||
$: uneditable =
|
$: uneditable =
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
!field.name ||
|
!field.name ||
|
||||||
(field.type === LINK_TYPE && !field.tableId) ||
|
(field.type === LINK_TYPE && !field.tableId) ||
|
||||||
Object.keys($tables.draft?.schema ?? {}).some(
|
Object.keys($tables.draft?.schema ?? {}).some(
|
||||||
(key) => key !== originalName && key === field.name
|
key => key !== originalName && key === field.name
|
||||||
)
|
)
|
||||||
|
|
||||||
// used to select what different options can be displayed for column type
|
// used to select what different options can be displayed for column type
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
if (!field || !field.tableId) {
|
if (!field || !field.tableId) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const linkTable = tableOptions.find((table) => table._id === field.tableId)
|
const linkTable = tableOptions.find(table => table._id === field.tableId)
|
||||||
if (!linkTable) {
|
if (!linkTable) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -197,8 +197,8 @@
|
||||||
...Object.values(fieldDefinitions),
|
...Object.values(fieldDefinitions),
|
||||||
{ name: "Auto Column", type: AUTO_COL },
|
{ name: "Auto Column", type: AUTO_COL },
|
||||||
]}
|
]}
|
||||||
getOptionLabel={(field) => field.name}
|
getOptionLabel={field => field.name}
|
||||||
getOptionValue={(field) => field.type}
|
getOptionValue={field => field.type}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if canBeRequired || canBeDisplay}
|
{#if canBeRequired || canBeDisplay}
|
||||||
|
@ -274,8 +274,8 @@
|
||||||
label="Table"
|
label="Table"
|
||||||
bind:value={field.tableId}
|
bind:value={field.tableId}
|
||||||
options={tableOptions}
|
options={tableOptions}
|
||||||
getOptionLabel={(table) => table.name}
|
getOptionLabel={table => table.name}
|
||||||
getOptionValue={(table) => table._id}
|
getOptionValue={table => table._id}
|
||||||
/>
|
/>
|
||||||
{#if relationshipOptions && relationshipOptions.length > 0}
|
{#if relationshipOptions && relationshipOptions.length > 0}
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
|
@ -283,8 +283,8 @@
|
||||||
label="Define the relationship"
|
label="Define the relationship"
|
||||||
bind:value={field.relationshipType}
|
bind:value={field.relationshipType}
|
||||||
options={relationshipOptions}
|
options={relationshipOptions}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={option => option.name}
|
||||||
getOptionValue={(option) => option.value}
|
getOptionValue={option => option.value}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<Input label={`Column name in other table`} bind:value={field.fieldName} />
|
<Input label={`Column name in other table`} bind:value={field.fieldName} />
|
||||||
|
@ -292,10 +292,10 @@
|
||||||
<Select
|
<Select
|
||||||
label="Auto Column Type"
|
label="Auto Column Type"
|
||||||
value={field.subtype}
|
value={field.subtype}
|
||||||
on:change={(e) => (field.subtype = e.detail)}
|
on:change={e => (field.subtype = e.detail)}
|
||||||
options={Object.entries(getAutoColumnInformation())}
|
options={Object.entries(getAutoColumnInformation())}
|
||||||
getOptionLabel={(option) => option[1].name}
|
getOptionLabel={option => option[1].name}
|
||||||
getOptionValue={(option) => option[0]}
|
getOptionValue={option => option[0]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
$: creating = row?._id == null
|
$: creating = row?._id == null
|
||||||
$: table = row.tableId
|
$: table = row.tableId
|
||||||
? $tables.list.find((table) => table._id === row?.tableId)
|
? $tables.list.find(table => table._id === row?.tableId)
|
||||||
: $tables.selected
|
: $tables.selected
|
||||||
$: tableSchema = Object.entries(table?.schema ?? {})
|
$: tableSchema = Object.entries(table?.schema ?? {})
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
|
|
||||||
$: creating = row?._id == null
|
$: creating = row?._id == null
|
||||||
$: table = row.tableId
|
$: table = row.tableId
|
||||||
? $tables.list.find((table) => table._id === row?.tableId)
|
? $tables.list.find(table => table._id === row?.tableId)
|
||||||
: $tables.selected
|
: $tables.selected
|
||||||
$: tableSchema = getUserSchema(table)
|
$: tableSchema = getUserSchema(table)
|
||||||
$: customSchemaKeys = getCustomSchemaKeys(tableSchema)
|
$: customSchemaKeys = getCustomSchemaKeys(tableSchema)
|
||||||
$: if (!row.status) row.status = "active"
|
$: if (!row.status) row.status = "active"
|
||||||
|
|
||||||
const getUserSchema = (table) => {
|
const getUserSchema = table => {
|
||||||
let schema = table?.schema ?? {}
|
let schema = table?.schema ?? {}
|
||||||
if (schema.username) {
|
if (schema.username) {
|
||||||
schema.username.name = "Username"
|
schema.username.name = "Username"
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
return schema
|
return schema
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCustomSchemaKeys = (schema) => {
|
const getCustomSchemaKeys = schema => {
|
||||||
let customSchema = { ...schema }
|
let customSchema = { ...schema }
|
||||||
delete customSchema["email"]
|
delete customSchema["email"]
|
||||||
delete customSchema["roleId"]
|
delete customSchema["roleId"]
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
)
|
)
|
||||||
if (rowResponse.errors) {
|
if (rowResponse.errors) {
|
||||||
if (Array.isArray(rowResponse.errors)) {
|
if (Array.isArray(rowResponse.errors)) {
|
||||||
errors = rowResponse.errors.map((error) => ({ message: error }))
|
errors = rowResponse.errors.map(error => ({ message: error }))
|
||||||
} else {
|
} else {
|
||||||
errors = Object.entries(rowResponse.errors)
|
errors = Object.entries(rowResponse.errors)
|
||||||
.map(([key, error]) => ({ dataPath: key, message: error }))
|
.map(([key, error]) => ({ dataPath: key, message: error }))
|
||||||
|
@ -94,8 +94,8 @@
|
||||||
data-cy="roleId-select"
|
data-cy="roleId-select"
|
||||||
bind:value={row.roleId}
|
bind:value={row.roleId}
|
||||||
options={$roles}
|
options={$roles}
|
||||||
getOptionLabel={(role) => role.name}
|
getOptionLabel={role => role.name}
|
||||||
getOptionValue={(role) => role._id}
|
getOptionValue={role => role._id}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
label="Status"
|
label="Status"
|
||||||
|
@ -104,8 +104,8 @@
|
||||||
{ label: "Active", value: "active" },
|
{ label: "Active", value: "active" },
|
||||||
{ label: "Inactive", value: "inactive" },
|
{ label: "Inactive", value: "inactive" },
|
||||||
]}
|
]}
|
||||||
getOptionLabel={(status) => status.label}
|
getOptionLabel={status => status.label}
|
||||||
getOptionValue={(status) => status.value}
|
getOptionValue={status => status.value}
|
||||||
/>
|
/>
|
||||||
{#each customSchemaKeys as [key, meta]}
|
{#each customSchemaKeys as [key, meta]}
|
||||||
{#if !meta.autocolumn}
|
{#if !meta.autocolumn}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
let name
|
let name
|
||||||
let field
|
let field
|
||||||
|
|
||||||
$: views = $tables.list.flatMap((table) => Object.keys(table.views || {}))
|
$: views = $tables.list.flatMap(table => Object.keys(table.views || {}))
|
||||||
|
|
||||||
function saveView() {
|
function saveView() {
|
||||||
if (views.includes(name)) {
|
if (views.includes(name)) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
let errors = []
|
let errors = []
|
||||||
let builtInRoles = ["Admin", "Power", "Basic", "Public"]
|
let builtInRoles = ["Admin", "Power", "Basic", "Public"]
|
||||||
$: selectedRoleId = selectedRole._id
|
$: selectedRoleId = selectedRole._id
|
||||||
$: otherRoles = $roles.filter((role) => role._id !== selectedRoleId)
|
$: otherRoles = $roles.filter(role => role._id !== selectedRoleId)
|
||||||
$: isCreating = selectedRoleId == null || selectedRoleId === ""
|
$: isCreating = selectedRoleId == null || selectedRoleId === ""
|
||||||
|
|
||||||
const fetchBasePermissions = async () => {
|
const fetchBasePermissions = async () => {
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes the selected role
|
// Changes the selected role
|
||||||
const changeRole = (event) => {
|
const changeRole = event => {
|
||||||
const id = event?.detail
|
const id = event?.detail
|
||||||
const role = $roles.find((role) => role._id === id)
|
const role = $roles.find(role => role._id === id)
|
||||||
if (role) {
|
if (role) {
|
||||||
selectedRole = {
|
selectedRole = {
|
||||||
...role,
|
...role,
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
// Clean up empty strings
|
// Clean up empty strings
|
||||||
const keys = ["_id", "inherits", "permissionId"]
|
const keys = ["_id", "inherits", "permissionId"]
|
||||||
keys.forEach((key) => {
|
keys.forEach(key => {
|
||||||
if (selectedRole[key] === "") {
|
if (selectedRole[key] === "") {
|
||||||
delete selectedRole[key]
|
delete selectedRole[key]
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,8 @@
|
||||||
on:change={changeRole}
|
on:change={changeRole}
|
||||||
options={$roles}
|
options={$roles}
|
||||||
placeholder="Create new role"
|
placeholder="Create new role"
|
||||||
getOptionValue={(role) => role._id}
|
getOptionValue={role => role._id}
|
||||||
getOptionLabel={(role) => role.name}
|
getOptionLabel={role => role.name}
|
||||||
/>
|
/>
|
||||||
{#if selectedRole}
|
{#if selectedRole}
|
||||||
<Input
|
<Input
|
||||||
|
@ -111,16 +111,16 @@
|
||||||
label="Inherits Role"
|
label="Inherits Role"
|
||||||
bind:value={selectedRole.inherits}
|
bind:value={selectedRole.inherits}
|
||||||
options={otherRoles}
|
options={otherRoles}
|
||||||
getOptionValue={(role) => role._id}
|
getOptionValue={role => role._id}
|
||||||
getOptionLabel={(role) => role.name}
|
getOptionLabel={role => role.name}
|
||||||
placeholder="None"
|
placeholder="None"
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
label="Base Permissions"
|
label="Base Permissions"
|
||||||
bind:value={selectedRole.permissionId}
|
bind:value={selectedRole.permissionId}
|
||||||
options={basePermissions}
|
options={basePermissions}
|
||||||
getOptionValue={(x) => x._id}
|
getOptionValue={x => x._id}
|
||||||
getOptionLabel={(x) => x.name}
|
getOptionLabel={x => x.name}
|
||||||
placeholder="Choose permissions"
|
placeholder="Choose permissions"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
bind:value={exportFormat}
|
bind:value={exportFormat}
|
||||||
options={FORMATS}
|
options={FORMATS}
|
||||||
placeholder={null}
|
placeholder={null}
|
||||||
getOptionLabel={(x) => x.name}
|
getOptionLabel={x => x.name}
|
||||||
getOptionValue={(x) => x.key}
|
getOptionValue={x => x.key}
|
||||||
/>
|
/>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
return viewTable.schema[field].type === "number"
|
return viewTable.schema[field].type === "number"
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldChanged = (filter) => (ev) => {
|
const fieldChanged = filter => ev => {
|
||||||
// reset if type changed
|
// reset if type changed
|
||||||
if (
|
if (
|
||||||
filter.key &&
|
filter.key &&
|
||||||
|
@ -113,8 +113,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOptionLabel = (x) => x.name
|
const getOptionLabel = x => x.name
|
||||||
const getOptionValue = (x) => x.key
|
const getOptionValue = x => x.key
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent title="Filter" confirmText="Save" onConfirm={saveView} size="L">
|
<ModalContent title="Filter" confirmText="Save" onConfirm={saveView} size="L">
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
<Select
|
<Select
|
||||||
bind:value={filter.value}
|
bind:value={filter.value}
|
||||||
options={fieldOptions(filter.key)}
|
options={fieldOptions(filter.key)}
|
||||||
getOptionLabel={(x) => x.toString()}
|
getOptionLabel={x => x.toString()}
|
||||||
/>
|
/>
|
||||||
{:else if filter.key && isDate(filter.key)}
|
{:else if filter.key && isDate(filter.key)}
|
||||||
<DatePicker
|
<DatePicker
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
$: fields =
|
$: fields =
|
||||||
viewTable &&
|
viewTable &&
|
||||||
Object.entries(viewTable.schema)
|
Object.entries(viewTable.schema)
|
||||||
.filter((entry) => entry[1].type !== FIELDS.LINK.type)
|
.filter(entry => entry[1].type !== FIELDS.LINK.type)
|
||||||
.map(([key]) => key)
|
.map(([key]) => key)
|
||||||
|
|
||||||
function saveView() {
|
function saveView() {
|
||||||
|
|
|
@ -38,10 +38,10 @@
|
||||||
<Input value={capitalise(level)} disabled />
|
<Input value={capitalise(level)} disabled />
|
||||||
<Select
|
<Select
|
||||||
value={permissions[level]}
|
value={permissions[level]}
|
||||||
on:change={(e) => changePermission(level, e.detail)}
|
on:change={e => changePermission(level, e.detail)}
|
||||||
options={$roles}
|
options={$roles}
|
||||||
getOptionLabel={(x) => x.name}
|
getOptionLabel={x => x.name}
|
||||||
getOptionValue={(x) => x._id}
|
getOptionValue={x => x._id}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
</div>
|
</div>
|
||||||
<EditDatasourcePopover {datasource} />
|
<EditDatasourcePopover {datasource} />
|
||||||
</NavItem>
|
</NavItem>
|
||||||
{#each $queries.list.filter((query) => query.datasourceId === datasource._id) as query}
|
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
|
||||||
<NavItem
|
<NavItem
|
||||||
indentLevel={1}
|
indentLevel={1}
|
||||||
icon="SQLQuery"
|
icon="SQLQuery"
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
function checkValid(evt) {
|
function checkValid(evt) {
|
||||||
const datasourceName = evt.target.value
|
const datasourceName = evt.target.value
|
||||||
if (
|
if (
|
||||||
$datasources?.list.some(
|
$datasources?.list.some(datasource => datasource.name === datasourceName)
|
||||||
(datasource) => datasource.name === datasourceName
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
error = `Datasource with name ${datasourceName} already exists. Please choose another name.`
|
error = `Datasource with name ${datasourceName} already exists. Please choose another name.`
|
||||||
return
|
return
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
let schema = {}
|
let schema = {}
|
||||||
let fields = []
|
let fields = []
|
||||||
|
|
||||||
$: valid = !schema || fields.every((column) => schema[column].success)
|
$: valid = !schema || fields.every(column => schema[column].success)
|
||||||
$: dataImport = {
|
$: dataImport = {
|
||||||
valid,
|
valid,
|
||||||
schema: buildTableSchema(schema),
|
schema: buildTableSchema(schema),
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
const parseResult = await response.json()
|
const parseResult = await response.json()
|
||||||
schema = parseResult && parseResult.schema
|
schema = parseResult && parseResult.schema
|
||||||
fields = Object.keys(schema || {}).filter(
|
fields = Object.keys(schema || {}).filter(
|
||||||
(key) => schema[key].type !== "omit"
|
key => schema[key].type !== "omit"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check primary display is valid
|
// Check primary display is valid
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
|
|
||||||
async function handleFile(evt) {
|
async function handleFile(evt) {
|
||||||
const fileArray = Array.from(evt.target.files)
|
const fileArray = Array.from(evt.target.files)
|
||||||
if (fileArray.some((file) => file.size >= FILE_SIZE_LIMIT)) {
|
if (fileArray.some(file => file.size >= FILE_SIZE_LIMIT)) {
|
||||||
notifications.error(
|
notifications.error(
|
||||||
`Files cannot exceed ${
|
`Files cannot exceed ${
|
||||||
FILE_SIZE_LIMIT / BYTES_IN_MB
|
FILE_SIZE_LIMIT / BYTES_IN_MB
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
await validateCSV()
|
await validateCSV()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTypeChange = (column) => (evt) => {
|
const handleTypeChange = column => evt => {
|
||||||
schema[column].type = evt.detail
|
schema[column].type = evt.detail
|
||||||
validateCSV()
|
validateCSV()
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,8 @@
|
||||||
on:change={handleTypeChange(columnName)}
|
on:change={handleTypeChange(columnName)}
|
||||||
options={typeOptions}
|
options={typeOptions}
|
||||||
placeholder={null}
|
placeholder={null}
|
||||||
getOptionLabel={(option) => option.label}
|
getOptionLabel={option => option.label}
|
||||||
getOptionValue={(option) => option.value}
|
getOptionValue={option => option.value}
|
||||||
/>
|
/>
|
||||||
<span class="field-status" class:error={!schema[columnName].success}>
|
<span class="field-status" class:error={!schema[columnName].success}>
|
||||||
{schema[columnName].success ? "Success" : "Failure"}
|
{schema[columnName].success ? "Success" : "Failure"}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
ROW_LIST_TEMPLATE,
|
ROW_LIST_TEMPLATE,
|
||||||
]
|
]
|
||||||
|
|
||||||
$: tableNames = $tables.list.map((table) => table.name)
|
$: tableNames = $tables.list.map(table => table.name)
|
||||||
|
|
||||||
let modal
|
let modal
|
||||||
let name
|
let name
|
||||||
|
@ -66,8 +66,8 @@
|
||||||
// Create auto screens
|
// Create auto screens
|
||||||
if (createAutoscreens) {
|
if (createAutoscreens) {
|
||||||
const screens = screenTemplates($store, [table])
|
const screens = screenTemplates($store, [table])
|
||||||
.filter((template) => defaultScreens.includes(template.id))
|
.filter(template => defaultScreens.includes(template.id))
|
||||||
.map((template) => template.create())
|
.map(template => template.create())
|
||||||
for (let screen of screens) {
|
for (let screen of screens) {
|
||||||
// Record the table that created this screen so we can link it later
|
// Record the table that created this screen so we can link it later
|
||||||
screen.autoTableId = table._id
|
screen.autoTableId = table._id
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create autolink to newly created list screen
|
// Create autolink to newly created list screen
|
||||||
const listScreen = screens.find((screen) =>
|
const listScreen = screens.find(screen =>
|
||||||
screen.props._instanceName.endsWith("List")
|
screen.props._instanceName.endsWith("List")
|
||||||
)
|
)
|
||||||
await store.actions.components.links.save(
|
await store.actions.components.links.save(
|
||||||
|
|
|
@ -24,11 +24,9 @@
|
||||||
|
|
||||||
function showDeleteModal() {
|
function showDeleteModal() {
|
||||||
const screens = $allScreens
|
const screens = $allScreens
|
||||||
templateScreens = screens.filter(
|
templateScreens = screens.filter(screen => screen.autoTableId === table._id)
|
||||||
(screen) => screen.autoTableId === table._id
|
|
||||||
)
|
|
||||||
willBeDeleted = ["All table data"].concat(
|
willBeDeleted = ["All table data"].concat(
|
||||||
templateScreens.map((screen) => `Screen ${screen.props._instanceName}`)
|
templateScreens.map(screen => `Screen ${screen.props._instanceName}`)
|
||||||
)
|
)
|
||||||
confirmDeleteDialog.show()
|
confirmDeleteDialog.show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
bindingDrawer.hide()
|
bindingDrawer.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onChange = (value) => {
|
const onChange = value => {
|
||||||
dispatch("change", readableToRuntimeBinding(bindings, value))
|
dispatch("change", readableToRuntimeBinding(bindings, value))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<Input
|
<Input
|
||||||
{label}
|
{label}
|
||||||
value={readableValue}
|
value={readableValue}
|
||||||
on:change={(event) => onChange(event.detail)}
|
on:change={event => onChange(event.detail)}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
/>
|
/>
|
||||||
<div class="icon" on:click={bindingDrawer.show}>
|
<div class="icon" on:click={bindingDrawer.show}>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
slot="body"
|
slot="body"
|
||||||
value={readableValue}
|
value={readableValue}
|
||||||
close={handleClose}
|
close={handleClose}
|
||||||
on:update={(event) => (tempValue = event.detail)}
|
on:update={event => (tempValue = event.detail)}
|
||||||
bindableProperties={bindings}
|
bindableProperties={bindings}
|
||||||
/>
|
/>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
export let linkedRows = []
|
export let linkedRows = []
|
||||||
|
|
||||||
let rows = []
|
let rows = []
|
||||||
let linkedIds = (linkedRows || [])?.map((row) => row?._id || row)
|
let linkedIds = (linkedRows || [])?.map(row => row?._id || row)
|
||||||
|
|
||||||
$: linkedRows = linkedIds
|
$: linkedRows = linkedIds
|
||||||
$: label = capitalise(schema.name)
|
$: label = capitalise(schema.name)
|
||||||
$: linkedTableId = schema.tableId
|
$: linkedTableId = schema.tableId
|
||||||
$: linkedTable = $tables.list.find((table) => table._id === linkedTableId)
|
$: linkedTable = $tables.list.find(table => table._id === linkedTableId)
|
||||||
$: fetchRows(linkedTableId)
|
$: fetchRows(linkedTableId)
|
||||||
|
|
||||||
async function fetchRows(linkedTableId) {
|
async function fetchRows(linkedTableId) {
|
||||||
|
@ -44,8 +44,8 @@
|
||||||
value={linkedIds?.[0]}
|
value={linkedIds?.[0]}
|
||||||
options={rows}
|
options={rows}
|
||||||
getOptionLabel={getPrettyName}
|
getOptionLabel={getPrettyName}
|
||||||
getOptionValue={(row) => row._id}
|
getOptionValue={row => row._id}
|
||||||
on:change={(e) => (linkedIds = e.detail ? [e.detail] : [])}
|
on:change={e => (linkedIds = e.detail ? [e.detail] : [])}
|
||||||
{label}
|
{label}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -54,6 +54,6 @@
|
||||||
{label}
|
{label}
|
||||||
options={rows}
|
options={rows}
|
||||||
getOptionLabel={getPrettyName}
|
getOptionLabel={getPrettyName}
|
||||||
getOptionValue={(row) => row._id}
|
getOptionValue={row => row._id}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
export let values
|
export let values
|
||||||
export let label
|
export let label
|
||||||
|
|
||||||
const inputChanged = (ev) => {
|
const inputChanged = ev => {
|
||||||
try {
|
try {
|
||||||
values = ev.target.value.split("\n")
|
values = ev.target.value.split("\n")
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
$: automations = $automationStore.automations
|
$: automations = $automationStore.automations
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
webhookUrls = automations.map((automation) => {
|
webhookUrls = automations.map(automation => {
|
||||||
const trigger = automation.definition.trigger
|
const trigger = automation.definition.trigger
|
||||||
if (trigger?.stepId === "WEBHOOK" && trigger.inputs) {
|
if (trigger?.stepId === "WEBHOOK" && trigger.inputs) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
for (let incomingDeployment of incoming) {
|
for (let incomingDeployment of incoming) {
|
||||||
if (incomingDeployment.status === DeploymentStatus.FAILURE) {
|
if (incomingDeployment.status === DeploymentStatus.FAILURE) {
|
||||||
const currentDeployment = current.find(
|
const currentDeployment = current.find(
|
||||||
(deployment) => deployment._id === incomingDeployment._id
|
deployment => deployment._id === incomingDeployment._id
|
||||||
)
|
)
|
||||||
|
|
||||||
// We have just been notified of an ongoing deployments failure
|
// We have just been notified of an ongoing deployments failure
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
<header>
|
<header>
|
||||||
<Heading>Deployment History</Heading>
|
<Heading>Deployment History</Heading>
|
||||||
<div class="deploy-div">
|
<div class="deploy-div">
|
||||||
{#if deployments.some((deployment) => deployment.status === DeploymentStatus.SUCCESS)}
|
{#if deployments.some(deployment => deployment.status === DeploymentStatus.SUCCESS)}
|
||||||
<a target="_blank" href={deploymentUrl}> View Your Deployed App → </a>
|
<a target="_blank" href={deploymentUrl}> View Your Deployed App → </a>
|
||||||
<Button primary on:click={() => modal.show()}>View webhooks</Button>
|
<Button primary on:click={() => modal.show()}>View webhooks</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
const enrichStructure = (structure, definitions) => {
|
const enrichStructure = (structure, definitions) => {
|
||||||
let enrichedStructure = []
|
let enrichedStructure = []
|
||||||
structure.forEach((item) => {
|
structure.forEach(item => {
|
||||||
if (typeof item === "string") {
|
if (typeof item === "string") {
|
||||||
const def = definitions[`@budibase/standard-components/${item}`]
|
const def = definitions[`@budibase/standard-components/${item}`]
|
||||||
if (def) {
|
if (def) {
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
return enrichedStructure
|
return enrichedStructure
|
||||||
}
|
}
|
||||||
|
|
||||||
const onItemChosen = async (item) => {
|
const onItemChosen = async item => {
|
||||||
if (!item.isCategory) {
|
if (!item.isCategory) {
|
||||||
await store.actions.components.create(item.component)
|
await store.actions.components.create(item.component)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
if (currentIndex === 0) {
|
if (currentIndex === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const newChildren = parent._children.filter((c) => c !== component)
|
const newChildren = parent._children.filter(c => c !== component)
|
||||||
newChildren.splice(currentIndex - 1, 0, component)
|
newChildren.splice(currentIndex - 1, 0, component)
|
||||||
parent._children = newChildren
|
parent._children = newChildren
|
||||||
store.actions.preview.saveSelected()
|
store.actions.preview.saveSelected()
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
if (currentIndex === parent._children.length - 1) {
|
if (currentIndex === parent._children.length - 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const newChildren = parent._children.filter((c) => c !== component)
|
const newChildren = parent._children.filter(c => c !== component)
|
||||||
newChildren.splice(currentIndex + 1, 0, component)
|
newChildren.splice(currentIndex + 1, 0, component)
|
||||||
parent._children = newChildren
|
parent._children = newChildren
|
||||||
store.actions.preview.saveSelected()
|
store.actions.preview.saveSelected()
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
store.actions.components.copy(component, cut)
|
store.actions.components.copy(component, cut)
|
||||||
}
|
}
|
||||||
|
|
||||||
const pasteComponent = (mode) => {
|
const pasteComponent = mode => {
|
||||||
// lives in store - also used by drag drop
|
// lives in store - also used by drag drop
|
||||||
store.actions.components.paste(component, mode)
|
store.actions.components.paste(component, mode)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,18 @@
|
||||||
export let level = 0
|
export let level = 0
|
||||||
export let dragDropStore
|
export let dragDropStore
|
||||||
|
|
||||||
const isScreenslot = (name) => name?.endsWith("screenslot")
|
const isScreenslot = name => name?.endsWith("screenslot")
|
||||||
|
|
||||||
const selectComponent = (component) => {
|
const selectComponent = component => {
|
||||||
store.actions.components.select(component)
|
store.actions.components.select(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
const dragstart = (component) => (e) => {
|
const dragstart = component => e => {
|
||||||
e.dataTransfer.dropEffect = DropEffect.MOVE
|
e.dataTransfer.dropEffect = DropEffect.MOVE
|
||||||
dragDropStore.actions.dragstart(component)
|
dragDropStore.actions.dragstart(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
const dragover = (component, index) => (e) => {
|
const dragover = (component, index) => e => {
|
||||||
const definition = store.actions.components.getDefinition(
|
const definition = store.actions.components.getDefinition(
|
||||||
component._component
|
component._component
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
route.subpaths[selectedScreen?.routing?.route] !== undefined
|
route.subpaths[selectedScreen?.routing?.route] !== undefined
|
||||||
$: routeOpened = routeManuallyOpened || routeSelected || hasSearchMatch
|
$: routeOpened = routeManuallyOpened || routeSelected || hasSearchMatch
|
||||||
|
|
||||||
const changeScreen = (screenId) => {
|
const changeScreen = screenId => {
|
||||||
store.actions.screens.select(screenId)
|
store.actions.screens.select(screenId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAllScreens = (route) => {
|
const getAllScreens = route => {
|
||||||
let screens = []
|
let screens = []
|
||||||
Object.entries(route.subpaths).forEach(([route, subpath]) => {
|
Object.entries(route.subpaths).forEach(([route, subpath]) => {
|
||||||
Object.entries(subpath.screens).forEach(([role, id]) => {
|
Object.entries(subpath.screens).forEach(([role, id]) => {
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
const getFilteredScreens = (screens, searchString) => {
|
const getFilteredScreens = (screens, searchString) => {
|
||||||
return screens.filter(
|
return screens.filter(
|
||||||
(screen) => !searchString || screen.route.includes(searchString)
|
screen => !searchString || screen.route.includes(searchString)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
let confirmDeleteDialog
|
let confirmDeleteDialog
|
||||||
|
|
||||||
$: screen = $allScreens.find((screen) => screen._id === screenId)
|
$: screen = $allScreens.find(screen => screen._id === screenId)
|
||||||
|
|
||||||
const deleteScreen = () => {
|
const deleteScreen = () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,8 +17,8 @@ export default function () {
|
||||||
const store = writable({})
|
const store = writable({})
|
||||||
|
|
||||||
store.actions = {
|
store.actions = {
|
||||||
dragstart: (component) => {
|
dragstart: component => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.dragged = component
|
state.dragged = component
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
@ -29,7 +29,7 @@ export default function () {
|
||||||
canHaveChildrenButIsEmpty,
|
canHaveChildrenButIsEmpty,
|
||||||
mousePosition,
|
mousePosition,
|
||||||
}) => {
|
}) => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.targetComponent = component
|
state.targetComponent = component
|
||||||
// only allow dropping inside when container is empty
|
// only allow dropping inside when container is empty
|
||||||
// if container has children, drag over them
|
// if container has children, drag over them
|
||||||
|
@ -65,7 +65,7 @@ export default function () {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
reset: () => {
|
reset: () => {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.dropPosition = ""
|
state.dropPosition = ""
|
||||||
state.targetComponent = null
|
state.targetComponent = null
|
||||||
state.dragged = null
|
state.dragged = null
|
||||||
|
@ -85,7 +85,7 @@ export default function () {
|
||||||
}
|
}
|
||||||
// Stop if the target is a child of source
|
// Stop if the target is a child of source
|
||||||
const path = findComponentPath(state.dragged, state.targetComponent._id)
|
const path = findComponentPath(state.dragged, state.targetComponent._id)
|
||||||
const ids = path.map((component) => component._id)
|
const ids = path.map(component => component._id)
|
||||||
if (ids.includes(state.targetComponent._id)) {
|
if (ids.includes(state.targetComponent._id)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
let screenRoleId
|
let screenRoleId
|
||||||
|
|
||||||
// Filter all routes down to only those which match the current role
|
// Filter all routes down to only those which match the current role
|
||||||
sortedPaths.forEach((path) => {
|
sortedPaths.forEach(path => {
|
||||||
const config = allRoutes[path]
|
const config = allRoutes[path]
|
||||||
Object.entries(config.subpaths).forEach(([subpath, pathConfig]) => {
|
Object.entries(config.subpaths).forEach(([subpath, pathConfig]) => {
|
||||||
Object.entries(pathConfig.screens).forEach(([roleId, screenId]) => {
|
Object.entries(pathConfig.screens).forEach(([roleId, screenId]) => {
|
||||||
|
|
|
@ -26,22 +26,21 @@
|
||||||
]
|
]
|
||||||
|
|
||||||
let modal
|
let modal
|
||||||
$: selected =
|
$: selected = tabs.find(t => t.key === $params.assetType)?.title || "Screens"
|
||||||
tabs.find((t) => t.key === $params.assetType)?.title || "Screens"
|
|
||||||
|
|
||||||
const navigate = ({ detail }) => {
|
const navigate = ({ detail }) => {
|
||||||
const { key } = tabs.find((t) => t.title === detail)
|
const { key } = tabs.find(t => t.title === detail)
|
||||||
$goto(`../${key}`)
|
$goto(`../${key}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateAccessRole = (event) => {
|
const updateAccessRole = event => {
|
||||||
const role = event.detail
|
const role = event.detail
|
||||||
|
|
||||||
// Select a valid screen with this new role - otherwise we'll not be
|
// Select a valid screen with this new role - otherwise we'll not be
|
||||||
// able to change role at all because ComponentNavigationTree will kick us
|
// able to change role at all because ComponentNavigationTree will kick us
|
||||||
// back the current role again because the same screen ID is still selected
|
// back the current role again because the same screen ID is still selected
|
||||||
const firstValidScreenId = $allScreens.find(
|
const firstValidScreenId = $allScreens.find(
|
||||||
(screen) => screen.routing.roleId === role
|
screen => screen.routing.roleId === role
|
||||||
)?._id
|
)?._id
|
||||||
if (firstValidScreenId) {
|
if (firstValidScreenId) {
|
||||||
store.actions.screens.select(firstValidScreenId)
|
store.actions.screens.select(firstValidScreenId)
|
||||||
|
@ -50,7 +49,7 @@
|
||||||
// Otherwise clear the selected screen ID so that the first new valid screen
|
// Otherwise clear the selected screen ID so that the first new valid screen
|
||||||
// can be selected by ComponentNavigationTree
|
// can be selected by ComponentNavigationTree
|
||||||
else {
|
else {
|
||||||
store.update((state) => {
|
store.update(state => {
|
||||||
state.selectedScreenId = null
|
state.selectedScreenId = null
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
@ -73,8 +72,8 @@
|
||||||
on:change={updateAccessRole}
|
on:change={updateAccessRole}
|
||||||
value={$selectedAccessRole}
|
value={$selectedAccessRole}
|
||||||
label="Filter by Access"
|
label="Filter by Access"
|
||||||
getOptionLabel={(role) => role.name}
|
getOptionLabel={role => role.name}
|
||||||
getOptionValue={(role) => role._id}
|
getOptionValue={role => role._id}
|
||||||
options={$roles}
|
options={$roles}
|
||||||
/>
|
/>
|
||||||
<Search
|
<Search
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue