Remove animation on prefers-reduced-motion/low referesh rate devices

Also normalises handling of asset list cable table & improves its use of space on large devices
This commit is contained in:
2020-10-18 11:04:58 +01:00
parent 7736a2d3cc
commit 59756ab86a
11 changed files with 58 additions and 40 deletions

View File

@@ -2,8 +2,6 @@
{% load widget_tweaks %}
{% load static %}
{% block title %}Asset {{ object.asset_id }}{% endblock %}
{% block css %}
<link rel="stylesheet" href="{% static 'css/bootstrap-select.css' %}"/>
<link rel="stylesheet" href="{% static 'css/ajax-bootstrap-select.css' %}"/>
@@ -14,11 +12,13 @@
<script src="{% static 'js/ajax-bootstrap-select.js' %}"></script>
<script src="{% static 'js/autocompleter.js' %}"></script>
<script>
const matches = window.matchMedia("(prefers-reduced-motion: reduce)").matches || window.matchMedia("(update: slow)").matches;
dur = matches ? 0 : 500;
function checkIfCableHidden() {
if (document.getElementById("id_is_cable").checked) {
document.getElementById("cable-table").hidden = false;
if ($("#id_is_cable").prop('checked')) {
$("#cable-table").slideDown(dur);
} else {
document.getElementById("cable-table").hidden = true;
$("#cable-table").slideUp(dur);
}
}
checkIfCableHidden();
@@ -71,15 +71,6 @@
{% endblock %}
{% block content %}
<h1>
{% if edit and object %}
Edit Asset: {{ object.asset_id }}
{% elif duplicate %}
Duplication of Asset: {{ previous_asset_id }}
{% else %}
Create Asset
{% endif %}
</h1>
{% if duplicate %}
<form method="POST" id="asset_update_form" action="{% url 'asset_duplicate' pk=previous_asset_id %}">
{% elif edit %}
@@ -90,24 +81,24 @@
{% include 'form_errors.html' %}
{% csrf_token %}
<input type="hidden" name="id" value="{{ object.id|default:0 }}" hidden=true>
<div class="row pt-4">
<div class="row pt-2">
<div class="col-sm-12">
{% include 'partials/asset_detail_form.html' %}
</div>
</div>
<div class="row pt-4">
<div class="col-md-6">
<div class="row pt-2">
<div class="col-12 col-sm">
{% include 'partials/purchasedetails_form.html' %}
</div>
<div class="col-md-6" hidden="true" id="cable-table">
<div class="col-12 col-sm-6 col-md-4" id="cable-table">
{% include 'partials/cable_form.html' %}
</div>
<div class="col-md-4">
<div class="col-12 col-md-4">
{% include 'partials/parent_form.html' %}
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-12">
{% include 'partials/asset_buttons.html' %}
</div>
</div>

View File

@@ -1,5 +1,5 @@
{% load widget_tweaks %}
<div class="card">
<div class="card mb-2">
<div class="card-header">
Cable Details
</div>

View File

@@ -1,5 +1,5 @@
{% load widget_tweaks %}
<div class="card">
<div class="card mb-2">
<div class="card-header">
Collection Details
</div>

View File

@@ -1,5 +1,5 @@
{% load widget_tweaks %}
<div class="card">
<div class="card mb-2">
<div class="card-header">
Purchase Details
</div>

View File

@@ -117,7 +117,7 @@ class AssetEdit(LoginRequiredMixin, AssetIDUrlMixin, generic.UpdateView):
context = super().get_context_data(**kwargs)
context["edit"] = True
context["connectors"] = models.Connector.objects.all()
context["page_title"] = "Edit Asset: {}".format(self.object.display_id)
return context
def get_success_url(self):
@@ -140,7 +140,7 @@ class AssetCreate(LoginRequiredMixin, generic.CreateView):
context = super(AssetCreate, self).get_context_data(**kwargs)
context["create"] = True
context["connectors"] = models.Connector.objects.all()
context["page_title"] = "Create Asset"
return context
def get_initial(self, *args, **kwargs):
@@ -165,6 +165,7 @@ class AssetDuplicate(DuplicateMixin, AssetIDUrlMixin, AssetCreate):
context["create"] = None
context["duplicate"] = True
context['previous_asset_id'] = self.get_object().asset_id
context["page_title"] = "Duplication of Asset: {}".format(context['previous_asset_id'])
return context