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

Sort item sets by title in item set selector #2217

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions application/src/Form/Element/AbstractGroupByOwnerSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public function getValueOptions(): array
$resourceOwners[$index]['resources'][] = $resource;
}
ksort($resourceOwners);
// Sort the resources by label.
foreach ($resourceOwners as $email => $resourceOwner) {
usort($resourceOwners[$email]['resources'], function ($a, $b) {
return strcmp($this->getValueLabel($a), $this->getValueLabel($b));
});
}

$valueOptions = [];
foreach ($resourceOwners as $resourceOwner) {
Expand Down
6 changes: 6 additions & 0 deletions application/src/View/Helper/ItemSetSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public function __invoke($includeClosedSets = false)
$itemSetOwners[$email]['owner'] = $owner;
$itemSetOwners[$email]['item_sets'][] = $itemSet;
}
// Sort the item sets by title.
foreach ($itemSetOwners as $email => $itemSetOwner) {
usort($itemSetOwners[$email]['item_sets'], function ($a, $b) {
return strcmp($a->displayTitle(), $b->displayTitle());
});
}

return $this->getView()->partial(
'common/item-set-selector',
Expand Down
Loading