Wrong lazy-load of „levels“ dropdown when changing room
When selecting Marschnerstraße in the building dropdown, the level defaults to 0, but the level 5 rooms are loaded.
A workaround requires selecting a different level, and then the original one.
The same happens when creating a new host.
Sentry issue: PYCROFT-52
Important Defs:
LazyLoadSelectField
https://github.com/agdsn/wtforms-widgets/blob/981f37c88d5ec743fafebca38f4102bac671405c/wtforms_widgets/fields/custom.py#L27-L94
LazyLoadSelectWidget (renders the LazyLoadSelectField)
https://github.com/agdsn/wtforms-widgets/blob/981f37c88d5ec743fafebca38f4102bac671405c/wtforms_widgets/widgets.py#L308-L322
class LazyLoadSelect (jQuery plugin)
https://github.com/agdsn/pycroft/blob/ac8da0dae4ca3ee904e4f9606fb92c689f121a7f/web/resources/js/lazy-load-select.js#L41-L44
The change event:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event
get queryurl takes when switching the dormitory the last selected level. Thats also why the right rooms where shown
In case there is only one level in the selected dormitory, one might be completely unable to select a room if the last selected level is not the one present in the dormitory. Workaround: switch to another dormitory where the desired level is present and select it, then switch back.
The problem is that we use async fetches so it is not predictable which one (the doorm or the floors are fetched)