dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31212
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15890: tracker capture - applied validation during enrollment
------------------------------------------------------------
revno: 15890
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2014-06-27 17:42:43 +0200
message:
tracker capture - applied validation during enrollment
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2014-06-27 10:57:20 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2014-06-27 15:42:43 +0000
@@ -74,7 +74,7 @@
}
$scope.broadCastProgram = function(){
- CurrentSelection.set({tei: $scope.selectedEntity, te: $scope.trackedEntity, pr: $scope.selectedProgram});
+ CurrentSelection.set({tei: $scope.selectedEntity, te: $scope.trackedEntity, pr: $scope.selectedProgram, enrollment: null});
$timeout(function() {
$rootScope.$broadcast('selectedEntity', {programExists: $scope.programs.length > 0});
}, 100);
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2014-06-27 10:57:20 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2014-06-27 15:42:43 +0000
@@ -316,4 +316,9 @@
}
return 'form-control';
};
+
+ $scope.closeEventCreation = function(){
+ $scope.currentDummyEvent = null;
+ $scope.showEventCreationDiv = !$scope.showEventCreationDiv;
+ };
});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2014-06-27 14:49:34 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2014-06-27 15:42:43 +0000
@@ -66,7 +66,8 @@
</div>
<div class="row vertical-spacing">
<div class="col-md-6">
- <button type="button" class="btn btn-default" ng-click="createEvent()">{{'create'| translate}}</button>
+ <button type="button" class="btn btn-primary" ng-click="createEvent()">{{'create'| translate}}</button>
+ <button type="button" class="btn btn-default small-horizonal-spacing" ng-click="closeEventCreation()">{{'cancel'| translate}}</button>
</div>
</div>
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2014-06-27 10:57:20 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2014-06-27 15:42:43 +0000
@@ -47,7 +47,6 @@
if($scope.selectedProgram){
//check for possible enrollment
- $scope.selectedEnrollment = null;
angular.forEach($scope.enrollments, function(enrollment){
if(enrollment.program === $scope.selectedProgram.id ){
$scope.selectedEnrollment = enrollment;
@@ -59,7 +58,6 @@
}
else{//prepare for possible enrollment
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
-
$scope.attributesForEnrollment = [];
for(var i=0; i<atts.length; i++){
var exists = false;
@@ -112,6 +110,13 @@
$scope.enroll = function(){
+ //check for form validity
+ $scope.outerForm.submitted = true;
+ if( $scope.outerForm.$invalid ){
+ return false;
+ }
+
+ //form is valid, continue with enrollment
var tei = angular.copy($scope.selectedEntity);
tei.attributes = [];
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html 2014-06-27 14:49:34 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html 2014-06-27 15:42:43 +0000
@@ -64,80 +64,91 @@
</button>
</div>
</div>
-
-
- <div ng-if="selectedProgram && !selectedEnrollment">
- <table class="table-borderless">
- <tr class="col-md-12">
- <td class="col-md-6">
- {{selectedProgram.dateOfEnrollmentDescription}}
- </td>
- <td class="col-md-6">
- <input type="text" class="form-control" ng-date ng-model="newEnrollment.dateOfEnrollment" />
- </td>
- </tr>
- <tr class="col-md-12" ng-if="selectedProgram.displayIncidentDate">
- <td class="col-md-6">
- {{selectedProgram.dateOfIncidentDescription}}
- </td>
- <td class="col-md-6">
- <input type="text" class="form-control" ng-date ng-model="newEnrollment.dateOfIncident" />
- </td>
- </tr>
- </table>
- <hr>
- <table class="table-borderless table-striped">
- <tr class="col-md-12" ng-repeat="attribute in attributesForEnrollment">
- <td class="col-md-6">
- {{attribute.name}}
- </td>
- <td class="col-md-6">
- <div ng-switch="attribute.valueType">
- <div ng-switch-when="date">
- <input type="text" class="form-control" ng-date ng-model="attribute.value" />
- </div>
- <div ng-switch-when="trueOnly">
- <input type="checkbox" class="form-control" ng-model="attribute.value" />
- </div>
- <div ng-switch-when="bool">
- <select ng-model="attribute.value" class="form-control">
- <option value="">{{'please_select'| translate}}</option>
- <option value="0">{{'no'| translate}}</option>
- <option value="1">{{'yes'| translate}}</option>
- </select>
- </div>
- <div ng-switch-when="optionSet">
- <input type="text"
- class="form-control"
- ng-model="attribute.value"
- typeahead="option for option in attribute.optionSet.options | filter:$viewValue | limitTo:20"
- typeahead-open-on-focus
- />
- </div>
- <div ng-switch-when="number">
- <input type="number" class="form-control" ng-model="attribute.value"/>
- </div>
- <div ng-switch-default>
- <input type="text" class="form-control" ng-model="attribute.value" />
- </div>
- </div>
- </td>
- </tr>
- </table>
-
- <div class="vertical-spacing small-horizonal-spacing">
- <button type="button"
- class="btn btn-primary"
- ng-click="enroll()">
- {{'enroll'| translate}}
- </button>
- <button type="button"
- class="btn btn-default"
- ng-click="cancelEnrollment()">
- {{'cancel'| translate}}
- </button>
+
+ <form name="outerForm" novalidate>
+ <div ng-if="selectedProgram && !selectedEnrollment">
+ <table class="table-borderless">
+ <tr class="col-md-12">
+ <td class="col-md-6">
+ {{selectedProgram.dateOfEnrollmentDescription}}
+ </td>
+ <td class="col-md-6">
+ <input type="text" name="dateOfEnrollment" class="form-control" ng-date ng-model="newEnrollment.dateOfEnrollment" ng-required="true"/>
+ <span ng-show="outerForm.submitted && outerForm.dateOfEnrollment.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </td>
+ </tr>
+ <tr class="col-md-12" ng-if="selectedProgram.displayIncidentDate">
+ <td class="col-md-6">
+ {{selectedProgram.dateOfIncidentDescription}}
+ </td>
+ <td class="col-md-6">
+ <input type="text" class="form-control" ng-date ng-model="newEnrollment.dateOfIncident" />
+ </td>
+ </tr>
+ </table>
+ <hr>
+ <table class="table-borderless table-striped">
+ <tr class="col-md-12" ng-repeat="attribute in attributesForEnrollment">
+ <td class="col-md-6">
+ {{attribute.name}}
+ </td>
+ <td class="col-md-6">
+ <ng-form name="innerForm">
+ <div ng-switch="attribute.valueType">
+ <div ng-switch-when="date">
+ <input type="text" class="form-control" ng-date ng-model="attribute.value" ng-required="attribute.mandatory"/>
+ <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </div>
+ <div ng-switch-when="trueOnly">
+ <input type="checkbox" class="form-control" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+ <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </div>
+ <div ng-switch-when="bool">
+ <select ng-model="attribute.value" class="form-control" ng-required="attribute.mandatory">
+ <option value="">{{'please_select'| translate}}</option>
+ <option value="0">{{'no'| translate}}</option>
+ <option value="1">{{'yes'| translate}}</option>
+ </select>
+ <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </div>
+ <div ng-switch-when="optionSet">
+ <input type="text"
+ class="form-control"
+ ng-model="attribute.value"
+ typeahead="option for option in attribute.optionSet.options | filter:$viewValue | limitTo:20"
+ typeahead-open-on-focus
+ ng-required="attribute.mandatory"
+ />
+ <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </div>
+ <div ng-switch-when="number">
+ <input type="number" class="form-control" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+ <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </div>
+ <div ng-switch-default>
+ <input type="text" class="form-control" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+ <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+ </div>
+ </div>
+ </ng-form>
+ </td>
+ </tr>
+ </table>
+
+ <div class="vertical-spacing small-horizonal-spacing">
+ <button type="button"
+ class="btn btn-primary"
+ ng-click="enroll()">
+ {{'enroll'| translate}}
+ </button>
+ <button type="button"
+ class="btn btn-default"
+ ng-click="cancelEnrollment()">
+ {{'cancel'| translate}}
+ </button>
+ </div>
</div>
- </div>
+ </form>
<div ng-if="!selectedProgram && programExists">
<div class="alert alert-warning">{{'please_select_a_program_for_enrollment'| translate}}</div>
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2014-06-27 10:57:20 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2014-06-27 15:42:43 +0000
@@ -3,7 +3,6 @@
$scope,
orderByFilter,
CurrentSelection,
- TEService,
TEIService,
AttributesFactory,
TranslationService) {
@@ -25,7 +24,8 @@
var selections = CurrentSelection.get();
$scope.selectedTei = selections.tei;
$scope.trackedEntity = selections.te;
- $scope.selectedProgram = selections.pr;
+ $scope.selectedProgram = selections.pr;
+ $scope.selectedEnrollment = selections.enrollment;
$scope.processTeiAttributes();
});
@@ -38,8 +38,8 @@
att.value = parseInt(att.value);
}
});
-
- if($scope.selectedProgram){
+
+ if($scope.selectedProgram && $scope.selectedEnrollment){
//show only those attributes in selected program
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){