wger
wger copied to clipboard
UI Rejects Editing Body Weight Entries if they are above 300Kg when desired measurement is Lbs.
Steps to Reproduce
- Set user preference to using pounds instead of Kg.
- Create a body weight entry that is above 300 pounds.
- Attempt to edit your 300+ pound body weight entry to anything still above 300 pounds.
Expected results: I expect to see my new body weight entry accepted and edited in the body weight summary.
Actual results: UI rejects the new body weight entry with red text saying "Max Weight is 300kg" but user preference is set to pounds. This means that for users over 300 pounds, it is impossible to edit your body weight entries.
This was found with the latest Docker instance.
Hi @zerojay @rolandgeider, I am interested in picking this up! I was thinking a good solution would be to check whether the user preference is in pounds and if so, to adjust the current max weight allowed. I am new to this project so any tips would be greatly appreciated. Would love to hear your thoughts.
Hi @gabeliss !
yes we would need to have two different validators (and error messages). Also note that currently the weight input form is django, but we should move to react (this is already implemented and tested, it just needs a bit of tweaking so it is used in the app).
To start the react app, you just need to install everything, set a key in the env file and start the server, I can give you one for the test server if you want
Yes a key for the test server would be great thank you
Here you go:
REACT_APP_API_SERVER=https://wger-master.rge.uber.space
REACT_APP_API_KEY="31e2ea0322c07b9df583a9b6d1e794f7139e78d4"
(the test server is reset every day, so feel free to edit stuff)
https://wger-master.rge.uber.space/api/v2/userprofile/
You'll probably want to take a look at User/models/profile.ts
. We currently expose the unit used in weight_unit
but it's currently not stored anywhere (the profile needs to be trimmed anyway, some of those entries are not really used anymore). At the moment that can have either the value kg
or lb
but it's probably smarter to convert that to a boolean and work with that (this could also be done in the backend, but that's another issue). To load the profile, you can just use the useProfileQuery
query
Hey @rolandgeider I am running into a quick problem with picking up this task in which I was wondering if you had come across before. I have cloned the React codebase onto my local machine but when I try to run npm start, I get the following error.
I noticed that the ModuleNotFound error could be because the locales/en/translation.json file is in the public directory, while this import is being written in a file in the src directory. When attempting to add ../public to the file path, I get an error that this is not allowed. A google search regarding this error says to either move the file to the src folder or to not import a file from the public folder, but neither of these solutions seem like the correct course of action. I was wondering if you knew how to proceed with this issue.
yes, that came in with a recent update of the translation library. The English translation need to be imported there to make typescript happy, but they also need to be in the public folder so they can be served later to the application. I had commited a symlink from src/locales/en/translation.json to the same file in the public folder but it seems it didn't work. As a workaround you can just copy the en locale for now, that should work.
Oh and sometimes npm somehow can't get the correct dependency tree, in that case just install everything with yarn
Copying the file into the src folder worked. Have you run into that useTranslation "type instantiation is excessively deep" issue as well? I am having difficulty finding a workaround to get the React App to load. If not, since the first issue we worked on successfully was in the Django codebase, we are considering picking up a different issue within the original codebase if we cannot get the React to load.
My experience is that restarting the IDE "fixes" the error. It seems it doesn't pick up the translation file, specially after copying/moving/etc it. (BTW, I also managed to commit the symlink, so you should be able to delete the file when you pull)
But sure, if this doesn't start, we can find some other django issues
By the way, I've lost 240 pounds since opening this issue back in April and am now under 300 pounds, so I - very technically - can no longer reproduce this. ;)
By the way, I've lost 240 pounds since opening this issue back in April and am now under 300 pounds, so I - very technically - can no longer reproduce this. ;)
congratulations!!
(still leaving the issue open though 😄 )
By the way, I've lost 240 pounds since opening this issue back in April and am now under 300 pounds, so I - very technically - can no longer reproduce this. ;)
Congrats!
I ran into a similar issue while attempting to use lbs (found this issue the hard way) then switched back to kg. While editing my data to be in kg from lbs, I noticed that if I enter three decimal points (calculator output) it silently fails to update (page refresh shows the old data in lbs). If the input is trimmed manually to 2 decimal places, it works without fail.
So I'm curious whether the preferred route forward would be to auto-trim, or pop up a message saying the edit failed when entering data with over 2 decimal points?
This bug is still persistent in the current wger/server docker installation.