dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27003
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13385: Minor
------------------------------------------------------------
revno: 13385
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-12-22 14:10:39 +0100
message:
Minor
modified:
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-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-12-22 10:11:38 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-12-22 13:10:39 +0000
@@ -70,7 +70,7 @@
// Instance of the StorageManager
dhis2.de.storageManager = new StorageManager();
-// Is this form a multiOrg form?
+// Indicates whether current form is multi org unit
dhis2.de.multiOrganisationUnit = false;
// "organisationUnits" object inherited from ouwt.js
@@ -589,7 +589,7 @@
$( '#contentDiv' ).html( html );
- dhis2.de.multiOrganisationUnit = !!$('.formSection').data('multiorg');
+ dhis2.de.multiOrganisationUnit = !!$( '.formSection' ).data( 'multiorg' );
if ( !dhis2.de.multiOrganisationUnit )
{
@@ -614,7 +614,7 @@
},
function()
{
- dhis2.de.multiOrganisationUnit = !!$( '.formSection').data('multiorg' );
+ dhis2.de.multiOrganisationUnit = !!$( '.formSection' ).data( 'multiorg' );
if ( !dhis2.de.multiOrganisationUnit )
{
@@ -783,69 +783,6 @@
// OrganisationUnit Selection
// -----------------------------------------------------------------------------
-/**
- * Returns an array containing associative array elements with id and name
- * properties. The array is sorted on the element name property.
- */
-function getSortedDataSetList( orgUnit )
-{
- var associationSet = orgUnit !== undefined ? dhis2.de.organisationUnitAssociationSetMap[orgUnit] : dhis2.de.organisationUnitAssociationSetMap[getCurrentOrganisationUnit()];
- var orgUnitDataSets = dhis2.de.dataSetAssociationSets[associationSet];
-
- var dataSetList = [];
-
- $.safeEach( orgUnitDataSets, function( idx, item )
- {
- var dataSetId = orgUnitDataSets[idx];
- var dataSetName = dhis2.de.dataSets[dataSetId].name;
-
- var row = [];
- row['id'] = dataSetId;
- row['name'] = dataSetName;
- dataSetList[idx] = row;
- } );
-
- dataSetList.sort( function( a, b )
- {
- return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
- } );
-
- return dataSetList;
-}
-
-function getSortedDataSetListForOrgUnits( orgUnits )
-{
- var dataSetList = [];
-
- $.safeEach( orgUnits, function( idx, item )
- {
- dataSetList.push.apply( dataSetList, getSortedDataSetList(item) )
- } );
-
- var filteredDataSetList = [];
-
- $.safeEach( dataSetList, function( idx, item )
- {
- var formType = dhis2.de.dataSets[item.id].type;
- var found = false;
-
- $.safeEach( filteredDataSetList, function( i, el )
- {
- if( item.name == el.name )
- {
- found = true;
- }
- } );
-
- if ( !found && ( formType == FORMTYPE_SECTION || formType == FORMTYPE_DEFAULT ) )
- {
- filteredDataSetList.push(item);
- }
- } );
-
- return filteredDataSetList;
-}
-
function organisationUnitSelected( orgUnits, orgUnitNames, children )
{
if ( dhis2.de.metaDataIsLoaded == false )
@@ -897,7 +834,7 @@
multiDataSetValid = true;
}
- $( '<option />' ).attr( 'data-multiorg', true).attr( 'value', item.id).html(item.name).appendTo( '#selectedDataSetId' );
+ $( '<option />' ).attr( 'data-multiorg', true ).attr( 'value', item.id).html(item.name).appendTo( '#selectedDataSetId' );
} );
$( '#selectDataSetId' ).append( '</optgroup>' );
@@ -931,6 +868,69 @@
}
}
+/**
+ * Returns an array containing associative array elements with id and name
+ * properties. The array is sorted on the element name property.
+ */
+function getSortedDataSetList( orgUnit )
+{
+ var associationSet = orgUnit !== undefined ? dhis2.de.organisationUnitAssociationSetMap[orgUnit] : dhis2.de.organisationUnitAssociationSetMap[getCurrentOrganisationUnit()];
+ var orgUnitDataSets = dhis2.de.dataSetAssociationSets[associationSet];
+
+ var dataSetList = [];
+
+ $.safeEach( orgUnitDataSets, function( idx, item )
+ {
+ var dataSetId = orgUnitDataSets[idx];
+ var dataSetName = dhis2.de.dataSets[dataSetId].name;
+
+ var row = [];
+ row['id'] = dataSetId;
+ row['name'] = dataSetName;
+ dataSetList[idx] = row;
+ } );
+
+ dataSetList.sort( function( a, b )
+ {
+ return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
+ } );
+
+ return dataSetList;
+}
+
+function getSortedDataSetListForOrgUnits( orgUnits )
+{
+ var dataSetList = [];
+
+ $.safeEach( orgUnits, function( idx, item )
+ {
+ dataSetList.push.apply( dataSetList, getSortedDataSetList(item) )
+ } );
+
+ var filteredDataSetList = [];
+
+ $.safeEach( dataSetList, function( idx, item )
+ {
+ var formType = dhis2.de.dataSets[item.id].type;
+ var found = false;
+
+ $.safeEach( filteredDataSetList, function( i, el )
+ {
+ if( item.name == el.name )
+ {
+ found = true;
+ }
+ } );
+
+ if ( !found && ( formType == FORMTYPE_SECTION || formType == FORMTYPE_DEFAULT ) )
+ {
+ filteredDataSetList.push(item);
+ }
+ } );
+
+ return filteredDataSetList;
+}
+
// -----------------------------------------------------------------------------
// DataSet Selection
// -----------------------------------------------------------------------------
@@ -1216,6 +1216,22 @@
// Form
// -----------------------------------------------------------------------------
+/**
+ * Indicates whether all required inpout selections have been made.
+ */
+dhis2.de.inputSelected = function()
+{
+ if (
+ dhis2.de.currentOrganisationUnitId &&
+ dhis2.de.currentDataSetId &&
+ dhis2.de.currentPeriodId &&
+ dhis2.de.categoriesSelected ) {
+ return true;
+ }
+
+ return false;
+};
+
function loadDataValues()
{
$( '#completeButton' ).removeAttr( 'disabled' );