Skip to content

Commit

Permalink
simplify changes to honeycrisp
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotondo committed Nov 7, 2024
1 parent 892e5b6 commit 3fe82bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
26 changes: 5 additions & 21 deletions app/javascript/lib/honeycrisp.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,32 +118,16 @@ var followUpQuestion = (function () {
});
},
update: function ($container) {
let reset_other_follow_ups = $container.attr('data-reset-other-follow-ups') !== "false";
let hide_other_follow_ups = $container.attr('data-hide-other-follow-ups') !== "false";

// reset follow ups
if (reset_other_follow_ups) {
$container.find('.question-with-follow-up__follow-up input').attr('disabled', true);
}

if (hide_other_follow_ups) {
console.log("hiding followups");
$container.find('.question-with-follow-up__follow-up').hide();
}
$container.find('.question-with-follow-up__follow-up input').attr('disabled', true);
$container.find('.question-with-follow-up__follow-up').hide();

$container.find('.question-with-follow-up__question input').each(function (index, input) {
// if any of the inputs with a data-follow-up is checked then show the follow-up
if ($(input).attr('data-follow-up') != null) {
if ($(input).is(':checked') && $(input).attr('data-follow-up') != null) {
var followUpSelector = $(this).attr('data-follow-up');
if (/^[a-zA-Z0-9_\-#\.]+$/.test(followUpSelector)) {
if ($(input).is(':checked')) {
console.log("showing " + followUpSelector);
$(followUpSelector).show();
$(followUpSelector).find('input').attr('disabled', false);
} else {
$(followUpSelector).hide();
$(followUpSelector).find('input').attr('disabled', true);
}
$(followUpSelector).show();
$(followUpSelector).find('input').attr('disabled', false);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<%= form_with model: @form, url: { action: :update }, method: :put, local: true, builder: VitaMinFormBuilder, class: 'form-card' do |f| %>

<div class="question-with-follow-up spacing-below-25" data-reset-other-follow-ups="false">
<div class="question-with-follow-up spacing-below-25">
<div class="question-with-follow-up__question">
<div class="white-group">
<p class="spacing-below-0"><%= t(".situations_question") %></p>
Expand Down

0 comments on commit 3fe82bc

Please sign in to comment.