← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21972: Added input fields for specifying the category combo and category options while creating events i...

 

------------------------------------------------------------
revno: 21972
committer: jijukjose <jijukjose@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-02-15 13:05:18 +0100
message:
  Added input fields for specifying the category combo and category options while creating events in the tracker capture.
modified:
  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/event-details.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties
  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/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-02-15 12:05:18 +0000
@@ -1005,7 +1005,7 @@
             }
         }
         var autoCreate = stage && stage.displayEventsInTable ? stage.displayEventsInTable : false;
-        EventCreationService.showModal($scope.eventsByStage, stage, availableStages, $scope.programStages, $scope.selectedEntity, $scope.selectedProgram, $scope.selectedOrgUnit, $scope.selectedEnrollment, autoCreate, eventCreationAction, allApplicableEvents,suggestedStage)
+        EventCreationService.showModal($scope.eventsByStage, stage, availableStages, $scope.programStages, $scope.selectedEntity, $scope.selectedProgram, $scope.selectedOrgUnit, $scope.selectedEnrollment, autoCreate, eventCreationAction, allApplicableEvents,suggestedStage, $scope.selectedCategories)
                 .then(function (eventContainer) {
                     if(angular.isDefined(eventContainer)){                
                         var ev = eventContainer.ev;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-details.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-details.html	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-details.html	2016-02-15 12:05:18 +0000
@@ -44,20 +44,6 @@
 </div>
 <!-- event dates/scheduling end -->
 
-<div class="row col-sm-12" ng-if="selectedProgram" ng-repeat="category in selectedCategories">
-    <div class="col-sm-6">
-        {{category.displayName}}
-    </div>
-    <div class="col-sm-6">
-        <select class="form-control"
-                name="option"                             
-                ng-model="category.selectedOption"
-                ng-options="option as option.displayName for option in category.categoryOptions"
-                ng-change="getCategoryOptions()">
-            <option value="">{{pleaseSelectLabel}}</option>
-        </select>
-    </div>
-</div>
 <!-- coordinates begin -->
 <div class="row" ng-if="currentStage.captureCoordinates && currentEvent.eventDate">
     <div class="col-md-6">

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js	2016-02-04 10:43:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js	2016-02-15 12:05:18 +0000
@@ -5,6 +5,7 @@
         function ($scope,
                 $modalInstance,
                 $timeout,
+                $translate,
                 DateUtils,
                 DHIS2EventFactory,
                 OrgUnitFactory,
@@ -22,7 +23,8 @@
                 autoCreate,
                 EventUtils,
                 events,
-                suggestedStage) {
+                suggestedStage,
+                selectedCategories) {
     $scope.stages = stages;
     $scope.allStages = allStages;
     $scope.events = events;
@@ -34,8 +36,11 @@
     $scope.model = {selectedStage: stage, dueDateInvalid: false, eventDateInvalid: false};
     $scope.stageSpecifiedOnModalOpen = angular.isObject(stage) ? true : false;
     $scope.suggestedStage = suggestedStage;
-    
-    var orgPath = [];    
+    $scope.selectedProgram = program;
+    $scope.selectedCategories = selectedCategories;
+    $scope.pleaseSelectLabel = $translate.instant('please_select');
+
+    var orgPath = [];
     var dummyEvent = {};
     
     function prepareEvent(){
@@ -169,7 +174,25 @@
         }
     });
 
+    $scope.getCategoryOptions = function(){
+        $scope.eventFetched = false;
+        $scope.optionsReady = false;
+        $scope.selectedOptions = [];
+        for (var i = 0; i < $scope.selectedCategories.length; i++) {
+            if ($scope.selectedCategories[i].selectedOption && $scope.selectedCategories[i].selectedOption.id) {
+                $scope.optionsReady = true;
+                $scope.selectedOptions.push($scope.selectedCategories[i].selectedOption.id);
+            }
+            else {
+                $scope.optionsReady = false;
+                break;
+            }
+        }
+    };
+
     $scope.save = function () {
+
+        $scope.getCategoryOptions();
         //check for form validity
         if ($scope.model.dueDateInvalid || $scope.model.eventDateInvalid) {
             return false;
@@ -204,6 +227,20 @@
 
         newEvent.status = newEvent.eventDate ? 'ACTIVE' : 'SCHEDULE';
 
+        /*for saving category combo*/
+        if (!$scope.selectedProgram.categoryCombo.isDefault) {
+            if ($scope.selectedOptions.length !== $scope.selectedCategories.length) {
+                var dialogOptions = {
+                    headerText: 'error',
+                    bodyText: 'fill_all_category_options'
+                };
+                DialogService.showDialog({}, dialogOptions);
+                return;
+            }
+            newEvent.attributeCategoryOptions = $scope.selectedOptions.join(';');
+        }
+        /*for saving category combo*/
+
         newEvents.events.push(newEvent);
         DHIS2EventFactory.create(newEvents).then(function (response) {
             if (response.response && response.response.importSummaries[0].status === 'SUCCESS') {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html	2016-02-15 12:05:18 +0000
@@ -110,6 +110,23 @@
         
             </div>            
         </div>
+        <div ng-if="selectedProgram" ng-repeat="category in selectedCategories">
+            <div class="form-group">
+                <div class="col-sm-11">
+                    <label class="col-sm-3 control-label">{{category.displayName}}</label>
+                    <div class="col-sm-9">
+                        <select class="form-control"
+                                name="option"
+                                ng-model="category.selectedOption"
+                                ng-options="option as option.displayName for option in category.categoryOptions"
+                                ng-change="getCategoryOptions()">
+                            <option value="" ng-selected="selectDefault.selected">{{pleaseSelectLabel}}</option>
+                        </select>
+                    </div>
+                </div>
+            </div>
+        </div>
+
     </form>  
 </div>
 <div class="modal-footer page">        

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2016-02-09 15:59:55 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2016-02-15 12:05:18 +0000
@@ -465,3 +465,4 @@
 events_in_two_weeks=Events due in two weeks
 events_in_one_month=Events due in a month
 choose_the_dates=Choose the dates
+fill_all_category_options=Please fill all category options
\ No newline at end of file

=== 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	2016-02-15 09:46:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-02-15 12:05:18 +0000
@@ -1911,7 +1911,7 @@
 
 .service('EventCreationService', function($modal){
             
-        this.showModal = function(eventsByStage, stage, availableStages,programStages,selectedEntity,selectedProgram,selectedOrgUnit,selectedEnrollment, autoCreate, eventCreationAction,allEventsSorted, suggestedStage){
+        this.showModal = function(eventsByStage, stage, availableStages,programStages,selectedEntity,selectedProgram,selectedOrgUnit,selectedEnrollment, autoCreate, eventCreationAction,allEventsSorted, suggestedStage, selectedCategories){
             var modalInstance = $modal.open({
                 templateUrl: 'components/dataentry/new-event.html',
                 controller: 'EventCreationController',
@@ -1951,7 +1951,10 @@
                     },
                     suggestedStage: function(){
                         return suggestedStage;
-                    }
+                    },
+                	selectedCategories: function () {
+                    	return selectedCategories;
+	                }
                 }
             }).result;
             return modalInstance;