dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36154
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18515: some cleanup
------------------------------------------------------------
revno: 18515
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-06 17:27:25 +0100
message:
some cleanup
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/scripts/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/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-03-06 14:43:54 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-03-06 16:27:25 +0000
@@ -142,7 +142,7 @@
//Fetch the selected entity
TEIService.get($scope.selectedTeiId, $scope.optionSets, $scope.attributesById).then(function(response){
- $scope.selectedTei = response.data;
+ $scope.selectedTei = response;
//get the entity type
TEService.get($scope.selectedTei.trackedEntity).then(function(te){
=== 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-06 16:14:10 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-03-06 16:27:25 +0000
@@ -510,35 +510,21 @@
})
/* Service for getting tracked entity instances */
-.factory('TEIService', function($http, $q, AttributesFactory, OptionSetService, CurrentSelection, DateUtils) {
+.factory('TEIService', function($http, $q, AttributesFactory) {
- return {
- convertFromApiToUser: function(promise, optionSets, attsById){
- promise.then(function(response){
+ return {
+ get: function(entityUid, optionSets, attributesById){
+ var promise = $http.get( '../api/trackedEntityInstances/' + entityUid + '.json').then(function(response){
var tei = response.data;
angular.forEach(tei.attributes, function(att){
- if(attsById[att.attribute]){
- att.displayName = attsById[att.attribute].name;
+ if(attributesById[att.attribute]){
+ att.displayName = attributesById[att.attribute].name;
}
- att.value = AttributesFactory.formatAttributeValue(att, attsById, optionSets, 'USER');
- });
+ att.value = AttributesFactory.formatAttributeValue(att, attributesById, optionSets, 'USER');
+ });
return tei;
- });
- return promise;
- },
- convertFromUserToApi: function(_tei, optionSets, attsById){
- var tei = angular.copy(_tei);
- angular.forEach(tei.attributes, function(att){
- att.value = AttributesFactory.formatAttributeValue(att, attsById, optionSets, 'API');
- });
- return tei;
- },
- get: function(entityUid, optionSets, attributesById){
- var promise = $http.get( '../api/trackedEntityInstances/' + entityUid );
+ });
- this.convertFromApiToUser(promise, optionSets, attributesById).then(function(response){
- return response.data;
- });
return promise;
},
search: function(ouId, ouMode, queryUrl, programUrl, attributeUrl, pager, paging) {
@@ -571,8 +557,11 @@
});
return promise;
},
- update: function(tei, optionSets, attributesById){
- var formattedTei = this.convertFromUserToApi(tei,optionSets, attributesById);
+ update: function(tei, optionSets, attributesById){
+ var formattedTei = angular.copy(tei);
+ angular.forEach(formattedTei.attributes, function(att){
+ att.value = AttributesFactory.formatAttributeValue(att, attributesById, optionSets, 'API');
+ });
var promise = $http.put( '../api/trackedEntityInstances/' + formattedTei.trackedEntityInstance , formattedTei ).then(function(response){
return response.data;
});
@@ -580,7 +569,11 @@
return promise;
},
register: function(tei, optionSets, attributesById){
- var formattedTei = this.convertFromUserToApi(tei,optionSets, attributesById);
+ var formattedTei = angular.copy(tei);
+ angular.forEach(formattedTei.attributes, function(att){
+ att.value = AttributesFactory.formatAttributeValue(att, attributesById, optionSets, 'API');
+ });
+
var promise = $http.put( '../api/trackedEntityInstances' , formattedTei ).then(function(response){
return response.data;
});