added option to hide dod files in the fs browser...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-01-05 19:47:26 +03:00
parent 62a9b43fe5
commit f7cc2ba306
3 changed files with 81 additions and 38 deletions

View File

@ -78,14 +78,21 @@ function(attr, states, a, b){
: states instanceof Function ? states.call(this) : states instanceof Function ? states.call(this)
: states : 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){ if(action == null){
var cfg = this.config[attr] var val = cfg[a.pop()]
return cfg == null ? return val == null ?
(lst[lst.indexOf('none')] || lst[0]) (lst[lst.indexOf('none')] || lst[0])
: cfg : val
} else { } else {
this.config[attr] = action cfg[a[a.length-1]] = action
this.config[a[0]] = this.config[a[0]]
} }
}, },
states, pre, post) states, pre, post)

View File

@ -874,6 +874,9 @@ var FileSystemLoaderUIActions = actions.Actions({
showNonTraversable: true, showNonTraversable: true,
showDisabled: true, showDisabled: true,
disableDotFiles: 'on',
//disableHiddenFiles: false,
//actionButton: '&ctdot;', // "..." //actionButton: '&ctdot;', // "..."
//actionButton: '&#11168;', // down then left arrow (long) //actionButton: '&#11168;', // down then left arrow (long)
//actionButton: '&#9657;', // right-pointing white triangle //actionButton: '&#9657;', // right-pointing white triangle
@ -896,6 +899,8 @@ var FileSystemLoaderUIActions = actions.Actions({
var cfg = Object.create(this.config['file-browser-settings']) var cfg = Object.create(this.config['file-browser-settings'])
cfg.cls = 'file-browser' cfg.cls = 'file-browser'
// normalize...
cfg.disableDotFiles = cfg.disableDotFiles == 'on'
base = base || this.location.path || '/' base = base || this.location.path || '/'
base = util.normalizePath(base) base = util.normalizePath(base)
@ -936,12 +941,15 @@ var FileSystemLoaderUIActions = actions.Actions({
}) })
// we closed the browser -- save settings to .config... // we closed the browser -- save settings to .config...
.on('close', function(){ .on('close', function(){
var config =
var config = that.config['file-browser-settings'] that.config['file-browser-settings'] =
that.config['file-browser-settings'] || {}
config.disableFiles = o.options.disableFiles config.disableFiles = o.options.disableFiles
config.showDisabled = o.options.showDisabled config.showDisabled = o.options.showDisabled
config.showNonTraversable = o.options.showNonTraversable config.showNonTraversable = o.options.showNonTraversable
// normalize...
config.disableDotFiles = o.options.disableDotFiles ? 'on' : 'off'
}) })
return o return o
@ -1005,6 +1013,11 @@ var FileSystemLoaderUIActions = actions.Actions({
return o return o
})], })],
toggleDotFileDrawing: ['Interface/File browser/Hide dot files',
core.makeConfigToggler(
'file-browser-settings.disableDotFiles',
['on', 'off'])],
}) })

View File

@ -196,16 +196,20 @@ function(path, make){
} }
var dir = res.isDirectory() var dir = res.isDirectory()
var elem = res && make(fullpath var elem = res
&& !(that.options.disableDotFiles
&& file.startsWith('.'))
&& make(fullpath
? path +'/'+ file ? path +'/'+ file
: file + (dir ? '/' : ''), : file + (dir ? '/' : ''),
null, null,
that.options.disableFiles && !dir) that.options.disableFiles
&& !dir)
// count the number of files... // count the number of files...
// NOTE: we do not care how long it will take // NOTE: we do not care how long it will take
// so we'll not wait... // 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 // NOTE: we are not using promise.all(..) here because it
// triggers BEFORE the first make(..) is called... // triggers BEFORE the first make(..) is called...
@ -285,8 +289,12 @@ var listDir = module.listDir = listDirfs
// XXX for some reason pop does not focus the container dir correctly... // XXX for some reason pop does not focus the container dir correctly...
// ...this is potentially due to the list not being ready yet... // ...this is potentially due to the list not being ready yet...
// XXX this should be smarter and support other URL schemes... // XXX this should be smarter and support other URL schemes...
var WalkPrototype = Object.create(browse.Browser.prototype) var WalkPrototype = {
WalkPrototype.options = { __proto__: browse.Browser.prototype,
options: {
__proto__: browse.Browser.prototype.options,
// XXX this should be smarter and support other URL schemes... // XXX this should be smarter and support other URL schemes...
pathPrefix: os.type() == 'Windows_NT' ? '' : '/', pathPrefix: os.type() == 'Windows_NT' ? '' : '/',
@ -316,10 +324,25 @@ WalkPrototype.options = {
disableFiles: false, disableFiles: false,
disableDotFiles: true,
//disableHiddenFiles: false,
// enable '.' and '..' dirs... // enable '.' and '..' dirs...
dotDirs: true, 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 = var Walk =