From 3afd6c273a27c96dad56cd2b92826380d7ee83e7 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 16 Jan 2022 10:30:46 +0000 Subject: [PATCH 1/5] Move shop_variant templates to views --- .../shop/products/_shop_variant.html.haml} | 0 .../shop/products/_shop_variant_no_group_buy.html.haml} | 0 .../shop/products/_shop_variant_with_group_buy.html.haml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename app/{assets/javascripts/templates/shop_variant.html.haml => views/shop/products/_shop_variant.html.haml} (100%) rename app/{assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml => views/shop/products/_shop_variant_no_group_buy.html.haml} (100%) rename app/{assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml => views/shop/products/_shop_variant_with_group_buy.html.haml} (100%) diff --git a/app/assets/javascripts/templates/shop_variant.html.haml b/app/views/shop/products/_shop_variant.html.haml similarity index 100% rename from app/assets/javascripts/templates/shop_variant.html.haml rename to app/views/shop/products/_shop_variant.html.haml diff --git a/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml b/app/views/shop/products/_shop_variant_no_group_buy.html.haml similarity index 100% rename from app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml rename to app/views/shop/products/_shop_variant_no_group_buy.html.haml diff --git a/app/assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml b/app/views/shop/products/_shop_variant_with_group_buy.html.haml similarity index 100% rename from app/assets/javascripts/templates/partials/shop_variant_with_group_buy.html.haml rename to app/views/shop/products/_shop_variant_with_group_buy.html.haml From e5009432c366ebbc902e4ef0636df004c4782d6f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 16 Jan 2022 10:45:26 +0000 Subject: [PATCH 2/5] Render regular partials --- app/views/shop/products/_shop_variant.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shop/products/_shop_variant.html.haml b/app/views/shop/products/_shop_variant.html.haml index 382839712d..819622d982 100644 --- a/app/views/shop/products/_shop_variant.html.haml +++ b/app/views/shop/products/_shop_variant.html.haml @@ -19,5 +19,5 @@ .medium-2.large-2.columns.total-price %span{"ng-class" => "{filled: variant.line_item.total_price}"} {{ variant.line_item.total_price | localizeCurrency }} - %ng-include{src: "'partials/shop_variant_no_group_buy.html'"} - %ng-include{src: "'partials/shop_variant_with_group_buy.html'"} + = render partial: "shop/products/shop_variant_no_group_buy" + = render partial: "shop/products/shop_variant_with_group_buy" From f06ec94b30dfde0024a164fc295acffb844e71c1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 16 Jan 2022 10:46:26 +0000 Subject: [PATCH 3/5] Render shop_variant partial normally and remove shop_variant directive --- .../directives/shop_variant.js.coffee | 7 --- app/views/shop/products/_form.html.haml | 3 +- .../shop/products/_shop_variant.html.haml | 45 +++++++++---------- 3 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 app/assets/javascripts/darkswarm/directives/shop_variant.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/shop_variant.js.coffee b/app/assets/javascripts/darkswarm/directives/shop_variant.js.coffee deleted file mode 100644 index 372a92b69d..0000000000 --- a/app/assets/javascripts/darkswarm/directives/shop_variant.js.coffee +++ /dev/null @@ -1,7 +0,0 @@ -angular.module('Darkswarm').directive "shopVariant", -> - restrict: 'E' - replace: true - templateUrl: 'shop_variant.html' - scope: - variant: '=' - controller: 'ShopVariantCtrl' diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index bccaf6e334..18471ead25 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -13,7 +13,8 @@ %product.animate-repeat{"ng-controller" => "ProductNodeCtrl", "ng-repeat" => "product in Products.products track by product.id", "id" => "product-{{ product.id }}"} = render "shop/products/summary" .shop-variants - %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}"} + .variants.row{"ng-controller": "ShopVariantCtrl", 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}"} + = render "shop/products/shop_variant" %product{"ng-show" => "Products.loading"} .summary .small-12.columns.text-center diff --git a/app/views/shop/products/_shop_variant.html.haml b/app/views/shop/products/_shop_variant.html.haml index 819622d982..63d5f05090 100644 --- a/app/views/shop/products/_shop_variant.html.haml +++ b/app/views/shop/products/_shop_variant.html.haml @@ -1,23 +1,22 @@ -.variants.row - .small-4.medium-4.large-5.columns.variant-name - .inline{"ng-if" => "::variant.display_name"} {{ ::variant.display_name }} - .variant-unit {{ ::variant.unit_to_display }} - .small-3.medium-3.large-2.columns.variant-price - %price-breakdown{"price-breakdown" => "_", variant: "variant", - "price-breakdown-append-to-body" => "true", - "price-breakdown-placement" => "bottom", - "price-breakdown-animation" => true} - {{ variant.price_with_fees | localizeCurrency }} - .unit-price.variant-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, - key: "'js.shopfront.unit_price_tooltip'"} - {{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }} - - .medium-2.large-2.columns.total-price - %span{"ng-class" => "{filled: variant.line_item.total_price}"} - {{ variant.line_item.total_price | localizeCurrency }} - = render partial: "shop/products/shop_variant_no_group_buy" - = render partial: "shop/products/shop_variant_with_group_buy" +.small-4.medium-4.large-5.columns.variant-name + .inline{"ng-if" => "::variant.display_name"} {{ ::variant.display_name }} + .variant-unit {{ ::variant.unit_to_display }} +.small-3.medium-3.large-2.columns.variant-price + %price-breakdown{"price-breakdown" => "_", variant: "variant", + "price-breakdown-append-to-body" => "true", + "price-breakdown-placement" => "bottom", + "price-breakdown-animation" => true} + {{ variant.price_with_fees | localizeCurrency }} + .unit-price.variant-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, + key: "'js.shopfront.unit_price_tooltip'"} + {{ variant.unit_price_price | localizeCurrency }} / {{ variant.unit_price_unit }} + +.medium-2.large-2.columns.total-price + %span{"ng-class" => "{filled: variant.line_item.total_price}"} + {{ variant.line_item.total_price | localizeCurrency }} += render partial: "shop/products/shop_variant_no_group_buy" += render partial: "shop/products/shop_variant_with_group_buy" From a6ef7ca17fd95d39d6f7569e697837628dd8de7d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 16 Jan 2022 10:58:27 +0000 Subject: [PATCH 4/5] Move shipping_type_selector template to views --- .../shops/_shipping_type_selector.html.haml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/{assets/javascripts/templates/shipping_type_selector.html.haml => views/shops/_shipping_type_selector.html.haml} (100%) diff --git a/app/assets/javascripts/templates/shipping_type_selector.html.haml b/app/views/shops/_shipping_type_selector.html.haml similarity index 100% rename from app/assets/javascripts/templates/shipping_type_selector.html.haml rename to app/views/shops/_shipping_type_selector.html.haml From 31b4c06ea3874c38442013e9754207f46401ca27 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 16 Jan 2022 11:02:28 +0000 Subject: [PATCH 5/5] Update rendering and shipping_type_selector directive --- .../darkswarm/directives/shipping_type_selector.js.coffee | 4 +--- app/views/shops/_filters.html.haml | 2 +- app/views/shops/_shipping_type_selector.html.haml | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/darkswarm/directives/shipping_type_selector.js.coffee b/app/assets/javascripts/darkswarm/directives/shipping_type_selector.js.coffee index b7ffe71eb9..bf89254298 100644 --- a/app/assets/javascripts/darkswarm/directives/shipping_type_selector.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/shipping_type_selector.js.coffee @@ -1,8 +1,6 @@ angular.module('Darkswarm').directive "shippingTypeSelector", -> # Builds selector for shipping types - restrict: 'E' - replace: true - templateUrl: 'shipping_type_selector.html' + restrict: 'C' link: (scope, elem, attr)-> scope.shippingTypes = pickup: false diff --git a/app/views/shops/_filters.html.haml b/app/views/shops/_filters.html.haml index 1e62405be3..f3011a0a25 100644 --- a/app/views/shops/_filters.html.haml +++ b/app/views/shops/_filters.html.haml @@ -19,7 +19,7 @@ .light = t :hubs_filter_by = t :hubs_filter_delivery - %shipping-type-selector + = render "shops/shipping_type_selector" .small-12.large-12.columns %h5.tdhead diff --git a/app/views/shops/_shipping_type_selector.html.haml b/app/views/shops/_shipping_type_selector.html.haml index 45f35911d4..db7c8319c7 100644 --- a/app/views/shops/_shipping_type_selector.html.haml +++ b/app/views/shops/_shipping_type_selector.html.haml @@ -1,4 +1,4 @@ -%ul.small-block-grid-2.medium-block-grid-4.large-block-grid-2 +%ul.shipping-type-selector.small-block-grid-2.medium-block-grid-4.large-block-grid-2 %active-selector{"ng-repeat" => "(name, selector) in selectors"} %i{"ng-class" => "selector.icon"} - {{ selector.translation_key | t | capitalize }} \ No newline at end of file + {{ selector.translation_key | t | capitalize }}