dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32706
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16678: Data entry, added trigger for validation success and error
------------------------------------------------------------
revno: 16678
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-09 22:39:02 -0400
message:
Data entry, added trigger for validation success and error
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/select.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-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 2014-09-08 03:05:12 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2014-09-10 02:39:02 +0000
@@ -104,6 +104,8 @@
dhis2.de.event.dataValueSaved = "dhis2.de.event.dataValueSaved";
dhis2.de.event.completed = "dhis2.de.event.completed";
dhis2.de.event.uncompleted = "dhis2.de.event.uncompleted";
+dhis2.de.event.validationSucces = "dhis2.de.event.validationSuccess";
+dhis2.de.event.validationError = "dhis2.de.event.validationError";
/**
* Convenience method to be used from inside custom forms. When a function is
@@ -1615,7 +1617,7 @@
return false;
}
- validate( true, function()
+ dhis2.de.validate( true, function()
{
var params = dhis2.de.storageManager.getCurrentCompleteDataSetParams();
@@ -1751,7 +1753,14 @@
// Validation
// -----------------------------------------------------------------------------
-function validate( ignoreSuccessfulValidation, successCallback )
+/**
+ * Executes all validation checks.
+ *
+ * @param ignoreValidationSuccess indicates whether no dialog should be display
+ * if validation is successful.
+ * @param successCallback the function to execute if validation is successful.
+ */
+dhis2.de.validate = function( ignoreValidationSuccess, successCallback )
{
var compulsoryCombinationsValid = dhis2.de.validateCompulsoryCombinations();
@@ -1788,7 +1797,7 @@
$( '#validationDiv' ).load( 'validate.action', params, function( response, status, xhr ) {
var success = null;
- if ( status == 'error' && !ignoreSuccessfulValidation )
+ if ( status == 'error' && !ignoreValidationSuccess )
{
window.alert( i18n_operation_not_available_offline );
success = true; // Accept if offline
@@ -1802,7 +1811,7 @@
{
dhis2.de.displayValidationDialog( response, 500 );
}
- else if ( !ignoreSuccessfulValidation )
+ else if ( !ignoreValidationSuccess )
{
dhis2.de.displayValidationDialog( successHtml, 200 );
}
@@ -1812,6 +1821,15 @@
{
successCallback.call();
}
+
+ if ( success )
+ {
+ $( document ).trigger( dhis2.de.event.validationSucces );
+ }
+ else
+ {
+ $( document ).trigger( dhis2.de.event.validationError );
+ }
} );
}
=== 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 2014-09-03 01:48:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2014-09-10 02:39:02 +0000
@@ -67,7 +67,7 @@
</div>
<div id="actions">
- <input type="button" value="$i18n.getString( 'run_validation' )" onclick="validate( false )" id="validationButton" style="width:120px;" disabled="disabled"/><br>
+ <input type="button" value="$i18n.getString( 'run_validation' )" onclick="dhis2.de.validate( false )" id="validationButton" style="width:120px;" disabled="disabled"/><br>
<input type="button" value="$i18n.getString( 'print_form' )" onclick="window.print()" id="printButton" style="width:120px"/><br>
<input type="button" value="$i18n.getString( 'print_blank_form' )" onclick="printBlankForm()" style="width:120px"/><br> </br>
</div>
@@ -107,7 +107,7 @@
<input type="button" id="completeButton" name="completeButton" value="$i18n.getString( 'complete' )" onclick="registerCompleteDataSet()" style="width:120px">
<input type="button" id="undoButton" name="undoButton" value="$i18n.getString( 'incomplete' )" onclick="undoCompleteDataSet()" style="width:120px">
<span class="separator">|</span>
-<input type="button" id="validateButton" value="$i18n.getString( 'run_validation' )" onclick="validate( false )" style="width:120px">
+<input type="button" id="validateButton" value="$i18n.getString( 'run_validation' )" onclick="dhis2.de.validate( false )" style="width:120px">
</div>
<div id="infoDiv" class="page inputCriteria">