Fix forms results with conditional sections (#799)

pull/1/head
yflory 3 years ago
parent ca95af082d
commit 04e298dd46

@ -13,14 +13,14 @@ define([
value += '"' + vv + '"';
return value;
};
Export.results = function (content, answers, TYPES) {
Export.results = function (content, answers, TYPES, order) {
if (!content || !content.form) { return; }
var csv = "";
var form = content.form;
var questions = [Messages.form_poll_time, Messages.share_formView];
content.order.forEach(function (key) {
order.forEach(function (key) {
var obj = form[key];
if (!obj) { return; }
var type = obj.type;
@ -44,7 +44,7 @@ define([
var user = msg._userdata || {};
csv += escapeCSV(time);
csv += ',' + escapeCSV(user.name || Messages.anonymous);
content.order.forEach(function (key) {
order.forEach(function (key) {
var type = form[key].type;
if (!TYPES[type]) { return; } // Ignore static types
if (TYPES[type].exportCSV) {

@ -2628,7 +2628,7 @@ define([
var $results = $(results).appendTo($container);
$(exportButton).click(function () {
var csv = Exporter.results(content, answers, TYPES);
var csv = Exporter.results(content, answers, TYPES, getFullOrder(content));
if (!csv) { return void UI.warn(Messages.error); }
var suggestion = APP.framework._.title.suggestTitle('cryptpad-document');
var title = Util.fixFileName(suggestion) + '.csv';
@ -2644,7 +2644,8 @@ define([
$controls.hide().append(switchMode);
var show = function (answers, header) {
var elements = content.order.map(function (uid) {
var order = getFullOrder(content);
var elements = order.map(function (uid) {
var block = form[uid];
var type = block.type;
var model = TYPES[type];

Loading…
Cancel
Save