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
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_stock_article
|
def new_stock_article
|
||||||
article = @supplier.stock_articles.build(params[:stock_article])
|
@stock_article = @supplier.stock_articles.build
|
||||||
render :update do |page|
|
render :layout => false
|
||||||
if article.save
|
end
|
||||||
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',
|
def add_stock_article
|
||||||
:locals => {:stock_article => @supplier.stock_articles.build}
|
@stock_article = StockArticle.new(params[:stock_article])
|
||||||
else
|
if @stock_article.valid? and @stock_article.save
|
||||||
page.replace_html 'new_stock_article', :partial => 'stock_article_form',
|
render :layout => false
|
||||||
:locals => {:stock_article => article}
|
else
|
||||||
end
|
render :action => 'new_stock_article', :layout => false
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def add_stock_change
|
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|
|
= simple_form_for [@supplier, @delivery], validate: true do |f|
|
||||||
= f.hidden_field :supplier_id
|
= f.hidden_field :supplier_id
|
||||||
#stock_changes
|
#stock_changes
|
||||||
|
@ -23,23 +28,10 @@
|
||||||
= stock_change_form.hidden_field :_destroy
|
= stock_change_form.hidden_field :_destroy
|
||||||
= link_to t('.remove_article'), "#", class: 'destroy_stock_change'
|
= link_to t('.remove_article'), "#", class: 'destroy_stock_change'
|
||||||
%p
|
%p
|
||||||
= link_to t('.add_article'), {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true
|
= link_to t('.add_article'), {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true, class: 'btn btn-small'
|
||||||
%p
|
|
||||||
%small= t('.note_new_article', new_link: link_to(t('.note_new_article_link'), new_stock_article_path)).html_safe
|
|
||||||
%hr/
|
%hr/
|
||||||
= f.input :delivered_on, as: :date_picker
|
= f.input :delivered_on, as: :date_picker
|
||||||
= f.input :note, input_html: {size: '35x4'}
|
= f.input :note, input_html: {size: '35x4'}
|
||||||
.form-actions
|
.form-actions
|
||||||
= f.submit class: 'btn btn-primary'
|
= f.submit class: 'btn btn-primary'
|
||||||
= link_to t('ui.or_cancel'), supplier_deliveries_path(@supplier)
|
= 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,
|
= simple_form_for stock_article, url: add_stock_article_supplier_deliveries_path(supplier), remote: true, validate: true do |f|
|
||||||
validate: true do |f|
|
|
||||||
= f.hidden_field :supplier_id
|
= f.hidden_field :supplier_id
|
||||||
= f.input :name
|
.modal-header
|
||||||
= f.input :unit
|
= link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'}
|
||||||
= f.input :note
|
%h3= t '.title'
|
||||||
= f.input :price
|
.modal-body
|
||||||
= f.input :tax
|
= f.input :name
|
||||||
= f.input :deposit
|
= f.input :unit
|
||||||
= f.association :article_category
|
= f.input :note
|
||||||
= f.submit class: 'btn'
|
- 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)
|
= form.select :stock_article_id, stock_articles_for_select(supplier)
|
||||||
Menge
|
Menge
|
||||||
= form.text_field :quantity, :size => 5, :autocomplete => 'off'
|
= 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))}'));
|
successDiv.append(document.createTextNode('#{escape_javascript(t('.notice', name: @article.name))}'));
|
||||||
$('div.container-fluid').prepend(successDiv);
|
$('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();
|
$('#stockArticle-#{@article.id}').remove();
|
||||||
|
|
||||||
-# WARNING: Do not use a simple .fadeOut() above, because it conflicts with the show/hide function of unavailable articles.
|
-# 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
|
second: Sekunden
|
||||||
year: Jahr
|
year: Jahr
|
||||||
deliveries:
|
deliveries:
|
||||||
|
add_stock_article:
|
||||||
|
notice: ! Neuer Lagerartikel »%{name}« gespeichert. Zum Auswählen bitte <strong>erneut</strong> einen Lagerartikel der Lieferung hinzufügen.
|
||||||
create:
|
create:
|
||||||
notice: Lieferung wurde erstellt. Bitte nicht vergessen die Rechnung anzulegen!
|
notice: Lieferung wurde erstellt. Bitte nicht vergessen die Rechnung anzulegen!
|
||||||
destroy:
|
destroy:
|
||||||
|
@ -424,6 +426,7 @@ de:
|
||||||
title: Lieferung bearbeiten
|
title: Lieferung bearbeiten
|
||||||
form:
|
form:
|
||||||
add_article: Lagerartikel der Lieferung hinzufügen
|
add_article: Lagerartikel der Lieferung hinzufügen
|
||||||
|
new_stock_article: Neuen Lagerartikel anlegen
|
||||||
new_article:
|
new_article:
|
||||||
search: Suche nach Artikeln aus dem <i>%{supplier}</i> Katalog
|
search: Suche nach Artikeln aus dem <i>%{supplier}</i> Katalog
|
||||||
title: Neuen Lagerartikel anlegen
|
title: Neuen Lagerartikel anlegen
|
||||||
|
@ -451,6 +454,8 @@ de:
|
||||||
unit: Einheit
|
unit: Einheit
|
||||||
stock_change:
|
stock_change:
|
||||||
remove_article: Artikel aus Lieferung entfernen
|
remove_article: Artikel aus Lieferung entfernen
|
||||||
|
stock_article_form:
|
||||||
|
title: Lagerartikel
|
||||||
suppliers_overview: Lieferantenübersicht
|
suppliers_overview: Lieferantenübersicht
|
||||||
update:
|
update:
|
||||||
notice: Lieferung wurde aktualisiert.
|
notice: Lieferung wurde aktualisiert.
|
||||||
|
@ -1825,6 +1830,7 @@ de:
|
||||||
edit: Bearbeiten
|
edit: Bearbeiten
|
||||||
marks:
|
marks:
|
||||||
close: ! '×'
|
close: ! '×'
|
||||||
|
success: ! '<i class="icon icon-ok"></i>'
|
||||||
or_cancel: oder abbrechen
|
or_cancel: oder abbrechen
|
||||||
save: Speichern
|
save: Speichern
|
||||||
show: Anzeigen
|
show: Anzeigen
|
||||||
|
|
|
@ -103,6 +103,7 @@ Foodsoft::Application.routes.draw do
|
||||||
|
|
||||||
resources :deliveries do
|
resources :deliveries do
|
||||||
post :drop_stock_change, :on => :member
|
post :drop_stock_change, :on => :member
|
||||||
|
get :new_stock_article, :on => :collection
|
||||||
post :add_stock_article, :on => :collection
|
post :add_stock_article, :on => :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue