Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove delimiter on number with currency field #2428

Merged

Conversation

lgiacalone3
Copy link
Contributor

Noticed a weird bug when editing a promotion - after updating the promotion, the item total dropped from 1000 down to 1. Looks like the delimiter is causing the amount to get truncated when values are 1000 and over.

Probably due to this:

irb(main):001:0> '1,000'.to_i
=> 1

This removes the delimiter from the number_with_currency partial, which is used on the promotion edit page. If there are any other fields that should get a similar treatment, feel free to let me know - happy to make the change.

@@ -5,7 +5,7 @@

<div class="input-group number-with-currency <%= "number-with-currency-with-select" unless currency %> js-number-with-currency">
<div class="input-group-addon number-with-currency-symbol"></div>
<%= f.text_field amount_attr, value: number_to_currency(f.object.public_send(amount_attr), unit: ''), class: 'form-control number-with-currency-amount', required: required %>
<%= f.text_field amount_attr, value: number_to_currency(f.object.public_send(amount_attr), unit: '', delimiter: ''), class: 'form-control number-with-currency-amount', required: required %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be a number_field as well. It's only used in admin forms for numeric values.

@lgiacalone3
Copy link
Contributor Author

@luukveenis fixed!

@jhawthorn
Copy link
Contributor

That was a nice idea @luukveenis, but we can't use a number_field here, unfortunately. See my comment here

@lgiacalone3 lgiacalone3 force-pushed the remove-admin-currency-delimiter branch from 9b7168e to c7ec843 Compare December 13, 2017 14:32
@lgiacalone3
Copy link
Contributor Author

lgiacalone3 commented Dec 13, 2017

@jhawthorn @luukveenis Just removed that last commit that replaced the text_field with a number_field.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jhawthorn jhawthorn merged commit d9e83d7 into solidusio:master Dec 19, 2017
@jhawthorn
Copy link
Contributor

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants