diff --git a/www/form/app-form.less b/www/form/app-form.less index d763ed204..1cc538708 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -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 { max-width: 1000px; min-width: 300px; @@ -393,7 +400,6 @@ } } .cp-form-block-content { - overflow-x: auto; p { a { color: @cryptpad_color_link; @@ -559,6 +565,11 @@ align-items: center; justify-content: center; flex: 1; + .cp-form-submit-actions { + button:not(:last-child) { + margin-right: 10px; + } + } } div.cp-form-creator-results { display: flex; diff --git a/www/form/inner.js b/www/form/inner.js index f1ad9d89d..ad39af67f 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -157,7 +157,7 @@ define([ h('span', Messages.form_textType), typeSelect[0] ]); - typeSelect.onChange.reg(evOnSave.fire()); + typeSelect.onChange.reg(evOnSave.fire); } setCursorGetter(function () { @@ -2176,7 +2176,8 @@ define([ }; 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('span.cp-button-name', Messages.form_results) ])); @@ -2190,20 +2191,20 @@ define([ $('body').addClass('cp-app-form-results'); renderResults(content, answers); $res.remove(); - var $editor = $(h('button.cp-toolbar-appmenu', [ + var $editor = $(h('button.btn.btn-primary', [ 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 () { $('body').removeClass('cp-app-form-results'); $editor.remove(); 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 @@ -2213,7 +2214,7 @@ define([ var $formContainer = $('div.cp-form-creator-content').hide(); 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', [ viewOnly ? h('i.fa.fa-bar-chart') : h('i.fa.fa-pencil'), h('span', viewOnly ? Messages.form_viewAnswer : Messages.form_editAnswer) @@ -2238,7 +2239,10 @@ define([ // If responses are public, show button to view them var responses; 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 () { var sframeChan = framework._.sfCommon.getSframeChannel(); sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) { @@ -2387,10 +2391,7 @@ define([ } evOnChange.fire(false, true); window.onbeforeunload = undefined; - if (!update && content.answers.privateKey) { - // Add results button - addResultsButton(framework, content); - } + $send.removeAttr('disabled'); //UI.alert(Messages.form_sent); // XXX not needed anymore? $send.text(Messages.form_update); @@ -2509,7 +2510,7 @@ define([ 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(); sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) { var answers = obj && obj.results; @@ -3073,10 +3074,11 @@ define([ var $toolbarContainer = $('#cp-toolbar'); - if (APP.isEditor || priv.form_auditorKey) { - var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']); - $toolbarContainer.after(helpMenu.menu); - framework._.toolbar.$drawer.append(helpMenu.button); + var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']); + $toolbarContainer.after(helpMenu.menu); + 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); @@ -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 var resultsType = h('div.cp-form-results-type-container'); var $results = $(resultsType); @@ -3618,9 +3620,6 @@ define([ // If we have a non-anon answer, we can't answer anonymously later if (answers[curve1]) { APP.cantAnon = true; } - // Add results button - if (myAnswers) { addResultsButton(framework, content); } - updateForm(framework, content, false, myAnswers); }); return; @@ -3648,9 +3647,6 @@ define([ APP.hasAnswered = true; // If we have a non-anon answer, we can't answer anonymously later if (!obj._isAnon) { APP.cantAnon = true; } - - // Add results button - if (content.answers.privateKey) { addResultsButton(framework, content); } } checkIntegrity(false); updateForm(framework, content, false, answers);