← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11201: Data entry, including triggers which can be attached to from inside custom forms. Useful to imple...

 

------------------------------------------------------------
revno: 11201
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-06-11 23:03:10 +0200
message:
  Data entry, including triggers which can be attached to from inside custom forms. Useful to implement custom, dynamic behavior in forms like skip logic
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
  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/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-05-23 10:40:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-06-11 21:03:10 +0000
@@ -17,6 +17,7 @@
 
 var FORMULA_PATTERN = /#\{.+?\}/g;
 var SEPARATOR = '.';
+var EVENT_VALUE_SAVED = 'dhis-web-dataentry-value-saved';
 
 function updateDataElementTotals()
 {
@@ -266,6 +267,14 @@
     return false;
 }
 
+/**
+ * Convenience method which can be used in custom form scripts. Do not change.
+ */
+function onValueSave( fn )
+{
+	$( 'body' ).off( EVENT_VALUE_SAVED ).on( EVENT_VALUE_SAVED, fn );
+}
+
 // -----------------------------------------------------------------------------
 // Saver objects
 // -----------------------------------------------------------------------------
@@ -312,6 +321,8 @@
             markValue( fieldId, COLOR_RED );
             window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
         }
+        
+        $( 'body' ).trigger( EVENT_VALUE_SAVED, dataValue );
     }
 
     function handleError( jqXHR, textStatus, errorThrown )

=== 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-05-29 21:44:35 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-06-11 21:03:10 +0000
@@ -1393,6 +1393,14 @@
     }
 }
 
+/**
+ * Convenience method which can be used in custom form scripts. Do not change.
+ */
+function onFormLoad( fn )
+{
+	$( 'body' ).off( EVENT_FORM_LOADED ).on( EVENT_FORM_LOADED, fn );
+}
+
 // -----------------------------------------------------------------------------
 // Data completeness
 // -----------------------------------------------------------------------------