From 1fc2e086be1a69b0adbbc719da248908cef4206f Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Mon, 11 Dec 2023 22:03:10 +0100 Subject: [PATCH 1/4] Don't wrap hidden fields in `div` This creates unnecessary space --- web/templates/macros/forms.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/templates/macros/forms.html b/web/templates/macros/forms.html index dfa056082..01d44e2a5 100644 --- a/web/templates/macros/forms.html +++ b/web/templates/macros/forms.html @@ -20,9 +20,13 @@ {# Namespace required because jinja2 does not save changes done in a loop #} {% set ns = namespace(autofocus=first_autofocus) %} {% for field in form %} + {% if field.flags.hidden %} + {{ field(render_mode=field_render_mode, autofocus=ns.autofocus, autocomplete=autocomplete) }} + {% else %}
{{ field(render_mode=field_render_mode, autofocus=ns.autofocus, autocomplete=autocomplete) }}
+ {% endif %} {% set ns.autofocus = false %} {% endfor %}
From ab6e870b374370981a9ad00c606347ea79d66d09 Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Mon, 11 Dec 2023 22:16:38 +0100 Subject: [PATCH 2/4] Disable toolbar for TenancyTable --- web/blueprints/user/tables.py | 2 ++ web/table/table.py | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/web/blueprints/user/tables.py b/web/blueprints/user/tables.py index 66880b8a0..705e5573e 100644 --- a/web/blueprints/user/tables.py +++ b/web/blueprints/user/tables.py @@ -112,6 +112,8 @@ class RoomHistoryRow(BaseModel): class TenancyTable(BootstrapTable): + _render_toolbar = False + room = LinkColumn("Zimmer") begins_at = DateColumn("Von") ends_at = DateColumn("Bis") diff --git a/web/table/table.py b/web/table/table.py index 6af8afeba..2a066de97 100644 --- a/web/table/table.py +++ b/web/table/table.py @@ -329,6 +329,7 @@ class BootstrapTable(metaclass=BootstrapTableMeta): """ column_attrname_map: OrderedDict[str, str] # provided by BootstrapTableMeta + _render_toolbar: bool = True _table_args: UnboundTableArgs # provided by BootstrapTableMeta _enforced_url_params: Iterable[tuple[str, Any]] # provided by BootstrapTableMeta table_args: TableArgs @@ -388,18 +389,21 @@ def table_footer(self) -> HasDunderStr | None: @lazy_join("\n") def _render(self, table_id: str) -> t.Iterator[HasDunderStr | None]: - toolbar_args = html_params(id=f"{table_id}-toolbar", - class_="btn-toolbar", - role="toolbar") - yield f"
" - yield self.toolbar - yield "
" - table_args = self.table_args - table_args.update({ - 'id': table_id, - 'data-toolbar': f"#{table_id}-toolbar", - }) + table_args.update({"id": table_id}) + + if self._render_toolbar: + toolbar_args = html_params( + id=f"{table_id}-toolbar", class_="btn-toolbar", role="toolbar" + ) + yield f"
" + yield self.toolbar + yield "
" + table_args.update( + { + "data-toolbar": f"#{table_id}-toolbar", + } + ) yield f"" yield self.table_header From 8755c7b39dab781de3ba6956d059339a74eceb8e Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Mon, 11 Dec 2023 22:17:32 +0100 Subject: [PATCH 3/4] Add `margin-bottom` to `advanced_form` --- web/templates/macros/forms.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/templates/macros/forms.html b/web/templates/macros/forms.html index 01d44e2a5..d76e649b1 100644 --- a/web/templates/macros/forms.html +++ b/web/templates/macros/forms.html @@ -16,7 +16,7 @@ {% macro advanced_form(form, submit_to="", cancel_to="", form_render_mode="horizontal", field_render_mode="horizontal", submit_text="Übernehmen", enctype="application/x-www-form-urlencoded", method="POST", show_cancel=true, show_submit=true, col_width=12, actions_offset=4, first_autofocus=true, autocomplete="off") -%}
-
+
{# Namespace required because jinja2 does not save changes done in a loop #} {% set ns = namespace(autofocus=first_autofocus) %} {% for field in form %} From a05bcef8cc353739665fa079d904d2508e5de93d Mon Sep 17 00:00:00 2001 From: Lukas Juhrich Date: Mon, 11 Dec 2023 22:18:20 +0100 Subject: [PATCH 4/4] Include a tenancy table to `user_move` Fixes #555 --- web/blueprints/user/__init__.py | 9 ++++++++- web/templates/user/user_move.html | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/web/blueprints/user/__init__.py b/web/blueprints/user/__init__.py index abbc1c0c2..7cbce56e7 100644 --- a/web/blueprints/user/__init__.py +++ b/web/blueprints/user/__init__.py @@ -731,7 +731,14 @@ def default_response(refill_form_data: bool = False) -> ResponseReturnValue: if not form.is_submitted() or refill_form_data: if user.room is not None: refill_room_data(form, user.room) - return render_template('user/user_move.html', user_id=user_id, form=form) + return render_template( + "user/user_move.html", + user_id=user_id, + form=form, + tenancy_table=TenancyTable( + data_url=url_for(".tenancies_json", user_id=user.id) + ), + ) if not form.validate_on_submit(): return default_response() diff --git a/web/templates/user/user_move.html b/web/templates/user/user_move.html index fccd80cd8..749d3035e 100644 --- a/web/templates/user/user_move.html +++ b/web/templates/user/user_move.html @@ -10,13 +10,21 @@ {% import "macros/forms.html" as forms %} {% import "macros/resources.html" as resources %} -{% block single_row_content %} -
- Hinweis: - Bei Umzügen muss ein Nachweis über den Umzugswunsch archiviert werden! - Beispiel: Verschieben eines Tickets in die Umzugsqueue oder Ausdrucken / unterschrieben Abheften des Antrags. +{% block content %} +
+
+ Hinweis: + Bei Umzügen muss ein Nachweis über den Umzugswunsch archiviert werden! + Beispiel: Verschieben eines Tickets in die Umzugsqueue oder Ausdrucken / unterschrieben Abheften des Antrags. +
+ {{ forms.simple_form(form, '', url_for('.user_show', user_id=user_id) ) }}
- {{ forms.simple_form(form, '', url_for('.user_show', user_id=user_id) ) }} + {% if tenancy_table %} +
+

{{ _("Mietverträge") }}

+ {{ tenancy_table.render("tenancy_table") }} +
+ {% endif %} {% endblock %} {% block page_script %}