better dir hiding -- still not full-proof...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-03-25 12:33:48 +03:00
parent 53f6e7c1f3
commit b5403e5542
4 changed files with 51 additions and 27 deletions

View File

@ -1409,8 +1409,6 @@ module.TagsEdit = core.ImageGridFeatures.Feature({
//---------------------------------------------------------------------
// Image Group...
@ -1491,7 +1489,6 @@ module.ImageEditGroupActions = actions.Actions({
groupForward: ['Group|Edit/Group forwards',
{journal: true},
function(target){ this.groupTo(target, 'next') }],
})
var ImageEditGroup =

View File

@ -1385,13 +1385,12 @@ var BrowseActionsActions = actions.Actions({
// 'System/' hidden...
alias: ['- System/', ''],
// XXX this should also (optionally?):
// - sort levels - DONE
// - expand path patterns - DONE
// - handle "*" listing (???)
// ...only for paths going into such a branch, otherwise
// it might get recursive fast.
// - handle visibility checks (???)
// NOTE: we are avoiding handling here the lister actions (action
// paths ending with '*') as they are active while .getActions(..)
// should be as independent as possible and never trigger any
// side-effects...
// ...the same can be said about handling visibility tests.
// XXX revise...
getActions: ['- System/',
core.doc`List actions in action tree...
@ -1429,13 +1428,11 @@ var BrowseActionsActions = actions.Actions({
var PRIORITY = /^(-?[0-9]+)\s*:\s*/
var MARKER = RegExp(this.config['browse-actions-shortcut-marker'], 'g')
MARKER = MARKER || RegExp(MARKER, 'g')
// Sort tree level in-place...
//
// NOTE: this will remove the priority unless raw_keys is set...
// NOTE: setting shallow will sort only one level level...
var sortTree = function(tree, raw_keys, shallow){
var sortTree = function(tree, raw_keys){
var level = Object.keys(tree)
level
.slice()
@ -1482,10 +1479,9 @@ var BrowseActionsActions = actions.Actions({
tree[text] = value
// go down the tree...
!shallow
&& value
value
&& !(value instanceof Array)
&& sortTree(value, raw_keys, shallow)
&& sortTree(value, raw_keys)
})
return tree
}
@ -1618,6 +1614,10 @@ var BrowseActionsActions = actions.Actions({
return cur
}],
// XXX do not draw empty dirs (i.e. where all actions are hidden)...
// Example:
// /Store/
// /Jobs/
// XXX can we do a deep search on '/' -- find any nested action???
// ...or rather a search from this level and down...
// XXX can this also do a flat mode???
@ -1712,7 +1712,6 @@ var BrowseActionsActions = actions.Actions({
options = options || {}
var MARKER = RegExp(this.config['browse-actions-shortcut-marker'], 'g')
MARKER = MARKER || RegExp(MARKER, 'g')
// prepare the config...
var cfg = {
@ -1736,12 +1735,15 @@ var BrowseActionsActions = actions.Actions({
return (keys[action] || []).join(' / ') }
// Get action browse mode (disabled or hidden)...
var mode_cache = {}
var getMode = function(action){
var m = action
var visited = [m]
var last
// handle aliases...
do {
last = m
m = actions.getActionAttr(m, 'browseMode')
// check for loops...
if(m && visited[m] != null){
@ -1751,7 +1753,14 @@ var BrowseActionsActions = actions.Actions({
visited.push(m)
} while(typeof(m) == typeof('str'))
return m ? m.call(actions) : undefined
//return m ? m.call(actions) : undefined
return m ?
(mode_cache == null ?
m.call(actions)
: last in mode_cache ?
mode_cache[last]
: (mode_cache[last] = m.call(actions)))
: undefined
}
// Wait for dialog...
@ -1781,6 +1790,11 @@ var BrowseActionsActions = actions.Actions({
var that = this
var cur = actions.getActions(path.slice(), tree)
// reset mode cache...
// NOTE: we reset the cache to allow state changes while
// navigating...
mode_cache = {}
// render current level...
// NOTE: we can be at one of several level types, each
// is rendered in a different way...
@ -1918,6 +1932,10 @@ var BrowseActionsActions = actions.Actions({
}
// Item: dir...
// XXX need to check if this is empty...
// ...do not draw if nothing will be visible inside...
// XXX this will hide non-empty dirs containing only hidden stuff
// ...should such dirs still be treated as empty???
} else if(actions.config['browse-actions-settings'].showEmpty
|| (cur[key] != null
&& Object.keys(cur[key]).length > 0)){
@ -1931,6 +1949,15 @@ var BrowseActionsActions = actions.Actions({
getKeys('browseActions!: "'+ p +'"'),
].filter(function(e){ return e.trim() != '' }).join(' / '),
},
// XXX this will only check statically hidden stuff...
// ...the rest may still get dynamically hidden...
hidden: options.no_hidden ?
false
: Object.keys(cur[key])
// XXX we still need to check browseMode of each child...
.filter(function(k){
return (cur[key][k] || [])[1] != 'hidden' })
.length == 0,
})
// item: line...

View File

@ -199,9 +199,9 @@
}
},
"commander": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.0.tgz",
"integrity": "sha512-7B1ilBwtYSbetCgTY1NJFg+gVpestg0fdA1MhC1Vs4ssyfSXnCAjFr+QcQM9/RedXC0EaUx1sG8Smgw2VfgKEg=="
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag=="
},
"concat-map": {
"version": "0.0.1",
@ -1170,9 +1170,9 @@
"integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
},
"ig-actions": {
"version": "3.19.0",
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.19.0.tgz",
"integrity": "sha512-8X5W7yNtsrwi35RnR+K5H6+/CtEb/dFVXrJEPxOxeByH3njuHwC44MMr3wLIXS0XVH1vM8xjlHsUd0uFU37J5A==",
"version": "3.19.1",
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.19.1.tgz",
"integrity": "sha512-yzmO9OVCUw891mpu1AUlViB/BQil2fFKymK83gcDc6qzteqdfQ/8CsGascba4uy4vufCP+43MI9aGEpgOo5JfQ==",
"requires": {
"ig-object": "1.0.2"
}
@ -1182,7 +1182,7 @@
"resolved": "https://registry.npmjs.org/ig-features/-/ig-features-3.3.4.tgz",
"integrity": "sha512-nJmMDfY6JiyQ2mQj31oMOmw/HOY4zbN6yyPEFu61ySXU/f3+CC/GZjdaYFemVbnZThC7hcxYfmj62eSjt7oT+Q==",
"requires": {
"ig-actions": "3.19.0",
"ig-actions": "3.19.1",
"ig-object": "1.0.2"
}
},

View File

@ -20,13 +20,13 @@
"dependencies": {
"app-module-path": "^1.0.6",
"async-json": "0.0.2",
"commander": "^2.15.0",
"commander": "^2.15.1",
"exiftool": "^0.0.3",
"fs-extra": "^4.0.3",
"fs-walk": "^0.0.1",
"glob": "^4.0.6",
"guarantee-events": "^1.0.0",
"ig-actions": "^3.19.0",
"ig-actions": "^3.19.1",
"ig-features": "^3.3.4",
"ig-object": "^1.0.2",
"moment": "^2.21.0",