From 2263e79fd86b05efdcf41c1310faf045777b5fc4 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:37:10 +0200 Subject: [PATCH] fix: [DHIS2-15102] assign data elements sequentially (#1852) --- components/dataentry/dataentry-controller.js | 6 +++--- scripts/services.js | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/dataentry/dataentry-controller.js b/components/dataentry/dataentry-controller.js index 35330f87c..7188327af 100644 --- a/components/dataentry/dataentry-controller.js +++ b/components/dataentry/dataentry-controller.js @@ -34,7 +34,8 @@ trackerCapture.controller('DataEntryController', AuthorityService, AccessUtils, TCOrgUnitService, - UsersService) { + UsersService, + AssignmentQueue) { //Unique instance id for the controller: $scope.APIURL = DHIS2URL; @@ -1752,7 +1753,7 @@ trackerCapture.controller('DataEntryController', } ] }; - return DHIS2EventFactory.updateForSingleValue(ev).then(function (response) { + return AssignmentQueue.insertAssignment(() => DHIS2EventFactory.updateForSingleValue(ev)).then(function (response) { if(!response) { if(!backgroundUpdate) { $scope.currentElement.saved = false; @@ -1789,7 +1790,6 @@ trackerCapture.controller('DataEntryController', } }); - } }; diff --git a/scripts/services.js b/scripts/services.js index 207015c6f..dd2e3d0f2 100644 --- a/scripts/services.js +++ b/scripts/services.js @@ -3414,4 +3414,12 @@ var trackerCaptureServices = angular.module('trackerCaptureServices', ['ngResour }); return promise; } +}) +.service('AssignmentQueue', function() { + var assignmentQueue = Promise.resolve(); + + this.insertAssignment = function(assignment) { + assignmentQueue = assignmentQueue.then(assignment, assignment); + return assignmentQueue; + } });