From 01643d7fbaf77b7f85929c535e724b99ed99b8be Mon Sep 17 00:00:00 2001 From: jesscall <34260251+jesscall@users.noreply.github.com> Date: Mon, 18 Nov 2019 10:08:01 -0500 Subject: [PATCH] [dataquery] Fixed broken link for 'deleteAll' and fixed save error on query names that contain spaces (#5399) This addresses the issues reported in #5364 for the data query module: 1. The Delete All link in DQT was broken and not actually deselecting the fields. 2. You couldn't save a query if it had a space in the name. No error was displayed, it just wouldn't save. The code now replaces any space by underscores. Fixes #5364. --- modules/dataquery/jsx/react.app.js | 4 ++-- modules/dataquery/jsx/react.fieldselector.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/dataquery/jsx/react.app.js b/modules/dataquery/jsx/react.app.js index 9fb84aaf279..139560a62d8 100644 --- a/modules/dataquery/jsx/react.app.js +++ b/modules/dataquery/jsx/react.app.js @@ -173,7 +173,7 @@ class DataQueryApp extends Component { for (let i = 0; i < this.state.queryIDs[key].length; i += 1) { let curRequest; curRequest = Promise.resolve( - $.ajax(loris.BaseURL + '/AjaxHelper.php?Module=dataquery&script=GetDoc.php&DocID=' + this.state.queryIDs[key][i]), { + $.ajax(loris.BaseURL + '/AjaxHelper.php?Module=dataquery&script=GetDoc.php&DocID=' + encodeURIComponent(this.state.queryIDs[key][i])), { data: { DocID: this.state.queryIDs[key][i] }, @@ -472,7 +472,7 @@ class DataQueryApp extends Component { } else { // Query was saved in the new format filterState = criteria; - selectedFields = fields; + selectedFields = fields ? fields : {}; for (let instrument in fields) { for (let field in fields[instrument]) { if (field !== 'allVisits') { diff --git a/modules/dataquery/jsx/react.fieldselector.js b/modules/dataquery/jsx/react.fieldselector.js index 128f6a56364..59c6588ffd7 100644 --- a/modules/dataquery/jsx/react.fieldselector.js +++ b/modules/dataquery/jsx/react.fieldselector.js @@ -317,7 +317,7 @@ class FieldSelector extends Component { deleteAll() { // Deletes all fields the currently selected category - let i, index, fieldName; + let i, index, fieldName, category, isFile; for (i in this.state.categoryFields[this.state.selectedCategory]) { fieldName = this.state.categoryFields[this.state.selectedCategory][i].key[1]; category = this.state.categoryFields[this.state.selectedCategory][i].key[0];