Skip to content

Commit 538e10a

Browse files
authored
Semesters not ordered correctly in evaluation selection on person management page (#2399)
* add option to disable standard tomselect sorting according to tomselect docs by default the result is sorted by $score so the value or group which matches the sorting best. But we want to order the groups by our sorting with summer and winter terms. The sortField option here disables that and maintains the original order of options (see https://tom-select.js.org/docs/)
1 parent c5be96d commit 538e10a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

evap/evaluation/templates/base.html

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
plugins: {},
165165
hideSelected: false,
166166
};
167+
if (element.hasAttribute("tomselect-no-sort")) {
168+
baseOptions.sortField = [{field:'$order'},{field:'$score'}];
169+
}
167170
if(element.hasAttribute("data-tomselect-fullwidth")) {
168171
// span needed to the "remove this icon" button is right-aligned
169172
baseOptions.render.item = (data, escape) => `<div class="w-100"><span class="w-100">${ escape(data.text) }</span></div>`;

evap/staff/forms.py

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def __init__(self, *args, **kwargs):
142142
choices += [(semester.name, evaluation_choices)]
143143

144144
self.fields["evaluation"].choices = choices
145+
self.fields["evaluation"].widget.attrs["tomselect-no-sort"] = ""
145146

146147
def clean(self):
147148
if self.evaluation_selection_required and self.cleaned_data.get("evaluation") is None:

0 commit comments

Comments
 (0)