MoneyInput (:as => :money) #649

Closed
justinfrench opened this Issue Aug 9, 2011 · 9 comments

Comments

Projects
None yet
2 participants
Owner

justinfrench commented Aug 9, 2011

Could be useful for wrapping up Money and composed_of stuff. See #645.

EppO commented Dec 19, 2011

I am currently implementing a CurrencyInput to manage this use case, I am struggling with the spec because I started with NumberInput. Do you think all options of NumberInput are required for this new input ? like min, max, in..range ?
I will send a pull request as soon as I clean up my mess.

Owner

justinfrench commented Dec 20, 2011

@EppO I haven't given this much thought yet, but maybe it's helpful to first think about what the differences are between what you get with a number input, and what you'd like to see in a money input.

EppO commented Dec 20, 2011

IMHO, Currency is a more specific that numbers, it's a float with only 2 digits after decimal point, and with a symbol outside the input (more likely in a span surrounding the input). What do you think ?

Owner

justinfrench commented Dec 20, 2011

@EppO have a look at the number_to_currency helper in Rails... I think there's a bit more to it than that. Different precisions, different separators for the decimal and the thousands, and the currency symbol can be at the start ($) or end (€), for example.

A lot of the formatting rules (e.g. precision) aren't catered for in HTML5 client-side (and we don't do any JS yet), so perhaps as a starting point, all we're talking about is a numeric input that can somehow include a currency symbols relevant to a locale?

Next, an option to present the value stored in the database (usually in cents) as money (usually divide by 100, etc), and a way of detecting and doing this automatically by detecting the presence of the Money gem, or other common traits.

Sounds like three incremental steps. I have some ideas around the markup and currency symbol side of this, but would be great if you're motivated to look into the other (harder) bits.

EppO commented Dec 21, 2011

You want to put separators in the input when typing the amount ? or allowing the user to put separators in the input ? That would be harder to parse as it won't be anymore a number...

In my branch, I handled the symbol before/after the input but I don't really like how I did it (in to_html method), so I don't mind at all if you manage that part. I would be really please to help you for the other parts if I can.

Owner

justinfrench commented Dec 21, 2011

@EppO As a designer and user, seeing large numbers with 1000's separators is convenient for accuracy, but not crucial. Being able to copy-paste numbers with separators (and even currency symbols) into a form field and it Just Works™ is crucial. It's the app's responsibility to handle many varied types of input, not the user's.

However, in the spirit of incremental improvement, let's just get something ready to merge :)

Owner

justinfrench commented Apr 8, 2012

@EppO did you make progress on this?

EppO commented Apr 8, 2012

Sorry, not much. I've been quite busy, didn't look at the code for a while.
I will try to get something that you can merge.

Owner

justinfrench commented Oct 23, 2012

closing, no action in 7 months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment