-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
fix: nutrition edit warnings #8411
Conversation
Kudos, SonarCloud Quality Gate passed!
|
Codecov Report
@@ Coverage Diff @@
## main #8411 +/- ##
=======================================
Coverage 48.46% 48.47%
=======================================
Files 114 114
Lines 21268 21277 +9
Branches 4768 4770 +2
=======================================
+ Hits 10308 10314 +6
- Misses 9677 9679 +2
- Partials 1283 1284 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
var nutrient_value = \$(this).val().replace(',','.'); | ||
var is_above_or_below_100 = (isNaN(nutrient_value) && nutrient_value != '-') || nutrient_value < 0 || nutrient_value > 100; | ||
// if the nutrition facts are indicated per serving, the value can be above 100 | ||
if ((nutrient_value > 100) && (\$('#nutrition_data_per_serving').is(':checked'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we check that it's below serving size ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's tricky, because serving size is parsed on the server (it can be specified with different units etc.), but the user can change it in the form while editing nutrients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! Thanks.
This PR builds upon the work of @jnsereko : #8258
It fixes some issues with the original PR, that were found when doing more testing before pushing to production.