------------------------------------------------------------
revno: 15317
committer: Abyot Asalefew Gizaw aby...@gmail.com
branch nick: dhis2
timestamp: Tue 2014-05-20 17:56:10 +0200
message:
  more interaction in tei dashboard widgets such as editing, enrolling, event 
creation... - 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/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
  
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.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-05-19 11:33:07 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-05-20 15:56:10 +0000
@@ -26,7 +26,8 @@
     "next": "Next",
     "last": "Last",
     "dashboard": "Go to Dashboard",
-    "edit": "Edit Entity",
+    "edit": "Edit",
+    "edit_profile": "Edit profile",
     "association": "Manage Associations",
     "change_location": "Manage Location",
     "details_history": "Details/History",
@@ -35,6 +36,7 @@
     "add_new": "Add new",
     "new_event": "New event",
     "create_new_event": "Create new event",
+    "create_new_event_repeatable": "Create new event from a repeatable stage",
     "close_search": "Close search",
     "search_attributes": "Search attributes",
     "available_search_attributes": "Available search attributes",
@@ -78,6 +80,7 @@
     "registration_error": "Error in registration",
     "category": "Category",
     "entity_type": "Entity type",
+    "save": "Save",
     "save_and_add_new": "Save and add new",
     "save_and_go_back": "Save and go back",
     "save_and_continue": "Save and continue",

=== 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-05-20 13:24:54 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-05-20 15:56:10 +0000
@@ -507,6 +507,7 @@
     
     //attributes for profile    
     $scope.attributes = {};    
+    $scope.editProfile = false;    
     
     angular.forEach(storage.get('ATTRIBUTES'), function(attribute){
         $scope.attributes[attribute.id] = attribute;
@@ -522,7 +523,23 @@
                 $scope.trackedEntity = te;
             }
         }); 
+        
+        $scope.entityAttributes = angular.copy($scope.selectedEntity.attributes);
     });
+    
+    $scope.showEdit = function(){
+      $scope.editProfile = !$scope.editProfile; 
+    };
+    
+    $scope.save = function(){
+        
+        $scope.editProfile = !$scope.editProfile;
+    };
+    
+    $scope.cancel = function(){
+        $scope.selectedEntity.attributes = $scope.entityAttributes;  
+        $scope.editProfile = !$scope.editProfile;
+    };
 })
 
 //Controller for the enrollment section
@@ -540,6 +557,7 @@
     //programs for enrollment
     $scope.enrollments = [];
     $scope.programs = []; 
+    $scope.showEnrollmentDiv = false;
     
     $scope.selectedOrgUnit = storage.get('SELECTED_OU');
     
@@ -601,6 +619,10 @@
         }        
     };
     
+    $scope.showEnrollment = function(){        
+        console.log('Enrollment', $scope.selectedEntity, ' ', $scope.selectedProgram);
+    };
+    
     $scope.enroll = function(){        
         console.log('Enrollment', $scope.selectedEntity, ' ', $scope.selectedProgram);
     };
@@ -622,9 +644,14 @@
     
     //listen for the selected items
     $scope.$on('dataentry', function(event, args) {  
+        
+        var today = moment();
+        today = Date.parse(today);
+        today = $filter('date')(today, 'yyyy-MM-dd');
 
         $scope.currentEvent = null;
-        
+        $scope.allowEventCreation = false;
+        $scope.repeatableStages = [];        
         $scope.dhis2Events = [];       
     
         $scope.selectedEntity = args.selectedEntity;
@@ -642,7 +669,7 @@
                     
                     console.log('need to create new ones:  ', $scope.selectedEnrollment);
                     
-                    if($scope.selectedEnrollment.status == 'ACTIVE'){
+                    if($scope.selectedEnrollment.status === 'ACTIVE'){
                         //create events for the selected enrollment
                         var program = storage.get($scope.selectedProgramId);
                         var programStages = [];
@@ -650,43 +677,47 @@
                         angular.forEach(program.programStages, function(ps){  
                             ps = storage.get(ps.id);
                             programStages.push(ps);
+                            
+                            var eventDate = moment(moment().add('d', ps.minDaysFromStart), 'YYYY-MM-DD')._d;
+                            eventDate = Date.parse(eventDate);
+                            eventDate = $filter('date')(eventDate, 'yyyy-MM-dd');
                             var dhis2Event = {programStage: ps.id, 
                                               orgUnit: $scope.selectedOrgUnitId, 
-                                              eventDate: moment(),
+                                              eventDate: eventDate,
                                               name: ps.name,
                                               status: 'ACTIVE'};
                             
-                            var today = moment();                                       
-                            
-                            dhis2Event.statusColor = 'stage-on-time';
-                            
-                            if( moment().add('d', ps.minDaysFromStart).isBefore(today)){                                
-                                dhis2Event.statusColor = 'stage-overdue';
-                            }                            
-
-                            $scope.dhis2Events.push(dhis2Event);
+                            $scope.dhis2Events.push(dhis2Event);    
+                            
                         });
                     }
                 }
                 
                 angular.forEach($scope.dhis2Events, function(dhis2Event){
-                        
-                    dhis2Event.name = storage.get(dhis2Event.programStage).name;
+                    
+                    var ps = storage.get(dhis2Event.programStage);
+                    //check if a stage is repeatable
+                    if(ps.repeatable){
+                        $scope.allowEventCreation = true;
+                        if($scope.repeatableStages.indexOf(ps) == -1){
+                            $scope.repeatableStages.push(ps);
+                        }
+                    }
+                            
+                    dhis2Event.name = ps.name;
                     dhis2Event.eventDate = moment(dhis2Event.eventDate, 'YYYY-MM-DD')._d;
                     dhis2Event.eventDate = Date.parse(dhis2Event.eventDate);
                     dhis2Event.eventDate = $filter('date')(dhis2Event.eventDate, 'yyyy-MM-dd');
                     
-                    if(dhis2Event.status == 'COMPLETED'){
+                    if(dhis2Event.status === 'COMPLETED'){
                         dhis2Event.statusColor = 'stage-completed';
                     }
                     else{
-                        var date = moment(dhis2Event.eventDate, 'yyyy-MM-dd');
-                        if(moment().isAfter(date)){
+                        dhis2Event.statusColor = 'stage-on-time';
+
+                        if(moment(today).isAfter(dhis2Event.eventDate)){
                             dhis2Event.statusColor = 'stage-overdue';
-                        }
-                        else{
-                            dhis2Event.statusColor = 'stage-on-time';
-                        }
+                        }                        
                     } 
                     
                     if(dhis2Event.orgUnit){
@@ -706,8 +737,8 @@
         }
     });
     
-    $scope.createNewEvent = function(){        
-        console.log('need to create new event');        
+    $scope.createNewEvent = function(){
+        console.log('need to create new event:  ', $scope.repeatableStages);        
     };
     
     $scope.showDataEntry = function(event){

=== 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-05-16 13:58:07 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-05-20 15:56:10 +0000
@@ -583,6 +583,10 @@
     margin-bottom: 10px;
 }
 
+.widget-content-container{
+    padding: 20px 10px;
+}
+
 /*----------------------------------------------------------------------------*/
 /* Bootstrap modal style
 /*----------------------------------------------------------------------------*/

=== 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-05-13 09:54:48 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html	2014-05-20 15:56:10 +0000
@@ -1,8 +1,8 @@
 <div class="panel panel-default" ng-controller="DataEntryController">
     <div class="panel-heading">
         {{dataentryWidget.title| translate}} 
-        <span class="nav-pills" ng-show="selectedEnrollment">
-            | <span><a href ng-click="createNewEvent()">{{'create_new_event'| translate}}</a></span>            
+        <span class="nav-pills" ng-show="selectedEnrollment && allowEventCreation">
+            | <span><a href ng-click="createNewEvent()" title="{{'create_new_event_repeatable'| translate}}">{{'create_new_event'| translate}}</a></span>            
         </span>
         <span class="pull-right">
             <a href ng-click="removeWidget(dataentryWidget)" title="{{'remove'| translate}}"><span class='black'><i class="fa fa-times-circle"></i></span></a>            

=== 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-05-19 14:00:19 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html	2014-05-20 15:56:10 +0000
@@ -22,7 +22,7 @@
                 <button type="button" 
                         class="btn btn-default"
                         ng-if="selectedProgram && !selectedEnrollment" 
-                        ng-click="enroll()">
+                        ng-click="showEnrollment()">
                     {{'enroll'| translate}}
                 </button>  
             </td>                

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html	2014-05-19 14:00:19 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html	2014-05-20 15:56:10 +0000
@@ -1,6 +1,10 @@
+
 <div class="panel panel-default" ng-controller="ProfileController">
     <div class="panel-heading">
-        {{trackedEntity.name || 'entity' | translate}} {{profileWidget.title| translate}}
+        {{trackedEntity.name|| 'entity' | translate}} {{profileWidget.title| translate}}
+        <span class="nav-pills" ng-show="selectedEntity.attributes.length">
+            | <span><a href ng-click="showEdit()" title="{{'edit_profile'| translate}}">{{'edit'| translate}}</a></span>            
+        </span>
         <span class="pull-right">
             <a href ng-click="removeWidget(profileWidget)" title="{{'remove'| translate}}"><span class='black'><i class="fa fa-times-circle"></i></span></a>            
         </span>        
@@ -13,13 +17,13 @@
             <td>
                 <div ng-switch="attribute.type">
                     <div ng-switch-when="date">
-                        <input type="text" class="form-control" ng-date ng-model="attribute.value"  value="attribute.value | date:'yyyy-MM-dd"/>
+                        <input type="text" class="form-control" ng-date ng-model="attribute.value"  value="attribute.value | date:'yyyy-MM-dd" ng-disabled="!editProfile"/>
                     </div>
                     <div ng-switch-when="trueOnly">
-                        <input type="checkbox" class="form-control" ng-model="attribute.value" />
+                        <input type="checkbox" class="form-control" ng-model="attribute.value" ng-disabled="!editProfile"/>
                     </div>
                     <div ng-switch-when="bool">
-                        <select ng-model="attribute.value" class="form-control">
+                        <select ng-model="attribute.value" class="form-control" ng-disabled="!editProfile">
                             <option value="">{{'please_select'| translate}}</option>                        
                             <option value="0">{{'no'| translate}}</option>
                             <option value="1">{{'yes'| translate}}</option>
@@ -31,16 +35,32 @@
                                ng-model="attribute.value"                                                 
                                typeahead="option for option in attributes[attribute.attribute].optionSet.options | filter:$viewValue | limitTo:20" 
                                typeahead-open-on-focus 
-                               />
+                               ng-disabled="!editProfile"/>
                     </div>
                     <div ng-switch-when="number">
-                        <input type="number" class="form-control" ng-model="attribute.value" />
+                        <input type="number" class="form-control" ng-model="attribute.value" ng-disabled="!editProfile"/>
                     </div>
                     <div ng-switch-default>
-                        <input type="text"  class="form-control" ng-model="attribute.value" />                                        
+                        <input type="text"  class="form-control" ng-model="attribute.value" ng-disabled="!editProfile"/>                         
                     </div>
                 </div>                                                                                                    
             </td>
         </tr>           
     </table>
+
+    <div class="widget-content-container" ng-if="editProfile">
+        <div class="btn-group">
+            <button type="button" 
+                    class="btn btn-default"
+                    ng-click="save()">
+                {{'save'| translate}}
+            </button>        
+            <button type="button" 
+                    class="btn btn-default" 
+                    ng-click="cancel()">
+                {{'cancel'| translate}}
+            </button>        
+        </div>
+    </div>
+
 </div>
\ No newline at end of file

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to