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... // Image Group...
@ -1491,7 +1489,6 @@ module.ImageEditGroupActions = actions.Actions({
groupForward: ['Group|Edit/Group forwards', groupForward: ['Group|Edit/Group forwards',
{journal: true}, {journal: true},
function(target){ this.groupTo(target, 'next') }], function(target){ this.groupTo(target, 'next') }],
}) })
var ImageEditGroup = var ImageEditGroup =

View File

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

View File

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

View File

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