ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.68k stars 387 forks source link

Sorting results in SelectRepeater #280

Closed tgirod closed 4 years ago

tgirod commented 5 years ago

I see there is a Sortable interface that allows to sort items by date. Is there something equivalent to sort items in the SelectRepeater ? From the generated code I see the content of the select is extracted from a map[string]string, hence the random order.

In term of usability, I think it would be better to be able to sort the content one way or another - or at least make the order stable.

nilslice commented 5 years ago

@tgirod - that's a great point. There certainly could be a sorting step before the map is serialized. I think A-Z is pretty common for select dropdowns in a UI. What do you think? If you're interested in taking a swing at this in a PR, please feel free to do so.

tgirod commented 5 years ago

@nilslice well, that's a pretty low hanging fruit, I might have a try :smile:

nilslice commented 5 years ago

@tgirod sounds great! let me know if you have any issues or questions

olliephillips commented 4 years ago

This hasn't been implemented yet, but it reads like a good idea. Maybe the community could pick this up? Labelled.

junnotantra commented 4 years ago

Hi guys, this looks like a nice to have feature so I've been trying to make this works. But I realized that the code for this feature have it's own repo at https://github.com/bosssauce/reference. It was included in ponzu repo also at addons/github.com/bosssauce/reference/reference.go

So should I update the code on ponzu repo? bosssauce/reference repo? or both?

olliephillips commented 4 years ago

Hi @junnotantra I'm not sure, select has many use cases beyond the reference add-on, but there may be something that might need replicating in the add-on, so it's a great point.

I would focus on the core ponzu-cms functionality, and if the case, flag that there are changes needed in that add-on, so it does the same thing in respect of sorting.

Thanks for taking the time to investigate this, as always, shout if the community can help with the development piece.

junnotantra commented 4 years ago

oops, wrong account

Oh, so that's why there are some similar code about select on ponzu repo alone. I think I will update all of them (on both ponzu & bosssauce repo) to be sorted alphabetically.

Will create the PR later today.

nilslice commented 4 years ago

@junnotantra - great question, and thanks for taking time to explore this. it would be great to have your help on the feature.

to add context, the reference package was designed as an addon to Ponzu in a way to prove how "external" code could be integrated into the project, but remain external. I think that it was a worthy experiment, but if you find that the code could be more easily integrated into Ponzu directly (as a core internal component of the editor package (similar to the editor.Input, editor.Select, etc elements), then I fully support that approach. I don't think it's necessary for the reference package to be externalized. It seems that @olliephillips has a similar opinion on this, so unless I've read wrong, I believe we're on the same page here!

I'll leave it up to you to make the decision on how you want to proceed, but if we can bring reference into Ponzu directly, and not have it as a vendored dependency, that would be great.

Let me know if you have any issues with this, just leave a note here in this issue.

Thanks!

junnotantra commented 4 years ago

Hi @nilslice, it's true that integrate the reference to ponzu core is great but I've decided not to do it for now.

The first reason is if we move reference to ponzu core, then there will be no more example about how external code can be integrated to ponzu. I think it would be better if we can find a replacement about this external integration example before moving reference to ponzu core.

The second reason is bosssauce/reference are imported on generated content source code. I still haven't learn how code geeration on ponzu works in order to "internalize" the reference.

Please help take a look at my PRs above. Thanks!

olliephillips commented 4 years ago

@junnotantra This is now merged to ponzu-dev. Thanks for picking the issue up. Closing this issue.