Skip to content

Commit 3fc6576

Browse files
committed
jinja2: updated file listing/editing
1 parent b4c69eb commit 3fc6576

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

share/roundup/templates/jinja2/html/file.index.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,32 @@ <h4>{% trans %}Files{% endtrans %}</h4>
44
<th>{% trans %}File name{% endtrans %}</th>
55
<th>{% trans %}Uploaded{% endtrans %}</th>
66
<th>{% trans %}Type{% endtrans %}</th>
7-
<th>{% trans %}Edit{% endtrans %}</th>
8-
<th>{% trans %}Remove{% endtrans %}</th>
7+
<th>{% if context.is_edit_ok() %}{% trans %}Edit{% endtrans %}{% else %}{% trans %}Details{% endtrans %}{% endif %}</th>
8+
{% if context.is_edit_ok() %}<th>{% trans %}Remove{% endtrans %}</th>{% endif %}
99
</tr>
1010
{% for file in context.files %}
1111
<tr>
1212
<td>
13-
<a href='{{ file.download_url() }}'>{{ file.name.plain()|u }}</a>
13+
<a class="btn btn-sm btn-outline-primary" href='{{ file.download_url()|u|safe }}'>{{ file.name.plain()|u }}</a>
1414
</td>
1515
<td>{{ file.creator.plain()|u }}, {{ file.creation.plain()|u }}</td>
1616
<td>{{ file.type.plain()|u }}</td>
17-
{% if file.is_edit_ok %}
18-
<td>
19-
<a href='file{{ file.id }}'>{% trans %}edit{% endtrans %}</a>
20-
</td>
21-
{% endif %}
22-
{% if context.is_edit_ok %}
17+
<td>
18+
<a class="btn btn-sm btn-success" href='file{{ file.id }}'>
19+
{% if file.is_edit_ok() %}
20+
{% trans %}edit{% endtrans %}
21+
{% else %}
22+
{% trans %}view{% endtrans %}
23+
{% endif %}
24+
</a>
25+
</td>
26+
{% if file.is_edit_ok() %}
2327
<td>
2428
<form method="POST" action='issue{{ context.id }}'>
2529
<input type="hidden" name="@remove@files" value='{{ file.id }}'>
2630
<input name="@csrf" type="hidden" value="{{ utils.anti_csrf_nonce() }}">
2731
<input type="hidden" name="@action" value="edit">
28-
<input type="submit" value="{% trans %}remove{% endtrans %}">
32+
<input class="btn btn-sm btn-danger" type="submit" value="{% trans %}remove{% endtrans %}">
2933
</form>
3034
</td>
3135
{% endif %}

share/roundup/templates/jinja2/html/file.item.html

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{% extends 'layout/page.html' %}
2+
{% import 'layout/view.tmpl' as view with context -%}
3+
{% import 'layout/edit.tmpl' as edit with context -%}
24

35
{% block head_title %}
46
{% trans %}File display{% endtrans %}
@@ -16,32 +18,33 @@
1618
<form method="POST"
1719
enctype="multipart/form-data" action='{{ context.designator() }}'>
1820

19-
<dl class="row row-cols-1 row-cols-md-2">
20-
<div class="col row">
21-
<dt class="col col-auto">{% trans %}Name{% endtrans %}</dt>
22-
<dd class="col col-auto">{{ context.name.field()|u|safe }}</dd>
23-
</div>
24-
<div class="col row">
25-
<dt class="col col-auto">{% trans %}Content Type{% endtrans %}</dt>
26-
<dd class="col col-auto">{{ context.type.field()|u|safe }}</dd>
27-
</div>
28-
</dl>
21+
<dl class="row row-cols-1 row-cols-lg-2 no-gutters">
22+
{% if context.is_edit_ok() %}
23+
{{ edit.field_small('Name', 'name', 'name', required=True) }}
24+
{{ edit.field_small('Content Type', 'type', 'type', required=True) }}
25+
{% else %}
26+
{{ view.field_small('Name', 'name') }}
27+
{{ view.field_small('Content Type', 'type') }}
28+
{% endif %}
29+
</dl>
2930

3031
<input type="hidden" name="@template" value="item">
3132
<input type="hidden" name="@required" value="name,type">
3233
{% if '@multilink' in request.form %}
3334
<input type="hidden" name="@multilink"
3435
value='{{ request.form["@multilink"].value()|u }}'>
3536
{% endif %}
37+
{% if context.is_edit_ok() %}
3638
<div class='form-actions'>
37-
{{ context.submit()|u|safe }}
39+
{{ context.submit(html_kwargs={'class': 'btn btn-primary'})|u|safe }}
3840
</div>
41+
{% endif %}
3942
</form>
4043
{% endif %}
4144

4245
{% if context.id and context.is_view_ok() %}
4346
<div>
44-
<a href='file{{ context.id }}/{{ context.name.plain()|u }}'>{% trans %}Download{% endtrans %}</a>
47+
<a class="btn btn-success" href="file{{ context.id }}/{{ context.name.plain()|u }}">{% trans %}Download{% endtrans %}</a>
4548
</div>
4649
{% endif %}
4750

0 commit comments

Comments
 (0)