Merge pull request #361 from foodcoops/feature/spreadsheets

Let upload provide same functionality as shared database sync
This commit is contained in:
wvengen 2015-04-17 19:18:44 +02:00
commit b028431bf0
21 changed files with 490 additions and 343 deletions

View file

@ -0,0 +1,32 @@
- 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_article_pairs.any?
%h2= t '.update.title'
%p
%i
= t '.update.update_msg', count: @updated_article_pairs.size
= t '.update.body'
= render 'sync_table', articles: @updated_article_pairs, 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
%p
%i= t '.outlist.body_ignored', count: ignored_article_count

View file

@ -51,3 +51,6 @@
= 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'
- unless changed_article.errors.empty?
%tr.alert
%td(colspan=11)= changed_article.errors.full_messages.join(', ')

View file

@ -1,11 +1,8 @@
- title t('.title', supplier: @supplier.name)
%p= t('.body').html_safe
= form_tag(create_from_upload_supplier_articles_path(@supplier)) do
= render layout: 'edit_all_table' do |form|
= form.hidden_field :manufacturer
= form.hidden_field :origin
= form_tag update_synchronized_supplier_articles_path(@supplier) do
= hidden_field_tag :from_action, 'parse_upload'
= render 'sync'
.form-actions
= submit_tag t('.submit', supplier: @supplier.name), class: 'btn btn-primary'
= submit_tag t('.submit'), class: 'btn btn-primary'
= link_to t('ui.or_cancel'), upload_supplier_articles_path(@supplier)

View file

@ -1,39 +1,8 @@
- title t('.title')
= form_tag update_synchronized_supplier_articles_path(@supplier) do
- 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
%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)
= hidden_field_tag :from_action, 'sync'
= render 'sync'
.form-actions
= submit_tag t('.submit'), class: 'btn btn-primary'
= link_to t('ui.or_cancel'), supplier_articles_path(@supplier)

View file

@ -1,24 +1,88 @@
- title t('.title', supplier: @supplier.name)
= t('.body').html_safe
%pre
= [t('.fields.status'),
Article.human_attribute_name(:order_number),
Article.human_attribute_name(:name),
Article.human_attribute_name(:note),
Article.human_attribute_name(:manufacturer),
Article.human_attribute_name(:origin),
Article.human_attribute_name(:unit),
Article.human_attribute_name(:price),
Article.human_attribute_name(:tax),
Article.human_attribute_name(:deposit),
Article.human_attribute_name(:unit_quantity),
t('.fields.reserved'),
t('.fields.reserved'),
Article.human_attribute_name(:article_category)].join(" | ")
%p= t '.text_1', supplier: @supplier.name
%table.table.table-bordered
%thead
%tr
%th= t '.field.status'
%th= Article.human_attribute_name(:order_number)
%th= Article.human_attribute_name(:name)
%th= Article.human_attribute_name(:note)
%th= Article.human_attribute_name(:manufacturer)
%th= Article.human_attribute_name(:origin)
%th= Article.human_attribute_name(:unit)
%th= Article.human_attribute_name(:price)
%th= Article.human_attribute_name(:tax)
%th= Article.human_attribute_name(:deposit)
%th= Article.human_attribute_name(:unit_quantity)
%th.muted= t '.fields.reserved'
%th.muted= t '.fields.reserved'
%th= Article.human_attribute_name(:article_category)
%tbody
%tr
%td
%td 1234A
%td= t '.sample.walnuts'
%td
%td= t '.sample.supplier_1'
%td CA
%td 500 gr
%td 8.90
%td= FoodsoftConfig[:tax_default] || 6
%td 0
%td 6
%td
%td
%td= t '.sample.nuts'
%tr
%td x
%td 4321Z
%td= t '.sample.tomato_juice'
%td= t '.sample.organic'
%td= t '.sample.supplier_2'
%td IN
%td 1.5 l
%td 4.35
%td= FoodsoftConfig[:tax_default] || 6
%td 0
%td 1
%td
%td
%td= t '.sample.juices'
%tr
%td
%td 4322Q
%td= t '.sample.tomato_juice'
%td= t '.sample.organic'
%td= t '.sample.supplier_3'
%td TR
%td 1.2 l
%td 4.02
%td= FoodsoftConfig[:tax_default] || 6
%td 0
%td 2
%td
%td
%td= t '.sample.juices'
%p= t '.text_2'
= form_for :articles, :url => parse_upload_supplier_articles_path(@supplier),
:html => { :multipart => true } do |f|
%label(for="articles_file")= t '.file_label'
= f.file_field "file"
:html => { multipart: true, class: "form-horizontal" } do |f|
.control-group
%label(for="articles_file")= t '.file_label'
= f.file_field "file"
.control-group
%label(for="articles_outlist_absent")
= f.check_box "outlist_absent"
= t '.options.outlist_absent'
%label(for="articles_convert_units")
= f.check_box "convert_units"
= t '.options.convert_units'
.form-actions
= submit_tag t('.submit'), class: 'btn'
= submit_tag t('.submit'), class: 'btn btn-primary'
= link_to t('ui.or_cancel'), supplier_articles_path(@supplier)