#Local API - Query Global based status of relationship item

1 messages · Page 1 of 1 (latest)

arctic kelp
#

Hey! I have an interesting case and wonder if there is any functionality to make this happen.

I have a pizza menu stored in a menu-items collection. Then I have a global called menu which controls the ordering of the Menu items using a relationship. What I wan't is to be able to toggle off items in the menu-items collection using the payload draft's functionality and simultaneously hiding these when querying the menu global.

I can query the menu-items based on _status equals published directly and then query the menu global for the order and sort these in JS, but I would prefer if there was a way to do this in one go by just hitting the menu global.

Is this possible?

median yachtBOT
thick crystal
#

I'm taking inspiration from the payload-workflow plugin.

#

I believe it'll be simpler if you just have one collection that handles all the stuff rather than having a menu item collection and a menu global

#

Reorderable collection is such a complex topic that even Strapi doesn't implement it, as of this forum thread https://forum.strapi.io/t/re-organize-documents-inside-a-collection/541/4

Strapi Community Forum

@DMehaffy thanks for your response ! @soupette Indeed, dynamic zone can do the tricks in terms of layout. That’s what I’m using right now and it’s working wonderfully. 🙂 However, let’s say you have a list of projects (so documents in a collection) and you want to rearrange the order of the projects, this is - almost - not possible. You can do...

#

Hmm, after rereading your problem, maybe a simple afterRead hook could solve that?

arctic kelp
#

Perhaps yes, I do agree though. Keeping this inside a single collection would be way better

#

Still the nesting is complex to handle for such a simple task 😅

thick crystal
#

True, you don't need the nesting part

#

All you need is probably a lexorank field and a drag and drop mechanism that will be able to modify the lexorank field accordingly, meaning you need to make a custom List view component.

#

Take a look at payload-workflow source code, you might be able to isolate the drag-n-drop, the custom list view and lexorank part and implement it in your own collection

#

Or maybe all you need is an afterRead hook afterall, choice on you

thick crystal
#

@arctic kelp Have you found a solution?