Some minor UI tweaks.
This commit is contained in:
parent
9dd987ffc2
commit
ae510760c3
|
@ -137,9 +137,9 @@ export function getDynamicVariables(datasource, queryId) {
|
||||||
|
|
||||||
// convert dynamic variables object back to a list, enrich with query id
|
// convert dynamic variables object back to a list, enrich with query id
|
||||||
export function rebuildVariables(datasource, queryId, variables) {
|
export function rebuildVariables(datasource, queryId, variables) {
|
||||||
let finalVars = []
|
let newVariables = []
|
||||||
if (variables) {
|
if (variables) {
|
||||||
finalVars = Object.entries(variables).map(entry => {
|
newVariables = Object.entries(variables).map(entry => {
|
||||||
return {
|
return {
|
||||||
name: entry[0],
|
name: entry[0],
|
||||||
value: entry[1],
|
value: entry[1],
|
||||||
|
@ -147,7 +147,15 @@ export function rebuildVariables(datasource, queryId, variables) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return [...(datasource?.config?.dynamicVariables || []), ...finalVars]
|
let existing = datasource?.config?.dynamicVariables || []
|
||||||
|
// filter out any by same name
|
||||||
|
existing = existing.filter(
|
||||||
|
variable =>
|
||||||
|
!newVariables.find(
|
||||||
|
newVar => newVar.name.toLowerCase() === variable.name.toLowerCase()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return [...existing, ...newVariables]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function shouldShowVariables(dynamicVariables, variablesReadOnly) {
|
export function shouldShowVariables(dynamicVariables, variablesReadOnly) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Input, ModalContent, Modal } from "@budibase/bbui"
|
import { Input, ModalContent, Modal, Body } from "@budibase/bbui"
|
||||||
|
|
||||||
export let dynamicVariables
|
export let dynamicVariables
|
||||||
export let datasource
|
export let datasource
|
||||||
|
@ -44,6 +44,10 @@
|
||||||
confirmText="Save"
|
confirmText="Save"
|
||||||
onConfirm={saveVariable}
|
onConfirm={saveVariable}
|
||||||
disabled={!valid}
|
disabled={!valid}
|
||||||
|
>
|
||||||
|
<Body size="S"
|
||||||
|
>Specify a name for your new dynamic variable, this must be unique across
|
||||||
|
your datasource.</Body
|
||||||
>
|
>
|
||||||
<Input label="Variable name" bind:value={name} on:input {error} />
|
<Input label="Variable name" bind:value={name} on:input {error} />
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
|
@ -16,6 +16,10 @@ class QueryRunner {
|
||||||
this.queryId = input.queryId
|
this.queryId = input.queryId
|
||||||
this.noRecursiveQuery = flags.noRecursiveQuery
|
this.noRecursiveQuery = flags.noRecursiveQuery
|
||||||
this.cachedVariables = []
|
this.cachedVariables = []
|
||||||
|
// allows the response from a query to be stored throughout this
|
||||||
|
// execution so that if it needs to be re-used for another variable
|
||||||
|
// it can be
|
||||||
|
this.queryResponse = {}
|
||||||
this.hasRerun = false
|
this.hasRerun = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +106,11 @@ class QueryRunner {
|
||||||
name = variable.name
|
name = variable.name
|
||||||
let value = await threadUtils.checkCacheForDynamicVariable(queryId, name)
|
let value = await threadUtils.checkCacheForDynamicVariable(queryId, name)
|
||||||
if (!value) {
|
if (!value) {
|
||||||
value = await this.runAnotherQuery(queryId, parameters)
|
value = this.queryResponse[queryId]
|
||||||
|
? this.queryResponse[queryId]
|
||||||
|
: await this.runAnotherQuery(queryId, parameters)
|
||||||
|
// store incase this query is to be called again
|
||||||
|
this.queryResponse[queryId] = value
|
||||||
await threadUtils.storeDynamicVariable(queryId, name, value)
|
await threadUtils.storeDynamicVariable(queryId, name, value)
|
||||||
} else {
|
} else {
|
||||||
this.cachedVariables.push({ queryId, name })
|
this.cachedVariables.push({ queryId, name })
|
||||||
|
|
Loading…
Reference in New Issue