fixed bug in make.EditableList(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-08-17 15:13:35 +03:00
parent a12f3b5c81
commit 186a45140a
2 changed files with 12 additions and 5 deletions

View File

@ -129,6 +129,8 @@ var UIAliasActions = actions.Actions({
var names = Object.keys(aliases) var names = Object.keys(aliases)
console.log('>>>>>>>>>>>', names)
names.length > 0 ? names.length > 0 ?
// XXX for some reason this does not get updated on dialog.update() // XXX for some reason this does not get updated on dialog.update()
make.EditableList(names, make.EditableList(names,
@ -143,6 +145,7 @@ var UIAliasActions = actions.Actions({
}, },
each: function(name, elem){ each: function(name, elem){
console.log('>>>>', name)
$(elem) $(elem)
.attr({ .attr({
keys: getKeys(name), keys: getKeys(name),

View File

@ -457,6 +457,8 @@ function(data, options){
: options.isItemHidden, : options.isItemHidden,
} }
console.log('LIST:', keys)
keys.forEach(function(k){ keys.forEach(function(k){
var txt var txt
var opts = Object.create(options) var opts = Object.create(options)
@ -502,7 +504,7 @@ function(data, options){
&& elem.on('open', data[k]) && elem.on('open', data[k])
opts.each opts.each
&& opts.each(txt || k, elem) && opts.each.call(elem, txt || k)
res.push(elem[0]) res.push(elem[0])
}) })
@ -673,8 +675,8 @@ function(list, options){
var make = this var make = this
var dialog = make.dialog var dialog = make.dialog
var write = function(list, lst){
// write back the list... // write back the list...
var write = function(list, lst){
return (list instanceof Function ? return (list instanceof Function ?
// call the writer... // call the writer...
list(lst) list(lst)
@ -710,22 +712,24 @@ function(list, options){
} }
options = opts options = opts
/*
if(id in dialog.__list && id in dialog.__editable){ if(id in dialog.__list && id in dialog.__editable){
var lst = dialog.__list[id] var lst = dialog.__list[id]
var editable = dialog.__editable[id] var editable = dialog.__editable[id]
} else { } else {
//*/
var lst = list instanceof Function ? var lst = list instanceof Function ?
list() list()
: list : list
var editable = dialog.__editable[id] = lst instanceof Array var editable = dialog.__editable[id] = lst instanceof Array && dialog.__editable[id]
// view objects... // view objects...
// NOTE: we .slice() here to make the changes a bit better packaged // NOTE: we .slice() here to make the changes a bit better packaged
// or discrete and not done as they come in... // or discrete and not done as they come in...
lst = !editable ? Object.keys(lst) : lst.slice() lst = lst instanceof Array ? lst.slice() : Object.keys(lst)
dialog.__list[id] = lst dialog.__list[id] = lst
} //}
var buttons = options.buttons = (options.buttons || []).slice() var buttons = options.buttons = (options.buttons || []).slice()