From 581988240a8b2bc33f44b0981474d2cc7f202fdd Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 3 Sep 2021 12:43:47 +0200 Subject: [PATCH] Redirect to submit page when updating responses --- www/form/inner.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/www/form/inner.js b/www/form/inner.js index f48ba2b83..5689500cc 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2069,7 +2069,7 @@ define([ }; var renderResults = APP.renderResults = function (content, answers, showUser) { - var $container = $('div.cp-form-creator-results').empty(); + var $container = $('div.cp-form-creator-results').empty().css('display', ''); var answerCount = Object.keys(answers || {}).length; @@ -2286,11 +2286,18 @@ 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 $resContainer = $('div.cp-form-creator-results').hide(); var $container = $('div.cp-form-creator-answered').empty().css('display', ''); + if (APP.answeredInForm) { + $container.hide(); + $formContainer.css('display', ''); + } else if (APP.answeredInResponses) { + $container.hide(); + $resContainer.css('display', ''); + } + 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'), @@ -2300,6 +2307,7 @@ define([ $(action).click(function () { $formContainer.css('display', ''); $container.hide(); + APP.answeredInForm = true; if (viewOnly) { $formContainer.find('.cp-form-send-container .cp-open').hide(); if (Array.isArray(APP.formBlocks)) { @@ -2329,6 +2337,7 @@ define([ }); $(responses).click(function () { sframeChan.query("Q_FORM_FETCH_ANSWERS", content.answers, function (err, obj) { + APP.answeredInResponses = true; var answers = obj && obj.results; if (answers) { APP.answers = answers; } $('body').addClass('cp-app-form-results'); @@ -2593,6 +2602,7 @@ define([ //UI.alert(Messages.form_sent); // XXX not needed anymore? $send.text(Messages.form_update); APP.hasAnswered = true; + APP.answeredInForm = false; showAnsweredPage(framework, content, { '_time': +new Date() }); if (content.answers.cantEdit) { $cbox.hide();