1
0
Fork 0

Bug fix/quotation marks query editor (#4380)

This commit is contained in:
Heiko 2018-01-23 12:38:13 +01:00 committed by Jan
parent 3de120d915
commit fdc0c62dbc
2 changed files with 22 additions and 23 deletions

View File

@ -7,6 +7,9 @@ devel
superseded by other REST APIs and were partially dysfunctional. Therefore superseded by other REST APIs and were partially dysfunctional. Therefore
these two endpoints have been removed entirely. these two endpoints have been removed entirely.
* fix internal issue #81: quotation marks disappeared when switching table/json
editor in the query editor ui
* fix internal issue #1439: improve performance of any-iterator for RocksDB * fix internal issue #1439: improve performance of any-iterator for RocksDB
* added option `--rocksdb.throttle` to control whether write-throttling is enabled * added option `--rocksdb.throttle` to control whether write-throttling is enabled

View File

@ -145,6 +145,7 @@
$('#switchTypes').text('JSON'); $('#switchTypes').text('JSON');
this.renderBindParamTable(); this.renderBindParamTable();
} }
this.setCachedQuery(this.aqlEditor.getValue(), JSON.stringify(this.bindParamTableObj));
} else { } else {
arangoHelper.arangoError('Bind parameter', 'Could not parse bind parameter'); arangoHelper.arangoError('Bind parameter', 'Could not parse bind parameter');
} }
@ -592,7 +593,7 @@
var queryObject = this.getCachedQuery(); var queryObject = this.getCachedQuery();
var self = this; var self = this;
if (queryObject !== null && queryObject !== undefined && queryObject !== '') { if (queryObject !== null && queryObject !== undefined && queryObject !== '' && Object.keys(queryObject).length > 0) {
this.aqlEditor.setValue(queryObject.query, 1); this.aqlEditor.setValue(queryObject.query, 1);
var queryName = localStorage.getItem('lastOpenQuery'); var queryName = localStorage.getItem('lastOpenQuery');
@ -615,16 +616,7 @@
try { try {
// then fill values into input boxes // then fill values into input boxes
self.bindParamTableObj = JSON.parse(queryObject.parameter); self.bindParamTableObj = JSON.parse(queryObject.parameter);
self.fillBindParamTable(self.bindParamTableObj);
var key;
_.each($('#arangoBindParamTable input'), function (element) {
key = $(element).attr('name');
if (typeof self.bindParamTableObj[key] === 'object') {
$(element).val(JSON.parse(self.bindParamTableObj[key]));
} else {
$(element).val(self.bindParamTableObj[key]);
}
});
// resave cached query // resave cached query
self.setCachedQuery(self.aqlEditor.getValue(), JSON.stringify(self.bindParamTableObj)); self.setCachedQuery(self.aqlEditor.getValue(), JSON.stringify(self.bindParamTableObj));
@ -1073,17 +1065,6 @@
'</tr>' '</tr>'
); );
counter++; counter++;
/* _.each($('#arangoBindParamTable input'), function (element) {
if ($(element).attr('name') === key) {
if (val instanceof Array) {
$(element).val(JSON.stringify(val)).addClass('arraytype');
} else if (typeof val === 'object') {
$(element).val('' + JSON.stringify(val) + '').addClass(typeof val + 'type');
} else {
$(element).val(val).addClass(typeof val + 'type');
}
}
});*/
}); });
if (counter === 0) { if (counter === 0) {
$('#arangoBindParamTable tbody').append( $('#arangoBindParamTable tbody').append(
@ -1119,8 +1100,23 @@
$(element).val(JSON.stringify(val)).addClass('arraytype'); $(element).val(JSON.stringify(val)).addClass('arraytype');
} else if (typeof val === 'object') { } else if (typeof val === 'object') {
$(element).val(JSON.stringify(val)).addClass(typeof val + 'type'); $(element).val(JSON.stringify(val)).addClass(typeof val + 'type');
} else { } else if (typeof val === 'number') {
$(element).val(val).addClass(typeof val + 'type'); $(element).val(val).addClass(typeof val + 'type');
} else {
var isNumber = false;
// check if a potential string value is a number
try {
if (typeof JSON.parse(val) === 'number') {
isNumber = true;
}
} catch (ignore) {
}
if (!isNumber) {
$(element).val(val).addClass(typeof val + 'type');
} else {
$(element).val('"' + val + '"').addClass(typeof val + 'type');
}
} }
} }
}); });