Improved list views to look better when they are empty

This commit is contained in:
Raphael Michel
2016-05-07 14:29:00 +02:00
parent 81c23271ea
commit 7ae7da5af1
8 changed files with 334 additions and 175 deletions

View File

@@ -2,7 +2,7 @@
{% load i18n %}
{% block title %}{% trans "Products" %}{% endblock %}
{% block inside %}
<h1>{% trans "Products" %}</h1>
<h1>{% trans "Products" %}</h1>
<p>
{% blocktrans trimmed %}
Below, you find a list of all available products. You can click on a product name to inspect and change
@@ -10,42 +10,57 @@
give category.
{% endblocktrans %}
</p>
<p>
<a href="{% url "control:event.items.add" organizer=request.event.organizer.slug event=request.event.slug %}"
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create new product" %}</a>
</p>
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
{% if items|length == 0 %}
<div class="empty-collection">
<p>
{% blocktrans trimmed %}
You haven't created any products yet.
{% endblocktrans %}
</p>
<a href="{% url "control:event.items.add" organizer=request.event.organizer.slug event=request.event.slug %}"
class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create a new product" %}</a>
</div>
{% else %}
<p>
<a href="{% url "control:event.items.add" organizer=request.event.organizer.slug event=request.event.slug %}"
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new product" %}</a>
</p>
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Product name" %}</th>
<th>{% trans "Category" %}</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
{% regroup items by category as cat_list %}
{% for c in cat_list %}
{% for i in c.list %}
<tr>
<td><strong>
{% if not i.active %}<strike>{% endif %}
<a href="
<tr>
<td><strong>
{% if not i.active %}<strike>{% endif %}
<a href="
{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}">{{ i.name }}</a>
{% if not i.active %}</strike>{% endif %}
</strong></td>
<td>{% if i.category %}{{ i.category.name }}{% endif %}</td>
<td>
<a href="{% url "control:event.items.up" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm {% if forloop.counter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-up"></i></a>
<a href="{% url "control:event.items.down" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm {% if forloop.revcounter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-down"></i></a>
</td>
<td class="text-right"><a href="{% url "control:event.items.delete" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a></td>
</tr>
{% if not i.active %}</strike>{% endif %}
</strong></td>
<td>{% if i.category %}{{ i.category.name }}{% endif %}</td>
<td>
<a href="{% url "control:event.items.up" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm {% if forloop.counter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-up"></i></a>
<a href="{% url "control:event.items.down" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-default btn-sm {% if forloop.revcounter0 == 0 %}disabled{% endif %}"><i class="fa fa-arrow-down"></i></a>
</td>
<td class="text-right">
<a href="{% url "control:event.items.delete" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
{% include "pretixcontrol/pagination.html" %}
</tbody>
</table>
</div>
{% include "pretixcontrol/pagination.html" %}
{% endif %}
{% endblock %}