Fix StockArticle creation during delivery; small cleanups
This commit is contained in:
parent
ad29a238f2
commit
e28f3eda65
10 changed files with 66 additions and 44 deletions
|
@ -75,21 +75,32 @@ class DeliveriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def add_stock_article
|
||||
article = @supplier.stock_articles.build(params[:stock_article])
|
||||
render :update do |page|
|
||||
if article.save
|
||||
logger.debug "new StockArticle: #{article.id}"
|
||||
page.insert_html :bottom, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => article.stock_changes.build, :supplier => @supplier}
|
||||
def new_stock_article
|
||||
@stock_article = @supplier.stock_articles.build
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => @supplier.stock_articles.build}
|
||||
else
|
||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
:locals => {:stock_article => article}
|
||||
end
|
||||
def add_stock_article
|
||||
@stock_article = StockArticle.new(params[:stock_article])
|
||||
if @stock_article.valid? and @stock_article.save
|
||||
render :layout => false
|
||||
else
|
||||
render :action => 'new_stock_article', :layout => false
|
||||
end
|
||||
|
||||
#render :update do |page|
|
||||
# if article.save
|
||||
# logger.debug "new StockArticle: #{article.id}"
|
||||
# page.insert_html :bottom, 'stock_changes', :partial => 'stock_change',
|
||||
# :locals => {:stock_change => article.stock_changes.build, :supplier => @supplier}
|
||||
#
|
||||
# page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
# :locals => {:stock_article => @supplier.stock_articles.build}
|
||||
# else
|
||||
# page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
||||
# :locals => {:stock_article => article}
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
def add_stock_change
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
})
|
||||
});
|
||||
|
||||
.well.well-small
|
||||
.btn-toolbar
|
||||
.btn-group
|
||||
= link_to t('.new_stock_article'), new_stock_article_supplier_deliveries_path(@supplier), remote: true, class: 'btn btn-primary'
|
||||
|
||||
= simple_form_for [@supplier, @delivery], validate: true do |f|
|
||||
= f.hidden_field :supplier_id
|
||||
#stock_changes
|
||||
|
@ -23,23 +28,10 @@
|
|||
= stock_change_form.hidden_field :_destroy
|
||||
= link_to t('.remove_article'), "#", class: 'destroy_stock_change'
|
||||
%p
|
||||
= link_to t('.add_article'), {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true
|
||||
%p
|
||||
%small= t('.note_new_article', new_link: link_to(t('.note_new_article_link'), new_stock_article_path)).html_safe
|
||||
= link_to t('.add_article'), {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true, class: 'btn btn-small'
|
||||
%hr/
|
||||
= f.input :delivered_on, as: :date_picker
|
||||
= f.input :note, input_html: {size: '35x4'}
|
||||
.form-actions
|
||||
= f.submit class: 'btn btn-primary'
|
||||
= link_to t('ui.or_cancel'), supplier_deliveries_path(@supplier)
|
||||
|
||||
/
|
||||
TODO: Fix this!!
|
||||
.span6
|
||||
%h2= t '.new_article.title'
|
||||
%p
|
||||
= t('.new_article.search', supplier: @supplier.name).html_safe + ': '
|
||||
= text_field_tag 'article_name'
|
||||
%hr/
|
||||
#stock_article_form
|
||||
= render 'stock_article_form', stock_article: @supplier.stock_articles.build
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
= simple_form_for stock_article, url: add_stock_article_supplier_deliveries_path(@supplier), remote: true,
|
||||
validate: true do |f|
|
||||
= simple_form_for stock_article, url: add_stock_article_supplier_deliveries_path(supplier), remote: true, validate: true do |f|
|
||||
= f.hidden_field :supplier_id
|
||||
= f.input :name
|
||||
= f.input :unit
|
||||
= f.input :note
|
||||
= f.input :price
|
||||
= f.input :tax
|
||||
= f.input :deposit
|
||||
= f.association :article_category
|
||||
= f.submit class: 'btn'
|
||||
.modal-header
|
||||
= link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'}
|
||||
%h3= t '.title'
|
||||
.modal-body
|
||||
= f.input :name
|
||||
= f.input :unit
|
||||
= f.input :note
|
||||
- if stock_article.new_record?
|
||||
= f.input :price
|
||||
= f.input :tax
|
||||
= f.input :deposit
|
||||
- else
|
||||
= f.input :price, :input_html => {:disabled => 'disabled'}, :hint => t('.form.price_hint')
|
||||
= f.association :article_category
|
||||
.modal-footer
|
||||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||
= f.submit class: 'btn btn-primary'
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
= form.select :stock_article_id, stock_articles_for_select(supplier)
|
||||
Menge
|
||||
= form.text_field :quantity, :size => 5, :autocomplete => 'off'
|
||||
= link_to t('.remove_article'), "#", :class => 'remove_new_stock_change'
|
||||
= link_to t('.remove_article'), "#", :class => 'remove_new_stock_change btn btn-small'
|
||||
|
|
3
app/views/deliveries/add_stock_article.js.haml
Normal file
3
app/views/deliveries/add_stock_article.js.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
$('div.container-fluid').prepend('#{j(render(:partial => 'shared/alert_success', :locals => {:alert_message => t('.notice', :name => @stock_article.name)}))}');
|
||||
|
||||
$('#modalContainer').modal('hide');
|
2
app/views/deliveries/new_stock_article.js.haml
Normal file
2
app/views/deliveries/new_stock_article.js.haml
Normal file
|
@ -0,0 +1,2 @@
|
|||
$('#modalContainer').html('#{j(render(:partial => "stock_article_form", :locals => {:stock_article => @stock_article, :supplier => @supplier}))}');
|
||||
$('#modalContainer').modal();
|
5
app/views/shared/_alert_success.haml
Normal file
5
app/views/shared/_alert_success.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
.alert.fade.in.alert-success
|
||||
%a.close{:href => '#', :data => {:dismiss => 'alert'}}
|
||||
= t('ui.marks.close').html_safe
|
||||
= t('ui.marks.success').html_safe
|
||||
= alert_message
|
|
@ -4,11 +4,5 @@ var successDiv = $('<div class="alert fade in alert-success"><a class="close" da
|
|||
successDiv.append(document.createTextNode('#{escape_javascript(t('.notice', name: @article.name))}'));
|
||||
$('div.container-fluid').prepend(successDiv);
|
||||
|
||||
-# WARNING: If you try to use the escape j(...) here, an error occurs:
|
||||
-# Ein Fehler ist aufgetreten: undefined method `gsub' for 50:Fixnum
|
||||
-# However, it should work without without escaping.
|
||||
-# Note that article names which are purely numeric, e.g. 12345, are escaped correctly (see above).
|
||||
|
||||
$('#stockArticle-#{@article.id}').remove();
|
||||
|
||||
-# WARNING: Do not use a simple .fadeOut() above, because it conflicts with the show/hide function of unavailable articles.
|
||||
|
|
|
@ -416,6 +416,8 @@ de:
|
|||
second: Sekunden
|
||||
year: Jahr
|
||||
deliveries:
|
||||
add_stock_article:
|
||||
notice: ! Neuer Lagerartikel »%{name}« gespeichert. Zum Auswählen bitte <strong>erneut</strong> einen Lagerartikel der Lieferung hinzufügen.
|
||||
create:
|
||||
notice: Lieferung wurde erstellt. Bitte nicht vergessen die Rechnung anzulegen!
|
||||
destroy:
|
||||
|
@ -424,6 +426,7 @@ de:
|
|||
title: Lieferung bearbeiten
|
||||
form:
|
||||
add_article: Lagerartikel der Lieferung hinzufügen
|
||||
new_stock_article: Neuen Lagerartikel anlegen
|
||||
new_article:
|
||||
search: Suche nach Artikeln aus dem <i>%{supplier}</i> Katalog
|
||||
title: Neuen Lagerartikel anlegen
|
||||
|
@ -451,6 +454,8 @@ de:
|
|||
unit: Einheit
|
||||
stock_change:
|
||||
remove_article: Artikel aus Lieferung entfernen
|
||||
stock_article_form:
|
||||
title: Lagerartikel
|
||||
suppliers_overview: Lieferantenübersicht
|
||||
update:
|
||||
notice: Lieferung wurde aktualisiert.
|
||||
|
@ -1825,6 +1830,7 @@ de:
|
|||
edit: Bearbeiten
|
||||
marks:
|
||||
close: ! '×'
|
||||
success: ! '<i class="icon icon-ok"></i>'
|
||||
or_cancel: oder abbrechen
|
||||
save: Speichern
|
||||
show: Anzeigen
|
||||
|
|
|
@ -103,6 +103,7 @@ Foodsoft::Application.routes.draw do
|
|||
|
||||
resources :deliveries do
|
||||
post :drop_stock_change, :on => :member
|
||||
get :new_stock_article, :on => :collection
|
||||
post :add_stock_article, :on => :collection
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue