Skip to content

Commit 83a17e9

Browse files
author
minjk-bl
committed
Variable add default selection
1 parent 2a85c47 commit 83a17e9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

js/m_apps/Variable.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,23 @@ define([
9393

9494
// HTML rendering
9595
vpKernel.getDataList(types).then(function(resultObj) {
96-
// var jsonVars = result.replace(/'/gi, `"`);
97-
// var varList = JSON.parse(jsonVars);
9896
let varListStr = resultObj.result;
9997
var varList = JSON.parse(varListStr);
10098

10199
// add variable list in table
102-
varList.forEach(varObj => {
100+
varList.forEach((varObj, idx) => {
103101
if (types.includes(varObj.varType) && varObj.varName[0] !== '_') {
102+
let selected = false;
103+
if ((that.state.variable == varObj.varName)) {
104+
selected = true;
105+
}
104106
var tagTr = document.createElement('tr');
105107
var tagTdName = document.createElement('td');
106108
var tagTdType = document.createElement('td');
107109
$(tagTr).attr({
108110
'data-var-name': varObj.varName,
109111
'data-var-type': varObj.varType,
110-
'class': that.state.variable == varObj.varName?'vp-selected':''
112+
'class': selected?'vp-selected':''
111113
});
112114
tagTdName.innerText = varObj.varName;
113115
tagTdType.innerText = varObj.varType;
@@ -151,6 +153,10 @@ define([
151153
}
152154
});
153155

156+
if ($(that.wrapSelector('.vp-selected')).length == 0) {
157+
$(that.wrapSelector('#vp_var_variableBox tbody tr:nth(0)')).addClass('vp-selected');
158+
}
159+
154160
// trigger click of selected variable
155161
$(that.wrapSelector('.vp-selected')).click();
156162
});

0 commit comments

Comments
 (0)