WIP search in vfsSelect dialog:

Implement search query for file lists
This commit is contained in:
Hadi Nategh 2019-07-26 17:26:53 +02:00
parent 666125326c
commit c8151c6f30
2 changed files with 40 additions and 2 deletions

View File

@ -17,6 +17,7 @@
app.classes.vfsSelectUI = (function(){ "use strict"; return AppJS.extend(
{
appname: 'filemanager',
dirContent: {},
vfsSelectWidget: {},
path_widget: {},
/**
@ -54,6 +55,7 @@ app.classes.vfsSelectUI = (function(){ "use strict"; return AppJS.extend(
et2_ready: function(et2,name)
{
this.path_widget = this.et2.getWidgetById('path');
this.dirContent = this.et2.getArrayMgr('content').data.dir;
},
/**
@ -310,5 +312,41 @@ app.classes.vfsSelectUI = (function(){ "use strict"; return AppJS.extend(
}
this.vfsSelectWidget._content(arrMgrs.content.data, _callback);
},
/**
* search through dir content and set its content base on searched query
* @returns
*/
search: function(_widget)
{
var dir = this.et2.getWidgetById('dir');
var query = _widget.get_value();
if (query == "")
{
dir.set_value({content: this.dirContent});
return;
}
var searchQuery = function (_query)
{
var result = {};
var reg = RegExp(_query, 'ig');
var content = dir.getArrayMgr('content').data;
var key = 0;
for (var i in content)
{
if (typeof content[i]['name'] != 'undefined' && content[i]['name'].match(reg))
{
result[key] = content[i];
key++;
}
else if (typeof content[i]['name'] == 'undefined' && isNaN(i))
{
result[i] = content[i];
}
}
return result;
};
dir.set_value({content: searchQuery(query)});
}
});}).call(this);

View File

@ -19,7 +19,7 @@
<select width="175" id="app" empty_label="Applications" no_lang="1" onchange="app.vfsSelectUI.do_action('app', widget)"/>
<buttononly statustext="Create directory" id="createdir" class="createDir" onclick="app.vfsSelectUI.createdir" image="button_createdir" ro_image="createdir_disabled" background_image="1"/>
<file id='upload_file' statustext="upload file" progress_dropdownlist = "true" multiple="true" onFinish="app.vfsSelectUI.storeFile"/>
<searchbox id="search"/>
<searchbox id="search" onchange="app.vfsSelectUI.search"/>
<vfs-path id="path" class="et2_fullWidth selectPath" align="left" onchange="app.vfsSelectUI.do_action('path', widget)"/>
</box>
</row>