← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3066: Disabled fields ignored in data entry forms when using arrows/enter to move between cells.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 3066 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-03-18 10:40:50 +0100
message:
  Disabled fields ignored in data entry forms when using arrows/enter to move between cells.
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	2011-02-10 11:57:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-03-18 09:39:37 +0000
@@ -330,14 +330,40 @@
 {
     var fields = $('input[name="entryfield"]');
     
-    return fields[field.tabIndex];
+    if (fields[field.tabIndex]) {
+        if (!fields[field.tabIndex].disabled) {
+            return fields[field.tabIndex];
+        }
+        else {
+            var index = field.tabIndex + 1;
+            while (fields[index]) {
+                if (!fields[index].disabled) {
+                    return fields[index];
+                }
+                index++;
+            }
+        }
+    }
 }
 
 function getPreviousEntryField( field )
 {
     var fields = $('input[name="entryfield"]');
     
-    return fields[field.tabIndex - 2];
+    if (fields[field.tabIndex - 2]) {
+        if (!fields[field.tabIndex - 2].disabled) {
+            return fields[field.tabIndex - 2];
+        }
+        else {
+            var index = field.tabIndex - 3;
+            while (fields[index]) {
+                if (!fields[index].disabled) {
+                    return fields[index];
+                }
+                index--;
+            }
+        }
+    }
 }
 
 // -----------------------------------------------------------------------------