From 6d032a5932319e5ed82e03891dfc7be8902cc161 Mon Sep 17 00:00:00 2001 From: Xander Date: Wed, 19 Apr 2023 22:52:42 +0200 Subject: [PATCH] Fixes bugs --- app/assets/javascripts/registrations.js | 6 +++--- app/views/registrations/_form.html.erb | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/registrations.js b/app/assets/javascripts/registrations.js index 9ac4ca91..61aaeb1c 100644 --- a/app/assets/javascripts/registrations.js +++ b/app/assets/javascripts/registrations.js @@ -41,7 +41,7 @@ $(document).on('turbolinks:load', function() { const hidePaymentInfoIfNeeded = function(value) { const val = parseInt(value); - if (window.freeTickets && (window.freeTickets.indexOf(val) !== -1)) { + if (window.freeTickets && window.freeTickets.includes(val)) { $("#payment-info").hide(); } else { $("#payment-info").show(); @@ -50,10 +50,10 @@ $(document).on('turbolinks:load', function() { $("#registration_access_level").on('change', function() { hidePaymentInfoIfNeeded($(this).val()); - return hideCommentFieldIfNeeded($(this).val()); + hideCommentFieldIfNeeded($(this).val()); }); hidePaymentInfoIfNeeded($("#registration_access_level").val()); - return hideCommentFieldIfNeeded($("#registration_access_level").val()); + hideCommentFieldIfNeeded($("#registration_access_level").val()); }); diff --git a/app/views/registrations/_form.html.erb b/app/views/registrations/_form.html.erb index 67dc876a..6079fd3e 100644 --- a/app/views/registrations/_form.html.erb +++ b/app/views/registrations/_form.html.erb @@ -12,9 +12,7 @@ <%= form_text_area f, :comment %> <%= javascript_tag do %> window.ticketsWithComments = <%= @event.access_levels.find_all(&:has_comment).map(&:id).to_json %> - window.freeTickets = <%= @event.access_levels.find_all{|_| :price == 0}.map(&:id).to_json %> - access_levels = <%= @event.access_levels.find_all{|_| true}.to_json %> - console.log("poop") + window.freeTickets = <%= @event.access_levels.where(price: 0).map(&:id).to_json %> <% end %> <%= f.submit "Register", class: 'btn btn-group btn-primary' %> <% end %> @@ -24,4 +22,4 @@ Payments can be done by bank transfer, not by credit card. - \ No newline at end of file +