From 20d9a71a9e901bd16033915630d72fcf0465512f Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sun, 16 Feb 2020 15:49:53 +0000 Subject: [PATCH] FIX: Remove assets from to-be-audited table when audited Previously required a page reload --- assets/forms.py | 1 + assets/templates/asset_audit.html | 7 ++++++- assets/templates/asset_audit_list.html | 7 +++++-- assets/templates/partials/asset_list_table_body.html | 4 +--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/assets/forms.py b/assets/forms.py index d4d90931..347c179f 100644 --- a/assets/forms.py +++ b/assets/forms.py @@ -26,6 +26,7 @@ class AssetAuditForm(AssetForm): # TODO Inherit exlcusions from superclass exclude = ['asset_id_prefix', 'asset_id_number', 'last_audited_at', 'last_audited_by', 'parent'] + class AssetSearchForm(forms.Form): query = forms.CharField(required=False) category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False) diff --git a/assets/templates/asset_audit.html b/assets/templates/asset_audit.html index 9d8f071a..d7eca597 100644 --- a/assets/templates/asset_audit.html +++ b/assets/templates/asset_audit.html @@ -114,11 +114,16 @@ + {% if not request.is_ajax %} +
+ +
+ {% endif %} {% endblock %} {% block footer %}
- +
{% endblock %} diff --git a/assets/templates/asset_audit_list.html b/assets/templates/asset_audit_list.html index 6d48dd94..de300d7b 100644 --- a/assets/templates/asset_audit_list.html +++ b/assets/templates/asset_audit_list.html @@ -15,9 +15,12 @@ return false; }); }); - function onClick() { + function onSearchClick() { $('#searchButton').attr("href", "{% url 'asset_audit' None %}".replace('None', $('#{{form.query.id_for_label}}').val())); } + function onAuditClick(assetID) { + $('#' + assetID).remove(); + } {% endblock %} @@ -31,7 +34,7 @@
{% render_field form.query|add_class:'form-control' placeholder='Enter Asset ID' autofocus="true" %} - Search + Search
diff --git a/assets/templates/partials/asset_list_table_body.html b/assets/templates/partials/asset_list_table_body.html index 2677c187..64526d08 100644 --- a/assets/templates/partials/asset_list_table_body.html +++ b/assets/templates/partials/asset_list_table_body.html @@ -1,7 +1,5 @@ {% for item in object_list %} - {#
  • {{ item.asset_id }} - {{ item.description }}
  • #} - - + {{ item.asset_id }} {{ item.description }} {{ item.category }}