Commit 3375ec28 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

More mobile friendly index page and tables

/close #36
/close #28
parent 81461b83
......@@ -114,7 +114,7 @@ def merge_todos():
@manager.command
def runserver():
app.run()
app.run(host="192.168.0.13")
make_scheduler()
# cause uwsgi currently has a bug
......@@ -430,7 +430,7 @@ def list_protocols():
"<b>{}</b>".format(text) if matched else text
for text, matched in parts
]))
search_results[protocol] = "<br />\n".join(formatted_lines)
search_results[protocol] = "<br />\n".join(formatted_lines)
protocols = sorted(protocols, key=lambda protocol: protocol.date, reverse=True)
page = _get_page()
page_count = int(math.ceil(len(protocols) / config.PAGE_LENGTH))
......
......@@ -3,7 +3,7 @@
{% block title %}Startseite{% endblock %}
{% block content %}
{% if protocol is not none %}
{% if check_login() %}
<div class="row">
<div id="left-column" class="col-lg-6">
{% endif %}
......@@ -25,56 +25,56 @@
{% endif %}
{% endif %}
</ul>
{% if check_login() %}
<h3>Offene Todos <a href="{{url_for("list_todos")}}">Alle</a></h3>
<ul>
{% if todos|length > 0 %}
{% for todo in todos %}
<li>{{todo.render_html()|safe}} ({{todo.protocoltype.name}})</li>
{% endfor %}
{% else %}
<li>Keine Todos</li>
{% if protocol is not none %}
<h3>Letztes Protokoll</h3>
<div class="well">
<div class="btn-group">
<a class="btn btn-primary" href="{{url_for("show_protocol", protocol_id=protocol.id)}}">Details anzeigen</a>
{% if protocol.protocoltype.has_modify_right(current_user()) %}
<a class="btn btn-default" href="{{url_for("update_protocol", protocol_id=protocol.id)}}">Protokoll editieren</a>
{% endif %}
{% if protocol.has_compiled_document() %}
<a class="btn btn-success" href="{{url_for("download_document", document_id=protocol.get_compiled_document().id)}}">Download</a>
{% endif %}
</div>
<h2>Protokoll: {{protocol.protocoltype.name}} {% if protocol.date is not none %}vom {{protocol.date|datify}}{% endif %}</h2>
{% if protocol.date is not none %}
<p><strong>Datum:</strong> {{protocol.date|datify_long}}</p>
{% endif %}
</ul>
{% if protocol.start_time is not none and protocol.end_time is not none %}
<p><strong>Zeit:</strong> von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}</p>
{% endif %}
{% for meta in protocol.metas %}
<p><strong>{{meta.name}}:</strong> {{meta.value}}</p>
{% endfor %}
<h3>Tagesordnung{% if has_modify_right and not protocol.has_nonplanned_tops() %} <a href="{{url_for("new_top", protocol_id=protocol.id)}}">Top hinzufügen</a>{% endif %}</h3>
{% include "protocol-tops-include.html" %}
<h3>Beschlüsse</h3>
<ul>
{% if protocol.decisions|length > 0 %}
{% for decision in protocol.decisions %}
<li>{{decision.content}}</li>
{% endfor %}
{% else %}
<li>Keine Beschlüsse</li>
{% endif %}
</ul>
</div>
{% endif %}
{% if protocol is not none %}
{% if check_login() %}
</div>
<div id="right-column" class="col-lg-6">
<h3>Letztes Protokoll</h3>
<div class="well">
<div class="btn-group">
<a class="btn btn-primary" href="{{url_for("show_protocol", protocol_id=protocol.id)}}">Details anzeigen</a>
{% if protocol.protocoltype.has_modify_right(current_user()) %}
<a class="btn btn-default" href="{{url_for("update_protocol", protocol_id=protocol.id)}}">Protokoll editieren</a>
{% endif %}
{% if protocol.has_compiled_document() %}
<a class="btn btn-success" href="{{url_for("download_document", document_id=protocol.get_compiled_document().id)}}">Download</a>
{% endif %}
</div>
<h2>Protokoll: {{protocol.protocoltype.name}} {% if protocol.date is not none %}vom {{protocol.date|datify}}{% endif %}</h2>
{% if protocol.date is not none %}
<p><strong>Datum:</strong> {{protocol.date|datify_long}}</p>
{% endif %}
{% if protocol.start_time is not none and protocol.end_time is not none %}
<p><strong>Zeit:</strong> von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}</p>
<h3>Offene Todos <a href="{{url_for("list_todos")}}">Alle</a></h3>
<ul>
{% if todos|length > 0 %}
{% for todo in todos %}
<li>{{todo.render_html()|safe}} ({{todo.protocoltype.name}})</li>
{% endfor %}
{% else %}
<li>Keine Todos</li>
{% endif %}
{% for meta in protocol.metas %}
<p><strong>{{meta.name}}:</strong> {{meta.value}}</p>
{% endfor %}
<h3>Tagesordnung{% if has_modify_right and not protocol.has_nonplanned_tops() %} <a href="{{url_for("new_top", protocol_id=protocol.id)}}">Top hinzufügen</a>{% endif %}</h3>
{% include "protocol-tops-include.html" %}
<h3>Beschlüsse</h3>
<ul>
{% if protocol.decisions|length > 0 %}
{% for decision in protocol.decisions %}
<li>{{decision.content}}</li>
{% endfor %}
{% else %}
<li>Keine Beschlüsse</li>
{% endif %}
</ul>
</div>
</ul>
</div>
</div>
{% endif %}
......
......@@ -109,6 +109,7 @@ to not render a label for the CRSFTokenField -->
{%- endmacro %}
{% macro render_table(table) -%}
{% set classes = table.classes() %}
<h3>
{{table.title}}
{% if table.newlink is not none %}
......@@ -118,16 +119,16 @@ to not render a label for the CRSFTokenField -->
<table class="table table-striped">
<thead>
<tr>
{% for header in table.headers() %}
<th>{{header}}</th>
{% for (header, class) in zip(table.headers(), classes) %}
<th{% if class is not none %} class="{{class}}"{% endif %}>{{header}}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in table.rows() %}
<tr>
{% for entry in row %}
<td>{{entry}}</td>
{% for (entry, class) in zip(row, classes) %}
<td{% if class is not none %} class="{{class}}"{% endif %}>{{entry}}</td>
{% endfor %}
</tr>
{% endfor %}
......
......@@ -15,6 +15,9 @@ class Table:
def rows(self):
return [row for row in [self.row(value) for value in self.values] if row is not None]
def classes(self):
return [None for header in self.headers()]
@staticmethod
def link(target, text, confirm=None):
confirmation = ""
......@@ -55,7 +58,7 @@ class ProtocolsTable(Table):
self.search_results = search_results
def headers(self):
result = ["ID", "Sitzung", "Datum"]
result = ["ID", "Sitzung", "Sitzung", "Datum"]
state_part = ["Status"]
search_part = ["Suchergebnis"]
login_part = ["Typ", "Löschen"]
......@@ -67,11 +70,22 @@ class ProtocolsTable(Table):
result.extend(login_part)
return result
def classes(self):
state_or_search_class = "hidden-xs" if self.search_results is None else None
result = ["hidden-xs", "hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", None]
#result.append(state_or_search_class)
login_part = ["hidden-xs", "hidden-xs"]
if check_login():
result.extend(login_part)
return result
def row(self, protocol):
user = current_user()
protocol_link = url_for("show_protocol", protocol_id=protocol.id)
result = [
Table.link(url_for("show_protocol", protocol_id=protocol.id), str(protocol.id)),
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.protocoltype.name),
Table.link(protocol_link, str(protocol.id)),
Markup("<br>").join([Table.link(protocol_link, protocol.protocoltype.name), date_filter(protocol.date)]),
Table.link(protocol_link, protocol.protocoltype.name),
date_filter(protocol.date),
]
if self.search_results is None:
......@@ -92,19 +106,41 @@ class ProtocolTypesTable(Table):
super().__init__("Protokolltypen", types, newlink=url_for("new_type"))
def headers(self):
return ["Typ", "Name", "Neuestes Protokoll", ""]
return [
"Typ", "Protokoll",
"Typ", "Name", "Neuestes Protokoll", ""
]
def classes(self):
return [
"hidden-sm hidden-md hidden-lg", "hidden-sm hidden-md hidden-lg",
"hidden-xs", "hidden-xs", "hidden-xs", "hidden-xs"
]
def row(self, protocoltype):
protocol = protocoltype.get_latest_protocol()
user = current_user()
has_private_view_right = protocoltype.has_private_view_right(user)
has_modify_right = protocoltype.has_modify_right(user)
return [
Table.link(url_for("show_type", protocoltype_id=protocoltype.id), protocoltype.short_name) if has_modify_right else protocoltype.short_name,
protocoltype_link = url_for("show_type", protocoltype_id=protocoltype.id)
protocol_link = url_for("show_protocol", protocol_id=protocol.id)
new_protocol_link = url_for("new_protocol", type_id=protocoltype.id)
mobile_name = "{} ({})".format(protocoltype.name, protocoltype.short_name)
mobile_links = [Table.link(protocol_link, protocol.get_identifier())]
if has_modify_right:
mobile_links.append(Table.link(new_protocol_link, "Neues Protokoll"))
mobile_part = [
Table.link(protocoltype_link, mobile_name) if has_private_view_right else mobile_name,
Markup("<br>".join(mobile_links))
]
desktop_part = [
Table.link(protocoltype_link, protocoltype.short_name) if has_private_view_right else protocoltype.short_name,
protocoltype.name,
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier()) if protocol is not None else "Noch kein Protokoll",
Table.link(url_for("new_protocol", type_id=protocoltype.id), "Neues Protokoll") if has_modify_right else ""
Table.link(protocol_link, protocol.get_identifier()) if protocol is not None else "Noch kein Protokoll",
Table.link(new_protocol_link, "Neues Protokoll") if has_modify_right else ""
"" # TODO: add link for modify, delete
]
return mobile_part + desktop_part
class ProtocolTypeTable(SingleValueTable):
def __init__(self, protocoltype):
......@@ -229,6 +265,9 @@ class ErrorsTable(Table):
def headers(self):
return ["Protokoll", "Aktion", "Fehler", "Zeitpunkt", "Beschreibung", ""]
def classes(self):
return [None, None, None, None, "hidden-xs"]
def row(self, error):
return [
Table.link(url_for("show_protocol", protocol_id=error.protocol.id), error.protocol.get_identifier()),
......@@ -260,12 +299,20 @@ class TodosTable(Table):
super().__init__("Todos", todos, newlink=url_for("new_todo"))
def headers(self):
return ["ID", "Status", "Sitzung", "Name", "Aufgabe", ""]
return ["Todo", "ID", "Status", "Sitzung", "Name", "Aufgabe", ""]
def classes(self):
return ["hidden-sm hidden-md hidden-lg", "hidden-xs", "hidden-xs", "hidden-xs", "hidden-xs", None, "hidden-xs"]
def row(self, todo):
user = current_user()
protocol = todo.get_first_protocol()
row = [
Markup("<br>").join([
Table.link(url_for("show_todo", todo_id=todo.id), todo.get_state()),
Table.link(url_for("show_protocol", protocol_id=protocol.id), todo.protocoltype.short_name),
todo.who
]),
Table.link(url_for("show_todo", todo_id=todo.id), todo.get_id()),
todo.get_state(),
Table.link(url_for("show_protocol", protocol_id=protocol.id), protocol.get_identifier())
......@@ -338,6 +385,9 @@ class DocumentsTable(Table):
def headers(self):
return ["ID", "Name", ""]
def classes(self):
return [None, None, "hidden-xs"]
def row(self, document):
user = current_user()
links = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment