dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35646
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18236: tracker-capture: advanced search now provides separate OU tree (full tree - irrespective of user ...
------------------------------------------------------------
revno: 18236
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-02-12 11:51:40 +0100
message:
tracker-capture: advanced search now provides separate OU tree (full tree - irrespective of user assignment)
added:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/search-ou-tree.html
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-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-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-02-11 11:52:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-02-12 10:51:40 +0000
@@ -21,7 +21,7 @@
$scope.selectedProgramId = ($location.search()).program;
$scope.selectedOrgUnit = storage.get('SELECTED_OU');
$scope.selectedProgram;
- $scope.selectedTei;
+ $scope.selectedTei;
//dashboard items
var getDashboardLayout = function(){
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-02-06 20:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-02-12 10:51:40 +0000
@@ -7,20 +7,13 @@
CurrentSelection,
TEIService,
RelationshipFactory) {
- $rootScope.showAddRelationshipDiv = false;
- $scope.relationshipTypes = [];
- $scope.relationships = [];
- $scope.addRelationshipLabel = $translate('add');
-
- RelationshipFactory.getAll().then(function(rels){
- $scope.relationshipTypes = rels;
- angular.forEach(rels, function(rel){
- $scope.relationships[rel.id] = rel;
- });
- });
+ $rootScope.showAddRelationshipDiv = false;
+ $scope.addRelationshipLabel = $translate('add');
//listen for the selected entity
$scope.$on('dashboardWidgets', function(event, args) {
+ $scope.relationshipTypes = [];
+ $scope.relationships = [];
$scope.relatedTeis = [];
$scope.selections = CurrentSelection.get();
$scope.optionSets = $scope.selections.optionSets;
@@ -38,8 +31,15 @@
$scope.addRelationshipLabel = $translate('add');
}
- setRelationships();
-
+ RelationshipFactory.getAll().then(function(rels){
+ $scope.relationshipTypes = rels;
+ angular.forEach(rels, function(rel){
+ $scope.relationships[rel.id] = rel;
+ });
+
+ setRelationships();
+
+ });
});
$scope.showAddRelationship = function() {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html 2014-10-13 15:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html 2015-02-12 10:51:40 +0000
@@ -1,5 +1,5 @@
-<div class="search-container-main">
- <div class="search-container">
+<div class="advanced-search-container-main">
+ <div class="advanced-search-container">
<table data-stop-propagation="true" class="table-borderless table-striped">
<tr>
<td>{{'org_unit'| translate}}</td>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties 2015-02-06 20:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties 2015-02-12 10:51:40 +0000
@@ -274,4 +274,5 @@
point_and_click_for_coordinate=Point and click for coordinate
value_must_be_between=Value must be between
locate_organisation_unit_by_name=Locate organisation unit by name
-dashboard_layout_not_saved=Dashboard layout not saved
\ No newline at end of file
+dashboard_layout_not_saved=Dashboard layout not saved
+ou_search_scope=Orgunit scope to use
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2015-02-03 15:59:38 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2015-02-12 10:51:40 +0000
@@ -11,6 +11,7 @@
Paginator,
storage,
OptionSetService,
+ OrgUnitFactory,
OperatorFactory,
ProgramFactory,
AttributesFactory,
@@ -25,6 +26,7 @@
$scope.dashboardProgramId = ($location.search()).program;
$scope.selectedOrgUnitId = ($location.search()).ou;
$scope.treeLoaded = false;
+ $scope.searchOuTree = false;
//Paging
$scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5};
@@ -86,8 +88,8 @@
}
}
}
- });
-
+ });
+
//watch for program feedback (this is when coming back from dashboard)
if($scope.dashboardProgramId && $scope.dashboardProgramId !== 'null'){
ProgramFactory.get($scope.dashboardProgramId).then(function(program){
@@ -151,29 +153,11 @@
};
$scope.processAttributes = function(){
-
- if($scope.selectedProgram){
- AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.attributes = atts;
- setTimeout(function () {
- $scope.$apply(function () {
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
- });
- }, 100);
- });
- }
- else{
- AttributesFactory.getWithoutProgram().then(function(atts){
- $scope.attributes = atts;
- setTimeout(function () {
- $scope.$apply(function () {
- $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
- $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
- });
- }, 100);
- });
- }
+
+ AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
+ $scope.attributes = $scope.generateAttributeFilters(atts);
+ $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
+ });
};
//$scope.searchParam = {bools: []};
@@ -182,7 +166,6 @@
$scope.selectedSearchMode = mode;
$scope.emptySearchText = false;
$scope.emptySearchAttribute = false;
- //$scope.showSearchDiv = false;
$scope.showRegistrationDiv = false;
$scope.showReportDiv = false;
$scope.showTrackedEntityDiv = false;
@@ -206,9 +189,10 @@
$scope.teiCount = null;
return;
}
-
+
$scope.queryUrl = 'query=' + $scope.searchText;
$scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
+ $scope.searchingOrgUnit = $scope.selectedOrgUnit;
}
if( $scope.selectedSearchMode === $scope.searchMode.attributeBased ){
@@ -223,21 +207,22 @@
$scope.teiCount = null;
return;
}
+
+ $scope.searchingOrgUnit = $scope.selectedSearchingOrgUnit && $scope.selectedSearchingOrgUnit.id ? $scope.selectedSearchingOrgUnit : $scope.selectedOrgUnit;
}
if( $scope.selectedSearchMode === $scope.searchMode.listAll ){
- $scope.searchText = '';
-
+ $scope.searchText = '';
$scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
+ $scope.searchingOrgUnit = $scope.selectedOrgUnit;
}
$scope.fetchTeis();
};
$scope.fetchTeis = function(){
-
- //get events for the specified parameters
- TEIService.search($scope.selectedOrgUnit.id,
+ //get events for the specified parameters
+ TEIService.search($scope.searchingOrgUnit.id,
$scope.selectedOuMode.name,
$scope.queryUrl,
$scope.programUrl,
@@ -363,5 +348,40 @@
$scope.getHelpContent = function(){
console.log('I will get help content');
- };
+ };
+
+ //Get orgunits for the logged in user
+ OrgUnitFactory.getRoot().then(function(response) {
+ $scope.orgUnits = response.organisationUnits;
+ $scope.selectedSearchingOrgUnit = $scope.orgUnits && $scope.orgUnits.length && $scope.orgUnits[0] ? $scope.orgUnits[0] : null;
+ angular.forEach($scope.orgUnits, function(ou){
+ ou.show = true;
+ angular.forEach(ou.children, function(o){
+ o.hasChildren = o.children && o.children.length > 0 ? true : false;
+ });
+ });
+ });
+
+ //expand/collapse of search orgunit tree
+ $scope.expandCollapse = function(orgUnit) {
+ if( orgUnit.hasChildren ){
+ //Get children for the selected orgUnit
+ OrgUnitFactory.get(orgUnit.id).then(function(ou) {
+ orgUnit.show = !orgUnit.show;
+ orgUnit.hasChildren = false;
+ orgUnit.children = ou.organisationUnits[0].children;
+ angular.forEach(orgUnit.children, function(ou){
+ ou.hasChildren = ou.children && ou.children.length > 0 ? true : false;
+ });
+ });
+ }
+ else{
+ orgUnit.show = !orgUnit.show;
+ }
+ };
+
+ //load programs for the selected orgunit (from tree)
+ $scope.setSelectedSearchingOrgUnit = function(orgUnit){
+ $scope.selectedSearchingOrgUnit = orgUnit;
+ };
});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-02-11 11:52:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-02-12 10:51:40 +0000
@@ -333,6 +333,38 @@
};
})
+/* Factory for fetching OrgUnit */
+.factory('OrgUnitFactory', function($http) {
+ var orgUnit, orgUnitPromise, rootOrgUnitPromise, myOrgUnitsPromise;
+ return {
+ get: function(uid){
+ if( orgUnit !== uid ){
+ orgUnitPromise = $http.get( '../api/organisationUnits.json?filter=id:eq:' + uid + '&fields=id,name,children[id,name,children[id,name]]&paging=false' ).then(function(response){
+ orgUnit = response.data.id;
+ return response.data;
+ });
+ }
+ return orgUnitPromise;
+ },
+ getRoot: function(){
+ if(!rootOrgUnitPromise){
+ rootOrgUnitPromise = $http.get( '../api/organisationUnits.json?filter=level:eq:1&fields=id,name,children[id,name,children[id,name]]&paging=false' ).then(function(response){
+ return response.data;
+ });
+ }
+ return rootOrgUnitPromise;
+ },
+ getMine: function(){
+ if(!myOrgUnitsPromise){
+ myOrgUnitsPromise = $http.get('../api/me/organisationUnits').then(function(response){
+ return response.data;
+ });
+ }
+ return myOrgUnitsPromise;
+ }
+ };
+})
+
/* Service to deal with enrollment */
.service('EnrollmentService', function($http, DateUtils) {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2015-02-11 12:05:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2015-02-12 10:51:40 +0000
@@ -454,20 +454,30 @@
padding-left: 5px;
padding-right: 5px;
}
-.search-container-main {
+.advanced-search-container-main {
width: 100%;
float: left;
height: 100%;
padding-bottom: 5px;
}
-.search-container{
+.advanced-search-container{
margin: 5px;
padding: 5px 9px 5px 5px;
max-height: 570px;
overflow-y: scroll;
}
+div#searchOuTree accordion>.panel-group>.panel-default>.panel-heading{
+ background-color: #ffffff;
+ padding: 10px 5px 10px 5px;
+ //padding: 5px 9px 5px 5px;
+}
+
+div#searchOuTree h4{
+ font-size: 9pt;
+}
+
.widget-content-container{
padding: 20px 10px;
}
@@ -845,4 +855,77 @@
#header, #leftBar, .not-printable {
display: none;
}
-}
\ No newline at end of file
+}
+
+
+.org-unit-tree {
+ margin-left: -5px;
+ color: #000;
+ text-decoration: none;
+ font-size: 9pt;
+ background-color: white;
+ overflow: auto;
+ width: 100%;
+ height: 100%;
+ display: inline-block;
+ white-space: nowrap;
+}
+
+ul.tree, ul.tree ul {
+ list-style:none;
+ margin:0;
+ padding:0;
+}
+
+ul.tree ul {
+ margin-left:10px; /* indentation */
+ position:relative;
+}
+
+ul.tree ul:before {
+ content:"";
+ display:block;
+ width:0;
+ position:absolute;
+ top:0;
+ bottom:0;
+ left:0;
+ border-left:1px dotted;
+}
+
+ul.tree li {
+ margin:0;
+ padding:0 12px; /* indentation + 2 */
+ line-height:20px; /* default list item `line-height` */
+ position:relative;
+}
+
+ul.tree ul li:before {
+ content:"";
+ display:block;
+ width:10px; /* same with indentation */
+ height:0;
+ border-top:1px dotted;
+ position:absolute;
+ top:10px;
+ left:0;
+}
+
+ul.tree ul li:last-child:before {
+ background:white; /* same with body background */
+ height:auto;
+ top:10px; /* (line-height/2) */
+ bottom:0;
+}
+
+.org-unit-tree-button {
+ background:transparent;
+ border:none;
+ outline:none;
+ cursor:pointer;
+}
+
+.selected-org-unit {
+ font-weight: bold;
+ color: #FF8000;
+}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-search.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-search.html 2015-02-11 14:01:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/advanced-search.html 2015-02-12 10:51:40 +0000
@@ -1,13 +1,16 @@
-<div class="search-container-main">
- <div class="search-container">
- <table data-stop-propagation="true" class="table-borderless table-striped">
- <tr>
- <td>{{'org_unit'| translate}}</td>
+<div class="advanced-search-container-main">
+ <div data-stop-propagation="true" class="advanced-search-container">
+ <table class="table-borderless table-striped">
+ <tr>
+ <div ng-include="'views/search-ou-tree.html'"></div>
+ </tr>
+ <tr>
+ <td>{{'ou_search_scope'| translate}}</td>
<td>
<label><input type="radio" ng-model="selectedOuMode.name" name="selected" value="SELECTED"> {{'SELECTED'| translate}}</label><br/>
<label><input type="radio" ng-model="selectedOuMode.name" name="children" value="CHILDREN"> {{'CHILDREN'| translate}}</label><br/>
<label><input type="radio" ng-model="selectedOuMode.name" name="descendants" value="DESCENDANTS"> {{'DESCENDANTS'| translate}}</label><br/>
- <label><input type="radio" ng-model="selectedOuMode.name" name="accessible" value="ACCESSIBLE"> {{'ACCESSIBLE'| translate}}</label>
+ <!--<label><input type="radio" ng-model="selectedOuMode.name" name="accessible" value="ACCESSIBLE"> {{'ACCESSIBLE'| translate}}</label>-->
</td>
</tr>
<tr ng-if="selectedProgram">
@@ -101,10 +104,10 @@
ng-click="search(searchMode.attributeBased)">
{{'search'| translate}}
</button>
- <button type="button"
+ <!--<button type="button"
class="btn btn-success small-horizonal-spacing"
ng-click="search(searchMode.listAll)">
{{'list_all'| translate}}
- </button>
+ </button>-->
</div>
</div>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/search-ou-tree.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/search-ou-tree.html 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/search-ou-tree.html 2015-02-12 10:51:40 +0000
@@ -0,0 +1,22 @@
+<div id="searchOuTree">
+ <accordion>
+ <accordion-group is-open="searchOuTree.open">
+ <accordion-heading>
+ {{'org_unit'| translate}} <i class="pull-right" ng-class="{'fa fa-chevron-up vertical-center': searchOuTree.open, 'fa fa-chevron-down vertical-center': !searchOuTree.open}"></i>
+ </accordion-heading>
+ <div class="org-unit-tree row" data-stop-propagation="true">
+ <script type="text/ng-template" id="orgUnitTree.html">
+ <span class="org-unit-tree-button" ng-click="expandCollapse(orgUnit)" ng-show="orgUnit.show && orgUnit.children.length > 0"><i class="fa fa-minus-square-o"></i></span>
+ <span class="org-unit-tree-button" ng-click="expandCollapse(orgUnit)" ng-show="(!orgUnit.show && orgUnit.children.length > 0) || (!orgUnit.show && orgUnit.hasChildren)"><i class="fa fa-plus-square-o"></i></span>
+ <span class="org-unit-tree-button" ng-click="setSelectedSearchingOrgUnit(orgUnit)" ng-class="{'selected-org-unit' : orgUnit.id === selectedSearchingOrgUnit.id}">{{orgUnit.name}}</span>
+ <ul class="tree" id="tree" ng-show="orgUnit.show">
+ <li ng-repeat="orgUnit in orgUnit.children | orderBy:'name':reverse" ng-include="'orgUnitTree.html'"></li>
+ </ul>
+ </script>
+ <ul class="tree" id="tree">
+ <li ng-repeat="orgUnit in orgUnits | orderBy:'name':reverse" ng-include="'orgUnitTree.html'"></li>
+ </ul>
+ </div>
+ </accordion-group>
+ </accordion>
+</div>
\ No newline at end of file