diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index b6b2393..861df04 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -240,9 +240,10 @@ function select_video_from_manager(input_id){ function select_product_from_manager(input_id){ - - manager_prompt("/admin/p_product_refs.html?manager=true",function(m_return){ + + + manager_prompt(p_product_refs_url,function(m_return){ $('.p_product_ref_id_'+input_id).val(m_return.id); $('.p_product_ref_name_'+input_id).val(m_return.name); diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index fbf5675..1f2017e 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -47,6 +47,14 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") respond_to do |format| + format.js{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_product_refs = @p_product_refs.page(page).per(per_page) + + } format.html{ params[:search][:per_page] = params[:search][:per_page] || 100 diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 9e77e44..3a3aeaf 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -1,17 +1,19 @@ -.qi_header - .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false - %h1 - Achats - %span - Produits +-if !@manager + .qi_header + .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false + %h1 + Achats + %span + Références + .qi_search_row - =form_tag "", :method => "get", :onsubmit => "" do + =form_tag admin_p_product_refs_path, :method => "get", :onsubmit => "", :remote => true do =hidden_field_tag :column, params[:column] =hidden_field_tag :direction, params[:direction] - + =hidden_field_tag :manager, params[:manager] %table %tr %td @@ -42,7 +44,7 @@ -=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs} +#p_product_refs_index_wrapper=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs, :remote => true} @@ -52,4 +54,7 @@ }); - \ No newline at end of file + +:coffeescript + $(".qi_search_row form").on "submit", -> + $("#p_product_refs_index_wrapper").html('recherche en cours ...') \ No newline at end of file diff --git a/app/views/admin/p_product_refs/index.js.erb b/app/views/admin/p_product_refs/index.js.erb new file mode 100644 index 0000000..ab3b84a --- /dev/null +++ b/app/views/admin/p_product_refs/index.js.erb @@ -0,0 +1,9 @@ + +var p_product_refs_url = "<%= escape_javascript(request.url) %>"; + + +$('#p_product_refs_index_wrapper').html("<%= escape_javascript(render(:partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs, :remote => true}))%>"); + + + +$(".btn-qi-search").html(' Rechercher'); \ No newline at end of file diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 77c4f79..728e663 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -18,6 +18,9 @@ = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}" %td =link_to ic(:search), "#", class: "ml-2",:onclick => "select_product_from_manager('#{key}');return false;" + + :javascript + var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}" -form.object.forced_price = true if form.object.ct_u_price_ht @@ -39,7 +42,6 @@ .mx-2.form-inline = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte form-control mx-2", tabindex: 1} - = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" %td .form-inline %label.mx-2 Taux de TVA : diff --git a/app/views/qi/_qi_ordered_table.html.haml b/app/views/qi/_qi_ordered_table.html.haml index 79c9a48..b968bab 100644 --- a/app/views/qi/_qi_ordered_table.html.haml +++ b/app/views/qi/_qi_ordered_table.html.haml @@ -1,5 +1,7 @@ - "QI ActsAsCaching V0.6" +- remote = remote || false + -if true -masqued_columns = masqued_columns || nil @@ -183,7 +185,7 @@ .qi_pagination - = paginate qi_ordered_table_collection #, :remote => true + = paginate qi_ordered_table_collection, :remote => remote :scss