-
-
Notifications
You must be signed in to change notification settings - Fork 285
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
Packagings weights not recorded if using a comma (6,5) or a unit (e.g. 6.9 g) is included (mobile) #3663
Comments
I will also change the product edit form on the web, and the API, to accept strings with units: openfoodfacts/openfoodfacts-server#8054 |
@stephanegigandet There are pending issues in Smoothie on the packaging screen as we presented numeric fields as text fields, and did not fully check if they were really numeric (we just replaced with That's currently the case for
If I understand you, that means we'll switch to the following types, am I right?
|
@stephanegigandet Please ping me when it's done on the server side (I've just checked, it's not). |
@monsieurtanuki on the server side, both number_of_units and weight_measured will still be numbers, but if the WRITE API is passed a string, the API will convert them to a number (and send back a warning and an indication of what the value was converted to). For the READ API, both will be numbers. I'm thinking the easiest would be for the app to send back a string. That way you don't have to deal with conversions (e.g. numbers with a dot or comma, all types of units like kg, mg etc.). Corresponding PR server side: openfoodfacts/openfoodfacts-server#8056 (in review, not deployed yet) |
@stephanegigandet Correct me if I'm wrong: I would write Honestly I would prefer a clean warning for the user at submit time: a red hint saying "Error: please enter a value in grams". And anyway we have to deal with dot/comma in nutrition facts too. What about adding a g/mg/µg button, at least on the UI? Here I'm talking about Smoothie, that would compute locally the value in grams from a numeric text field and the unit button. And as you guys won't get/store the unit, we would display the "best" unit. I don't know... |
@monsieurtanuki The API will convert '1kg' to 1000. If you prefer to do the conversions client side, no problem at all. But we need to make sure that values like '1.4', '1,4', '1.4g', "1,4 g' etc. are converted to 1.4. And maybe show a warning if it wasn't possible to convert it. There's no need to do all the conversions for mg and kg etc. We do tell users to enter the weight in grams (the title of the field is "Weight of an empty unit (g)". The UI is already very complex for packagings, so I don't think it's a good idea to show a unit button. |
@stephanegigandet OK for not adding a unit button to the packaging screen. |
Hi @monsieurtanuki , can we fix this particular issue quickly, either with a numeric keyboard, or by converting the string to a valid number? (removing the g unit, and changing comma to dot). Some contributors spend a lot of time to enter weights, and their entries are discarded. I just witnessed someone do it yesterday: she used commas (6,5) when entering weights, and it wasn't saved. |
Hi @stephanegigandet! |
Great, thank you! |
If a packaging weight is entered with a unit (e.g. "9.6 g"), then the value is not recorded at all.
The text was updated successfully, but these errors were encountered: