Fix forms results with conditional sections

pull/1/head
yflory 3 years ago
commit bef8f131d9

@ -617,11 +617,11 @@ define([
return void cb({error: 'NO_SUCH_CHANNEL'}); return void cb({error: 'NO_SUCH_CHANNEL'});
} }
var proxy = ctx.store.proxy; var proxy = ctx.store.proxy || {};
var msg = [Types.message, proxy.curvePublic, +new Date(), payload]; var msg = [Types.message, proxy.curvePublic, +new Date(), payload];
if (!channel.isFriendChat) { if (!channel.isFriendChat) {
var name = proxy[Constants.displayNameKey] || var name = proxy[Constants.displayNameKey] ||
Messages.anonymous + '#' + proxy.uid.slice(0,5); Messages.anonymous + '#' + (proxy.uid || ctx.store.noDriveUid).slice(0,5);
msg.push(name); msg.push(name);
} }
var msgStr = JSON.stringify(msg); var msgStr = JSON.stringify(msg);

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

@ -2628,7 +2628,7 @@ define([
var $results = $(results).appendTo($container); var $results = $(results).appendTo($container);
$(exportButton).click(function () { $(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); } if (!csv) { return void UI.warn(Messages.error); }
var suggestion = APP.framework._.title.suggestTitle('cryptpad-document'); var suggestion = APP.framework._.title.suggestTitle('cryptpad-document');
var title = Util.fixFileName(suggestion) + '.csv'; var title = Util.fixFileName(suggestion) + '.csv';
@ -2645,7 +2645,7 @@ define([
]); ]);
$(export2Button).appendTo($controls); $(export2Button).appendTo($controls);
$(export2Button).click(function () { $(export2Button).click(function () {
var arr = Exporter.results(content, answers, TYPES, true); var arr = Exporter.results(content, answers, TYPES, getFullOrder(content), true);
if (!arr) { return void UI.warn(Messages.error); } if (!arr) { return void UI.warn(Messages.error); }
var sframeChan = framework._.sfCommon.getSframeChannel(); var sframeChan = framework._.sfCommon.getSframeChannel();
var title = framework._.title.title || framework._.title.defaultTitle; var title = framework._.title.title || framework._.title.defaultTitle;
@ -2662,7 +2662,8 @@ define([
$controls.hide().append(switchMode); $controls.hide().append(switchMode);
var show = function (answers, header) { 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 block = form[uid];
var type = block.type; var type = block.type;
var model = TYPES[type]; var model = TYPES[type];

Loading…
Cancel
Save