dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39870
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20207: tracker/event-capture: left bar show/hide menu
------------------------------------------------------------
revno: 20207
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-17 13:21:04 +0200
message:
tracker/event-capture: left bar show/hide menu
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/event-capture.appcache
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties
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/views/home.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/services.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js
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/event-capture.appcache'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/event-capture.appcache 2015-09-09 15:23:50 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/event-capture.appcache 2015-09-17 11:21:04 +0000
@@ -58,6 +58,7 @@
../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js
../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js
../dhis-web-commons/ouwt/ouwt.js
+../main.js
scripts/event-capture.js
../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties 2015-08-09 22:28:42 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties 2015-09-17 11:21:04 +0000
@@ -143,4 +143,7 @@
proceed=Proceed
lacking_required_authority_to_add_update_event=Lacking required authority to add/update event.
select_or_search=Select or search from the list
-indicators=Indicators
\ No newline at end of file
+indicators=Indicators
+hide_menu=Hide menu
+extend_menu=Extend menu
+show_main_menu=Show main menu
\ No newline at end of file
=== 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-09 12:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-09-17 11:21:04 +0000
@@ -86,6 +86,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.translate.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.menu.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.menu.ui.js"></script>
+ <script type="text/javascript" src="../main.js"></script>
<link type="text/css" rel="stylesheet" href="../dhis-web-commons/font-awesome/css/font-awesome.min.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="../dhis-web-commons/css/widgets.css"/>
=== 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-09 12:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-17 11:21:04 +0000
@@ -79,6 +79,8 @@
$scope.eventCaptureLabel = $translate.instant('event_capture');
$scope.programLabel = $translate.instant('program');
$scope.searchLabel = $translate.instant('search');
+ $scope.findLabel = $translate.instant('find');
+ $scope.searchOusLabel = $translate.instant('locate_organisation_unit_by_name');
$scope.yesLabel = $translate.instant('yes');
$scope.noLabel = $translate.instant('no');
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html 2015-09-09 12:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html 2015-09-17 11:21:04 +0000
@@ -1,16 +1,4 @@
-<div id="leftBar">
-
- <d2-ou-search></d2-ou-search>
-
- <div id="orgUnitTree">
- <ul>
- </ul>
- </div>
- <img id="ouwt_loader" src="../images/ajax-loader-bar.gif"/>
- <div class="small-horizonal-spacing" ng-if='!treeLoaded'>
- {{'loading_tree'| translate}}
- </div>
-</div>
+<d2-left-bar></d2-left-bar>
<div class="page" id="mainPage">
=== 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-09-11 15:16:03 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties 2015-09-17 11:21:04 +0000
@@ -356,4 +356,7 @@
inactive=Inactive
activate_tei=Set TEI to active
deactivate_tei=Set TEI to inactive
-tei_inactive_only_read=The TEI is inactive. Only read operations are allowed.
\ No newline at end of file
+tei_inactive_only_read=The TEI is inactive. Only read operations are allowed.
+hide_menu=Hide menu
+extend_menu=Extend menu
+show_main_menu=Show main menu
\ 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-09-14 16:13:56 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-09-17 11:21:04 +0000
@@ -427,64 +427,6 @@
};
})
-/*Orgunit service for local db */
-.service('OrgUnitService', function($window, $q){
-
- var indexedDB = $window.indexedDB;
- var db = null;
-
- var open = function(){
- var deferred = $q.defer();
-
- var request = indexedDB.open("dhis2ou");
-
- request.onsuccess = function(e) {
- db = e.target.result;
- deferred.resolve();
- };
-
- request.onerror = function(){
- deferred.reject();
- };
-
- return deferred.promise;
- };
-
- var get = function(uid){
-
- var deferred = $q.defer();
-
- if( db === null){
- deferred.reject("DB not opened");
- }
- else{
- var tx = db.transaction(["ou"]);
- var store = tx.objectStore("ou");
- var query = store.get(uid);
-
- query.onsuccess = function(e){
- if(e.target.result){
- deferred.resolve(e.target.result);
- }
- else{
- var t = db.transaction(["ouPartial"]);
- var s = t.objectStore("ouPartial");
- var q = s.get(uid);
- q.onsuccess = function(e){
- deferred.resolve(e.target.result);
- };
- }
- };
- }
- return deferred.promise;
- };
-
- return {
- open: open,
- get: get
- };
-})
-
/* Factory for fetching OrgUnit */
.factory('OrgUnitFactory', function($http, SessionStorageService) {
var orgUnit, orgUnitPromise, rootOrgUnitPromise;
@@ -1516,56 +1458,53 @@
angular.forEach(atts, function(att){
attributes[att.id] = att;
});
-
- OrgUnitService.open().then(function(){
-
- angular.forEach(grid.rows, function(row){
- if(invalidTeis.indexOf(row[0]) === -1 ){
- var entity = {};
- var isEmpty = true;
-
- entity.id = row[0];
- entity.created = DateUtils.formatFromApiToUser( row[1] );
- entity.orgUnit = row[3];
- entity.type = row[4];
- entity.inactive = row[5] !== "" ? row[5] : false;
-
- OrgUnitService.get(row[3]).then(function(ou){
- if(ou){
- entity.orgUnitName = ou.n;
- }
- });
-
- for(var i=6; i<row.length; i++){
- if(row[i] && row[i] !== ''){
- isEmpty = false;
- var val = row[i];
-
- if(attributes[grid.headers[i].name] &&
- attributes[grid.headers[i].name].optionSetValue &&
- optionSets &&
- attributes[grid.headers[i].name].optionSet &&
- optionSets[attributes[grid.headers[i].name].optionSet.id] ){
- val = OptionSetService.getName(optionSets[attributes[grid.headers[i].name].optionSet.id].options, val);
- }
- if(attributes[grid.headers[i].name] && attributes[grid.headers[i].name].valueType === 'date'){
- val = DateUtils.formatFromApiToUser( val );
- }
-
- entity[grid.headers[i].name] = val;
- }
- }
-
- if(!isEmpty){
- if(map){
- entityList[entity.id] = entity;
- }
- else{
- entityList.push(entity);
- }
- }
- }
- });
+
+ angular.forEach(grid.rows, function(row){
+ if(invalidTeis.indexOf(row[0]) === -1 ){
+ var entity = {};
+ var isEmpty = true;
+
+ entity.id = row[0];
+ entity.created = DateUtils.formatFromApiToUser( row[1] );
+ entity.orgUnit = row[3];
+ entity.type = row[4];
+ entity.inactive = row[5] !== "" ? row[5] : false;
+
+ OrgUnitService.get(row[3]).then(function(ou){
+ if(ou && ou.name){
+ entity.orgUnitName = ou.name;
+ }
+ });
+
+ for(var i=6; i<row.length; i++){
+ if(row[i] && row[i] !== ''){
+ isEmpty = false;
+ var val = row[i];
+
+ if(attributes[grid.headers[i].name] &&
+ attributes[grid.headers[i].name].optionSetValue &&
+ optionSets &&
+ attributes[grid.headers[i].name].optionSet &&
+ optionSets[attributes[grid.headers[i].name].optionSet.id] ){
+ val = OptionSetService.getName(optionSets[attributes[grid.headers[i].name].optionSet.id].options, val);
+ }
+ if(attributes[grid.headers[i].name] && attributes[grid.headers[i].name].valueType === 'date'){
+ val = DateUtils.formatFromApiToUser( val );
+ }
+
+ entity[grid.headers[i].name] = val;
+ }
+ }
+
+ if(!isEmpty){
+ if(map){
+ entityList[entity.id] = entity;
+ }
+ else{
+ entityList.push(entity);
+ }
+ }
+ }
});
});
return {headers: attributes, rows: entityList, pager: grid.metaData.pager};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-09-11 12:20:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-09-17 11:21:04 +0000
@@ -18,6 +18,7 @@
var attributesInPromise = [];
dhis2.tc.store = null;
+dhis2.tc.metaDataCached = false;
dhis2.tc.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
var adapters = [];
if( dhis2.tc.memoryOnly ) {
@@ -154,7 +155,8 @@
promise = promise.then( getTrackedEntityAttributeGroups );
promise.done(function() {
//Enable ou selection after meta-data has downloaded
- $( "#orgUnitTree" ).removeClass( "disable-clicks" );
+ $( "#orgUnitTree" ).removeClass( "disable-clicks" );
+ dhis2.tc.metaDataCached = true;
console.log( 'Finished loading meta-data' );
selection.responseReceived();
});
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2015-09-16 14:17:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2015-09-17 11:21:04 +0000
@@ -27,26 +27,7 @@
});
</script>
-<div id="leftBar">
-
- <div class="left-bar-menu" ng-controller="LeftBarMenuController">
- <ul class="nav nav-pills nav-stacked">
- <li><a href ng-click="showHome()">{{'registration_and_data_entry' | translate}}</a></li>
- <li><a href ng-click="showReportTypes()">{{'reports' | translate}}</a></li>
- </ul>
- </div>
-
- <d2-ou-search></d2-ou-search>
-
- <div id="orgUnitTree">
- <ul>
- </ul>
- </div>
- <img id="ouwt_loader" src="../images/ajax-loader-bar.gif" alt="{{'loading_tree'| translate}}"/>
- <div class="small-horizonal-spacing" ng-if='!treeLoaded'>
- {{'loading_tree'| translate}}
- </div>
-</div>
+<d2-left-bar></d2-left-bar>
<div class="page" id="mainPage">
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js 2015-09-16 14:17:44 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js 2015-09-17 11:21:04 +0000
@@ -23,17 +23,36 @@
};
})
-.directive('d2OuSearch', function () {
+.directive('d2LeftBar', function () {
return {
restrict: 'E',
- template: '<div style="margin-top:20px">\n\
- <img id="searchIcon" src="../images/search.png" style="cursor: pointer" title="{{ searchOusLabel}}">\n\
+ template: '<span id="showLeftBar">\n\
+ <a href="javascript:dhis2.leftBar.showAnimated()" title="$i18n.getString(\'show_menu\' )">\n\
+ <i class="fa fa-arrow-right leftBarIcon"></i></a>\n\
+ </span>\n\
+ <div id="leftBar">\n\
+ <div id="hideLeftBar">\n\
+ <a href="index.action" title="{{\'show_main_menu\' | translate}}" id="showMainMenuLink"><i class="fa fa-home leftBarIcon"></i></a>\n\
+ <a href="javascript:dhis2.leftBar.hideAnimated()" title="{{\'hide_menu\' | translate}}" id="hideMainMenuLink"><i class="fa fa-arrow-left leftBarIcon"></i></a>\n\
+ <a href="javascript:dhis2.leftBar.extendAnimated()" title="{{\'extend_menu\' | translate}}" id="extendMainMenuLink"><i class="fa fa-arrow-right leftBarIcon"></i></a>\n\
+ </div>\n\
+ <div style="margin-top:20px">\n\
+ <img id="searchIcon" src="../images/search.png" style="cursor: pointer" title="{{searchOusLabel}}">\n\
<span id="searchSpan" style="width:100%;display:none;">\n\
- <input type="text" id="searchField" name="key"/>\n\
- <input type="button" value="{{findLabel}}" onclick="selection.findByName()"/>\n\
+ <input type="text" id="searchField" name="key"/>\n\
+ <input type="button" value="{{findLabel}}" onclick="selection.findByName()"/>\n\
</span>\n\
- </div>',
+ </div>\n\
+ <div id="orgUnitTree">\n\
+ <ul>\n\
+ </ul>\n\
+ </div>\n\
+ <img id="ouwt_loader" src="../images/ajax-loader-bar.gif"/>\n\
+ <div class="small-horizonal-spacing" ng-if="!treeLoaded">\n\
+ {{\'loading_tree\'| translate}}\n\
+ </div>\n\
+ </div>',
link: function (scope, element, attrs) {
$("#searchIcon").click(function () {
@@ -52,35 +71,45 @@
};
})
-.directive('selectedOrgUnit', function ($timeout) {
-
+.directive('selectedOrgUnit', function ($timeout, OrgUnitService, SessionStorageService) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
-
//once ou tree is loaded, start meta-data download
$(function () {
dhis2.ou.store.open().done(function () {
- selection.load();
- $("#orgUnitTree").one("ouwtLoaded", function (event, ids, names) {
- console.log('Finished loading orgunit tree');
-
- //Disable ou selection until meta-data has downloaded
- $("#orgUnitTree").addClass("disable-clicks");
-
- $timeout(function () {
- scope.treeLoaded = true;
- scope.$apply();
- });
-
- downloadMetaData();
- });
+ selection.load();
+ if(dhis2.tc && dhis2.tc.metaDataCached){
+ var ouId = SessionStorageService.get('ouSelected');
+ OrgUnitService.get(ouId).then(function(ou){
+ if(ou && ou.id && ou.name){
+ $timeout(function () {
+ scope.selectedOrgUnit = ou;
+ scope.treeLoaded = true;
+ scope.$apply();
+ });
+ }
+ });
+ }
+ else{
+ $("#orgUnitTree").one("ouwtLoaded", function (event, ids, names) {
+ console.log('Finished loading orgunit tree');
+ //Disable ou selection until meta-data has downloaded
+ $("#orgUnitTree").addClass("disable-clicks");
+
+ $timeout(function () {
+ scope.treeLoaded = true;
+ scope.$apply();
+ });
+
+ downloadMetaData();
+ });
+ }
});
});
//listen to user selection, and inform angular
selection.setListenerFunction(setSelectedOu, true);
-
function setSelectedOu(ids, names) {
var ou = {id: ids[0], name: names[0]};
$timeout(function () {
=== 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-17 09:03:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-09-17 11:21:04 +0000
@@ -242,6 +242,25 @@
};
})
+/*Orgunit service for local db */
+.service('OrgUnitService', function($rootScope, $q){
+
+ return {
+ get: function(uid){
+ var def = $q.defer();
+ selection.getOrganisationUnit(uid).then(function(response){
+ var ou = response && response[uid] && response[uid].n ? {id: uid, name: response[uid].n} : null;
+ $rootScope.$apply(function(){
+ def.resolve(ou);
+ });
+ }, function(){
+ def.resolve(null);
+ });
+ return def.promise;
+ }
+ };
+})
+
/* service for common utils */
.service('CommonUtils', function(DateUtils, OptionSetService){