From 95067ddb08ccd3472a276e3dc577d4ba186a8e5f Mon Sep 17 00:00:00 2001 From: Shubham Dhama Date: Fri, 16 Mar 2018 01:59:32 +0530 Subject: [PATCH] org settings: Disable "Add filter" button when a request is in transit. This prevents accidental multiple click requests due to which we get some errors like "This field cannot be blank" (though we have successfully added the desired filter). Fixes: #8699. --- static/js/settings_filters.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/js/settings_filters.js b/static/js/settings_filters.js index 136fcd7ad8..97ecc46f2a 100644 --- a/static/js/settings_filters.js +++ b/static/js/settings_filters.js @@ -72,6 +72,8 @@ exports.set_up = function () { var filter_status = $('#admin-filter-status'); var pattern_status = $('#admin-filter-pattern-status'); var format_status = $('#admin-filter-format-status'); + var add_filter_button = $('.new-filter-form button'); + add_filter_button.attr("disabled", "disabled"); filter_status.hide(); pattern_status.hide(); format_status.hide(); @@ -86,11 +88,13 @@ exports.set_up = function () { success: function (data) { $('#filter_pattern').val(''); $('#filter_format_string').val(''); + add_filter_button.removeAttr("disabled"); filter.id = data.id; ui_report.success(i18n.t("Custom filter added!"), filter_status); }, error: function (xhr) { var errors = JSON.parse(xhr.responseText).errors; + add_filter_button.removeAttr("disabled"); if (errors.pattern !== undefined) { xhr.responseText = JSON.stringify({msg: errors.pattern}); ui_report.error(i18n.t("Failed"), xhr, pattern_status);