Skip to content

Commit

Permalink
style orders#show
Browse files Browse the repository at this point in the history
  • Loading branch information
mreq committed May 12, 2022
1 parent 354059c commit 4df2838
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 34 deletions.
19 changes: 12 additions & 7 deletions app/cells/boutique/line_items/summary/show.slim
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
.b-line-items-summary
h3 = t('.title')

- line_items.each do |line_item|
.b-line-items-summary__item
= image(line_item.cover_placement_from_variant_or_product, THUMB_SIZE)
.b-line-items-summary__flex
- line_items.each do |line_item|
.b-line-items-summary__line-item
.b-line-items-summary__line-item-cover-wrap
= image(line_item.cover_placement_from_variant_or_product,
THUMB_SIZE,
contain: true,
class: 'b-line-items-summary__line-item-cover '\
'b-adaptive-css-background-primary')

ul
/ TODO: site
li = line_item.to_label
li.font-weight-bold.mt-2 = price(line_item.price)
p = line_item.summary_text

h4.mb-0 = price(line_item.price)
29 changes: 29 additions & 0 deletions app/cells/boutique/line_items/summary/summary.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.b-line-items-summary
&__flex
display: flex
flex-wrap: wrap
margin-right: - $grid-gutter-width

&__line-item
flex: 0 0 195px
max-width: 50%
margin-right: $grid-gutter-width

&__line-item-cover-wrap
margin-bottom: 20px
position: relative
max-width: 150px

&::before
content: ''
padding-top: percentage(100 / 150)
display: block

&__line-item-cover
position: absolute
top: 0
right: 0
bottom: 0
left: 0
max-width: 100% !important
max-height: 100% !important
2 changes: 1 addition & 1 deletion app/cells/boutique/line_items/summary_cell.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Boutique::LineItems::SummaryCell < Boutique::ApplicationCell
THUMB_SIZE = "150x100#"
THUMB_SIZE = "150x100"

def line_items
@line_items ||= model.includes(product_variant: { product: { cover_placement: :file } })
Expand Down
2 changes: 1 addition & 1 deletion app/cells/boutique/orders/edit/summary/show.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class: 'b-orders-edit-summary__line-item-cover '\
'b-adaptive-css-background-primary')

= line_item.to_label
= simple_format line_item.summary_text

h4.b-orders-edit-summary__total-price
= price(model.total_price)
26 changes: 14 additions & 12 deletions app/cells/boutique/orders/payment_methods/show.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.b-orders-payment-methods
h3.b-orders-payment-methods__title
= t('.title', price: price(f.object.total_price))
- if options[:title] != false
h3.b-orders-payment-methods__title
= t('.title', price: price(f.object.total_price))

input.b-orders-payment-methods__hidden-method[
type="hidden"
Expand All @@ -12,16 +13,17 @@
- payment_methods.each_with_index do |method, i|
= payment_button(f, method, i)

.b-orders-payment-methods__info.small.text-muted
.b-orders-payment-methods__info-flex
= t('.secured_by')
- if options[:info] != false
.b-orders-payment-methods__info.small.text-muted
.b-orders-payment-methods__info-flex
= t('.secured_by')

a.b-orders-payment-methods__info-a[
href="https://www.gopay.com/"
target="_blank"
]
img.b-orders-payment-methods__info-img[
src=image_path("boutique/gopay-logo.svg")
a.b-orders-payment-methods__info-a[
href="https://www.gopay.com/"
target="_blank"
]
img.b-orders-payment-methods__info-img[
src=image_path("boutique/gopay-logo.svg")
]

= t('.prices_include_vat')
= t('.prices_include_vat')
21 changes: 13 additions & 8 deletions app/cells/boutique/orders/show/show.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
h2
= t('.unpaid_notice')

span.mr-4
= price(model.total_price)
.d-flex.align-items-center.mt-g
h4.my-0.mr-g
= price(model.total_price)

span.text-gray.mr-4
= l(model.confirmed_at, format: :as_date)
span.text-gray
= model.confirmed? ? t('.unpaid') : t('.paid')
.text-muted.mr-g
= l(model.confirmed_at, format: :as_date)

.text-muted
= model.confirmed? ? t('.unpaid') : t('.paid')

- if model.confirmed?
.mt-4
= payment_methods_form do |f|
= cell('boutique/orders/payment_methods', f)
= cell('boutique/orders/payment_methods',
f,
title: false,
info: false)

hr
hr.my-g

= cell('boutique/line_items/summary', model.line_items)
4 changes: 4 additions & 0 deletions app/controllers/boutique/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ def add
end

def edit
@use_boutique_adaptive_css_for_head = true
end

def confirm
@use_boutique_adaptive_css_for_head = true

current_order.assign_attributes(order_params)

current_order.transaction do
Expand All @@ -31,6 +34,7 @@ def confirm
end

def show
@use_boutique_adaptive_css_for_head = :no_background
end

def payment
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/boutique/config_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Boutique::ConfigHelper
}

def boutique_adaptive_css_for_head(model)
return unless @use_boutique_adaptive_css_for_head

if model && model.respond_to?(:boutique_adaptive_css_for_head)
override = model.boutique_adaptive_css_for_head
else
Expand All @@ -17,7 +19,7 @@ def boutique_adaptive_css_for_head(model)

%{
<style type="text/css">
.b-adaptive-css-main-background { background: #{h[:background]}; }
#{@use_boutique_adaptive_css_for_head == :no_background ? "" : "body { background: #{h[:background]}; }" }
.b-adaptive-css-background-primary { background: #{h[:border_color]}; }
.b-adaptive-css-border-color-primary { border-color: #{h[:border_color]}; }
</style>
Expand Down
4 changes: 4 additions & 0 deletions app/models/boutique/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def imprint_unit_price!
def cover_placement_from_variant_or_product
product_variant.cover_placement || product_variant.product.cover_placement
end

def summary_text
to_label
end
end

# == Schema Information
Expand Down
13 changes: 10 additions & 3 deletions app/models/boutique/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class Boutique::Order < Boutique::ApplicationRecord
format: { with: Folio::EMAIL_REGEXP },
unless: :pending?

validates :primary_address,
presence: true,
if: :requires_address_and_not_pending?
validate :validate_primary_address

aasm timestamps: true do
state :pending, initial: true
Expand Down Expand Up @@ -173,6 +171,15 @@ def requires_address?
def requires_address_and_not_pending?
requires_address? && !pending?
end

def validate_primary_address
return unless requires_address_and_not_pending?
if primary_address.blank?
build_primary_address
primary_address.valid?
errors.add(:primary_address, :blank)
end
end
end

# == Schema Information
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/app/views/layouts/folio/application.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ html[

= boutique_adaptive_css_for_head(@boutique_adaptive_css_model)

body.b-adaptive-css-main-background
body
== cell('dummy/ui/header')
== cell('dummy/ui/flash', flash)

Expand Down

0 comments on commit 4df2838

Please sign in to comment.