Update response page

pull/1/head
yflory 3 years ago
parent 538122d1b6
commit 6680293ef1

@ -1286,7 +1286,10 @@ define([
// results radio // results radio
var empty = 0; var empty = 0;
var count = {}; var count = {};
var showBars = Boolean(content);
var opts = form[uid].opts || TYPES.radio.defaultOpts;
(opts.values || []).forEach(function (v) { count[v] = 0; });
Object.keys(answers).forEach(function (author) { Object.keys(answers).forEach(function (author) {
var obj = answers[author]; var obj = answers[author];
var answer = obj.msg[uid]; var answer = obj.msg[uid];
@ -1294,6 +1297,7 @@ define([
Util.inc(count, answer); Util.inc(count, answer);
}); });
var showBars = Boolean(content);
var rendered = renderTally(count, empty, showBars); var rendered = renderTally(count, empty, showBars);
return h('div.cp-form-results-type-radio', rendered); return h('div.cp-form-results-type-radio', rendered);
}, },
@ -1393,6 +1397,7 @@ define([
var results = []; var results = [];
var empty = 0; var empty = 0;
var count = {}; var count = {};
var showBars = Boolean(content); var showBars = Boolean(content);
Object.keys(answers).forEach(function (author) { Object.keys(answers).forEach(function (author) {
var obj = answers[author]; var obj = answers[author];
@ -1400,7 +1405,11 @@ define([
if (!answer || !Object.keys(answer).length) { return empty++; } if (!answer || !Object.keys(answer).length) { return empty++; }
//count[answer] = count[answer] || {}; //count[answer] = count[answer] || {};
Object.keys(answer).forEach(function (q_uid) { Object.keys(answer).forEach(function (q_uid) {
var c = count[q_uid] = count[q_uid] || {}; var c = count[q_uid];
if (!c) {
count[q_uid] = c = {};
(opts.values || []).forEach(function (v) { c[v] = 0; });
}
var res = answer[q_uid]; var res = answer[q_uid];
if (!res || !res.trim || !res.trim()) { return; } if (!res || !res.trim || !res.trim()) { return; }
Util.inc(c, res); Util.inc(c, res);
@ -1538,6 +1547,10 @@ define([
// results checkbox // results checkbox
var empty = 0; var empty = 0;
var count = {}; var count = {};
var opts = form[uid].opts || TYPES.checkbox.defaultOpts;
(opts.values || []).forEach(function (v) { count[v] = 0; });
var showBars = Boolean(content); var showBars = Boolean(content);
Object.keys(answers).forEach(function (author) { Object.keys(answers).forEach(function (author) {
var obj = answers[author]; var obj = answers[author];
@ -1674,7 +1687,11 @@ define([
var answer = obj.msg[uid]; var answer = obj.msg[uid];
if (!answer || !Object.keys(answer).length) { return empty++; } if (!answer || !Object.keys(answer).length) { return empty++; }
Object.keys(answer).forEach(function (q_uid) { Object.keys(answer).forEach(function (q_uid) {
var c = count[q_uid] = count[q_uid] || {}; var c = count[q_uid];
if (!c) {
count[q_uid] = c = {};
(opts.values || []).forEach(function (v) { c[v] = 0; });
}
var res = answer[q_uid]; var res = answer[q_uid];
if (res && typeof(res) === "string") { res = [res]; } if (res && typeof(res) === "string") { res = [res]; }
if (!Array.isArray(res) || !res.length) { return; } if (!Array.isArray(res) || !res.length) { return; }
@ -1837,6 +1854,7 @@ define([
//var results = []; //var results = [];
var empty = 0; var empty = 0;
var count = {}; var count = {};
(opts.values || []).forEach(function (v) { count[v] = 0; });
var showBars = Boolean(content); var showBars = Boolean(content);
Object.keys(answers).forEach(function (author) { Object.keys(answers).forEach(function (author) {
var obj = answers[author]; var obj = answers[author];

Loading…
Cancel
Save