Skip to content

Commit 653b700

Browse files
author
minjk-bl
committed
Apps > Instance - Allocate variable to simple input
1 parent 36e2a58 commit 653b700

File tree

4 files changed

+27
-78
lines changed

4 files changed

+27
-78
lines changed

css/file_io/instance.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
grid-column: 1/2;
2525
font-weight: 700;
2626
margin: 0px;
27+
28+
line-height: 30px;
29+
vertical-align: middle;
2730
}
2831
.vp-instance-box {
2932
grid-column-start: 1;
@@ -37,10 +40,7 @@
3740
}
3841
.vp-ins-container.variable {
3942
grid-column: 1/3;
40-
}
41-
42-
.vp-ins-container.allocate {
43-
grid-column: 1/3;
43+
height: 250px;
4444
}
4545

4646
/* UDF Editor - CodeMirror */

src/api_block/constData.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ define([
762762
},
763763
'instance': {
764764
file: '/nbextensions/visualpython/src/file_io/instance.js',
765-
config: { title: 'Instance' }
765+
config: { title: 'Instance', width: '500px', height: '500px' }
766766
},
767767
'subset': {
768768
file: 'nbextensions/visualpython/src/common/vpSubsetEditor',

src/file_io/instance.html

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<div class="vp-option-page" id="vp_instance">
22
<div class="vp-instance-base cm-s-ipython">
3-
<!-- <div class="vp-instance-toolbar">
4-
<input type="hidden" id="vp_stateLeft"/>
5-
<input type="hidden" id="vp_stateRight"/>
6-
<input type="button" id="vp_instanceClear" class="vp-toolbar-button" value="Clear"/>
7-
<input type="button" id="vp_instanceUndo" class="vp-toolbar-button" value="Undo"/>
8-
</div> -->
93
<label for="vp_instanceVariable" class="vp-instance-label variable">Variable</label>
104
<div class="vp-instance-box variable">
115
<textarea id="vp_instanceVariable" name="code"></textarea>
@@ -17,11 +11,6 @@
1711
<hr style="margin: 0px;"/>
1812

1913
<label for="vp_instanceAllocate" class="vp-instance-label allocate">Allocate to</label>
20-
<div class="vp-instance-box allocate">
21-
<textarea id="vp_instanceAllocate" name="code"></textarea>
22-
</div>
23-
<div class="vp-ins-container allocate" id="vp_allocateInsEditContainer">
24-
<!-- vpInstanceEditor -->
25-
</div>
14+
<input type="text" id="vp_instanceAllocate" placeholder="Variable name"/>
2615
</div>
2716
</div>

src/file_io/instance.js

Lines changed: 21 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Project Name : Visual Python
3+
* Description : GUI-based Python code generator
4+
* File Name : instance.js
5+
* Author : Black Logic
6+
* Note : Instance app
7+
* License : GNU GPLv3 with Visual Python special exception
8+
* Date : 2021. 10. 05
9+
* Change Date :
10+
*/
11+
112
define([
213
'require'
314
, 'jquery'
@@ -80,22 +91,6 @@ define([
8091

8192
// 옵션 속성 할당.
8293
varPackage.setOptionProp(funcOptProp);
83-
84-
// load metadata
85-
// if (meta != undefined && meta.options != undefined) {
86-
// try {
87-
// var leftMeta = decodeURIComponent(meta.options[0].value);
88-
// var rightMeta = decodeURIComponent(meta.options[1].value);
89-
90-
// var leftBlocks = JSON.parse(leftMeta);
91-
// var rightBlocks = JSON.parse(rightMeta);
92-
93-
// varPackage.state.left.board.loadBoard(leftBlocks);
94-
// varPackage.state.right.board.loadBoard(rightBlocks);
95-
// } catch {
96-
// ;
97-
// }
98-
// }
9994

10095
// html 설정.
10196
varPackage.initHtml();
@@ -129,11 +124,6 @@ define([
129124
subsetEditor: undefined,
130125
codeEditor: undefined,
131126
stack: []
132-
}
133-
, allocate: {
134-
subsetEditor: undefined,
135-
codeEditor: undefined,
136-
stack: []
137127
},
138128
selectedBox: 'variable'
139129
}
@@ -189,31 +179,32 @@ define([
189179
$('.vp-instance-box.variable .CodeMirror').addClass('selected');
190180

191181
// allocate - codemirror
192-
this.state.allocate.codeEditor = CodeMirror.fromTextArea($(this.wrapSelector('#vp_instanceAllocate'))[0], this.cmconfig);
193-
this.updateValue('allocate', '');
182+
// this.state.allocate.codeEditor = CodeMirror.fromTextArea($(this.wrapSelector('#vp_instanceAllocate'))[0], this.cmconfig);
183+
// this.updateValue('allocate', '');
194184

195185
// load metadata
196186
var variable = this.getMetadata('vp_instanceVariable');
197187
var allocate = this.getMetadata('vp_instanceAllocate');
198188
this.updateValue('variable', variable);
199-
this.updateValue('allocate', allocate);
189+
$(this.wrapSelector('#vp_instanceAllocate')).val(allocate);
190+
// this.updateValue('allocate', allocate);
200191

201192
// vpSubsetEditor
202193
this.state.variable.subsetEditor = new vpSubsetEditor(this, "vp_instanceVariable", true);
203-
this.state.allocate.subsetEditor = new vpSubsetEditor(this, "vp_instanceAllocate", true);
194+
// this.state.allocate.subsetEditor = new vpSubsetEditor(this, "vp_instanceAllocate", true);
204195
this.state.variable.subsetEditor.disableButton();
205-
this.state.allocate.subsetEditor.disableButton();
196+
// this.state.allocate.subsetEditor.disableButton();
206197

207198
this.ALLOW_SUBSET_TYPES = that.pointer.subsetEditor.getAllowSubsetTypes();
208199

209200
// vpInstanceEditor
210201
this.state.variable.insEditor = new vpInstanceEditor(this, "vp_instanceVariable", 'vp_variableInsEditContainer');
211202

212203
// vpInstanceEditor
213-
this.state.allocate.insEditor = new vpInstanceEditor(this, "vp_instanceAllocate", 'vp_allocateInsEditContainer');
204+
// this.state.allocate.insEditor = new vpInstanceEditor(this, "vp_instanceAllocate", 'vp_allocateInsEditContainer');
214205

215206
that.state.variable.insEditor.show();
216-
that.state.allocate.insEditor.show();
207+
// that.state.allocate.insEditor.show();
217208

218209
// variable load
219210
that.reloadInsEditor();
@@ -253,14 +244,10 @@ define([
253244
$(that.wrapSelector('.CodeMirror')).removeClass('selected');
254245
if (insEditorType == 'variable') {
255246
// variable
256-
// that.state.variable.insEditor.show();
257-
// that.state.allocate.insEditor.hide();
258247
that.pointer = that.state.variable;
259248
$(that.wrapSelector('.variable .CodeMirror')).addClass('selected');
260249
} else if (insEditorType == 'allocate'){
261250
// allocate
262-
// that.state.variable.insEditor.hide();
263-
// that.state.allocate.insEditor.show();
264251
that.pointer = that.state.allocate;
265252
$(that.wrapSelector('.allocate .CodeMirror')).addClass('selected');
266253
} else {
@@ -293,20 +280,14 @@ define([
293280

294281
if (insEditorType == 'variable') {
295282
// variable
296-
// that.state.variable.insEditor.show();
297-
// that.state.allocate.insEditor.hide();
298283
that.state.selectedBox = 'variable';
299284
that.pointer = that.state.variable;
300285
} else if (insEditorType == 'allocate'){
301286
// allocate
302-
// that.state.variable.insEditor.hide();
303-
// that.state.allocate.insEditor.show();
304287
that.state.selectedBox = 'allocate';
305288
that.pointer = that.state.allocate;
306289
} else {
307290
that.state.selectedBox = '';
308-
// that.state.variable.insEditor.hide();
309-
// that.state.allocate.insEditor.hide();
310291
}
311292
});
312293

@@ -327,19 +308,6 @@ define([
327308
that.reloadInsEditor('variable');
328309
});
329310

330-
// instance_editor_selected - allocate
331-
$(document).on('instance_editor_selected', this.wrapSelector('#vp_instanceAllocate'), function(event) {
332-
that.addStack();
333-
334-
var nowCode = that.state.allocate.codeEditor.getValue();
335-
if (nowCode != '') {
336-
nowCode += '.'
337-
}
338-
var selectedVariable = event.varName;
339-
that.updateValue('allocate', nowCode + selectedVariable);
340-
that.reloadInsEditor('allocate');
341-
});
342-
343311
// instance_editor_replaced - variable
344312
$(document).on('instance_editor_replaced', this.wrapSelector('#vp_instanceVariable'), function(event) {
345313
that.addStack();
@@ -348,15 +316,6 @@ define([
348316
that.updateValue('variable', newCode);
349317
that.reloadInsEditor('variable');
350318
});
351-
352-
// instance_editor_replaced - allocate
353-
$(document).on('instance_editor_replaced', this.wrapSelector('#vp_instanceAllocate'), function(event) {
354-
that.addStack();
355-
356-
var newCode = event.newCode;
357-
that.updateValue('allocate', newCode);
358-
that.reloadInsEditor('allocate');
359-
});
360319
}
361320

362321
VariablePackage.prototype.updateValue = function(type, value) {
@@ -421,7 +380,8 @@ define([
421380
var sbCode = new sb.StringBuilder();
422381

423382
// 변수 내용 조회
424-
var leftCode = this.state.allocate.codeEditor.getValue();
383+
// var leftCode = this.state.allocate.codeEditor.getValue();
384+
var leftCode = $(this.wrapSelector('#vp_instanceAllocate')).val();
425385
var rightCode = this.state.variable.codeEditor.getValue();
426386
if (leftCode && leftCode != '') {
427387
sbCode.appendFormat('{0} = {1}', leftCode, rightCode);

0 commit comments

Comments
 (0)