Skip to content

Commit 00ee8e5

Browse files
author
minjk-bl
committed
Edit Instance app to support more libraries option
1 parent 035ade7 commit 00ee8e5

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

visualpython/html/m_apps/instance.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div class="vp-bold">
2222
<span class="vp-instance-preview-title">Instance Preview</span>
2323
</div>
24-
<div class="vp-instance-preview-box vp-grid-border-box">
24+
<div class="vp-instance-preview-box vp-grid-border-box vp-scrollbar">
2525
<div id="instancePreview" class="vp-instance-preview-content rendered_html vp-center"></div>
2626
</div>
2727
</div>

visualpython/js/com/com_generatorV2.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,13 @@ define([
785785
if (code.startsWith(' = ')) {
786786
code = code.substr(3);
787787
}
788+
// prevent code: without allocation code (${o0} = code)
789+
let outputCodeMatch = code.match(/^\$\{.+\} = /);
790+
if (outputCodeMatch) {
791+
let matchLength = outputCodeMatch[0].length;
792+
let matchStartIdx = outputCodeMatch['index'];
793+
code = code.substr(matchStartIdx + matchLength);
794+
}
788795
// show_result
789796
// get output variables
790797
if (_VP_SHOW_RESULT && package.options) {

visualpython/js/com/component/InstanceEditor.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ define([
338338

339339
var varType = varObj.type;
340340
var varList = varObj.list;
341+
var prevVarType = that.state.type;
341342

342343
that.state.type = varType;
343344
that.state.list = varList;
@@ -437,22 +438,24 @@ define([
437438
// get target code
438439
var methodName = lastSplit.match(/[a-zA-Z_]+/i)[0];
439440
var targetCode = splitList.slice(0, splitList.length - 1).join('.');
440-
if ((varType in instanceLibrary.INSTANCE_MATCHING_LIBRARY) && (methodName in instanceLibrary.INSTANCE_MATCHING_LIBRARY[varType])) {
441+
if ((prevVarType in instanceLibrary.INSTANCE_MATCHING_LIBRARY) && (methodName in instanceLibrary.INSTANCE_MATCHING_LIBRARY[prevVarType])) {
441442
// get target library
442-
var targetLib = instanceLibrary.INSTANCE_MATCHING_LIBRARY[varType][methodName];
443+
var targetLib = instanceLibrary.INSTANCE_MATCHING_LIBRARY[prevVarType][methodName];
443444
var targetId = targetLib.target;
444445
that.optionPopup = new LibraryComponent({
445446
[targetId]: targetCode,
446447
config: {
447448
name: methodName, category: 'Instance',
449+
id: targetLib.id,
448450
saveOnly: true,
449-
id: targetLib.id
451+
noOutput: true
450452
}
451453
},
452454
{
453455
pageThis: that,
454456
useInputVariable: true,
455457
targetSelector: that.pageThis.wrapSelector('#' + that.targetId),
458+
456459
finish: function(code) {
457460
// TODO: save state
458461

@@ -475,7 +478,7 @@ define([
475478
// remove first/last brackets
476479
var parameter = lastBracket.substr(1, lastBracket.length - 2);
477480
$(that.wrapSelector('.' + VP_INS_PARAMETER)).val(parameter);
478-
$(that.wrapSelector('.' + VP_INS_PARAMETER)).show();
481+
$(that.wrapSelector('.' + VP_INS_PARAMETER)).prop('disabled', false);
479482
if (hasOption) {
480483
if ($(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
481484
$(that.wrapSelector('.vp-ins-opt-button')).removeClass('disabled');
@@ -487,13 +490,13 @@ define([
487490
}
488491
} else {
489492
$(that.wrapSelector('.' + VP_INS_PARAMETER)).val('');
490-
$(that.wrapSelector('.' + VP_INS_PARAMETER)).hide();
493+
$(that.wrapSelector('.' + VP_INS_PARAMETER)).prop('disabled', true);
491494
if (!$(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
492495
$(that.wrapSelector('.vp-ins-opt-button')).addClass('disabled');
493496
}
494497
}
495498
} else {
496-
$(that.wrapSelector('.' + VP_INS_PARAMETER)).hide();
499+
$(that.wrapSelector('.' + VP_INS_PARAMETER)).prop('disabled', true);
497500
if (!$(that.wrapSelector('.vp-ins-opt-button')).hasClass('disabled')) {
498501
$(that.wrapSelector('.vp-ins-opt-button')).addClass('disabled');
499502
}

visualpython/js/com/component/LibraryComponent.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ define([
132132

133133
// show interface
134134
// com_generator.vp_showInterfaceOnPage(this.wrapSelector(), this.package);
135+
if (this.config.noOutput && this.config.noOutput === true) {
136+
// no allocateTo
137+
this.package.options = this.package.options.filter(x => x.output != true);
138+
}
135139
com_generatorV2.vp_showInterfaceOnPage(this, this.package, this.state);
136140

137141
// hide required page if no options

0 commit comments

Comments
 (0)