← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4047: Put a list of constant into indicator expression builder form.

 

------------------------------------------------------------
revno: 4047
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-07-01 10:36:32 +0700
message:
  Put a list of constant into indicator expression builder form.
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/jsonConstants.vm
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java
  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-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-05-11 07:26:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-07-01 03:36:32 +0000
@@ -1,8 +1,8 @@
-#-- Application name ------------------------------------------------------------#
+#-- Application name -----------------------------------------------------------#
 
 district_health_information_software = District Health Information Software 2
 
-#-- Date Formats --------------------------------------------------------------#
+#-- Date Formats ---------------------------------------------------------------#
 
 format.date = yyyy-MM-dd
 format.date.label = yyyy-mm-dd
@@ -12,7 +12,7 @@
 format.datetime.label = yyyy-mm-dd hh:mm
 format.date.label.jquery = yy-mm-dd
 
-#-- dhis-wp -------------------------------------------------------------------#
+#-- dhis-wp --------------------------------------------------------------------#
 
 no_page_specified = No page specified
 an_exception_occured = An exception occurred
@@ -31,7 +31,7 @@
 maintenance = Maintenance
 services = Services
 
-#-- dhis-ouwt -----------------------------------------------------------------#
+#-- dhis-ouwt ------------------------------------------------------------------#
 
 org_unit_tree = Organisation Unit Tree
 specify_organisationunit = Please specify an organisation unit
@@ -40,7 +40,7 @@
 error_occurred = An error has occurred.
 select_organisationunit = You must select an OrganisationUnit from the tree.
 
-#-- Modules -------------------------------------------------------------------#
+#-- Modules --------------------------------------------------------------------#
 
 dhis-web-maintenance-datadictionary = Data Elements and Indicators
 dhis-web-maintenance-dataset = Datasets
@@ -76,7 +76,7 @@
 patient_attribute_group = Beneficiary Attribute Group
 patient_attribute_group_management = Beneficiary Attribute Group Management
 
-#-- Common --------------------------------------------------------------------#
+#-- Common ---------------------------------------------------------------------#
 
 details                 = Details
 show_details            = Show details
@@ -109,7 +109,7 @@
 delete                  = Delete
 close                   = Close
 
-#-- PeriodTypes ---------------------------------------------------------------#
+#-- PeriodTypes ----------------------------------------------------------------#
 
 Daily					= Daily
 Weekly					= Weekly
@@ -153,7 +153,7 @@
 format.FinancialOct.startDate	= 'FY '
 format.FinancialOct.endDate= yyyy
 
-#-- Months and weeks ----------------------------------------------------------#
+#-- Months and weeks -----------------------------------------------------------#
 
 month.january			= January
 month.february			= February
@@ -299,7 +299,7 @@
 bool    = Yes/No
 none    = None
 
-#-- User account  ----------------------------------------------------------------------#
+#-- User account  --------------------------------------------------------------#
 
 update_user         = Update user
 user_account        = User Account
@@ -317,13 +317,13 @@
 help_intro          = Welcome to the DHIS 2 Help Center. Please select an item from the menu to the left.
 please_wait_while_the_system_is_processing = Please wait while the system is processing
 
-#-- Contact info ----------------------------------------------------------------------#
+#-- Contact info ---------------------------------------------------------------#
 
 address             = Address
 contact_details     = Contact information
 contact_person      = Contact person
 
-#-- Form validation messages  ----------------------------------------------------------------------#
+#-- Form validation messages  --------------------------------------------------#
 
 this_field_is_required	=	This field is required.
 please_fix_this_field	=	Please fix this field.
@@ -406,7 +406,7 @@
 move_to_top         = Move to top
 move_to_bottom      = Move to bottom
 
-#-- Paging messages  ----------------------------------------------------------------------#
+#-- Paging messages  -----------------------------------------------------------#
 
 no_of_pages 	    = No. of pages
 rows_in_page		= No. of rows per page
@@ -419,7 +419,7 @@
 delete_success      = Object deleted
 process             = Processing...
 
-#-- Export PDF messages  ----------------------------------------------------------------------#
+#-- Export PDF messages  -------------------------------------------------------#
 
 get_pdf                             = Get PDF
 name                                = Name
@@ -449,7 +449,7 @@
 validation_rules                    = Validation rules
 period_type                         = Period Type
 
-#-- Indicator  ----------------------------------------------------------------------#
+#-- Indicator  -----------------------------------------------------------------#
 
 expression                          = Expression
 left_expression                     = Left Expression
@@ -471,7 +471,7 @@
 id_not_numeric                      = Identifier is not numeric
 expression_not_well_formed          = Expression is not well-formed
 
-#-- Validation Rule  ----------------------------------------------------------------------#
+#-- Validation Rule  -----------------------------------------------------------#
 
 absolute                            = Absolute
 statistical                         = Statistical
@@ -492,3 +492,8 @@
 greater_than_or_equal_to            = >=
 less_than                           = <
 less_than_or_equal_to               = <=
+
+#-- Constant  ------------------------------------------------------------------#
+
+constants							= Constants
+no_constant_to_select				= No constants to select
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties	2011-04-21 17:09:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties	2011-07-01 03:36:32 +0000
@@ -1,9 +1,9 @@
 
-#-- Program's name ------------------------------------------------------------#
+#-- Program's name -------------------------------------------------------------#
 
 district_health_information_software = H\u1ec7 Th\u1ed1ng B\u00e1o C\u00e1o Tr\u1ef1c Tuy\u1ebfn DHIS2.0
 
-#-- Date Formats --------------------------------------------------------------#
+#-- Date Formats ---------------------------------------------------------------#
 
 format.date 					= dd-MM-yyyy
 format.date.label 				= dd-mm-yyyy
@@ -13,7 +13,7 @@
 format.datetime.label 			= dd-mm-yyyy hh:mm
 format.date.label.jquery 		= dd-mm-yy
 
-#-- dhis-wp -------------------------------------------------------------------#
+#-- dhis-wp --------------------------------------------------------------------#
 
 no_page_specified 						= Kh\u00f4ng c\u00f3 trang n\u00e0o \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh
 an_exception_occured 					= C\u00f3 m\u1ed9t l\u1ed7i x\u1ea3y ra trong h\u1ec7 th\u1ed1ng
@@ -32,7 +32,7 @@
 maintenance 							= Qu\u1ea3n L\u00fd
 services 								= Ch\u1ee9c N\u0103ng
 
-#-- dhis-ouwt -----------------------------------------------------------------#
+#-- dhis-ouwt ------------------------------------------------------------------#
 
 org_unit_tree 							= C\u00e2y \u0111\u01a1n v\u1ecb
 specify_organisationunit 				= Vui l\u00f2ng ch\u1ecdn \u0111\u01a1n v\u1ecb
@@ -40,7 +40,7 @@
 error_occurred                          = L\u1ed7i trong qu\u00e1 tr\u00ecnh duy\u1ec7t d\u1eef li\u1ec7u.
 select_organisationunit                 = Vui l\u00f2ng ch\u1ecdn m\u1ed9t \u0111\u01a1n v\u1ecb trong c\u00e2y \u0111\u01a1n v\u1ecb.
 geo_code				                = M\u00e3 \u0111\u1ecba l\u00fd
-#-- Modules -------------------------------------------------------------------#
+#-- Modules --------------------------------------------------------------------#
 
 dhis-web-maintenance-datadictionary 	= Ph\u1ea7n t\u1eed d\u1eef li\u1ec7u & Ch\u1ec9 s\u1ed1
 dhis-web-maintenance-dataset 			= T\u1eadp h\u1ee3p d\u1eef li\u1ec7u
@@ -60,7 +60,7 @@
 dhis-web-datastatus						= Tr\u1ea1ng th\u00e1i d\u1eef li\u1ec7u
 dhis-web-excel-reporting				= B\u00e1o c\u00e1o excel
 
-#-- Common --------------------------------------------------------------------#
+#-- Common ---------------------------------------------------------------------#
 
 show_details            = Hi\u1ec3n th\u1ecb th\u00f4ng tin chi ti\u1ebft
 hide_details            = \u1ea8n th\u00f4ng tin chi ti\u1ebft
@@ -92,7 +92,7 @@
 delete                  = X\u00f3a
 close                   = \u0110\u00f3ng
 
-#-- PeriodTypes ---------------------------------------------------------------#
+#-- PeriodTypes ----------------------------------------------------------------#
 
 Daily					= H\u00e0ng ng\u00e0y
 Weekly					= H\u00e0ng tu\u1ea7n
@@ -126,7 +126,7 @@
 format.Relative.startDate	= dd-MM-yyyy '- '
 format.Relative.endDate		= dd-MM-yyyy
 
-#-- Months and weeks ----------------------------------------------------------#
+#-- Months and weeks -----------------------------------------------------------#
 
 month.january			= Th\u00e1ng m\u1ed9t
 month.february			= Th\u00e1ng hai
@@ -250,7 +250,7 @@
 bool    = C\u00f3/Kh\u00f4ng
 none    = Kh\u00f4ng c\u00f3
 
-#-- User account  ----------------------------------------------------------------------#
+#-- User account  --------------------------------------------------------------#
 
 update_user 		= C\u1eadp nh\u1eadt th\u00f4ng tin ng\u01b0\u1eddi d\u00f9ng
 details 			= Chi ti\u1ebft
@@ -267,14 +267,13 @@
 password_not_match  = X\u00e1c nh\u1eadn m\u1eadt kh\u1ea9u kh\u00f4ng \u0111\u00fang
 update_user_success	= Th\u00f4ng tin c\u1ee7a b\u1ea1n \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00e2y \u0111\u1ed5i
 
-#-- Contact info ----------------------------------------------------------------------#
+#-- Contact info ---------------------------------------------------------------#
 
 address             = \u0110\u1ecba ch\u1ec9
 contact_details     = Th\u00f4ng tin li\u00ean h\u1ec7
 contact_person      = Ng\u01b0\u1eddi li\u00ean h\u1ec7
 
-#-- Form validation messages  ----------------------------------------------------------------------#
-
+#-- Form validation messages  --------------------------------------------------#
 this_field_is_required	       =	Tr\u01b0\u1eddng n\u00e0y ph\u1ea3i nh\u1eadp
 please_fix_this_field	       =	Vui l\u00f2ng s\u1eeda l\u1ed7i tr\u01b0\u1eddng n\u00e0y
 please_enter_a_valid_email_address	=	Vui l\u00f2ng nh\u1eadp \u0111\u1ecba ch\u1ec9 email h\u1ee3p l\u1ec7
@@ -313,7 +312,7 @@
 please_fill_out_at_least_one_of_these_fields	=	Vui l\u00f2ng \u0111i\u1ec1n \u00edt nh\u1ea5t m\u1ed9t trong s\u1ed1 c\u00e1c tr\u01b0\u1eddng sau.
 password_must_contain_at_least_one_capital_letter_and_one_digit	= M\u1eadt kh\u1ea9u ph\u1ea3i ch\u1ee9a \u00edt nh\u1ea5t 1 k\u00fd t\u1ef1 IN HOA v\u00e0 m\u1ed9t s\u1ed1.
 
-#-- Commons message  ----------------------------------------------------------#
+#-- Commons message  -----------------------------------------------------------#
 
 please_enter_name	        = Vui l\u00f2ng nh\u1eadp t\u00ean !
 please_select_period        = Vui l\u00f2ng ch\u1ecdn th\u1eddi \u0111i\u1ec3m !
@@ -352,7 +351,7 @@
 move_to_top         = Di chuy\u1ec3n l\u00ean \u0111\u1ea7u
 move_to_bottom      = Di chuy\u1ec3n xu\u1ed1ng cu\u1ed1i
 
-#-- Paging messages  ----------------------------------------------------------------------#
+#-- Paging messages  -----------------------------------------------------------#
 
 no_of_pages         = S\u1ed1 trang
 size_of_page        = K\u00edch th\u01b0\u1edbc trang
@@ -365,7 +364,7 @@
 delete_success      = \u0110\u1ed1i t\u01b0\u1ee3ng \u0111\u00e3 x\u00f3a
 process             = \u0110ang x\u1eed l\u00fd
 
-#-- Export PDF messages  ------------------------------------------------------#
+#-- Export PDF messages  -------------------------------------------------------#
 
 get_pdf                             = Xu\u1ea5t t\u1eadp tin PDF
 name                                = T\u00ean
@@ -394,7 +393,7 @@
 validation_rules                    = C\u00e1c \u0111i\u1ec1u ki\u1ec7n ki\u1ec3m tra
 period_type                         = Ki\u1ec3u th\u1eddi gian
 
-#-- Indicator  ----------------------------------------------------------------#
+#-- Indicator  -----------------------------------------------------------------#
 
 expression                          = Bi\u1ec3u th\u1ee9c
 left_expression                     = Bi\u1ec3u th\u1ee9c v\u1ebf tr\u00e1i
@@ -411,7 +410,7 @@
 numerator_aggregation_operator      = Ki\u1ec3u s\u1ed1 li\u1ec7u t\u1ed5ng h\u1ee3p cho t\u1eed s\u1ed1
 denominator_aggregation_operator    = Ki\u1ec3u s\u1ed1 li\u1ec7u t\u1ed5ng h\u1ee3p cho m\u1eabu s\u1ed1
 
-#-- Validation Rule  ----------------------------------------------------------------------#
+#-- Validation Rule  -----------------------------------------------------------#
 
 absolute                            = Tuy\u1ec7t \u0111\u1ed1i
 statistical                         = Th\u1ed1ng k\u00ea
@@ -432,3 +431,8 @@
 greater_than_or_equal_to            = >=
 less_than                           = <
 less_than_or_equal_to               = <=
+
+#-- Constant  ------------------------------------------------------------------#
+
+constants							= Bi\u1ec3u th\u1ee9c H\u1eb1ng
+no_constant_to_select				= Kh\u00f4ng c\u00f3 Bi\u1ec3u th\u1ee9c H\u1eb1ng \u0111\u1ec3 ch\u1ecdn
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2011-06-30 07:55:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2011-07-01 03:36:32 +0000
@@ -392,6 +392,12 @@
         /dhis-web-maintenance-dataadmin/responseConstant.vm</result>
     </action>
 
+    <action name="getConstants" class="org.hisp.dhis.dataadmin.action.constant.GetConstantListAction">
+      <result name="success" type="velocity-json">
+		/dhis-web-maintenance-dataadmin/jsonConstants.vm</result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+	
     <action name="constant" class="org.hisp.dhis.dataadmin.action.constant.GetConstantListAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/jsonConstants.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/jsonConstants.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/jsonConstants.vm	2011-07-01 03:36:32 +0000
@@ -0,0 +1,13 @@
+#set( $size = $constants.size() )
+{ "constants": [
+#foreach( $constant in $constants )
+  {
+    "constantId": "$!{constant.id}",
+    "constantName": "$!encoder.jsonEncode( ${constant.name} )"
+  }#if( $velocityCount < $size ),#end
+#end
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java	2011-05-06 11:10:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/GetConceptListAction.java	2011-07-01 03:36:32 +0000
@@ -92,7 +92,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Action implemantation
+    // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()

=== 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	2011-06-16 01:47:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm	2011-07-01 03:36:32 +0000
@@ -1,4 +1,8 @@
 <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 );
 
@@ -11,6 +15,7 @@
 			height: 500
 		});
 		
+		getConstantsPage();
 		getOperandsPage();
 	});	
 
@@ -58,6 +63,25 @@
 		dialog.dialog( "open");
 	}
 	
+	function getConstantsPage()
+	{
+		var target = jQuery( "#indicator-expression-container select[id=constantId]" );
+		target.children().remove();
+		
+		jQuery.postJSON( '../dhis-web-maintenance-dataadmin/getConstants.action', {},
+			function( json ) {
+				if ( json.constants.length == 0 )
+				{
+					setInnerHTML( 'constantHeader', "<i style='color:red'>"+i18n_no_constant_to_select+"</i>" );
+					return;
+				}
+				
+				jQuery.each( json.constants, function(i, item) {
+					target.append( '<option value="[C'+item.constantId+']">'+item.constantName+'</option>' );
+				});
+			});
+	}
+	
 	function getOperandsPage()
 	{
 		var aggregationOperator = getRadioValue( 'aggregationOperator' );
@@ -154,15 +178,17 @@
 
 <div id="indicator-expression-container">
 <form id="indicator-expression-form">
-<table width="800" style="text-align:left">
+<table width="780" style="text-align:left">
 	<colgroup>
 		<col width="250"/>
-		<col width="20"/>
-		<col width="530"/>
+		<col width="10"/>
+		<col width="150"/>
+		<col width="300"/>
 	</colgroup>
 	<tr>
 		<th colspan="2">$i18n.getString( "description" )</th>
-		<th>$i18n.getString( "aggregation_operator" )</th>
+		<th colspan="2">$i18n.getString( "aggregation_operator" )</th>
+		<th id="constantHeader">$i18n.getString( "constants" )</th>
 	</tr>
 	<tr>
 		<td>
@@ -175,10 +201,17 @@
 			<input type="radio" name="aggregationOperator" value="average" onclick="getOperandsPage()"/>
 			$i18n.getString( "average" )
 		</td>
+		<td></td>
+		<td>
+			<select id="constantId" name="constantId" size="3" style="width:300px" ondblclick="insertText( 'expression', this.value )">
+			</select>
+		</td>
 	</tr>
 	<tr>
 		<td colspan="3"></td>
 	</tr>
+</table>
+<table width="800" style="text-align:left">
 	<tr>
 		<th colspan="2">$i18n.getString( "formula" )</th>
 		<th>$i18n.getString( "list_of_data_elements" )</th>
@@ -201,7 +234,7 @@
 			<input type="button" value="$i18n.getString( 'filter' )" onclick="getOperandsPage()" style="width:60px">
 			<input type="button" value="$i18n.getString( 'clear' )" onclick="clearSearchText();" style="width:60px"><br/>
 
-			<select id="dataElementId" name="dataElementId" size="7" style="width:510px" ondblclick="insertText( 'expression', this.value )">
+			<select id="dataElementId" name="dataElementId" size="7" style="width:500px" ondblclick="insertText( 'expression', this.value )">
 			</select>
 		</td>
 	</tr>
@@ -222,4 +255,4 @@
 	</tr>	
 </table>
 </form>
-</div>
+</div>
\ No newline at end of file