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,12 +18,12 @@ class OrderArticlesController < ApplicationController
|
||||||
if @order_article and @order_article.units_to_order == 0
|
if @order_article and @order_article.units_to_order == 0
|
||||||
@order_article.units_to_order = 1
|
@order_article.units_to_order = 1
|
||||||
else
|
else
|
||||||
@order_article = @order.order_articles.build(params[:order_article])
|
@order_article = OrderArticle.new(params[:order_article])
|
||||||
end
|
end
|
||||||
unless @order_article.save
|
@order_article.save!
|
||||||
|
rescue
|
||||||
render action: :new
|
render action: :new
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@order = Order.find(params[:order_id])
|
@order = Order.find(params[:order_id])
|
||||||
|
|
|
@ -200,6 +200,8 @@ class OrderArticle < ActiveRecord::Base
|
||||||
|
|
||||||
def article_and_price_exist
|
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
|
end
|
||||||
|
|
||||||
# Associate with current article price if created in a finished order
|
# 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|
|
= simple_form_for [@order, @order_article], remote: true do |form|
|
||||||
|
= form.association :order, as: :hidden
|
||||||
.modal-header
|
.modal-header
|
||||||
= link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'}
|
= link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'}
|
||||||
%h3= t '.title'
|
%h3= t '.title'
|
||||||
.modal-body
|
.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
|
.modal-footer
|
||||||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||||
= form.submit class: 'btn btn-primary'
|
= form.submit class: 'btn btn-primary'
|
||||||
|
|
|
@ -78,6 +78,7 @@ de:
|
||||||
starts: Läuft vom
|
starts: Läuft vom
|
||||||
status: Status
|
status: Status
|
||||||
order_article:
|
order_article:
|
||||||
|
article: Artikel
|
||||||
missing_units: Fehlende Einheiten
|
missing_units: Fehlende Einheiten
|
||||||
missing_units_short: Fehlende
|
missing_units_short: Fehlende
|
||||||
units_to_order: Menge
|
units_to_order: Menge
|
||||||
|
|
|
@ -78,6 +78,7 @@ en:
|
||||||
starts: Starts at
|
starts: Starts at
|
||||||
status: Status
|
status: Status
|
||||||
order_article:
|
order_article:
|
||||||
|
article: Article
|
||||||
missing_units: Missing units
|
missing_units: Missing units
|
||||||
missing_units_short: Missing
|
missing_units_short: Missing
|
||||||
units_to_order: Amount of units
|
units_to_order: Amount of units
|
||||||
|
|
|
@ -78,6 +78,7 @@ fr:
|
||||||
starts: Ouverture le
|
starts: Ouverture le
|
||||||
status:
|
status:
|
||||||
order_article:
|
order_article:
|
||||||
|
article: Article
|
||||||
missing_units: Unités manquantes
|
missing_units: Unités manquantes
|
||||||
missing_units_short:
|
missing_units_short:
|
||||||
units_to_order: Quantité
|
units_to_order: Quantité
|
||||||
|
|
|
@ -78,6 +78,7 @@ nl:
|
||||||
starts: Start op
|
starts: Start op
|
||||||
status: Status
|
status: Status
|
||||||
order_article:
|
order_article:
|
||||||
|
article: Artikel
|
||||||
missing_units: Missende eenheden
|
missing_units: Missende eenheden
|
||||||
missing_units_short: Nodig
|
missing_units_short: Nodig
|
||||||
units_to_order: Aantal eenheden
|
units_to_order: Aantal eenheden
|
||||||
|
|
Loading…
Reference in a new issue