From 90193ef5bb4b612b2c75455626738cfc3a32e914 Mon Sep 17 00:00:00 2001 From: Zee Spencer <50284+zspencer@users.noreply.github.com> Date: Sat, 6 May 2023 12:47:55 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20`Marketplace`:=20Show=20`Product::P?= =?UTF-8?q?hoto`=20in=20`Cart`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://github.com/zinc-collective/convene/issues/1428 - https://github.com/zinc-collective/convene/issues/1326 A quick insertion of the photos into the cart view. We probably should do a broader redesign pass on the `Cart` UI :soon: but this seems decent enough? --- app/controllers/application_controller.rb | 3 ++ .../cart_products/_cart_product.html.erb | 35 +++++++++++++------ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9d3b96e3d..9db15bd21 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,6 +17,9 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception, unless: -> { api_request? } + # @see https://til.hashrocket.com/posts/3exmhtwqy6-setting-the-urloptions-hash-in-the-controller + include ActiveStorage::SetCurrent + # Referenced in application layout to display page title # Override on a per-controller basis to display different title # @return [String] diff --git a/app/furniture/marketplace/cart_products/_cart_product.html.erb b/app/furniture/marketplace/cart_products/_cart_product.html.erb index ad0b7c30b..7cbdacc56 100644 --- a/app/furniture/marketplace/cart_products/_cart_product.html.erb +++ b/app/furniture/marketplace/cart_products/_cart_product.html.erb @@ -1,8 +1,19 @@ <%- product = cart_product.product %> <%- cart = cart_product.cart %> - + - <%= product.name %> + <%- if product.photo.present? %> +
+ <%= image_tag product.photo.variant(resize_to_limit: [550, 550]).processed.url, class: "rounded-lg" + %> +
+ <%=product.name%> +
+
+ <%- else %> + <%= product.name %> + <%- end %> +
<%= product.class.human_attribute_name(:price) %>
<%= humanized_money_with_symbol(product.price) %>
@@ -17,17 +28,19 @@ <%= humanized_money_with_symbol(product.price) %> - - <%# TODO: Extract minus and plus buttons into components %> - <%- minus_quantity = [cart_product.quantity - 1, 0].max %> - <%- minus_method = minus_quantity.zero? ? :delete : :put %> - <%= render "buttons/minus", disabled: cart_product.quantity.zero?, method: minus_method, title: t('.remove'), disabled: cart_product.quantity.zero?, href: [cart.space, cart.room, cart.marketplace, cart, cart_product, { cart_product: { quantity: minus_quantity, product_id: product.id} }] %> + +
+ <%# TODO: Extract minus and plus buttons into components %> + <%- minus_quantity = [cart_product.quantity - 1, 0].max %> + <%- minus_method = minus_quantity.zero? ? :delete : :put %> + <%= render "buttons/minus", disabled: cart_product.quantity.zero?, method: minus_method, title: t('.remove'), disabled: cart_product.quantity.zero?, href: [cart.space, cart.room, cart.marketplace, cart, cart_product, { cart_product: { quantity: minus_quantity, product_id: product.id} }] %> - <%= cart_product.quantity %> + <%= cart_product.quantity %> - <%- add_quantity = cart_product.quantity + 1 %> - <%- add_method = add_quantity == 1 ? :post : :put %> - <%= render "buttons/plus", method: add_method, title: t('.add'), href: [cart.space, cart.room, cart.marketplace, cart, cart_product, { cart_product: {quantity: add_quantity, product_id: product.id} }] %> + <%- add_quantity = cart_product.quantity + 1 %> + <%- add_method = add_quantity == 1 ? :post : :put %> + <%= render "buttons/plus", method: add_method, title: t('.add'), href: [cart.space, cart.room, cart.marketplace, cart, cart_product, { cart_product: {quantity: add_quantity, product_id: product.id} }] %> +