Port current_orders plugin to current foodsoft
This commit is contained in:
parent
5907ff11bb
commit
466e8c5eeb
19 changed files with 114 additions and 108 deletions
|
|
@ -34,10 +34,13 @@ class CurrentOrders::ArticlesController < ApplicationController
|
|||
else
|
||||
@order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id))
|
||||
end
|
||||
params[:q] ||= params[:search] # for meta_search instead of ransack
|
||||
@q = OrderArticle.search(params[:q])
|
||||
@order_articles = @order_articles.ordered.merge(@q.relation).includes(:article, :article_price)
|
||||
@order_articles = @order_articles.ordered.merge(@q.result).includes(:article, :article_price)
|
||||
@order_article = @order_articles.where(id: params[:id]).first
|
||||
end
|
||||
|
||||
helper_method \
|
||||
def ordergroups_for_adding
|
||||
Ordergroup.undeleted.order(:name)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# encoding: utf-8
|
||||
class CurrentOrders::OrdergroupsController < ApplicationController
|
||||
|
||||
|
||||
before_filter :authenticate_orders
|
||||
before_filter :find_group_orders, only: [:index, :show]
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ class CurrentOrders::OrdergroupsController < ApplicationController
|
|||
def find_group_orders
|
||||
@order_ids = Order.finished_not_closed.map(&:id)
|
||||
|
||||
@all_ordergroups = Ordergroup.undeleted.order(:name).all
|
||||
@all_ordergroups = Ordergroup.undeleted.order(:name).to_a
|
||||
@ordered_group_ids = GroupOrder.where(order_id: @order_ids).pluck('DISTINCT(ordergroup_id)')
|
||||
@all_ordergroups.sort_by! {|o| @ordered_group_ids.include?(o.id) ? o.name : "ZZZZZ#{o.name}" }
|
||||
|
||||
|
|
@ -40,4 +40,8 @@ class CurrentOrders::OrdergroupsController < ApplicationController
|
|||
where(group_orders: {order_id: @order_ids, ordergroup_id: @ordergroup.id}).ordered.all unless @ordergroup.nil?
|
||||
end
|
||||
|
||||
helper_method \
|
||||
def articles_for_adding
|
||||
OrderArticle.includes(:article, :article_price).where(order_id: @order_ids)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue