dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32632
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16635: tracker capture - scheduling and messaging, WIP
------------------------------------------------------------
revno: 16635
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-05 11:21:39 +0200
message:
tracker capture - scheduling and messaging, WIP
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
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/styles/style.css
--
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/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2014-07-23 12:21:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2014-09-05 09:21:39 +0000
@@ -30,7 +30,8 @@
//display only those attributes that belong the selected program
//if no program, display attributesInNoProgram
TEIService.processAttributes($scope.selectedTei, $scope.selectedProgram, $scope.selectedEnrollment).then(function(tei){
- $scope.selectedTei = tei;
+ $scope.selectedTei = tei;
+ console.log('The tei is: ', $scope.selectedTei);
});
});
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js 2014-09-01 15:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js 2014-09-05 09:21:39 +0000
@@ -4,9 +4,8 @@
DateUtils,
EventUtils,
DHIS2EventFactory,
- EnrollmentService,
+ TEIService,
CurrentSelection,
- orderByFilter,
TranslationService) {
TranslationService.translate();
@@ -18,65 +17,106 @@
}
var today = DateUtils.format(moment());
+ $scope.showSchedulingDiv = false;
+ $scope.schedulingPossible = false;
+ $scope.showMessagingDiv = false;
+ $scope.messagingPossible = false;
+ $scope.showEventSchedulingDiv = false;
$scope.$on('dashboardWidgets', function(event, args) {
var selections = CurrentSelection.get();
- $scope.selectedOrgUnit = storage.get('SELECTED_OU');
- $scope.selectedEntity = selections.tei;
+ $scope.selectedOrgUnit = storage.get('SELECTED_OU');
+ $scope.selectedTei = angular.copy(selections.tei);
$scope.selectedProgram = selections.pr;
$scope.selectedEnrollment = selections.enrollment;
$scope.selectedProgramWithStage = [];
+ $scope.dhis2Events = [];
if($scope.selectedOrgUnit &&
$scope.selectedProgram &&
- $scope.selectedEntity &&
- $scope.selectedEnrollment){
+ $scope.selectedTei &&
+ $scope.selectedEnrollment){
+ //check if the selected TEI has any of the contact attributes
+ //that can be used for communication
+ TEIService.processAttributes($scope.selectedTei, $scope.selectedProgram, $scope.selectedEnrollment).then(function(tei){
+ $scope.selectedTei = tei;
+ var continueLoop = true;
+ for(var i=0; i<$scope.selectedTei.attributes.length && continueLoop; i++){
+ if( ($scope.selectedTei.attributes[i].type === 'phoneNumber' && $scope.selectedTei.attributes[i].show) ||
+ ($scope.selectedTei.attributes[i].type === 'email' && $scope.selectedTei.attributes[i].show) ){
+ $scope.messagingPossible = true;
+ continueLoop = false;
+ }
+ }
+ });
+
angular.forEach($scope.selectedProgram.programStages, function(stage){
$scope.selectedProgramWithStage[stage.id] = stage;
});
-
- /*EnrollmentService.get(selections.enrollment.enrollment).then(function(data){
- $scope.selectedEnrollment = data;
- if(!angular.isUndefined( $scope.selectedEnrollment.notes)){
- $scope.selectedEnrollment.notes = orderByFilter($scope.selectedEnrollment.notes, '-storedDate');
- angular.forEach($scope.selectedEnrollment.notes, function(note){
- note.storedDate = moment(note.storedDate).format('YYYY-MM-DD @ hh:mm A');
- });
- }
- });*/
- $scope.dhis2Events = '';
- DHIS2EventFactory.getEventsByStatus($scope.selectedEntity.trackedEntityInstance, $scope.selectedOrgUnit.id, $scope.selectedProgram.id, 'ACTIVE').then(function(data){
- $scope.dhis2Events = data;
- if(angular.isObject($scope.dhis2Events)){
- angular.forEach($scope.dhis2Events, function(dhis2Event){
-
- if(dhis2Event.enrollment === $scope.selectedEnrollment.enrollment){
- var eventStage = $scope.selectedProgramWithStage[dhis2Event.programStage];
- if(angular.isObject(eventStage)){
-
- dhis2Event.name = eventStage.name;
- dhis2Event.reportDateDescription = eventStage.reportDateDescription;
- dhis2Event.dueDate = DateUtils.format(dhis2Event.dueDate);
-
- if(dhis2Event.eventDate){
- dhis2Event.eventDate = DateUtils.format(dhis2Event.eventDate);
- dhis2Event.sortingDate = DateUtils.format(dhis2Event.eventDate);
- }
- else{
- dhis2Event.sortingDate = dhis2Event.dueDate;
- }
-
- dhis2Event.statusColor = EventUtils.getEventStatusColor(dhis2Event);
- dhis2Event = EventUtils.setEventOrgUnitName(dhis2Event);
- }
- }
- });
- }
+
+ DHIS2EventFactory.getEventsByStatus($scope.selectedTei.trackedEntityInstance, $scope.selectedOrgUnit.id, $scope.selectedProgram.id, 'ACTIVE').then(function(eventList){
+ angular.forEach(eventList, function(dhis2Event){
+ if( dhis2Event.enrollment === $scope.selectedEnrollment.enrollment &&
+ dhis2Event.status === 'SCHEDULE' &&
+ angular.isUndefined(dhis2Event.eventDate)){
+ var eventStage = $scope.selectedProgramWithStage[dhis2Event.programStage];
+ if(angular.isObject(eventStage)){
+
+ $scope.dhis2Events.push(dhis2Event);
+ dhis2Event.name = eventStage.name;
+ dhis2Event.reportDateDescription = eventStage.reportDateDescription;
+ dhis2Event.dueDate = DateUtils.format(dhis2Event.dueDate);
+
+ if(dhis2Event.eventDate){
+ dhis2Event.eventDate = DateUtils.format(dhis2Event.eventDate);
+ dhis2Event.sortingDate = DateUtils.format(dhis2Event.eventDate);
+ }
+ else{
+ dhis2Event.sortingDate = dhis2Event.dueDate;
+ }
+ dhis2Event.statusColor = EventUtils.getEventStatusColor(dhis2Event);
+ dhis2Event = EventUtils.setEventOrgUnitName(dhis2Event);
+ }
+ }
+ });
+ $scope.schedulingPossible = $scope.dhis2Events.length > 0 ? true : false;
});
}
});
+ $scope.showScheduling = function(){
+ $scope.showSchedulingDiv = !$scope.showSchedulingDiv;
+ //$scope.showMessagingDiv = !$scope.showMessagingDiv;
+ };
+
+ $scope.showMessaging = function(){
+ //$scope.showSchedulingDiv = !$scope.showSchedulingDiv;
+ $scope.showMessagingDiv = !$scope.showMessagingDiv;
+ };
+
+ $scope.showSchedulingDetails = function(dhis2Event){
+
+ if( !$scope.currentEvent ){
+ $scope.currentEvent = dhis2Event;
+ $scope.showEventSchedulingDiv = !$scope.showEventSchedulingDiv;
+ }
+ else{
+ if( dhis2Event.event === $scope.currentEvent.event ){
+ $scope.showEventSchedulingDiv = !$scope.showEventSchedulingDiv;
+ $scope.currentEvent = null;
+ }
+ else{
+ $scope.currentEvent = dhis2Event;
+ }
+ }
+ };
+
+ $scope.cancelScheduling = function(){
+ $scope.showEventSchedulingDiv = !$scope.showEventSchedulingDiv;
+ $scope.currentEvent = null;
+ };
+
$scope.saveDueDate = function(){
$scope.dueDateSaved = false;
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html 2014-09-01 15:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html 2014-09-05 09:21:39 +0000
@@ -1,6 +1,16 @@
-<div class="panel panel-default" ng-controller="SchedulingMessagingController">
+<div class="panel panel-default" ng-controller="SchedulingMessagingController" ng-show="schedulingPossible || messagingPossible">
<div class="panel-heading handle bold">
- {{schedulingMessagingWidget.title| translate}}
+ <span class="nav-pills" ng-if="schedulingPossible">
+ <a href ng-click="showScheduling()" title="{{'show_hide_scheduling'| translate}}">
+ <span class="bold" ng-class="{'text-primary': showSchedulingDiv}">{{'scheduling'| translate}}</span>
+ </a>
+ </span>
+ <span class="nav-pills" ng-if="messagingPossible">
+ <span ng-if="schedulingPossible">|</span> <a href ng-click="showMessaging()" title="{{'show_hide_messaging'| translate}}">
+ <span class="bold" ng-class="{'text-primary': showMessagingDiv}">{{'messaging'| translate}}</span>
+ </a>
+ </span>
+
<span class="pull-right">
<a class="small-horizonal-spacing" href ng-click="expandCollapse(schedulingMessagingWidget)">
<span ng-show="schedulingMessagingWidget.expand"><i class="fa fa-chevron-up" title="{{'collapse'| translate}}"></i></span>
@@ -8,8 +18,53 @@
</a>
<a class="small-horizonal-spacing" href ng-click="removeWidget(schedulingMessagingWidget)" title="{{'remove'| translate}}"><i class="fa fa-times-circle"></i></a>
</span>
- </div>
+ </div>
+
<div ng-show="schedulingMessagingWidget.expand" class="panel-body dashboard-element-container">
- <div ng-show="!selectedEnrollment" class="alert alert-warning">{{'not_yet_enrolled_scheduling'| translate}}</div>
+ <div ng-if="!selectedEnrollment" class="alert alert-warning">{{'not_yet_enrolled_scheduling'| translate}}</div>
+ <div class="remove-default-padding" ng-if="showSchedulingDiv && schedulingPossible">
+ <div ng-switch="dhis2Events.length">
+ <div ng-switch-when="0" class="alert alert-warning">
+ {{'no_event_to_schedule'| translate}}
+ </div>
+ <div ng-switch-default>
+ <table class="table table-striped dhis2-table-hover">
+ <tr>
+ <th>{{'event_name'| translate}}</th>
+ <th>{{'due_date'| translate}}</th>
+ </tr>
+ <tr ng-click="showSchedulingDetails(dhis2Event)" ng-repeat="dhis2Event in dhis2Events">
+ <td>{{dhis2Event.name}}</td>
+ <td>{{dhis2Event.dueDate}}</td>
+ </tr>
+ </table>
+ <div ng-if="showEventSchedulingDiv">
+ <pre>{{currentEvent}}</pre>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="remove-default-padding" ng-if="showMessagingDiv && messagingPossible">
+ <div ng-switch="dhis2Events.length">
+ <div ng-switch-when="0" class="alert alert-warning add-default-padding">
+ {{'no_event_to_schedule'| translate}}
+ </div>
+ <div ng-switch-default>
+ <table class="table table-striped dhis2-table-hover">
+ <tr>
+ <th>{{'event_name'| translate}}</th>
+ <th>{{'due_date'| translate}}</th>
+ </tr>
+ <tr ng-click="showSchedulingDetails(dhis2Event)" ng-repeat="dhis2Event in dhis2Events">
+ <td>{{dhis2Event.name}}</td>
+ <td>{{dhis2Event.dueDate}}</td>
+ </tr>
+ </table>
+ <div ng-if="showEventSchedulingDiv">
+ <pre>{{currentEvent}}</pre>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
</div>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-09-01 15:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-09-05 09:21:39 +0000
@@ -82,6 +82,7 @@
"date": "Date",
"_date": "date",
"add_new": "Add new",
+ "event_name": "Event name",
"new_event": "New event",
"create_new_event": "Create new event",
"create_new_event_repeatable": "Create new event from a repeatable stage",
@@ -161,13 +162,16 @@
"list_programs": "List programs",
"program_stage": "Program stage",
"due_date": "Due date",
- "scheduled_date": "Scheduled date",
+ "show_hide_scheduling": "Show/hide scheduling form",
+ "show_hide_messaging": "Show/hide messaging form",
+ "messaging": "Messaging",
"scheduling": "Scheduling",
"reschedule": "Reschedule",
"rescheduling": "Rescheduling",
"scheduling_messaging": "Scheduling and Messaging",
"not_yet_enrolled_scheduling": "Not yet enrolled. Scheduling not possible.",
"schedule_details": "Schedule details",
+ "no_event_to_schedule": "No event to schedule",
"enroll": "Enroll",
"new_enrollment": "New enrollment",
"start_date": "Start date",
=== 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-08-29 14:15:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-09-05 09:21:39 +0000
@@ -203,7 +203,7 @@
})
/* Service to deal with enrollment */
-.service('EnrollmentService', function($http, EventUtils, DHIS2EventFactory) {
+.service('EnrollmentService', function($http) {
return {
get: function( enrollmentUid ){
@@ -1163,7 +1163,7 @@
sortingDate: dueDate,
name: programStage.name,
reportDateDescription: programStage.reportDateDescription,
- status: 'ACTIVE'};
+ status: 'SCHEDULED'};
dummyEvent.statusColor = 'alert alert-info';//'stage-on-time';
if(moment(today).isAfter(dummyEvent.dueDate)){
dummyEvent.statusColor = 'alert alert-danger';//'stage-overdue';
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-09-01 13:04:19 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-09-05 09:21:39 +0000
@@ -475,6 +475,9 @@
margin: -15px !important;
}
+.add-default-padding {
+ margin: 15px !important;
+}
.add-default-top-margin {
margin-top: 15px !important;
}
@@ -777,6 +780,7 @@
background-color: #ebebeb;
cursor: pointer;
}
+
@media print {
#header, #leftBar, .not-printable {
display: none;