Allow users to re-order list without changing the universal value

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.

Couple of questions for clarity:

  1. All of these list items are global (all users see the same items), correct?
  2. Although all list items are global, you need individual users to be able to re-order list items without affecting the view of other users?

If you can give more info on how the app works, that would help as well.

Hi. Correct, all list items are global.

It is a workout-tracking app.

Users will build a custom, unique individual workout with a global list of exercises.

When they add the exercises, a unique workout log gets created.

That workout log is a list of exercises that the user has chosen. I want users to be able to re-order the list of exercises.

But keep in mind, the exercises that they added, came from a global list.

1 Like

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:

  1. You’re able to create individualized lists of selected exercises for each user.
  2. You can do that without using a Many-To-Many relationship (which would slow down your app quite a bit over time)
  3. 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” ?

This would create multiple records in User_Exercises.

So, let’s say you have three exercises: Pushups, Situps, and Pullups.

A user (Jacob), might select “Pushups” and “Situps” from the list of Exercises.

Selecting these would create the records “Jacob_Pushups” and “Jacob_Situps” in the User_Exercises database.

Then you can have a custom list of User_Exercises (your Workout Log) on a screen which can be manipulated by the user.

I’m almost there…

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.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.