Skip to content

Commit

Permalink
trying to make solution less scuffed and bug-free
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentyMcFatty authored and TomNaessens committed Mar 17, 2024
1 parent debf60d commit 2eccb32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/assets/javascripts/registrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ $(document).on('turbolinks:load', function() {
};

const hidePaymentInfoIfNeeded = function(value) {

if (value.search("€") === -1) {
const val = parseInt(value);
if (window.freeTickets && (window.freeTickets.indexOf(val) !== -1)) {
$("#payment-info").hide();
} else {
$("#payment-info").show();
}
};

$("#registration_access_level").on('change', function() {
hidePaymentInfoIfNeeded($("option:selected", this).text());
hidePaymentInfoIfNeeded($(this).val());
return hideCommentFieldIfNeeded($(this).val());
});

hidePaymentInfoIfNeeded($("#registration_access_level option:selected").text());
hidePaymentInfoIfNeeded($("#registration_access_level").val());
return hideCommentFieldIfNeeded($("#registration_access_level").val());

});
3 changes: 3 additions & 0 deletions app/views/registrations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<%= 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")
<% end %>
<%= f.submit "Register", class: 'btn btn-group btn-primary' %>
<% end %>
Expand Down

0 comments on commit 2eccb32

Please sign in to comment.