Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor NumberInput and RangeInput to be Numeric rather than Stringish
- Loading branch information
Showing
7 changed files
with
66 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Formtastic | ||
module Inputs | ||
module Base | ||
module Numeric | ||
def input_html_options | ||
defaults = super | ||
|
||
if in_option | ||
defaults[:min] = in_option.to_a.min | ||
defaults[:max] = in_option.to_a.max | ||
else | ||
defaults[:min] ||= min_option | ||
defaults[:max] ||= max_option | ||
end | ||
defaults[:step] ||= step_option | ||
defaults | ||
end | ||
|
||
def step_option | ||
return options[:step] if options.key?(:step) | ||
validation_step | ||
end | ||
|
||
def min_option | ||
return options[:min] if options.key?(:min) | ||
validation_min | ||
end | ||
|
||
def max_option | ||
return options[:max] if options.key?(:max) | ||
validation_max | ||
end | ||
|
||
def in_option | ||
options[:in] | ||
end | ||
|
||
def wrapper_html_options | ||
new_class = [super[:class], "numeric"].compact.join(" ") | ||
super.merge(:class => new_class) | ||
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
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