From 6fdee8a7d6fe8cd99ac0832d662755a0e935b30c Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sat, 21 Jun 2014 14:52:45 +0530 Subject: [PATCH] datetimepicker --- app/assets/javascripts/application.js | 2 ++ app/inputs/datetimepicker_input.rb | 30 ++++++++++++++++++++ app/models/calentry.rb | 3 ++ app/views/calentries/_nested_fields.html.erb | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 app/inputs/datetimepicker_input.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 50fb36d..ebf404f 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -26,6 +26,8 @@ //= require bootstrap/image-gallery.min //= require jquery-fileupload // require jquery.remotipart +//= require jquery.datetimepicker + function insertAttachment(url,name) { var ext = url.split('.').pop().toLowerCase(); var img_ext = [ "jpg", "png", "bmp" , "jpeg" ]; diff --git a/app/inputs/datetimepicker_input.rb b/app/inputs/datetimepicker_input.rb new file mode 100644 index 0000000..5654827 --- /dev/null +++ b/app/inputs/datetimepicker_input.rb @@ -0,0 +1,30 @@ +class DatetimepickerInput < FormtasticBootstrap::Inputs::StringInput + def input_html_options + super + super.merge(:class => "datetimepicker",:value=>builder.to_s) + end + + def html_options + super + + end + def wrapper_html_options + super.merge(:class=>"") + #super.merge(:class=>"datepicker",'date-date-format'.to_sym=>"%d.%m.%Y") + end + def controls_wrapper_html_options + super.merge(:class=> " date input-append", 'data-date'.to_sym =>I18n.l(Date.today()).to_s, 'data-date-format'.to_sym=>I18n.t('date.formats.default-picker'), 'data-time-format'.to_sym=>"hh:mm" ,) + end + def to_html + bootstrap_wrapping do + builder.text_field(method, input_html_options) + + ''.html_safe() + end + end + def options + super +#d.merge(:class=>"datepicker") + #super.merge(:append_content=>''') + end +end diff --git a/app/models/calentry.rb b/app/models/calentry.rb index 8ee967e..2070a03 100644 --- a/app/models/calentry.rb +++ b/app/models/calentry.rb @@ -35,6 +35,9 @@ class Calentry < ActiveRecord::Base self.public = (self.try(:object).nil?)? (self.calendar.try(:public?)) : object.try(:public?) true end + def s_time=(s_time) + start + end def start_time start end diff --git a/app/views/calentries/_nested_fields.html.erb b/app/views/calentries/_nested_fields.html.erb index e4fc987..6f1f97d 100644 --- a/app/views/calentries/_nested_fields.html.erb +++ b/app/views/calentries/_nested_fields.html.erb @@ -4,7 +4,7 @@
- <%= f.input :start, :as => :datepicker %>
+ <%= f.input :start, :as => :datetimepicker %>
<%= f.input :dauer , :as => :string, :append=>"h" %>
<% f.input :typ %>
<%= f.check_box :_destroy %> <%= I18n.t 'common.delete' %>