From 9068c624eee3b54446ce94e6d93880f8d2b774dd Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 14 Jun 2021 10:33:00 +0200 Subject: [PATCH 1/4] Fix form favicon --- www/common/notify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/notify.js b/www/common/notify.js index ac8461104..d289d6da8 100644 --- a/www/common/notify.js +++ b/www/common/notify.js @@ -1,7 +1,7 @@ define(['/api/config'], function (ApiConfig) { var Module = {}; - var apps = ['code', 'slide', 'pad', 'kanban', 'whiteboard', 'sheet', 'poll', 'teams']; + var apps = ['code', 'slide', 'pad', 'kanban', 'whiteboard', 'sheet', 'poll', 'teams', 'form']; var app = window.location.pathname.slice(1, -1); // remove "/" at the beginnin and the end var suffix = apps.indexOf(app) !== -1 ? '-'+app : ''; From 369567d5094ca61c55328934a967530b3611174f Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 14 Jun 2021 10:47:32 +0200 Subject: [PATCH 2/4] Fix onbeforeunload after submititng a form --- www/form/inner.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/form/inner.js b/www/form/inner.js index fda6bbf38..5dcc5f3b5 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -1949,6 +1949,7 @@ define([ console.error(err || data.error); return void UI.warn(Messages.error); } + evOnChange.fire(false, true); window.onbeforeunload = undefined; if (!update) { // Add results button @@ -2029,9 +2030,13 @@ define([ var _answers = Util.clone(answers || {}); delete _answers._proof; delete _answers._userdata; - evOnChange.reg(function (noBeforeUnload) { + evOnChange.reg(function (noBeforeUnload, isSave) { if (noBeforeUnload) { return; } var results = getFormResults(); + if (isSave) { + answers = Util.clone(results || {}); + _answers = Util.clone(answers); + } if (!answers || Sortify(_answers) !== Sortify(results)) { window.onbeforeunload = function () { return true; From e7a85d576b092e9b70edf021d6cfce22cb976300 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 14 Jun 2021 10:50:30 +0200 Subject: [PATCH 3/4] Fix block numbering in forms --- www/form/inner.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/form/inner.js b/www/form/inner.js index 5dcc5f3b5..b398261ec 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2152,6 +2152,9 @@ define([ h('span.cp-form-block-question-number', (n++)+'.'), h('span', block.q || Messages.form_default) ]); + // Static blocks don't have questions ("q" is not used) so we can decrement n + if (isStatic) { n--; } + var editButtons, editContainer; APP.formBlocks.push(data); From 886b798bc3e39786fd1070917f16f04920d1942b Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 14 Jun 2021 15:59:15 +0530 Subject: [PATCH 4/4] describe intended usage of poll options in forms --- www/form/app-form.less | 2 +- www/form/inner.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index e79c4f78d..115bbf3e9 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -531,7 +531,7 @@ } } } - .cp-form-sort-hint { + .cp-form-sort-hint, .cp-poll-hint { margin-bottom: 10px; } .cp-form-type-sort { diff --git a/www/form/inner.js b/www/form/inner.js index 93258afe3..cc9ddc98f 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -905,6 +905,9 @@ define([ icon: h('i.cptools.cptools-form-page-break') }, }; + + Messages.form_poll_hint = ": Yes, : No, : Acceptable"; // XXX + var TYPES = { input: { defaultOpts: { @@ -1580,7 +1583,21 @@ define([ var total = makePollTotal(answers, opts, addLine, evOnChange); if (total) { lines.push(h('div', total)); } - var tag = h('div.cp-form-type-poll-container', h('div.cp-form-type-poll', lines)); + var pollHint = UI.setHTML(h('div.cp-form-poll-hint'), Messages.form_poll_hint); + var classes = [ + 'fa fa-check cp-yes', + 'fa fa-times cp-no', + 'cptools cptools-form-poll-maybe cp-maybe', + ]; + $(pollHint).find('i').each(function (index) { + this.setAttribute('class', classes[index]); + // XXX accessibility options? + }); + + var tag = h('div.cp-form-type-poll-container', [ + pollHint, + h('div.cp-form-type-poll', lines) + ]); var $tag = $(tag); var cursorGetter;