diff --git a/.gitignore b/.gitignore index c554eb26..2bd55feb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ log/*.log tmp/**/* config/*.yml +config/initializers/secret_token.rb db/*.sqlite3 nbproject/ config/environments/development.rb diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index 3f956cd1..b6d9f746 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -37,6 +37,11 @@ body { // Custom styles +// Fix empty dd tags in horizontal dl, see https://github.com/twitter/bootstrap/issues/4062 +.dl-horizontal { + dd { .clearfix(); } +} + @mainRedColor: #ED0606; .logo { @@ -194,4 +199,4 @@ tr.unavailable { input, select { border-color: red; } -} \ No newline at end of file +} diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 4044d454..35bd36db 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -20,7 +20,7 @@ class ArticlesController < ApplicationController sort = "article_categories.name, articles.name" end - @articles = Article.where(supplier_id: @supplier).includes(:article_category).order(sort) + @articles = Article.where(supplier_id: @supplier, :type => nil).includes(:article_category).order(sort) @articles = @articles.where('articles.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil? @articles = @articles.page(params[:page]).per(@per_page) @@ -231,4 +231,4 @@ class ArticlesController < ApplicationController redirect_to supplier_articles_path(@supplier), :notice => "Der Katalog ist aktuell." end end -end \ No newline at end of file +end diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index f3ee9167..a123179a 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -126,4 +126,4 @@ class OrdersController < ApplicationController :type => 'text/plain; charset=utf-8; header=present', :disposition => "attachment; filename=#{order.name}" end -end \ No newline at end of file +end diff --git a/app/controllers/stockit_controller.rb b/app/controllers/stockit_controller.rb index cdd9b633..2a232a31 100644 --- a/app/controllers/stockit_controller.rb +++ b/app/controllers/stockit_controller.rb @@ -32,11 +32,12 @@ class StockitController < ApplicationController end def destroy - StockArticle.find(params[:id]).destroy - redirect_to stock_articles_path + @article = StockArticle.find(params[:id]) + @article.destroy + render :layout => false rescue => error - flash[:error] = "Ein Fehler ist aufgetreten: " + error.message - redirect_to stock_articles_path + render :partial => "destroy_fail", :layout => false, + :locals => { :fail_msg => "Ein Fehler ist aufgetreten: " + error.message } end #TODO: Fix this!! diff --git a/app/documents/order_fax.rb b/app/documents/order_fax.rb index 3630546c..5dd4bfee 100644 --- a/app/documents/order_fax.rb +++ b/app/documents/order_fax.rb @@ -19,6 +19,10 @@ class OrderFax < OrderPdf text contact[:street], align: :right move_down 5 text "#{contact[:zip_code]} #{contact[:city]}", align: :right + move_down 5 + if @order.supplier.customer_number != '' + text "Kundennummer: #{@order.supplier.customer_number}", align: :right + end move_down 10 text contact[:phone], size: 9, align: :right move_down 5 @@ -34,6 +38,7 @@ class OrderFax < OrderPdf text "Fax: " + @order.supplier.fax end + move_down 5 text Date.today.strftime('%d.%m.%Y'), align: :right move_down 10 @@ -66,4 +71,4 @@ class OrderFax < OrderPdf #align: {0 => :left} end -end \ No newline at end of file +end diff --git a/app/views/stockit/_destroy_fail.js.haml b/app/views/stockit/_destroy_fail.js.haml new file mode 100644 index 00000000..a9601900 --- /dev/null +++ b/app/views/stockit/_destroy_fail.js.haml @@ -0,0 +1,5 @@ +-# please polish the following line if you know how, same in view destroy +var errorDiv = $('
'); + +errorDiv.append(document.createTextNode('#{j(fail_msg)}')); +$('div.container-fluid').prepend(errorDiv); diff --git a/app/views/stockit/destroy.js.haml b/app/views/stockit/destroy.js.haml new file mode 100644 index 00000000..66d6d70d --- /dev/null +++ b/app/views/stockit/destroy.js.haml @@ -0,0 +1,14 @@ +-# please polish the following line if you know how, same in partial _destroy_fail +var successDiv = $(''); + +successDiv.append(document.createTextNode('Artikel #{j(@article.name)} gelöscht.')); +$('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. diff --git a/app/views/stockit/index.html.haml b/app/views/stockit/index.html.haml index 5fee8934..c69c1689 100644 --- a/app/views/stockit/index.html.haml +++ b/app/views/stockit/index.html.haml @@ -29,7 +29,6 @@ - Supplier.all.each do |supplier| %li= link_to supplier.name, new_supplier_delivery_path(supplier), tabindex: -1 - %table.table.table-hover#articles %thead %tr @@ -45,7 +44,7 @@ %th %tbody - for article in @stock_articles - %tr{:class => stock_article_classes(article)} + %tr{:class => stock_article_classes(article), :id => "stockArticle-#{article.id}"} %td=h article.name %td= article.quantity %td= article.quantity - article.quantity_available @@ -58,7 +57,8 @@ %td = link_to "Bearbeiten", edit_stock_article_path(article), class: 'btn btn-mini' = link_to "Löschen", article, :method => :delete, :confirm => "Bist Du sicher?", - class: 'btn btn-mini btn-danger' + class: 'btn btn-mini btn-danger', :remote => true + %p Aktueller Lagerwert: = number_to_currency StockArticle.stock_value diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb deleted file mode 100644 index fcbd6c1e..00000000 --- a/config/initializers/secret_token.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -Foodsoft::Application.config.secret_token = '2be5574568ff4d270b108399078a8e485b363af84d441d02d2a6fd3fc51a8c015065790b7e414134e6d97ffc40da898a5a12f66f9de6b992b7ea96e7a34839b8'