Fix evaluated filters overwriting configuration
This commit is contained in:
parent
b6b8f1b8b7
commit
03ec8d3930
@ -328,10 +328,7 @@ export default {
|
|||||||
case compose.PageBlockCalendar.feedResources.record:
|
case compose.PageBlockCalendar.feedResources.record:
|
||||||
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID })
|
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID })
|
||||||
.then(module => {
|
.then(module => {
|
||||||
const ff = {
|
const ff = compose.PageBlockCalendar.makeFeed(feed) // Clone feed, so we don't modify the original
|
||||||
...feed,
|
|
||||||
options: { ...feed.options },
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interpolate prefilter variables
|
// Interpolate prefilter variables
|
||||||
if (ff.options.prefilter) {
|
if (ff.options.prefilter) {
|
||||||
|
|||||||
@ -190,51 +190,50 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(this.options.feeds.filter(f => f.isValid()).map((feed, idx) => {
|
Promise.all(this.options.feeds.filter(f => f.isValid()).map((feed, idx) => {
|
||||||
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID })
|
return this.findModuleByID({ namespace: this.namespace, moduleID: feed.options.moduleID }).then(module => {
|
||||||
.then(module => {
|
const f = compose.PageBlockGeometry.makeFeed(feed) // Clone feed, so we don't modify the original
|
||||||
const f = { ...feed } // Clone feed, so we dont modify the original
|
|
||||||
|
|
||||||
// Interpolate prefilter variables
|
// Interpolate prefilter variables
|
||||||
if (f.options.prefilter) {
|
if (f.options.prefilter) {
|
||||||
f.options.prefilter = evaluatePrefilter(f.options.prefilter, {
|
f.options.prefilter = evaluatePrefilter(f.options.prefilter, {
|
||||||
record: this.record,
|
record: this.record,
|
||||||
user: this.$auth.user || {},
|
user: this.$auth.user || {},
|
||||||
recordID: (this.record || {}).recordID || NoID,
|
recordID: (this.record || {}).recordID || NoID,
|
||||||
ownerID: (this.record || {}).ownedBy || NoID,
|
ownerID: (this.record || {}).ownedBy || NoID,
|
||||||
userID: (this.$auth.user || {}).userID || NoID,
|
userID: (this.$auth.user || {}).userID || NoID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return compose.PageBlockGeometry.RecordFeed(this.$ComposeAPI, module, this.namespace, f, { cancelToken: this.cancelTokenSource.token })
|
return compose.PageBlockGeometry.RecordFeed(this.$ComposeAPI, module, this.namespace, f, { cancelToken: this.cancelTokenSource.token })
|
||||||
.then(records => {
|
.then(records => {
|
||||||
const mapModuleField = module.fields.find(field => field.name === f.geometryField)
|
const mapModuleField = module.fields.find(field => field.name === f.geometryField)
|
||||||
|
|
||||||
if (!mapModuleField) return
|
if (!mapModuleField) return
|
||||||
|
|
||||||
this.geometries[idx] = records.map(record => {
|
this.geometries[idx] = records.map(record => {
|
||||||
let geometry = record.values[f.geometryField]
|
let geometry = record.values[f.geometryField]
|
||||||
let markers = []
|
let markers = []
|
||||||
|
|
||||||
if (mapModuleField.isMulti) {
|
if (mapModuleField.isMulti) {
|
||||||
geometry = geometry.map(value => this.parseGeometryField(value))
|
geometry = geometry.map(value => this.parseGeometryField(value))
|
||||||
markers = geometry
|
markers = geometry
|
||||||
} else {
|
} else {
|
||||||
geometry = this.parseGeometryField(geometry)
|
geometry = this.parseGeometryField(geometry)
|
||||||
markers = [geometry]
|
markers = [geometry]
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: record.values[f.titleField],
|
title: record.values[f.titleField],
|
||||||
geometry: f.displayPolygon ? geometry : [],
|
geometry: f.displayPolygon ? geometry : [],
|
||||||
markers,
|
markers,
|
||||||
color: f.options.color,
|
color: f.options.color,
|
||||||
displayMarker: f.displayMarker,
|
displayMarker: f.displayMarker,
|
||||||
recordID: record.recordID,
|
recordID: record.recordID,
|
||||||
moduleID: record.moduleID,
|
moduleID: record.moduleID,
|
||||||
}
|
}
|
||||||
}).filter(g => g && g.markers.length)
|
}).filter(g => g && g.markers.length)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})).finally(() => {
|
})).finally(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.processing = false
|
this.processing = false
|
||||||
|
|||||||
@ -166,6 +166,7 @@ export default {
|
|||||||
if (m.moduleID) {
|
if (m.moduleID) {
|
||||||
// prepare a fresh metric with an evaluated prefilter
|
// prepare a fresh metric with an evaluated prefilter
|
||||||
const auxM = { ...m }
|
const auxM = { ...m }
|
||||||
|
|
||||||
if (auxM.filter) {
|
if (auxM.filter) {
|
||||||
auxM.filter = evaluatePrefilter(auxM.filter, {
|
auxM.filter = evaluatePrefilter(auxM.filter, {
|
||||||
record: this.record,
|
record: this.record,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user