------------------------------------------------------------ revno: 19504 committer: Abyot Asalefew Gizaw <aby...@gmail.com> branch nick: dhis2 timestamp: Tue 2015-06-23 21:48:46 +0200 message: tracker-capture: authorized users can now set default dashboard layout (per program) applicable for all usres. For more flexibility users can also set their own dashabord layout per program. removed: dhis-2/dhis-services/dhis-service-sms/ dhis-2/dhis-services/dhis-service-sms/bin/ 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/dashboard/dashboard.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties
-- 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
=== removed directory 'dhis-2/dhis-services/dhis-service-sms' === removed directory 'dhis-2/dhis-services/dhis-service-sms/bin' === 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-06-23 13:17:50 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-06-23 19:48:46 +0000 @@ -19,12 +19,13 @@ DHIS2EventFactory, DashboardLayoutService, AttributesFactory, - CurrentSelection) { + CurrentSelection, + AuthorityService) { //selections $scope.selectedTeiId = ($location.search()).tei; $scope.selectedProgramId = ($location.search()).program; $scope.selectedOrgUnit = SessionStorageService.get('SELECTED_OU'); - + $scope.userAuthority = AuthorityService.getUserAuthorities(SessionStorageService.get('USER_ROLES')); $scope.sortedTeiIds = CurrentSelection.getSortedTeiIds(); $scope.previousTeiExists = false; @@ -64,12 +65,13 @@ $scope.orderChanged = false; DashboardLayoutService.get().then(function(response){ - $scope.dashboardLayouts = response; - - var selectedLayout = $scope.dashboardLayouts ['DEFAULT']; - if($scope.selectedProgram && $scope.selectedProgram.id){ - selectedLayout = $scope.dashboardLayouts [$scope.selectedProgram.id] ? $scope.dashboardLayouts [$scope.selectedProgram.id] : selectedLayout; - } + $scope.dashboardLayouts = response; + var defaultLayout = $scope.dashboardLayouts.defaultLayout['DEFAULT']; + var selectedLayout = null; + if($scope.selectedProgram && $scope.selectedProgram.id){ + selectedLayout = $scope.dashboardLayouts.customLayout && $scope.dashboardLayouts.customLayout[$scope.selectedProgram.id] ? $scope.dashboardLayouts.customLayout[$scope.selectedProgram.id] : $scope.dashboardLayouts.defaultLayout[$scope.selectedProgram.id]; + } + selectedLayout = !selectedLayout ? defaultLayout : selectedLayout; angular.forEach(selectedLayout.widgets, function(widget){ switch(widget.title){ @@ -238,6 +240,48 @@ $scope.applySelectedProgram(); }); + function getCurrentDashboardLayout(){ + var widgets = []; + $scope.hasBigger = false; + $scope.hasSmaller = false; + angular.forEach($rootScope.dashboardWidgets, function(widget){ + var w = angular.copy(widget); + if($scope.orderChanged){ + if($scope.widgetsOrder.biggerWidgets.indexOf(w.title) !== -1){ + $scope.hasBigger = $scope.hasBigger || w.show; + w.parent = 'biggerWidget'; + w.order = $scope.widgetsOrder.biggerWidgets.indexOf(w.title); + } + + if($scope.widgetsOrder.smallerWidgets.indexOf(w.title) !== -1){ + $scope.hasSmaller = $scope.hasSmaller || w.show; + w.parent = 'smallerWidget'; + w.order = $scope.widgetsOrder.smallerWidgets.indexOf(w.title); + } + } + widgets.push(w); + }); + var layout = {}; + if($scope.selectedProgram && $scope.selectedProgram.id){ + layout[$scope.selectedProgram.id] = {widgets: widgets, program: $scope.selectedProgram.id}; + } + else{ + layout['DEFAULT'] = {widgets: widgets, program: 'DEFAULT'}; + } + return layout; + } + + function saveDashboardLayout(){ + var layout = getCurrentDashboardLayout(); + DashboardLayoutService.saveLayout(layout, false).then(function(){ + if(!$scope.orderChanged){ + $scope.hasSmaller = $filter('filter')($scope.dashboardWidgets, {parent: "smallerWidget", show: true}).length > 0; + $scope.hasBigger = $filter('filter')($scope.dashboardWidgets, {parent: "biggerWidget", show: true}).length > 0; + } + setWidgetsSize(); + }); + }; + //watch for widget sorting $scope.$watch('widgetsOrder', function() { if(angular.isObject($scope.widgetsOrder)){ @@ -304,41 +348,14 @@ saveDashboardLayout();; }; - var saveDashboardLayout = function(){ - var widgets = []; - $scope.hasBigger = false; - $scope.hasSmaller = false; - angular.forEach($rootScope.dashboardWidgets, function(widget){ - var w = angular.copy(widget); - if($scope.orderChanged){ - if($scope.widgetsOrder.biggerWidgets.indexOf(w.title) !== -1){ - $scope.hasBigger = $scope.hasBigger || w.show; - w.parent = 'biggerWidget'; - w.order = $scope.widgetsOrder.biggerWidgets.indexOf(w.title); - } - - if($scope.widgetsOrder.smallerWidgets.indexOf(w.title) !== -1){ - $scope.hasSmaller = $scope.hasSmaller || w.show; - w.parent = 'smallerWidget'; - w.order = $scope.widgetsOrder.smallerWidgets.indexOf(w.title); - } - } - widgets.push(w); - }); - - if($scope.selectedProgram && $scope.selectedProgram.id){ - $scope.dashboardLayouts[$scope.selectedProgram.id] = {widgets: widgets, program: $scope.selectedProgram.id}; - } - - DashboardLayoutService.saveLayout($scope.dashboardLayouts).then(function(){ - if(!$scope.orderChanged){ - $scope.hasSmaller = $filter('filter')($scope.dashboardWidgets, {parent: "smallerWidget", show: true}).length > 0; - $scope.hasBigger = $filter('filter')($scope.dashboardWidgets, {parent: "biggerWidget", show: true}).length > 0; - } - setWidgetsSize(); + $scope.saveDashboarLayoutAsDefault = function(){ + var layout = angular.copy($scope.dashboardLayouts.defaultLayout); + var currentLayout = getCurrentDashboardLayout(); + angular.extend(layout, currentLayout); + delete layout.DEFAULT; + DashboardLayoutService.saveLayout(layout, true).then(function(){ }); }; - $scope.showHideWidgets = function(){ var modalInstance = $modal.open({ templateUrl: "components/dashboard/dashboard-widgets.html", === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html 2015-06-10 11:55:41 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard.html 2015-06-23 19:48:46 +0000 @@ -22,6 +22,7 @@ </button> <ul class="dropdown-menu pull-right" role="menu"> <li><a href ng-click="showHideWidgets()">{{'show_hide_widgets'| translate}}</a></li> + <li ng-if="userAuthority.canAdministerDashboard"><a href ng-click="saveDashboarLayoutAsDefault()">{{'save_layout_as_default'| translate}}</a></li> </ul> </div> </div> === 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-06-23 13:17:50 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties 2015-06-23 19:48:46 +0000 @@ -330,4 +330,5 @@ oct=October nov=November dec=December -week=Week \ No newline at end of file +week=Week +save_layout_as_default=Save dashboard layout as default \ 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-06-23 13:17:50 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-06-23 19:48:46 +0000 @@ -20,6 +20,7 @@ /* Service to fetch/store dasboard widgets */ .service('DashboardLayoutService', function($http) { + var w = {}; w.enrollmentWidget = {title: 'enrollment', view: "components/enrollment/enrollment.html", show: true, expand: true, parent: 'biggerWidget', order: 0}; w.indicatorWidget = {title: 'indicators', view: "components/rulebound/rulebound.html", show: true, expand: true, parent: 'biggerWidget', order: 1}; @@ -33,19 +34,34 @@ var defaultLayout = new Object(); defaultLayout['DEFAULT'] = {widgets: w, program: 'DEFAULT'}; + var getDefaultLayout = function(customLayout){ + var dashboardLayout = {customLayout: customLayout, defaultLayout: defaultLayout}; + var promise = $http.get( '../api/systemSettings/keyTrackerDashboardDefaultLayout' ).then(function(response){ + angular.extend(dashboardLayout.defaultLayout, response.data); + return dashboardLayout; + }, function(){ + return dashboardLayout; + }); + return promise; + }; + return { - saveLayout: function(dashboardLayout){ + saveLayout: function(dashboardLayout, saveAsDefault){ var layout = JSON.stringify(dashboardLayout); - var promise = $http.post( '../api/userSettings/dhis2-tracker-dashboard?value=' + layout, '', {headers: {'Content-Type': 'text/plain;charset=utf-8'}}).then(function(response){ + var url = '../api/userSettings/keyTrackerDashboardLayout?value='; + if(saveAsDefault){ + url = '../api/systemSettings/keyTrackerDashboardDefaultLayout?value='; + } + var promise = $http.post( url + layout, '', {headers: {'Content-Type': 'text/plain;charset=utf-8'}}).then(function(response){ return response.data; }); return promise; }, - get: function(){ - var promise = $http.get( '../api/userSettings/dhis2-tracker-dashboard' ).then(function(response){ - return response.data === "" ? defaultLayout : response.data; + get: function(){ + var promise = $http.get( '../api/userSettings/keyTrackerDashboardLayout' ).then(function(response){ + return getDefaultLayout(response.data); }, function(){ - return defaultLayout; + return getDefaultLayout(null); }); return promise; } === 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-06-22 12:07:24 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-06-23 19:48:46 +0000 @@ -93,6 +93,7 @@ authority.canRegisterTei = auth['F_TRACKED_ENTITY_INSTANCE_ADD'] || auth['ALL'] ? true : false; authority.canEnrollTei = auth['F_PROGRAM_ENROLLMENT'] || auth['ALL'] ? true : false; authority.canUnEnrollTei = auth['F_PROGRAM_UNENROLLMENT'] || auth['ALL'] ? true : false; + authority.canAdministerDashboard = auth['F_PROGRAM_DASHBOARD_CONFIG_ADMIN'] || auth['ALL'] ? true : false; return authority; } }; === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml 2015-06-23 04:12:17 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml 2015-06-23 19:48:46 +0000 @@ -377,6 +377,7 @@ <value>F_USER_ADD_WITHIN_MANAGED_GROUP</value> <value>F_USER_GROUPS_READ_ONLY_ADD_MEMBERS</value> <value>F_OAUTH2_CLIENT_MANAGE</value> + <value>F_PROGRAM_DASHBOARD_CONFIG_ADMIN</value> </set> </property> </bean> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2015-04-11 13:18:25 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2015-06-23 19:48:46 +0000 @@ -285,6 +285,7 @@ F_PROGRAM_RULE_MANAGEMENT = Manage Program Rule F_PROGRAM_RULE_ADD = Add Program Rule F_PROGRAM_RULE_UPDATE = Update Program Rule +F_PROGRAM_DASHBOARD_CONFIG_ADMIN=Administer program dashboard configuration #-- FRED API module -----------------------------------------------------------#
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp