Skip to content

Commit f4bd436

Browse files
author
minjk-bl
committed
Fix load and save on Instance app
1 parent 1a45660 commit f4bd436

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

js/m_apps/Instance.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ define([
3434
this.config.sizeLevel = 1;
3535

3636
this.state = {
37-
subsetEditor: undefined,
37+
vp_instanceVariable: '',
3838
variable: {
3939
stack: []
4040
},
@@ -43,6 +43,8 @@ define([
4343
...this.state
4444
}
4545
this.pointer = this.state.variable;
46+
this.subsetEditor = null;
47+
this.insEditor = null;
4648

4749
this._addCodemirror('vp_instanceVariable', this.wrapSelector('#vp_instanceVariable'), 'readonly');
4850
}
@@ -173,7 +175,9 @@ define([
173175
}
174176

175177
templateForBody() {
176-
return insHtml;
178+
let page = $(insHtml);
179+
$(page).find('#vp_instanceVariable').val(this.state.vp_instanceVariable);
180+
return page;
177181
}
178182

179183
render() {
@@ -182,25 +186,25 @@ define([
182186
let that = this;
183187

184188
// vpSubsetEditor
185-
this.state.subsetEditor = new Subset({ pandasObject: '', config: { name: 'Subset' } },
189+
this.subsetEditor = new Subset({ pandasObject: '', config: { name: 'Subset' } },
186190
{
187191
useInputVariable: true,
188192
targetSelector: this.wrapSelector('#vp_instanceVariable'),
189193
pageThis: this,
190194
finish: function(code) {
191195
that.addStack();
192-
that.state.subsetEditor.state.pandasObject = code;
196+
that.subsetEditor.state.pandasObject = code;
193197
that.updateValue(code);
194198
}
195199
});
196-
this.state.subsetEditor.disableButton();
200+
this.subsetEditor.disableButton();
197201

198-
this.ALLOW_SUBSET_TYPES = this.state.subsetEditor.getAllowSubsetTypes();
202+
this.ALLOW_SUBSET_TYPES = this.subsetEditor.getAllowSubsetTypes();
199203

200204
// vpInstanceEditor
201-
this.state.variable.insEditor = new InstanceEditor(this, "vp_instanceVariable", 'vp_variableInsEditContainer');
205+
this.insEditor = new InstanceEditor(this, "vp_instanceVariable", 'vp_variableInsEditContainer');
202206

203-
this.state.variable.insEditor.show();
207+
this.insEditor.show();
204208

205209
// variable load
206210
this.reloadInsEditor();
@@ -232,17 +236,17 @@ define([
232236

233237
hide() {
234238
super.hide();
235-
this.state.subsetEditor && this.state.subsetEditor.hide();
239+
this.subsetEditor && this.subsetEditor.hide();
236240
}
237241

238242
close() {
239243
super.close();
240-
this.state.subsetEditor && this.state.subsetEditor.close();
244+
this.subsetEditor && this.subsetEditor.close();
241245
}
242246

243247
remove() {
244248
super.remove();
245-
this.state.subsetEditor && this.state.subsetEditor.remove();
249+
this.subsetEditor && this.subsetEditor.remove();
246250
}
247251

248252
updateValue(value) {
@@ -254,6 +258,7 @@ define([
254258
cm.focus();
255259
cm.setCursor({ line: 0, ch: value.length});
256260
}
261+
this.state.vp_instanceVariable = value;
257262
}
258263

259264
addStack() {
@@ -287,22 +292,17 @@ define([
287292
var varType = varObj.type;
288293

289294
if (that.ALLOW_SUBSET_TYPES.includes(varType)) {
290-
that.state.subsetEditor.state.dataType = varType;
295+
that.subsetEditor.state.dataType = varType;
291296
let cmObj = that.getCodemirror('vp_instanceVariable');
292297
let nowCode = (cmObj && cmObj.cm)?cmObj.cm.getValue():'';
293-
that.state.subsetEditor.state.pandasObject = nowCode;
294-
that.state.subsetEditor.enableButton();
298+
that.subsetEditor.state.pandasObject = nowCode;
299+
that.subsetEditor.enableButton();
295300
} else {
296-
that.state.subsetEditor.disableButton();
301+
that.subsetEditor.disableButton();
297302
}
298303
};
299304

300-
if (type == '') {
301-
this.pointer.insEditor.reload(callbackFunction);
302-
} else {
303-
tempPointer = this.state[type];
304-
this.state[type].insEditor.reload(callbackFunction);
305-
}
305+
this.insEditor.reload(callbackFunction);
306306
}
307307
}
308308

0 commit comments

Comments
 (0)