Skip to content

Commit

Permalink
fix data queries not inserting when data_sources is null
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnub committed Aug 9, 2023
1 parent fc1e1d0 commit 9ee197d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ee/reporting/components/EditorToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ function insertDataQuery() {
component: DataQuerySelect,
}).onOk((queryName: string) => {
let variablesJson = parse(props.variablesEditor.getValue()) || {};

if (!("data_sources" in variablesJson)) {
if (!("data_sources" in variablesJson) || !variablesJson.data_sources) {
variablesJson["data_sources"] = {};
}
variablesJson["data_sources"][convertCamelCase(queryName)] = queryName;
Expand All @@ -387,7 +386,7 @@ function openChartDialog() {
let variablesJson = parse(props.variablesEditor.getValue()) || {};
const optionsJson = parse(data.options);

if (!("charts" in variablesJson)) {
if (!("charts" in variablesJson) || !variablesJson.charts) {
variablesJson["charts"] = {};
}

Expand All @@ -407,7 +406,7 @@ function openQueryAddDialog() {
}).onOk((queryName: string) => {
let variablesJson = parse(props.variablesEditor.getValue()) || {};

if (!("data_sources" in variablesJson)) {
if (!("data_sources" in variablesJson) || !variablesJson.data_sources) {
variablesJson["data_sources"] = {};
}
variablesJson["data_sources"][convertCamelCase(queryName)] = queryName;
Expand Down
1 change: 1 addition & 0 deletions src/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export function convertFromBitArray(array) {

export function convertCamelCase(str) {
return str
.replace(/[^a-zA-Z0-9]+/g, " ")
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
return index == 0 ? word.toLowerCase() : word.toUpperCase();
})
Expand Down

0 comments on commit 9ee197d

Please sign in to comment.