Début popup produits

This commit is contained in:
Nicolas Bally 2021-09-08 10:18:48 +02:00
parent 8be2ad4ce9
commit eed90a2d33
6 changed files with 47 additions and 13 deletions

View File

@ -42,7 +42,7 @@ function manager_show(url){
function manager_hide(){ function manager_hide(){
$("#manager_box_place").removeClass("manager_box_place_active"); $("#manager_box_place").removeClass("manager_box_place_active");
$('#manager_box').html("");
$("body").css("overflow", "auto"); $("body").css("overflow", "auto");
slider_enabled = null; slider_enabled = null;
@ -239,3 +239,22 @@ 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){
$('.p_product_ref_id_'+input_id).val(m_return.id);
$('.p_product_ref_name_'+input_id).val(m_return.name);
});
}
function send_manager_product(product_id, product_name){
manager_send_response({id : product_id, name : product_name});
}

View File

@ -2,7 +2,8 @@
#manager_box_place{ #manager_box_place{
position:fixed; position:fixed;
height:0; height:0;
width:100%; left:100px;
right:30px;
z-index:1500; z-index:1500;
top:0px; top:0px;
margin:0px; margin:0px;

View File

@ -58,6 +58,11 @@ class Admin::PProductRefsController < ApplicationController
end end
if params[:manager].to_s == "true"
@manager = true
render :layout => false
end
end end
def show def show

View File

@ -17,8 +17,8 @@
.right.actions .large_actions
.actions
=link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn"
=form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add"
.clear

View File

@ -31,6 +31,12 @@
%td.actions %td.actions
=# link_to i(:"trash-o"), [:admin, p_product_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce produit ? ' } , :remote => true if !PriceLine.where(:p_product_ref_id => p_product_ref).first =# link_to i(:"trash-o"), [:admin, p_product_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce produit ? ' } , :remote => true if !PriceLine.where(:p_product_ref_id => p_product_ref).first
=#debug PriceLine.where(:p_product_ref_id => p_product_ref.id).first =#debug PriceLine.where(:p_product_ref_id => p_product_ref.id).first
-if @manager
= link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false, :target => "_blank"
= link_to i(:"check"), "#",:onclick => "send_manager_product('"+p_product_ref.id.to_s+"', '"+escape_javascript(p_product_ref.member_label.to_s)+"');return false;"
-else
= link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false
= link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false

View File

@ -9,12 +9,15 @@
= form.input :ct_title, :label => "Designation personnalisée : " if @avoir = form.input :ct_title, :label => "Designation personnalisée : " if @avoir
%div{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} %div{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
-key = SecureRandom.hex(6)
%label Produit : %label Produit :
%input.p_product_ref_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)} %input.p_product_ref_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref), :class => "p_product_ref_name_#{key}"}
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}"
=link_to "selectionner un produit", "#", :onclick => "select_product_from_manager('#{key}');return false;"
:javascript :javascript
$( function() { $( function() {