From c2c9af5310538d3ca006855921cfc5356f5450aa Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 22 Dec 2019 02:26:36 +0300 Subject: [PATCH] added callback to make.batch(..) -- still needs testing... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index ca48f945..34cba6cc 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1224,16 +1224,31 @@ function(spec, callback){ .reduce(function(res, cur){ that = res return res[cur] }, that) - // XXX revise this... - .call(that, field.text || '[field]', field) + .call(that, field.title || field.id, field) // other... : that(field) }) // batch callback... callback && this.dialog - .close(function(){ + .close(function(mode){ // XXX get the field data and pass it to the callback... - // XXX + callback( + // get the field-value pairs... + spec.reduce(function(res, e){ + var id = e.id || e.title + id != undefined + && (res[id] = e.value instanceof Function ? + e.value.call(that) + : e.value) + return res }, {}), + // full spec... + // NOTE: technically we do not need to pass this + // through as we are mutating the data inside + // but passing it here is cleaner than forcing + // the user to get it via closure... + spec, + // XXX is this the right spot for this??? + mode) }) return this }