dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28661
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14331: tracked entity instance dashboard - WIP
------------------------------------------------------------
revno: 14331
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2014-03-21 08:58:52 +0100
message:
tracked entity instance dashboard - WIP
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html
--
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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-03-17 15:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-03-21 07:58:52 +0000
@@ -28,6 +28,7 @@
"remove": "Remove",
"entity": "Entity",
"add_new": "Add new",
+ "new_event": "New event",
"close_search": "Close search",
"search_attributes": "Search attributes",
"search_for_dashboard": "Search for dashboard items",
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-03-19 17:01:46 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-03-21 07:58:52 +0000
@@ -12,7 +12,7 @@
SelectedEntity,
storage,
AttributesFactory,
- TrackedEntityService) {
+ TrackedEntityInstanceService) {
//Selection
$scope.selectedOrgUnit = '';
@@ -94,14 +94,14 @@
if( angular.isObject($scope.selectedProgram)){
//Load entities for the selected program and orgunit
- TrackedEntityService.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedProgram.id).then(function(data){
+ TrackedEntityInstanceService.getByOrgUnitAndProgram($scope.selectedOrgUnit.id, $scope.selectedProgram.id).then(function(data){
$scope.trackedEntityList = data;
});
}
else{
//Load entities for the selected orgunit
- TrackedEntityService.getByOrgUnit($scope.selectedOrgUnit.id).then(function(data){
+ TrackedEntityInstanceService.getByOrgUnit($scope.selectedOrgUnit.id).then(function(data){
$scope.trackedEntityList = data;
});
}
@@ -171,7 +171,7 @@
$scope,
$location,
storage,
- TrackedEntityService,
+ TrackedEntityInstanceService,
TranslationService) {
//do translation of the dashboard page
@@ -195,10 +195,10 @@
if( $scope.selectedEntityId ){
//Fetch the selected entity
- TrackedEntityService.get($scope.selectedEntityId).then(function(data){
+ TrackedEntityInstanceService.get($scope.selectedEntityId).then(function(data){
$scope.selectedEntity = data;
- //broadcast for all the dashboard item
+ //broadcast selections for dashboard controllers
$rootScope.$broadcast('selectedItems', {selectedEntity: $scope.selectedEntity,
selectedProgramId: $scope.selectedProgramId,
selectedOrgUnitId: $scope.selectedOrgUnit.id});
@@ -242,7 +242,8 @@
//Controller for the enrollment section
.controller('EnrollmentController',
- function($scope,
+ function($rootScope,
+ $scope,
storage,
EnrollmentService,
TranslationService) {
@@ -251,37 +252,133 @@
$scope.enrollment = {title: 'enrollment', isOpen: true};
+ //programs for enrollment
+ $scope.enrollments = [];
+ $scope.programs = [];
+ var programs = storage.get('PROGRAMS');
+
//listen for the selected items
- $scope.$on('selectedItems', function(event, args) {
+ $scope.$on('selectedItems', function(event, args) {
+
$scope.selectedEntity = args.selectedEntity;
- $scope.selectedProgramId = args.selectedProgramId;
- $scope.selectedOrgUnitId = args.selectedOrgUnitId;
-
- //programs for enrollment
- $scope.programs = [];
- var programs = storage.get('PROGRAMS');
- if( programs ){
-
- for(var i=0; i<programs.length; i++){
-
- var program = storage.get(programs[i].id);
-
- if($scope.selectedProgramId == program.id){
- $scope.selectedProgram = program;
- }
-
- if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnitId) &&
- program.trackedEntity.id == $scope.selectedEntity.trackedEntity){
-
- $scope.programs.push(program);
- }
+ $scope.selectedProgramId = args.selectedProgramId;
+ $scope.selectedOrgUnitId = args.selectedOrgUnitId;
+
+ for(var i=0; i<programs.length; i++){
+ var program = storage.get(programs[i].id);
+ if($scope.selectedProgramId == program.id){
+ $scope.selectedProgram = program;
+ }
+
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnitId) &&
+ program.trackedEntity.id == $scope.selectedEntity.trackedEntity){
+ $scope.programs.push(program);
}
}
EnrollmentService.get($scope.selectedEntity.trackedEntityInstance).then(function(data){
- console.log('enrollment: ', data);
- });
- });
+ $scope.enrollments = data.enrollmentList;
+
+ console.log('the enrollments are: ', $scope.enrollments);
+
+ if($scope.enrollments && $scope.enrollments.length == 1){
+
+ $scope.selectedProgramId = $scope.enrollments[0].program;
+
+ angular.forEach($scope.programs, function(program){
+ if(program.id == $scope.selectedProgramId ){
+ $scope.selectedProgram = program;
+ }
+ });
+
+ $scope.loadEvents($scope.selectedProgramId);
+ }
+ });
+ });
+
+ $scope.loadEvents = function(prId) {
+
+ var isEnrolled = false;
+ angular.forEach($scope.enrollments, function(enrollment){
+ if(enrollment.program == prId ){
+ isEnrolled = true;
+ }
+ });
+
+ if(isEnrolled){
+ console.log('enrolled');
+
+ //broadcast for data entry
+ $rootScope.$broadcast('dataentry', {selectedEntity: $scope.selectedEntity,
+ selectedProgramId: prId,
+ selectedOrgUnitId: $scope.selectedOrgUnitId});
+ }
+
+ };
+})
+
+//Controller for the data entry section
+.controller('DataEntryController',
+ function($scope,
+ $filter,
+ orderByFilter,
+ storage,
+ DHIS2EventFactory,
+ TranslationService) {
+
+ TranslationService.translate();
+
+ $scope.dataEntry = {title: 'dataentry', isOpen: true};
+
+ $scope.attributes = storage.get('ATTRIBUTES');
+
+ //listen for the selected items
+ $scope.$on('dataentry', function(event, args) {
+
+ $scope.dhis2Events = '';
+ $scope.programStages = {};
+
+ $scope.selectedEntity = args.selectedEntity;
+ $scope.selectedProgramId = args.selectedProgramId;
+ $scope.selectedOrgUnitId = args.selectedOrgUnitId;
+
+ if($scope.selectedOrgUnitId && $scope.selectedProgramId && $scope.selectedEntity ){
+
+ //get selected program
+ var program = storage.get($scope.selectedProgramId);
+
+ angular.forEach(program.programStages, function(prSt){
+ $scope.programStages[prSt.id] = prSt;
+ });
+
+ DHIS2EventFactory.getByEntity($scope.selectedEntity.trackedEntityInstance, $scope.selectedOrgUnitId, $scope.selectedProgramId).then(function(data){
+ $scope.dhis2Events = data;
+
+ if($scope.dhis2Events){
+
+ angular.forEach($scope.dhis2Events, function(dhis2Event){
+ dhis2Event.eventDate = moment(dhis2Event.eventDate, 'YYYY-MM-DD')._d
+ dhis2Event.eventDate = Date.parse(dhis2Event.eventDate);
+ dhis2Event.eventDate = $filter('date')(dhis2Event.eventDate, 'yyyy-MM-dd');
+ });
+
+ $scope.dhis2Events = orderByFilter($scope.dhis2Events, '-eventDate');
+ $scope.dhis2Events.reverse();
+ }
+
+ console.log('existing events are: ', $scope.dhis2Events);
+ });
+ }
+ });
+
+ $scope.createNewEvent = function(){
+ console.log('need to create new event');
+ };
+
+ $scope.showDataEntry = function(){
+ console.log('need to show data entry');
+ };
+
})
//Controller for the notes section
@@ -298,20 +395,6 @@
})
-//Controller for the data entry section
-.controller('DataEntryController',
- function($scope,
- storage,
- TranslationService) {
-
- TranslationService.translate();
-
- $scope.dataEntry = {title: 'dataentry', isOpen: true};
-
- $scope.attributes = storage.get('ATTRIBUTES');
-
-})
-
//Controller for the header section
.controller('HeaderController',
function($scope,
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-03-19 16:58:56 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-03-21 07:58:52 +0000
@@ -104,7 +104,7 @@
})
/* Service for getting tracked entity instances */
-.factory('TrackedEntityService', function($http, AttributesFactory) {
+.factory('TrackedEntityInstanceService', function($http, AttributesFactory) {
var promise;
return {
@@ -118,10 +118,10 @@
getByOrgUnitAndProgram: function(orgUnitUid, programUid) {
- var attributes = AttributesFactory.convertListingForToQuery();
+ //var attributes = AttributesFactory.convertListingForToQuery();
var url = '../api/trackedEntityInstances.json?ou=' + orgUnitUid + '&program=' + programUid;
- promise = $http.get( url + attributes ).then(function(response){
+ promise = $http.get( url ).then(function(response){
return entityFormatter(response.data);
});
@@ -129,10 +129,10 @@
},
getByOrgUnit: function(orgUnitUid) {
- var attributes = AttributesFactory.convertListingForToQuery();
+ //var attributes = AttributesFactory.convertListingForToQuery();
var url = '../api/trackedEntityInstances.json?ou=' + orgUnitUid;
- promise = $http.get( url + attributes ).then(function(response){
+ promise = $http.get( url ).then(function(response){
return entityFormatter(response.data);
});
@@ -183,9 +183,9 @@
return {
- getByPerson: function(person, orgUnit, program){
- var promise = $http.get( '../api/events.json?' + 'person=' + person + '&orgUnit=' + orgUnit + '&program=' + program + '&paging=false').then(function(response){
- return response.data.eventList;
+ getByEntity: function(entity, orgUnit, program){
+ var promise = $http.get( '../api/events.json?' + 'trackedEntityInstance=' + entity + '&orgUnit=' + orgUnit + '&program=' + program + '&paging=false').then(function(response){
+ return response.data.events;
});
return promise;
},
@@ -194,7 +194,7 @@
var promise = $http.get( '../api/events.json?' + 'orgUnit=' + orgUnit + '&programStage=' + programStage + '&paging=false')
.then(function(response){
- return response.data.eventList;
+ return response.data.events;
}, function(){
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-03-17 15:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-03-21 07:58:52 +0000
@@ -417,6 +417,10 @@
// program-stage-instances
// -------------------------------------------------------------- */
+.arrow-container {
+ font-size: 25px;
+ width: 10px;
+}
.stage-container
{
width:100%;
@@ -487,6 +491,18 @@
border: 5px solid;
}
+input.entity-instance-object[type="button"]
+{
+ width: 130px;
+ height: 60px;
+ border-color: #bbbbbb;
+ background-color: #ddd;
+ cursor: pointer;
+ border: 1px solid #aaa;
+ margin: 5px;
+ border-radius: 2px;
+}
+
input.patient-object[type="button"]
{
width: 130px;
@@ -1335,19 +1351,19 @@
}
.panel-body {
- padding: 15px
-}
-.panel-body:before, .panel-body:after {
- display: table;
- content: " "
-}
-.panel-body:after {
- clear: both
-}
-.panel-body:before, .panel-body:after {
- display: table;
- content: " "
-}
-.panel-body:after {
- clear: both
+ padding: 15px
+}
+.panel-body:before, .panel-body:after {
+ display: table;
+ content: " "
+}
+.panel-body:after {
+ clear: both
+}
+.panel-body:before, .panel-body:after {
+ display: table;
+ content: " "
+}
+.panel-body:after {
+ clear: both
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html 2014-03-19 16:58:56 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html 2014-03-21 07:58:52 +0000
@@ -2,7 +2,36 @@
<accordion-group is-open="{{dataEntry.isOpen}}">
<accordion-heading>
<span class="list-title">{{dataEntry.title| translate}}</span>
- </accordion-heading>
- This is data entry.
+ </accordion-heading>
+ <div ng-show="dhis2Events">
+ <table style="width: 100%;">
+ <tbody>
+ <tr>
+ <td>
+ <div class="stage-flow">
+ <table class="stage-flow">
+ <tbody>
+ <tr>
+ <td ng-repeat="dhis2Event in dhis2Events">
+ <span class="arrow-container">→</span><input type="button" class="stage-object" value="{{programStages[dhis2Event.programStage].name}}" style="border-color: rgb(152, 142, 128);" ng-click="showDataEntry()">
+ </td>
+
+ </tr>
+ </tbody>
+
+ </table>
+ </div>
+
+ </td>
+ <td class="right">
+ <input type="button" class="entity-instance-object" value="{{'new_event' | translate}}" ng-click="createNewEvent()">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <hr>
+
+ hi there...
+ </div>
</accordion-group>
</accordion>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html 2014-03-19 16:58:56 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html 2014-03-21 07:58:52 +0000
@@ -7,9 +7,9 @@
<div class="list-element">
{{'program'| translate}}
<span class="right">
- <select ng-model="selectedProgram"
+ <select ng-model="selectedProgram"
ng-options="program as program.name for program in programs | orderBy: 'name'"
- ng-change="showEnrollment()">
+ ng-change="loadEvents(selectedProgram.id)">
<option value="">{{'please_select'| translate}}</option>
</select>
</span>