Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to sort group members with metadata configuration #2553

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cweitkamp
Copy link
Contributor

  • Added feature to sort group members with metadata configuration

See #2123 (comment)

This is an initial draft on sorting group members with metadata configuration. Items in groups can be sorted by name, label or state. Default ordering is ascending.

demo.items

Group:Number testGroup "Test Group" {
    sortBy="STATE" [ ordering="DESCENDING" ]
}

Allowed values for sortBy: LABEL, NAME and STATE.
Allowed values for ordering: DESCENDING, otherwise ascending ordering will be used. Configuration of ordering is optional.

Sort members by state picks up a Comparator from items, which can be implemented individually for each item type. Item class provides a default Comparator to sort states in alphabetically order by applying toFullString() on the state first.

UIs and other services have to be changed afterwards to benefit from this feature.

@openhab/core-maintainers wdyt?
// CC @ghys @rkoshak

Signed-off-by: Christoph Weitkamp github@christophweitkamp.de

@cweitkamp cweitkamp added the enhancement An enhancement or new feature of the Core label Nov 1, 2021
@cweitkamp cweitkamp force-pushed the feature-sort-group-members-with-metadata-configuration branch 2 times, most recently from 7e9944b to d3b1a53 Compare November 3, 2021 10:05
@cweitkamp cweitkamp marked this pull request as ready for review November 3, 2021 15:55
@cweitkamp cweitkamp requested a review from a team as a code owner November 3, 2021 15:55
@cweitkamp cweitkamp added rebuild Triggers the Jenkins PR build and removed rebuild Triggers the Jenkins PR build labels Nov 3, 2021
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
@cweitkamp cweitkamp force-pushed the feature-sort-group-members-with-metadata-configuration branch from d3b1a53 to 4748644 Compare November 5, 2021 13:05
Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me in general and the feature might be useful.
Before merging, I'd like to see a comment from @ghys as you had pinged him specifically as well on whether this fits for the UI to support it or whether some tweaks are desired.

@kaikreuzer kaikreuzer changed the title Added feature to sort group members with metadata configuration Add feature to sort group members with metadata configuration Dec 2, 2021
@cweitkamp
Copy link
Contributor Author

Thanks for looking into this. From my POV we at least need to tweak the REST API to make use of this feature or add a special method for retrieving sorted groups / member of groups.

@ghys
Copy link
Member

ghys commented Dec 2, 2021

The UI has its own sorting function which will consider the index put in the widgetOrder metadata namespace first, then will sort labels (or fallback to the name if the item has no label) alphabetically. It was because in many cases the order of items in API responses seemed random and indeterminate.
When you use features like the "group popup" action, the home page cards, the "add from model" function in pages, or the oh-repeater component with a itemsInGroup source, that function will be used instead of the order of the API. So there would be a need to figure out that in some cases the order of the API is the correct one.

@cweitkamp
Copy link
Contributor Author

The feature to order based on widgetOrder can be integrated in this implementation too.

Would it make sense to add an orderIndex field to the EnrichedItemDTO which carries the previously determined ordering? This can be used by consumers to ensure correct ordering.

@rkoshak
Copy link

rkoshak commented Jan 11, 2022

Holy cow, there's been a lot of stuff going on on GitHub I've simply missed. Playing catchup.

All I have to add is this is something that has been asked for many times by sitemap users. I could see it potentially being useful in rules too, though there are already ways to sort members of a Group there.

I can't comment on MainUI concerns.

@J-N-K
Copy link
Member

J-N-K commented May 14, 2022

@cweitkamp What is the status here? Judging from your last comment I assume there's still work to do before we can merge?

@kaikreuzer
Copy link
Member

@cweitkamp Are you still around and could comment on the status here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants