← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12999: give user a warning in data-entry, if no orgUnits are connected to it data-entry possible)

 

------------------------------------------------------------
revno: 12999
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-11-21 12:27:47 +0100
message:
  give user a warning in data-entry, if no orgUnits are connected to it data-entry possible)
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm


--
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-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2013-11-21 11:27:47 +0000
@@ -38,6 +38,8 @@
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -90,6 +92,14 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private CurrentUserService currentUserService;
+
+    @Autowired
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -143,12 +153,26 @@
         return organisationUnitAssociationSetMap;
     }
 
+    private boolean emptyOrganisationUnits;
+
+    public boolean isEmptyOrganisationUnits()
+    {
+        return emptyOrganisationUnits;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
+        if ( currentUserService.getCurrentUser().getOrganisationUnits().isEmpty() )
+        {
+            emptyOrganisationUnits = true;
+
+            return SUCCESS;
+        }
+
         significantZeros = dataElementService.getDataElementsByZeroIsSignificant( true );
 
         dataElements = dataElementService.getDataElementsWithDataSets();

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2013-10-11 10:47:27 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2013-11-21 11:27:47 +0000
@@ -104,6 +104,7 @@
 no_periods_click_prev_year_button=No periods, click "Prev year" button
 print=Print
 view_comment=View comment
+no_orgunits=No organisation unit attached to current user, no data entry possible
 validation_rules_are_being_processed_please_wait=Validation rules are being processed, please wait
 section=Section
 print_form=Print form

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-11-20 12:15:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-11-21 11:27:47 +0000
@@ -1,3 +1,7 @@
+
+// does current user have any organisation units?
+var emptyOrganisationUnits = false;
+
 // Identifiers for which zero values are insignificant, also used in entry.js
 var significantZeros = [];
 
@@ -145,8 +149,12 @@
 	        }
 	        else
 	        {
-	            setHeaderDelayMessage( i18n_online_notification );
-	        }
+            if( emptyOrganisationUnits ) {
+              setHeaderMessage(i18n_no_orgunits);
+            } else {
+              setHeaderDelayMessage(i18n_online_notification);
+            }
+          }
 	    }
 	    else
 	    {
@@ -167,7 +175,11 @@
 
     $( document ).bind( 'dhis2.offline', function()
     {
+      if( emptyOrganisationUnits ) {
+        setHeaderMessage(i18n_no_orgunits);
+      } else {
         setHeaderMessage( i18n_offline_notification );
+      }
     } );
 
     dhis2.availability.startAvailabilityCheck();
@@ -210,6 +222,7 @@
 	    {
 	        var metaData = JSON.parse( sessionStorage[KEY_METADATA] );
 
+          emptyOrganisationUnits = metaData.emptyOrganisationUnits;
 	        significantZeros = metaData.significantZeros;
 	        dataElements = metaData.dataElements;
 	        indicatorFormulas = metaData.indicatorFormulas;

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2013-11-20 10:28:18 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2013-11-21 11:27:47 +0000
@@ -1,5 +1,9 @@
 { "metaData": {
 
+#if( $emptyOrganisationUnits )
+"emptyOrganisationUnits": $emptyOrganisationUnits,
+#end
+
 "significantZeros": [
 #set( $size = $significantZeros.size() )
 #foreach( $dataElement in $significantZeros )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2013-10-07 17:58:57 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2013-11-21 11:27:47 +0000
@@ -46,6 +46,7 @@
 var i18n_childrens_forms = '$encoder.jsEscape( $i18n.getString( "childrens_forms" ) , "'")';
 var i18n_no_periods_click_prev_year_button = '$encoder.jsEscape( $i18n.getString( "no_periods_click_prev_year_button" ) , "'")';
 var i18n_view_comment = '$encoder.jsEscape( $i18n.getString( "view_comment" ) , "'")';
+var i18n_no_orgunits = '$encoder.jsEscape( $i18n.getString( "no_orgunits" ) , "'")';
 </script>
 
 <style type="text/css" media="print">