From d71a45d1984a4a997807dee51d8503a4984a0fc7 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Sun, 22 Apr 2018 01:25:09 +0200 Subject: [PATCH] fix pagination for products on category view --- app/views/category/show.html.erb | 78 ++++++++++++++++---------------- app/views/category/show.js.erb | 1 + 2 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 app/views/category/show.js.erb diff --git a/app/views/category/show.html.erb b/app/views/category/show.html.erb index e3039cd..ed2be56 100644 --- a/app/views/category/show.html.erb +++ b/app/views/category/show.html.erb @@ -1,53 +1,55 @@ <%= render '/product/partials/product_modal' %> <% if @category.active_childrens.size > 0 %> -
-

Kategorie

-
- <% row = 0 %> +
+

Kategorie

+
+ <% row = 0 %> <% for cat in @category.active_childrens %> - <% if row == 0 %> -
+ <% if row == 0 %> +
<% end %>
-
-
-
- <% if !cat.cover_image.blank? %> - <%= link_to(image_tag(cat.cover_image.image.url(:large), style: 'margin: auto;vertical-align: middle;display: inline-block;'), category_path(cat), style: 'line-height: 338px;') %> - <% else %> - <%= link_to(image_tag('kaktus.png'), category_path(cat)) %> - <% end %> -
-
-
-
<%= link_to(cat.name, category_path(cat)) %>
-
-
+
+
+
+ <% if !cat.cover_image.blank? %> + <%= link_to(image_tag(cat.cover_image.image.url(:large), style: 'margin: auto;vertical-align: middle;display: inline-block;'), category_path(cat), style: 'line-height: 338px;') %> + <% else %> + <%= link_to(image_tag('kaktus.png'), category_path(cat)) %> + <% end %> +
+
+
+
<%= link_to(cat.name, category_path(cat)) %>
+
+ +
+
- <% row += 1 + <% row += 1 if row == 4 row = 0 %> -
- <% end %> +
+ <% end %> <% end %> <% if row > 0 && row < 4 %> - - <% end %> + + <% end %> <% end %> <% if @products.size > 0 %> -
-

Produkty

-
-
- <%= render '/product/partials/products_thumbnails' %> +
+

Produkty

+
+
+ <%= render '/product/partials/products_thumbnails' %>
-<% end %> + <% end %> - \ No newline at end of file + diff --git a/app/views/category/show.js.erb b/app/views/category/show.js.erb new file mode 100644 index 0000000..bf3edca --- /dev/null +++ b/app/views/category/show.js.erb @@ -0,0 +1 @@ + $("#products_list").html("<%= escape_javascript(render('/product/partials/products_thumbnails')) %>");