Add possibility to copy an order #348

Merged
merged 1 commit into from Feb 18, 2015

Projects

None yet

3 participants

@paroga
Contributor
paroga commented Feb 18, 2015

If a supplier has a long list of articles, which are all available, but
the order should contain only a subset of them, selecting them for every
order can take a long time. Starting with a copy of an existing order
can safe a lot of time.

@wvengen wvengen commented on an outdated diff Feb 18, 2015
app/controllers/orders_controller.rb
@@ -63,6 +63,11 @@ def show
# Page to create a new order.
def new
@order = Order.new(supplier_id: params[:supplier_id]).init_dates
+ @checkall_articels = true
+ if params[:order_id]
+ @base_order = Order.find(params[:order_id])
+ @checkall_articels = false
+ end
@wvengen
wvengen Feb 18, 2015 Member

Could we also just set it with something like:

if params[:order_id]
  base_order = Order.find(params[:order_id])
  @order.article_ids = base_order.article_ids
end
@wvengen wvengen commented on an outdated diff Feb 18, 2015
app/views/orders/new.html.haml
@@ -1,10 +1,10 @@
- title t('.title')
= render 'form'
-
-- content_for :javascript do
- :javascript
- // select all articles by default
- $(function() {
- $('#checkall').click();
- });
+- if @checkall_articels
@wvengen
wvengen Feb 18, 2015 Member

this could then become: if @order.article_ids.empty?

@wvengen
Member
wvengen commented Feb 18, 2015

Nice idea :)

@paroga paroga Add possibility to copy an order
If a supplier has a long list of articles, which are all available, but
the order should contain only a subset of them, selecting them for every
order can take a long time. Starting with a copy of an existing order
can safe a lot of time.
e57fd50
@wvengen wvengen commented on the diff Feb 18, 2015
app/controllers/orders_controller.rb
@@ -63,6 +63,7 @@ def show
# Page to create a new order.
def new
@order = Order.new(supplier_id: params[:supplier_id]).init_dates
+ @order.article_ids = Order.find(params[:order_id]).article_ids if params[:order_id]
@wvengen
wvengen Feb 18, 2015 Member

even better :)

@wvengen wvengen merged commit 1ac2478 into foodcoops:master Feb 18, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@paroga paroga deleted the foodcoop1040:copy_order branch Feb 18, 2015
@wvengen wvengen modified the milestone: 4.4 Feb 27, 2015
@Tamriel
Tamriel commented Jul 23, 2015

Where can I find this function in the UI?

@wvengen
Member
wvengen commented Jul 30, 2015

In the "manage orders" screen.
foodsoft_-manage_orders-_2015-07-30_20 01 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment