-
-
Notifications
You must be signed in to change notification settings - Fork 793
[Grid view] Display product as a grid #14345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
bfe09ed
951da2f
bdd38c7
8081f42
4195d1a
428bc4b
5ee736e
e45a01a
67316ea
834ddd4
4fd783f
eaa22a4
9fdfa1a
409e06a
735477a
6c101f0
a3e46de
18fe7c6
24f3fbe
30c7b79
dc30610
666f161
95ea333
17b9717
dda80ef
a3843e8
ae3651c
42ab6c2
ab3e1ac
8918645
dd274f9
443a512
b070c3a
a74fbb8
65150ce
a997d0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ProductsController < BaseController | ||
| def index | ||
| @order_cycle_id = params[:order_cycle_id] | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| = turbo_frame_tag "shop-products" do | ||
| TODO Render products grid for order cycle | ||
| = @order_cycle_id |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| - # NOTE: make sure that any changes in this template are reflected in app/views/admin/products_v3/product_preview.turbo_stream.haml | ||
| = cache_with_locale do | ||
| = cache_with_locale(current_order_cycle&.id) do | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to cache by feature toggle as well?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should, now that I think about it a bit more I am not sure the order cycle is needed but I'll double check that.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reviewed the cache key and made it feature aware, see: 24f3fbe |
||
| %form{action: main_app.cart_path} | ||
| %products{"ng-init" => "refreshStaleData()", "ng-show" => "order_cycle.order_cycle_id != null", "ng-cloak" => true } | ||
|
|
||
|
|
@@ -11,19 +11,34 @@ | |
| .medium-12.large-9.columns.full | ||
| = render partial: "shop/products/search_feedback" | ||
|
|
||
| .pad-top{ "infinite-scroll" => "loadMore()", "infinite-scroll-distance" => "1", "infinite-scroll-disabled" => 'Products.loading', "infinite-scroll-immediate-check": "false" } | ||
| %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 | ||
| .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 | ||
| = t :products_loading | ||
| .row.full | ||
| .small-12.columns.text-center | ||
| = render partial: "components/spinner" | ||
| - if feature?(:product_grid_view, @current_user) | ||
| - if current_order_cycle.present? | ||
| = turbo_frame_tag("shop-products", src: order_cycle_products_path(current_order_cycle.id), "data-controller": "product-grid-view", "data-action": "orderCycleSelected@window->product-grid-view#updateProducts") do | ||
| %product | ||
| .summary | ||
| .small-12.columns.text-center | ||
| = t :products_loading | ||
| .row.full | ||
| .small-12.columns.text-center | ||
| = render partial: "components/spinner" | ||
|
|
||
| - else | ||
| = turbo_frame_tag("shop-products", "data-controller": "product-grid-view", "data-action": "orderCycleSelected@window->product-grid-view#updateProducts") do | ||
| | ||
| - else | ||
| .pad-top{ "infinite-scroll" => "loadMore()", "infinite-scroll-distance" => "1", "infinite-scroll-disabled" => 'Products.loading', "infinite-scroll-immediate-check": "false" } | ||
| %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 | ||
| .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 | ||
| = t :products_loading | ||
| .row.full | ||
| .small-12.columns.text-center | ||
| = render partial: "components/spinner" | ||
|
|
||
| .hide-for-medium-down.large-1.columns | ||
| -# Space between products and filters | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { Controller } from "stimulus"; | ||
|
|
||
| export default class extends Controller { | ||
| updateProducts(ev) { | ||
| const orderCycleId = ev.detail.orderCycleId; | ||
| // Updating the turbo-frame source will reload the frame | ||
| this.element.src = `/order_cycles/${orderCycleId}/products`; | ||
| } | ||
|
dacook marked this conversation as resolved.
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.