-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #826 from justinfrench/rename_timeish_inputs
Rename DateInput, TimeInput, DatetimeInput:
- Loading branch information
Showing
20 changed files
with
294 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,10 @@ | ||
module Formtastic | ||
module Inputs | ||
# Outputs a series of select boxes for the fragments that make up a date (year, month, day). | ||
# | ||
# @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. | ||
class DateInput | ||
include Base | ||
include Base::Timeish | ||
|
||
# We don't want hour and minute fragments on a date input | ||
def time_fragments | ||
[] | ||
class DateInput < DateSelectInput | ||
def to_html | ||
::ActiveSupport::Deprecation.warn("DateInput (:as => :date) has been renamed to DateSelectInput (:as => :date_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2)) | ||
super | ||
end | ||
|
||
def hidden_date_fragments | ||
default_date_fragments - date_fragments | ||
end | ||
|
||
def hidden_fragments | ||
hidden_date_fragments.map do |fragment| | ||
template.hidden_field_tag(hidden_field_name(fragment), fragment_value(fragment), :id => fragment_id(fragment), :disabled => input_html_options[:disabled] ) | ||
end.join.html_safe | ||
end | ||
|
||
def fragment_value(fragment) | ||
if fragment == :year | ||
Time.now.year | ||
else | ||
'1' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Formtastic | ||
module Inputs | ||
# Outputs a series of select boxes for the fragments that make up a date (year, month, day). | ||
# | ||
# @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. | ||
class DateSelectInput | ||
include Base | ||
include Base::Timeish | ||
|
||
# We don't want hour and minute fragments on a date input | ||
def time_fragments | ||
[] | ||
end | ||
|
||
def hidden_date_fragments | ||
default_date_fragments - date_fragments | ||
end | ||
|
||
def hidden_fragments | ||
hidden_date_fragments.map do |fragment| | ||
template.hidden_field_tag(hidden_field_name(fragment), fragment_value(fragment), :id => fragment_id(fragment), :disabled => input_html_options[:disabled] ) | ||
end.join.html_safe | ||
end | ||
|
||
def fragment_value(fragment) | ||
if fragment == :year | ||
Time.now.year | ||
else | ||
'1' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
module Formtastic | ||
module Inputs | ||
|
||
# Outputs a series of select boxes for the fragments that make up a date and time (year, month, day, hour, minute, second). | ||
# | ||
# @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. | ||
class DatetimeInput | ||
include Base | ||
include Base::Timeish | ||
class DatetimeInput < DatetimeSelectInput | ||
def to_html | ||
::ActiveSupport::Deprecation.warn("DatetimeInput (:as => :datetime) has been renamed to DatetimeSelectInput (:as => :datetime_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2)) | ||
super | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Formtastic | ||
module Inputs | ||
|
||
# Outputs a series of select boxes for the fragments that make up a date and time (year, month, day, hour, minute, second). | ||
# | ||
# @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. | ||
class DatetimeSelectInput | ||
include Base | ||
include Base::Timeish | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,10 @@ | ||
module Formtastic | ||
module Inputs | ||
# Outputs a series of select boxes for the fragments that make up a time (hour, minute, second). | ||
# Unless `:ignore_date` is true, it will render hidden inputs for the year, month and day as | ||
# well, defaulting to `Time.current` if the form object doesn't have a value, much like Rails' | ||
# own `time_select`. | ||
# | ||
# @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. | ||
class TimeInput | ||
include Base | ||
include Base::Timeish | ||
|
||
# we don't want year / month / day fragments if :ignore_date => true | ||
def fragments | ||
time_fragments | ||
class TimeInput < TimeSelectInput | ||
def to_html | ||
::ActiveSupport::Deprecation.warn("TimeInput (:as => :time) has been renamed to TimeSelectInput (:as => :time_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2)) | ||
super | ||
end | ||
|
||
def fragment_value(fragment) | ||
value ? value.send(fragment) : "" | ||
end | ||
|
||
def hidden_fragments | ||
if !options[:ignore_date] | ||
date_fragments.map do |fragment| | ||
template.hidden_field_tag(hidden_field_name(fragment), fragment_value(fragment), :id => fragment_id(fragment), :disabled => input_html_options[:disabled] ) | ||
end.join.html_safe | ||
else | ||
super | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Formtastic | ||
module Inputs | ||
# Outputs a series of select boxes for the fragments that make up a time (hour, minute, second). | ||
# Unless `:ignore_date` is true, it will render hidden inputs for the year, month and day as | ||
# well, defaulting to `Time.current` if the form object doesn't have a value, much like Rails' | ||
# own `time_select`. | ||
# | ||
# @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. | ||
class TimeSelectInput | ||
include Base | ||
include Base::Timeish | ||
|
||
# we don't want year / month / day fragments if :ignore_date => true | ||
def fragments | ||
time_fragments | ||
end | ||
|
||
def fragment_value(fragment) | ||
value ? value.send(fragment) : "" | ||
end | ||
|
||
def hidden_fragments | ||
if !options[:ignore_date] | ||
date_fragments.map do |fragment| | ||
template.hidden_field_tag(hidden_field_name(fragment), fragment_value(fragment), :id => fragment_id(fragment), :disabled => input_html_options[:disabled] ) | ||
end.join.html_safe | ||
else | ||
super | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.