Refactoring of delivery-workflow. Added ability to add stock_changes after creating a delivery.
This commit is contained in:
parent
43fc7b06f8
commit
a8e35bd421
7 changed files with 66 additions and 101 deletions
|
|
@ -22,7 +22,7 @@ class DeliveriesController < ApplicationController
|
|||
|
||||
def new
|
||||
@delivery = @supplier.deliveries.build
|
||||
@supplier.stock_articles.each { |article| @delivery.stock_changes.build(:stock_article => article) }
|
||||
@delivery.stock_changes.build(:stock_article => @supplier.stock_articles.first)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
|
|
@ -79,8 +79,8 @@ class DeliveriesController < ApplicationController
|
|||
render :update do |page|
|
||||
if article.save
|
||||
logger.debug "new StockArticle: #{article.id}"
|
||||
page.insert_html :top, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => article.stock_changes.build}
|
||||
page.insert_html :bottom, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => article.stock_changes.build, :supplier => @supplier}
|
||||
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => @supplier.stock_articles.build}
|
||||
|
|
@ -91,12 +91,11 @@ class DeliveriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def drop_stock_change
|
||||
stock_change = StockChange.find(params[:stock_change_id])
|
||||
stock_change.destroy
|
||||
def add_stock_change
|
||||
|
||||
render :update do |page|
|
||||
page.visual_effect :DropOut, "stock_change_#{stock_change.id}"
|
||||
page.insert_html :bottom, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => StockChange.new, :supplier => @supplier}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -109,13 +108,4 @@ class DeliveriesController < ApplicationController
|
|||
|
||||
render :partial => 'stock_article_form', :locals => {:stock_article => stock_article}
|
||||
end
|
||||
|
||||
def in_place_edit_for_stock_quantity
|
||||
stock_change = StockChange.find(params[:editorId])
|
||||
if stock_change.update_attributes(:quantity => params[:value])
|
||||
render :inline => params[:value]
|
||||
else
|
||||
render :inline => "Ein Fehler ist aufgetreten."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue