dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30035
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15228: UI for search by program
------------------------------------------------------------
revno: 15228
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Mon 2014-05-12 16:08:02 +0200
message:
UI for search by program
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
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
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-05-06 12:52:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json 2014-05-12 14:08:02 +0000
@@ -50,6 +50,7 @@
"use_all_children": "Use all children",
"data_element": "Data element",
"value": "Value",
+ "provided_elsewhere": "Provided elsewhere",
"show_hide_widgets": "Show/Hide widgets",
"select_widgets_to_show": "Select widgets to show",
"close": "Close",
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-05-08 09:34:02 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-05-12 14:08:02 +0000
@@ -31,7 +31,8 @@
//Searching
$scope.showSearchDiv = false;
- $scope.searchField = {title: 'search', isOpen: false};
+ $scope.searchField = {title: 'search', isOpen: false};
+ $scope.attributes = [];
//watch for selection of org unit from tree
$scope.$watch('selectedOrgUnit', function() {
@@ -39,13 +40,48 @@
if( angular.isObject($scope.selectedOrgUnit)){
$scope.trackedEntityList = [];
+ $scope.selectedProgram = '';
//apply translation - by now user's profile is fetched from server.
TranslationService.translate();
+ $scope.loadPrograms($scope.selectedOrgUnit);
$scope.attributes = storage.get('ATTRIBUTES');
}
});
+ //load programs associated with the selected org unit.
+ $scope.loadPrograms = function(orgUnit) {
+
+ $scope.selectedOrgUnit = orgUnit;
+ $scope.selectedProgram = null;
+ $scope.selectedProgramStage = null;
+
+ if (angular.isObject($scope.selectedOrgUnit)) {
+
+ $scope.programs = [];
+
+ var programs = storage.get('TRACKER_PROGRAMS');
+
+ if( programs && programs != 'undefined' ){
+ for(var i=0; i<programs.length; i++){
+ var program = storage.get(programs[i].id);
+ if(angular.isObject(program)){
+ if(program.organisationUnits.hasOwnProperty(orgUnit.id)){
+ $scope.programs.push(program);
+ }
+ }
+ }
+
+ if( !angular.isUndefined($scope.programs)){
+ if($scope.programs.length === 1){
+ $scope.selectedProgram = $scope.programs[0];
+ $scope.pr = $scope.selectedProgram;
+ }
+ }
+ }
+ }
+ };
+
//get events for the selected program (and org unit)
$scope.loadTrackedEntities = function(){
@@ -136,22 +172,29 @@
//Controller for the search section
.controller('SearchController',
function($rootScope,
- $scope,
- storage,
+ $scope,
+ AttributesFactory,
TranslationService) {
TranslationService.translate();
//search attibutes
- $scope.attributes = storage.get('ATTRIBUTES');
- $scope.availableAttributes = [];
+ $scope.attributes = AttributesFactory.getAll();
+ $scope.availableAttributes = $scope.attributes;
$scope.selectedAttributes = [];
$rootScope.showAdvancedSearchDiv = false;
$scope.ouMode = 'SELECTED';
- angular.forEach($scope.attributes, function(attribute){
- $scope.availableAttributes.push(attribute);
- });
+ $scope.getProgramAttributes = function(program){
+ if(program){
+ $scope.attributes = AttributesFactory.getByProgram(program);
+ $scope.availableAttributes = $scope.attributes;
+ }
+ else{
+ $scope.attributes = AttributesFactory.getAll();
+ $scope.availableAttributes = $scope.attributes;
+ }
+ };
$scope.moveToSelected = function(attribute, fromView){
@@ -172,20 +215,20 @@
}
else if(attribute.valueType === 'bool'){
- filter.operands = ['One of'];
+ filter.operands = ['IS'];
filter.operand = filter.operands[0];
filter.values = ['No', 'Yes'];
filter.value = filter.values[0];
}
else if(attribute.valueType === 'combo'){
- filter.operands = ['One of'];
+ filter.operands = ['IS'];
filter.operand = filter.operands[0];
filter.values = attribute.optionSet.options;
filter.value = filter.values[0];
}
else{
- filter.operands = ['like', 'not_like' ];
+ filter.operands = ['LIKE', 'NOT LIKE' ];
filter.operand = filter.operands[0];
}
@@ -198,8 +241,7 @@
}
};
- $scope.moveAllToSelected = function(){
- for(var i=0; i<$scope.availableAttributes.length;)
+ $scope.moveAllToSelected = function(){
angular.forEach($scope.availableAttributes, function(attribute){
//$scope.selectedAttributes.push(attribute);
$scope.moveToSelected(attribute, false);
@@ -218,20 +260,20 @@
}
else if(attribute.valueType === 'bool'){
- filter.operands = ['One of'];
+ filter.operands = ['IS'];
filter.operand = filter.operands[0];
filter.values = ['No', 'Yes'];
filter.value = filter.values[0];
}
else if(attribute.valueType === 'combo'){
- filter.operands = ['One of'];
+ filter.operands = ['IS'];
filter.operand = filter.operands[0];
filter.values = attribute.optionSet.options;
filter.value = filter.values[0];
}
else{
- filter.operands = ['like', 'not_like' ];
+ filter.operands = ['LIKE', 'NOT LIKE' ];
filter.operand = filter.operands[0];
}
@@ -419,8 +461,10 @@
$scope.programStages = [];
angular.forEach($scope.selectedProgram.programStages, function(stage){
- $scope.programStages.push(storage.get(stage.id));
+ $scope.programStages.push(storage.get(stage.id));
});
+
+ console.log('the stages are: ', $scope.programStages);
if($scope.selectedEnrollment){
$scope.selectedEnrollment.dateOfIncident = $filter('date')($scope.selectedEnrollment.dateOfIncident, 'yyyy-MM-dd');
@@ -553,10 +597,12 @@
if(event){
$scope.currentEvent = event;
+ $scope.currentEvent.dataValues = [];
$scope.currentStage = storage.get($scope.currentEvent.programStage);
angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
$scope.currentStage.programStageDataElements[prStDe.dataElement.id] = prStDe.dataElement;
+ //$scope.currentEvent.dataValues.push({value: '', dataElement: prStDe.dataElement.id, providedElsewhere: ''});
});
angular.forEach($scope.currentEvent.dataValues, function(dataValue){
@@ -564,9 +610,10 @@
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[dataValue.dataElement] = val;
});
}
};
=== 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 2013-03-22 16:15:16 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-05-12 14:08:02 +0000
@@ -165,12 +165,10 @@
},
getByOrgUnitAndProgram: function(orgUnitUid, programUid) {
-
- //var attributes = AttributesFactory.convertListingForToQuery();
+
var url = '../api/trackedEntityInstances.json?ou=' + orgUnitUid + '&program=' + programUid;
- promise = $http.get( url ).then(function(response){
-
+ promise = $http.get( url ).then(function(response){
return entityFormatter(response.data);
});
return promise;
@@ -201,7 +199,21 @@
return attributes;
}
return;
- },
+ },
+ getByProgram: function(program){
+ var attributes = [];
+ var programAttributes = [];
+
+ angular.forEach(this.getAll(), function(attribute){
+ attributes[attribute.id] = attribute;
+ });
+
+ angular.forEach(program.programTrackedEntityAttributes, function(pAttribute){
+ programAttributes.push(attributes[pAttribute.attribute.id]);
+ });
+
+ return programAttributes;
+ },
getForListing: function(){
var attributes = [];
@@ -310,6 +322,10 @@
};
})
+.service('ProgramAttributes', function(){
+
+})
+
/* Modal service for user interaction */
.service('ModalService', ['$modal', function($modal) {
=== 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-05-06 12:52:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2014-05-12 14:08:02 +0000
@@ -457,6 +457,7 @@
width: 100%;
border: 1px solid #c2c2c2;
padding: 5px 10px;
+ table-layout: fixed;
}
.dhis2-list-table-striped>thead>tr,
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html 2014-04-04 11:55:55 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/dataentry.html 2014-05-12 14:08:02 +0000
@@ -29,6 +29,20 @@
<hr>
<div ng-show="currentEvent">
<table class="table table-striped table-hover">
+ <thead>
+ <tr>
+ <th>
+ {{'data_element' | translate}}
+ </th>
+ <th>
+ {{'value' | translate}}
+ </th>
+ <th>
+ {{'provided_elsewhere' | translate}}
+ </th>
+ </tr>
+ </thead>
+
<tr ng-repeat="prStDe in currentStage.programStageDataElements">
<td>
{{prStDe.dataElement.name}}
@@ -73,8 +87,16 @@
</div>
</div>
</td>
+ <td>
+ <span ng-if="prStDe.allowProvidedElsewhere">
+ <input type="checkbox" ng-model="currentEvent[prStDe.dataElement.id].providedElsewhere"/>
+ </span>
+ </td>
</tr>
- </table>
+ </table>
+
+ <hr>
+
</div>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html 2014-04-04 11:55:55 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html 2014-05-12 14:08:02 +0000
@@ -55,6 +55,7 @@
</td>
<td>
{{programStage.minDaysFromStart}}
+ {{selectedEnrollment.dateOfIncident}}
</td>
</tr>
</table>
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html 2014-04-08 15:37:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html 2014-05-12 14:08:02 +0000
@@ -22,6 +22,16 @@
</div>
<div class="panel panel-default">
<div class="panel-heading">
+ {{'program'| translate}}
+ </div>
+ <div>
+ <select class="form-control" ng-model="pr" ng-change="getProgramAttributes(pr)" ng-options="program as program.name for program in programs | orderBy: 'name'">
+ <option value="">{{'please_select'| translate}}</option>
+ </select>
+ </div>
+ </div>
+ <div class="panel panel-default">
+ <div class="panel-heading">
{{'available_search_attributes'| translate}} |
<span ng-show="availableAttributes.length > 0">
<a href ng-click="moveToSelected(selectedAttribute, true)" title="{{'move_to_selected'| translate}}"><span class="black"><i class="fa fa-angle-down"></i></span></a>
@@ -31,6 +41,7 @@
<select class="form-control" multiple ng-model="selectedAttribute" ng-options="attribute as attribute.name for attribute in availableAttributes | orderBy:'name'" ng-dblclick="moveToSelected(selectedAttribute, true)">
</select>
</div>
+
<div class="panel panel-default">
<div class="panel-heading">
{{'selected_search_attributes'| translate}}
@@ -139,6 +150,26 @@
<div ng-if="!showAdvancedSearchDiv">
<table class="dhis2-list-table-striped dhis2-table-hover">
+ <tr>
+ <td>{{'org_unit_mode'| translate}}</td>
+ <td>
+ <input type='radio' ng-model='ouMode' value='SELECTED'>{{'use_selected'| translate}}<br/>
+ <input type='radio' ng-model='ouMode' value='CHILDREN'>{{'use_immediate_children'| translate}}<br/>
+ <input type='radio' ng-model='ouMode' value='DESCENDANTS'>{{'use_all_children'| translate}}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{'program'| translate}}
+ {{attributes.size}}
+ </td>
+ <td>
+ <select class="form-control" ng-model="pr" ng-change="getProgramAttributes(pr)" ng-options="program as program.name for program in programs | orderBy: 'name'">
+ <option value="">{{'please_select'| translate}}</option>
+ </select>
+ </td>
+ </tr>
+
<tr ng-repeat="attribute in attributes">
<td>
{{attribute.name}}
@@ -174,15 +205,7 @@
</div>
</div>
</td>
- </tr>
- <tr>
- <td>{{'org_unit_mode'| translate}}</td>
- <td>
- <input type='radio' ng-model='ouMode' value='SELECTED'>{{'use_selected'| translate}}<br/>
- <input type='radio' ng-model='ouMode' value='CHILDREN'>{{'use_immediate_children'| translate}}<br/>
- <input type='radio' ng-model='ouMode' value='DESCENDANTS'>{{'use_all_children'| translate}}
- </td>
- </tr>
+ </tr>
</table>
</div>