Skip to content

Commit be42fff

Browse files
author
minjk-bl
committed
Change Code sign
1 parent 5c4d182 commit be42fff

File tree

7 files changed

+65
-21
lines changed

7 files changed

+65
-21
lines changed

js/board/Block.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ define([
296296
get name() {
297297
return this.task.name;
298298
}
299+
get menuGroup() {
300+
let groupCode = this._getMenuGroupRootType();
301+
let groupLabel = vpConfig.getMenuGroupLabel(groupCode);
302+
if (groupLabel == undefined || groupLabel === '') {
303+
return groupCode;
304+
}
305+
return groupLabel;
306+
}
299307
get blockType() {
300308
return this.getColorLabel();
301309
}
@@ -330,6 +338,9 @@ define([
330338
get popup() {
331339
return this.task;
332340
}
341+
get sigText() {
342+
return this.menuGroup + ' > ' + this.name;
343+
}
333344
canMakeChild() {
334345
let innerList = [
335346
'lgDef_class', 'lgDef_def',

js/board/BlockMenu.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ define([
7373
// if markdown, add #
7474
groupCode = '#' + groupCode.replaceAll('\n', '\n# ');
7575
}
76-
overallCode.appendFormatLine('# VisualPython [{0}]{1}', that.block.blockNumber,
77-
that.block.id == 'apps_markdown'? ' - Markdown':'');
76+
overallCode.appendFormatLine('# Visual Python: {0} > {1}', that.block.name, that.block.name);
7877
overallCode.append(groupCode);
7978

8079
// open codeview

js/board/BoardFrame.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,10 @@ define([
598598
}
599599
if (addcell) {
600600
// insert single cell using prev code
601-
com_interface.insertCell('code', code.toString(), execute, block.blockNumber);
601+
com_interface.insertCell('code', code.toString(), execute, block.sigText);
602602
code = new com_String();
603603
// insert cells using this block code list
604-
com_interface.insertCells('code', thisBlockCode, execute, block.blockNumber);
604+
com_interface.insertCells('code', thisBlockCode, execute, block.sigText);
605605
}
606606
} else {
607607
// set indent to every line of thisblockcode
@@ -610,7 +610,7 @@ define([
610610
}
611611
});
612612
if (addcell) {
613-
com_interface.insertCell('code', code.toString(), execute, block.blockNumber);
613+
com_interface.insertCell('code', code.toString(), execute, block.sigText);
614614
}
615615
return code.toString();
616616
}
@@ -636,7 +636,7 @@ define([
636636
// if markdown, add #
637637
groupCode = '#' + groupCode.replaceAll('\n', '\n# ');
638638
}
639-
overallCode.appendFormatLine('# VisualPython [{0}]{1}', block.blockNumber,
639+
overallCode.appendFormatLine('# Visual Python: {0} > {1}', block.name, block.name,
640640
block.id == 'apps_markdown'? ' - Markdown':'');
641641
overallCode.append(groupCode);
642642
}

js/com/com_Config.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,14 @@ define([
437437
})
438438
}
439439

440+
getMenuGroupLabel(key = '') {
441+
return Config.MENU_GROUP_DICT[key];
442+
}
443+
444+
getMenuGroupDict() {
445+
return Config.MENU_GROUP_DICT;
446+
}
447+
440448
getDataTypes() {
441449
return Config.DATA_TYPES;
442450
}
@@ -485,7 +493,18 @@ define([
485493
Config.BOARD_MIN_WIDTH = 263;
486494
Config.MENU_BOARD_SPACING = 5;
487495
Config.VP_MIN_WIDTH = Config.MENU_MIN_WIDTH + Config.BOARD_MIN_WIDTH + Config.MENU_BOARD_SPACING; // = MENU_MIN_WIDTH + BOARD_MIN_WIDTH + MENU_BOARD_SPACING
488-
496+
497+
/**
498+
* Menu group codes
499+
*/
500+
Config.MENU_GROUP_DICT = {
501+
'': '',
502+
'logic': 'Logic',
503+
'library': 'Library',
504+
'apps': 'Data Analysis',
505+
'visualization': 'Visualization',
506+
'machine_learning': 'Machine Learning'
507+
}
489508
/**
490509
* Data types
491510
*/

js/com/com_interface.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ define([
2424
* @param {boolean} exec true(default) / false
2525
* @param {int} sigNum
2626
*/
27-
var insertCell = function(type, command, exec=true, sigNum=-1) {
27+
var insertCell = function(type, command, exec=true, sigText='') {
2828
var selectedIndex = getSelectedCell();
2929
var targetCell = Jupyter.notebook.insert_cell_below(type, selectedIndex);
3030

3131
// Add signature
3232
if (type == 'code') {
33-
if (sigNum >= 0) {
34-
command = com_util.formatString('# VisualPython [{0}]\n', sigNum) + command;
33+
if (sigText !== '') {
34+
command = com_util.formatString('# Visual Python: {0}\n', sigText) + command;
3535
} else {
36-
command = '# VisualPython\n' + command;
36+
command = '# Visual Python\n' + command;
3737
}
3838
}
3939
targetCell.set_text(command);
@@ -61,14 +61,18 @@ define([
6161
* @param {boolean} exec
6262
* @param {int} sigNum
6363
*/
64-
var insertCells = function(type, commands, exec=true, sigNum=-1) {
64+
var insertCells = function(type, commands, exec=true, sigText='') {
6565
var selectedIndex = getSelectedCell();
6666
var targetCell = Jupyter.notebook.insert_cell_below(type, selectedIndex);
6767

6868
commands && commands.forEach((command, idx) => {
6969
// Add signature
70-
if (type == 'code' && sigNum >= 0) {
71-
command = com_util.formatString('# VisualPython [{0}] - {1}\n', sigNum, idx + 1) + command
70+
if (type == 'code') {
71+
if (sigText !== '') {
72+
command = com_util.formatString('# Visual Python: {0}\n', sigText) + command;
73+
} else {
74+
command = com_util.formatString('# Visual Python') + command;
75+
}
7276
}
7377
targetCell.set_text(command);
7478
Jupyter.notebook.select_next();

js/com/component/PopupComponent.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ define([
4949
this.id = this.state.config.id;
5050
this.name = this.state.config.name;
5151
this.path = this.state.config.path;
52+
5253

5354
this.config = {
5455
sizeLevel: 0, // 0: 400x400 / 1: 500x500 / 2: 600x500 / 3: 750x500
@@ -683,18 +684,28 @@ define([
683684
run(execute=true, addcell=true) {
684685
let code = this.generateCode();
685686
let mode = this.config.executeMode;
686-
let blockNumber = -1;
687+
let sigText = '';
687688
// check if it's block
688689
if (this.getTaskType() == 'block') {
689690
let block = this.taskItem;
690-
blockNumber = block.blockNumber;
691+
sigText = block.sigText;
692+
} else {
693+
try {
694+
let menuGroup = this.path.split(' - ')[1];
695+
let menuGroupLabel = vpConfig.getMenuGroupLabel(menuGroup);
696+
if (menuGroupLabel != undefined && menuGroupLabel !== '') {
697+
sigText = menuGroupLabel + ' > ' + this.name;
698+
} else {
699+
sigText = this.name;
700+
}
701+
} catch {}
691702
}
692703
if (addcell) {
693704
if (Array.isArray(code)) {
694705
// insert cells if it's array of codes
695-
com_interface.insertCells(mode, code, execute, blockNumber);
706+
com_interface.insertCells(mode, code, execute, sigText);
696707
} else {
697-
com_interface.insertCell(mode, code, execute, blockNumber);
708+
com_interface.insertCell(mode, code, execute, sigText);
698709
}
699710
}
700711
return code;

js/m_apps/Profiling.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ define([
7676
code.append(saveas);
7777
break;
7878
}
79-
com_interface.insertCell('code', code.toString());
79+
com_interface.insertCell('code', code.toString(), 'Data Analysis > Profiling');
8080
that.loadReportList();
8181
});
8282
}
@@ -113,7 +113,7 @@ define([
113113
}
114114
var code = new com_String();
115115
code.appendFormat("{0}.to_file('{1}')", varName, path);
116-
com_interface.insertCell('code', code.toString());
116+
com_interface.insertCell('code', code.toString(), 'Data Analysis > Profiling');
117117

118118
that.selectedReport = '';
119119
});
@@ -124,7 +124,7 @@ define([
124124
default:
125125
return;
126126
}
127-
com_interface.insertCell('code', code.toString());
127+
com_interface.insertCell('code', code.toString(), 'Data Analysis > Profiling');
128128
that.loadReportList();
129129
});
130130
}

0 commit comments

Comments
 (0)