From 7f244d532f611ab06e3102f4e52ffbbea4f9aea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Benqu=C3=A9?= Date: Wed, 1 Sep 2021 16:11:50 +0100 Subject: [PATCH 01/11] Style required question submit error --- www/form/app-form.less | 4 ++++ www/form/inner.js | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 06d559c85..5bc46a085 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -308,6 +308,10 @@ color: @cryptpad_color_link; } } + .alert-danger { + font-size: 1rem; + padding: 10px; + } } .cp-form-anon-answer { text-align: center; diff --git a/www/form/inner.js b/www/form/inner.js index 85c3c0bfd..8bdd1296a 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2500,8 +2500,10 @@ define([ }); var list = h('ul', lis); var divContent = [ - h('span', Messages.form_requiredWarning), - list + h('div.alert.alert-danger', [ + Messages.form_requiredWarning, + list + ]) ]; $errors.empty().append(divContent); }); From 258ccd4e60b7a49ea086a32c127f3c59b6e4319a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Benqu=C3=A9?= Date: Wed, 1 Sep 2021 16:19:43 +0100 Subject: [PATCH 02/11] Use default button for Responses/Editor --- www/form/inner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/form/inner.js b/www/form/inner.js index 8bdd1296a..7eb2d8fc2 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2184,7 +2184,7 @@ define([ var addResultsButton = function (framework, content, answers) { var $container = $('.cp-forms-results-participant'); var l = getAnswersLength(answers); - var $res = $(h('button.btn.btn-primary.cp-toolbar-form-button', [ + var $res = $(h('button.btn.btn-default.cp-toolbar-form-button', [ h('i.fa.fa-bar-chart'), h('span.cp-button-name', Messages._getKey('form_results', [l])), ])); @@ -2198,7 +2198,7 @@ define([ $('body').addClass('cp-app-form-results'); renderResults(content, answers); $res.remove(); - var $editor = $(h('button.btn.btn-primary', [ + var $editor = $(h('button.btn.btn-default', [ h('i.fa.fa-pencil'), h('span.cp-button-name', Messages.form_editor) ])); From bcd4d88f8112304ee87d295af14ac1901f026e09 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 1 Sep 2021 17:25:16 +0200 Subject: [PATCH 03/11] Fix reordering questions in forms --- www/form/inner.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/form/inner.js b/www/form/inner.js index 85c3c0bfd..e1e719534 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2987,6 +2987,7 @@ define([ updateAddInline(); if (editable) { + if (APP.mainSortable) { APP.mainSortable.destroy(); } APP.mainSortable = Sortable.create($container[0], { direction: "vertical", filter: "input, button, .CodeMirror, .cp-form-type-sort, .cp-form-block-type.editable", From 15eeaa75f65e95ab44a88032e2e501b46487200c Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 1 Sep 2021 17:32:55 +0200 Subject: [PATCH 04/11] Add logo to the submit page --- www/form/app-form.less | 5 +++++ www/form/inner.js | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 5bc46a085..2a1533268 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -581,11 +581,16 @@ align-items: center; justify-content: center; flex: 1; + flex-flow: column; .cp-form-submit-actions { button:not(:last-child) { margin-right: 10px; } } + .cp-form-view-logo { + margin-top: 100px; + padding-bottom: 20px; + } } div.cp-form-creator-results { display: flex; diff --git a/www/form/inner.js b/www/form/inner.js index 40bc96272..75d4b47af 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2217,6 +2217,20 @@ define([ $container.prepend($res); }; + var getLogo = function () { + var logo = h('div.cp-form-view-logo', [ + h('img', { + src:'/customize/CryptPad_logo_grey.svg?'+ApiConfig.requireConf.urlArgs, + alt:'CryptPad_logo' + }), + h('span', 'CryptPad') + ]); + $(logo).click(function () { + framework._.sfCommon.gotoURL('/drive/'); + }); + return logo; + }; + Messages.form_alreadyAnswered = "You've responded to this form on {0}"; // XXX Messages.form_editAnswer = "Edit my responses"; // XXX Messages.form_viewAnswer = "View my responses"; // XXX @@ -2290,6 +2304,7 @@ define([ new Date(APP.lastAnswerTime).toLocaleString()])), actions ])); + $container.append(getLogo()); }; var getFormResults = function () { @@ -3047,17 +3062,7 @@ define([ // at the bottom var title = framework._.title.title || framework._.title.defaultTitle; $container.prepend(h('h1.cp-form-view-title', title)); - var logo = h('div.cp-form-view-logo', [ - h('img', { - src:'/customize/CryptPad_logo_grey.svg?'+ApiConfig.requireConf.urlArgs, - alt:'CryptPad_logo' - }), - h('span', 'CryptPad') - ]); - $(logo).click(function () { - framework._.sfCommon.gotoURL('/drive/'); - }); - $container.append(logo); + $container.append(getLogo()); if (!answers) { $container.find('.cp-reset-button').attr('disabled', 'disabled'); From cfa4a2708dd831ef0dab726ad6c8b3f0e2ba4ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Benqu=C3=A9?= Date: Wed, 1 Sep 2021 16:42:28 +0100 Subject: [PATCH 05/11] Truncate response chart option values + add full option as tooltip --- www/form/app-form.less | 5 ++++- www/form/inner.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 5bc46a085..45c075f8a 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -673,7 +673,10 @@ & > span { .cp-form-results-cell(); &.cp-value { - min-width: 200px; + max-width: 200px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } &.cp-bar-container { width: 99%; diff --git a/www/form/inner.js b/www/form/inner.js index 7eb2d8fc2..296d8b79c 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -1020,7 +1020,7 @@ define([ var itemScale = (itemCount / max); rows.push(h('div.cp-form-results-type-radio-data', [ - h('span.cp-value', value), + h('span.cp-value', {'title': value}, value), h('span.cp-count', itemCount), showBar? barGraphic(itemScale): undefined, ])); From ab79f32055f6e45912b7dda0545ce5a9b0743c13 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 1 Sep 2021 17:44:40 +0200 Subject: [PATCH 06/11] Fix forms issues --- www/form/inner.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/form/inner.js b/www/form/inner.js index 75d4b47af..d04baa3f7 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2235,6 +2235,8 @@ define([ Messages.form_editAnswer = "Edit my responses"; // XXX Messages.form_viewAnswer = "View my responses"; // XXX var showAnsweredPage = function (framework, content, answers) { + if (APP.submitPage) { return; } + APP.submitPage = true; var $formContainer = $('div.cp-form-creator-content').hide(); var $container = $('div.cp-form-creator-answered').empty().css('display', ''); From 478e95e24cbbcde50f2674eb61ebc2ff0b45cd70 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 1 Sep 2021 18:25:14 +0200 Subject: [PATCH 07/11] Fix forms charts UI --- www/form/app-form.less | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 913384c58..738909e1d 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -182,6 +182,12 @@ overflow-x: auto; } } + .cp-form-creator-results-timeline { + margin-bottom: 20px; + table.cp-charts.column { + overflow-x: initial; + } + } } div.cp-form-creator-content, div.cp-form-creator-results { max-width: 1000px; @@ -611,7 +617,6 @@ .cp-form-creator-results-controls { margin-bottom: 20px; - margin-top: 20px; //background: @cp_form-bg1; //padding: 10px; button { @@ -674,11 +679,12 @@ } .cp-form-results-type-radio-data { display: table-row; - border: 1px solid @cp_form-border; + border: 1px solid transparent; & > span { .cp-form-results-cell(); &.cp-value { max-width: 200px; + min-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -687,10 +693,14 @@ width: 99%; padding: 0px; position: relative; + background: transparent; + border-left-width: 15px; + border-right-width: 15px; .cp-bar { position: absolute; - background: @cryptpad_color_brand; - height: 100%; + background: fade(@cryptpad_text_col, 50%); + height: 50%; + top: 25%; } } } From 513c2d51fc8004c361b313170f6d701998ff4134 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 1 Sep 2021 18:26:56 +0200 Subject: [PATCH 08/11] Update logo redirect in forms --- www/form/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/form/inner.js b/www/form/inner.js index 9f09f0115..e5c4e5171 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2226,7 +2226,7 @@ define([ h('span', 'CryptPad') ]); $(logo).click(function () { - framework._.sfCommon.gotoURL('/drive/'); + APP.framework._.sfCommon.gotoURL('/'); }); return logo; }; From 2ebe2b955cb0f371c851f0b2ad6c69737a6a61d6 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 1 Sep 2021 18:29:06 +0200 Subject: [PATCH 09/11] Move submit message in the submit page --- www/form/inner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/form/inner.js b/www/form/inner.js index e5c4e5171..d2621f257 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2301,9 +2301,9 @@ define([ var title = framework._.title.title || framework._.title.defaultTitle; $container.append(h('div.cp-form-submit-success', [ h('h3.cp-form-view-title', title), - description, h('div.alert.alert-info', Messages._getKey('form_alreadyAnswered', [ new Date(APP.lastAnswerTime).toLocaleString()])), + description, actions ])); $container.append(getLogo()); From cd65bea28cf9eab0d92321f0276b3b0b75ff03f6 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 2 Sep 2021 11:00:03 +0200 Subject: [PATCH 10/11] Add 'Answer as ...' in forms --- www/form/app-form.less | 4 ++++ www/form/inner.js | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 738909e1d..d17045009 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -331,6 +331,10 @@ margin-left: 10px; } } + .cp-form-anon-answer-registered { + font-style: italic; + margin-left: 10px; + } } } diff --git a/www/form/inner.js b/www/form/inner.js index d2621f257..9dc726ee4 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2346,6 +2346,7 @@ define([ } else if (content.answers.anonymous) { // Answers aren't anonymous and guests are allowed // Guests can set a username and logged in users can answer anonymously + var $anon; if (!loggedIn) { anonName = h('div.cp-form-anon-answer-input', [ Messages.form_answerAs, @@ -2355,15 +2356,24 @@ define([ }) ]); $anonName = $(anonName).hide(); - $anonBox.on('change', function () { - if (Util.isChecked($anonBox)) { $anonName.hide(); } - else { $anonName.show(); } - }); } else if (APP.cantAnon) { // You've already answered with your credentials $cbox.hide(); $anonBox.attr('disabled', 'disabled').prop('checked', false); } + if (!anonName) { + anonName = h('div.cp-form-anon-answer-input', [ + Messages.form_answerAs, + h('span.cp-form-anon-answer-registered', user.nameĀ || Messages.anonymous) + ]); + } + if (!APP.cantAnon) { + var $anon = $(anonName).hide(); + $anonBox.on('change', function () { + if (Util.isChecked($anonBox)) { $anon.hide(); } + else { $anon.show(); } + }); + } } else { // Answers don't have to be anonymous and only logged in users can answer // ==> they have to answer with their keys so we know their name too @@ -2374,7 +2384,7 @@ define([ $cbox.after(h('div.alert.alert-info', Messages.form_authAnswer)); }); } - if (update && content.answers.cantEdit) { + if (update && content.answers.cantEdit || APP.isClosed) { $cbox.hide(); anonName = undefined; } @@ -3036,6 +3046,13 @@ define([ new Date(answers._time || APP.lastAnswerTime).toLocaleString()]))); } + if (APP.isClosed) { + APP.formBlocks.forEach(function (b) { + if (!b.setEditable) { return; } + b.setEditable(false); + }); + } + // In view mode, add "Submit" and "reset" buttons $container.append(makeFormControls(framework, content, Boolean(answers), evOnChange)); From bbd449855fcd604f0cc603db25675c221e71830b Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 2 Sep 2021 11:04:18 +0200 Subject: [PATCH 11/11] Cancel adding a closing date --- www/form/inner.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/form/inner.js b/www/form/inner.js index 9dc726ee4..f96bb6d13 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -3399,14 +3399,21 @@ define([ }); var save = h('button.btn.btn-primary', Messages.settings_save); $(save).click(function () { + if (dataPicker.value === '') { + return void refreshEndDate(); + } var d = picker.parseDate(datePicker.value); content.answers.endDate = +d; framework.localChange(); refreshEndDate(); }); + var cancel = h('button.btn.btn-danger', h('i.fa.fa-times')); + $(cancel).click(function () { + refreshEndDate(); + }); var confirmContent = h('div', [ h('div', Messages.form_setEnd), - h('div.cp-form-input-block', [datePicker, save]), + h('div.cp-form-input-block', [datePicker, save, cancel]), ]); $button.after(confirmContent); $button.remove();