Skip to content

Commit

Permalink
refactor new session view into two partials
Browse files Browse the repository at this point in the history
  • Loading branch information
adam2451 committed Mar 15, 2024
1 parent 6b091a4 commit 4025a19
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 74 deletions.
1 change: 1 addition & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def new
end
@remember_me = true
@email ||= params[:email]
@head = "Subscribers and Returning Customers"
end

def new_from_secret
Expand Down
1 change: 1 addition & 0 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def donate
reset_shopping # even if order in progress, going to donation page cancels it
if @customer == Customer.anonymous_customer
# handle donation as a 'guest checkout', even though may end up being tied to real customer
@head = "Login for a faster checkout!"
@customer = Customer.new
session[:guest_checkout] = true
return_after_login params.except(:customer_id)
Expand Down
29 changes: 29 additions & 0 deletions app/views/layouts/_login_form.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
= form_tag session_path, :class => 'form' do
.card
.card-header.text-center
%h3
= head
.card-body
.row
.col-md-2.text-right
%label.col-form-label{:for=>:customer_email} Email
.col-md-6
= text_field_tag 'email', @email, :class => 'form-control'
.col-md-4
.row
.col-md-2.text-right
%label.col-form-label{:for=>:customer_password} Password
.col-md-6
= password_field_tag 'password', nil, :autocomplete => 'off', :class => 'form-control'
.col-md-4
= submit_tag 'Login', :class => 'btn btn-success', :disable_with => 'Logging in...'
.row
.col-md-2.text-right
= check_box_tag 'remember_me', '1', @remember_me
.col-md-10
Remember me for next time (Don't use on public/shared computers)
.row
Need to reset your password? 
= link_to 'Reset password by email', forgot_password_customers_path
 or 
= link_to 'Login with secret question', new_from_secret_session_path
11 changes: 11 additions & 0 deletions app/views/layouts/_new_customers.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.card
.card-header.text-center
%h3 New Customers
.card-body.text-center
- if @gOrderInProgress
- if @display_guest_checkout
.row.p-2= link_to "Checkout as Guest", guest_checkout_customers_path, :class => 'btn btn-primary btn-block'
.row.p-2= link_to "Create Account", new_customer_path, :class => 'btn btn-primary btn-block'
- else
.row.p-2= link_to_if_option_text :homepage_ticket_sales_text, store_path, {:class => 'btn btn-primary btn-block'}
.row.p-2= link_to_if_option_text :homepage_subscription_sales_text, store_subscribe_path, {:class => 'btn btn-primary btn-block'}
46 changes: 4 additions & 42 deletions app/views/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,9 @@

- unless @gOrderInProgress
%h1.text-center.py-3= "#{Option.venue} Online Box Office"

= form_tag session_path, :class => 'form' do
.row
.col-md-8
.card
.card-header.text-center
%h3 Subscribers and Returning Customers
.card-body
.row
.col-md-2.text-right
%label.col-form-label{:for=>:customer_email} Email
.col-md-6
= text_field_tag 'email', @email, :class => 'form-control'
.col-md-4
.row
.col-md-2.text-right
%label.col-form-label{:for=>:customer_password} Password
.col-md-6
= password_field_tag 'password', nil, :autocomplete => 'off', :class => 'form-control'
.col-md-4
= submit_tag 'Login', :class => 'btn btn-success', :disable_with => 'Logging in...'
.row
.col-md-2.text-right
= check_box_tag 'remember_me', '1', @remember_me
.col-md-10
Remember me for next time (Don't use on public/shared computers)
.row
Need to reset your password? 
= link_to 'Reset password by email', forgot_password_customers_path
 or 
= link_to 'Login with secret question', new_from_secret_session_path
#content.a1-plain.col-md-8
= render :partial => 'layouts/login_form', locals: {head: @head}

.col-md-4
.card
.card-header.text-center
%h3 New Customers
.card-body.text-center
- if @gOrderInProgress
- if @display_guest_checkout
.row.p-2= link_to "Checkout as Guest", guest_checkout_customers_path, :class => 'btn btn-primary btn-block'
.row.p-2= link_to "Create Account", new_customer_path, :class => 'btn btn-primary btn-block'
- else
.row.p-2= link_to_if_option_text :homepage_ticket_sales_text, store_path, {:class => 'btn btn-primary btn-block'}
.row.p-2= link_to_if_option_text :homepage_subscription_sales_text, store_subscribe_path, {:class => 'btn btn-primary btn-block'}
#content.a2-plain.col-md-4
= render :partial => 'layouts/new_customers'
35 changes: 3 additions & 32 deletions app/views/store/donate.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,9 @@
%p.text-center.lead-= sanitize(Option.quick_donation_explanation)

- if session[:guest_checkout] == true
= form_tag session_path, :class => 'form' do
.row
.col-md-12
.card
.card-header.text-center
%h8 Login For A Faster Checkout!
.card-body
.row
.col-md-2.text-right
%label.col-form-label{:for=>:customer_email} Email
.col-md-6
= text_field_tag 'email', @email, :class => 'form-control'
.col-md-4
.row
.col-md-2.text-right
%label.col-form-label{:for=>:customer_password} Password
.col-md-6
= password_field_tag 'password', nil, :autocomplete => 'off', :class => 'form-control'
.col-md-4
= submit_tag 'Login', :class => 'btn btn-success', :disable_with => 'Logging in...'
.row
.col-md-2.text-right
= check_box_tag 'remember_me', '1', @remember_me
.col-md-10
Remember me for next time (Don't use on public/shared computers)
.row
Need to reset your password? 
= link_to 'Reset password by email', forgot_password_customers_path
 or 
= link_to 'Login with secret question', new_from_secret_session_path


#content.a1-plain.col-md-12
= render :partial => 'layouts/login_form', locals: {head: @head}

= form_tag(process_donation_path, {:id => '_stripe_payment_form', :onsubmit => 'return confirmAndSubmit()' }) do
= hidden_field_tag 'referer', 'donate'
= hidden_field_tag 'customer_id', @customer.id
Expand Down

0 comments on commit 4025a19

Please sign in to comment.