Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/components/renderer/form-record-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,17 @@ export default {
this.currentPage = this.currentPage == 0 ? 1 : this.currentPage;
}
},
// Watch for changes in the option input field
"validationData.option": {
handler(newValue) {
// Watch for changes in validationData to handle any Mustache variable changes
validationData: {
handler(newValue, oldValue) {
if (this.source?.sourceOptions === "Collection" && this.source?.collectionFields?.pmql) {
this.onCollectionChange(
this.source?.collectionFields?.collectionId,
this.source?.collectionFields?.pmql
);
}
},
deep: true,
immediate: false
}
},
Expand Down Expand Up @@ -614,20 +615,21 @@ export default {
// Get data from validationData
const data = this.validationData || {};

// Clean up the PMQL by removing unnecessary quotes around Mustache variables
let processedPmql = pmql.replace(/"{{([^}]+)}}"/g, "{{$1}}");

// Process Mustache variables
processedPmql = Mustache.render(processedPmql, data);

// First, process all Mustache variables (both quoted and unquoted)
let processedPmql = Mustache.render(pmql, data);

// Check if the processed PMQL has empty values
if (this.hasEmptyValues(processedPmql)) {
this.collectionData = [];
return null;
}

// Add quotes around string values in PMQL if they don't have them
processedPmql = processedPmql.replace(/= ([^"'\s]+)/g, '= "$1"');
// This regex now properly handles values with spaces by looking for the end of the comparison
processedPmql = processedPmql.replace(
/= ([^"'\s][^"']*[^"'\s]|[^"'\s]+)(?=\s|$)/g,
'= "$1"'
);

return processedPmql;
} catch (error) {
Expand Down
Loading