Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit36c75a8

Browse files
author
minjk-bl
committed
Edit FileNavigation to get use multi-extensions
1 parent97457ff commit36c75a8

File tree

1 file changed

+58
-45
lines changed

1 file changed

+58
-45
lines changed

‎visualpython/js/com/component/FileNavigation.js‎

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ define([
8484
this.pathStackPointer=-1;
8585
this.pathStack=[];
8686
this.currentFileList=[];
87+
this.selectedExt='';
88+
if(this.state.extensions.length>0){
89+
this.selectedExt=this.state.extensions[0];
90+
}
8791

8892
this.pathState={
8993
parentPath:'',
@@ -280,6 +284,32 @@ define([
280284
// clear body
281285
$(this.wrapSelector('.fileNavigationPage-body')).html('');
282286

287+
/**
288+
* Filter file/dir which included in this.state.extensions
289+
*/
290+
if(Array.isArray(this.state.extensions)&&this.state.extensions.length>0&&this.state.extensions.toString()!==''){
291+
fileList=fileList.filter((data,index)=>{
292+
if(index==0){
293+
returntrue;
294+
}
295+
296+
if(data.type&&data.type=='dir'){
297+
// if directory, just show
298+
returntrue;
299+
}elseif(data.name){
300+
varextension=data.name.substring(data.name.lastIndexOf('.')+1);
301+
// if (that.state.extensions.includes(extension)) {
302+
if(that.selectedExt===''||extension===that.selectedExt){
303+
returntrue;
304+
}else{
305+
returnfalse;
306+
}
307+
}else{
308+
returnfalse;
309+
}
310+
});
311+
}
312+
283313
// render file items
284314
letdirArr=[];
285315
letfileArr=[];
@@ -411,12 +441,12 @@ define([
411441
page.appendFormatLine('<input id="{0}" type="text" class="vp-input" placeholder="{1}" value="{2}"/>'
412442
,'vp_fileNavigationInput','New File Name',this.state.fileName);
413443
page.appendFormatLine('<select id="{0}" class="vp-select">','vp_fileNavigationExt');
444+
page.appendLine('<option value="">All files(*.*)</option>');
414445
if(this.state.extensions&&this.state.extensions.length>0){
446+
letselectedExt=this.selectedExt;
415447
this.state.extensions.forEach(ext=>{
416-
page.appendFormatLine('<option value="{0}">*.{1}</option>',ext,ext);
448+
page.appendFormatLine('<option value="{0}" {1}>*.{2}</option>',ext,(selectedExt===ext?'selected':''),ext);
417449
});
418-
}else{
419-
page.appendLine('<option value="">All files(*.*)</option>');
420450
}
421451
page.appendLine('</select>');
422452
page.appendFormatLine('<button class="{0} vp-button" data-menu="{1}">{2}</button>','vp-filenavi-btn','select','Select');
@@ -430,6 +460,13 @@ define([
430460

431461
that.handleSelectFile(filePath,fileName);
432462
});
463+
// bind file extension change event
464+
$(this.wrapSelector('#vp_fileNavigationExt')).on('change',function(){
465+
letext=$(this).val();
466+
that.selectedExt=ext;
467+
468+
that.renderFileList();
469+
});
433470
// bind save cancel event
434471
$(this.wrapSelector('.vp-filenavi-btn')).on('click',function(){
435472
letmenu=$(this).data('menu');
@@ -477,10 +514,10 @@ define([
477514
letthat=this;
478515
/** Implement after rendering */
479516
// if save mode
480-
if(this.state.type=='save'){
481-
// render saving box
482-
this.renderSaveBox();
483-
}
517+
//if (this.state.type == 'save') {
518+
// render saving box
519+
this.renderSaveBox();
520+
//}
484521

485522
// get current path
486523
this.getCurrentDirectory().then(function(currentPath){
@@ -527,20 +564,21 @@ define([
527564
//============================================================================
528565
// Set selection result
529566
//============================================================================
530-
if(this.state.type=='save'){
531-
// add as saving file
532-
this.setSelectedFile(fileInput,pathInput);
533-
}else{
534-
// Manage result using finish function
535-
letfilesPath=[{file:fileInput,path:pathInput}];//FIXME: fix it if multiple selection implemented
536-
letstatus=true;
537-
leterror=null;
538-
vpLog.display(VP_LOG_TYPE.DEVELOP,'fileNavigation finished',filesPath,status,error);
539-
this.state.finish(filesPath,status,error);
567+
this.setSelectedFile(fileInput,pathInput);
568+
// if (this.state.type == 'save') {
569+
// // add as saving file
570+
// this.setSelectedFile(fileInput, pathInput);
571+
// } else {
572+
// // Manage result using finish function
573+
// let filesPath = [{ file: fileInput, path: pathInput }]; //FIXME: fix it if multiple selection implemented
574+
// let status = true;
575+
// let error = null;
576+
// vpLog.display(VP_LOG_TYPE.DEVELOP, 'fileNavigation finished', filesPath, status, error);
577+
// this.state.finish(filesPath, status, error);
540578

541-
// remove and close file navigation
542-
this.close();
543-
}
579+
// // remove and close file navigation
580+
// this.close();
581+
//}
544582
}
545583
getCurrentDirectory(){
546584
returnvpKernel.getCurrentDirectory();
@@ -588,31 +626,6 @@ define([
588626
returna-b;
589627
});
590628

591-
/**
592-
* Filter file/dir which included in this.state.extensions
593-
*/
594-
if(Array.isArray(that.state.extensions)&&that.state.extensions.length>0&&that.state.extensions.toString()!==''){
595-
filtered_varList=filtered_varList.filter((data,index)=>{
596-
if(index==0){
597-
returntrue;
598-
}
599-
600-
if(data.type&&data.type=='dir'){
601-
// if file, just show
602-
returntrue;
603-
}elseif(data.name){
604-
varextension=data.name.substring(data.name.lastIndexOf('.')+1);
605-
if(that.state.extensions.includes(extension)){
606-
returntrue;
607-
}else{
608-
returnfalse;
609-
}
610-
}else{
611-
returnfalse;
612-
}
613-
});
614-
}
615-
616629
vpLog.display(VP_LOG_TYPE.DEVELOP,'FileNavigation - getFileList: ',filtered_varList);
617630

618631
var{ currentDirStr, currentRelativePathStr}=that.splitPathStrAndSetStack(dirObj,filtered_varList);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp