← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19188: PT data approval level implemented.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 19188 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-05-27 15:59:05 +0200
message:
  PT data approval level implemented.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/i18n_app.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.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-pivot/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/i18n_app.properties	2015-05-04 11:27:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/i18n_app.properties	2015-05-27 13:46:35 +0000
@@ -193,3 +193,5 @@
 username=Username
 error=Error
 warning=Warning
+approval_level=Approval level
+show_all_data=Show all data

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2015-05-13 15:44:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2015-05-27 13:46:35 +0000
@@ -514,6 +514,7 @@
 			showDimensionLabels,
 			hideEmptyRows,
             aggregationType,
+            dataApprovalLevel,
 			showHierarchy,
 			digitGroupSeparator,
 			displayDensity,
@@ -592,6 +593,37 @@
 			})
 		});
 
+		dataApprovalLevel = Ext.create('Ext.form.field.ComboBox', {
+			cls: 'ns-combo',
+			style: 'margin-bottom:' + comboBottomMargin + 'px',
+			width: comboboxWidth,
+			labelWidth: 130,
+			fieldLabel: NS.i18n.approval_level,
+			labelStyle: 'color:#333',
+			queryMode: 'local',
+			valueField: 'id',
+			displayField: 'name',
+			editable: false,
+			hidden: !(ns.core.init.systemInfo.hideUnapprovedDataInAnalytics && ns.core.init.user.viewUnapprovedData),
+			value: 'DEFAULT',
+			store: Ext.create('Ext.data.Store', {
+				fields: ['id', 'name'],
+				data: function() {
+					var data = [{id: 'DEFAULT', name: NS.i18n.show_all_data}],
+						levels = ns.core.init.dataApprovalLevels;
+
+					for (var i = 0; i < levels.length; i++) {
+						data.push({
+							id: levels[i].id,
+							name: 'Data approved at ' + levels[i].name
+						});
+					}
+
+					return data;
+				}()
+			})
+		});
+
 		showHierarchy = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.show_hierarchy,
 			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
@@ -754,7 +786,8 @@
                 showRowSubTotals,
                 showDimensionLabels,
 				hideEmptyRows,
-                aggregationType
+                aggregationType,
+                dataApprovalLevel
 			]
 		};
 
@@ -809,6 +842,7 @@
                     showDimensionLabels: showDimensionLabels.getValue(),
 					hideEmptyRows: hideEmptyRows.getValue(),
                     aggregationType: aggregationType.getValue(),
+                    dataApprovalLevel: {id: dataApprovalLevel.getValue()},
 					showHierarchy: showHierarchy.getValue(),
 					displayDensity: displayDensity.getValue(),
 					fontSize: fontSize.getValue(),
@@ -831,6 +865,7 @@
 				showDimensionLabels.setValue(Ext.isBoolean(layout.showDimensionLabels) ? layout.showDimensionLabels : true);
 				hideEmptyRows.setValue(Ext.isBoolean(layout.hideEmptyRows) ? layout.hideEmptyRows : false);
                 aggregationType.setValue(Ext.isString(layout.aggregationType) ? layout.aggregationType : 'DEFAULT');
+				dataApprovalLevel.setValue(Ext.isObject(layout.dataApprovalLevel) && Ext.isString(layout.dataApprovalLevel.id) ? layout.dataApprovalLevel.id : 'DEFAULT');
 				showHierarchy.setValue(Ext.isBoolean(layout.showHierarchy) ? layout.showHierarchy : false);
 				displayDensity.setValue(Ext.isString(layout.displayDensity) ? layout.displayDensity : 'normal');
 				fontSize.setValue(Ext.isString(layout.fontSize) ? layout.fontSize : 'normal');
@@ -946,6 +981,7 @@
                     w.showDimensionLabels = showDimensionLabels;
 					w.hideEmptyRows = hideEmptyRows;
                     w.aggregationType = aggregationType;
+                    w.dataApprovalLevel = dataApprovalLevel;
 					w.showHierarchy = showHierarchy;
 					w.displayDensity = displayDensity;
 					w.fontSize = fontSize;
@@ -6732,12 +6768,13 @@
 
                         // date, calendar
                         Ext.Ajax.request({
-                            url: init.contextPath + '/api/systemSettings.json?key=keyCalendar&key=keyDateFormat&key=keyAnalysisRelativePeriod',
+                            url: init.contextPath + '/api/systemSettings.json?key=keyCalendar&key=keyDateFormat&key=keyAnalysisRelativePeriod&key=keyHideUnapprovedDataInAnalytics',
                             success: function(r) {
                                 var systemSettings = Ext.decode(r.responseText);
                                 init.systemInfo.dateFormat = Ext.isString(systemSettings.keyDateFormat) ? systemSettings.keyDateFormat.toLowerCase() : 'yyyy-mm-dd';
                                 init.systemInfo.calendar = systemSettings.keyCalendar;
                                 init.systemInfo.analysisRelativePeriod = systemSettings.keyAnalysisRelativePeriod || 'LAST_12_MONTHS';
+                                init.systemInfo.hideUnapprovedDataInAnalytics = systemSettings.keyHideUnapprovedDataInAnalytics;
 
                                 // user-account
                                 Ext.Ajax.request({
@@ -6834,6 +6871,16 @@
                                             }
                                         });
 
+                                        // authorization
+                                        requests.push({
+                                            url: init.contextPath + '/api/me/authorization/F_VIEW_UNAPPROVED_DATA',
+                                            success: function(r) {
+												init.user = init.user || {};
+                                                init.user.viewUnapprovedData = (r.responseText === 'true');
+                                                fn();
+                                            }
+                                        });
+
                                         // root nodes
                                         requests.push({
                                             url: contextPath + '/api/organisationUnits.json?userDataViewFallback=true&paging=false&fields=id,' + namePropertyUrl + ',children[id,' + namePropertyUrl + ']',
@@ -6906,6 +6953,15 @@
                                             }
                                         });
 
+                                        // approval levels
+                                        requests.push({
+                                            url: contextPath + '/api/dataApprovalLevels.json?fields=id,name&paging=false',
+                                            success: function(r) {
+                                                init.dataApprovalLevels = Ext.decode(r.responseText).dataApprovalLevels || [];
+                                                fn();
+                                            }
+                                        });
+
                                         for (var i = 0; i < requests.length; i++) {
                                             Ext.Ajax.request(requests[i]);
                                         }

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js	2015-05-05 15:14:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js	2015-05-27 13:46:35 +0000
@@ -363,6 +363,8 @@
 
                 // aggregationType: string ('DEFAULT') - 'DEFAULT', 'COUNT', 'SUM', 'STDDEV', 'VARIANCE', 'MIN', 'MAX'
 
+                // dataApprovalLevel: object
+
 				// showHierarchy: boolean (false)
 
 				// displayDensity: string ('normal') - 'compact', 'normal', 'comfortable'
@@ -539,6 +541,7 @@
 					layout.showDimensionLabels = Ext.isBoolean(config.showDimensionLabels) ? config.showDimensionLabels : (Ext.isBoolean(config.showDimensionLabels) ? config.showDimensionLabels : true);
 					layout.hideEmptyRows = Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : false;
                     layout.aggregationType = Ext.isString(config.aggregationType) ? config.aggregationType : 'DEFAULT';
+					layout.dataApprovalLevel = Ext.isObject(config.dataApprovalLevel) && Ext.isString(config.dataApprovalLevel.id) ? config.dataApprovalLevel : null;
 
 					layout.showHierarchy = Ext.isBoolean(config.showHierarchy) ? config.showHierarchy : false;
 
@@ -1753,6 +1756,10 @@
 					delete layout.aggregationType;
 				}
 
+				if (layout.dataApprovalLevel && layout.dataApprovalLevel.id === 'DEFAULT') {
+					delete layout.dataApprovalLevel;
+				}
+
 				delete layout.parentGraphMap;
 				delete layout.reportingPeriod;
 				delete layout.organisationUnit;
@@ -2131,6 +2138,11 @@
 					paramString += '&userOrganisationUnit=' + xLayout.userOrganisationUnit;
 				}
 
+				// data approval level
+				if (Ext.isObject(xLayout.dataApprovalLevel) && Ext.isString(xLayout.dataApprovalLevel.id) && xLayout.dataApprovalLevel.id !== 'DEFAULT') {
+					paramString += '&approvalLevel=' + xLayout.dataApprovalLevel.id;
+				}
+
 				return paramString;
 			};