From 30bd05e77bb1d0b99808b2946b4ca55e545b0665 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson <frjo@xdeb.org> Date: Tue, 28 Apr 2020 23:34:57 +0200 Subject: [PATCH] Added help text and help links to the application form copy script. --- .../javascript/apply/submission-form-copy.js | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/hypha/static_src/src/javascript/apply/submission-form-copy.js b/hypha/static_src/src/javascript/apply/submission-form-copy.js index 7b8fc2f11..9ae8f484b 100644 --- a/hypha/static_src/src/javascript/apply/submission-form-copy.js +++ b/hypha/static_src/src/javascript/apply/submission-form-copy.js @@ -15,8 +15,6 @@ $('.application-form').find('.form__group, .rich-text').each(function () { var question_text = ''; var label_text = $(this).find('.form__question').html(); - var input_text = $(this).find('input').val(); - var rich_text = $(this).find('.tinymce4-editor').val(); if (label_text) { // Get the label, i.e. question. label_text = strip(label_text); @@ -24,8 +22,34 @@ label_text = label_text.replace(/[ ]+/g, ' '); question_text = '### ' + label_text; + var help_text = $(this).find('.form__help').html(); + var $help_link = $(this).find('.form__help-link'); + var $input_list = $(this).find('.form__item > ul > li'); + var input_text = $(this).find('input').val(); + var rich_text = $(this).find('.tinymce4-editor').val(); + + // Get help text and link if any. + if (help_text) { + question_text = question_text + '\n\n' + strip(help_text); + } + if ($help_link.length !== 0) { + question_text = question_text + '\n\n' + strip($help_link.html()) + ' <' + $help_link.find('a').attr('href') + '>'; + } + // Get the user input if any. - if (input_text) { + if ($input_list.length !== 0) { + var input_list = []; + var input_item = ''; + $input_list.each(function () { + input_item = strip($(this).html()); + if ($(this).find('input').is(':checked')) { + input_item = input_item + '*'; + } + input_list.push(input_item); + }); + question_text = question_text + '\n\n' + input_list.join('\n'); + } + else if (input_text) { question_text = question_text + '\n\n' + strip(input_text); } else if (rich_text) { -- GitLab