From 49cfa9aded447ad35484b35594777c73dcfd381f Mon Sep 17 00:00:00 2001 From: Julius Date: Tue, 11 Jun 2013 15:05:19 +0200 Subject: [PATCH] Cleanup StockArticle creation during delivery --- app/controllers/deliveries_controller.rb | 14 -------------- app/views/deliveries/_form.html.haml | 10 ++++++++-- app/views/deliveries/_stock_article_form.html.haml | 2 +- config/locales/de.yml | 4 +--- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb index af247462..4604c0c7 100644 --- a/app/controllers/deliveries_controller.rb +++ b/app/controllers/deliveries_controller.rb @@ -87,20 +87,6 @@ class DeliveriesController < ApplicationController 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 diff --git a/app/views/deliveries/_form.html.haml b/app/views/deliveries/_form.html.haml index bfa90114..1fb6a5ce 100644 --- a/app/views/deliveries/_form.html.haml +++ b/app/views/deliveries/_form.html.haml @@ -12,10 +12,16 @@ }) }); +- content_for :javascript do + :javascript + $(function() { + $('#add-stock-change').click(); + }); + .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' + = link_to t('.new_stock_article'), new_stock_article_supplier_deliveries_path(@supplier), remote: true, class: 'btn' = simple_form_for [@supplier, @delivery], validate: true do |f| = f.hidden_field :supplier_id @@ -28,7 +34,7 @@ = 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, class: 'btn btn-small' + = link_to t('.add_article'), {action: 'add_stock_change', supplier_id: @supplier.id}, :id => 'add-stock-change', remote: true, class: 'btn btn-small btn-primary' %hr/ = f.input :delivered_on, as: :date_picker = f.input :note, input_html: {size: '35x4'} diff --git a/app/views/deliveries/_stock_article_form.html.haml b/app/views/deliveries/_stock_article_form.html.haml index 8384eefe..2d3b0906 100644 --- a/app/views/deliveries/_stock_article_form.html.haml +++ b/app/views/deliveries/_stock_article_form.html.haml @@ -2,7 +2,7 @@ = f.hidden_field :supplier_id .modal-header = link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'} - %h3= t '.title' + %h3= t 'activerecord.models.stock_article' .modal-body = f.input :name = f.input :unit diff --git a/config/locales/de.yml b/config/locales/de.yml index 8d48adc0..ccd58e76 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -417,7 +417,7 @@ de: year: Jahr deliveries: add_stock_article: - notice: ! Neuer Lagerartikel »%{name}« gespeichert. Zum Auswählen bitte erneut einen Lagerartikel der Lieferung hinzufügen. + notice: Neuer Lagerartikel »%{name}« gespeichert. Zum Auswählen bitte erneut einen Lagerartikel der Lieferung hinzufügen. create: notice: Lieferung wurde erstellt. Bitte nicht vergessen die Rechnung anzulegen! destroy: @@ -454,8 +454,6 @@ 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.