From 15ca09fed0af715c21824f9fc666b9404a7f5937 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 23 Jun 2019 21:18:43 +0300 Subject: [PATCH] minor tweaks... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/widget/browse2.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/ui (gen4)/lib/widget/browse2.js b/ui (gen4)/lib/widget/browse2.js index 7e06e6fe..a9f7d683 100755 --- a/ui (gen4)/lib/widget/browse2.js +++ b/ui (gen4)/lib/widget/browse2.js @@ -299,6 +299,16 @@ var BaseItemPrototype = { get text(){ return this.constructor.text(this) }, + get pathArray(){ + var p = this.parent + while(p.parent instanceof BaseBrowser){ + p = p.parent } + return p ? + p.pathOf(this) + : undefined }, + get path(){ + return this.pathArray.join('/') }, + __init__(...state){ Object.assign(this, ...state) }, } @@ -752,10 +762,6 @@ var BaseBrowserClassPrototype = { // ...only some item updates (how .collapsed is handled) make // sense at this time -- need to think about this more // carefully + strictly document the result... -// XXX can/should we make traversal simpler??? -// ...currently to get to a nested item we'd need to: -// dialog.flatIndex.B.children.index.C. ... -// on the other hand we can .get('B/C/...') var BaseBrowserPrototype = { // XXX should we mix item/list options or separate them into sub-objects??? options: { @@ -817,8 +823,15 @@ var BaseBrowserPrototype = { // This will delete all attributes of the format: // .___cache // + // + // Clear all cache data including generated items... + // .clearCache(true) + // -> this + // + // NOTE: .clearCache(true) will yield a state that would require at + // least a .update() call to be usable... clearCache: function(title){ - if(title == null){ + if(title == null || title === true){ Object.keys(this) .forEach(function(key){ if(key.startsWith('__') && key.endsWith('_cache')){ @@ -831,6 +844,9 @@ var BaseBrowserPrototype = { delete this[`__${title}_cache`] }.bind(this)) } + if(title === true){ + delete this.__items + } return this }, @@ -3058,7 +3074,6 @@ var HTMLItemClassPrototype = { return elem.classList.contains('list') ? elem.querySelector('.item') : elem }, - } var HTMLItemPrototype = { @@ -3192,7 +3207,6 @@ var HTMLBrowserClassPrototype = { // ...need to render lists and items both as a whole or independently... // XXX need a strategy to update the DOM -- i.e. add/remove nodes for // partial rendering instead of full DOM replacement... -// XXX add a left button type/option -- expand/collapse and friends... var HTMLBrowserPrototype = { __proto__: BaseBrowser.prototype, __item__: HTMLItem, @@ -4118,6 +4132,8 @@ var HTMLBrowserPrototype = { keyPress: makeEventMethod('keypress', function(evt, key){ this.__keyboard_handler(key) }), + // XXX do we need a default behavior here??? + // ...something like .expand(..) menu: makeItemEventMethod('menu'),