Clean up OrderArticle#new form and related stuff
This commit is contained in:
parent
baa5f16cfc
commit
01264bc0ac
7 changed files with 13 additions and 6 deletions
|
@ -18,11 +18,11 @@ class OrderArticlesController < ApplicationController
|
|||
if @order_article and @order_article.units_to_order == 0
|
||||
@order_article.units_to_order = 1
|
||||
else
|
||||
@order_article = @order.order_articles.build(params[:order_article])
|
||||
end
|
||||
unless @order_article.save
|
||||
render action: :new
|
||||
@order_article = OrderArticle.new(params[:order_article])
|
||||
end
|
||||
@order_article.save!
|
||||
rescue
|
||||
render action: :new
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -199,7 +199,9 @@ class OrderArticle < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def article_and_price_exist
|
||||
errors.add(:article, I18n.t('model.order_article.error_price')) if !(article = Article.find(article_id)) || article.fc_price.nil?
|
||||
errors.add(:article, I18n.t('model.order_article.error_price')) if !(article = Article.find(article_id)) || article.fc_price.nil?
|
||||
rescue
|
||||
errors.add(:article, I18n.t('model.order_article.error_price'))
|
||||
end
|
||||
|
||||
# Associate with current article price if created in a finished order
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
= simple_form_for [@order, @order_article], remote: true do |form|
|
||||
= form.association :order, as: :hidden
|
||||
.modal-header
|
||||
= link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'}
|
||||
%h3= t '.title'
|
||||
.modal-body
|
||||
= form.input :article_id, as: :select, collection: new_order_articles_collection, :label => Article.model_name.human # Why do we need the label?
|
||||
= form.association :article, collection: new_order_articles_collection
|
||||
.modal-footer
|
||||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||
= form.submit class: 'btn btn-primary'
|
||||
|
|
|
@ -78,6 +78,7 @@ de:
|
|||
starts: Läuft vom
|
||||
status: Status
|
||||
order_article:
|
||||
article: Artikel
|
||||
missing_units: Fehlende Einheiten
|
||||
missing_units_short: Fehlende
|
||||
units_to_order: Menge
|
||||
|
|
|
@ -78,6 +78,7 @@ en:
|
|||
starts: Starts at
|
||||
status: Status
|
||||
order_article:
|
||||
article: Article
|
||||
missing_units: Missing units
|
||||
missing_units_short: Missing
|
||||
units_to_order: Amount of units
|
||||
|
|
|
@ -78,6 +78,7 @@ fr:
|
|||
starts: Ouverture le
|
||||
status:
|
||||
order_article:
|
||||
article: Article
|
||||
missing_units: Unités manquantes
|
||||
missing_units_short:
|
||||
units_to_order: Quantité
|
||||
|
|
|
@ -78,6 +78,7 @@ nl:
|
|||
starts: Start op
|
||||
status: Status
|
||||
order_article:
|
||||
article: Artikel
|
||||
missing_units: Missende eenheden
|
||||
missing_units_short: Nodig
|
||||
units_to_order: Aantal eenheden
|
||||
|
|
Loading…
Reference in a new issue