From 7ff66bff493c2a17f02120c1183d7079f2319e6d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 18 Dec 2019 18:28:00 +0300 Subject: [PATCH 1/3] notes... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 184002d4..b62da883 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1088,7 +1088,7 @@ function(title, options){ type: 'toggle', open: function(evt){ - // XXX + // XXX CONTEXT... var actions = options.app || that.app var getValues = function(){ @@ -1184,7 +1184,7 @@ function(title, options){ options // normalize value... .run(function(){ - // XXX + // XXX CONTEXT... var actions = options.app || that.app if(!(this.value instanceof Function)){ From c0dd13342adde534883f95e79c38c04b4795fcd5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 19 Dec 2019 18:44:52 +0300 Subject: [PATCH 2/3] adding make.batch(..) Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 33 ++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index b62da883..5a1dff0a 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1205,10 +1205,39 @@ function(title, options){ // XXX like .makeEditor(..) but local to make(..) (i.e. generic)... +// XXX should we have a batch callback??? +// ...otherwise what's the point in this? +// XXX TEST... //browse.items.makeEditor = -browse.items.makeBatch = +browse.items.batch = function(spec, callback){ - // XXX + var that = this + + // build the fields... + ;(spec || []) + .forEach(function(field){ + // array... + field instanceof Array ? + make(...field) + // spec... + : field instanceof Object ? + // XXX add support for field paths... + //filed.type.split('.') + // .reduce(function(res, cur){ + // return res[cur] }, this)(field.text, field) + this[field.type || 'field'](field.text, field) + // other... + : make(field) }) + + // batch callback... + callback + && this.dialog + .close(function(){ + // XXX get the field data... + // XXX + }) + + return this } From 5865acdfc6f6075f9e80e290a5a20f7545c2ba40 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 20 Dec 2019 16:56:24 +0300 Subject: [PATCH 3/3] tweaking .batch(..) Signed-off-by: Alex A. Naanou --- ui (gen4)/features/examples.js | 7 +++++++ ui (gen4)/features/ui-widgets.js | 27 ++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/ui (gen4)/features/examples.js b/ui (gen4)/features/examples.js index 364c228a..89c99e4b 100755 --- a/ui (gen4)/features/examples.js +++ b/ui (gen4)/features/examples.js @@ -939,6 +939,13 @@ var ExampleUIActions = actions.Actions({ //make.field.Toggle('Toggle: ', 'on') make.field.Toggle('Toggle: ', data) + // XXX need more testing... + make.batch([ + ['X', 'Y'], + {text: 'foo', value: 123}, + {type: 'field.Toggle', text: 'Batch toggle: '}, + ]) + }, { cls: 'table-view', }) })], diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 5a1dff0a..89828808 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1034,7 +1034,6 @@ browse.items.makeSubContext = function(name, obj){ // XXX Q: should title/value args be optional??? // ...and should we break the make(..) convention of passing an arg // array for multiple .text blocks, i.e. make([title, value], ...)?? -//browse.items.Field = browse.items.makeSubContext('field', function(title, value, options){ options = options || {} @@ -1207,38 +1206,36 @@ function(title, options){ // XXX like .makeEditor(..) but local to make(..) (i.e. generic)... // XXX should we have a batch callback??? // ...otherwise what's the point in this? -// XXX TEST... //browse.items.makeEditor = browse.items.batch = function(spec, callback){ var that = this - // build the fields... ;(spec || []) .forEach(function(field){ // array... field instanceof Array ? - make(...field) + that(...field) // spec... : field instanceof Object ? - // XXX add support for field paths... - //filed.type.split('.') - // .reduce(function(res, cur){ - // return res[cur] }, this)(field.text, field) - this[field.type || 'field'](field.text, field) + (field.type || 'field') + // handle field paths... + .split('.') + .reduce(function(res, cur){ + that = res + return res[cur] }, that) + // XXX revise this... + .call(that, field.text, field) // other... - : make(field) }) - + : that(field) }) // batch callback... callback && this.dialog .close(function(){ - // XXX get the field data... + // XXX get the field data and pass it to the callback... // XXX }) - - return this -} + return this }