From cf7593553bbe8ed980611c29830cb1c44e1d4001 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 18 Aug 2021 14:46:56 +0530 Subject: [PATCH] polish and re-enable form response messages --- www/form/app-form.less | 9 ++++++++- www/form/inner.js | 24 +++++++++++++++++------- www/form/main.js | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 781b8161d..53acb92af 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -440,7 +440,6 @@ } } .cp-form-edit-block { - button.btn-secondary { margin-left: 30px; margin-bottom: 5px; @@ -487,6 +486,9 @@ p:last-child { margin-bottom: 0; } + * { + max-width: 100%; + } } .cp-form-creator-results-controls { @@ -832,6 +834,11 @@ color: @cp_form-poll-yes-color; } } + .cp-form-response-modal { + .CodeMirror { + border: 1px solid @cp_forms-border; + } + } .charts_main(); } diff --git a/www/form/inner.js b/www/form/inner.js index ad89ada26..ec329830f 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2702,7 +2702,6 @@ define([ var responseMsg = h('div.cp-form-response-msg-container'); var $responseMsg = $(responseMsg); var refreshResponse = function () { - if (true) { return; } // XXX 4.11.0 $responseMsg.empty(); Messages.form_updateMsg = "Update response message"; // XXX 4.11.0 Messages.form_addMsg = "Add response message"; // XXX 4.11.0 @@ -2713,12 +2712,23 @@ define([ var editor; if (!APP.responseModal) { var t = h('textarea'); + var p = h('p', Messages.form_responseMsg); var div = h('div', [ - h('p', Messages.form_responseMsg), - t + p, + h('div.cp-form-response-modal', t), ]); - var cm = SFCodeMirror.create("gfm", CMeditor, t); + var cm = window.my_cm = SFCodeMirror.create("gfm", CMeditor, t); editor = APP.responseEditor = cm.editor; + var markdownTb = APP.common.createMarkdownToolbar(editor, { + embed: function (mt) { + editor.focus(); + editor.replaceSelection($(mt)[0].outerHTML); + } + }); + $(markdownTb.toolbar).insertAfter($(p)); + $(markdownTb.toolbar).show(); + + cm.configureTheme(APP.common, function () {}); editor.setOption('lineNumbers', true); editor.setOption('lineWrapping', true); editor.setOption('styleActiveLine', true); @@ -2735,7 +2745,7 @@ define([ name: Messages.settings_save, onClick: function () { var v = editor.getValue(); - content.answers.msg = v.trim(0, 2000); // XXX 4.11.0 max length? + content.answers.msg = v.slice(0, 2000); // XXX 4.11.0 max length? framework.localChange(); framework._.cpNfInner.chainpad.onSettle(function () { UI.log(Messages.saved); @@ -2761,9 +2771,9 @@ define([ } UI.openCustomModal(APP.responseModal); }); - // $responseMsg.append(btn); // XXX 4.11.0 + $responseMsg.append(btn); }; - //refreshResponse(); + refreshResponse(); // Allow anonymous answers var privacyContainer = h('div.cp-form-privacy-container'); diff --git a/www/form/main.js b/www/form/main.js index b82397caf..9a017fbe1 100644 --- a/www/form/main.js +++ b/www/form/main.js @@ -176,7 +176,7 @@ define([ validateKey: keys.secondaryValidateKey, owners: [myKeys.edPublic], crypto: crypto, - //Cache: Utils.Cache // XXX 4.11.0 + //Cache: Utils.Cache // TODO enable cache for form responses when the cache stops evicting old answers }; var results = {}; config.onError = function (info) {