diff --git a/www/common/common-util.js b/www/common/common-util.js index e5471c1ff..22509c617 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -733,6 +733,11 @@ return !(typeof(Atomics) === "undefined" || !supportsSharedArrayBuffers() || typeof(WebAssembly) === 'undefined'); }; + //Returns an array of integers in range 0 to (length-1) + Util.getKeysArray = function (length) { + return [...Array(length).keys()]; + }; + if (typeof(module) !== 'undefined' && module.exports) { module.exports = Util; } else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) { diff --git a/www/form/inner.js b/www/form/inner.js index 2316b992a..5b6e7eb14 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -3296,7 +3296,7 @@ define([ }); sorted.forEach(function (uid) { var answer = answers[uid]; - + var viewOnly = content.answers.cantEdit || APP.isClosed; var action = h(viewOnly ? 'button.btn.btn-secondary' : 'button.btn.btn-primary', [ @@ -4110,9 +4110,27 @@ define([ idx = obj.idx; _uid = Util.uid(); + var opts = Util.clone(content.form[uid].opts); + if (type === 'multiradio' || type === 'multicheck') { + var itemKeys = Util.getKeysArray(content.form[uid].opts.items.length); + var valueKeys = Util.getKeysArray(content.form[uid].opts.values.length); + opts.items = itemKeys.map(function (i) { + return { + uid: Util.uid(), + v: content.form[uid].opts.items[i].v + }; + }); + opts.values = valueKeys.map(function (i) { + return { + uid: Util.uid(), + v: content.form[uid].opts.values[i].v + }; + }); + } + content.form[_uid] = { q: content.form[uid].q, - opts: content.form[uid].opts, + opts: opts, type: type, };