Fix poll export

pull/1/head
yflory 6 years ago
parent 3e9e92dcac
commit 6397528f0f

@ -10,10 +10,18 @@ define([
}; };
module.getCSV = function (content) { module.getCSV = function (content) {
if (!APP.proxy) { return; }
var data = copyObject(content); var data = copyObject(content);
var res = ''; var res = '';
var count = {};
data.rowsOrder.forEach(function (rId) {
var c = Object.keys(data.cells)
.filter(function (k) {
return k.indexOf(rId) !== -1 && data.cells[k] === 1;
}).length;
count[rId] = c;
});
var escapeStr = function (str) { var escapeStr = function (str) {
return '"' + str.replace(/"/g, '""') + '"'; return '"' + str.replace(/"/g, '""') + '"';
}; };
@ -44,7 +52,7 @@ define([
} }
// tbody // tbody
if (!rowId) { throw new Error("Invalid data"); } if (!rowId) { throw new Error("Invalid data"); }
res += APP.count[rowId] || '?'; res += count[rowId] || '?';
res += '\n'; res += '\n';
}); });
@ -60,7 +68,7 @@ define([
var blob2 = new Blob([JSON.stringify(content, 0, 2)], { var blob2 = new Blob([JSON.stringify(content, 0, 2)], {
type: 'application/json', type: 'application/json',
}); });
return void cb(content, true); return void cb(blob2, true);
} }
var blob = new Blob([csv], {type: "application/csv;charset=utf-8"}); var blob = new Blob([csv], {type: "application/csv;charset=utf-8"});
cb(blob); cb(blob);

Loading…
Cancel
Save