Skip to content

Commit

Permalink
Add user object to all evaluatePrefilter variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajfa committed Mar 19, 2024
1 parent 7fc4ca9 commit eb9cce2
Show file tree
Hide file tree
Showing 29 changed files with 38 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ export default {
if (this.field.options.prefilter) {
const pf = evaluatePrefilter(this.field.options.prefilter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export default {
if (ff.options.prefilter) {
ff.options.prefilter = evaluatePrefilter(ff.options.prefilter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
1 change: 1 addition & 0 deletions client/web/compose/src/components/PageBlocks/ChartBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
filter = evaluatePrefilter(filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export default {
if (this.options.filter) {
return evaluatePrefilter(this.options.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>

Expand Down
4 changes: 2 additions & 2 deletions client/web/compose/src/components/PageBlocks/Configurator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down Expand Up @@ -81,7 +81,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
return evaluatePrefilter(body, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-tab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default {
if (feed.options.prefilter) {
feed.options.prefilter = evaluatePrefilter(feed.options.prefilter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {
const interpolatedURL = evaluatePrefilter(url, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-tab>
Expand Down
2 changes: 2 additions & 0 deletions client/web/compose/src/components/PageBlocks/MetricBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default {
if (auxM.filter) {
auxM.filter = evaluatePrefilter(auxM.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand All @@ -166,6 +167,7 @@ export default {
if (auxM.transformFx) {
auxM.transformFx = evaluatePrefilter(auxM.transformFx, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</fieldset>
Expand Down Expand Up @@ -218,7 +218,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>

Expand Down
3 changes: 3 additions & 0 deletions client/web/compose/src/components/PageBlocks/ProgressBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default {
value: {
filter: evaluatePrefilter(this.options.value.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand All @@ -107,6 +108,7 @@ export default {
minValue: {
filter: evaluatePrefilter(this.options.minValue.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand All @@ -115,6 +117,7 @@ export default {
maxValue: {
filter: evaluatePrefilter(this.options.maxValue.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down Expand Up @@ -176,7 +176,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down Expand Up @@ -287,7 +287,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ export default {
if (prefilter) {
const pf = evaluatePrefilter(prefilter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>
</b-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export default {
// hence the /hanging/ record, recordID, ownerID and userID variables
filter.push(`(${evaluatePrefilter(this.options.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export default {
buttonLabel (label = '') {
return evaluatePrefilter(label, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>

Expand Down
2 changes: 2 additions & 0 deletions client/web/compose/src/components/PageBlocks/TabsBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,15 @@ export default {
const { title: blockTitle, kind } = block
const interpolatedTitle = evaluatePrefilter(blockTitle, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
})
title = evaluatePrefilter(title, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
2 changes: 2 additions & 0 deletions client/web/compose/src/components/PageBlocks/Wrap/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
blockTitle () {
return evaluatePrefilter(this.block.title, {
record: this.$attrs.record,
user: this.$auth.user || {},
recordID: (this.$attrs.record || {}).recordID || NoID,
ownerID: (this.$attrs.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand All @@ -99,6 +100,7 @@ export default {
blockDescription () {
return evaluatePrefilter(this.block.description, {
record: this.$attrs.record,
user: this.$auth.user || {},
recordID: (this.$attrs.record || {}).recordID || NoID,
ownerID: (this.$attrs.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
2 changes: 1 addition & 1 deletion client/web/compose/src/lib/record-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function queryToFilter (searchQuery = '', prefilter = '', fields = [], re

// Evaluates the given prefilter. Allows JS template literal expressions
// such as id = ${recordID}
export function evaluatePrefilter (prefilter, { record, recordID, ownerID, userID }) {
export function evaluatePrefilter (prefilter, { record, user, recordID, ownerID, userID }) {
return (function (prefilter) {
/* eslint-disable no-eval */
return eval('`' + prefilter + '`')
Expand Down
1 change: 1 addition & 0 deletions client/web/compose/src/views/Admin/Charts/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ export default {
if (nr.filter) {
nr.filter = evaluatePrefilter(nr.filter, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down
2 changes: 1 addition & 1 deletion client/web/compose/src/views/Admin/Pages/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
<code>${record.values.fieldName}</code>
<code>${recordID}</code>
<code>${ownerID}</code>
<code>${userID}</code>
<code>${userID}, ${user.name}</code>
</i18next>
</b-form-group>

Expand Down
1 change: 1 addition & 0 deletions client/web/compose/src/views/Public/Pages/Records/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export default {
try {
return evaluatePrefilter(meta.title, {
record: this.record,
user: this.$auth.user || {},
recordID: (this.record || {}).recordID || NoID,
ownerID: (this.record || {}).ownedBy || NoID,
userID: (this.$auth.user || {}).userID || NoID,
Expand Down

0 comments on commit eb9cce2

Please sign in to comment.