Skip to content

Commit

Permalink
BC-4879 - Make the 'Assign an additional owner' field usable (#3319)
Browse files Browse the repository at this point in the history
* add search functionality and sort users in 'select additional owner' select

* sort select data
  • Loading branch information
davwas authored Oct 6, 2023
1 parent cfaa235 commit f768a37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions controllers/administration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2678,6 +2678,13 @@ router.all('/teams', async (req, res, next) => {
baseUrl: `/administration/teams/?p={{page}}${sortQuery}${limitQuery}`,
};

const compare = (a, b) => (a > b) - (a < b);

users.sort((a, b) => (
compare(a.lastName.toLowerCase(), b.lastName.toLowerCase())
|| compare(a.firstName.toLowerCase(), b.firstName.toLowerCase())
));

users = users.filter((user) => !isUserHidden(user, res.locals.currentSchoolData));

res.render('administration/teams', {
Expand Down
8 changes: 2 additions & 6 deletions views/administration/forms/form-teams.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
<div class="form-group">
<label>{{$t "administration.teams.label.selectAnAdditionalOwner" }}</label>
{{{course.name}}}
<select class="form-control form-control-lg" type="text" name="userId">
<select class="form-control form-control-lg search-enabled" aria-label="{{$t "administration.teams.label.selectAnAdditionalOwner" }}" type="text" name="userId">
<option value="">{{$t "administration.teams.button.addAnotherOwner" }}</option>
{{#each users}}
<option value="{{{this._id}}}">
{{#if this.displayName}}
{{this.displayName}}
{{else}}
{{this.firstName}} {{this.lastName}}
{{/if}}
{{this.lastName}} {{this.firstName}}
</option>
{{/each}}
</select>
Expand Down

0 comments on commit f768a37

Please sign in to comment.