From f7cc2ba306172aa7587a65b30fcb9e90b2ef73c9 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 5 Jan 2019 19:47:26 +0300 Subject: [PATCH] added option to hide dod files in the fs browser... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/core.js | 15 +++-- ui (gen4)/features/filesystem.js | 17 +++++- ui (gen4)/lib/widget/browse-walk.js | 87 ++++++++++++++++++----------- 3 files changed, 81 insertions(+), 38 deletions(-) diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index f693a41e..9efbdd22 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -78,14 +78,21 @@ function(attr, states, a, b){ : states instanceof Function ? states.call(this) : states + // get attr path... + var a = attr.split(/\./g) + var cfg = a.slice(0, -1) + .reduce(function(res, cur){ + return res[cur] }, this.config) + if(action == null){ - var cfg = this.config[attr] - return cfg == null ? + var val = cfg[a.pop()] + return val == null ? (lst[lst.indexOf('none')] || lst[0]) - : cfg + : val } else { - this.config[attr] = action + cfg[a[a.length-1]] = action + this.config[a[0]] = this.config[a[0]] } }, states, pre, post) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index a73ed3aa..d8798e30 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -874,6 +874,9 @@ var FileSystemLoaderUIActions = actions.Actions({ showNonTraversable: true, showDisabled: true, + disableDotFiles: 'on', + //disableHiddenFiles: false, + //actionButton: '⋯', // "..." //actionButton: '⮠', // down then left arrow (long) //actionButton: '▹', // right-pointing white triangle @@ -896,6 +899,8 @@ var FileSystemLoaderUIActions = actions.Actions({ var cfg = Object.create(this.config['file-browser-settings']) cfg.cls = 'file-browser' + // normalize... + cfg.disableDotFiles = cfg.disableDotFiles == 'on' base = base || this.location.path || '/' base = util.normalizePath(base) @@ -936,12 +941,15 @@ var FileSystemLoaderUIActions = actions.Actions({ }) // we closed the browser -- save settings to .config... .on('close', function(){ - - var config = that.config['file-browser-settings'] + var config = + that.config['file-browser-settings'] = + that.config['file-browser-settings'] || {} config.disableFiles = o.options.disableFiles config.showDisabled = o.options.showDisabled config.showNonTraversable = o.options.showNonTraversable + // normalize... + config.disableDotFiles = o.options.disableDotFiles ? 'on' : 'off' }) return o @@ -1005,6 +1013,11 @@ var FileSystemLoaderUIActions = actions.Actions({ return o })], + + toggleDotFileDrawing: ['Interface/File browser/Hide dot files', + core.makeConfigToggler( + 'file-browser-settings.disableDotFiles', + ['on', 'off'])], }) diff --git a/ui (gen4)/lib/widget/browse-walk.js b/ui (gen4)/lib/widget/browse-walk.js index 2913af26..df752da4 100755 --- a/ui (gen4)/lib/widget/browse-walk.js +++ b/ui (gen4)/lib/widget/browse-walk.js @@ -196,16 +196,20 @@ function(path, make){ } var dir = res.isDirectory() - var elem = res && make(fullpath - ? path +'/'+ file - : file + (dir ? '/' : ''), - null, - that.options.disableFiles && !dir) + var elem = res + && !(that.options.disableDotFiles + && file.startsWith('.')) + && make(fullpath + ? path +'/'+ file + : file + (dir ? '/' : ''), + null, + that.options.disableFiles + && !dir) // count the number of files... // NOTE: we do not care how long it will take // so we'll not wait... - res && dir && _countDirFiles(path, file, elem) + res && dir && elem && _countDirFiles(path, file, elem) }) // NOTE: we are not using promise.all(..) here because it // triggers BEFORE the first make(..) is called... @@ -285,41 +289,60 @@ var listDir = module.listDir = listDirfs // XXX for some reason pop does not focus the container dir correctly... // ...this is potentially due to the list not being ready yet... // XXX this should be smarter and support other URL schemes... -var WalkPrototype = Object.create(browse.Browser.prototype) -WalkPrototype.options = { - // XXX this should be smarter and support other URL schemes... - pathPrefix: os.type() == 'Windows_NT' ? '' : '/', +var WalkPrototype = { + __proto__: browse.Browser.prototype, - fullPathEdit: true, - traversable: true, - flat: false, + options: { + __proto__: browse.Browser.prototype.options, - sortTraversable: 'first', + // XXX this should be smarter and support other URL schemes... + pathPrefix: os.type() == 'Windows_NT' ? '' : '/', - //actionButton: '⋯', // "..." - //actionButton: '⊙', // circle with dot - actionButton: '⮠', // down then left arrow (long) - //actionButton: '▹', // right-pointing white triangle - //actionButton: '◹', // ne white triangle - //actionButton: '↗', // ne arrow - //actionButton: '⮣', // up then right arrow - //actionButton: '»', // right-pointing double angle - // quotation mark - // XXX not sure about this... - //actionButton: '📂', // folder icon (color) + fullPathEdit: true, + traversable: true, + flat: false, - pushButton: false, + sortTraversable: 'first', - list: listDir, + //actionButton: '⋯', // "..." + //actionButton: '⊙', // circle with dot + actionButton: '⮠', // down then left arrow (long) + //actionButton: '▹', // right-pointing white triangle + //actionButton: '◹', // ne white triangle + //actionButton: '↗', // ne arrow + //actionButton: '⮣', // up then right arrow + //actionButton: '»', // right-pointing double angle + // quotation mark + // XXX not sure about this... + //actionButton: '📂', // folder icon (color) - fileCountPattern: '*', + pushButton: false, - disableFiles: false, + list: listDir, - // enable '.' and '..' dirs... - dotDirs: true, + fileCountPattern: '*', + + disableFiles: false, + + disableDotFiles: true, + //disableHiddenFiles: false, + + + // enable '.' and '..' dirs... + dotDirs: true, + }, + + toggleDotFileDrawing: function(){ + var cur = this.selected + if(this.options.toggleDisabledDrawing == false){ + return this + } + this.options.disableDotFiles = !this.options.disableDotFiles + this.update() + cur && this.select(cur) + return this + }, } -WalkPrototype.options.__proto__ = browse.Browser.prototype.options var Walk =