Skip to content

Commit 7acfb89

Browse files
authored
Merge branch 'main' into release
2 parents bfb5657 + 5ca19ee commit 7acfb89

File tree

11 files changed

+113
-92
lines changed

11 files changed

+113
-92
lines changed

visualpython/css/component/multiSelector.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,4 @@
8080
left: calc(100% - 25px);
8181
bottom: 23px;
8282
cursor: pointer;
83-
}
84-
.vp-cs-del-item {
85-
position: relative;
86-
float: right;
87-
top: 4px;
88-
cursor: pointer;
8983
}

visualpython/css/m_ml/modelInfo.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.vp-model-select-box {
2-
grid-column-gap: 5px;
3-
align-items: start;
4-
}
51
.vp-ins-select-title {
62
font-weight: bold;
73
color: var(--vp-font-highlight);

visualpython/html/component/dataSelector.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="vp-inner-popup-close" title="Close data selector"></div>
99
</div>
1010
<div class="vp-inner-popup-body vp-scrollbar">
11-
<div class="vp-grid-col-p50 mb5">
11+
<div class="vp-grid-col-p50">
1212
<label class="vp-bold">Type</label>
1313
<label class="vp-bold">Data</label>
1414
</div>
@@ -22,7 +22,7 @@
2222
</div>
2323
<div class="vp-ds-option-box">
2424
<label class="vp-bold">Option Page</label>
25-
<div class="vp-ds-option-inner-box mt5">
25+
<div class="vp-ds-option-inner-box">
2626

2727
</div>
2828
</div>

visualpython/html/m_apps/file.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</td>
7575
</tr>
7676
<tr>
77-
<td><label for="vp_sampleReturn">Allocate to</label></td>
77+
<td><label for="vp_sampleReturn" class="vp-orange-text">Allocate to</label></td>
7878
<td><input type="text" class="vp-input input-single" id="vp_sampleReturn" placeholder="" value="" title=""></td>
7979
</tr>
8080
</tbody>

visualpython/js/MainFrame.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,10 @@ define([
478478
let parentBlock = null;
479479
let prevBlock = null;
480480
loadStateList.forEach(obj => {
481-
let { file, blockType, menuId, menuState, menuConfig, argIdx, position, afterAction } = obj;
481+
let { blockType, menuId, menuState, menuConfig, argIdx, position, afterAction } = obj;
482482
// get OptionComponent Object
483483
// LAB: relative path needed
484-
let OptionComponent = require('./' + file);
484+
let OptionComponent = require('./' + menuConfig.file);
485485
if (OptionComponent) {
486486
let taskState = menuState.taskState;
487487
let blockState = menuState.blockState;

visualpython/js/com/com_Config.js

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ define([
228228
vp_config_version: '1.0.0',
229229
vp_signature: 'VisualPython',
230230
vp_position: {},
231-
vp_section_display: false,
231+
// CHROME: default to display vp
232+
vp_section_display: true,
232233
vp_note_display: false,
233234
vp_menu_width: Config.MENU_MIN_WIDTH,
234235
vp_note_width: Config.BOARD_MIN_WIDTH
@@ -506,15 +507,15 @@ define([
506507
that._checkMounted().then(function() {
507508
that._readFromColab(configKey).then(function(result) {
508509
let data = result;
509-
if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) {
510+
if (data == undefined || data == {}) {
510511
resolve(data);
511512
return;
512513
}
513514
if (dataKey == '') {
514515
resolve(data);
515516
return;
516517
}
517-
if (data instanceof Object && Object.keys(data).length > 0) {
518+
if (Object.keys(data).length > 0) {
518519
resolve(data[dataKey]);
519520
return;
520521
}
@@ -530,15 +531,15 @@ define([
530531
// LAB: use local .visualpython files
531532
that._readFromLab(configKey).then(function(result) {
532533
let data = result;
533-
if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) {
534+
if (data == undefined || data == {}) {
534535
resolve(data);
535536
return;
536537
}
537538
if (dataKey == '') {
538539
resolve(data);
539540
return;
540541
}
541-
if (data instanceof Object && Object.keys(data).length > 0) {
542+
if (Object.keys(data).length > 0) {
542543
resolve(data[dataKey]);
543544
return;
544545
}
@@ -800,40 +801,6 @@ define([
800801
return Config.version;
801802
}
802803

803-
checkVersionTimestamp = function() {
804-
let that = this;
805-
// check version timestamp
806-
let nowDate = new Date();
807-
this.getData('version_timestamp', 'vpcfg').then(function(data) {
808-
let doCheckVersion = false;
809-
vpLog.display(VP_LOG_TYPE.DEVELOP, 'Checking its version timestamp... : ' + data);
810-
if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) {
811-
// no timestamp, check version
812-
doCheckVersion = true;
813-
} else if (data != '') {
814-
let lastCheck = new Date(parseInt(data));
815-
let diffCheck_now = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate());
816-
let diffCheck_last = new Date(lastCheck.getFullYear(), lastCheck.getMonth() + 1, lastCheck.getDate());
817-
818-
let diff = Math.abs(diffCheck_now.getTime() - diffCheck_last.getTime());
819-
diff = Math.ceil(diff / (1000 * 3600 * 24));
820-
821-
if (diff >= 1) {
822-
// if More than 1 day passed, check version
823-
doCheckVersion = true;
824-
}
825-
}
826-
827-
// check version and update version_timestamp
828-
if (doCheckVersion == true) {
829-
that.checkVpVersion(true);
830-
}
831-
832-
}).catch(function(err) {
833-
vpLog.display(VP_LOG_TYPE.ERROR, err);
834-
})
835-
}
836-
837804
checkVpVersion(background=false) {
838805
let that = this;
839806
let nowVersion = this.getVpInstalledVersion();
@@ -873,8 +840,6 @@ define([
873840
switch (clickedBtnIdx) {
874841
case 0:
875842
// cancel
876-
// update version_timestamp
877-
that.setData({ 'version_timestamp': new Date().getTime() }, 'vpcfg');
878843
break;
879844
case 1:
880845
// update

visualpython/js/com/com_generatorV2.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,14 @@ define([
137137
package.options && package.options.forEach(function(o, i) {
138138
var obj = JSON.parse(JSON.stringify(o));
139139
let newTag = vp_createTag(pageThis, obj, state);
140-
if (obj.required === true || obj.output === true) {
140+
if (obj.required) {
141141
tblInput.append(newTag);
142142
} else {
143143
tblOption.append(newTag);
144144
}
145145
});
146146

147147
// TODO: userOption
148-
if (package.code.includes('${etc}')) {
149-
150-
}
151148

152149
bindAutoComponentEvent(pageThis);
153150
}

visualpython/js/com/component/MultiSelector.js

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,62 @@ define([
404404
that._bindItemClickEvent();
405405
});
406406

407+
// item indexing
408+
$(this.wrapSelector('.' + APP_SELECT_ITEM)).on('click', function(event) {
409+
var dataIdx = $(this).attr('data-idx');
410+
var idx = $(this).index();
411+
var added = $(this).hasClass('added'); // right side added item?
412+
var selector = '';
413+
414+
// remove selection for select box on the other side
415+
if (added) {
416+
// remove selection for left side
417+
$(that.wrapSelector('.' + APP_SELECT_ITEM + ':not(.added)')).removeClass('selected');
418+
// set selector
419+
selector = '.added';
420+
} else {
421+
// remove selection for right(added) side
422+
$(that.wrapSelector('.' + APP_SELECT_ITEM + '.added')).removeClass('selected');
423+
// set selector
424+
selector = ':not(.added)';
425+
}
426+
427+
if (vpEvent.keyManager.keyCheck.ctrlKey) {
428+
// multi-select
429+
that.pointer = { start: idx, end: -1 };
430+
$(this).toggleClass('selected');
431+
} else if (vpEvent.keyManager.keyCheck.shiftKey) {
432+
// slicing
433+
var startIdx = that.pointer.start;
434+
435+
if (startIdx == -1) {
436+
// no selection
437+
that.pointer = { start: idx, end: -1 };
438+
} else if (startIdx > idx) {
439+
// add selection from idx to startIdx
440+
var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector));
441+
for (var i = idx; i <= startIdx; i++) {
442+
$(tags[i]).addClass('selected');
443+
}
444+
that.pointer = { start: startIdx, end: idx };
445+
} else if (startIdx <= idx) {
446+
// add selection from startIdx to idx
447+
var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector));
448+
for (var i = startIdx; i <= idx; i++) {
449+
$(tags[i]).addClass('selected');
450+
}
451+
that.pointer = { start: startIdx, end: idx };
452+
}
453+
} else {
454+
// single-select
455+
that.pointer = { start: idx, end: -1 };
456+
// un-select others
457+
$(that.wrapSelector('.' + APP_SELECT_ITEM + selector)).removeClass('selected');
458+
// select this
459+
$(this).addClass('selected');
460+
}
461+
});
462+
407463
// item indexing - add all
408464
$(this.wrapSelector('.' + APP_SELECT_ADD_ALL_BTN)).on('click', function(event) {
409465
$(that.wrapSelector('.' + APP_SELECT_BOX + '.left .' + APP_SELECT_ITEM)).appendTo(
@@ -602,7 +658,6 @@ define([
602658
let newItemIndex = this.dataList.length;
603659
var targetTag = $(`<div class="${APP_SELECT_ITEM} ${APP_DRAGGABLE} added selected" data-idx="${newItemIndex}" data-name="${newItemName}" data-type="object" data-code="'${newItemName}'" title="${newItemName}: Added manually">
604660
<span>${newItemName}</span>
605-
<div class="vp-cs-del-item vp-icon-close-small" title="Delete this manually added item"></div>
606661
</div>`);
607662
$(targetTag).appendTo(
608663
$(this.wrapSelector('.' + APP_SELECT_BOX + '.right'))
@@ -612,8 +667,6 @@ define([
612667
$(this.wrapSelector('.' + APP_SELECT_ITEM)).removeClass('selected');
613668
// clear item input
614669
$(this.wrapSelector('.vp-cs-add-item-name')).val('');
615-
// bind click event
616-
this._bindItemClickEvent();
617670
// bind draggable
618671
this.bindDraggable();
619672
}

visualpython/js/loadVisualpython.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,38 @@ define([
206206
}
207207
}
208208

209+
var _checkVersion = function() {
210+
// check version timestamp
211+
let nowDate = new Date();
212+
vpConfig.getData('version_timestamp', 'vpcfg').then(function(data) {
213+
let doCheckVersion = false;
214+
if (data == undefined) {
215+
// no timestamp, check version
216+
doCheckVersion = true;
217+
} else if (data != '') {
218+
let lastCheck = new Date(parseInt(data));
219+
let diffCheck_now = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate());
220+
let diffCheck_last = new Date(lastCheck.getFullYear(), lastCheck.getMonth() + 1, lastCheck.getDate());
221+
222+
let diff = Math.abs(diffCheck_now.getTime() - diffCheck_last.getTime());
223+
diff = Math.ceil(diff / (1000 * 3600 * 24));
224+
225+
if (diff >= 1) {
226+
// if More than 1 day passed, check version
227+
doCheckVersion = true;
228+
}
229+
}
230+
231+
// check version and update version_timestamp
232+
if (doCheckVersion == true) {
233+
vpConfig.checkVpVersion(true);
234+
}
235+
236+
}).catch(function(err) {
237+
vpLog.display(VP_LOG_TYPE.ERROR, err);
238+
})
239+
}
240+
209241
//========================================================================
210242
// External call function
211243
//========================================================================
@@ -258,10 +290,9 @@ define([
258290
_addToolBarVpButton();
259291
}
260292
_loadVpResource(cfg);
261-
vpConfig.checkVersionTimestamp();
293+
_checkVersion();
262294

263-
if ((cfg.vp_section_display && vpFrame)
264-
|| vpConfig.extensionType === 'colab') { // CHROME: default to display vp
295+
if (cfg.vp_section_display && vpFrame) {
265296
vpFrame.openVp();
266297
}
267298

@@ -288,13 +319,11 @@ define([
288319
if (newValue.sessionContext.isReady) {
289320
vpLog.display(VP_LOG_TYPE.LOG, 'vp operations for kernel ready...');
290321
vpConfig.readKernelFunction();
291-
vpConfig.checkVersionTimestamp();
292322
}
293323
newValue.sessionContext._connectionStatusChanged.connect(function(s2, status) {
294324
if (status === 'connected') {
295325
vpLog.display(VP_LOG_TYPE.LOG, 'vp operations for kernel ready...');
296326
vpConfig.readKernelFunction();
297-
vpConfig.checkVersionTimestamp();
298327
}
299328
});
300329
} else {

visualpython/js/m_apps/File.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ define([
2222
'vp_base/js/com/com_generatorV2',
2323
'vp_base/data/m_library/pandasLibrary',
2424
'vp_base/js/com/component/FileNavigation',
25-
'vp_base/js/com/component/SuggestInput',
26-
'vp_base/js/com/component/DataSelector'
25+
'vp_base/js/com/component/SuggestInput'
2726
], function(fileHtml, fileCss, com_String, com_util, com_Const, PopupComponent
28-
, pdGen, pandasLibrary, FileNavigation, SuggestInput, DataSelector) {
27+
, pdGen, pandasLibrary, FileNavigation, SuggestInput) {
2928

3029
/**
3130
* File
@@ -303,14 +302,7 @@ define([
303302

304303
templateForBody() {
305304
/** Implement generating template */
306-
let page = $(fileHtml);
307-
308-
let allocateSelector = new DataSelector({
309-
pageThis: this, id: 'vp_sampleReturn', placeholder: 'Variable name'
310-
});
311-
$(page).find('#vp_sampleReturn').replaceWith(allocateSelector.toTagString());
312-
313-
return page;
305+
return fileHtml;
314306
}
315307

316308
renderPage(pageType) {

visualpython/js/menu/MenuFrame.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,19 @@ define([
199199
return {};
200200
}
201201

202-
getMenuLibrary(menuId, libraries=this.menuLibrariesFlatten) {
202+
getMenuLibrary(menuId, libraries=this.menuLibraries) {
203203
for (var i=0; i < libraries.length; i++) {
204204
var item = libraries[i];
205205
if (item) {
206206
if (item.id === menuId) {
207207
return item;
208208
}
209-
// if (item.type === 'package') {
210-
// var result = this.getMenuLibrary(menuId, item.item);
211-
// if (result) {
212-
// return result;
213-
// }
214-
// }
209+
if (item.type === 'package') {
210+
var result = this.getMenuLibrary(menuId, item.item);
211+
if (result) {
212+
return result;
213+
}
214+
}
215215
}
216216
}
217217
return null;
@@ -246,12 +246,7 @@ define([
246246
var that = this;
247247
var body = group.getBody();
248248
var item = group.getItem();
249-
var state = group.getState();
250249
item && item.forEach(child => {
251-
// remember parent to navigate its parent menu
252-
var category = state.category?(state.category + ' > ' + state.name):state.name;
253-
child['category'] = category;
254-
255250
if (child.type == 'package') {
256251
// packages : MenuGroup
257252
var menuGroup = new MenuGroup($(body), child);
@@ -297,7 +292,7 @@ define([
297292
});
298293

299294
let functionList = this.menuLibrariesFlatten.map(menu => {
300-
return { label: menu.name, value: menu.name, dtype: menu.category, ...menu }
295+
return { label: menu.name, value: menu.name, ...menu }
301296
});
302297
// render searchbox
303298
let searchBox = new SuggestInput();

0 commit comments

Comments
 (0)