From d269d763457e3eaa3ded4562a231e54d23006760 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Mon, 20 May 2024 15:10:43 -0700 Subject: [PATCH] Fixing checkout and bootstrap --- app/javascript/init_bootstrap.js | 2 +- app/javascript/init_popup.js | 7 ++ app/models/ticket_request.rb | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/payments/new.html.haml | 57 ++++++++---- app/views/ticket_requests/_form.html.haml | 8 +- .../_ticket_request_show.html.haml | 87 ++++++++++--------- 7 files changed, 99 insertions(+), 66 deletions(-) diff --git a/app/javascript/init_bootstrap.js b/app/javascript/init_bootstrap.js index 755d3529..a496671e 100644 --- a/app/javascript/init_bootstrap.js +++ b/app/javascript/init_bootstrap.js @@ -1,6 +1,6 @@ -import "bootstrap/dist/js/bootstrap.bundle.min"; +import "bootstrap/dist/js/bootstrap"; import * as bootstrap from "bootstrap"; diff --git a/app/javascript/init_popup.js b/app/javascript/init_popup.js index a2f8faf7..302bc1a3 100644 --- a/app/javascript/init_popup.js +++ b/app/javascript/init_popup.js @@ -1,3 +1,10 @@ +import "@popperjs"; + +import * as popover from "@popperjs/core"; + +window.popover= popover; + + // open a popup window.popupWindow = function(url, windowName, win, w, h) { const y = win.top.outerHeight / 2 + win.top.screenY - (h / 2); diff --git a/app/models/ticket_request.rb b/app/models/ticket_request.rb index 35f229bc..4f704698 100644 --- a/app/models/ticket_request.rb +++ b/app/models/ticket_request.rb @@ -320,7 +320,7 @@ def total_tickets end def guest_count - total_tickets - 1 + total_tickets end def guests_specified diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b1df48e2..5cf5dce4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,7 +8,7 @@ %link{:href => "/icons/android-chrome-192x192.png", :rel => "shortcut icon", :type => "image/png"}/ %link{:href => "https://fonts.googleapis.com", :rel => "preconnect"}/ %link{:href => "https://fonts.googleapis.com/css2?family=Dosis:wght@200..800&family=Oswald:wght@200..700&display=swap", :rel => "stylesheet"}/ - %script{src: "https://js.stripe.com/v3/", crossorigin: "anonymous"} + %script{src: "https://js.stripe.com/v3/", crossorigin: "anonymous", async: true} %title - if content_for?(:title) diff --git a/app/views/payments/new.html.haml b/app/views/payments/new.html.haml index 1f9f508e..bf5f4790 100644 --- a/app/views/payments/new.html.haml +++ b/app/views/payments/new.html.haml @@ -11,25 +11,50 @@ - if @event.tickets_require_approval .card-body.bg-success-subtle - %p.lead - Your request for - %strong - = @ticket_request.adults - = 'ticket'.pluralize(@ticket_request.total_tickets) - has been approved! + %table.w-100 + %thead + %tr + %th + Your request for + %strong + = @ticket_request.adults + = 'ticket'.pluralize(@ticket_request.total_tickets) + has been approved! - %td.text-end.small.p-2.px-4.text-nowrap= "Total Ticket Price:" - %td - %strong - %span{ class: ('label label-info' if @ticket_request.special_price) } - = number_to_currency(@ticket_request.price, precision: 0) - %p + %tbody + %tr + %td.w-100{colspan: 2} + %hr.w-100 + %tr + %td= "Total Price for Tickets:" + %td.text-end + %strong + %span{ class: ('label label-info' if @ticket_request.special_price) } + = number_to_currency(@ticket_request.price, precision: 0) + - if @ticket_request.donation&.positive? + %tr + %td= "Additional Donation:" + %td.text-end + %strong + = number_to_currency(@ticket_request.donation, precision: 0) + + %tbody + %tr + %td.w-100{colspan: 2} + %hr.w-100 + + %tr + %td= "Total Amount" + %td.text-end + %strong + = number_to_currency(@ticket_request.cost, precision: 0) + + + .card-footer.bg-body-secondary %p Now all that's left is to pay for your tickets. If you are paying via credit card, please fill out the form ➜ - - .card-footer.bg-body-secondary %strong = link_to 'I am not paying via credit card', other_event_ticket_request_payment_path(@event, @ticket_request) @@ -46,8 +71,8 @@ .card-header.bg-body-secondary %h5 Please Enter Your Payment Details %strong - Total Ticket Price: - = number_to_currency(@ticket_request.price, precision: 0) + Total Amount Due: + = number_to_currency(@ticket_request.cost, precision: 0) %p .card-body diff --git a/app/views/ticket_requests/_form.html.haml b/app/views/ticket_requests/_form.html.haml index 79f38793..a6066cbc 100644 --- a/app/views/ticket_requests/_form.html.haml +++ b/app/views/ticket_requests/_form.html.haml @@ -57,11 +57,11 @@ %li John Digweed <digweed@bedrock-records.com> - total_guests = @ticket_request.guest_count - - adult_guests = @ticket_request.adults - 1 + - adult_guests = @ticket_request.adults - adult_guests.times do |guest_id| - - next if @ticket_request.guests[guest_id] == "#{@ticket_request.user.name} <#{@ticket_request.user.email}>" + - default_value = guest_id == 0 ? @ticket_request.user.name_and_email : '' = f.label "Adult Guest #{guest_id + 1}" - = f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[0...adult_guests])[guest_id], style: 'width: 80%' + = f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[0...adult_guests])[guest_id] || default_value, style: 'width: 80%' - if @ticket_request.kids.positive? .col-lg-6.col-xl-6.col-md-12.col-sm-12 @@ -74,7 +74,7 @@ - kid_guests = @ticket_request.kids - kid_guests.times do |guest_id| = f.label "Kid Guest #{guest_id + 1}" - = f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[(adult_guests)...total_guests])[guest_id], style: 'width: 80%' + = f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[(adult_guests)..total_guests])[guest_id], style: 'width: 80%' %hr %h4 How are you contributing to the event? diff --git a/app/views/ticket_requests/_ticket_request_show.html.haml b/app/views/ticket_requests/_ticket_request_show.html.haml index 9c92b65c..748dbc67 100644 --- a/app/views/ticket_requests/_ticket_request_show.html.haml +++ b/app/views/ticket_requests/_ticket_request_show.html.haml @@ -16,12 +16,13 @@ %span.p-2.rounded{ class: text_class_for_status(ticket_request) } = ticket_request.status_name - %tr - %td.text-end.small.p-2.px-4.text-nowrap= "Total Tickets Price:" - %td - %strong - %span{ class: ('label label-info' if ticket_request.special_price) } - = number_to_currency(ticket_request.price, precision: 0) + - if ticket_request.can_purchase? + %tr + %td.text-end.small.p-2.px-4.text-nowrap= "Total Tickets Price:" + %td + %strong + %span{ class: ('label label-info' if ticket_request.special_price) } + = number_to_currency(ticket_request.price, precision: 0) - if ticket_request.donation&.positive? %tr @@ -30,46 +31,46 @@ %strong = number_to_currency(ticket_request.donation, precision: 0) - %tr - %td.text-end.small.p-2.px-4.text-nowrap= "Payment:" - %td - %strong - - if ticket_request.payment_received? - - if ticket_request.refunded? - %span.bg-success Refunded - - else - .text-success - = link_to 'Received', event_ticket_request_payment_path(payment, ticket_request) - - - if event.admin?(current_user) - = link_to 'Refund', refund_event_ticket_request_path(event, ticket_request), - method: :post, - class: 'btn btn-sm btn-danger', - data: { confirm: "Are you sure you want to refund #{ticket_request.user.name}'s ticket? This cannot be undone!", - disable_with: 'Refunding...' } - - elsif ticket_request.free? - .text-success - Free + %tr + %td.text-end.small.p-2.px-4.text-nowrap= "Payment:" + %td + %strong + - if ticket_request.payment_received? + - if ticket_request.refunded? + %span.bg-success Refunded - else - - if event.ticket_sales_open? - - if ticket_request.payment.present? && ticket_request.payment.explanation.present? - %span.bg-warning Paying with #{ticket_request.payment.explanation} + .text-success + = link_to 'Received', event_ticket_request_payment_path(payment, ticket_request) + + - if event.admin?(current_user) + = link_to 'Refund', refund_event_ticket_request_path(event, ticket_request), + method: :post, + class: 'btn btn-sm btn-danger', + data: { confirm: "Are you sure you want to refund #{ticket_request.user.name}'s ticket? This cannot be undone!", + disable_with: 'Refunding...' } + - elsif ticket_request.free? + .text-success + Free + - else + - if event.ticket_sales_open? + - if ticket_request.payment.present? && ticket_request.payment.explanation.present? + %span.bg-warning Paying with #{ticket_request.payment.explanation} + - else + - if ticket_request.all_guests_specified? + = link_to 'Purchase your ticket now', + new_event_ticket_request_payment_path(event, ticket_request), + class: 'btn btn-primary m-0' - else - - if ticket_request.all_guests_specified? - = link_to 'Purchase your ticket now', - new_event_ticket_request_payment_path(event, ticket_request), - class: 'btn btn-primary m-0' - - else - .small - You must register all of your guests before you can pay for your ticket. - = link_to edit_event_ticket_request_path(event, ticket_request), class: 'btn btn-primary btn-round btn-sm mx-0' do - = event.admin?(current_user) ? 'Add Their Guests' : 'Add My Guests' + .small + You must register all of your guests before you can pay for your ticket. + = link_to edit_event_ticket_request_path(event, ticket_request), class: 'btn btn-primary btn-round btn-sm mx-0' do + = event.admin?(current_user) ? 'Add Their Guests' : 'Add My Guests' - - else - %span.bg-warning - Unfortunately, ticket sales are now closed. You can no longer purchase your - = succeed '.' do - = 'ticket'.pluralize(ticket_request.total_tickets) + - else + %span.bg-warning + Unfortunately, ticket sales are now closed. You can no longer purchase your + = succeed '.' do + = 'ticket'.pluralize(ticket_request.total_tickets) %tr %td.text-end.small.p-2.px-4.text-nowrap= "Email:"