95 lines
2.6 KiB
Ruby
95 lines
2.6 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
Date::DATE_FORMATS[:default] = '%d/%m/%Y'
|
|
Time::DATE_FORMATS[:default]= '%d/%m/%Y %H:%M:%S'
|
|
module Formtastic
|
|
|
|
|
|
module Inputs
|
|
|
|
class QiCibleSelectInput
|
|
include Base
|
|
|
|
def to_html
|
|
r = rand(1000000000000000000000000000)
|
|
|
|
|
|
input_wrapping do
|
|
label_html +
|
|
template.content_tag(:fieldset, template.text_field_tag("cible_name", (object.cible ? object.cible.cible_name : "aucuns élément séléctionné"), :id =>"name_#{r}" ) +
|
|
self.manager_select_cible_link(method, options, r) + builder.hidden_field(method.to_s+"_id", input_html_options.merge!(:id => "input_id_"+r.to_s)) +
|
|
builder.hidden_field(method.to_s+"_type", input_html_options.merge!(:id => "input_type_"+r.to_s)) )
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def manager_select_cible_link(method, options, r)
|
|
|
|
template.content_tag(:a, "Modifier ce lien", :href => "#", :onclick => "select_cible_from_manager('"+r.to_s+"');return false;")
|
|
|
|
end
|
|
end
|
|
|
|
class QiImageSelectInput
|
|
include Base
|
|
|
|
def to_html
|
|
r = rand(1000000000000000000000000000)
|
|
|
|
|
|
input_wrapping do
|
|
label_html +
|
|
template.content_tag(:fieldset, manager_select_link(method, options, r) + template.tag(:br) + image_preview(method, options, r) + builder.hidden_field(method.to_s, input_html_options.merge!(:id => "input_"+r.to_s)) )
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def manager_select_link(method, options, r)
|
|
template.content_tag(:a, "Modifier cette image", :href => "#", :onclick => "select_image_from_manager('"+r.to_s+"');return false;")
|
|
end
|
|
|
|
def image_preview(method, options,r)
|
|
if object.send("#{method}?") and ImageFile.exists?(object.send("#{method}"))
|
|
template.content_tag(:span, template.image_tag(object.image_file.file.large.medium.small.thumb.url, :id => "img_"+r.to_s, :onclick => "select_image_from_manager('"+r.to_s+"');return false;"), :class => "preview ")
|
|
else
|
|
template.content_tag(:span, template.image_tag("admin/default_image.png", :id => "img_"+r.to_s, :onclick => "select_image_from_manager('"+r.to_s+"');return false;"), :class => "preview ")
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
class QiDatePickerInput
|
|
include Base
|
|
|
|
def to_html
|
|
r = rand(1000000000000000000000000000)
|
|
|
|
|
|
input_wrapping do
|
|
label_html +
|
|
builder.text_field(method.to_s, input_html_options.merge!(:class => "datepicker"))
|
|
#template.content_tag(:fieldset, manager_select_link(method, options, r) + template.tag(:br) + image_preview(method, options, r) + builder.hidden_field(method.to_s, input_html_options.merge!(:id => "input_"+r.to_s)) )
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
end
|