From c8151c6f3075fcbc6ef070d7dcb5117144a4f8ad Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 26 Jul 2019 17:26:53 +0200 Subject: [PATCH] WIP search in vfsSelect dialog: Implement search query for file lists --- api/js/etemplate/vfsSelectUI.js | 40 ++++++++++++++++++++++++++- api/templates/default/vfsSelectUI.xet | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/vfsSelectUI.js b/api/js/etemplate/vfsSelectUI.js index 6671af5b5e..d888eaa452 100644 --- a/api/js/etemplate/vfsSelectUI.js +++ b/api/js/etemplate/vfsSelectUI.js @@ -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); +});}).call(this); \ No newline at end of file diff --git a/api/templates/default/vfsSelectUI.xet b/api/templates/default/vfsSelectUI.xet index 2d42c3ed81..909424d341 100644 --- a/api/templates/default/vfsSelectUI.xet +++ b/api/templates/default/vfsSelectUI.xet @@ -19,7 +19,7 @@