Block Components - Ranking Items by Type in Repeating Group

I have a page that allows users to edit block components (like Notion or Editor.js). Some of these blocks are numbered lists, which can have other elements in between each item (a photo, video, etc.). This prevents me from utilizing “current cell’s index” on a numbered list, because there are other elements which throw off the count. Each block has a data field for type (utilizing an option set), so I was wondering if there was a way to filter by type in order to rank a list item?

For example, this is how my list looks now:

Screen Shot 2022-07-19 at 8.48.07 AM

Instead, I want to somehow filter by list type and rank the items, so items three and four come out like this:

Screen Shot 2022-07-19 at 8.51.08 AM

Hi!

I have a similar feature in my app. First thing i have to ask is do you really need the numeration for each block? You can remove a lot of headache by not having any.

1 Like

Yes, it’s a list of directions so that’s really a necessity for this app.

I don’t have any precise answer for what you need but i can suggest some things.

If you know where a Group Heading needs to be, you can have it be a part of an Item itself. So in your example the heading is actually a part of item number three itself. Now you can use the cell’s index.

Or you can rework your workflow to process a “index” field in your Item which ignores any heading type. You can process the “index” numbers during creation of each block or during creation of the final list.

1 Like

This generally works until the user deletes a list item. It required several workflows to change the parent to the next list item , and if there wasn’t a list item with a higher index, then I had to create a new list item. All in, it multiplied the number of workflows in my app, and I was hoping for something a little more lightweight. I like the idea of using the current cell’s index, and would prefer this method if I can find a more direct solution.

I’ve done this before to re-order lists and utilize a recursive workflow to clean up the index when the user leaves the page. However, for this use case it would be nice for the list number to update almost instantaneously; otherwise if a user deletes or re-orders a list there would be a delay until the workflow runs through the list.

You can try creating a client side custom workflow that you can trigger everytime an entry is created or deleted.

I find this to be the best solution since it’s easier to keep track of workflows than trying to figure out the required index mathematically.

Been trying to crack my brain on other ways to go about it but can’t come up with anything else at the moment. Sorry :frowning:

1 Like

I had to convert my repeating group cell’s content to a reusable element to make use of a group focus, so unfortunately that prevented me from going with the “current cell’s index” workaround.

I ended up creating two data fields on my list item. The first is the index, which adds +1 to the highest index in the list any time a list item or section heading is created. The second is the display, which adds +1 to the highest list item’s display only when a list item is created. I use the display for my step number, and the index for sorting.

There’s a few options to update the display index when a step is deleted or re-ordered. You can schedule a recursive workflow to loop through the list for any item whose index > current list item’s index. Or, you can utilize ListShifter or the Toolbox plugin to iterate through the list as well. I’m not sure which I’ll use yet, it will depend on speed and capacity. Still open to suggestions here!

Wouldn’t I need to use a backend workflow in order to “loop” through a list and adjust the display? Or is there a way to do this using custom workflows?

No, thanks for your help! I appreciate the input.