Considered calculating the current cost per use each time it needs to be displayed and rendering the result. Although this works and always gives an accurate result, I don’t think it’s the best solution because the function would need to be run over and over again. It still seems better to store the value since it’s a number that needs to be displayed so often.
I picked up from before trying to get the updated data to be submitted when the user makes updates. I had added the fields and added event listeners so that the data would be updated automatically, and would go into the database correctly. I made the
currentValuefields disabled so that the user can’t change the data. All was set up as it should be, but I was still stuck in the same place as yesterday where all of the fields weren’t being saved as part of the form object.
Key Learning! Disabled fields aren’t sent with form data when they post. Didn’t know that! It worked once I took off the
disabled tag. Yay!
However I don’t want the user to change these values and mess up the calculations, so for now I’ve set both fields to
hidden so that the user can’t see them at all. This isn’t an ideal solution since there are ways to get around this and submit bad information anyway, but as far as an MVP goes I’m happy with this.
Now I am working on the final element of completing this project as an MVP: deleting usage dates from a Thing. For each Thing, the app stores the date each time someone says they’ve used it…this number of uses is how the app calculates each Thing’s current cost-per-use. The user can see a list of the dates they’ve used it, and should be able to delete a date. This is what I’m working on now. More on that in the next post..!