dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31778
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16230: Indicator expression builder, moved js to separate file
------------------------------------------------------------
revno: 16230
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-07-25 08:49:27 +0200
message:
Indicator expression builder, moved js to separate file
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.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-datadictionary/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2014-07-16 15:41:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml 2014-07-25 06:49:27 +0000
@@ -220,7 +220,7 @@
<action name="showAddIndicatorForm" class="org.hisp.dhis.dd.action.indicator.ShowAddIndicatorForm">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-datadictionary/addIndicatorForm.vm</param>
- <param name="javascripts">javascript/shortName.js,javascript/indicator.js</param>
+ <param name="javascripts">javascript/shortName.js,javascript/indicator.js,javascript/expressionBuilder.js</param>
<param name="anyAuthorities">F_INDICATOR_PUBLIC_ADD, F_INDICATOR_PRIVATE_ADD</param>
</action>
@@ -232,7 +232,7 @@
<action name="showUpdateIndicatorForm" class="org.hisp.dhis.dd.action.indicator.ShowUpdateIndicatorFormAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-datadictionary/updateIndicatorForm.vm</param>
- <param name="javascripts">javascript/shortName.js,javascript/indicator.js</param>
+ <param name="javascripts">javascript/shortName.js,javascript/indicator.js,javascript/expressionBuilder.js</param>
<param name="anyAuthorities">F_INDICATOR_PUBLIC_ADD, F_INDICATOR_PRIVATE_ADD</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm 2014-01-31 18:08:43 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm 2014-07-25 06:49:27 +0000
@@ -1,160 +1,25 @@
<script type="text/javascript">
-
- var i18n_no_constant_to_select = '$encoder.jsEscape( $i18n.getString( "no_constant_to_select" ) , "'")';
- var i18n_no_dataelement_to_select = '$encoder.jsEscape( $i18n.getString( "no_dataelement_to_select" ) , "'")';
-
- jQuery( document ).ready( function(){
- validator = validation( 'indicator-expression-form', insertExpression );
-
- dialog = jQuery("#indicator-expression-container").dialog({
- modal: true,
- autoOpen: false,
- minWidth: 840,
- minHeight: 560,
- width: 840,
- height: 560
- });
-
- getConstantsPage();
- getOrgUnitGroupsPage();
- getOperandsPage();
- });
-
- var numerator = false;
- var validator = null;
- var dialog = null;
-
- function indicatorNumeratorForm()
- {
- numerator = true;
-
- validator.resetForm();
-
- var expression = getFieldValue( 'numerator' );
- var description = getFieldValue( 'numeratorDescription' );
- setFieldValue( 'indicator-expression-container textarea[id=expression]', expression );
- setFieldValue( 'indicator-expression-container input[id=description]', description );
-
- getExpressionText();
-
- dialog.dialog("option", "title", "$i18n.getString( 'edit_numerator' )");
- dialog.dialog("open");
- }
-
- function indicatorDenominatorForm()
- {
- numerator = false;
-
- validator.resetForm();
-
- var expression = getFieldValue( 'denominator' );
- var description = getFieldValue( 'denominatorDescription' );
- setFieldValue( 'indicator-expression-container textarea[id=expression]', expression );
- setFieldValue( 'indicator-expression-container input[id=description]', description );
-
- getExpressionText();
-
- dialog.dialog("option", "title", "$i18n.getString( 'edit_denominator' )");
- dialog.dialog( "open");
- }
-
- function getConstantsPage()
- {
- var target = jQuery( "#indicator-expression-container select[id=constantId]" );
- target.children().remove();
-
- jQuery.get( '../api/constants.json?paging=false&links=false',
- function( json ) {
- jQuery.each( json.constants, function(i, item) {
- target.append( '<option value="C{' + item.id + '}">' + item.name + '</option>' );
- });
- });
- }
-
- function getOrgUnitGroupsPage()
- {
- var target = jQuery( "#indicator-expression-container select[id=orgUnitGroupId]" );
- target.children().remove();
-
- jQuery.get( '../api/organisationUnitGroups.json?paging=false&links=false',
- function( json ) {
- jQuery.each( json.organisationUnitGroups, function(i, item) {
- target.append( '<option value="OUG{' + item.id + '}">' + item.name + '</option>' );
- });
- });
- }
-
- function getOperandsPage()
- {
- var key = getFieldValue( "indicator-expression-container input[id=filter]");
-
- dataDictionary.loadOperands( "#indicator-expression-container select[id=dataElementId]", {usePaging: true, key: key, includeTotals: true} );
- }
-
- function clearSearchText()
- {
- jQuery( "#indicator-expression-container input[id=filter]").val("");
- getOperandsPage();
- }
-
- function getExpressionText()
- {
- if ( hasText('expression') ){
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
- expression: getFieldValue('expression')
- }, function( json ){
- if( json.response == 'success' || json.response == 'error' )
- {
- jQuery( "#formulaText").html( json.message );
- }else{
- jQuery( "#formulaText").html( '' );
- }
- });
- } else{
- jQuery( "#formulaText").html( '' );
- }
- }
-
- function insertText( inputAreaName, inputText )
- {
- insertTextCommon( inputAreaName, inputText );
-
- getExpressionText();
- }
-
- function cleanExpression()
- {
- getExpressionText();
- }
-
- function closeExpressionBuilder()
- {
- dialog.dialog( "close" );
- }
-
- function insertExpression()
- {
- var expression = getFieldValue( 'indicator-expression-container textarea[id=expression]' );
- var description = getFieldValue( 'indicator-expression-container input[id=description]' );
-
- jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action',
- {expression: expression},
- function( json ) {
- if( json.response == 'error') markInvalid( 'indicator-expression-container textarea[id=expression]', json.message );
- else {
- if( numerator ){
- setFieldValue( 'numerator', expression );
- setFieldValue( 'numeratorDescription', description );
- }else{
- setFieldValue( 'denominator', expression );
- setFieldValue( 'denominatorDescription', description );
- }
-
- closeExpressionBuilder();
- }
- }
- );
- }
+var i18n_no_constant_to_select = '$encoder.jsEscape( $i18n.getString( "no_constant_to_select" ) , "'")';
+var i18n_no_dataelement_to_select = '$encoder.jsEscape( $i18n.getString( "no_dataelement_to_select" ) , "'")';
+var i18n_edit_numerator = '$encoder.jsEscape( $i18n.getString( "edit_numerator" ) , "'")';
+var i18n_edit_denominator = '$encoder.jsEscape( $i18n.getString( "edit_denominator" ) , "'")';
+
+jQuery( document ).ready( function(){
+ validator = validation( 'indicator-expression-form', insertExpression );
+
+ dialog = jQuery("#indicator-expression-container").dialog({
+ modal: true,
+ autoOpen: false,
+ minWidth: 840,
+ minHeight: 560,
+ width: 840,
+ height: 560
+ });
+
+ getConstantsPage();
+ getOrgUnitGroupsPage();
+ getOperandsPage();
+});
</script>
<div id="indicator-expression-container" class="page">
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/expressionBuilder.js 2014-07-25 06:49:27 +0000
@@ -0,0 +1,139 @@
+
+var numerator = false;
+var validator = null;
+var dialog = null;
+
+function indicatorNumeratorForm()
+{
+ numerator = true;
+
+ validator.resetForm();
+
+ var expression = getFieldValue( 'numerator' );
+ var description = getFieldValue( 'numeratorDescription' );
+ setFieldValue( 'indicator-expression-container textarea[id=expression]', expression );
+ setFieldValue( 'indicator-expression-container input[id=description]', description );
+
+ getExpressionText();
+
+ dialog.dialog("option", "title", i18n_edit_numerator);
+ dialog.dialog("open");
+}
+
+function indicatorDenominatorForm()
+{
+ numerator = false;
+
+ validator.resetForm();
+
+ var expression = getFieldValue( 'denominator' );
+ var description = getFieldValue( 'denominatorDescription' );
+ setFieldValue( 'indicator-expression-container textarea[id=expression]', expression );
+ setFieldValue( 'indicator-expression-container input[id=description]', description );
+
+ getExpressionText();
+
+ dialog.dialog("option", "title", i18n_edit_denominator);
+ dialog.dialog( "open");
+}
+
+function getConstantsPage()
+{
+ var target = jQuery( "#indicator-expression-container select[id=constantId]" );
+ target.children().remove();
+
+ jQuery.get( '../api/constants.json?paging=false&links=false',
+ function( json ) {
+ jQuery.each( json.constants, function(i, item) {
+ target.append( '<option value="C{' + item.id + '}">' + item.name + '</option>' );
+ });
+ });
+}
+
+function getOrgUnitGroupsPage()
+{
+ var target = jQuery( "#indicator-expression-container select[id=orgUnitGroupId]" );
+ target.children().remove();
+
+ jQuery.get( '../api/organisationUnitGroups.json?paging=false&links=false',
+ function( json ) {
+ jQuery.each( json.organisationUnitGroups, function(i, item) {
+ target.append( '<option value="OUG{' + item.id + '}">' + item.name + '</option>' );
+ });
+ });
+}
+
+function getOperandsPage()
+{
+ var key = getFieldValue( "indicator-expression-container input[id=filter]");
+
+ dataDictionary.loadOperands( "#indicator-expression-container select[id=dataElementId]", {usePaging: true, key: key, includeTotals: true} );
+}
+
+function clearSearchText()
+{
+ jQuery( "#indicator-expression-container input[id=filter]").val("");
+ getOperandsPage();
+}
+
+function getExpressionText()
+{
+ if ( hasText('expression') ){
+ jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
+ expression: getFieldValue('expression')
+ }, function( json ) {
+ if( json.response == 'success' || json.response == 'error' )
+ {
+ jQuery( "#formulaText").html( json.message );
+ }
+ else {
+ jQuery( "#formulaText").html( '' );
+ }
+ });
+ }
+ else {
+ jQuery( "#formulaText").html( '' );
+ }
+}
+
+function insertText( inputAreaName, inputText )
+{
+ insertTextCommon( inputAreaName, inputText );
+
+ getExpressionText();
+}
+
+function cleanExpression()
+{
+ getExpressionText();
+}
+
+function closeExpressionBuilder()
+{
+ dialog.dialog( "close" );
+}
+
+function insertExpression()
+{
+ var expression = getFieldValue( 'indicator-expression-container textarea[id=expression]' );
+ var description = getFieldValue( 'indicator-expression-container input[id=description]' );
+
+ jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action',
+ {expression: expression},
+ function( json ) {
+ if ( json.response == 'error') markInvalid( 'indicator-expression-container textarea[id=expression]', json.message );
+ else {
+ if ( numerator ){
+ setFieldValue( 'numerator', expression );
+ setFieldValue( 'numeratorDescription', description );
+ }
+ else{
+ setFieldValue( 'denominator', expression );
+ setFieldValue( 'denominatorDescription', description );
+ }
+
+ closeExpressionBuilder();
+ }
+ }
+ );
+}
\ No newline at end of file