Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #61 from torchbox/feature/add-different-label-for-…
Browse files Browse the repository at this point in the history
…checkboxes-skip-logic-stream-block

Change "Skip Logic" block label to "Choice" for "checkboxes"
  • Loading branch information
nathanbegbie committed Nov 24, 2017
2 parents 7131b3d + ee12086 commit 1c2db84
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion molo/surveys/static/js/blocks/skiplogic_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 1c2db84

Please sign in to comment.