This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/helpers/document_line_helper.rb
Philippe b32ddd37f5 Add front validations for p_article form, add p_article to stock_movement, add AJAX on price_line update method
TODO:
- AJAX for add_p_article and add_stock_movement_p_article in stock_movement views
- Fix select p_article with in stock_movement partial view
- Fix query to display available p_article in stock_movement partial
2021-11-23 20:20:41 +01:00

64 lines
1.9 KiB
Ruby

# -*- encoding : utf-8 -*-
module DocumentLineHelper
def link_to_remove_fields(name, f, options={})
f.hidden_field(:_destroy) + link_to(name, "#",
:onclick => " #{options[:js]} if(confirm('Voulez-vous vraiment supprimer cette ligne ?')) {remove_fields(this);return false;}else{return false;};",
:class => (options[:class]))
end
def link_to_add_fields(name, f, association, options={})
new_object = f.object.class.reflect_on_association(association).klass.new()
if association == :product_options
new_object.product_option_langs << ProductOptionLang.new(:lang => LangSite.first.slug)
end
if association == :p_articles
new_object.p_product_ref_id = f.object.p_product_ref_id
end
if options[:partial]
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render(options[:partial], :form => builder)
end
elsif association == :p_payments
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render("admin/"+association.to_s + "/essentials_form", :form => builder)
end
elsif options[:slug]
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render("admin/"+association.to_s + "/form_#{options[:slug]}", :form => builder)
end
else
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render("admin/"+association.to_s + "/form", :form => builder)
end
end
link_to name,"#",
:onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");#{options[:js]};return false;",
:class => (options[:class]),
tabindex: options[:tabindex],
style: options[:style],
data: options[:data]
end
end