dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31255
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15911: tracker capture - events can now save multiple notes.
------------------------------------------------------------
revno: 15911
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Mon 2014-06-30 13:46:04 +0200
message:
tracker capture - events can now save multiple notes.
modified:
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/scripts/services.js
dhis-2/dhis-web/dhis-web-tracker-capture/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-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-30 07:19:37 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2014-06-30 11:46:04 +0000
@@ -201,6 +201,22 @@
});
};
+ $scope.createDummyEvent = function(programStage, orgUnit, enrollment){
+
+ var dueDate = DateUtils.getDueDate(programStage, enrollment);
+ var dummyEvent = {programStage: programStage.id,
+ orgUnit: orgUnit.id,
+ orgUnitName: orgUnit.name,
+ dueDate: dueDate,
+ name: programStage.name,
+ status: 'ACTIVE'};
+ dummyEvent.statusColor = 'stage-on-time';
+ if(moment(today).isAfter(dummyEvent.dueDate)){
+ dummyEvent.statusColor = 'stage-overdue';
+ }
+ return dummyEvent;
+ };
+
$scope.showDataEntry = function(event){
if(event){
@@ -220,35 +236,47 @@
}
};
- $scope.getDataEntryForm = function(){
- $scope.currentEvent.providedElsewhere = [];
-
- ProgramStageFactory.get($scope.currentEvent.programStage).then(function(stage){
- $scope.currentStage = stage;
-
- $scope.allowProvidedElsewhereExists = false;
- angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
- $scope.currentStage.programStageDataElements[prStDe.dataElement.id] = prStDe.dataElement;
- if(prStDe.allowProvidedElsewhere){
- $scope.allowProvidedElsewhereExists = true;
- $scope.currentEvent.providedElsewhere[prStDe.dataElement.id] = '';
- }
- });
- angular.forEach($scope.currentEvent.dataValues, function(dataValue){
- var val = dataValue.value;
- if(val){
- var de = $scope.currentStage.programStageDataElements[dataValue.dataElement];
- if( de && de.type === 'int' && val){
- val = parseInt(val);
- dataValue.value = val;
- }
- $scope.currentEvent[dataValue.dataElement] = val;
- }
- });
-
- $scope.currentEvent.dataValues = [];
- $scope.currentEventOriginal = angular.copy($scope.currentEvent);
- });
+ $scope.getDataEntryForm = function(){
+
+ DHIS2EventFactory.get($scope.currentEvent.event).then(function(data){
+ $scope.currentEvent = data;
+ $scope.currentEvent.providedElsewhere = [];
+
+ if(!angular.isUndefined( $scope.currentEvent.notes)){
+ $scope.currentEvent.notes = orderByFilter($scope.currentEvent.notes, '-storedDate');
+ angular.forEach($scope.currentEvent.notes, function(note){
+ note.storedDate = moment(note.storedDate).format('DD.MM.YYYY @ hh:mm A');
+ });
+ }
+
+ ProgramStageFactory.get($scope.currentEvent.programStage).then(function(stage){
+ $scope.currentStage = stage;
+
+ $scope.allowProvidedElsewhereExists = false;
+ angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
+ $scope.currentStage.programStageDataElements[prStDe.dataElement.id] = prStDe.dataElement;
+ if(prStDe.allowProvidedElsewhere){
+ $scope.allowProvidedElsewhereExists = true;
+ $scope.currentEvent.providedElsewhere[prStDe.dataElement.id] = '';
+ }
+ });
+ angular.forEach($scope.currentEvent.dataValues, function(dataValue){
+ var val = dataValue.value;
+ if(val){
+ var de = $scope.currentStage.programStageDataElements[dataValue.dataElement];
+ if( de && de.type === 'int' && val){
+ val = parseInt(val);
+ dataValue.value = val;
+ }
+ $scope.currentEvent[dataValue.dataElement] = val;
+ }
+ });
+
+ $scope.currentEvent.dataValues = [];
+ $scope.currentEventOriginal = angular.copy($scope.currentEvent);
+ });
+ });
+
};
$scope.saveDatavalue = function(prStDe){
@@ -264,7 +292,7 @@
if(!angular.isUndefined($scope.currentEvent[prStDe.dataElement.id])){
- if($scope.currentEventOriginal[prStDe.dataElement.id] != $scope.currentEvent[prStDe.dataElement.id]){
+ if($scope.currentEventOriginal[prStDe.dataElement.id] !== $scope.currentEvent[prStDe.dataElement.id]){
//get current element
$scope.currentElement = {id: prStDe.dataElement.id, saved: false};
@@ -321,21 +349,34 @@
}
};
- $scope.createDummyEvent = function(programStage, orgUnit, enrollment){
+ $scope.addNote = function(){
- var dueDate = DateUtils.getDueDate(programStage, enrollment);
- var dummyEvent = {programStage: programStage.id,
- orgUnit: orgUnit.id,
- orgUnitName: orgUnit.name,
- dueDate: dueDate,
- name: programStage.name,
- status: 'ACTIVE'};
- dummyEvent.statusColor = 'stage-on-time';
- if(moment(today).isAfter(dummyEvent.dueDate)){
- dummyEvent.statusColor = 'stage-overdue';
- }
- return dummyEvent;
- };
+ if(!angular.isUndefined($scope.note) && $scope.note != ""){
+
+ var newNote = {value: $scope.note};
+
+ if(angular.isUndefined( $scope.currentEvent.notes) ){
+ $scope.currentEvent.notes = [newNote];
+ }
+ else{
+ $scope.currentEvent.notes.splice(0,0,newNote);
+ }
+
+ var e = {event: $scope.currentEvent.event,
+ program: $scope.currentEvent.program,
+ programStage: $scope.currentEvent.programStage,
+ orgUnit: $scope.currentEvent.orgUnit,
+ trackedEntityInstance: $scope.currentEvent.trackedEntityInstance,
+ notes: [newNote]
+ };
+
+ console.log('the notes before update are: ', $scope.currentEvent);
+ DHIS2EventFactory.updateForNote(e).then(function(data){
+ $scope.note = '';
+ console.log('the notes after update are: ', $scope.currentEvent);
+ });
+ }
+ };
$scope.getClass = function(id){
if($scope.currentElement){
=== 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-30 07:21:49 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2014-06-30 11:46:04 +0000
@@ -155,6 +155,35 @@
</tr>
</table>
</form>
+ <hr>
+ <div class="row">
+ <div class="col-md-10">
+ <textarea class="form-control" rows="3" ng-model="note" placeholder="{{'add_your_note_here'| translate}}"></textarea>
+ </div>
+ <div class="col-md-2 add-default-top-margin">
+ <button type="button"
+ class="btn btn-primary"
+ ng-click="addNote()">
+ {{'add'| translate}}
+ </button>
+ </div>
+
+ <table class="table table-with-fixed-layout">
+ <tr ng-repeat="note in currentEvent.notes">
+ <td class="over-flow-hidden">
+ <d2-pop-over content="note" template="note.html" details="{{'details'| translate}}">
+ <div>{{note.value}}</div>
+ </d2-pop-over>
+ <script type="text/ng-template" id="note.html">
+ <p>{{content.value}}</p>
+ <hr>
+ <p><strong>{{'created_by' | translate}}: </strong>{{content.storedBy}}</p>
+ <p><strong>{{'date' | translate}}: </strong>{{content.storedDate}}</p>
+ </script>
+ </td>
+ </tr>
+ </table>
+ </div>
</div>
</div>
</div>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-06-30 05:56:38 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-06-30 11:46:04 +0000
@@ -438,6 +438,12 @@
return response.data;
});
return promise;
+ },
+ updateForNote: function(dhis2Event){
+ var promise = $http.put('../api/events/' + dhis2Event.event + '/addNote', dhis2Event).then(function(response){
+ return response.data;
+ });
+ return promise;
}
};
})
=== 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-06-30 10:54:21 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-06-30 11:46:04 +0000
@@ -597,6 +597,10 @@
margin: -15px !important;
}
+.add-default-top-margin {
+ margin-top: 15px !important;
+}
+
.add-note {
margin-bottom: 30px;
margin-left: -5px;
@@ -929,4 +933,17 @@
a:hover {
color: inherit;
+}
+
+.note-container {
+ width: 100%;
+ display: block;
+}
+
+.note-entry-field {
+ width: 70%;
+}
+
+.note-entry-button {
+ width: 30%;
}
\ No newline at end of file