1
0
Fork 0
This commit is contained in:
hkernbach 2016-10-18 17:44:38 +02:00
parent cb8112b15c
commit e181457fac
1 changed files with 37 additions and 0 deletions

View File

@ -1103,11 +1103,48 @@
});
this.aqlEditor.getSession().on('change', function () {
// case copy-paste: query completely selected & removed
if (self.aqlEditor.getValue().length < 1) {
if (Object.keys(self.bindParamTableObj).length > 0) {
// query is empty but bindvars are defined
self.lastCachedBindParameter = self.bindParamTableObj;
}
}
self.checkForNewBindParams();
self.renderBindParamTable();
if (self.parseQuery(self.aqlEditor.getValue()).bindParams.length > 0) {
var restoreAttr = [];
_.each(self.parseQuery(self.aqlEditor.getValue()).bindParams, function (name) {
if ($('input[name=\'' + name + '\']') !== undefined && $('input[name=\'' + name + '\']').length > 0) {
if ($('input[name=\'' + name + '\']').val().length === 0) {
if (self.lastCachedBindParameter) {
var value = $('input[name=\'' + name + '\']').val();
if (self.lastCachedBindParameter[name]) {
if (self.lastCachedBindParameter[name] !== value) {
restoreAttr.push(name);
}
}
}
}
}
});
if (restoreAttr.length > 0) {
// self.bindParamTableObj = self.lastCachedBindParameter;
var toRestore = {};
_.each(restoreAttr, function (name, val) {
toRestore[name] = self.lastCachedBindParameter[name];
});
self.bindParamTableObj = toRestore;
self.renderBindParamTable();
}
}
if (self.initDone) {
self.setCachedQuery(self.aqlEditor.getValue(), JSON.stringify(self.bindParamTableObj));
}
self.bindParamAceEditor.setValue(JSON.stringify(self.bindParamTableObj, null, '\t'), 1);
$('#aqlEditor .ace_text-input').focus();