Forms V2 fixes

pull/1/head
yflory 3 years ago
parent 669297db4c
commit d2b24e666d

@ -165,6 +165,13 @@
} }
} }
} }
div.cp-form-creator-results {
.cp-form-block {
.cp-form-block-content {
overflow-x: auto;
}
}
}
div.cp-form-creator-content, div.cp-form-creator-results { div.cp-form-creator-content, div.cp-form-creator-results {
max-width: 1000px; max-width: 1000px;
min-width: 300px; min-width: 300px;
@ -393,7 +400,6 @@
} }
} }
.cp-form-block-content { .cp-form-block-content {
overflow-x: auto;
p { p {
a { a {
color: @cryptpad_color_link; color: @cryptpad_color_link;
@ -559,6 +565,11 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex: 1; flex: 1;
.cp-form-submit-actions {
button:not(:last-child) {
margin-right: 10px;
}
}
} }
div.cp-form-creator-results { div.cp-form-creator-results {
display: flex; display: flex;

@ -157,7 +157,7 @@ define([
h('span', Messages.form_textType), h('span', Messages.form_textType),
typeSelect[0] typeSelect[0]
]); ]);
typeSelect.onChange.reg(evOnSave.fire()); typeSelect.onChange.reg(evOnSave.fire);
} }
setCursorGetter(function () { setCursorGetter(function () {
@ -2176,7 +2176,8 @@ define([
}; };
var addResultsButton = function (framework, content) { var addResultsButton = function (framework, content) {
var $res = $(h('button.cp-toolbar-appmenu.cp-toolbar-form-button', [ var $container = $('.cp-forms-results-participant');
var $res = $(h('button.btn.btn-primary.cp-toolbar-form-button', [
h('i.fa.fa-bar-chart'), h('i.fa.fa-bar-chart'),
h('span.cp-button-name', Messages.form_results) h('span.cp-button-name', Messages.form_results)
])); ]));
@ -2190,20 +2191,20 @@ define([
$('body').addClass('cp-app-form-results'); $('body').addClass('cp-app-form-results');
renderResults(content, answers); renderResults(content, answers);
$res.remove(); $res.remove();
var $editor = $(h('button.cp-toolbar-appmenu', [ var $editor = $(h('button.btn.btn-primary', [
h('i.fa.fa-pencil'), h('i.fa.fa-pencil'),
h('span.cp-button-name', APP.isEditor ? Messages.form_editor : Messages.form_form) h('span.cp-button-name', Messages.form_editor)
])); ]));
$editor.click(function () { $editor.click(function () {
$('body').removeClass('cp-app-form-results'); $('body').removeClass('cp-app-form-results');
$editor.remove(); $editor.remove();
addResultsButton(framework, content); addResultsButton(framework, content);
}); });
framework._.toolbar.$bottomL.append($editor); $container.prepend($editor);
}); });
}); });
framework._.toolbar.$bottomL.append($res); $container.prepend($res);
}; };
Messages.form_alreadyAnswered = "You've responded to this form on {0}"; // XXX Messages.form_alreadyAnswered = "You've responded to this form on {0}"; // XXX
@ -2213,7 +2214,7 @@ define([
var $formContainer = $('div.cp-form-creator-content').hide(); var $formContainer = $('div.cp-form-creator-content').hide();
var $container = $('div.cp-form-creator-answered').empty().css('display', ''); var $container = $('div.cp-form-creator-answered').empty().css('display', '');
var viewOnly = content.answers.cantEdit; var viewOnly = content.answers.cantEdit || APP.isClosed;
var action = h('button.btn.btn-primary', [ var action = h('button.btn.btn-primary', [
viewOnly ? h('i.fa.fa-bar-chart') : h('i.fa.fa-pencil'), viewOnly ? h('i.fa.fa-bar-chart') : h('i.fa.fa-pencil'),
h('span', viewOnly ? Messages.form_viewAnswer : Messages.form_editAnswer) h('span', viewOnly ? Messages.form_viewAnswer : Messages.form_editAnswer)
@ -2238,7 +2239,10 @@ define([
// If responses are public, show button to view them // If responses are public, show button to view them
var responses; var responses;
if (content.answers.privateKey) { if (content.answers.privateKey) {
responses = h('button.btn.btn-default', Messages.form_results); responses = h('button.btn.btn-default', [
h('i.fa.fa-bar-chart'),
h('span.cp-button-name', Messages.form_results)
]);
$(responses).click(function () { $(responses).click(function () {
var sframeChan = framework._.sfCommon.getSframeChannel(); var sframeChan = framework._.sfCommon.getSframeChannel();
sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) { sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) {
@ -2387,10 +2391,7 @@ define([
} }
evOnChange.fire(false, true); evOnChange.fire(false, true);
window.onbeforeunload = undefined; window.onbeforeunload = undefined;
if (!update && content.answers.privateKey) {
// Add results button
addResultsButton(framework, content);
}
$send.removeAttr('disabled'); $send.removeAttr('disabled');
//UI.alert(Messages.form_sent); // XXX not needed anymore? //UI.alert(Messages.form_sent); // XXX not needed anymore?
$send.text(Messages.form_update); $send.text(Messages.form_update);
@ -2509,7 +2510,7 @@ define([
APP.formBlocks = []; APP.formBlocks = [];
if (APP.isClosed && content.answers.privateKey && !APP.isEditor) { if (APP.isClosed && content.answers.privateKey && !APP.isEditor && !APP.hasAnswered) {
var sframeChan = framework._.sfCommon.getSframeChannel(); var sframeChan = framework._.sfCommon.getSframeChannel();
sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) { sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) {
var answers = obj && obj.results; var answers = obj && obj.results;
@ -3073,10 +3074,11 @@ define([
var $toolbarContainer = $('#cp-toolbar'); var $toolbarContainer = $('#cp-toolbar');
if (APP.isEditor || priv.form_auditorKey) { var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']);
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']); $toolbarContainer.after(helpMenu.menu);
$toolbarContainer.after(helpMenu.menu); framework._.toolbar.$drawer.append(helpMenu.button);
framework._.toolbar.$drawer.append(helpMenu.button); if (!APP.isEditor && !priv.form_auditorKey) {
$(helpMenu.menu).hide();
} }
var offlineEl = h('div.alert.alert-danger.cp-burn-after-reading', Messages.disconnected); var offlineEl = h('div.alert.alert-danger.cp-burn-after-reading', Messages.disconnected);
@ -3126,7 +3128,7 @@ define([
}); });
}); });
Messages.form_makePublicWarning = "Are you sure you want to make responses to this form public? Past and future responses will be visible by participants. This cannot be undone." // XXX existing key Messages.form_makePublicWarning = "Are you sure you want to make responses to this form public? Past and future responses will be visible by participants. This cannot be undone."; // XXX existing key
// Private / public status // Private / public status
var resultsType = h('div.cp-form-results-type-container'); var resultsType = h('div.cp-form-results-type-container');
var $results = $(resultsType); var $results = $(resultsType);
@ -3618,9 +3620,6 @@ define([
// If we have a non-anon answer, we can't answer anonymously later // If we have a non-anon answer, we can't answer anonymously later
if (answers[curve1]) { APP.cantAnon = true; } if (answers[curve1]) { APP.cantAnon = true; }
// Add results button
if (myAnswers) { addResultsButton(framework, content); }
updateForm(framework, content, false, myAnswers); updateForm(framework, content, false, myAnswers);
}); });
return; return;
@ -3648,9 +3647,6 @@ define([
APP.hasAnswered = true; APP.hasAnswered = true;
// If we have a non-anon answer, we can't answer anonymously later // If we have a non-anon answer, we can't answer anonymously later
if (!obj._isAnon) { APP.cantAnon = true; } if (!obj._isAnon) { APP.cantAnon = true; }
// Add results button
if (content.answers.privateKey) { addResultsButton(framework, content); }
} }
checkIntegrity(false); checkIntegrity(false);
updateForm(framework, content, false, answers); updateForm(framework, content, false, answers);

Loading…
Cancel
Save