← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21992: Approval, UI fix

 

------------------------------------------------------------
revno: 21992
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-02-17 16:16:20 -0500
message:
  Approval, UI fix
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.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-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2016-02-17 19:02:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2016-02-17 21:16:20 +0000
@@ -318,8 +318,10 @@
 /**
  * Gets an approval payload object based on the given state.
  * @param ui the ui state.
+ * @param permissionProperty name of permission property which must be
+ *        true for the approval record to be included.
  */
-dhis2.appr.getApprovalPayload = function( ui ) {
+dhis2.appr.getApprovalPayload = function( ui, permissionProperty ) {
 	
 	var json = {
 		ds: [ui.ds],
@@ -328,10 +330,13 @@
 	};
 	
 	$.each( ui.approvals, function( inx, ap ) {
-		json.approvals.push( {
-			ou: ap.ou,
-			aoc: ap.aoc
-		} );
+		
+		if ( ap.permissions && ap.permissions[permissionProperty] ) {
+			json.approvals.push( {
+				ou: ap.ou,
+				aoc: ap.aoc
+			} );
+		}
 	} );
 	
 	return json;
@@ -617,7 +622,7 @@
 	
 	var ui = dhis2.appr.getUiState(),
 		ds = dhis2.appr.dataSets[ui.ds],
-		json = dhis2.appr.getApprovalPayload( ui );
+		json = dhis2.appr.getApprovalPayload( ui, "mayApprove" );
 	
 	if ( ds.hasCategoryCombo ) {
 		$.ajax( {
@@ -658,7 +663,7 @@
 
 	var ui = dhis2.appr.getUiState(),
 		ds = dhis2.appr.dataSets[ui.ds],
-		json = dhis2.appr.getApprovalPayload( ui );
+		json = dhis2.appr.getApprovalPayload( ui, "mayUnapprove" );
 	
 	if ( ds.hasCategoryCombo ) {
 		$.ajax( {
@@ -699,7 +704,7 @@
 
 	var ui = dhis2.appr.getUiState(),
 		ds = dhis2.appr.dataSets[ui.ds],
-		json = dhis2.appr.getApprovalPayload( ui );
+		json = dhis2.appr.getApprovalPayload( ui, "mayAccept" );
 	
 	if ( ds.hasCategoryCombo ) {
 		$.ajax( {
@@ -740,7 +745,7 @@
 
 	var ui = dhis2.appr.getUiState(),
 		ds = dhis2.appr.dataSets[ui.ds],
-		json = dhis2.appr.getApprovalPayload( ui );
+		json = dhis2.appr.getApprovalPayload( ui, "mayUnaccept" );
 		
 	if ( ds.hasCategoryCombo ) {
 		$.ajax( {