Skip to content

Commit

Permalink
Fixes bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xander committed Apr 19, 2023
1 parent 27b7f4b commit 2b3a6e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/assets/javascripts/registrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());

});
});
6 changes: 2 additions & 4 deletions app/views/registrations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -24,4 +22,4 @@
Payments can be done by bank transfer, <strong>not by credit card</strong>.
</div>

</div>
</div>

0 comments on commit 2b3a6e3

Please sign in to comment.