Popup produits

This commit is contained in:
Nicolas Bally 2021-09-16 20:01:42 +02:00
parent bfafa906ce
commit 1609c92ab7
6 changed files with 41 additions and 14 deletions

View File

@ -240,9 +240,10 @@ function select_video_from_manager(input_id){
function select_product_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_id_'+input_id).val(m_return.id);
$('.p_product_ref_name_'+input_id).val(m_return.name); $('.p_product_ref_name_'+input_id).val(m_return.name);

View File

@ -47,6 +47,14 @@ class Admin::PProductRefsController < ApplicationController
@p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC")
respond_to do |format| 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{ format.html{
params[:search][:per_page] = params[:search][:per_page] || 100 params[:search][:per_page] = params[:search][:per_page] || 100

View File

@ -1,17 +1,19 @@
.qi_header -if !@manager
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false .qi_header
%h1 .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
Achats %h1
%span Achats
Produits %span
Références
.qi_search_row .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 :column, params[:column]
=hidden_field_tag :direction, params[:direction] =hidden_field_tag :direction, params[:direction]
=hidden_field_tag :manager, params[:manager]
%table %table
%tr %tr
%td %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 @@
}); });
:coffeescript
$(".qi_search_row form").on "submit", ->
$("#p_product_refs_index_wrapper").html('recherche en cours ...')

View File

@ -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('<i class="fa fa-search "></i> Rechercher');

View File

@ -18,6 +18,9 @@
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}" = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}"
%td %td
=link_to ic(:search), "#", class: "ml-2",:onclick => "select_product_from_manager('#{key}');return false;" =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 -form.object.forced_price = true if form.object.ct_u_price_ht
@ -39,7 +42,6 @@
.mx-2.form-inline .mx-2.form-inline
= form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte form-control mx-2", tabindex: 1} = 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 %td
.form-inline .form-inline
%label.mx-2 Taux de TVA : %label.mx-2 Taux de TVA :

View File

@ -1,5 +1,7 @@
- "QI ActsAsCaching V0.6" - "QI ActsAsCaching V0.6"
- remote = remote || false
-if true -if true
-masqued_columns = masqued_columns || nil -masqued_columns = masqued_columns || nil
@ -183,7 +185,7 @@
.qi_pagination .qi_pagination
= paginate qi_ordered_table_collection #, :remote => true = paginate qi_ordered_table_collection, :remote => remote
:scss :scss