Apply form results to new sheet

This commit is contained in:
yflory 2021-09-24 16:31:26 +02:00
parent 3f1480a847
commit aaed6b7d77
5 changed files with 41 additions and 2 deletions

View File

@ -2268,6 +2268,7 @@ define([
var type = metadataMgr.getMetadataLazy().type || privateData.app;
var fromFileData = privateData.fromFileData;
var fromContent = privateData.fromContent;
var $body = $('body');
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
@ -2524,6 +2525,14 @@ define([
todo(res.data);
});
}
else if (fromContent) {
allData = [{
name: fromContent.title,
id: 0,
icon: h('span.cptools.cptools-poll'),
}];
redraw(0);
}
else {
redraw(0);
}

View File

@ -1440,11 +1440,16 @@ define([
// to be downloaded and decrypted before converting to xlsx
var downloadImages = {};
var firstOO = true;
startOO = function (blob, file, force) {
if (APP.ooconfig && !force) { return void console.error('already started'); }
var url = URL.createObjectURL(blob);
var lock = !APP.history && (APP.migrate);
var fromContent = metadataMgr.getPrivateData().fromContent;
if (!firstOO) { fromContent = undefined; }
firstOO = false;
// Starting from version 3, we can use the view mode again
// defined but never used
//var mode = (content && content.version > 2 && lock) ? "view" : "edit";
@ -1606,6 +1611,11 @@ define([
}
}
if (fromContent && !lock && Array.isArray(fromContent.content)) {
console.warn(fromContent);
makePatch(fromContent.content);
}
if (APP.isDownload) {
var bin = getContent();
if (!supportsXLSX()) {

View File

@ -300,6 +300,13 @@ define([
}));
};
if (sessionStorage.CP_formExportSheet && parsed.type === 'sheet') {
try {
Cryptpad.fromContent = JSON.parse(sessionStorage.CP_formExportSheet);
} catch (e) { console.error(e); }
delete sessionStorage.CP_formExportSheet;
}
// New pad options
var options = parsed.getOptions();
if (options.newPadOpts) {
@ -639,6 +646,7 @@ define([
fromFileData: Cryptpad.fromFileData ? (isOO ? Cryptpad.fromFileData : {
title: Cryptpad.fromFileData.title
}) : undefined,
fromContent: Cryptpad.fromContent,
burnAfterReading: burnAfterReading,
storeInTeam: Cryptpad.initialTeam || (Cryptpad.initialPath ? -1 : undefined),
supportsWasm: Utils.Util.supportsWasm()

View File

@ -2647,7 +2647,12 @@ define([
$(export2Button).click(function () {
var arr = Exporter.results(content, answers, TYPES, true);
if (!arr) { return void UI.warn(Messages.error); }
console.error(arr);
var sframeChan = framework._.sfCommon.getSframeChannel();
var title = framework._.title.title || framework._.title.defaultTitle;
sframeChan.event('EV_EXPORT_SHEET', {
title: title,
content: arr
});
});
var summary = true;

View File

@ -51,7 +51,14 @@ define([
Cryptpad.setPadAttribute('answersChannel', data.channel, function () {});
});
});
});
sframeChan.on('EV_EXPORT_SHEET', function (data) {
if (!data || !Array.isArray(data.content)) { return; }
sessionStorage.CP_formExportSheet = JSON.stringify(data);
var href = Utils.Hash.hashToHref('', 'sheet');
var a = window.open(href);
if (!a) { sframeChan.event('EV_POPUP_BLOCKED'); }
delete sessionStorage.CP_formExportSheet;
});
var getAnonymousKeys = function (formSeed, channel) {
var array = Nacl.util.decodeBase64(formSeed + channel);