Skip to content

Commit 2a5b42e

Browse files
author
minjk-bl
committed
FitPredict & ModelInfo - select first item as default
1 parent 5d3e539 commit 2a5b42e

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

js/m_ml/FitPredict.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ define([
152152
super.render();
153153

154154
this.loadModelList(this.state.category);
155-
156-
this.reload();
157155
}
158156

159157
loadModelList(category='') {
@@ -173,17 +171,21 @@ define([
173171
vpKernel.getModelList(category).then(function(resultObj) {
174172
let { result } = resultObj;
175173
var modelList = JSON.parse(result);
176-
modelList && modelList.forEach(model => {
174+
modelList && modelList.forEach((model, idx) => {
177175
let selectFlag = '';
178-
if (model.varName == that.state.model) {
176+
// if this item is pre-selected model or first item of model list
177+
if ((model.varName == that.state.model)
178+
|| (that.state.model == '' && idx == 0)) {
179179
selectFlag = 'selected';
180+
that.state.model = model.varName;
181+
that.state.modelType = model.varType;
180182
}
181183
modelOptionTag.appendFormatLine('<li class="{0} {1}" data-var-name="{2}" data-var-type="{3}" title="{4}">{5} ({6})</li>',
182184
'vp-ins-select-item', selectFlag, model.varName, model.varType, model.varName, model.varName, model.varType);
183185
});
184186
$(that.wrapSelector('.vp-ins-select-list.model')).html(modelOptionTag.toString());
185187

186-
// click model
188+
// click model event
187189
$(that.wrapSelector('.vp-ins-select-list.model .vp-ins-select-item')).on('click', function() {
188190
let model = $(this).data('var-name');
189191
let modelType = $(this).data('var-type');
@@ -196,9 +198,14 @@ define([
196198

197199
that.reload();
198200
});
201+
202+
that.reload();
199203
});
200204
}
201205

206+
/**
207+
* Load options for selected model
208+
*/
202209
reload() {
203210
// reset option page
204211
try {

js/m_ml/ModelInfo.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ define([
152152
super.render();
153153

154154
this.loadModelList(this.state.category);
155-
156-
this.reload();
157155
}
158156

159157
loadModelList(category='') {
@@ -175,15 +173,19 @@ define([
175173
var modelList = JSON.parse(result);
176174
modelList && modelList.forEach(model => {
177175
let selectFlag = '';
178-
if (model.varName == that.state.model) {
176+
// if this item is pre-selected model or first item of model list
177+
if ((model.varName == that.state.model)
178+
|| (that.state.model == '' && idx == 0)) {
179179
selectFlag = 'selected';
180+
that.state.model = model.varName;
181+
that.state.modelType = model.varType;
180182
}
181183
modelOptionTag.appendFormatLine('<li class="{0} {1}" data-var-name="{2}" data-var-type="{3}" title="{4}">{5} ({6})</li>',
182184
'vp-ins-select-item', selectFlag, model.varName, model.varType, model.varName, model.varName, model.varType);
183185
});
184186
$(that.wrapSelector('.vp-ins-select-list.model')).html(modelOptionTag.toString());
185187

186-
// click model
188+
// click model event
187189
$(that.wrapSelector('.vp-ins-select-list.model .vp-ins-select-item')).on('click', function() {
188190
let model = $(this).data('var-name');
189191
let modelType = $(this).data('var-type');
@@ -196,9 +198,14 @@ define([
196198

197199
that.reload();
198200
});
201+
202+
that.reload();
199203
});
200204
}
201205

206+
/**
207+
* Load options for selected model
208+
*/
202209
reload() {
203210
// reset option page
204211
try {

0 commit comments

Comments
 (0)