← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18746: tracker-capture: bug fix for unique attributes. Unique attributes can not be null, hence mandator...

 

------------------------------------------------------------
revno: 18746
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-30 15:21:20 +0200
message:
  tracker-capture: bug fix for unique attributes. Unique attributes can not be null, hence mandatory to fill.
modified:
  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/registration/default-registration-form.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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-03-19 10:18:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-03-30 13:21:20 +0000
@@ -74,7 +74,7 @@
             <div ng-if="currentEvent">
                 
                 <!-- event dates/scheduling begin -->
-                <div class="row">
+                <div class="row" ng-if="!currentStage.periodType">
                     <div class="col-md-6">
                         {{currentEvent.reportDateDescription}}
                         <input type="text"

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html	2015-03-26 12:26:37 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html	2015-03-30 13:21:20 +0000
@@ -2,7 +2,7 @@
 <table class="table-borderless table-striped">
     <tr ng-repeat="attribute in attributes">
         <td>
-            {{attribute.name}}<span ng-if="attribute.mandatory" class="required">*</span>
+            {{attribute.name}}<span ng-if="attribute.mandatory || attribute.unique" class="required">*</span>
         </td>
         <td>
             <ng-form name="innerForm">
@@ -16,7 +16,7 @@
                                max-date="attribute.allowFutureDate ? '' : 0"
                                ng-model="selectedTei[attribute.id]"
                                ng-disabled="editingDisabled" 
-                               ng-required="attribute.mandatory"/>
+                               ng-required="attribute.mandatory || attribute.unique"/>
                     </span>
                     <span ng-switch-when="trueOnly">
                         <input type="checkbox" 
@@ -24,14 +24,14 @@
                                class="form-control" 
                                ng-model="selectedTei[attribute.id]" 
                                ng-disabled="editingDisabled" 
-                               ng-required="attribute.mandatory"/>
+                               ng-required="attribute.mandatory || attribute.unique"/>
                     </span>
                     <span ng-switch-when="bool">
                         <select name="foo" 
                                 ng-model="selectedTei[attribute.id]" 
                                 class="form-control" 
                                 ng-disabled="editingDisabled" 
-                                ng-required="attribute.mandatory">
+                                ng-required="attribute.mandatory || attribute.unique">
                             <option value="">{{'please_select'| translate}}</option>                        
                             <option value="false">{{'no'| translate}}</option>
                             <option value="true">{{'yes'| translate}}</option>
@@ -44,7 +44,7 @@
                                ng-model="selectedTei[attribute.id]"                                                 
                                typeahead="option.name as option.name for option in optionSets[attributesById[attribute.id].optionSet.id].options | filter:$viewValue | limitTo:20" 
                                typeahead-open-on-focus                                           
-                               ng-disabled="editingDisabled" ng-required="attribute.mandatory"/>
+                               ng-disabled="editingDisabled" ng-required="attribute.mandatory || attribute.unique"/>
                     </span>
                     <span ng-switch-when="number">
                         <input type="text" 
@@ -52,7 +52,7 @@
                                class="form-control" 
                                ng-model="selectedTei[attribute.id]" 
                                ng-disabled="editingDisabled" 
-                               ng-required="attribute.mandatory"/>
+                               ng-required="attribute.mandatory || attribute.unique"/>
                     </span>
                     <span ng-switch-when="email">
                         <input type="email" 
@@ -60,7 +60,7 @@
                                class="form-control" 
                                ng-model="selectedTei[attribute.id]" 
                                ng-disabled="editingDisabled" 
-                               ng-required="attribute.mandatory"/>
+                               ng-required="attribute.mandatory || attribute.unique"/>
                     </span>
                     <span ng-switch-default>
                         <input type="text" 
@@ -68,7 +68,7 @@
                                class="form-control" 
                                ng-model="selectedTei[attribute.id]" 
                                ng-disabled="editingDisabled" 
-                               ng-required="attribute.mandatory"/>                                    
+                               ng-required="attribute.mandatory || attribute.unique"/>                                    
                     </span>
                 </span>
             </ng-form>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-03-27 14:31:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-03-30 13:21:20 +0000
@@ -227,16 +227,5 @@
     
     var notifyRegistrtaionCompletion = function(destination, teiId){
         goToDashboard( destination ? destination : 'DASHBOARD', teiId );
-        /*if($scope.registrationMode === 'REGISTRATION'){
-            goToDashboard(destination, teiId);
-        }
-        else{
-            
-            var selections = CurrentSelection.get();
-            CurrentSelection.set({tei: $scope.selectedTei, te: $scope.selectedTei.trackedEntity, prs: selections.prs, pr: $scope.selectedProgram, prNames: selections.prNames, prStNames: selections.prStNames, enrollments: selections.enrollments.push($scope.selectedEnrollment), selectedEnrollment: $scope.selectedEnrollment, optionSets: selections.optionSets});        
-            $timeout(function() { 
-                $rootScope.$broadcast('selectedItems', {programExists: selections.prs.length > 0});            
-            }, 100);
-        }*/
     };
 });
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-03-28 09:24:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-03-30 13:21:20 +0000
@@ -51,7 +51,7 @@
 })
 
 /* current selections */
-.service('PeriodService', function(DateUtils, CalendarService){
+.service('PeriodService', function(DateUtils, CalendarService, $filter){
     
     var calendarSetting = CalendarService.getSetting();    
     
@@ -65,7 +65,7 @@
     };
     
     this.getPeriods = function(events, stage, enrollment){
-        
+     
         if(!stage){
             return;
         }
@@ -88,15 +88,20 @@
         else{
 
             var startDate = DateUtils.format( moment(referenceDate, calendarSetting.momentFormat).add(offset, 'days') );
-            var periodOffet = splitDate(DateUtils.getToday()).year - splitDate(startDate).year;
-
+            var periodOffset = splitDate(DateUtils.getToday()).year - splitDate(startDate).year;
+            var eventDateOffSet = moment(referenceDate, calendarSetting.momentFormat).add('d', offset)._d;
+            eventDateOffSet = $filter('date')(eventDateOffSet, calendarSetting.keyDateFormat);        
+            
             //generate availablePeriods
             var pt = new PeriodType();
-            var d2Periods = pt.get(stage.periodType).generatePeriods({offset: periodOffet, filterFuturePeriods: false, reversePeriods: false});
+            var d2Periods = pt.get(stage.periodType).generatePeriods({offset: periodOffset, filterFuturePeriods: false, reversePeriods: false});
             angular.forEach(d2Periods, function(p){
                 p.endDate = DateUtils.formatFromApiToUser(p.endDate);
                 p.startDate = DateUtils.formatFromApiToUser(p.startDate);
-                availablePeriods[p.endDate] = p;
+                
+                if(moment(p.endDate).isAfter(eventDateOffSet)){
+                    availablePeriods[p.endDate] = p;
+                }                
             });                
 
             //get occupied periods
@@ -771,7 +776,7 @@
                         att.mandatory = pAttribute.mandatory;
                         if(pAttribute.displayInList){
                             att.displayInListNoProgram = true;
-                        }                    
+                        }
                         programAttributes.push(att);                
                     });
                     
@@ -1461,10 +1466,8 @@
                             };
                         if(stage.periodType){
                             var periods = getEventDuePeriod(null, stage, enrollment);
-                            newEvent.dueDate = DateUtils.formatFromUserToApi(periods[0].dueDate);;
+                            newEvent.dueDate = DateUtils.formatFromUserToApi(periods[0].endDate);;
                             newEvent.eventDate = newEvent.dueDate;
-                            //newEvent.periodName = periods[0].name;                            
-                            //newEvent.periods = periods;
                         }
                         else{
                             newEvent.dueDate = DateUtils.formatFromUserToApi(getEventDueDate(null,stage, enrollment));

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-03-30 10:40:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-03-30 13:21:20 +0000
@@ -403,7 +403,7 @@
 	                                            ' ng-model="selectedTei.' + attId + '" ' +
 	                                            ' ng-disabled="editingDisabled"' +
 	                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ';
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ';
 	                        }                                               
 	                        else if(att.valueType === "optionSet"){
 	                            var optionSetId = att.optionSet.id;                            
@@ -422,7 +422,7 @@
 	                                            ' typeahead="option.name as option.name for option in optionSets.' + optionSetId + '.options | filter:$viewValue | limitTo:50"' +
 	                                            ' typeahead-open-on-focus ' +
 	                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ';                            
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ';                            
 	                        }
 	                        else if(att.valueType === "bool"){
 	                            newInputField = '<select ' +
@@ -433,7 +433,7 @@
 	                                            ' ng-model="selectedTei.' + attId + '" ' +
 	                                            ' ng-disabled="editingDisabled"' +
 	                                            ' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ' +
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ' +
 	                                            ' <option value="">{{\'please_select\'| translate}}</option>' +
 	                                            ' <option value="false">{{\'no\'| translate}}</option>' + 
 	                                            ' <option value="true">{{\'yes\'| translate}}</option>' +
@@ -452,7 +452,7 @@
 	                                            ' d2-date' +
 	                                            ' d2-validation ' +
 	                                            ' blur-or-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ';
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ';
 	                        }
 	                        else if(att.valueType === "trueOnly"){
 	                            newInputField = '<input type="checkbox" ' +  
@@ -464,7 +464,7 @@
 	                                            ' ng-model="selectedTei.' + attId + '" ' +
 	                                            ' ng-disabled="editingDisabled"' +
 	                                            ' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ';
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ';
 	                        }
 	                        else if(att.valueType === "email"){
 	                            newInputField = '<input type="email" ' +    
@@ -476,7 +476,7 @@
 	                                            ' ng-model="selectedTei.' + attId + '" ' +
 	                                            ' ng-disabled="editingDisabled"' +
 	                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ';
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ';
 	                        }
 	                        else {
 	                            newInputField = '<input type="text" ' +
@@ -488,7 +488,7 @@
 	                                            ' ng-model="selectedTei.' + attId + '" ' +
 	                                            ' ng-disabled="editingDisabled"' +
 	                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
-	                                            ' ng-required=" ' + att.mandatory + '"> ';
+	                                            ' ng-required=" ' + att.mandatory || att.unique + '"> ';
 	                        }
                        }