Procházet zdrojové kódy

[Issue #9] Fixed categories index format

Jacqueline Maldonado před 7 roky
rodič
revize
d87cc95333
1 změnil soubory, kde provedl 10 přidání a 11 odebrání
  1. 10 11
      app/views/categories/index.html.erb

+ 10 - 11
app/views/categories/index.html.erb

@@ -45,8 +45,7 @@
 											</div>
 											<div class="actions">
 												<% if can? :create, Category %>
-												<%= link_to new_category_path, {:class=>"btn bold green pull-right filtros"} do %> Nueva Línea de producto <i class="fa fa-plus"></i>
-												<% end %>
+													<%= link_to new_category_path, {:class=>"btn bold green pull-right filtros"} do %> Nueva Línea de producto <i class="fa fa-plus"></i><% end %>
 												<% end %>
 											</div>
 										</div>
@@ -62,26 +61,26 @@
 														<th>Total de productos</th>
 														<th>Status</th>
 														<% if can? :manage, Category %>
-														<th>Acciones</th>
+															<th>Acciones</th>
 														<% end %>
 													</tr>
 												</thead>
 												<tbody>
 												<% @categories.each_with_index do |category, key| %>
-													<tr <% if !category.children.empty? %> class="bold" <% end %> >
+													<tr <% if category.parent_id.zero? %> class="bold" <% end %> >
 														<td><%= key + 1 %></td>
 														<td><%= category.category %></td>
 														<td><%= category.description %></td>
 														<td>
-															<% if category.children.empty? %>
-																<%= category.products.length %>
-															<% else %>
-																<% @productsofchildren = 0 %>
+															<% total_products = category.products.length %>
+															<% if !category.children.empty? %>
+																<% productsofchildren = 0 %>
 																<% category.children.each_with_index do |child, k|%>
-																	<% @productsofchildren += child.products.length %>
+																	<% productsofchildren += child.products.length %>
 																<% end %>
-																<%= @productsofchildren %>
+																<% total_products += productsofchildren %>
 															<% end %>
+															<%= total_products %>
 														</td>
 														<td class="text-center">
 															<% if category.active? %>
@@ -112,7 +111,7 @@
 														</td>
 														<% end %>
 													</tr>
-													<% category.children.each_with_index do |child, k|%>
+													<% category.children.each_with_index do |child, k| %>
 													<tr>
 														<td><%= key + 1 %> - <%= k + 1 %></td>
 														<td><span class="text-muted"> <%= child.category %> </span></td>