From d8b788fc85b8901526b1d4443210200d8b15ba07 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Tue, 10 Sep 2024 18:23:02 +0200 Subject: [PATCH] Prevent the page to change when a validation error occurs on project_questions (#1134) --- .../projects/js/project_questions/services.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rdmo/projects/static/projects/js/project_questions/services.js b/rdmo/projects/static/projects/js/project_questions/services.js index e24c168bc..5fcff4971 100644 --- a/rdmo/projects/static/projects/js/project_questions/services.js +++ b/rdmo/projects/static/projects/js/project_questions/services.js @@ -922,8 +922,10 @@ angular.module('project_questions') service.error = null; // reset error when moving to previous questionset if (service.settings.project_questions_autosave) { service.save(false, true).then(function() { - back = true; - service.initView(service.page.prev_page); + if (service.error === null) { + back = true; + service.initView(service.page.prev_page); + } }) } else { back = true; @@ -935,7 +937,9 @@ angular.module('project_questions') service.error = null; // reset error when moving to next questionset if (service.settings.project_questions_autosave) { service.save(false, true).then(function() { - service.initView(service.page.next_page); + if (service.error === null) { + service.initView(service.page.next_page); + } }) } else { service.initView(service.page.next_page); @@ -946,8 +950,8 @@ angular.module('project_questions') service.error = null; // reset error before saving if (service.settings.project_questions_autosave) { service.save(false, true).then(function() { - if (service.error !== null && service.error.status !== 400) { - // pass, dont jump (but not on a validation error) + if (service.error !== null) { + // pass, dont jump } else if (angular.isDefined(page)) { service.initView(page.id); } else if (angular.isDefined(section)) {