Skip to content

Commit e03a7e6

Browse files
Daniel Vegakaruturi
authored andcommitted
Sorting projects alphabetically in drop down menu
Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>
1 parent d969364 commit e03a7e6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎ui/scripts/ui-custom/projectSelect.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,21 @@
3030
response: {
3131
success: function(args) {
3232
var projects = args.data;
33+
var arrayOfProjs = [];
3334

3435
$(projects).map(function(index, project) {
36+
var proj = {id: _s(project.id), html: _s(project.displaytext ? project.displaytext : project.name)};
37+
arrayOfProjs.push(proj);
38+
});
39+
40+
arrayOfProjs.sort(function(a,b) {
41+
return a.html.localeCompare(b.html);
42+
});
43+
44+
$(arrayOfProjs).map(function(index, project) {
3545
var $option = $('<option>').val(_s(project.id));
3646

37-
$option.html(_s(project.displaytext ? project.displaytext : project.name));
47+
$option.html(_s(project.html));
3848
$option.appendTo($projectSelect);
3949
});
4050
},

0 commit comments

Comments
 (0)