dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41470
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21129: event-capture: event-grid now displays clickable file name for values of file type data elements
------------------------------------------------------------
revno: 21129
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-11-19 12:12:54 +0100
message:
event-capture: event-grid now displays clickable file name for values of file type data elements
modified:
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/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-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-11-18 16:35:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-11-19 11:12:54 +0000
@@ -30,6 +30,7 @@
ModalService,
DialogService,
CommonUtils,
+ FileService,
AuthorityService,
TrackerRulesExecutionService,
TrackerRulesFactory) {
@@ -63,7 +64,7 @@
$scope.optionSets = [];
$scope.proceedSelection = true;
$scope.formUnsaved = false;
- $scope.fileNames = {};
+ $scope.fileNames = [];
//notes
$scope.note = {};
@@ -137,7 +138,7 @@
$scope.dhis2Events = [];
$scope.currentEvent = {};
$scope.currentEventOriginialValue = {};
- $scope.fileNames = {};
+ $scope.fileNames = [];
$scope.eventRegistration = false;
$scope.editGridColumns = false;
@@ -314,7 +315,7 @@
$scope.eventLength = data.events.length;
}
- $scope.dhis2Events = data.events;
+ //$scope.dhis2Events = data.events;
if( data.pager ){
$scope.pager = data.pager;
@@ -327,18 +328,18 @@
}
//process event list for easier tabular sorting
- if( angular.isObject( $scope.dhis2Events ) ) {
-
- for(var i=0; i < $scope.dhis2Events.length; i++){
-
- if($scope.dhis2Events[i].notes && !$scope.noteExists){
+ if( angular.isObject( data.events ) ) {
+
+ angular.forEach(data.events,function(event){
+
+ if(event.notes && !$scope.noteExists){
$scope.noteExists = true;
}
//check if event is empty
- if(!angular.isUndefined($scope.dhis2Events[i].dataValues)){
+ if(!angular.isUndefined(event.dataValues)){
- angular.forEach($scope.dhis2Events[i].dataValues, function(dataValue){
+ angular.forEach(event.dataValues, function(dataValue){
//converting event.datavalues[i].datavalue.dataelement = value to
//event[dataElement] = value for easier grid display.
@@ -346,19 +347,36 @@
var val = dataValue.value;
if(angular.isObject($scope.prStDes[dataValue.dataElement].dataElement)){
val = CommonUtils.formatDataValue(val, $scope.prStDes[dataValue.dataElement].dataElement, $scope.optionSets, 'USER');
- }
- $scope.dhis2Events[i][dataValue.dataElement] = val;
+ }
+
+ event[dataValue.dataElement] = val;
+
+ if($scope.prStDes[dataValue.dataElement].dataElement.valueType === 'FILE_RESOURCE'){
+ FileService.get(val).then(function(response){
+ if(response && response.name){
+ if($scope.fileNames[event.event]){
+ $scope.fileNames[event.event][dataValue.dataElement] = response.name;
+ }
+ else{
+ $scope.fileNames[event.event] = [];
+ $scope.fileNames[event.event][dataValue.dataElement] = response.name;
+ }
+ }
+ });
+ }
}
});
- $scope.dhis2Events[i]['uid'] = $scope.dhis2Events[i].event;
- $scope.dhis2Events[i].eventDate = DateUtils.formatFromApiToUser($scope.dhis2Events[i].eventDate);
- $scope.dhis2Events[i]['eventDate'] = $scope.dhis2Events[i].eventDate;
+ event['uid'] = event.event;
+ event.eventDate = DateUtils.formatFromApiToUser(event.eventDate);
+ event['eventDate'] = event.eventDate;
- delete $scope.dhis2Events[i].dataValues;
+ delete event.dataValues;
}
- }
+ });
+ $scope.dhis2Events = data.events;
+
if($scope.noteExists && !GridColumnService.columnExists($scope.eventGridColumns, 'comment')){
$scope.eventGridColumns.push({name: 'comment', id: 'comment', type: 'TEXT', filterWithRange: false, compulsory: false, showFilter: false, show: true});
}
@@ -499,14 +517,12 @@
$scope.currentElement.updated = false;
$scope.currentEvent = {};
$scope.currentElement = {};
- $scope.fileNames = {};
$scope.currentEventOriginialValue = angular.copy($scope.currentEvent);
};
$scope.showEventRegistration = function(){
$scope.displayCustomForm = $scope.customForm ? true:false;
$scope.currentEvent = {};
- $scope.fileNames = {};
$scope.eventRegistration = !$scope.eventRegistration;
$scope.currentEvent = angular.copy($scope.newDhis2Event);
$scope.outerForm.submitted = false;
@@ -533,7 +549,6 @@
$scope.showEditEventInFull = function(){
$scope.note = {};
- $scope.fileNames = {};
$scope.displayCustomForm = $scope.customForm ? true:false;
$scope.currentEvent = ContextMenuSelectedItem.getSelectedItem();
=== 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-11-16 15:48:46 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html 2015-11-19 11:12:54 +0000
@@ -135,6 +135,9 @@
<span ng-switch-when="TRUE_ONLY">
<span ng-if="dhis2Event[eventGridColumn.id]"><i class="fa fa-check"></i></span>
</span>
+ <span ng-switch-when="FILE_RESOURCE">
+ <a href ng-click="downloadFile(dhis2Event.event, eventGridColumn.id)">{{fileNames[dhis2Event.event][eventGridColumn.id]}}</a>
+ </span>
<span ng-switch-default>
{{dhis2Event[eventGridColumn.id]}}
</span>
@@ -320,6 +323,30 @@
ng-class="getInputNotifcationClass(eventGridColumn.id,false)"
name="foo"/>
</div>
+ <div ng-switch-when="FILE_RESOURCE">
+ <div class="input-group">
+ <div class="form-control">
+ <a href ng-click="downloadFile(currentEvent.event, eventGridColumn.id)">{{fileNames[eventGridColumn.id]}}</a>
+ </div>
+ <span class="input-group-btn">
+ <span class="btn btn-primary btn-file">
+ <span ng-if="currentEvent[eventGridColumn.id]" title="{{'delete' | translate}}" d2-file-input-name="fileNames[eventGridColumn.id]" d2-file-input-delete="currentEvent[eventGridColumn.id]">
+ <i class="fa fa-trash"></i>
+ </span>
+ <span ng-if="!currentEvent[eventGridColumn.id]" title="{{'upload' | translate}}">
+ <i class="fa fa-upload"></i>
+ <input type="file"
+ ng-required={{eventGridColumn.compulsory}}
+ ng-disabled="assignedFields[eventGridColumn.id]"
+ name="foo"
+ input-field-id={{eventGridColumn.id}}
+ d2-file-input="currentEvent[eventGridColumn.id]"
+ d2-file-input-name="fileNames[eventGridColumn.id]">
+ </span>
+ </span>
+ </span>
+ </div>
+ </div>
<div ng-switch-default>
<input type="text"
ng-model="currentEvent[eventGridColumn.id]"