From 036bc102826f55102061ee370250331579651a3b Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Sat, 17 Oct 2009 20:33:36 +0200 Subject: [PATCH] Hide/show unavailable articles via js. --- app/controllers/stockit_controller.rb | 9 +-------- app/views/stockit/index.html.haml | 20 ++++++++++++++------ public/stylesheets/main.css | 3 +++ public/stylesheets/print.css | 3 +++ public/stylesheets/sass/main.sass | 5 ++++- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/controllers/stockit_controller.rb b/app/controllers/stockit_controller.rb index 0f9840a2..83cf7ce1 100644 --- a/app/controllers/stockit_controller.rb +++ b/app/controllers/stockit_controller.rb @@ -1,17 +1,10 @@ class StockitController < ApplicationController def index - unless params[:show_not_available] == "1" - @stock_articles = StockArticle.without_deleted.available.all( + @stock_articles = StockArticle.without_deleted.all( :include => [:supplier, :article_category], :order => 'suppliers.name, article_categories.name, articles.name' ) - else - @stock_articles = StockArticle.without_deleted.all( - :include => [:supplier, :article_category], - :order => 'suppliers.name, article_categories.name, articles.name' - ) - end end def new diff --git a/app/views/stockit/index.html.haml b/app/views/stockit/index.html.haml index e700d51b..654e32c5 100644 --- a/app/views/stockit/index.html.haml +++ b/app/views/stockit/index.html.haml @@ -1,5 +1,15 @@ - title "Lagerübersicht: #{StockArticle.available.count} Artikel im Lager" +.menu + - form_tag do + %ul + %li + Ansichtsoptionen + %ul + %li= link_to_function "Nicht verfügbare Artikel zeigen/verstecken", | + "$$('tr.unavailable').invoke('toggleClassName', 'hidden');", :style => "width:15em" | + + %div{:style => "padding:0 0 0.5em 0.7em;margin-bottom:2em"} %span{:style => "float:left"} - form_tag do @@ -20,11 +30,6 @@ %b= link_to "Inventur anlegen", new_stock_taking_path | = link_to "Inventurübersicht", stock_takings_path - | - - unless params[:show_not_available] == "1" - = link_to "Zeige auch nicht verfügbare Lagerartikel", stock_articles_path(:show_not_available => 1) - - else - = link_to "Verstecke nicht verfügbare Artikel", stock_articles_path #articles{:style => "clear:both;margin-top:1em"} %table.list @@ -42,7 +47,10 @@ %th %tbody - for article in @stock_articles - %tr{:class => cycle("even", "odd")} + - class_name = cycle :even, :odd + - class_name += " unavailable hidden" if article.quantity_available <= 0 + - class_name += " supplier_#{article.supplier.id}" + %tr{:class => class_name} %td=h article.name %td= article.quantity %td= article.quantity - article.quantity_available diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 76b667b9..f7ee532e 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -88,6 +88,9 @@ span.click-me { color: grey; font-size: 0.9em; } +.hidden { + display: none; } + #login { margin: auto; width: 27em; diff --git a/public/stylesheets/print.css b/public/stylesheets/print.css index 55f26348..eaa94e01 100644 --- a/public/stylesheets/print.css +++ b/public/stylesheets/print.css @@ -88,6 +88,9 @@ span.click-me { color: grey; font-size: 0.9em; } +.hidden { + display: none; } + #login { margin: auto; width: 27em; diff --git a/public/stylesheets/sass/main.sass b/public/stylesheets/sass/main.sass index 99ed387f..3747ab80 100644 --- a/public/stylesheets/sass/main.sass +++ b/public/stylesheets/sass/main.sass @@ -97,7 +97,10 @@ span.click-me .description color: grey font-size: 0.9em - + +.hidden + display: none + // ********************************* loginpage #login :margin auto