Adjust new interpolation additions implementation
This commit is contained in:
@@ -66,17 +66,16 @@
|
||||
v-model="f.options.prefilter"
|
||||
:placeholder="$t('kind.record.prefilterPlaceholder')"
|
||||
/>
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="kind.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="kind.record.prefilterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -51,17 +51,16 @@
|
||||
:placeholder="$t('recordList.record.prefilterPlaceholder')"
|
||||
/>
|
||||
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
|
||||
<b-form-group
|
||||
|
||||
@@ -36,6 +36,17 @@
|
||||
/>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
|
||||
<i18next
|
||||
path="interpolationFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
|
||||
@@ -62,6 +73,17 @@
|
||||
/>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
|
||||
<i18next
|
||||
path="interpolationFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
|
||||
|
||||
@@ -23,24 +23,14 @@ export default {
|
||||
|
||||
computed: {
|
||||
contentBody () {
|
||||
const { body } = this.options
|
||||
const { body = '' } = this.options
|
||||
|
||||
// Regular expression to match ${} tokens
|
||||
const tokenRegex = /\${(.*?)}/g
|
||||
|
||||
// Replace each token with its prefiltered content
|
||||
const prefilteredBody = body.replace(tokenRegex, (match, tokenContent) => {
|
||||
const reconstructedToken = '${' + tokenContent + '}'
|
||||
|
||||
return evaluatePrefilter(reconstructedToken, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
return evaluatePrefilter(body, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
|
||||
return prefilteredBody
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,6 +9,17 @@
|
||||
openLinkInNewTab: $t('content.openLinkInNewTab'),
|
||||
}"
|
||||
/>
|
||||
|
||||
<i18next
|
||||
path="interpolationFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-tab>
|
||||
</template>
|
||||
|
||||
@@ -24,21 +24,22 @@ export default {
|
||||
src () {
|
||||
const { srcField, src } = this.options
|
||||
const blank = 'about:blank'
|
||||
let url = src
|
||||
|
||||
if (this.options.srcField) {
|
||||
if (this.record) {
|
||||
return this.record.values[srcField] || blank
|
||||
url = this.record.values[srcField]
|
||||
}
|
||||
}
|
||||
|
||||
const prefilteredSource = evaluatePrefilter(src, {
|
||||
const interpolatedURL = evaluatePrefilter(url, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
|
||||
return prefilteredSource || blank
|
||||
return interpolatedURL || blank
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -22,6 +22,16 @@
|
||||
v-model="options.src"
|
||||
type="url"
|
||||
/>
|
||||
<i18next
|
||||
path="interpolationFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-tab>
|
||||
</template>
|
||||
|
||||
@@ -166,6 +166,15 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
if (auxM.transformFx) {
|
||||
auxM.transformFx = evaluatePrefilter(auxM.transformFx, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
}
|
||||
|
||||
const vals = await this.block.fetch({ m: auxM }, reporter)
|
||||
rtr.push(vals)
|
||||
}
|
||||
|
||||
@@ -153,17 +153,16 @@
|
||||
class="mb-1"
|
||||
/>
|
||||
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="small"
|
||||
class="d-block text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</fieldset>
|
||||
|
||||
@@ -208,21 +207,19 @@
|
||||
v-model="edit.transformFx"
|
||||
placeholder="v"
|
||||
class="mb-1"
|
||||
@change="evaluateTransformation"
|
||||
/>
|
||||
|
||||
<small>{{ $t('metric.edit.transformFunctionDescription') }}</small>
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.transformFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.transformFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
|
||||
<b-form-group
|
||||
@@ -341,7 +338,6 @@ import MStyle from './MStyle'
|
||||
import { mapGetters } from 'vuex'
|
||||
import MetricBase from '../MetricBase'
|
||||
import { compose, NoID } from '@cortezaproject/corteza-js'
|
||||
import { evaluatePrefilter } from 'corteza-webapp-compose/src/lib/record-filter'
|
||||
|
||||
export default {
|
||||
i18nOptions: {
|
||||
@@ -490,15 +486,6 @@ export default {
|
||||
this.dimensionModifiers = []
|
||||
this.aggregationOperations = []
|
||||
},
|
||||
|
||||
evaluateTransformation (t) {
|
||||
this.edit.transformFx = evaluatePrefilter(t, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -57,17 +57,16 @@
|
||||
placeholder="(A > B) OR (A < C)"
|
||||
class="mb-1"
|
||||
/>
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
|
||||
@@ -169,17 +168,16 @@
|
||||
placeholder="(A > B) OR (A < C)"
|
||||
class="mb-1"
|
||||
/>
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
|
||||
@@ -281,17 +279,16 @@
|
||||
placeholder="(A > B) OR (A < C)"
|
||||
class="mb-1"
|
||||
/>
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
|
||||
|
||||
@@ -263,17 +263,16 @@
|
||||
:placeholder="$t('recordList.record.prefilterPlaceholder')"
|
||||
/>
|
||||
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
</b-row>
|
||||
|
||||
@@ -50,17 +50,16 @@
|
||||
:value="true"
|
||||
:placeholder="$t('recordList.record.prefilterPlaceholder')"
|
||||
/>
|
||||
<b-form-text>
|
||||
<i18next
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
|
||||
<b-form-group
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
:class="buttonClass"
|
||||
@click.prevent="handle(b)"
|
||||
>
|
||||
{{ handleButtonLabel(b.label) || '-' }}
|
||||
{{ buttonLabel(b.label) || '-' }}
|
||||
</b-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -183,7 +183,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
handleButtonLabel (label) {
|
||||
buttonLabel (label = '') {
|
||||
return evaluatePrefilter(label, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
|
||||
@@ -7,11 +7,19 @@
|
||||
:label="$t('buttonLabel')"
|
||||
label-class="text-primary"
|
||||
>
|
||||
<b-input-group>
|
||||
<b-form-input
|
||||
v-model="button.label"
|
||||
/>
|
||||
</b-input-group>
|
||||
<b-form-input
|
||||
v-model="button.label"
|
||||
/>
|
||||
<i18next
|
||||
path="block:interpolationFootnote"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
|
||||
<b-form-group
|
||||
|
||||
@@ -233,16 +233,23 @@ export default {
|
||||
return `order-${index} text-truncate text-${alignment} ${justify !== 'none' ? 'flex-fill' : ''}`
|
||||
},
|
||||
|
||||
getTabTitle ({ title, block = {} }, tabIndex) {
|
||||
getTabTitle ({ title = '', block = {} }, tabIndex) {
|
||||
const { title: blockTitle, kind } = block
|
||||
const prefilteredTitle = evaluatePrefilter(blockTitle, {
|
||||
const interpolatedTitle = evaluatePrefilter(blockTitle, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
|
||||
return title || prefilteredTitle || blockTitle || kind || `${this.$t('tab')} ${tabIndex + 1}`
|
||||
title = evaluatePrefilter(title, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
|
||||
return title || interpolatedTitle || kind || `${this.$t('tab')} ${tabIndex + 1}`
|
||||
},
|
||||
|
||||
isTabLazy ({ block = {} }) {
|
||||
|
||||
@@ -119,10 +119,12 @@
|
||||
<tr>
|
||||
<th />
|
||||
|
||||
<th
|
||||
class="text-primary"
|
||||
>
|
||||
<th class="d-flex align-items-center text-primary">
|
||||
{{ $t('tabs.table.columns.title.label') }}
|
||||
<c-hint
|
||||
:tooltip="$t('interpolationFootnote', ['${record.values.fieldName}', '${recordID}', '${ownerID}', '${userID}'])"
|
||||
class="d-block"
|
||||
/>
|
||||
</th>
|
||||
|
||||
<th
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
</div>
|
||||
|
||||
<b-card-text
|
||||
v-if="block.description"
|
||||
v-if="blockDescription"
|
||||
class="text-dark text-wrap mt-1"
|
||||
>
|
||||
{{ block.description }}
|
||||
{{ blockDescription }}
|
||||
</b-card-text>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
</div>
|
||||
|
||||
<b-card-text
|
||||
v-if="block.description"
|
||||
v-if="blockDescription"
|
||||
class="text-dark text-wrap mt-1"
|
||||
>
|
||||
{{ block.description }}
|
||||
{{ blockDescription }}
|
||||
</b-card-text>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -89,6 +89,15 @@ export default {
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
},
|
||||
|
||||
blockDescription () {
|
||||
return evaluatePrefilter(this.block.description, {
|
||||
record: this.$attrs.record,
|
||||
recordID: (this.$attrs.record || {}).recordID || NoID,
|
||||
ownerID: (this.$attrs.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -506,31 +506,31 @@
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
|
||||
<b-form-text>
|
||||
<i18next
|
||||
v-if="isRecordPage"
|
||||
path="page-layout.condition.description.record-page"
|
||||
tag="span"
|
||||
>
|
||||
<code>record.values.fieldName</code>
|
||||
<code>user.(userID/email...)</code>
|
||||
<code>screen.(width/height)</code>
|
||||
<code>isView/isCreate/isEdit</code>
|
||||
<code>user.userID == record.values.createdBy</code>
|
||||
<code>screen.width < 1024</code>
|
||||
</i18next>
|
||||
<i18next
|
||||
v-if="isRecordPage"
|
||||
path="page-layout.condition.description.record-page"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>record.values.fieldName</code>
|
||||
<code>user.(userID/email...)</code>
|
||||
<code>screen.(width/height)</code>
|
||||
<code>isView/isCreate/isEdit</code>
|
||||
<code>user.userID == record.values.createdBy</code>
|
||||
<code>screen.width < 1024</code>
|
||||
</i18next>
|
||||
|
||||
<i18next
|
||||
v-else
|
||||
path="page-layout.condition.description.non-record-page"
|
||||
tag="span"
|
||||
>
|
||||
<code>user.(userID/email...)</code>
|
||||
<code>screen.(width/height)</code>
|
||||
<code>user.email == "test@mail.com"</code>
|
||||
<code>screen.width < 1024</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
<i18next
|
||||
v-else
|
||||
path="page-layout.condition.description.non-record-page"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>user.(userID/email...)</code>
|
||||
<code>screen.(width/height)</code>
|
||||
<code>user.email == "test@mail.com"</code>
|
||||
<code>screen.width < 1024</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
|
||||
<b-form-group
|
||||
|
||||
@@ -200,7 +200,7 @@ metric:
|
||||
dimensionLabel: Dimension
|
||||
filterLabel: Filter
|
||||
filterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
transformFootnote: Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
transformFootnote: Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available). Make sure to wrap the variables with quotes ("")
|
||||
labelLabel: Label
|
||||
labelPlaceholder: Label
|
||||
metricFieldLabel: Field
|
||||
@@ -847,4 +847,5 @@ tabs:
|
||||
editDisabled: Editing tabbed blocks is disabled until you save this block
|
||||
addBlock: Add new block
|
||||
|
||||
noConfiguration: Block not configured correctly
|
||||
noConfiguration: Block not configured correctly
|
||||
interpolationFootnote: Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
Reference in New Issue
Block a user