Skip to content

Commit

Permalink
Fix evaluated filters overwriting configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajfa committed Dec 11, 2024
1 parent b6b8f1b commit 03ec8d3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,7 @@ export default {
case compose.PageBlockCalendar.feedResources.record:
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID })
.then(module => {
const ff = {
...feed,
options: { ...feed.options },
}
const ff = compose.PageBlockCalendar.makeFeed(feed) // Clone feed, so we don't modify the original
// Interpolate prefilter variables
if (ff.options.prefilter) {
Expand Down
89 changes: 44 additions & 45 deletions client/web/compose/src/components/PageBlocks/GeometryBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,51 +190,50 @@ export default {
}
Promise.all(this.options.feeds.filter(f => f.isValid()).map((feed, idx) => {
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID })
.then(module => {
const f = { ...feed } // Clone feed, so we dont modify the original
// Interpolate prefilter variables
if (f.options.prefilter) {
f.options.prefilter = evaluatePrefilter(f.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,
})
}
return compose.PageBlockGeometry.RecordFeed(this.$ComposeAPI, module, this.namespace, f, { cancelToken: this.cancelTokenSource.token })
.then(records => {
const mapModuleField = module.fields.find(field => field.name === f.geometryField)
if (!mapModuleField) return
this.geometries[idx] = records.map(record => {
let geometry = record.values[f.geometryField]
let markers = []
if (mapModuleField.isMulti) {
geometry = geometry.map(value => this.parseGeometryField(value))
markers = geometry
} else {
geometry = this.parseGeometryField(geometry)
markers = [geometry]
}
return {
title: record.values[f.titleField],
geometry: f.displayPolygon ? geometry : [],
markers,
color: f.options.color,
displayMarker: f.displayMarker,
recordID: record.recordID,
moduleID: record.moduleID,
}
}).filter(g => g && g.markers.length)
})
})
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID }).then(module => {
const f = compose.PageBlockGeometry.makeFeed(feed) // Clone feed, so we don't modify the original
// Interpolate prefilter variables
if (f.options.prefilter) {
f.options.prefilter = evaluatePrefilter(f.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,
})
}
return compose.PageBlockGeometry.RecordFeed(this.$ComposeAPI, module, this.namespace, f, { cancelToken: this.cancelTokenSource.token })
.then(records => {
const mapModuleField = module.fields.find(field => field.name === f.geometryField)
if (!mapModuleField) return
this.geometries[idx] = records.map(record => {
let geometry = record.values[f.geometryField]
let markers = []
if (mapModuleField.isMulti) {
geometry = geometry.map(value => this.parseGeometryField(value))
markers = geometry
} else {
geometry = this.parseGeometryField(geometry)
markers = [geometry]
}
return {
title: record.values[f.titleField],
geometry: f.displayPolygon ? geometry : [],
markers,
color: f.options.color,
displayMarker: f.displayMarker,
recordID: record.recordID,
moduleID: record.moduleID,
}
}).filter(g => g && g.markers.length)
})
})
})).finally(() => {
setTimeout(() => {
this.processing = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export default {
if (m.moduleID) {
// prepare a fresh metric with an evaluated prefilter
const auxM = { ...m }
if (auxM.filter) {
auxM.filter = evaluatePrefilter(auxM.filter, {
record: this.record,
Expand Down

0 comments on commit 03ec8d3

Please sign in to comment.