Sortable table and dashboard_view styling

This commit is contained in:
Neil Martinsen-Burrell 2023-01-27 11:51:30 -06:00
parent 5dd4da2d5f
commit 69533a2f80
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
4 changed files with 31 additions and 8 deletions

View file

@ -130,7 +130,7 @@ section.dashboard {
} }
} }
#wrapper { #wrapper.dashboard {
background-color: color('primary-lightest'); background-color: color('primary-lightest');
} }

View file

@ -128,11 +128,13 @@
<div class="usa-navbar"> <div class="usa-navbar">
{% block logo %} {% block logo %}
<div class="usa-logo" id="extended-logo"> <div class="usa-logo" id="extended-logo">
<a href="{% url 'home' %}">
<img <img
src="{% static 'img/dottedgov-round.svg' %}" src="{% static 'img/dottedgov-round.svg' %}"
alt="Home" alt="Home"
width="48px" width="48px"
/> />
</a>
</div> </div>
{% endblock %} {% endblock %}
<button type="button" class="usa-menu-btn">Menu</button> <button type="button" class="usa-menu-btn">Menu</button>
@ -162,7 +164,7 @@
</div> </div>
</header> </header>
{% endblock banner %} {% endblock banner %}
<div id="wrapper"> <div id="wrapper" {% if dashboard_view %}class="dashboard"{% endif %}>
{% block messages %} {% block messages %}
{% if messages %} {% if messages %}
<ul class="messages"> <ul class="messages">

View file

@ -1,5 +1,7 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %}
{% block title %} Hello {% endblock %} {% block title %} Hello {% endblock %}
{% block content %} {% block content %}
@ -30,19 +32,36 @@
<caption class="sr-only">Your domain applications</caption> <caption class="sr-only">Your domain applications</caption>
<thead> <thead>
<tr> <tr>
<th>Name</th> <th data-sortable scope="col" role="columnheader">Domain name</th>
<th>Status</th> <th data-sortable scope="col" role="columnheader">Date created</th>
<th data-sortable scope="col" role="columnheader">Status</th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for application in domain_applications %} {% for application in domain_applications %}
<tr> <tr>
<th> <th th scope="row" role="rowheader">
<a href="{% url 'edit-application' application.pk %}">
{{ application.requested_domain.name|default:"New domain request" }} {{ application.requested_domain.name|default:"New domain request" }}
</a>
</th> </th>
<td>{{ application.status }}</td> <td data-sort-value="{{ application.created_at|date:"U" }}">{{ application.created_at|date }}</td>
<td>{{ application.status|title }}</td>
<td>
<a href="{% url 'edit-application' application.pk %}">
{% if application.status == "started" %}
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{%static 'img/sprite.svg'%}#edit"></use>
</svg>
Edit
{% else %}
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{%static 'img/sprite.svg'%}#settings"></use>
</svg>
Manage
{% endif %}
</a>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View file

@ -7,6 +7,8 @@ def index(request):
"""This page is available to anyone without logging in.""" """This page is available to anyone without logging in."""
context = {} context = {}
if request.user.is_authenticated: if request.user.is_authenticated:
# the logged-in index view IS the dashboard
context["dashboard_view"] = True
applications = DomainApplication.objects.filter(creator=request.user) applications = DomainApplication.objects.filter(creator=request.user)
context["domain_applications"] = applications context["domain_applications"] = applications
return render(request, "home.html", context) return render(request, "home.html", context)