=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-02-18 13:12:41 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-02-19 15:42:18 +0000 @@ -3,7 +3,6 @@ function($rootScope, $scope, $location, - $route, $modal, $timeout, $filter, === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-02-18 13:00:15 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-02-19 15:42:18 +0000 @@ -47,10 +47,12 @@ $scope.currentDummyEvent = null; $scope.currentEvent = null; $scope.currentStage = null; + $scope.totalEvents = 0; $scope.allowEventCreation = false; $scope.repeatableStages = []; $scope.dhis2Events = []; + $scope.eventsByStage = []; $scope.programStages = []; var selections = CurrentSelection.get(); @@ -70,8 +72,8 @@ $scope.currentStage = stage; } $scope.selectedProgramWithStage[stage.id] = stage; + $scope.eventsByStage[stage.id] = []; }); - $scope.getEvents(); }); } @@ -110,14 +112,17 @@ $scope.currentEvent = dhis2Event; $scope.showDataEntry($scope.currentEvent, true); } + + $scope.dhis2Events.push(dhis2Event); + $scope.eventsByStage[dhis2Event.programStage].push(dhis2Event); } - $scope.dhis2Events.push(dhis2Event); } }); } $scope.dhis2Events = orderByFilter($scope.dhis2Events, '-sortingDate'); - $scope.dummyEvents = $scope.checkForEventCreation($scope.dhis2Events, $scope.selectedProgram); + $scope.dummyEvents = $scope.checkForEventCreation($scope.dhis2Events, $scope.selectedProgram); + sortEventsByStage(); }); }; @@ -259,6 +264,7 @@ $scope.dhis2Events.splice(0,0,newEvent); } + $scope.eventsByStage[newEvent.programStage].push(newEvent); $scope.showDataEntry(newEvent, false); } }); @@ -707,7 +713,18 @@ index = i; } } - $scope.dhis2Events.splice(index,1); + $scope.dhis2Events.splice(index,1); + + continueLoop = true, index = -1; + for(var i=0; i< $scope.eventsByStage[$scope.currentEvent.programStage].length && continueLoop; i++){ + if($scope.eventsByStage[$scope.currentEvent.programStage][i].event === $scope.currentEvent.event ){ + $scope.eventsByStage[$scope.currentEvent.programStage][i] = $scope.currentEvent; + continueLoop = false; + index = i; + } + } + $scope.eventsByStage[$scope.currentEvent.programStage].splice(index,1); + $scope.currentEvent = null; if($scope.dhis2Events.length < 1){ $scope.dhis2Events = ''; @@ -737,4 +754,22 @@ } return style; }; + + $scope.getColumnWidth = function(weight){ + var col = 1; + if($scope.totalEvents > 0){ + col = weight <=1 ? 1 : weight; + col = Math.round(col*12/$scope.totalEvents); + } + return "col-sm-" + col; + }; + + var sortEventsByStage = function(){ + for(var key in $scope.eventsByStage){ + if($scope.eventsByStage.hasOwnProperty(key)){ + $scope.eventsByStage[key] = orderByFilter($scope.eventsByStage[key], '-sortingDate').reverse(); + $scope.totalEvents += $scope.eventsByStage[key].length <=1 ? 1:$scope.eventsByStage[key].length; + } + } + }; }); \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2015-02-18 13:00:15 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2015-02-19 15:42:18 +0000 @@ -2,9 +2,9 @@