From eed90a2d33e917ac6d1d39c56d05d0c000d3fbd3 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 8 Sep 2021 10:18:48 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20popup=20produits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/manager.js | 21 ++++++++++++++++++- app/assets/stylesheets/manager.scss | 3 ++- .../admin/p_product_refs_controller.rb | 5 +++++ .../admin/p_customer_sheets/_form.html.haml | 10 ++++----- .../p_product_refs/_p_product_ref.html.haml | 10 +++++++-- app/views/admin/price_lines/_form.html.haml | 11 ++++++---- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index 10623e4..b6b2393 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -42,7 +42,7 @@ function manager_show(url){ function manager_hide(){ $("#manager_box_place").removeClass("manager_box_place_active"); - + $('#manager_box').html(""); $("body").css("overflow", "auto"); 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}); +} + + + diff --git a/app/assets/stylesheets/manager.scss b/app/assets/stylesheets/manager.scss index eb296d2..f03e584 100644 --- a/app/assets/stylesheets/manager.scss +++ b/app/assets/stylesheets/manager.scss @@ -2,7 +2,8 @@ #manager_box_place{ position:fixed; height:0; - width:100%; + left:100px; + right:30px; z-index:1500; top:0px; margin:0px; diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 5648846..fbf5675 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -57,6 +57,11 @@ class Admin::PProductRefsController < ApplicationController } end + + if params[:manager].to_s == "true" + @manager = true + render :layout => false + end end diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index c8c82b9..14bc8a5 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -17,8 +17,8 @@ - .right.actions - =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" - =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" - .clear - + .large_actions + .actions + =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" + =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" + diff --git a/app/views/admin/p_product_refs/_p_product_ref.html.haml b/app/views/admin/p_product_refs/_p_product_ref.html.haml index 33e3f52..ca09295 100644 --- a/app/views/admin/p_product_refs/_p_product_ref.html.haml +++ b/app/views/admin/p_product_refs/_p_product_ref.html.haml @@ -31,8 +31,14 @@ %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 =#debug PriceLine.where(:p_product_ref_id => p_product_ref.id).first - = 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 + + -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(:eye), admin_p_product_ref_path(p_product_ref), :remote => false =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref} diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index ed95396..f16140b 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -9,12 +9,15 @@ = 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 )} + + -key = SecureRandom.hex(6) + %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 $( function() {