Merge branch 'rails3' into rails3-to-master
Conflicts: app/views/suppliers/shared_suppliers.haml
This commit is contained in:
commit
71e02ab569
6 changed files with 14 additions and 6 deletions
|
@ -209,7 +209,7 @@ class ArticlesController < ApplicationController
|
||||||
|
|
||||||
# fills a form whith values of the selected shared_article
|
# fills a form whith values of the selected shared_article
|
||||||
def import
|
def import
|
||||||
@article = SharedArticle.find(params[:shared_article_id]).build_new_article
|
@article = SharedArticle.find(params[:shared_article_id]).build_new_article(@supplier)
|
||||||
render :action => 'new', :layout => false
|
render :action => 'new', :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class SuppliersController < ApplicationController
|
||||||
def new
|
def new
|
||||||
if params[:shared_supplier_id]
|
if params[:shared_supplier_id]
|
||||||
shared_supplier = SharedSupplier.find(params[:shared_supplier_id])
|
shared_supplier = SharedSupplier.find(params[:shared_supplier_id])
|
||||||
@supplier = shared_supplier.build_supplier(shared_supplier.autofill_attributes)
|
@supplier = shared_supplier.suppliers.new(shared_supplier.autofill_attributes)
|
||||||
else
|
else
|
||||||
@supplier = Supplier.new
|
@supplier = Supplier.new
|
||||||
end
|
end
|
||||||
|
|
6
app/helpers/suppliers_helper.rb
Normal file
6
app/helpers/suppliers_helper.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module SuppliersHelper
|
||||||
|
|
||||||
|
def associated_supplier_names(shared_supplier)
|
||||||
|
"(#{shared_supplier.suppliers.map(&:name).join(', ')})"
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,8 +7,8 @@ class SharedArticle < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :shared_supplier, :foreign_key => :supplier_id
|
belongs_to :shared_supplier, :foreign_key => :supplier_id
|
||||||
|
|
||||||
def build_new_article
|
def build_new_article(supplier)
|
||||||
shared_supplier.supplier.articles.build(
|
supplier.articles.build(
|
||||||
:name => name,
|
:name => name,
|
||||||
:unit => unit,
|
:unit => unit,
|
||||||
:note => note,
|
:note => note,
|
||||||
|
|
|
@ -5,7 +5,7 @@ class SharedSupplier < ActiveRecord::Base
|
||||||
# set correct table_name in external DB
|
# set correct table_name in external DB
|
||||||
self.table_name = 'suppliers'
|
self.table_name = 'suppliers'
|
||||||
|
|
||||||
has_one :supplier
|
has_many :suppliers
|
||||||
has_many :shared_articles, :foreign_key => :supplier_id
|
has_many :shared_articles, :foreign_key => :supplier_id
|
||||||
|
|
||||||
# These set of attributes are used to autofill attributes of new supplier,
|
# These set of attributes are used to autofill attributes of new supplier,
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
%td= shared_supplier.note
|
%td= shared_supplier.note
|
||||||
%td= shared_supplier.delivery_days
|
%td= shared_supplier.delivery_days
|
||||||
%td
|
%td
|
||||||
- if shared_supplier.supplier
|
- if shared_supplier.suppliers.any?
|
||||||
%i.icon-ok
|
%i.icon-ok
|
||||||
|
= associated_supplier_names(shared_supplier)
|
||||||
|
= link_to t('.subscribe_again'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
|
||||||
- else
|
- else
|
||||||
= link_to t('.subscribe'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
|
= link_to t('.subscribe'), new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
|
||||||
|
|
Loading…
Reference in a new issue