← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13375: Data entry, js functions for category combos

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 13375 [merge]
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-12-21 21:52:13 +0100
message:
  Data entry, js functions for category combos
modified:
  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
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css


--
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-21 19:53:48 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-12-21 20:44:52 +0000
@@ -1369,6 +1369,54 @@
 	$( 'body' ).off( EVENT_FORM_LOADED ).on( EVENT_FORM_LOADED, fn );
 }
 
+/**
+ * Returns an array of category combo objects for the given data set. Default
+ * category combos are omitted.
+ */
+dhis2.de.getCategoryCombos = function( dataSets )
+{
+	var combos = [];
+	
+	$.safeEach( dataSets, function( idx, item ) {
+		if ( item.categoryCombo && dhis2.de.defaultCategoryCombo != item.categoryCombo ) {
+			var combo = dhis2.de.categoryCombos[item.categoryCombo];
+			combos.push( combo );
+		}
+	} );
+	
+	return combos;
+}
+
+/**
+ * Returns markup for drop down boxes to be put in the selection box for the
+ * given category combos.
+ */
+dhis2.de.getAttributeComboMarkup = function( categoryCombos )
+{
+	var html = '';
+	
+	if ( undefined === categoryCombos || categoryCombos.length == 0 ) {
+		return html;
+	}
+	
+	html = '<div class="selectionBoxRow">';
+	
+	$.safeEach( categoryCombos, function( idx, combo ) {
+		html += '<div class="selectionLabel">' + combo.name + '</div>';
+		html += '<select id="combo-' + combo.id + '" class="selectionBoxSelect">';
+		
+		$.safeEach( combo.categories, function( idx, cat ) {
+			var category = dhis2.de.categories[cat];
+			html += '<option value="' + category.id + '">' + category.name + '</option>';
+		} );
+		
+		html += '</select>';
+	} );
+
+	html += '</div>';
+	return html;
+}
+
 // -----------------------------------------------------------------------------
 // Data completeness
 // -----------------------------------------------------------------------------

=== 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-12-20 22:02:12 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2013-12-21 20:44:52 +0000
@@ -67,7 +67,7 @@
 "categoryCombos": {
 #set( $size1 = $categoryCombos.size() )
 #foreach( $categoryCombo in $categoryCombos )
-"${categoryCombo.uid}":{"name":"$encoder.jsonEncode( ${categoryCombo.displayName} )","categories":[
+"${categoryCombo.uid}":{"id":"${categoryCombo.uid}","name":"$encoder.jsonEncode( ${categoryCombo.displayName} )","categories":[
 #set( $size2 = $categoryCombo.categories.size() )
 #foreach( $category in $categoryCombo.categories )
 "${category.uid}"#if( $velocityCount < $size2 ),#end
@@ -82,7 +82,7 @@
 "${category.uid}":{"name":"$encoder.jsonEncode( ${category.displayName} )","options":[
 #set( $size2 = $category.categoryOptions.size() )
 #foreach( $option in $category.categoryOptions )
-{"id":"${option.uid}","name":"$encoder.jsonEncode( ${option.displayName} )"}#if( $velocityCount < $size2 ),#end
+{"id":"${option.uid}","id":"${option.uid}","name":"$encoder.jsonEncode( ${option.displayName} )"}#if( $velocityCount < $size2 ),#end
 #end
 ] }#if( $velocityCount < $size1 ),#end
 #end

=== 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-12-21 19:53:48 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2013-12-21 20:44:52 +0000
@@ -76,7 +76,7 @@
 </div>
 <div class="selectionBoxRow">
 	<div class="selectionLabel">$i18n.getString( "data_set" )</div>
-	<select id="selectedDataSetId" name="selectedDataSetId" style="width:401px" onchange="dataSetSelected()" disabled="disabled"></select>
+	<select id="selectedDataSetId" name="selectedDataSetId" class="selectionBoxSelect" onchange="dataSetSelected()" disabled="disabled"></select>
     <span id="loaderSpan" style="display:none"><img src='../images/ajax-loader-bar.gif'></span>
 </div>
 <div class="selectionBoxRow">
@@ -85,9 +85,11 @@
     <input type="button" id="prevButton" style="width:85px" value="$i18n.getString( 'prev_year' )" title="$i18n.getString('earlier_periods')" onclick="previousPeriodsSelected()" disabled="disabled">
    	<input type="button" id="nextButton" style="width:85px" value="$i18n.getString( 'next_year' )" title="$i18n.getString('later_periods')" onclick="nextPeriodsSelected()" disabled="disabled">
 </div>
+<div id="attributeComboDiv">
+</div>
 <div id="filterDataSetSectionDiv" class="selectionBoxRow" style="display:none">
     <div class="selectionLabel">$i18n.getString( "filter_on_section" )</div>
-    <select id="filterDataSetSection" name="filterDataSetSection" style="width:401px;" onchange="filterOnSection()"></select>
+    <select id="filterDataSetSection" name="filterDataSetSection" class="selectionBoxSelect" onchange="filterOnSection()"></select>
 </div>
 </div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css	2013-12-21 19:53:48 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css	2013-12-21 20:44:52 +0000
@@ -76,6 +76,11 @@
   padding: 2px 0;
 }
 
+.selectionBoxSelect
+{
+  width: 401px;
+}
+
 .selectionLabel
 {
   display: inline-block;