mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Merge pull request #1359 from cryptpad/question_duplication_bugfix
Fixes issue with duplicating choice/checkbox grid questions
This commit is contained in:
commit
e61b2aba63
@ -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)) {
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user