← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14619: Codestyle

 

------------------------------------------------------------
revno: 14619
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-04-02 18:21:34 +0200
message:
  Codestyle
modified:
  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/dataSetReport.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	2014-04-02 15:49:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2014-04-02 16:21:34 +0000
@@ -2,6 +2,11 @@
 dhis2.util.namespace( 'dhis2.appr' );
 
 dhis2.appr.currentPeriodOffset = 0;
+dhis2.appr.permissions = null;
+
+//------------------------------------------------------------------------------
+// Report
+//------------------------------------------------------------------------------
 
 dhis2.appr.dataSetSelected = function()
 {
@@ -28,3 +33,236 @@
     dhis2.appr.currentPeriodOffset--;
     dhis2.appr.displayPeriods();
 }
+
+//------------------------------------------------------------------------------
+// Approval
+//------------------------------------------------------------------------------
+
+/**
+ * Generates the URL for the approval of the given data set report.
+ */
+dhis2.appr.getDataApprovalUrl = function( dataSetReport )
+{
+    var url = "../api/dataApprovals" +
+        "?ds=" + dataSetReport.ds +
+        "&pe=" + dataSetReport.pe +
+        "&ou=" + dataSetReport.ou;
+
+    return url;
+}
+
+/**
+ * Generates the URL for the acceptance of the given data set report approval.
+ */
+dhis2.appr.getDataApprovalAcceptanceUrl = function( dataSetReport )
+{
+    var url = "../api/dataApprovals/acceptances" +
+        "?ds=" + dataSetReport.ds +
+        "&pe=" + dataSetReport.pe +
+        "&ou=" + dataSetReport.ou;
+
+    return url;
+}
+
+dhis2.appr.showApproval = function()
+{
+	var dataSetReport = dhis2.dsr.getDataSetReport();
+	
+	var approval = $( "#dataSetId :selected" ).data( "approval" );
+
+	$( "#approvalNotification" ).hide();
+    $( "#approvalDiv" ).hide();
+
+	if ( !approval ) {
+		return;
+	}
+	
+	var url = dhis2.appr.getDataApprovalUrl( dataSetReport );
+	
+	$.getJSON( url, function( json ) {
+	
+	if ( !json || !json.state ) {
+		return;
+	}
+
+	dhis2.appr.permissions = json;
+		
+	var state = json.state;
+
+    $( "#approveButton" ).hide();
+    $( "#unapproveButton" ).hide();
+    $( "#acceptButton" ).hide();
+    $( "#unacceptButton" ).hide();
+
+    switch (state) {
+    case "UNAPPROVED_WAITING":
+        $("#approvalNotification").show().html(i18n_waiting_for_lower_level_approval);
+        break;
+
+    case "UNAPPROVED_READY":
+        $("#approvalNotification").show().html(i18n_ready_for_approval);
+        
+        if (json.mayApprove) {
+            $("#approvalDiv").show();
+            $("#approveButton").show();
+        }
+        
+        break;
+
+    case "APPROVED_HERE":
+        $("#approvalNotification").show().html(i18n_approved);
+        
+        if (json.mayUnapprove)  {
+            $("#approvalDiv").show();
+            $("#unapproveButton").show();
+        }
+        
+        if (json.mayAccept)  {
+            $("#approvalDiv").show();
+            $("#acceptButton").show();
+        }
+        
+        break;
+
+    case "ACCEPTED_HERE":
+        $("#approvalNotification").show().html(i18n_approved);
+        
+        if (json.mayUnapprove)  {
+            $("#approvalDiv").show();
+            $("#unapproveButton").show();
+        }
+        
+        if (json.mayUnccept)  {
+            $("#approvalDiv").show();
+            $("#unacceptButton").show();
+        }
+        
+        break;
+    }
+    });	
+}
+
+dhis2.appr.approveData = function()
+{
+	if ( !confirm( i18n_confirm_approval ) ) {
+		return false;
+	}
+	
+	var dataSetReport = dhis2.dsr.getDataSetReport();
+	var url = dhis2.appr.getDataApprovalUrl( dataSetReport );
+	
+	$.ajax( {
+		url: url,
+		type: "post",
+		success: function() {
+            $( "#approvalNotification" ).show().html( i18n_approved );
+            $( "#approvalDiv" ).hide();
+			$( "#approveButton" ).hide();
+            if ( dhis2.appr.permissions.mayUnapprove ) {
+                $( "#approvalDiv" ).show();
+                $( "#unapproveButton" ).show();
+            }
+            if ( dhis2.appr.permissions.mayAccept ) {
+                $( "#approvalDiv" ).show();
+                $( "#acceptButton" ).show();
+            }
+		},
+		error: function( xhr, status, error ) {
+			alert( xhr.responseText );
+		}
+	} );
+}
+
+dhis2.appr.unapproveData = function()
+{
+	if ( !confirm( i18n_confirm_unapproval ) ) {
+		return false;
+	}
+	
+	var dataSetReport = dhis2.dsr.getDataSetReport();
+	var url = dhis2.appr.getDataApprovalUrl( dataSetReport );
+	
+	$.ajax( {
+		url: url,
+		type: "delete",
+		success: function() {
+            $( "#approvalNotification" ).show().html( i18n_ready_for_approval );
+            $( "#approvalDiv" ).hide();
+            $( "#unapproveButton" ).hide();
+            $( "#acceptButton" ).hide();
+            $( "#unacceptButton" ).hide();
+            
+            if ( dhis2.appr.permissions.mayApprove ) {
+                $( "#approvalDiv" ).show();
+                $( "#approveButton" ).show();
+            }
+		},
+		error: function( xhr, status, error ) {
+			alert( xhr.responseText );
+		}
+	} );
+}
+
+dhis2.appr.acceptData = function()
+{
+  if ( !confirm( i18n_confirm_accept ) ) {
+      return false;
+  }
+
+  var dataSetReport = dhis2.dsr.getDataSetReport();
+  var url = dhis2.appr.getDataApprovalAcceptanceUrl( dataSetReport );
+
+  $.ajax( {
+      url: url,
+      type: "post",
+      success: function() {
+          $( "#approvalNotification" ).show().html( i18n_approved_and_accepted );
+          $( "#approvalDiv" ).hide();
+          $( "#acceptButton" ).hide();
+          
+          if ( dhis2.appr.permissions.mayUnapprove ) {
+              $( "#approvalDiv" ).show();
+              $( "#unapproveButton" ).show();
+          }
+          
+          if ( dhis2.appr.permissions.mayUnaccept ) {
+              $( "#approvalDiv" ).show();
+              $( "#unacceptButton" ).show();
+          }
+      },
+      error: function( xhr, status, error ) {
+          alert( xhr.responseText );
+      }
+  } );
+}
+
+dhis2.appr.unacceptData = function()
+{
+    if ( !confirm( i18n_confirm_unaccept ) ) {
+        return false;
+    }
+
+    var dataSetReport = dhis2.dsr.getDataSetReport();
+    var url = dhis2.appr.getDataApprovalAcceptanceUrl( dataSetReport );
+
+    $.ajax( {
+        url: url,
+        type: "delete",
+        success: function() {
+            $( "#approvalNotification" ).show().html( i18n_approved );
+            $( "#approvalDiv" ).hide();
+            $( "#unacceptButton" ).hide();
+            if ( dhis2.appr.permissions.mayUnapprove ) {
+                $( "#approvalDiv" ).show();
+                $( "#unapproveButton" ).show();
+            }
+            if ( dhis2.appr.permissions.mayAccept ) {
+                $( "#approvalDiv" ).show();
+                $( "#acceptButton" ).show();
+            }
+        },
+        error: function( xhr, status, error ) {
+            alert( xhr.responseText );
+        }
+  } );
+}

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2014-04-02 16:07:27 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2014-04-02 16:21:34 +0000
@@ -7,7 +7,6 @@
 dhis2.dsr.currentPeriodOffset = 0;
 dhis2.dsr.periodTypeFactory = new PeriodType();
 dhis2.dsr.currentDataSetReport = null;
-dhis2.dsr.permissions = null;
 
 //------------------------------------------------------------------------------
 // Get and set methods
@@ -266,7 +265,6 @@
     	$( '#content' ).html( data );
     	hideLoader();
     	dhis2.dsr.showContent();
-    	dhis2.dsr.showApproval();
     	setTableStyles();
     } );
 }
@@ -289,32 +287,6 @@
     return url;
 }
 
-/**
- * Generates the URL for the approval of the given data set report.
- */
-dhis2.dsr.getDataApprovalUrl = function( dataSetReport )
-{
-    var url = "../api/dataApprovals" +
-        "?ds=" + dataSetReport.ds +
-        "&pe=" + dataSetReport.pe +
-        "&ou=" + dataSetReport.ou;
-
-    return url;
-}
-
-/**
- * Generates the URL for the acceptance of the given data set report approval.
- */
-dhis2.dsr.getDataApprovalAcceptanceUrl = function( dataSetReport )
-{
-    var url = "../api/dataApprovals/acceptances" +
-        "?ds=" + dataSetReport.ds +
-        "&pe=" + dataSetReport.pe +
-        "&ou=" + dataSetReport.ou;
-
-    return url;
-}
-
 dhis2.dsr.exportDataSetReport = function( type )
 {
 	var dataSetReport = dhis2.dsr.currentDataSetReport;
@@ -373,202 +345,6 @@
 	$( "#advancedOptions" ).hide();
 }
 
-dhis2.dsr.showApproval = function()
-{
-	var dataSetReport = dhis2.dsr.currentDataSetReport;
-	
-	var approval = $( "#dataSetId :selected" ).data( "approval" );
-
-	$( "#approvalNotification" ).hide();
-    $( "#approvalDiv" ).hide();
-
-	if ( !approval ) {
-		return;
-	}
-	
-	var url = dhis2.dsr.getDataApprovalUrl( dataSetReport );
-	
-	$.getJSON( url, function( json ) {
-		if ( !json || !json.state ) {
-			return;
-		}
-
-        dhis2.dsr.permissions = json;
-		
-		var state = json.state;
-
-        $( "#approveButton" ).hide();
-        $( "#unapproveButton" ).hide();
-        $( "#acceptButton" ).hide();
-        $( "#unacceptButton" ).hide();
-
-        switch (state)
-        {
-            case "UNAPPROVED_WAITING":
-                $( "#approvalNotification" ).show().html( i18n_waiting_for_lower_level_approval );
-                break;
-
-            case "UNAPPROVED_READY":
-                $( "#approvalNotification" ).show().html( i18n_ready_for_approval );
-                if ( json.mayApprove ) {
-                    $( "#approvalDiv" ).show();
-                    $( "#approveButton" ).show();
-                }
-                break;
-
-            case "APPROVED_HERE":
-                $( "#approvalNotification" ).show().html( i18n_approved );
-                if ( json.mayUnapprove ) {
-                    $( "#approvalDiv" ).show();
-                    $( "#unapproveButton" ).show();
-                }
-                if ( json.mayAccept ) {
-                    $( "#approvalDiv" ).show();
-                    $( "#acceptButton" ).show();
-                }
-                break;
-
-            case "ACCEPTED_HERE":
-                $( "#approvalNotification" ).show().html( i18n_approved );
-                if ( json.mayUnapprove ) {
-                    $( "#approvalDiv" ).show();
-                    $( "#unapproveButton" ).show();
-                }
-                if ( json.mayUnccept ) {
-                    $( "#approvalDiv" ).show();
-                    $( "#unacceptButton" ).show();
-                }
-                break;
-        }
-	} );
-}
-
-//------------------------------------------------------------------------------
-// Approval
-//------------------------------------------------------------------------------
-
-dhis2.dsr.approveData = function()
-{
-	if ( !confirm( i18n_confirm_approval ) ) {
-		return false;
-	}
-	
-	var dataSetReport = dhis2.dsr.currentDataSetReport;
-	var url = dhis2.dsr.getDataApprovalUrl( dataSetReport );
-	
-	$.ajax( {
-		url: url,
-		type: "post",
-		success: function() {
-            $( "#approvalNotification" ).show().html( i18n_approved );
-            $( "#approvalDiv" ).hide();
-			$( "#approveButton" ).hide();
-            if ( dhis2.dsr.permissions.mayUnapprove ) {
-                $( "#approvalDiv" ).show();
-                $( "#unapproveButton" ).show();
-            }
-            if ( dhis2.dsr.permissions.mayAccept ) {
-                $( "#approvalDiv" ).show();
-                $( "#acceptButton" ).show();
-            }
-		},
-		error: function( xhr, status, error ) {
-			alert( xhr.responseText );
-		}
-	} );
-}
-
-dhis2.dsr.unapproveData = function()
-{
-	if ( !confirm( i18n_confirm_unapproval ) ) {
-		return false;
-	}
-	
-	var dataSetReport = dhis2.dsr.currentDataSetReport;
-	var url = dhis2.dsr.getDataApprovalUrl( dataSetReport );
-	
-	$.ajax( {
-		url: url,
-		type: "delete",
-		success: function() {
-            $( "#approvalNotification" ).show().html( i18n_ready_for_approval );
-            $( "#approvalDiv" ).hide();
-            $( "#unapproveButton" ).hide();
-            $( "#acceptButton" ).hide();
-            $( "#unacceptButton" ).hide();
-            if ( dhis2.dsr.permissions.mayApprove ) {
-                $( "#approvalDiv" ).show();
-                $( "#approveButton" ).show();
-            }
-		},
-		error: function( xhr, status, error ) {
-			alert( xhr.responseText );
-		}
-	} );
-}
-
-dhis2.dsr.acceptData = function()
-{
-    if ( !confirm( i18n_confirm_accept ) ) {
-        return false;
-    }
-
-    var dataSetReport = dhis2.dsr.currentDataSetReport;
-    var url = dhis2.dsr.getDataApprovalAcceptanceUrl( dataSetReport );
-
-    $.ajax( {
-        url: url,
-        type: "post",
-        success: function() {
-            $( "#approvalNotification" ).show().html( i18n_approved_and_accepted );
-            $( "#approvalDiv" ).hide();
-            $( "#acceptButton" ).hide();
-            if ( dhis2.dsr.permissions.mayUnapprove ) {
-                $( "#approvalDiv" ).show();
-                $( "#unapproveButton" ).show();
-            }
-            if ( dhis2.dsr.permissions.mayUnaccept ) {
-                $( "#approvalDiv" ).show();
-                $( "#unacceptButton" ).show();
-            }
-        },
-        error: function( xhr, status, error ) {
-            alert( xhr.responseText );
-        }
-    } );
-}
-
-dhis2.dsr.unacceptData = function()
-{
-    if ( !confirm( i18n_confirm_unaccept ) ) {
-        return false;
-    }
-
-    var dataSetReport = dhis2.dsr.currentDataSetReport;
-    var url = dhis2.dsr.getDataApprovalAcceptanceUrl( dataSetReport );
-
-    $.ajax( {
-        url: url,
-        type: "delete",
-        success: function() {
-            $( "#approvalNotification" ).show().html( i18n_approved );
-            $( "#approvalDiv" ).hide();
-            $( "#unacceptButton" ).hide();
-            if ( dhis2.dsr.permissions.mayUnapprove ) {
-                $( "#approvalDiv" ).show();
-                $( "#unapproveButton" ).show();
-            }
-            if ( dhis2.dsr.permissions.mayAccept ) {
-                $( "#approvalDiv" ).show();
-                $( "#acceptButton" ).show();
-            }
-        },
-        error: function( xhr, status, error ) {
-            alert( xhr.responseText );
-        }
-    } );
-}
-
 //------------------------------------------------------------------------------
 // Share
 //------------------------------------------------------------------------------