diff --git a/app/cells/boutique/line_items/summary/show.slim b/app/cells/boutique/line_items/summary/show.slim index 4b53485b..90bea422 100644 --- a/app/cells/boutique/line_items/summary/show.slim +++ b/app/cells/boutique/line_items/summary/show.slim @@ -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) diff --git a/app/cells/boutique/line_items/summary/summary.sass b/app/cells/boutique/line_items/summary/summary.sass new file mode 100644 index 00000000..2c95fcf1 --- /dev/null +++ b/app/cells/boutique/line_items/summary/summary.sass @@ -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 diff --git a/app/cells/boutique/line_items/summary_cell.rb b/app/cells/boutique/line_items/summary_cell.rb index e28dec6a..8127ab3c 100644 --- a/app/cells/boutique/line_items/summary_cell.rb +++ b/app/cells/boutique/line_items/summary_cell.rb @@ -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 } }) diff --git a/app/cells/boutique/orders/edit/summary/show.slim b/app/cells/boutique/orders/edit/summary/show.slim index 65abe04b..f8d521f0 100644 --- a/app/cells/boutique/orders/edit/summary/show.slim +++ b/app/cells/boutique/orders/edit/summary/show.slim @@ -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) diff --git a/app/cells/boutique/orders/payment_methods/show.slim b/app/cells/boutique/orders/payment_methods/show.slim index 4fd5e0aa..c6821644 100644 --- a/app/cells/boutique/orders/payment_methods/show.slim +++ b/app/cells/boutique/orders/payment_methods/show.slim @@ -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" @@ -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') diff --git a/app/cells/boutique/orders/show/show.slim b/app/cells/boutique/orders/show/show.slim index 7ca41279..7cf0fb15 100644 --- a/app/cells/boutique/orders/show/show.slim +++ b/app/cells/boutique/orders/show/show.slim @@ -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) diff --git a/app/controllers/boutique/orders_controller.rb b/app/controllers/boutique/orders_controller.rb index bd07b5d2..35ca6d4c 100644 --- a/app/controllers/boutique/orders_controller.rb +++ b/app/controllers/boutique/orders_controller.rb @@ -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 @@ -31,6 +34,7 @@ def confirm end def show + @use_boutique_adaptive_css_for_head = :no_background end def payment diff --git a/app/helpers/boutique/config_helper.rb b/app/helpers/boutique/config_helper.rb index c46673f1..5ba936a4 100644 --- a/app/helpers/boutique/config_helper.rb +++ b/app/helpers/boutique/config_helper.rb @@ -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 @@ -17,7 +19,7 @@ def boutique_adaptive_css_for_head(model) %{ diff --git a/app/models/boutique/line_item.rb b/app/models/boutique/line_item.rb index 4624330f..6f2a69fb 100644 --- a/app/models/boutique/line_item.rb +++ b/app/models/boutique/line_item.rb @@ -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 diff --git a/app/models/boutique/order.rb b/app/models/boutique/order.rb index eb439418..ba2f6259 100644 --- a/app/models/boutique/order.rb +++ b/app/models/boutique/order.rb @@ -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 @@ -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 diff --git a/test/dummy/app/views/layouts/folio/application.slim b/test/dummy/app/views/layouts/folio/application.slim index 84d7e946..6dbe4be3 100644 --- a/test/dummy/app/views/layouts/folio/application.slim +++ b/test/dummy/app/views/layouts/folio/application.slim @@ -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)