dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40203
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20369: event-capture: update eventdate both in grid and full editing
------------------------------------------------------------
revno: 20369
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-09-25 15:33:59 +0200
message:
event-capture: update eventdate both in grid and full editing
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.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-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-09-21 15:01:55 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-09-25 13:33:59 +0000
@@ -1,5 +1,6 @@
<!DOCTYPE html>
-<html manifest="cacheManifest.action" ng-app="eventCapture">
+<html ng-app="eventCapture">
+<!--<html manifest="cacheManifest.action" ng-app="eventCapture">-->
<head>
<title>Event Capture</title>
@@ -62,7 +63,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="scripts/event-capture.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-24 15:28:23 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-25 13:33:59 +0000
@@ -174,9 +174,9 @@
$scope.eventGridColumns.push({name: 'form_id', id: 'uid', valueType: 'TEXT', compulsory: false, filterWithRange: false, showFilter: false, show: false});
$scope.filterTypes['uid'] = 'TEXT';
- $scope.eventGridColumns.push({name: $scope.selectedProgramStage.reportDateDescription ? $scope.selectedProgramStage.reportDateDescription : 'incident_date', id: 'event_date', valueType: 'DATE', filterWithRange: true, compulsory: false, showFilter: false, show: true});
- $scope.filterTypes['event_date'] = 'DATE';
- $scope.filterText['event_date']= {};
+ $scope.eventGridColumns.push({name: $scope.selectedProgramStage.reportDateDescription ? $scope.selectedProgramStage.reportDateDescription : 'incident_date', id: 'eventDate', valueType: 'DATE', filterWithRange: true, compulsory: false, showFilter: false, show: true});
+ $scope.filterTypes['eventDate'] = 'DATE';
+ $scope.filterText['eventDate']= {};
angular.forEach($scope.selectedProgramStage.programStageDataElements, function(prStDe){
$scope.prStDes[prStDe.dataElement.id] = prStDe;
@@ -319,7 +319,7 @@
$scope.dhis2Events[i]['uid'] = $scope.dhis2Events[i].event;
$scope.dhis2Events[i].eventDate = DateUtils.formatFromApiToUser($scope.dhis2Events[i].eventDate);
- $scope.dhis2Events[i]['event_date'] = $scope.dhis2Events[i].eventDate;
+ $scope.dhis2Events[i]['eventDate'] = $scope.dhis2Events[i].eventDate;
delete $scope.dhis2Events[i].dataValues;
}
@@ -330,7 +330,7 @@
}
if(!$scope.sortHeader.id){
- $scope.sortEventGrid({name: $scope.selectedProgramStage.reportDateDescription ? $scope.selectedProgramStage.reportDateDescription : 'incident_date', id: 'event_date', type: 'DATE', compulsory: false, showFilter: false, show: true});
+ $scope.sortEventGrid({name: $scope.selectedProgramStage.reportDateDescription ? $scope.selectedProgramStage.reportDateDescription : 'incident_date', id: 'eventDate', type: 'DATE', compulsory: false, showFilter: false, show: true});
}
}
@@ -609,7 +609,7 @@
$scope.dhis2Events = [];
}
newEvent['uid'] = newEvent.event;
- newEvent['event_date'] = newEvent.eventDate;
+ newEvent['eventDate'] = newEvent.eventDate;
$scope.dhis2Events.splice(0,0,newEvent);
$scope.eventLength++;
@@ -696,7 +696,55 @@
$scope.currentEventOriginialValue = angular.copy($scope.currentEvent);
});
};
-
+
+ $scope.updateEventDate = function () {
+ $scope.updateSuccess = false;
+
+ $scope.currentElement = {id: 'eventDate'};
+
+ var rawDate = angular.copy($scope.currentEvent.eventDate);
+ var convertedDate = DateUtils.format($scope.currentEvent.eventDate);
+
+ if (!rawDate || !convertedDate || rawDate !== convertedDate) {
+ $scope.invalidDate = true;
+ $scope.currentEvent.eventDate = $scope.currentEventOriginialValue.eventDate;
+ $scope.resetEventValue($scope.currentEvent);
+ $scope.currentElement.updated = false;
+ return false;
+ }
+
+ //get new and old values
+ var newValue = $scope.currentEvent.eventDate;
+ var oldValue = $scope.currentEventOriginialValue.eventDate;
+
+ if ($scope.currentEvent.eventDate === '') {
+ $scope.currentEvent.eventDate = oldValue;
+ $scope.resetEventValue($scope.currentEvent);
+ $scope.currentElement.updated = false;
+ return false;
+ }
+
+ if(newValue !== oldValue){
+ var e = {event: $scope.currentEvent.event,
+ orgUnit: $scope.currentEvent.orgUnit,
+ eventDate: DateUtils.formatFromUserToApi($scope.currentEvent.eventDate)
+ };
+
+ var updatedFullValueEvent = DHIS2EventService.reconstructEvent($scope.currentEvent, $scope.selectedProgramStage.programStageDataElements);
+
+ DHIS2EventFactory.updateForEventDate(e, updatedFullValueEvent).then(function () {
+ //reflect the new value in the grid
+ $scope.resetEventValue($scope.currentEvent);
+
+ //update original value
+ $scope.currentEventOriginialValue = angular.copy($scope.currentEvent);
+
+ $scope.currentElement.updated = true;
+ $scope.updateSuccess = true;
+ });
+ }
+ };
+
$scope.updateEventDataValue = function(currentEvent, dataElement){
$scope.updateSuccess = false;
@@ -743,11 +791,11 @@
}
};
- $scope.resetEventValue = function(currentEvent){
+ $scope.resetEventValue = function(){
var continueLoop = true;
for(var i=0; i< $scope.dhis2Events.length && continueLoop; i++){
- if($scope.dhis2Events[i].event === currentEvent.event ){
- $scope.dhis2Events[i] = currentEvent;
+ if($scope.dhis2Events[i].event === $scope.currentEvent.event ){
+ $scope.dhis2Events[i] = $scope.currentEvent;
continueLoop = false;
}
}
@@ -888,19 +936,6 @@
return status;
};
- //Infinite Scroll
- $scope.infiniteScroll = {};
- $scope.infiniteScroll.optionsToAdd = 20;
- $scope.infiniteScroll.currentOptions = 20;
-
- $scope.resetInfScroll = function() {
- $scope.infiniteScroll.currentOptions = $scope.infiniteScroll.optionsToAdd;
- };
-
- $scope.addMoreOptions = function(){
- $scope.infiniteScroll.currentOptions += $scope.infiniteScroll.optionsToAdd;
- };
-
//listen for rule effect changes
$scope.$on('ruleeffectsupdated', function(event, args) {
$scope.warningMessages = [];
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2015-09-22 16:33:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2015-09-25 13:33:59 +0000
@@ -337,6 +337,16 @@
dhis2.ec.store.set('events', fullValue);
});
return promise;
+ },
+ updateForEventDate: function(dhis2Event, fullEvent){
+ var promise = $http.put('../api/events/' + dhis2Event.event + '/updateEventDate', dhis2Event).then(function(response){
+ return response.data;
+ }, function(){
+ dhis2.ec.store.remove('events', fullEvent.event);
+ fullEvent.id = fullEvent.event;
+ dhis2.ec.store.set('events', fullEvent);
+ });
+ return promise;
}
};
})
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-09-25 07:58:42 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-09-25 13:33:59 +0000
@@ -28,8 +28,7 @@
placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
d2-date
max-date='0'
- ng-model="currentEvent.eventDate"
- ng-disabled="editingEventInFull"
+ ng-model="currentEvent.eventDate"
ng-required="true"
d2-date-validator
name="eventDate"
@@ -69,7 +68,7 @@
</div>
</td>
</tr>
- <tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid' && eventGridColumn.id !== 'event_date' && !hiddenFields[eventGridColumn.id]">
+ <tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid' && eventGridColumn.id !== 'eventDate' && !hiddenFields[eventGridColumn.id]">
<td >
{{eventGridColumn.name}}<span ng-if="eventGridColumn.compulsory" class="required">*</span>
</td>
@@ -269,8 +268,7 @@
placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
d2-date
max-date='0'
- ng-model="currentEvent.eventDate"
- ng-disabled="editingEventInFull"
+ ng-model="currentEvent.eventDate"
ng-required="true"
d2-date-validator
name="eventDate"
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html 2015-09-21 08:48:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html 2015-09-25 13:33:59 +0000
@@ -16,10 +16,8 @@
placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
d2-date
max-date='0'
- ng-model="currentEvent.eventDate"
- ng-disabled="editingEventInFull"
- ng-required="true"
-
+ ng-model="currentEvent.eventDate"
+ ng-required="true"
d2-date-validator
name="eventDate"
input-field-id='eventDate'
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html 2015-09-24 15:28:23 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html 2015-09-25 13:33:59 +0000
@@ -295,9 +295,8 @@
max-date="prStDes[eventGridColumn.id].allowFutureDate ? '' : 0"
d2-date-validator
ng-model="currentEvent[eventGridColumn.id]"
- blur-or-change="updateEventDataValue(dhis2Event, eventGridColumn.id)"
+ blur-or-change="eventGridColumn.id === 'eventDate' ? updateEventDate(dhis2Event, eventGridColumn) : updateEventDataValue(dhis2Event, eventGridColumn.id)"
ng-required={{eventGridColumn.compulsory}}
- ng-disabled="eventGridColumn.id == 'event_date'"
input-field-id={{eventGridColumn.id}}
ng-class="getInputNotifcationClass(eventGridColumn.id,false)"
name="foo"/>
@@ -311,7 +310,6 @@
ng-model="currentEvent[eventGridColumn.id]"
blur-or-change="updateEventDataValue(dhis2Event, eventGridColumn.id)"
ng-required={{eventGridColumn.compulsory}}
- ng-disabled="eventGridColumn.id == 'event_date'"
input-field-id={{eventGridColumn.id}}
ng-class="getInputNotifcationClass(eventGridColumn.id,false)"
name="foo"/>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-09-24 14:38:58 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-09-25 13:33:59 +0000
@@ -379,8 +379,8 @@
//check if dataelement has optionset
if (prStDe.dataElement.optionSetValue) {
var optionSetId = prStDe.dataElement.optionSet.id;
- newInputField = '<ui-select theme="select2" ' + commonInputFieldProperty + ' on-select="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')" >' +
- '<ui-select-match ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id, true)" allow-clear="true" placeholder="' + $translate.instant('select_or_search') + '">{{$select.selected.name || $select.selected}}</ui-select-match>' +
+ newInputField = '<ui-select style="width:100%;" theme="select2" ' + commonInputFieldProperty + ' on-select="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')" >' +
+ '<ui-select-match style="width:100%;" ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id, true)" allow-clear="true" placeholder="' + $translate.instant('select_or_search') + '">{{$select.selected.name || $select.selected}}</ui-select-match>' +
'<ui-select-choices ' +
' repeat="option.name as option in optionSets.' + optionSetId + '.options | filter: $select.search | limitTo:maxOptionSize">' +
'<span ng-bind-html="option.name | highlight: $select.search"></span>' +
@@ -504,8 +504,8 @@
//check if attribute has optionset
if (att.optionSetValue) {
var optionSetId = att.optionSet.id;
- newInputField = '<ui-select theme="select2" ' + commonInputFieldProperty + ' on-select="teiValueUpdated(selectedTei,\'' + attId + '\')" >' +
- '<ui-select-match allow-clear="true" placeholder="' + $translate.instant('select_or_search') + '">{{$select.selected.name || $select.selected}}</ui-select-match>' +
+ newInputField = '<ui-select style="width:100%;" theme="select2" ' + commonInputFieldProperty + ' on-select="teiValueUpdated(selectedTei,\'' + attId + '\')" >' +
+ '<ui-select-match style="width:100%;" allow-clear="true" placeholder="' + $translate.instant('select_or_search') + '">{{$select.selected.name || $select.selected}}</ui-select-match>' +
'<ui-select-choices ' +
'repeat="option.name as option in optionSets.' + optionSetId + '.options | filter: $select.search | limitTo:maxOptionSize">' +
'<span ng-bind-html="option.name | highlight: $select.search"></span>' +