From e0987c52eda0c700ca2601ad789fa9f1bb1fe077 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Fri, 16 Apr 2021 09:27:12 +0200 Subject: [PATCH] Add unit price information into the bulk buy modal - Pass a parameter to scope: showunitprice and display unit price information if it's true --- .../shop_variant_with_unit_price.js.coffee | 1 + .../templates/bulk_buy_modal.html.haml | 17 +++++++++++++---- app/views/shop/products/_form.html.haml | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/shop_variant_with_unit_price.js.coffee b/app/assets/javascripts/darkswarm/directives/shop_variant_with_unit_price.js.coffee index d23d365087..4fe5d1a799 100644 --- a/app/assets/javascripts/darkswarm/directives/shop_variant_with_unit_price.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/shop_variant_with_unit_price.js.coffee @@ -4,4 +4,5 @@ Darkswarm.directive "shopVariantWithUnitPrice", -> templateUrl: 'shop_variant_with_unit_price.html' scope: variant: '=' + show_unit_price: '=showunitprice' controller: 'ShopVariantCtrl' diff --git a/app/assets/javascripts/templates/bulk_buy_modal.html.haml b/app/assets/javascripts/templates/bulk_buy_modal.html.haml index 05868dab77..385fe23bef 100644 --- a/app/assets/javascripts/templates/bulk_buy_modal.html.haml +++ b/app/assets/javascripts/templates/bulk_buy_modal.html.haml @@ -2,12 +2,21 @@ .columns.small-12 %h3{"ng-bind" => "::variant.extended_name"} -.row.variant-bulk-buy-price-summary - .columns.small-6 - .variant-unit {{ ::variant.unit_to_display }} - .columns.small-6 +.flex.variant-bulk-buy-price-summary{style: "justify-content: space-around;"} + .variant-unit + {{ ::variant.unit_to_display }} + .div {{ variant.line_item.total_price | localizeCurrency }} + .unit-price{"ng-if": "show_unit_price"} + %question-mark-with-tooltip{"question-mark-with-tooltip": "_", + "question-mark-with-tooltip-append-to-body": "true", + "question-mark-with-tooltip-placement": "top", + "question-mark-with-tooltip-animation": true, + style: "margin-right: 5px", + key: "'js.shopfront.unit_price_tooltip'"} + {{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }} + .row .columns.small-12.medium-6 .variant-bulk-buy-quantity-label diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index dcd261e0b2..3fbdb1c43f 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -14,7 +14,7 @@ = render "shop/products/summary" .shop-variants - if feature? :unit_price, spree_current_user - %shop-variant-with-unit-price{variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"} + %shop-variant-with-unit-price{showunitprice: 'true', variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"} - else %shop-variant{variant: 'variant', "ng-repeat" => "variant in product.variants | orderBy: ['name_to_display','unit_value'] track by variant.id", "id" => "variant-{{ variant.id }}", "ng-class" => "{'out-of-stock': !variant.on_demand && variant.on_hand == 0}"} %product{"ng-show" => "Products.loading"}