← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1156: Add Dataset - Fixed bug 491619 shortName should have been populated

 

------------------------------------------------------------
revno: 1156
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2009-12-03 14:59:20 +0700
message:
  Add Dataset - Fixed bug 491619 shortName should have been populated
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/shortName.js
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.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-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2009-11-03 09:05:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2009-12-03 07:59:20 +0000
@@ -121,7 +121,7 @@
       class="org.hisp.dhis.dataset.action.PeriodTypeListAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-maintenance-dataset/addDataSet.vm</param>
-      <param name="javascripts">javascript/dataSet.js,javascript/dataElementsList.js</param>
+      <param name="javascripts">javascript/shortName.js,javascript/dataSet.js,javascript/dataElementsList.js</param>
       <param name="requiredAuthorities">F_DATASET_ADD</param>
     </action>
     

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2009-11-03 09:05:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2009-12-03 07:59:20 +0000
@@ -13,7 +13,7 @@
     <tbody>
       <tr>
         <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-        <td><input type="text" id="name" name="name" style="width:20em"></td>
+        <td><input type="text" id="name" name="name" onchange="nameChanged()" style="width:20em"></td>
       </tr>
       <tr>
         <td><label>$i18n.getString( "short_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
@@ -106,12 +106,14 @@
 	var dataSetMembers = new Object();
 
 	var availableDataElements = new Object();	
-#foreach ( $availableDataElement in $dataElements )
-	availableDataElements['$availableDataElement.id'] = '$encoder.jsEscape( $availableDataElement.name, "'" )';
-#end
+	
+	#foreach ( $availableDataElement in $dataElements )
+		availableDataElements['$availableDataElement.id'] = '$encoder.jsEscape( $availableDataElement.name, "'" )';
+	#end
 
 	initLists();
 
+	var previousName = '';
 	var nameField = document.getElementById( 'name' );
 	nameField.select();
 	nameField.focus();

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/shortName.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/shortName.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/shortName.js	2009-12-03 07:59:20 +0000
@@ -0,0 +1,21 @@
+
+// -----------------------------------------------------------------------------
+// $Id: shortName.js 1251 2006-01-31 06:43:27Z torgeilo $
+// -----------------------------------------------------------------------------
+
+function nameChanged()
+{
+    var nameField = document.getElementById( 'name' );
+    var shortNameField = document.getElementById( 'shortName' );
+    var maxLength = parseInt( shortNameField.maxLength );
+    
+    if ( previousName != nameField.value
+        && nameField.value.length <= maxLength
+        && ( shortNameField.value == previousName
+          || shortNameField.value.length == 0 ))
+    {
+            shortNameField.value = nameField.value;
+    }
+    
+    previousName = nameField.value;
+}