edit order user-interface update

also closes foodcoops#145
This commit is contained in:
wvengen 2014-02-20 12:37:51 +01:00
parent 63e2ec9d49
commit 8c0df3b4e8
12 changed files with 62 additions and 15 deletions

View file

@ -2,4 +2,4 @@ class DatePickerInput < SimpleForm::Inputs::StringInput
def input
@builder.text_field(attribute_name, input_html_options.merge({class: 'datepicker'}))
end
end
end

View file

@ -0,0 +1,19 @@
# DateTime picker using bootstrap-datepicker for the time part
# requires `date_time_attribute` gem and active on the attribute
# http://stackoverflow.com/a/20317763/2866660
# https://github.com/einzige/date_time_attribute
class DatePickerTimeInput < SimpleForm::Inputs::StringInput
def input
# Date format must match datepicker's, see app/assets/application.js .
# And for html5 inputs, match RFC3339, see http://dev.w3.org/html5/markup/datatypes.html#form.data.date .
# In the future, use html5 date&time inputs. This needs modernizr or equiv. to avoid
# double widgets, and perhaps conditional css to adjust input width (chrome).
value = @builder.object.send attribute_name
date_options = {as: :string, class: 'input-small datepicker', value: value.try {|e| e.strftime('%Y-%m-%d')}}
time_options = {as: :string, class: 'input-mini', value: value.try {|e| e.strftime('%H:%M')}}
@builder.input_field("#{attribute_name}_date", input_html_options.merge(date_options)) + ' ' +
@builder.input_field("#{attribute_name}_time", input_html_options.merge(time_options))
# time_select requires a date_select
#@builder.time_select("#{attribute_name}_time", {ignore_date: true}, input_html_options.merge(time_options))
end
end