From 6cc9d167f5bbadd187338873c7f88861384968e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 28 Sep 2021 17:02:53 +0200 Subject: [PATCH] global search ok / WIP for select filters --- .../admin/p_product_refs_controller.rb | 12 +++++-- .../admin/p_product_refs/index.html.haml | 34 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 5648846..564d597 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -28,8 +28,8 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = @p_product_refs.joins(:fournisseur_product_refs).where("fournisseur_product_refs.ref LIKE ?","%#{params[:search][:fournisseur_ref]}%") end - if params[:search][:name].to_s != "" - @p_product_refs = @p_product_refs.where("p_product_refs.ct_sub_name LIKE ? or p_product_refs.cc_name LIKE ?","%#{params[:search][:name]}%", "%#{params[:search][:name]}%") + if params[:search][:global].to_s != "" + @p_product_refs = PProductRef.global_search(params[:search][:global]) end if params[:search][:p_product_ref_cat_id].to_s != "" @@ -42,7 +42,13 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:s_brand_id].to_s != "" - @p_product_refs = @p_product_refs.where(:s_brand_id => params[:search][:s_brand_id]) + + @p_product_refs = @p_product_refs.where(:s_brand => params[:search][:s_brand_id]) + puts "£££££££££££££££££££££££££££££££££££££" + puts "£££££££££££££££££££££££££££££££££££££" + puts SBrand.find(params[:search][:s_brand_id]).id.to_s + ' ' +SBrand.find(params[:search][:s_brand_id]).name + puts "£££££££££££££££££££££££££££££££££££££" + puts "£££££££££££££££££££££££££££££££££££££" end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 9e77e44..e4564ec 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -14,27 +14,35 @@ %table %tr - %td - Actif : - =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]) + + -if false + %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" + %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" - %td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code" - - %td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur" - - - %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom" - + + %td{style: "min-width: 500px;"} + .input-group + =text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..." + .input-group-append{:onclick => "$(this).prev('input').val('');"} + .btn.btn-outline-primary + =ic(:times) + %table %tr + %td + Actif : + %td + =select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select" %td Catégorie : - =select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]) + %td + =select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]), class: "custom-select" %td Marque : - =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]) + %td + =select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select" @@ -52,4 +60,4 @@ }); - \ No newline at end of file +