From ee12086b342c3adcf201f147f32fab647b4bb57f Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Fri, 24 Nov 2017 10:16:09 +0000 Subject: [PATCH] Change "Skip Logic" block label to "Choice" for "checkboxes" --- molo/surveys/static/js/blocks/skiplogic_stream.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/molo/surveys/static/js/blocks/skiplogic_stream.js b/molo/surveys/static/js/blocks/skiplogic_stream.js index 86aa4ca..7431a00 100644 --- a/molo/surveys/static/js/blocks/skiplogic_stream.js +++ b/molo/surveys/static/js/blocks/skiplogic_stream.js @@ -13,15 +13,18 @@ question.questionSelectors = () => question.find('[id$="-question_1"]'); question.questionSelectors = () => question.find('[id$="-question_1"]'); question.answerHelpText = () => question.choices().find('.help'); + question.addBlockLabel = () => question.find('.action-add-block-skip_logic').children('span'); question.filterSelectors = sortOrder => question.questionSelectors().find(`option[value=${sortOrder}]`); question.hasSelected = sortOrder => { return question.questionSelectors().filter(':visible').is( function(index, element) { return $(element).val() == sortOrder; } ); }; + question.setAddBlockLabel = newLabel => question.addBlockLabel().text(newLabel); return question; }; + window.question = function(id) { this.fieldID = id; return addHelperMethods(questionSelector(this.fieldID)); @@ -50,11 +53,20 @@ } else { showChoices(duration); }; - if (thisQuestion.fieldSelect().val() == 'checkbox') { + // Set the help text for "checkbox" + if (thisQuestion.fieldSelect().val() === 'checkbox') { thisQuestion.answerHelpText().show(); } else { thisQuestion.answerHelpText().hide(); } + // Set the label for the stream field add block for "checkboxes". + // Set it to "choice" since there's no skip logic setting and + // calling it skip logic has a little sense. + if (thisQuestion.fieldSelect().val() === 'checkboxes') { + thisQuestion.setAddBlockLabel('Choice') + } else { + thisQuestion.setAddBlockLabel('Skip Logic') + } }; var shouldHide = function () {