From c074793aef7ae3bb6ae7b1d89f139e8329191211 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 9 Aug 2017 15:36:03 +0300 Subject: [PATCH] working on alias ui... Signed-off-by: Alex A. Naanou --- ui (gen4)/css/widget/browse.css | 1 + ui (gen4)/features/alias.js | 54 ++++++++++++++++++++++++++++++--- ui (gen4)/features/keyboard.js | 6 +--- ui (gen4)/lib/widget/browse.js | 17 +++++++++++ 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/ui (gen4)/css/widget/browse.css b/ui (gen4)/css/widget/browse.css index 53e1d7b7..efa73b55 100755 --- a/ui (gen4)/css/widget/browse.css +++ b/ui (gen4)/css/widget/browse.css @@ -298,6 +298,7 @@ .browse-widget .list .item.disabled { opacity: 0.3; } +.browse-widget .list .item.empty-msg, .browse-widget .list .item.hidden { font-style: italic; } diff --git a/ui (gen4)/features/alias.js b/ui (gen4)/features/alias.js index f68ed480..3e17a915 100755 --- a/ui (gen4)/features/alias.js +++ b/ui (gen4)/features/alias.js @@ -78,13 +78,59 @@ module.Alias = core.ImageGridFeatures.Feature({ var UIAliasActions = actions.Actions({ browseAliases: ['System/Aliases...', widgets.makeUIDialog(function(){ - // XXX - }], + var that = this + return browse.makeLister(null, + function(path, make){ + var aliases = that.config.aliases || {} + + var names = Object.keys(aliases) + + names.length > 0 ? + names + .forEach(function(name){ + make([name, aliases[name]]) + .on('open', function(){ that.editAlias(name) }) + }) + : make.Empty() + }, { + cls: 'table-view', + }) + })], editAlias: ['- System/Edit alias...', widgets.makeUIDialog(function(alias){ - // XXX - }], + var that = this + return browse.makeLister(null, + function(path, make){ + make.Editable(['Alias:', alias], + { + start_on: 'open', + edit_text: 'last', + clear_on_edit: false, + reset_on_commit: false, + }) + .on('edit-commit', + function(evt, text){ + }) + + make.Editable(['Code:', that.config.aliases[alias]], + { + start_on: 'open', + edit_text: 'last', + clear_on_edit: false, + reset_on_commit: false, + }) + .on('edit-commit', + function(evt, text){ + }) + + make('---') + + make.ConfirmAction('Delete', {}) + }, { + cls: 'table-view', + }) + })], }) var UIAlias = diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index 3e4dff8e..8cccebf8 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -1029,11 +1029,7 @@ var KeyboardUIActions = actions.Actions({ // XXX is adding info stuff like this a correct // thing to do in code? c == 0 && options.empty_section_text !== false - && make(options.empty_section_text || 'No bindings...', - { - disabled: true, - hide_on_search: true, - }) + && make.Empty(options.empty_section_text || 'No bindings...') .attr('mode', mode) .addClass('info') diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 801d317e..e643f276 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -86,6 +86,23 @@ function makeSimpleAction(direction){ // make protocol, i.e. make(content[, options]) or their own... var Items = module.items = function(){} +// Empty list place holder... +// +// XXX should this be in CSS??? +Items.Empty = +function(msg, options){ + options = options || {} + options.disabled = options.disabled !== undefined ? + options.disabled + : true + options.hide_on_search = options.hide_on_search !== undefined ? + options.hide_on_search + : true + msg = msg || options.message || 'Empty...' + return this(msg, options) + .addClass('empty-msg') +} + // NOTE: this is the same as make('---'[, options]) Items.Separator =