Skip to content

Commit

Permalink
Merge branch 'issue/555' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed Dec 11, 2023
2 parents 272c6b0 + a05bcef commit 7a6d634
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
9 changes: 8 additions & 1 deletion web/blueprints/user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions web/blueprints/user/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class RoomHistoryRow(BaseModel):


class TenancyTable(BootstrapTable):
_render_toolbar = False

room = LinkColumn("Zimmer")
begins_at = DateColumn("Von")
ends_at = DateColumn("Bis")
Expand Down
26 changes: 15 additions & 11 deletions web/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"<div {toolbar_args}>"
yield self.toolbar
yield "</div>"

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"<div {toolbar_args}>"
yield self.toolbar
yield "</div>"
table_args.update(
{
"data-toolbar": f"#{table_id}-toolbar",
}
)

yield f"<table {html_params(**table_args)}>"
yield self.table_header
Expand Down
6 changes: 5 additions & 1 deletion web/templates/macros/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@

{% 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") -%}
<form method="{{ method }}" action="{{ submit_to }}" enctype="{{ enctype }}" class="form-{{ form_render_mode }}" role="form">
<div class="row">
<div class="row mb-3">
{# 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 %}
<div class="col-sm-{{ col_width }} mb-3">
{{ field(render_mode=field_render_mode, autofocus=ns.autofocus, autocomplete=autocomplete) }}
</div>
{% endif %}
{% set ns.autofocus = false %}
{% endfor %}
<div class="offset-sm-{{ actions_offset }} col-sm-{{ col_width - actions_offset }}">
Expand Down
20 changes: 14 additions & 6 deletions web/templates/user/user_move.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@
{% import "macros/forms.html" as forms %}
{% import "macros/resources.html" as resources %}

{% block single_row_content %}
<div class="box box-info">
<strong>Hinweis:</strong>
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 %}
<div class="row">
<div class="box box-info">
<strong>Hinweis:</strong>
Bei Umzügen muss ein Nachweis über den Umzugswunsch archiviert werden!
Beispiel: Verschieben eines Tickets in die Umzugsqueue oder Ausdrucken / unterschrieben Abheften des Antrags.
</div>
{{ forms.simple_form(form, '', url_for('.user_show', user_id=user_id) ) }}
</div>
{{ forms.simple_form(form, '', url_for('.user_show', user_id=user_id) ) }}
{% if tenancy_table %}
<div class="row">
<h3>{{ _("Mietverträge") }}</h3>
{{ tenancy_table.render("tenancy_table") }}
</div>
{% endif %}
{% endblock %}

{% block page_script %}
Expand Down

0 comments on commit 7a6d634

Please sign in to comment.