Fix select ordering see #2224

The space before "G" in the option value is needed in order to
advmultiselect.php js puts the group items first so:

So it will appear like this:

G: group 1
Aimee Mann
Bob

Instead of:

Aimee Mann
Bob
G: group 1
pull/2487/head
jmontoyaa 8 years ago
parent bc54d39ee4
commit 80aa54d583
  1. 3
      main/inc/lib/course.lib.php
  2. 19
      main/inc/lib/javascript/pear/qfamsHandler.js

@ -5984,7 +5984,8 @@ class CourseManager
$result[] = array(
'disabled' => $user_disabled,
'value' => "GROUP:".$this_group['id'],
'content' => "G: ".$this_group['name']." - ".$this_group['userNb']." ".$user_label
// The space before "G" is needed in order to advmultiselect.php js puts groups first
'content' => " G: ".$this_group['name']." - ".$this_group['userNb']." ".$user_label
);
}
}

@ -270,6 +270,25 @@ QFAMS.moveSelection = function (qfamsName, selectLeft, selectRight, selectHidden
// Set the appropriate items as 'selected in the hidden select.
// These are the values that will actually be posted with the form.
QFAMS.updateHidden(selectHidden, selectRight);
// Order alphabetically
//var sourceId = $(source).attr('id');
var targetId = $(target).attr('id');
var options = $('#' + targetId +' option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value }; }).get();
arr.sort(function (o1, o2) {
//return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0;
// Ignore case
var t1 = o1.t.toLowerCase(), t2 = o2.t.toLowerCase();
return t1 > t2 ? 1 : t1 < t2 ? -1 : 0;
});
options.each(function(i, o) {
o.value = arr[i].v;
$(o).text(arr[i].t);
});
};
/**

Loading…
Cancel
Save