From a65726a30bc83ba917f2379172d8d1cc496f6bfb Mon Sep 17 00:00:00 2001 From: 635487 <635487@bah.com> Date: Thu, 30 May 2024 09:58:35 -0700 Subject: [PATCH 1/2] 85-pattern-error: add toastr error --- sde_indexing_helper/static/js/candidate_url_list.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sde_indexing_helper/static/js/candidate_url_list.js b/sde_indexing_helper/static/js/candidate_url_list.js index 8d5f1e17..40cc1488 100644 --- a/sde_indexing_helper/static/js/candidate_url_list.js +++ b/sde_indexing_helper/static/js/candidate_url_list.js @@ -855,6 +855,10 @@ function postDocumentTypePatterns( }, error: function (xhr, status, error) { var errorMessage = xhr.responseText; + if (errorMessage == '{"error":{"non_field_errors":["The fields collection, match_pattern must make a unique set."]},"status_code":400}') { + toastr.error("Pattern already exists"); + return; + } toastr.error(errorMessage); }, }); @@ -979,6 +983,10 @@ function postTitlePatterns( }, error: function (xhr, status, error) { var errorMessage = xhr.responseText; + if (errorMessage == '{"error":{"non_field_errors":["The fields collection, match_pattern must make a unique set."]},"status_code":400}') { + toastr.error("Pattern already exists"); + return; + } toastr.error(errorMessage); }, }); From 70ff0e5b492bab511a3d4fdeaef8d45944f07a24 Mon Sep 17 00:00:00 2001 From: 635487 <635487@bah.com> Date: Thu, 30 May 2024 11:40:58 -0700 Subject: [PATCH 2/2] 85-pattern-error: change error message to be more readable --- sde_indexing_helper/static/js/candidate_url_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sde_indexing_helper/static/js/candidate_url_list.js b/sde_indexing_helper/static/js/candidate_url_list.js index 40cc1488..ef25c419 100644 --- a/sde_indexing_helper/static/js/candidate_url_list.js +++ b/sde_indexing_helper/static/js/candidate_url_list.js @@ -856,7 +856,7 @@ function postDocumentTypePatterns( error: function (xhr, status, error) { var errorMessage = xhr.responseText; if (errorMessage == '{"error":{"non_field_errors":["The fields collection, match_pattern must make a unique set."]},"status_code":400}') { - toastr.error("Pattern already exists"); + toastr.success("Pattern already exists"); return; } toastr.error(errorMessage); @@ -984,7 +984,7 @@ function postTitlePatterns( error: function (xhr, status, error) { var errorMessage = xhr.responseText; if (errorMessage == '{"error":{"non_field_errors":["The fields collection, match_pattern must make a unique set."]},"status_code":400}') { - toastr.error("Pattern already exists"); + toastr.success("Pattern already exists"); return; } toastr.error(errorMessage);