guard against type errors when exporting results as CSV

and label a hardcoded string
pull/1/head
ansuz 3 years ago
parent 0560a9a403
commit fceab00a6b

@ -1216,7 +1216,7 @@ define([
return h('div.cp-form-results-type-radio', results); return h('div.cp-form-results-type-radio', results);
}, },
exportCSV: function (answer, form) { exportCSV: function (answer, form) {
var opts = form.opts; var opts = form.opts || {};
var q = form.q || Messages.form_default; var q = form.q || Messages.form_default;
if (answer === false) { if (answer === false) {
return (opts.items || []).map(function (obj) { return (opts.items || []).map(function (obj) {
@ -1444,7 +1444,7 @@ define([
return h('div.cp-form-results-type-radio', results); return h('div.cp-form-results-type-radio', results);
}, },
exportCSV: function (answer, form) { exportCSV: function (answer, form) {
var opts = form.opts; var opts = form.opts || {};
var q = form.q || Messages.form_default; var q = form.q || Messages.form_default;
if (answer === false) { if (answer === false) {
return (opts.items || []).map(function (obj) { return (opts.items || []).map(function (obj) {
@ -1701,7 +1701,7 @@ define([
var controls = h('div.cp-form-creator-results-controls'); var controls = h('div.cp-form-creator-results-controls');
var $controls = $(controls).appendTo($container); var $controls = $(controls).appendTo($container);
Messages.form_exportCSV = "Export results as CSV"; Messages.form_exportCSV = "Export results as CSV"; // XXX
var exportButton = h('button.btn.btn-secondary', Messages.form_exportCSV); var exportButton = h('button.btn.btn-secondary', Messages.form_exportCSV);
var exportCSV = h('div.cp-form-creator-results-export', exportButton); var exportCSV = h('div.cp-form-creator-results-export', exportButton);
$(exportCSV).appendTo($container); $(exportCSV).appendTo($container);

Loading…
Cancel
Save