Skip to content

Commit

Permalink
Merge pull request #24 from Jellyfishboy/feature/stock-filter
Browse files Browse the repository at this point in the history
Added low stock filter for stock management.
  • Loading branch information
Jellyfishboy committed Jul 26, 2016
2 parents 7a64956 + c392e4e commit b4f7bdb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/models/sku.rb
Expand Up @@ -122,4 +122,11 @@ def in_stock?
def valid_stock? quantity
stock > quantity ? true : false
end

# Checks if the stock attribute is below the stock_warning_level attribute
#
# @return [Boolean]
def low_stock?
stock < stock_warning_level ? true : false
end
end
11 changes: 9 additions & 2 deletions app/views/admin/products/stock/index.html.erb
Expand Up @@ -6,6 +6,13 @@
<div class="page-header">
<h2 class="widget widget-header">Stock management</h2>
</div>
<div class="widget-controls">
<select class="form-select" id="filter-order">
<option class="filter" data-filter="all">Show all</option>
<option class="filter" data-filter=".stock-low">Low</option>
</select>
<span>Stock:</span>
</div>
<% if @skus.empty? %>
<p>You don't have any Product SKUs yet.</p>
<% else %>
Expand All @@ -21,9 +28,9 @@
<th></th>
</tr>
</thead>
<tbody>
<tbody class="mixitup">
<% @skus.each do |sku| %>
<tr>
<tr class="<%= 'stock-low' if sku.low_stock? %> mix">
<td>
<%= sku.full_sku %>
</td>
Expand Down

0 comments on commit b4f7bdb

Please sign in to comment.