dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32191
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16444: event capture - sending event uid from the client side, WIP
------------------------------------------------------------
revno: 16444
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-19 13:45:47 +0200
message:
event capture - sending event uid from the client side, WIP
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/column-modal.html
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/customForm.html
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/defaultForm.html
dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/eventList.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js 2014-05-06 10:32:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js 2014-08-19 11:45:47 +0000
@@ -103,6 +103,25 @@
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
};
+
+dhis2.util.uid = function() {
+ var letters = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ var allowedChars = "0123456789" + letters;
+ var NUMBER_OF_CODEPOINTS = allowedChars.length;
+ var CODESIZE = 11;
+ var uid;
+
+ //the uid should start with a char
+ uid = letters.charAt( Math.random() * (letters.length) );
+
+ for ( var i = 1; i < CODESIZE; ++i ){
+ uid += allowedChars.charAt( Math.random() * (NUMBER_OF_CODEPOINTS) );
+ }
+
+ return uid;
+};
+
+
/**
* Normalizes an argument object returned from a jQuery promise. If the argument
* is undefined, not an array or an empty array, undefined is returned. If the
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json 2014-08-01 12:22:15 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/i18n/en.json 2014-08-19 11:45:47 +0000
@@ -51,6 +51,7 @@
"new_event": "New Event",
"data_element": "Data element",
"value": "Value",
+ "form_id": "Form id",
"register_event": "Register event",
"total_number_of_pages": "No. of pages",
"rows_per_page": "No. of rows per page",
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html 2014-08-12 10:54:04 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/index.html 2014-08-19 11:45:47 +0000
@@ -1,5 +1,6 @@
<!DOCTYPE html>
-<html manifest="event-capture.appcache" ng-app="eventCapture">
+<html ng-app="eventCapture">
+<!--<html manifest="event-capture.appcache" ng-app="eventCapture">-->
<head>
<title>Event Capture</title>
@@ -45,7 +46,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
- <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
+ <!--<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>-->
<script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
@@ -171,7 +172,7 @@
<h3>
<span ng-if="editingEventInFull">{{'event_details'| translate}}</span>
<span ng-if="eventRegistration">{{'new_event'| translate}}</span>
- </h3>
+ </h3>
<div class="bordered-div" ng-if="displayCustomForm">
<div ng-include="'views/customForm.html'"></div>
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-08-12 10:54:04 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-08-19 11:45:47 +0000
@@ -101,7 +101,6 @@
});
}
};
-
//get events for the selected program (and org unit)
$scope.loadEvents = function(){
@@ -134,6 +133,11 @@
$scope.newDhis2Event = {dataValues: []};
$scope.currentEvent = {dataValues: []};
+
+ if($scope.selectedProgramStage.preGenerateUID){
+ $scope.eventGridColumns.push({name: 'form_id', id: 'uid', type: 'string', compulsory: false, showFilter: false, show: true});
+ $scope.filterTypes['uid'] = 'string';
+ }
angular.forEach($scope.selectedProgramStage.programStageDataElements, function(prStDe){
$scope.programStageDataElements[prStDe.dataElement.id] = prStDe;
@@ -221,7 +225,9 @@
}
$scope.dhis2Events[i][dataValue.dataElement] = dataValue.value;
- });
+ });
+
+ $scope.dhis2Events[i]['uid'] = $scope.dhis2Events[i].event;
delete $scope.dhis2Events[i].dataValues;
}
@@ -233,7 +239,7 @@
}
if($scope.noteExists){
- $scope.eventGridColumns.push({name: 'Comment', id: 'comment', type: 'string', compulsory: false, showFilter: false, show: true});
+ $scope.eventGridColumns.push({name: 'comment', id: 'comment', type: 'string', compulsory: false, showFilter: false, show: true});
}
}
$scope.eventFetched = true;
@@ -340,6 +346,11 @@
$scope.outerForm.submitted = false;
$scope.note = {};
+ if($scope.selectedProgramStage.preGenerateUID){
+ $scope.eventUID = dhis2.util.uid();
+ $scope.currentEvent['uid'] = $scope.eventUID;
+ }
+
//$scope.currentEvent = {};
};
@@ -404,6 +415,10 @@
dataValues: dataValues
};
+ if($scope.selectedProgramStage.preGenerateUID && !angular.isUndefined(newEvent['uid'])){
+ dhis2Event.event = newEvent['uid'];
+ }
+
if(!angular.isUndefined($scope.note.value) && $scope.note.value != ''){
dhis2Event.notes = [{value: $scope.note.value}];
@@ -450,7 +465,8 @@
$scope.outerForm.submitted = false;
$scope.disableSaveAndAddNew = false;
- //this is to hide typeAheadPopUps - shouldn't be an issue in the
+ //this is to hide typeAheadPopUps - shouldn't be an issue in
+ //the first place.
$timeout(function() {
angular.element('#hideTypeAheadPopUp').trigger('click');
}, 10);
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2014-08-15 09:53:56 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2014-08-19 11:45:47 +0000
@@ -334,7 +334,7 @@
{
return function() {
return $.ajax( {
- url: '../api/programStages.json?filter=id:eq:' + id +'&fields=id,name,version,description,reportDateDescription,captureCoordinates,dataEntryForm,minDaysFromStart,repeatable,programStageDataElements[displayInReports,allowProvidedElsewhere,allowDateInFuture,compulsory,dataElement[id,name,type,formName,optionSet[id]]]',
+ url: '../api/programStages.json?filter=id:eq:' + id +'&fields=id,name,version,description,reportDateDescription,captureCoordinates,dataEntryForm,minDaysFromStart,repeatable,preGenerateUID,programStageDataElements[displayInReports,allowProvidedElsewhere,allowDateInFuture,compulsory,dataElement[id,name,type,formName,optionSet[id]]]',
type: 'GET'
}).done( function( response ){
_.each( _.values( response.programStages ), function( programStage ) {
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js 2014-04-02 09:11:11 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/filters.js 2014-08-19 11:45:47 +0000
@@ -7,7 +7,7 @@
.filter('gridFilter', function($filter){
return function(data, filters, filterTypes){
-
+
if(!data ){
return;
}
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-08-08 11:18:55 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-08-19 11:45:47 +0000
@@ -240,6 +240,7 @@
newInputField = '<input type="text" ' +
this.getAttributesAsString(attributes) +
' ng-model="currentEvent.' + deId + '" ' +
+ ' ng-disabled="currentEvent[uid] == \'uid\'" ' +
' ng-required="programStageDataElements.' + deId + '.compulsory"' +
' typeahead="option.code as option.name for option in programStageDataElements.'+deId+'.dataElement.optionSet.options | filter:$viewValue | limitTo:20"' +
' typeahead-open-on-focus ng-required="programStageDataElements.'+deId+'.compulsory">';
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/column-modal.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/column-modal.html 2014-04-22 08:56:08 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/column-modal.html 2014-08-19 11:45:47 +0000
@@ -6,7 +6,8 @@
<table class="listTable dhis2-table-striped-border">
<tr ng-repeat="eventGridColumn in eventGridColumns">
<td>
- {{eventGridColumn.name}}
+ <span ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid'">{{eventGridColumn.name}}</span>
+ <span ng-if="eventGridColumn.id === 'comment' || eventGridColumn.id === 'uid'">{{eventGridColumn.name | translate}}</span>
</td>
<td>
<input type="checkbox" ng-model="eventGridColumn.show" ng-change="showHideColumns(eventGridColumn)" ng-disabled="hiddenGridColumns + 1 == eventGridColumns.length && eventGridColumn.show">
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/customForm.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/customForm.html 2014-08-01 12:22:15 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/customForm.html 2014-08-19 11:45:47 +0000
@@ -1,23 +1,31 @@
<table style='width: 50%;'>
+ <tr ng-if="selectedProgramStage.preGenerateUID">
+ <td>
+ {{'form_id'| translate}}
+ </td>
+ <td>
+ <input type="text" ng-disabled="true" ng-model="currentEvent['uid']" style="width:99%;">
+ </td>
+ </tr>
<tr>
<td>
- {{selectedProgramStage.reportDateDescription ? selectedProgramStage.reportDateDescription : 'incident_date' | translate }}
+ {{selectedProgramStage.reportDateDescription ? selectedProgramStage.reportDateDescription : 'incident_date'| translate }}
</td>
<td>
<input type="text"
- placeholder="yyyy-mm-dd"
- ng-date
- ng-model="currentEvent.eventDate"
- ng-disabled="editingEventInFull"
- ng-required="true"
- name="eventDate"
- style="width:99%;"/>
+ placeholder="yyyy-mm-dd"
+ ng-date
+ ng-model="currentEvent.eventDate"
+ ng-disabled="editingEventInFull"
+ ng-required="true"
+ name="eventDate"
+ style="width:99%;"/>
<span ng-show="outerForm.submitted && outerForm.eventDate.$invalid" class="required">{{'required'| translate}}</span>
</td>
</tr>
<tr ng-if="selectedProgramStage.captureCoordinates">
<td>
- {{'latitude' | translate}}
+ {{'latitude'| translate}}
</td>
<td>
<input type="number"
@@ -32,7 +40,7 @@
</tr>
<tr ng-if="selectedProgramStage.captureCoordinates">
<td>
- {{'longitude' | translate}}
+ {{'longitude'| translate}}
</td>
<td>
<input type="number"
@@ -58,15 +66,15 @@
<thead>
<tr>
<th style="width:100%;">
- {{'recorded_comments' | translate}}
+ {{'recorded_comments'| translate}}
</th>
</tr>
</thead>
<tr ng-repeat="note in currentEvent.notes">
<td class="over-flow-hidden" style="width:100%;">
<p>{{note.value}}</p>
- <p><strong>{{'created_by' | translate}}: </strong>{{note.storedBy}}</p>
- <p><strong>{{'date' | translate}}: </strong>{{note.storedDate}}</p>
+ <p><strong>{{'created_by'| translate}}: </strong>{{note.storedBy}}</p>
+ <p><strong>{{'date'| translate}}: </strong>{{note.storedDate}}</p>
</td>
</tr>
</table>
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/defaultForm.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2014-08-08 11:18:55 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2014-08-19 11:45:47 +0000
@@ -10,6 +10,14 @@
</tr>
</thead>
<tbody id="list">
+ <tr ng-if="selectedProgramStage.preGenerateUID && currentEvent['uid']">
+ <td>
+ {{'form_id' | translate}}
+ </td>
+ <td>
+ <input type="text" ng-disabled="true" ng-model="currentEvent['uid']" style="width:99%;">
+ </td>
+ </tr>
<tr>
<td>
{{selectedProgramStage.reportDateDescription ? selectedProgramStage.reportDateDescription : 'incident_date'| translate }}
@@ -56,9 +64,9 @@
<span ng-show="outerForm.submitted && outerForm.longitude.$invalid" class="required">{{'number_required'| translate}}[-180 ... 180]</span>
</td>
</tr>
- <tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment'">
+ <tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid'">
<td >
- {{eventGridColumn.name}}
+ {{eventGridColumn.name}}
</td>
<td >
<ng-form name="innerForm">
=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/eventList.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/eventList.html 2014-08-11 14:13:53 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/views/eventList.html 2014-08-19 11:45:47 +0000
@@ -48,7 +48,8 @@
<span ng-hide="eventGridColumn.showFilter" class="bold" ng-click="sortEventGrid(eventGridColumn)">
<i ng-show="sortHeader == eventGridColumn.id && !reverse" class="fa fa-sort-desc"></i>
<i ng-show="sortHeader == eventGridColumn.id && reverse" class="fa fa-sort-asc"></i>
- {{eventGridColumn.name}}
+ <span ng-if="eventGridColumn.id !== 'uid'">{{eventGridColumn.name}}</span>
+ <span ng-if="eventGridColumn.id == 'uid'">{{eventGridColumn.name | translate}}</span>
</span>
<!-- sort icon ends -->
@@ -91,14 +92,15 @@
{{'comment' | translate}}
</span>
</th>
- <!--<th ng-if='noteExists'>
- {{'comment' | translate}}
- </th>-->
</tr>
</thead>
<tbody id="list">
<tr ng-repeat="dhis2Event in dhis2Events | orderBy:sortHeader:reverse | gridFilter:filterText:filterTypes">
+ <!--<td ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id === 'uid' && eventGridColumn.show">
+ {{dhis2Event.event}}
+ </td>-->
+
<!-- Visible when event is not under editing -->
<td dhis-context-menu
selected-item={{dhis2Event}}
@@ -129,13 +131,14 @@
<span ng-show="outerForm.submitted && innerFormGrid.foo.$invalid" class="red"><em title="{{'required'| translate}}" class="required">*</em></span>
</div>
<div ng-switch-when="string">
- <div class="container-fluid">
+ <div class="container-fluid">
<input type="text"
ng-model="dhis2Event[eventGridColumn.id]"
ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)"
typeahead="option.code as option.name for option in programStageDataElements[eventGridColumn.id].dataElement.optionSet.options | filter:$viewValue | limitTo:20"
typeahead-open-on-focus
ng-required={{eventGridColumn.compulsory}}
+ ng-disabled="eventGridColumn.id == 'uid'"
name="foo"
style="width:98%;"
ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"