Is it possible to allow app users to reorder items in a list without changing the universal value of the item?
I know it’s possible to re-order items by setting a number value of an item and linking a button that will increase or decrease the value which then you can sort from value low to high. But the problem with that is it will change the value for everyone else too. Not being exclusive to the user who changed it.
So, creating an intersect database would probably work best for this.
First, you create a User_Exercises collection. In that collection, you add a 1-M relationship (User to User_Exercises) and a 1-M relationship (Exercises to User_Exercises).
This does three things:
You’re able to create individualized lists of selected exercises for each user.
You can do that without using a Many-To-Many relationship (which would slow down your app quite a bit over time)
You can set a “ListOrder” field in the User_Exercises database, and then when you display those in the list, you can sort them by that order field.
That may be a bit confusing, but if you have questions, just ask. I have a fairly complex app that uses a few of these to avoid many-to-many relationships. They work really well once you get used to them.
I understand the logic here. I see how it can work. Let me know if I am missing anything:
A user adds exercises from the global exercise collection “Exercises”
This creates a record in “User_Exercises” adding the global exercise record to the “User_Exercise” record (Only 1 record needs to be created though, even if they choose multiple exercises. Is that possible)?
Those records from the “User_Exercises” get added to the “Workout_Log” collection.
The exercise list that should show now for users to log their workout should be “User_Exercises” ?
The only thing I’m missing is when users add exercises, they hit a toggle to add. If they are on that same screen and decide they want to remove it, they can toggle again to remove it. The problem is, I’m not getting the option when toggling to remove to update the workout log to remove the user_exercise. So this is causing exercises to remain on the log or duplicates to be there as well.
The reason this is happening is that they are adding the exercises from the global exercises list.
In other words, I’m able to add the new user exercise to the collection when the toggle is turned on, but not remove it when turned off, from the workout log
Yeah, you’d need to redo things to work with the database, or you’d need to create a fake toggle that executes an action instead of controlling a database value.
For example, you could have a list with all of the database options (and you can use a filter or a visibility condition to hide the ones that are in User_Exercises if they have the user’s name) and another list with all of the User_Exercises that have the user’s name.