diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2df36da4c0fd55374f82c40bc893d98fe649dee9..802c1274e8707e5c3ccf33c97a395ffc09000bc6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog`_, and this project adheres to `Semantic Versioning`_. +Unreleased +---------- + +Fixed +~~~~~ + +* get_next_properties() is erroneously called when an issue report dropdown gets cleared + `2.0`_ - 2021-10-30 ------------------- diff --git a/aleksis/apps/hjelp/templates/hjelp/issue_report.html b/aleksis/apps/hjelp/templates/hjelp/issue_report.html index f9462906d9fc35fb186819c7205c85fee8af2094..51d01bc362f0f1d7882f819f30bd722d4cd30bee 100644 --- a/aleksis/apps/hjelp/templates/hjelp/issue_report.html +++ b/aleksis/apps/hjelp/templates/hjelp/issue_report.html @@ -98,11 +98,10 @@ $(id).disabled = true; } $.fn.setNextProperties = function (field_id, next_field_id, next_field_name) { - var id = $('#' + field_id).find(':selected').val(); $.ajax({ url: '{% url "issues_get_next_properties" %}', data: { - 'id': id + 'id': field_id }, dataType: 'json', success: function (data) { @@ -123,13 +122,18 @@ }); } $("#{{ form.category_1.auto_id }}").on('input', function() { - $.fn.setNextProperties(this.id, "#{{ form.category_2.auto_id }}", "bug_category_2") + $.fn.setNextProperties($('#' + this.id).find(':selected').val(), "#{{ form.category_2.auto_id }}", "bug_category_2") if ($("#{{ form.category_3.auto_id }}").is(':visible')) { $.fn.hideAndDisable("#{{ form.category_3.auto_id }}") } }); $("#{{ form.category_2.auto_id }}").on('input', function() { - $.fn.setNextProperties(this.id, "#{{ form.category_3.auto_id }}", "bug_category_3") + let id = $('#' + this.id).find(':selected').val(); + if (id !== "") { + $.fn.setNextProperties(id, "#{{ form.category_3.auto_id }}", "bug_category_3"); + } else if ($("#{{ form.category_3.auto_id }}").is(':visible')) { + $.fn.hideAndDisable("#{{ form.category_3.auto_id }}") + } }); </script>