Skip to content

Commit 690795f

Browse files
committed
block menu - add menu added
1 parent f5012a4 commit 690795f

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/api_block/block.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,7 @@ define([
24682468

24692469

24702470
/** this Block 부터 코드 실행 */
2471-
Block.prototype.runThisBlock = function() {
2471+
Block.prototype.runThisBlock = function(runCell=true) {
24722472
var thisBlock = this;
24732473
var blockContainerThis = thisBlock.getBlockContainerThis();
24742474

@@ -2493,7 +2493,7 @@ define([
24932493
return;
24942494
}
24952495
blockContainerThis.setAPIBlockCode(code);
2496-
blockContainerThis.generateCode(true);
2496+
blockContainerThis.generateCode(true, runCell);
24972497
}
24982498

24992499

src/api_block/blockContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,9 +2180,9 @@ define([
21802180
/** importPackage의 generateCode 이전에 실행할 prefix code
21812181
* @param {boolean} isClicked true면 node 블럭 앞 run 버튼 클릭으로 코드 실행
21822182
*/
2183-
BlockContainer.prototype.generateCode = function(isClicked) {
2183+
BlockContainer.prototype.generateCode = function(isClicked, runCell=true) {
21842184
var importPackageThis = this.getImportPackageThis();
2185-
importPackageThis.generateCode(true, true, isClicked);
2185+
importPackageThis.generateCode(true, runCell, isClicked);
21862186
}
21872187

21882188
/** 코드 생성 */

src/api_block/component/blockMenu.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ define([
1919

2020
, VP_ID_APIBLOCK_MENU_BOX
2121
, VP_ID_APIBLOCK_MENU_RUN
22+
, VP_ID_APIBLOCK_MENU_ADD
2223
, VP_ID_APIBLOCK_MENU_DUPLICATE
2324
, VP_ID_APIBLOCK_MENU_DELETE
2425

@@ -51,6 +52,9 @@ define([
5152
// run button
5253
sbBlockMenu.appendFormatLine('<div id="{0}" class="{1}">{2}</div>'
5354
, VP_ID_APIBLOCK_MENU_RUN, VP_CLASS_APIBLOCK_MENU_ITEM, 'Run');
55+
// add button
56+
sbBlockMenu.appendFormatLine('<div id="{0}" class="{1}">{2}</div>'
57+
, VP_ID_APIBLOCK_MENU_ADD, VP_CLASS_APIBLOCK_MENU_ITEM, 'Add');
5458
// duplicate button
5559
sbBlockMenu.appendFormatLine('<div id="{0}" class="{1}">{2}</div>'
5660
, VP_ID_APIBLOCK_MENU_DUPLICATE, VP_CLASS_APIBLOCK_MENU_ITEM, 'Duplicate');
@@ -92,11 +96,16 @@ define([
9296
that.block.runThisBlock();
9397
that.close();
9498
});
99+
/** add block */
100+
$(document).off(STR_CLICK, this.wrapSelector(VP_ID_PREFIX + VP_ID_APIBLOCK_MENU_ADD));
101+
$(document).on(STR_CLICK, this.wrapSelector(VP_ID_PREFIX + VP_ID_APIBLOCK_MENU_ADD), function() {
102+
that.block.runThisBlock(false);
103+
that.close();
104+
});
95105
/** duplicate block */
96106
$(document).off(STR_CLICK, this.wrapSelector(VP_ID_PREFIX + VP_ID_APIBLOCK_MENU_DUPLICATE));
97107
$(document).on(STR_CLICK, this.wrapSelector(VP_ID_PREFIX + VP_ID_APIBLOCK_MENU_DUPLICATE), function() {
98-
// TODO: duplicate block
99-
108+
// duplicate block
100109
var blockContainer = that.block.getBlockContainerThis();
101110

102111
// blockContainer.setCtrlSaveData();

src/api_block/constData.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ define([
354354

355355
const VP_ID_APIBLOCK_MENU_BOX = 'vp_apiblock_menubox';
356356
const VP_ID_APIBLOCK_MENU_RUN = 'vp_apiblock_menu_run';
357+
const VP_ID_APIBLOCK_MENU_ADD = 'vp_apiblock_menu_add';
357358
const VP_ID_APIBLOCK_MENU_DUPLICATE = 'vp_apiblock_menu_duplicate';
358359
const VP_ID_APIBLOCK_MENU_DELETE = 'vp_apiblock_menu_delete';
359360

@@ -933,6 +934,7 @@ define([
933934

934935
, VP_ID_APIBLOCK_MENU_BOX
935936
, VP_ID_APIBLOCK_MENU_RUN
937+
, VP_ID_APIBLOCK_MENU_ADD
936938
, VP_ID_APIBLOCK_MENU_DUPLICATE
937939
, VP_ID_APIBLOCK_MENU_DELETE
938940

0 commit comments

Comments
 (0)