allow to synchronize all articles of a shared supplier
This commit is contained in:
parent
3918e22214
commit
647b7f0430
16 changed files with 194 additions and 77 deletions
53
app/views/articles/_sync_table.html.haml
Normal file
53
app/views/articles/_sync_table.html.haml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
%th= heading_helper Article, :name
|
||||
%th= heading_helper Article, :note
|
||||
%th= heading_helper Article, :manufacturer
|
||||
%th= heading_helper Article, :origin
|
||||
%th= heading_helper Article, :unit
|
||||
%th= heading_helper Article, :unit_quantity, short: true
|
||||
%th= heading_helper Article, :price
|
||||
%th= heading_helper Article, :tax
|
||||
%th= heading_helper Article, :deposit
|
||||
%th= heading_helper Article, :article_category
|
||||
%tbody
|
||||
- articles.each do |changed_article, attrs|
|
||||
- unless changed_article.new_record?
|
||||
- article = Article.find(changed_article.id)
|
||||
%tr{:style => 'color:grey'}
|
||||
%td= article.name
|
||||
%td= article.note
|
||||
%td= article.manufacturer
|
||||
%td= article.origin
|
||||
%td= article.unit
|
||||
%td= article.unit_quantity
|
||||
%td= number_to_currency article.price
|
||||
%td= number_to_percentage article.tax
|
||||
%td= number_to_currency article.deposit
|
||||
%td= article.article_category.name if article.article_category
|
||||
%tr
|
||||
= fields_for "#{field}[]", changed_article do |form|
|
||||
%td{:style => highlight_new(attrs, :name)}
|
||||
= form.text_field 'name', :size => 0
|
||||
- hidden_fields.each do |field|
|
||||
= form.hidden_field field
|
||||
%td{:style => highlight_new(attrs, :note)}= form.text_field 'note', class: 'input-small'
|
||||
%td{:style => highlight_new(attrs, :manufacturer)}= form.text_field 'manufacturer', class: 'input-small'
|
||||
%td{:style => highlight_new(attrs, :origin)}= form.text_field 'origin', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :unit)}= form.text_field 'unit', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :unit_quantity)}= form.text_field 'unit_quantity', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :price)}
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= form.text_field 'price', class: 'input-mini', style: 'width: 45px'
|
||||
%td{:style => highlight_new(attrs, :tax)}
|
||||
.input-append
|
||||
= form.text_field 'tax', class: 'input-mini', style: 'width: 45px'
|
||||
%span.add-on %
|
||||
%td{:style => highlight_new(attrs, :deposit)}
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= form.text_field 'deposit', class: 'input-mini', style: 'width: 45px'
|
||||
%td= form.select :article_category_id, ArticleCategory.all.map {|a| [ a.name, a.id ] },
|
||||
{include_blank: true}, class: 'input-small'
|
||||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
- if @supplier.shared_supplier
|
||||
.btn-group
|
||||
= link_to t('.ext_db.import'), "#import", 'data-toggle-this' => '#import', class: 'btn btn-primary'
|
||||
- if @supplier.shared_sync_method == 'import'
|
||||
= link_to t('.ext_db.import'), "#import", 'data-toggle-this' => '#import', class: 'btn btn-primary'
|
||||
= link_to t('.ext_db.sync'), sync_supplier_articles_path(@supplier), method: :post, class: 'btn btn-success'
|
||||
|
||||
.btn-group
|
||||
|
|
|
|||
|
|
@ -1,72 +1,39 @@
|
|||
- title t('.title')
|
||||
|
||||
= form_tag update_synchronized_supplier_articles_path(@supplier) do
|
||||
%h2= t '.outlist.title'
|
||||
%p
|
||||
- unless @outlisted_articles.empty?
|
||||
= t('.outlist.body').html_safe
|
||||
%ul
|
||||
- for article in @outlisted_articles
|
||||
%li
|
||||
= hidden_field_tag "outlisted_articles[#{article.id}]", '1'
|
||||
= article.name
|
||||
- if article.in_open_order
|
||||
.alert= t '.outlist.alert_used', article: article.name
|
||||
- else
|
||||
%i= t '.outlist.body_skip'
|
||||
- if @outlisted_articles.any?
|
||||
%h2= t '.outlist.title'
|
||||
%p
|
||||
= t('.outlist.body').html_safe
|
||||
%ul
|
||||
- for article in @outlisted_articles
|
||||
%li
|
||||
= hidden_field_tag "outlisted_articles[#{article.id}]", '1'
|
||||
= article.name
|
||||
- if article.in_open_order
|
||||
.alert= t '.outlist.alert_used', article: article.name
|
||||
%hr/
|
||||
|
||||
- if @updated_articles.any?
|
||||
%h2= t '.update.title'
|
||||
%p
|
||||
%i
|
||||
= t '.update.update_msg', count: @updated_articles.size
|
||||
= t '.update.body'
|
||||
= render 'sync_table', articles: @updated_articles, field: 'articles', hidden_fields: %w(shared_updated_on)
|
||||
%hr/
|
||||
|
||||
- if @new_articles.any?
|
||||
%h2= t '.upnew.title'
|
||||
%p
|
||||
%i= t '.upnew.body_count', count: @new_articles.length
|
||||
= render 'sync_table', articles: @new_articles, field: 'new_articles', hidden_fields: %w(shared_updated_on order_number)
|
||||
%hr/
|
||||
|
||||
- if @ignored_article_count > 0
|
||||
%i= t '.outlist.body_ignored', count: @ignored_article_count
|
||||
%hr/
|
||||
%h2= t '.update.title'
|
||||
%p
|
||||
%i
|
||||
= t '.update.update_msg', count: @updated_articles.size
|
||||
= t '.update.body'
|
||||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
%th= heading_helper Article, :name
|
||||
%th= heading_helper Article, :note
|
||||
%th= heading_helper Article, :manufacturer
|
||||
%th= heading_helper Article, :origin
|
||||
%th= heading_helper Article, :unit
|
||||
%th= heading_helper Article, :unit_quantity, short: true
|
||||
%th= heading_helper Article, :price
|
||||
%th= heading_helper Article, :tax
|
||||
%th= heading_helper Article, :deposit
|
||||
%th= heading_helper Article, :article_category
|
||||
%tbody
|
||||
- @updated_articles.each do |updated_article, attrs|
|
||||
- article = Article.find(updated_article.id)
|
||||
%tr{:style => 'color:grey'}
|
||||
%td= article.name
|
||||
%td= article.note
|
||||
%td= article.manufacturer
|
||||
%td= article.origin
|
||||
%td= article.unit
|
||||
%td= article.unit_quantity
|
||||
%td= article.price
|
||||
%td= article.tax
|
||||
%td= article.deposit
|
||||
%td= article.article_category.name if article.article_category
|
||||
%tr
|
||||
= fields_for 'articles[]', updated_article do |form|
|
||||
%td{:style => highlight_new(attrs, :name)}
|
||||
= form.text_field 'name', :size => 0
|
||||
= form.hidden_field 'shared_updated_on'
|
||||
%td{:style => highlight_new(attrs, :note)}= form.text_field 'note', class: 'input-small'
|
||||
%td{:style => highlight_new(attrs, :manufacturer)}= form.text_field 'manufacturer', class: 'input-small'
|
||||
%td{:style => highlight_new(attrs, :origin)}= form.text_field 'origin', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :unit)}= form.text_field 'unit', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :unit_quantity)}= form.text_field 'unit_quantity', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :price)}= form.text_field 'price', class: 'input-mini'
|
||||
%td{:style => highlight_new(attrs, :tax), class: 'input-append'}
|
||||
= form.text_field 'tax', class: 'input-mini'
|
||||
%span.add-on %
|
||||
%td{:style => highlight_new(attrs, :deposit)}= form.text_field 'deposit', class: 'input-mini'
|
||||
%td= form.select :article_category_id, ArticleCategory.all.map {|a| [ a.name, a.id ] },
|
||||
{include_blank: true}, class: 'input-small'
|
||||
%hr/
|
||||
%p
|
||||
%i= t '.outlist.body_ignored', count: @ignored_article_count
|
||||
|
||||
= hidden_field 'supplier', 'id'
|
||||
= submit_tag t('.submit'), class: 'btn btn-primary'
|
||||
= link_to t('ui.or_cancel'), supplier_articles_path(@supplier)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue