Skip to content

Commit 9dc86d1

Browse files
authored
GOATS-690: Improve UI in various places. (#414)
- Add colspan to various tables when table is empty. - Hide empty select when no observation groups.
1 parent 6b27091 commit 9dc86d1

8 files changed

Lines changed: 147 additions & 8 deletions

File tree

File renamed without changes.
File renamed without changes.

docs/changes/414.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved UI for tables when no data to display. Also hide empty select box when no observation groups.

src/goats_tom/templates/tom_alerts/brokerquery_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h3>Query a Broker</h3>
3636
</tr>
3737
{% empty %}
3838
<tr>
39-
<td colspan="5">
39+
<td colspan="6">
4040
No saved queries yet, Try creating a query from one of the alert brokers listed above.
4141
</td>
4242
</tr>

src/goats_tom/templates/tom_observations/observation_list.html

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,23 @@
1717
{% observation_distribution filter.qs %}
1818
<form action="" method="GET">
1919
<div class="row">
20-
<div class="col">
21-
<button type="submit" name="action" value="add" class="btn btn-primary">Add</button>
22-
<button type="submit" name="action" value="remove" class="btn btn-danger">Remove </button>
23-
Selected observations from group
24-
{{ filter.form.observationgroup }}
25-
</div>
20+
<div class="col d-flex align-items-center gap-2">
21+
<button type="submit" name="action" value="add" class="btn btn-primary">
22+
Add
23+
</button>
24+
<button type="submit" name="action" value="remove" class="btn btn-danger">
25+
Remove
26+
</button>
27+
<span>Selected observations from group:</span>
28+
{% if filter.form.observationgroup.field.queryset %}
29+
<div>
30+
{{ filter.form.observationgroup }}
31+
</div>
32+
{% else %}
33+
<span class="text-muted fst-italic">No groups available</span>
34+
{% endif %}
35+
</div>
2636
</div>
27-
2837
<table class="table">
2938
<thead>
3039
<tr>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% extends 'tom_common/base.html' %}
2+
{% load bootstrap4 %}
3+
{% block title %}Target Groups{% endblock %}
4+
{% block content %}
5+
<h1>Observation Groups</h1>
6+
<div class="row">
7+
<div class="col-md-10">
8+
<p>
9+
<a href="{% url 'observations:group-create' %}" class="btn btn-primary">Create New Grouping</a>
10+
</p>
11+
</div>
12+
</div>
13+
{% bootstrap_pagination page_obj extra=request.GET.urlencode %}
14+
<form action="{% url 'targets:list' %}" method="GET">
15+
<table class="table table-striped">
16+
<thead>
17+
<tr>
18+
<th>Name</th>
19+
<th>Total Observations</th>
20+
<th>Delete</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
{% for group in object_list %}
25+
<tr>
26+
<td>
27+
<a href="{% url 'tom_observations:list' %}?observationgroup={{ group.id }}">
28+
{{ group.name }}
29+
</a>
30+
</td>
31+
<td>
32+
{{ group.observation_records.count }}
33+
</td>
34+
<td>
35+
<a href="{% url 'tom_observations:group-delete' pk=group.id %}" class="btn btn-danger">Delete</a>
36+
</td>
37+
</tr>
38+
{% empty %}
39+
<tr>
40+
<td colspan="3">No groups yet</td>
41+
</tr>
42+
{% endfor %}
43+
</tbody>
44+
</table>
45+
</form>
46+
{% bootstrap_pagination page_obj extra=request.GET.urlencode %}
47+
{% endblock %}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<h4>Groups</h4>
2+
<table class="table table-striped">
3+
<thead>
4+
<tr>
5+
<th>Name</th>
6+
<th>Total Targets</th>
7+
<th>Remove</th>
8+
</tr>
9+
</thead>
10+
<tbody>
11+
{% for group in groups %}
12+
<tr>
13+
<td>
14+
<form action="{% url 'targets:list' %}" method="GET">
15+
<button type="submit" class="btn btn-link" name="targetlist__name" value="{{group.id}}" title="View Group">{{ group.name }}</button>
16+
</form>
17+
</td>
18+
<td valign="middle">{{ group.targets.count }}</td>
19+
<td>
20+
<form action="{% url 'targets:add-remove-grouping' %}" method="POST">
21+
{% csrf_token %}
22+
<button type="submit" title="Remove Target from Group" class="btn btn-danger" name="remove">Remove</button>
23+
<input type="hidden" name="selected-target" value="{{ target.id }}"/>
24+
<input type="hidden" name="grouping" value="{{ group.id }}"/>
25+
</form>
26+
</td>
27+
28+
</tr>
29+
{% empty %}
30+
<tr>
31+
<td colspan="3">Not in any groups</td>
32+
</tr>
33+
{% endfor %}
34+
</tbody>
35+
</table>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% extends 'tom_common/base.html' %}
2+
{% load bootstrap4 %}
3+
{% block title %}Target Groups{% endblock %}
4+
{% block content %}
5+
<h1>Target Groupings</h1>
6+
<div class="row">
7+
<div class="col-md-10">
8+
<p>
9+
<a href="{% url 'targets:create-group' %}" class="btn btn-primary">Create New Grouping</a>
10+
</p>
11+
</div>
12+
</div>
13+
{% bootstrap_pagination page_obj extra=request.GET.urlencode %}
14+
<form action="{% url 'targets:list' %}" method="GET">
15+
<table class="table table-striped">
16+
<thead>
17+
<tr>
18+
<th>Group</th>
19+
<th>Total Targets</th>
20+
{% if sharing %}
21+
<th>Share</th>
22+
{% endif %}
23+
<th>Delete</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
{% for group in object_list %}
28+
<tr>
29+
<td><button type="submit" class="btn btn-link" name="targetlist__name" value="{{group.id}}" title="View Group">{{ group.name }}</button></td>
30+
<td valign="middle">{{ group.targets.count }}</td>
31+
{% if sharing %}
32+
<td>
33+
<a href="{% url 'targets:share-group' group.id%}" title="Share Group" class="btn btn-info">Share</a>
34+
</td>
35+
{% endif %}
36+
<td><a href="{% url 'targets:delete-group' group.id%}" title="Delete Group" class="btn btn-danger">Delete</a></td>
37+
</tr>
38+
{% empty %}
39+
<tr>
40+
<td colspan="3">No groups yet</td>
41+
</tr>
42+
{% endfor %}
43+
</tbody>
44+
</table>
45+
</form>
46+
{% bootstrap_pagination page_obj extra=request.GET.urlencode %}
47+
{% endblock %}

0 commit comments

Comments
 (0)