From 877824fba4a850ab71760391412e7e8ddb9bc386 Mon Sep 17 00:00:00 2001
From: Philippe
Date: Fri, 5 Nov 2021 18:46:32 +0100
Subject: [PATCH] adding select2 on price_line_block in price_document_new
---
app/assets/javascripts/pane_hover.js | 7 +++
.../_form_facture_achat.html.haml | 11 +++--
.../price_line_p_articles/_form.html.haml | 2 +-
.../_add_price_line_p_article_form.html.haml | 4 +-
app/views/admin/price_lines/_form.html.haml | 44 ++++++++++---------
app/views/qi/_actions.html.haml | 4 ++
6 files changed, 43 insertions(+), 29 deletions(-)
create mode 100644 app/views/qi/_actions.html.haml
diff --git a/app/assets/javascripts/pane_hover.js b/app/assets/javascripts/pane_hover.js
index 3bb1844..8960543 100644
--- a/app/assets/javascripts/pane_hover.js
+++ b/app/assets/javascripts/pane_hover.js
@@ -25,6 +25,13 @@ function show_pane_hover(content, width, height, zindex){
$(".datepicker").attr("autocomplete", "off");
+ $(document).keyup(function(e) {
+ if (e.keyCode == 27) {
+ close_pane_hover();
+ return false;
+ }
+ });
+
}
diff --git a/app/views/admin/price_line_blocks/_form_facture_achat.html.haml b/app/views/admin/price_line_blocks/_form_facture_achat.html.haml
index 001336e..ca2fae3 100644
--- a/app/views/admin/price_line_blocks/_form_facture_achat.html.haml
+++ b/app/views/admin/price_line_blocks/_form_facture_achat.html.haml
@@ -63,7 +63,7 @@
=f.semantic_fields_for :price_lines do |f|
=render :partial => "admin/price_lines/form_bon_de_reception_achat", :locals => {:form => f}
- %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"}
+ %p= link_to_add_fields "Ajouter une ligneeeeeee", f, :price_lines, {:class => "btn btn-primary add_lines"}
-if current_admin.has_permission?("payments")
@@ -104,6 +104,9 @@
-if false
= f.input :ct_payment_month_end, :label => "Fin de mois ?"
-
-
-
+:javascript
+ $('.add_lines').click(function() {
+ console.log('LENGTH ' + $('.p_product_ref_select').length)
+ $('.p_product_ref_select').last().select2();
+ $('.p_product_ref_select').last().removeClass('form-control');
+ })
diff --git a/app/views/admin/price_line_p_articles/_form.html.haml b/app/views/admin/price_line_p_articles/_form.html.haml
index ce107a0..adf36d2 100644
--- a/app/views/admin/price_line_p_articles/_form.html.haml
+++ b/app/views/admin/price_line_p_articles/_form.html.haml
@@ -2,4 +2,4 @@
:javascript
$('.p_article_select').select2();
- $('.p_article_select').removeClass('form-control');
\ No newline at end of file
+ $('.p_article_select').removeClass('form-control');
diff --git a/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml
index 7aa687c..b601611 100644
--- a/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml
+++ b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml
@@ -5,6 +5,4 @@
= f.semantic_fields_for :price_line_p_articles do |form|
=render :partial => "admin/price_line_p_articles/form", :locals => {:form => form}
%p= link_to_add_fields "Ajouter un article", f, :price_line_p_articles, {:class => "btn btn-primary"} if @price_line.p_articles.count < @price_line.qte
- =link_to "Annuler", "#", class:"btn btn-default", onclick:"close_pane_hover();return false;"
- =f.submit "sauvegarder", :class => "btn btn-primary"
-
\ No newline at end of file
+ =render :partial => "qi/actions", :locals => {:f => f}
diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml
index 839313b..5e3ba63 100644
--- a/app/views/admin/price_lines/_form.html.haml
+++ b/app/views/admin/price_lines/_form.html.haml
@@ -1,48 +1,50 @@
-%tr.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
+.row.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
- %td{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
- .take.mr-1
- =ic :arrows
- %td{:style => "white-space: nowrap;"}
+
+ .take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
+ =ic :arrows
+ .col-3{:style => "white-space: nowrap;"}
+ =form.input :p_product_ref, as: :select, collection: PProductRef.all.map{ |p_product_ref| [p_product_ref.member_label, p_product_ref.id] }, label: "Référence", input_html: {class:"p_product_ref_select"}
.input-group
- %label Référence
- %input.p_product_ref_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref), :class => "p_product_ref_name"}
- = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
- .input-group-append
- =link_to "#", class: "btn btn-dark",:onclick => "key=genRanHex(12);select_product_from_manager(key);$(this).closest('tr').find('.p_product_ref_id').attr('id', 'p_product_ref_id_'+key);$(this).closest('tr').find('.p_product_ref_name').attr('id', 'p_product_ref_name_'+key);$(this).closest('tr').find('.p_product_ref_qte').attr('id', 'p_product_ref_qte_'+key);return false;" do
- =ic(:search)
+ -# %label Référence
+ -# %input.p_product_ref_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref), :class => "p_product_ref_name"}
+ -# = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
+
+ -# .input-group-append
+ -# =link_to "#", class: "btn btn-dark",:onclick => "key=genRanHex(12);select_product_from_manager(key);$(this).closest('tr').find('.p_product_ref_id').attr('id', 'p_product_ref_id_'+key);$(this).closest('tr').find('.p_product_ref_name').attr('id', 'p_product_ref_name_'+key);$(this).closest('tr').find('.p_product_ref_qte').attr('id', 'p_product_ref_qte_'+key);return false;" do
+ -# =ic(:search)
-form.object.forced_price = true if form.object.ct_u_price_ht
-# -if form.object.forced_price and form.object.p_product_ref
- -# %td
+ -# .col-3
-# .mx-2
-# .form-inline
-# =qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label => false, label_class: "mr-1", :value => form.object.th_price_u_ht)
-# -else
- -# %td
+ -# .col-3
-# .mx-2
-# .form-inline
-# =qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label =>false, label_class: "mr-1")
- -# %td
+ -# .col-3
-# .form-inline.mr-2{:style => ("display:none;" if !current_admin or !current_admin.has_permission?("customer-sheets-personalised-price"))}
-# = form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "form-inline input_price_line_forced_price"}
-# .forced_price_wrapper.mx-2{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"}
- %td
+ .col-3
= form.input :qte, :label => "Quantité", :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1}
- %td
+ .col-3
= form.input :ct_u_price_ht, :label => "Prix Unitaire HT :", :input_html => { class: "mx-2"}
- -# %td
+ -# .col-3
-# =form.input :ct_tva_account_id, :collection => options_from_collection_for_select(TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, "id", "member_label", form.object.tva_account_id), :as => :select ,:label => false, :include_blank => false , :input_html => {:class => "input_price_line_tva_account_id form-control custom-select"}
- %td
- %span.destroy=link_to_remove_fields ic(:"trash-o"), form
- =qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
+ .col-1.text-center.my-auto
+ %span.destroy{style: "font-size: 2rem;"}=link_to_remove_fields ic(:"trash-o"), form
+ = qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
= form.hidden_field :position, :class => "price_line_position_input"
-:javascript
+:javascript
$('.p_product_ref_autocomplete_input').focus()
$( function() {
$('.p_product_ref_autocomplete_input').autocomplete({
diff --git a/app/views/qi/_actions.html.haml b/app/views/qi/_actions.html.haml
new file mode 100644
index 0000000..cf5d322
--- /dev/null
+++ b/app/views/qi/_actions.html.haml
@@ -0,0 +1,4 @@
+%hr
+=link_to "Annuler", "#", class:"btn btn-default", onclick:"close_pane_hover();return false;"
+=f.submit "sauvegarder", :class => "btn btn-primary"
+
\ No newline at end of file