pycroft icon indicating copy to clipboard operation
pycroft copied to clipboard

Wrong lazy-load of „levels“ dropdown when changing room

Open lukasjuhrich opened this issue 4 years ago • 6 comments

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.

lukasjuhrich avatar Mar 18 '21 20:03 lukasjuhrich

The same happens when creating a new host.

lukasjuhrich avatar Jun 01 '23 17:06 lukasjuhrich

Sentry issue: PYCROFT-52

agdsn-sentry[bot] avatar Jun 01 '23 18:06 agdsn-sentry[bot]

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

lukasjuhrich avatar Jun 02 '23 07:06 lukasjuhrich

get queryurl takes when switching the dormitory the last selected level. Thats also why the right rooms where shown

agmes4 avatar Jun 02 '23 08:06 agmes4

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.

FestplattenSchnitzel avatar Aug 19 '24 19:08 FestplattenSchnitzel

The problem is that we use async fetches so it is not predictable which one (the doorm or the floors are fetched)

agmes4 avatar Aug 20 '24 07:08 agmes4