From 764e78b4f41315effa83af5d276152ff65395329 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 16 Aug 2017 14:40:17 +0300 Subject: [PATCH] updated alias dialog... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/alias.js | 38 +++++++++++++++++++++++----------- ui (gen4)/lib/widget/browse.js | 6 ++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ui (gen4)/features/alias.js b/ui (gen4)/features/alias.js index efb5a550..6a6d7a7b 100755 --- a/ui (gen4)/features/alias.js +++ b/ui (gen4)/features/alias.js @@ -109,6 +109,7 @@ module.Alias = core.ImageGridFeatures.Feature({ var UIAliasActions = actions.Actions({ // XXX should this update the parent??? + // XXX updating this does not work yet... browseAliases: ['System/Aliases...', widgets.makeUIDialog(function(){ var that = this @@ -119,6 +120,8 @@ var UIAliasActions = actions.Actions({ var getKeys = function(action){ return (keys[action] || []).join(' / ') } + var to_remove = [] + return browse.makeLister(null, function(path, make){ var dialog = this @@ -127,18 +130,24 @@ var UIAliasActions = actions.Actions({ var names = Object.keys(aliases) names.length > 0 ? - names - .forEach(function(name){ - //make([name, (aliases[name]).slice(-1)[0]]) - make([name]) - .attr({ - keys: getKeys(name), - action: name, - }) - .on('open', function(){ - that.editAlias(name) - .on('close', function(){ dialog.update() }) - }) + make.EditableList(names, + { + new_item: false, + to_remove: to_remove, + + itemopen: function(name){ + that.editAlias(name) + .on('close', function(){ dialog.update() }) + dialog.close() + }, + + each: function(name, elem){ + $(elem) + .attr({ + keys: getKeys(name), + action: name, + }) + } }) : make.Empty() @@ -161,6 +170,11 @@ var UIAliasActions = actions.Actions({ } this.keyboard.handler('General', '?', 'showDoc') }) + .close(function(){ + to_remove.forEach(function(alias){ + that.alias(alias, null) + }) + }) })], // NOTE: this does not include an attr editor by design... diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 4f290e37..73660a4e 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -434,6 +434,9 @@ function(list){ // // if true, group the items into a element... // groupList: false, // +// // process each dom element... +// each: , +// // // see: make(..) for additional option info. // ... // } @@ -498,6 +501,9 @@ function(data, options){ keys !== data && data[k] && elem.on('open', data[k]) + opts.each + && opts.each(txt || k, elem) + res.push(elem[0]) })