dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33647
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17211: tracker capture - respect setting for opening first stage after enrollment
------------------------------------------------------------
revno: 17211
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-22 16:22:06 +0200
message:
tracker capture - respect setting for opening first stage after enrollment
modified:
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/dataentry/dataentry-controller.js
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/registration-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
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/tracker-capture.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/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2014-10-22 14:22:06 +0000
@@ -67,7 +67,7 @@
}
});
- $scope.optionSets = {optionSets: [], optionNamesByCode: new Object(), optionCodesByName: new Object()};
+ $scope.optionSets = {optionSets: [], optionNamesByCode: new Object(), optionCodesByName: new Object()};
OptionSetFactory.getAll().then(function(optionSets){
angular.forEach(optionSets, function(optionSet){
angular.forEach(optionSet.options, function(option){
=== 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 2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2014-10-22 14:22:06 +0000
@@ -1,6 +1,5 @@
trackerCapture.controller('DataEntryController',
function($scope,
- $timeout,
DateUtils,
EventUtils,
orderByFilter,
@@ -48,6 +47,7 @@
$scope.showDummyEventDiv = false;
$scope.currentDummyEvent = null;
$scope.currentEvent = null;
+ $scope.currentStage = null;
$scope.allowEventCreation = false;
$scope.repeatableStages = [];
@@ -61,14 +61,12 @@
$scope.optionSets = selections.optionSets;
$scope.selectedProgramWithStage = [];
- if($scope.selectedOrgUnit &&
- $scope.selectedProgram &&
- $scope.selectedEntity &&
- $scope.selectedEnrollment){
-
+ if($scope.selectedOrgUnit && $scope.selectedProgram && $scope.selectedEntity && $scope.selectedEnrollment){
angular.forEach($scope.selectedProgram.programStages, function(st){
-
ProgramStageFactory.get(st.id).then(function(stage){
+ if(stage.openAfterEnrollment){
+ $scope.currentStage = stage;
+ }
$scope.selectedProgramWithStage[stage.id] = stage;
});
});
@@ -109,6 +107,20 @@
dhis2Event.statusColor = EventUtils.getEventStatusColor(dhis2Event);
//dhis2Event = EventUtils.setEventOrgUnitName(dhis2Event);
+
+ if($scope.currentStage && $scope.currentStage.id === dhis2Event.programStage){
+ $scope.currentEvent = dhis2Event;
+ if(!dhis2Event.eventDate){
+ if($scope.currentStage.reportDateToUse === 'dateOfIncident'){
+ $scope.currentEvent.eventDate = $scope.selectedEnrollment.dateOfIncident;
+ }
+ else{
+ $scope.currentEvent.eventDate = $scope.selectedEnrollment.dateOfEnrollment;
+ }
+ }
+ $scope.saveEventDate();
+ $scope.showDataEntry($scope.currentEvent, true);
+ }
}
}
});
@@ -247,18 +259,18 @@
$scope.dhis2Events.splice(0,0,newEvent);
}
- $scope.showDataEntry(newEvent);
+ $scope.showDataEntry(newEvent, false);
}
});
};
- $scope.showDataEntry = function(event){
+ $scope.showDataEntry = function(event, rightAfterEnrollment){
//$scope.dueDateSaved = false;
//$scope.eventDateSaved = false;
if(event){
- if($scope.currentEvent && $scope.currentEvent.event === event.event){
+ if($scope.currentEvent && !rightAfterEnrollment && $scope.currentEvent.event === event.event){
//clicked on the same stage, do toggling
$scope.currentEvent = null;
$scope.currentElement = {id: '', saved: false};
=== 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 2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2014-10-22 14:22:06 +0000
@@ -33,7 +33,7 @@
<tr>
<td class="inline-block" ng-repeat="dhis2Event in dhis2Events | orderBy:'sortingDate':reverse">
<!--<span class="block align-center">{{dhis2Event.eventOrgUnitName}}</span> -->
- <span class="stage-container" ng-class='getEventStyle(dhis2Event, false)' ng-click="showDataEntry(dhis2Event)">
+ <span class="stage-container" ng-class='getEventStyle(dhis2Event, false)' ng-click="showDataEntry(dhis2Event, false)">
{{dhis2Event.name}}<br/>
{{dhis2Event.sortingDate}}
</span>
=== 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 2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js 2014-10-22 14:22:06 +0000
@@ -42,22 +42,12 @@
if($scope.selectedProgram){
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.attributesLighter = [];
- $scope.attributes = [];
- angular.forEach(atts, function(att){
- $scope.attributesLighter.push({id: att.id, name: att.name, type: att.valueType, displayInListNoProgram: att.displayInListNoProgram});
- $scope.attributes[att.id] = att;
- });
+ $scope.attributes = atts;
});
}
else{
AttributesFactory.getWithoutProgram().then(function(atts){
- $scope.attributesLighter = [];
- $scope.attributes = [];
- angular.forEach(atts, function(att){
- $scope.attributesLighter.push({id: att.id, name: att.name, type: att.valueType, displayInListNoProgram: att.displayInListNoProgram});
- $scope.attributes[att.id] = att;
- });
+ $scope.attributes = atts;
});
}
};
@@ -82,10 +72,17 @@
//registration form comes empty, in this case enforce at least one value
$scope.valueExists = false;
var registrationAttributes = [];
- angular.forEach($scope.attributesLighter, function(attribute){
- if(!angular.isUndefined(attribute.value)){
- var att = {attribute: attribute.id, value: attribute.value};
- registrationAttributes.push(att);
+ angular.forEach($scope.attributes, function(attribute){
+ var val = attribute.value;
+ if(!angular.isUndefined(val)){
+
+ if(attribute.valueType === 'date'){
+ val = DateUtils.formatFromUserToApi(val);
+ }
+ if(attribute.valueType === 'optionSet' && $scope.optionSets.optionCodesByName[ '"' + val + '"']){
+ val = $scope.optionSets.optionCodesByName[ '"' + val + '"'];
+ }
+ registrationAttributes.push({attribute: attribute.id, value: val});
$scope.valueExists = true;
}
});
@@ -98,7 +95,6 @@
//prepare tei model and do registration
$scope.tei = {trackedEntity: selectedTrackedEntity, orgUnit: $scope.selectedOrgUnit.id, attributes: registrationAttributes };
var teiId = '';
-
TEIService.register($scope.tei).then(function(tei){
if(tei.status === 'SUCCESS'){
@@ -112,7 +108,7 @@
program: $scope.selectedProgram.id,
status: 'ACTIVE',
dateOfEnrollment: DateUtils.formatFromUserToApi($scope.enrollment.dateOfEnrollment),
- dateOfIncident: $scope.enrollment.dateOfIncident == '' ? DateUtils.formatFromUserToApi($scope.enrollment.dateOfEnrollment) : DateUtils.formatFromUserToApi($scope.enrollment.dateOfIncident)
+ dateOfIncident: $scope.enrollment.dateOfIncident === '' ? DateUtils.formatFromUserToApi($scope.enrollment.dateOfEnrollment) : DateUtils.formatFromUserToApi($scope.enrollment.dateOfIncident)
};
EnrollmentService.enroll(enrollment).then(function(data){
if(data.status !== 'SUCCESS'){
@@ -143,7 +139,7 @@
$timeout(function() {
//reset form
- angular.forEach($scope.attributesLighter, function(attribute){
+ angular.forEach($scope.attributes, function(attribute){
delete attribute.value;
});
@@ -201,7 +197,6 @@
});
if(dhis2Events.events.length > 0){
DHIS2EventFactory.create(dhis2Events).then(function(data){
-
});
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html 2014-10-13 15:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html 2014-10-22 14:22:06 +0000
@@ -19,13 +19,13 @@
<h3>{{'profile' | translate}}</h3>
<table class="table-borderless table-striped">
- <tr ng-repeat="attribute in attributesLighter">
+ <tr ng-repeat="attribute in attributes">
<td>
{{attribute.name}}
</td>
<td>
<ng-form name="innerForm">
- <div ng-switch="attribute.type">
+ <div ng-switch="attribute.valueType">
<div ng-switch-when="date">
<input type="text" placeholder="{{dhis2CalendarFormat.keyDateFormat}}" name="foo" class="form-control" d2-date ng-model="attribute.value" ng-required="attribute.mandatory" />
<span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
@@ -48,21 +48,22 @@
name="foo"
class="form-control"
ng-model="attribute.value"
- typeahead="option.code as option.name for option in attributes[attribute.id].optionSet.options | filter:$viewValue | limitTo:20"
+ typeahead="option.name as option.name for option in optionSets.optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:20"
typeahead-open-on-focus
ng-required="attribute.mandatory"/>
</div>
<div ng-if="selectedProgram">
- <div ng-if="!selectedProgram.dataEntryMethod || attribute.optionSet.options.length >= 7">
+ <div ng-if="!selectedProgram.dataEntryMethod || optionSets.optionSets[attribute.optionSet.id].options.length >= 7">
<input type="text"
name="foo"
class="form-control"
ng-model="attribute.value"
- typeahead="option.code as option.name for option in attributes[attribute.id].optionSet.options | filter:$viewValue | limitTo:20"
+ typeahead="option.name as option.name for option in optionSets.optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:20"
typeahead-open-on-focus
+ typeahead-editable=false
ng-required="attribute.mandatory"/>
</div>
- <div ng-if="selectedProgram.dataEntryMethod && attribute.optionSet.options.length < 7">
+ <div ng-if="selectedProgram.dataEntryMethod && optionSets.optionSet[attribute.optionSet.id].options.length < 7">
<label>
<input type="radio"
name={{attribute.id}}
@@ -70,13 +71,13 @@
ng-model="attribute.value"
value=""> {{'no_value' | translate}}<br>
</label><br>
- <span ng-repeat="option in attribute.optionSet.options">
+ <span ng-repeat="option in optionSets.optionSets[attribute.optionSet.id].options">
<label>
<input type="radio"
name={{attribute.id}}
ng-required="attribute.mandatory"
ng-model="attribute.value"
- value={{option.code}}> {{option.name}}
+ value={{option.name}}> {{option.name}}
</label><br>
</span>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2014-10-13 14:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2014-10-22 14:22:06 +0000
@@ -245,7 +245,7 @@
}
//process tei grid
- $scope.trackedEntityList = TEIGridService.format(data,false);
+ $scope.trackedEntityList = TEIGridService.format(data,false, null);
$scope.showTrackedEntityDiv = true;
$scope.teiFetched = true;
});
@@ -459,7 +459,7 @@
program: $scope.selectedProgramForRelative.id,
status: 'ACTIVE',
dateOfEnrollment: DateUtils.formatFromUserToApi($scope.enrollment.enrollmentDate),
- dateOfIncident: $scope.enrollment.incidentDate == '' ? DateUtils.formatFromUserToApi($scope.enrollment.enrollmentDate) : DateUtils.formatFromUserToApi($scope.enrollment.incidentDate)
+ dateOfIncident: $scope.enrollment.incidentDate === '' ? DateUtils.formatFromUserToApi($scope.enrollment.enrollmentDate) : DateUtils.formatFromUserToApi($scope.enrollment.incidentDate)
};
EnrollmentService.enroll(enrollment).then(function(data){
if(data.status !== 'SUCCESS'){
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2014-10-13 14:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2014-10-22 14:22:06 +0000
@@ -82,7 +82,7 @@
false).then(function(data){
//process tei grid
- var teis = TEIGridService.format(data,true);
+ var teis = TEIGridService.format(data,true, null);
$scope.teiList = [];
DHIS2EventFactory.getByOrgUnitAndProgram($scope.selectedOrgUnit.id,
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-10-13 14:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-10-22 14:22:06 +0000
@@ -11,6 +11,7 @@
Paginator,
TranslationService,
storage,
+ OptionSetFactory,
OperatorFactory,
ProgramFactory,
AttributesFactory,
@@ -38,7 +39,8 @@
$scope.boolOperators = OperatorFactory.boolOperators;
$scope.enrollment = {programStartDate: '', programEndDate: '', operator: $scope.defaultOperators[0]};
$scope.searchState = true;
- $scope.searchMode = { listAll: 'LIST_ALL', freeText: 'FREE_TEXT', attributeBased: 'ATTRIBUTE_BASED' };
+ $scope.searchMode = { listAll: 'LIST_ALL', freeText: 'FREE_TEXT', attributeBased: 'ATTRIBUTE_BASED' };
+ $scope.optionSets = null;
//Registration
$scope.showRegistrationDiv = false;
@@ -58,6 +60,20 @@
//apply translation - by now user's profile is fetched from server.
TranslationService.translate();
+ if(!$scope.optionSets){
+ $scope.optionSets = {optionSets: [], optionNamesByCode: new Object(), optionCodesByName: new Object()};
+ OptionSetFactory.getAll().then(function(optionSets){
+ angular.forEach(optionSets, function(optionSet){
+ angular.forEach(optionSet.options, function(option){
+ if(option.name && option.code){
+ $scope.optionSets.optionNamesByCode[ '"' + option.code + '"'] = option.name;
+ $scope.optionSets.optionCodesByName[ '"' + option.name + '"'] = option.code;
+ }
+ });
+ $scope.optionSets.optionSets[optionSet.id] = optionSet;
+ });
+ });
+ }
$scope.loadPrograms($scope.selectedOrgUnit);
}
});
@@ -262,7 +278,7 @@
}
//process tei grid
- $scope.trackedEntityList = TEIGridService.format(data,false);
+ $scope.trackedEntityList = TEIGridService.format(data,false, $scope.optionSets.optionNamesByCode);
$scope.showTrackedEntityDiv = true;
$scope.teiFetched = true;
$scope.doSearch = true;
=== 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 2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-10-22 14:22:06 +0000
@@ -1132,10 +1132,10 @@
})
-.service('TEIGridService', function(OrgUnitService, DateUtils, $translate){
+.service('TEIGridService', function(OrgUnitService, DateUtils, $translate, AttributesFactory){
return {
- format: function(grid, map){
+ format: function(grid, map, optionNamesByCode){
if(!grid || !grid.rows){
return;
}
@@ -1148,43 +1148,61 @@
}
var entityList = [];
-
- OrgUnitService.open().then(function(){
-
- angular.forEach(grid.rows, function(row){
- var entity = {};
- var isEmpty = true;
-
- entity.id = row[0];
- var rDate = row[1];
- rDate = DateUtils.format(rDate);
- entity.created = rDate;
- entity.orgUnit = row[3];
- entity.type = row[4];
-
- OrgUnitService.get(row[3]).then(function(ou){
- if(ou){
- entity.orgUnitName = ou.n;
- }
- });
-
- for(var i=5; i<row.length; i++){
- if(row[i] && row[i] !== ''){
- isEmpty = false;
- entity[grid.headers[i].name] = row[i];
- }
- }
-
- if(!isEmpty){
- if(map){
- entityList[entity.id] = entity;
- }
- else{
- entityList.push(entity);
- }
- }
- });
- });
+
+ AttributesFactory.getAll().then(function(atts){
+
+ var attributes = [];
+ angular.forEach(atts, function(att){
+ attributes[att.id] = att;
+ });
+
+ OrgUnitService.open().then(function(){
+
+ angular.forEach(grid.rows, function(row){
+ var entity = {};
+ var isEmpty = true;
+
+ entity.id = row[0];
+ entity.created = DateUtils.formatFromApiToUser( row[1] );
+ entity.orgUnit = row[3];
+ entity.type = row[4];
+
+ OrgUnitService.get(row[3]).then(function(ou){
+ if(ou){
+ entity.orgUnitName = ou.n;
+ }
+ });
+
+ for(var i=5; i<row.length; i++){
+ if(row[i] && row[i] !== ''){
+ isEmpty = false;
+ if(attributes[grid.headers[i].name] &&
+ attributes[grid.headers[i].name].valueType === 'optionSet' &&
+ optionNamesByCode &&
+ optionNamesByCode[ '"' + row[i] + '"']){
+
+ entity[grid.headers[i].name] = optionNamesByCode[ '"' + row[i] + '"'];
+ }
+ if(attributes[grid.headers[i].name] && attributes[grid.headers[i].name].valueType === 'date'){
+ entity[grid.headers[i].name] = DateUtils.formatFromApiToUser( row[i] );
+ }
+ else{
+ entity[grid.headers[i].name] = row[i];
+ }
+ }
+ }
+
+ if(!isEmpty){
+ if(map){
+ entityList[entity.id] = entity;
+ }
+ else{
+ entityList.push(entity);
+ }
+ }
+ });
+ });
+ });
return {headers: attributes, rows: entityList, pager: grid.metaData.pager};
},
generateGridColumns: function(attributes, ouMode){
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2014-10-22 14:22:06 +0000
@@ -474,7 +474,7 @@
return $.ajax( {
url: '../api/programStages.json',
type: 'GET',
- data: 'filter=id:eq:' + id +'&fields=id,name,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,reportDateDescription,minDaysFromStart,standardInterval,repeatable,programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,name,formName,type,optionSet[id]]]'
+ data: 'filter=id:eq:' + id +'&fields=id,name,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,openAfterEnrollment,reportDateToUse,reportDateDescription,minDaysFromStart,standardInterval,repeatable,programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,name,formName,type,optionSet[id]]]'
}).done( function( response ){
_.each( _.values( response.programStages ), function( programStage ) {
dhis2.tc.store.set( 'programStages', programStage );