Copy to clipboard
This commit is contained in:
parent
1e5316a3bf
commit
6f00816efc
@ -320,7 +320,7 @@
|
|||||||
|
|
||||||
-if @price_document.label == "Demande prix"
|
-if @price_document.label == "Demande prix"
|
||||||
|
|
||||||
%h3 Réponses fournisseur
|
%h3.ml-2 Réponses fournisseur
|
||||||
#bills
|
#bills
|
||||||
-params[:search][:per_page] = params[:search][:per_page] || 5000
|
-params[:search][:per_page] = params[:search][:per_page] || 5000
|
||||||
-per_page = params[:search][:per_page]
|
-per_page = params[:search][:per_page]
|
||||||
@ -341,7 +341,7 @@
|
|||||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"}
|
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"}
|
||||||
|
|
||||||
|
|
||||||
%h3 Consultations fournisseur
|
%h3.ml-2 Consultations fournisseur
|
||||||
#consult
|
#consult
|
||||||
-params[:search][:per_page] = params[:search][:per_page] || 5000
|
-params[:search][:per_page] = params[:search][:per_page] || 5000
|
||||||
-per_page = params[:search][:per_page]
|
-per_page = params[:search][:per_page]
|
||||||
@ -370,25 +370,55 @@
|
|||||||
|
|
||||||
-@price_documents.each do |price_document_consult|
|
-@price_documents.each do |price_document_consult|
|
||||||
|
|
||||||
=link_to ic(:clipboard) + " test clipboard TODO", "#", class: "right btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
|
%h4.ml-2= price_document_consult.p_fournisseur.name
|
||||||
%h4= price_document_consult.p_fournisseur.name
|
|
||||||
= semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
|
= semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
|
||||||
= form.button ic(:clipboard) + "Valider modifications (TODO +copier la consultation)", type: :submit, class: "btn btn-primary m-2"
|
= form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2"
|
||||||
|
=link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
|
||||||
.price-lines{"data-document" => price_document_consult.id}
|
.price-lines{"data-document" => price_document_consult.id}
|
||||||
=form.semantic_fields_for :price_line_block do |f|
|
=form.semantic_fields_for :price_line_block do |f|
|
||||||
=f.semantic_fields_for :price_lines do |form|
|
.mx-2
|
||||||
=render partial: "admin/price_lines/form_consult", locals: {form: form}
|
=f.semantic_fields_for :price_lines do |form|
|
||||||
|
=render partial: "admin/price_lines/form_consult", locals: {form: form}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
const copyPriceLines = (event) => {
|
const copyPriceLines = (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
console.log(event.target.dataset.document)
|
let priceDocumentId = event.target.dataset.document
|
||||||
let result = $('div[data-document=38]')
|
let names = $(`.p_product_ref_cc_name_${priceDocumentId}`)
|
||||||
copy(result)
|
let qtes = $(`.input_price_line_qte_${priceDocumentId}`)
|
||||||
}
|
let prices = $(`.price_line_price_u_ht_${priceDocumentId}`)
|
||||||
const copy = (element) => {
|
|
||||||
element.select()
|
let table = []
|
||||||
document.execCommand("copy")
|
names.each(function( i ) {
|
||||||
|
let row = []
|
||||||
|
row.push(qtes[i].valueAsNumber)
|
||||||
|
row.push(" X ")
|
||||||
|
row.push(names[i].innerText)
|
||||||
|
row.push(" @ ")
|
||||||
|
row.push(prices[i].innerText)
|
||||||
|
table.push(row.join(' '))
|
||||||
|
})
|
||||||
|
copyStringToClipboard(table.join('\r\n'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyStringToClipboard (str) {
|
||||||
|
// Create new element
|
||||||
|
var el = document.createElement('textarea');
|
||||||
|
// Set value (string to be copied)
|
||||||
|
el.value = str;
|
||||||
|
// Set non-editable to avoid focus and move outside of view
|
||||||
|
el.setAttribute('readonly', '');
|
||||||
|
el.style = {position: 'absolute', left: '-9999px'};
|
||||||
|
document.body.appendChild(el);
|
||||||
|
// Select text inside element
|
||||||
|
el.select();
|
||||||
|
// Copy text to clipboard
|
||||||
|
document.execCommand('copy');
|
||||||
|
// Remove temporary element
|
||||||
|
document.body.removeChild(el);
|
||||||
|
}
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
- price_line = form.object
|
- price_line = form.object
|
||||||
.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
|
.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
|
||||||
.row
|
.row
|
||||||
.col-1
|
.col-6.d-flex
|
||||||
.take.mr-1
|
.take.mr-4
|
||||||
=ic :arrows
|
=ic :arrows
|
||||||
.col-6
|
.mr-1
|
||||||
Produit :
|
ref :
|
||||||
=price_line.p_product_ref.cc_name
|
%div{class: "p_product_ref_cc_name_#{price_line.price_line_block.price_lineable_id}"}
|
||||||
|
=price_line.p_product_ref.cc_name
|
||||||
|
|
||||||
.col-2
|
|
||||||
|
.col-3.d-flex
|
||||||
Base de prix U HT :
|
Base de prix U HT :
|
||||||
= price_line.price_u_ht
|
%div{class: "mx-1 price_line_price_u_ht_#{price_line.price_line_block.price_lineable_id}"}
|
||||||
€
|
= price_line.price_u_ht
|
||||||
|
€
|
||||||
.col-3
|
.col-3
|
||||||
.form-inline
|
.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_#{price_line.price_line_block.price_lineable_id} form-control mx-2", tabindex: 1}
|
||||||
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
|
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
|
||||||
|
|
||||||
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
|
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
|
||||||
|
Reference in New Issue
Block a user