Skip to content

Commit

Permalink
show articles ordered by members but not by foodcoop dimmed in receive
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Aug 29, 2014
1 parent 790a6b1 commit 8913ad6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/order_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class OrderArticle < ActiveRecord::Base
validate :article_and_price_exist
validates_uniqueness_of :article_id, scope: :order_id

_ordered_sql = "units_to_order > 0 OR units_billed > 0 OR units_received > 0"
_ordered_sql = "units_to_order > 0 OR units_billed > 0 OR units_received > 0 OR order_articles.quantity > 0"
scope :ordered, -> { where(_ordered_sql) }
scope :ordered_or_member, -> { includes(:group_order_articles).where("#{_ordered_sql} OR group_order_articles.result > 0") }

Expand Down
4 changes: 3 additions & 1 deletion app/views/orders/_edit_amount.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-# NOTE: if you modify tiny details here you must also change them in `receive_on_order_article_update.js.erb`
= fields_for 'order_articles', order_article, index: order_article.id do |form|
%tr{id: "order_article_#{order_article.id}", class: "#{cycle('even', 'odd', name: 'articles')} order-article", valign: "top"}
- cssclass = "order-article #{cycle('even', 'odd', name: 'articles')}"
- cssclass += " unavailable" if (order_article.units_billed||order_article.units_to_order)==0 and order_article.units_received.nil?
%tr{id: "order_article_#{order_article.id}", class: cssclass, valign: "top"}
- order_title = []
- order_title.append Article.human_attribute_name(:manufacturer)+': ' + order_article.article.manufacturer unless order_article.article.manufacturer.to_s.empty?
- order_title.append Article.human_attribute_name(:note)+': ' + order_article.article.note unless order_article.article.note.to_s.empty?
Expand Down
3 changes: 3 additions & 0 deletions app/views/orders/_edit_amounts.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
}

$(input).closest('tr').find('.units_delta').html(html);

// un-dim row when received is nonzero
$(input).closest('tr').toggleClass('unavailable', expected == 0 && html=='');
}

$(document).on('change keyup', 'input[data-units-expected]', function() {
Expand Down

0 comments on commit 8913ad6

Please sign in to comment.