← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16961: lazy load dataset associations for offline ou in de, also expose dataSetType on dataSet

 

------------------------------------------------------------
revno: 16961
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-06 16:35:51 +0700
message:
  lazy load dataset associations for offline ou in de, also expose dataSetType on dataSet
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2014-09-29 18:29:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2014-10-06 09:35:51 +0000
@@ -366,6 +366,10 @@
         return sections != null && sections.size() > 0;
     }
 
+
+    @JsonProperty
+    @JsonView( { DetailedView.class })
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDataSetType()
     {
         if ( hasDataEntryForm() )

=== 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	2014-10-03 08:33:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-10-06 09:35:51 +0000
@@ -884,6 +884,59 @@
 }
 
 /**
+ * Fetch data-sets for a orgUnit + data-sets for its children.
+ *
+ * @param {String} ou Organisation Unit ID to fetch data-sets for
+ * @returns {$.Deferred}
+ */
+dhis2.de.fetchDataSets = function( ou )
+{
+    var def = $.Deferred();
+
+    var dataSetFields = 'id,name,periodType,categoryCombo[id],allowFuturePeriods,skipOffline,version,dataSetType' +
+        ',expiryDays,fieldCombinationRequired,validCompleteOnly,renderAsTabs,renderHorizontally';
+
+    $.ajax({
+        type: 'GET',
+        url: '../api/organisationUnits/' + ou,
+        data: {
+            fields: 'dataSets[' + dataSetFields + '],children[id,name,dataSets[' + dataSetFields + ']]'
+        }
+    }).done(function(data) {
+        var dataSets = [];
+
+        data.dataSets.forEach(function( item ) {
+            dataSets.push(item.id);
+            dhis2.de.dataSets[item.id] = {
+                name: item.name,
+                periodType: item.periodType,
+                categoryCombo: item.categoryCombo.id,
+                allowFuturePeriods: item.allowFuturePeriods,
+                skipOffline: item.skipOffline,
+                version: item.version,
+                type: item.dataSetType,
+                expiryDays: item.expiryDays,
+                fieldCombinationRequired: item.fieldCombinationRequired,
+                validCompleteOnly: item.validCompleteOnly,
+                renderAsTabs: item.renderAsTabs,
+                renderHorizontally: item.renderHorizontally
+            }
+        });
+
+        dhis2.de.dataSetAssociationSets[Object.keys(dhis2.de.dataSetAssociationSets).length] = dataSets;
+        dhis2.de.organisationUnitAssociationSetMap[ou] = Object.keys(dhis2.de.dataSetAssociationSets).length -1;
+
+        data.children.forEach(function( item ) {
+            console.log(item);
+        });
+
+        def.resolve(data);
+    });
+
+    return def.promise();
+};
+
+/**
  * Returns an array containing associative array elements with id and name
  * properties. The array is sorted on the element name property.
  */