add translations, adapt test and fix bug
This commit is contained in:
parent
346e985c49
commit
da1015abd1
9 changed files with 45 additions and 17 deletions
|
|
@ -46,6 +46,11 @@ class ArticlesController < ApplicationController
|
|||
render :layout => false
|
||||
end
|
||||
|
||||
def edit
|
||||
@article = Article.find(params[:id])
|
||||
render :action => 'new', :layout => false
|
||||
end
|
||||
|
||||
def create
|
||||
@article = Article.new(params[:article])
|
||||
if @article.valid? && @article.save
|
||||
|
|
@ -55,11 +60,6 @@ class ArticlesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@article = Article.find(params[:id])
|
||||
render :action => 'new', :layout => false
|
||||
end
|
||||
|
||||
# Updates one Article and highlights the line if succeded
|
||||
def update
|
||||
@article = Article.find(params[:id])
|
||||
|
|
|
|||
|
|
@ -142,9 +142,6 @@ class Article < ApplicationRecord
|
|||
new_unit_quantity = new_article.unit_quantity
|
||||
new_unit = new_article.unit
|
||||
end
|
||||
if options[:update_category] == true
|
||||
new_article_category = new_article.article_category
|
||||
end
|
||||
|
||||
attribute_hash = {
|
||||
:name => [self.name, new_article.name],
|
||||
|
|
@ -158,7 +155,10 @@ class Article < ApplicationRecord
|
|||
:unit_quantity => [self.unit_quantity.to_s.to_f, new_unit_quantity.to_s.to_f],
|
||||
:note => [self.note.to_s, new_article.note.to_s]
|
||||
}
|
||||
attribute_hash[:article_category] = [self.article_category, new_article_category] if new_article_category
|
||||
if options[:update_category] == true
|
||||
new_article_category = new_article.article_category
|
||||
attribute_hash[:article_category] = [self.article_category, new_article_category] unless new_article_category.blank?
|
||||
end
|
||||
|
||||
Article.compare_attributes(attribute_hash)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -82,9 +82,10 @@ class Supplier < ApplicationRecord
|
|||
FoodsoftFile::parse file, options do |status, new_attrs, line|
|
||||
article = articles.undeleted.where(order_number: new_attrs[:order_number]).first
|
||||
|
||||
|
||||
unless new_attrs[:article_category].blank?
|
||||
new_attrs[:article_category] = ArticleCategory.find_match(new_attrs[:article_category]) ? ArticleCategory.find_match(new_attrs[:article_category]) : ArticleCategory.create_or_find_by!(name: new_attrs[:article_category])
|
||||
if new_attrs[:article_category].present? && options[:update_category]
|
||||
new_attrs[:article_category] = ArticleCategory.find_match(new_attrs[:article_category]) || ArticleCategory.create_or_find_by!(name: new_attrs[:article_category])
|
||||
else
|
||||
new_attrs[:article_category] = nil
|
||||
end
|
||||
|
||||
new_attrs[:tax] ||= FoodsoftConfig[:tax_default]
|
||||
|
|
@ -94,7 +95,7 @@ class Supplier < ApplicationRecord
|
|||
if article.nil?
|
||||
new_articles << new_article
|
||||
else
|
||||
unequal_attributes = article.unequal_attributes(new_article, options.slice(:convert_units,:update_category))
|
||||
unequal_attributes = article.unequal_attributes(new_article, options.slice(:convert_units, :update_category))
|
||||
unless unequal_attributes.empty?
|
||||
article.attributes = unequal_attributes
|
||||
updated_article_pairs << [article, unequal_attributes]
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@
|
|||
.control-group
|
||||
%label(for="articles_update_category")
|
||||
= f.check_box "update_category"
|
||||
= "update category ?"
|
||||
= t '.options.update_category'
|
||||
%label(for="articles_outlist_absent")
|
||||
= f.check_box "outlist_absent"
|
||||
= t '.options.outlist_absent'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue