dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16720
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6429: (local) Sort data elements list by form name in data entry form.
------------------------------------------------------------
revno: 6429
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-29 11:55:32 +0700
message:
(local) Sort data elements list by form name in data entry form.
added:
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/about/
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/about/modules.vm
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/jsonAttributeValues.vm
modified:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java
local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/dataelement/LoadFormAction.java
local/vn/dhis-web-dataentry-hospital/src/main/webapp/WEB-INF/web.xml
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/javascript/form.js
local/vn/dhis-web-dataentry-hospital/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 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-03-29 04:55:32 +0000
@@ -49,6 +49,6 @@
{
return getCriteria().createAlias( "attributeValues", "attributeValue" ).add(
Restrictions.eq( "attributeValue.attribute", attribute ) ).add(
- Restrictions.eq( "attributeValue.value", value ) ).list();
+ Restrictions.ilike( "attributeValue.value", value ) ).list();
}
}
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/dataelement/LoadFormAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/dataelement/LoadFormAction.java 2012-03-26 02:41:46 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/dataelement/LoadFormAction.java 2012-03-29 04:55:32 +0000
@@ -231,6 +231,8 @@
List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+ Collections.sort( dataElements, new DataElementFormNameComparator() );
+
if ( dataElements.isEmpty() )
{
return INPUT;
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/WEB-INF/web.xml'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/WEB-INF/web.xml 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/WEB-INF/web.xml 2012-03-29 04:55:32 +0000
@@ -18,7 +18,7 @@
<filter-class>org.hisp.dhis.servlet.filter.HttpRedirectFilter</filter-class>
<init-param>
<param-name>redirectPath</param-name>
- <param-value>dhis-web-dataentry-hospital/index.action</param-value>
+ <param-value>dhis-web-dataentry/index.action</param-value>
</init-param>
</filter>
<filter>
=== added directory 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons'
=== added directory 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/about'
=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/about/modules.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/about/modules.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-commons/about/modules.vm 2012-03-29 04:55:32 +0000
@@ -0,0 +1,29 @@
+<table cellspacing="0" cellpadding="0">
+<tr>
+
+#if( $maintenanceModules && $maintenanceModules.size() > 0 )
+<td valign="top">
+<ul class="introList" style="width:340px; margin-top:0px; margin-right:15px;">
+#foreach( $module in $maintenanceModules )
+ #if( $module.name!='dhis-web-dataentry-hospital' )
+ #introListImgItem( "${module.defaultAction}" "${module.name}" "${module.name}" )
+ #end
+#end
+</ul>
+</td>
+#end
+
+#if( $serviceModules && $serviceModules.size() > 0 )
+<td valign="top">
+<ul class="introList" style="width:340px; margin-top:0px;">
+#foreach( $module in $serviceModules )
+ #if( $module.name!='dhis-web-dataentry-hospital' )
+ #introListImgItem( "${module.defaultAction}" "${module.name}" "${module.name}" )
+ #end
+#end
+</ul>
+</td>
+#end
+
+</tr>
+</table>
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/javascript/form.js 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/javascript/form.js 2012-03-29 04:55:32 +0000
@@ -400,7 +400,7 @@
$( '#contentDiv' ).load( '../dhis-web-dataentry-hospital/loadForm.action', {
dataSetId : dataSetId,
attributeId: getFieldValue( 'attributeId' ),
- value: getFieldValue( 'value' )
+ value: byId( 'valueInput' ).value
}, loadDataValues );
//}
}
@@ -1641,3 +1641,109 @@
}
} );
}
+
+function getSuggestedAttrValue()
+{
+ clearListById( 'value' );
+ $.getJSON( '../dhis-web-dataentry-hospital/loadAttributeValuesByAttribute.action',
+ {
+ attributeId: getFieldValue( 'attributeId' )
+ }
+ , function( json )
+ {
+ addOptionById( 'value', '', i18n_please_select_attribute );
+
+ for ( i in json.attributeValues )
+ {
+ $('#value').append('<option value=' + json.attributeValues[i].value + '>' + json.attributeValues[i].value + '</option>');
+ }
+
+ autoCompletedField();
+ } );
+}
+
+
+function autoCompletedField()
+{
+ var select = jQuery( "#value" );
+ $( "#valueButton" ).unbind('click');
+ enable( 'valueButton' );
+ var selected = select.children( ":selected" );
+ var value = selected.val() ? selected.text() : "";
+
+ var input = jQuery( "#valueInput" )
+ .insertAfter( select )
+ .val( value )
+ .autocomplete({
+ delay: 0,
+ minLength: 0,
+ source: function( request, response ) {
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
+ response( select.children( "option" ).map(function() {
+ var text = $( this ).text();
+ if ( this.value && ( !request.term || matcher.test(text) ) )
+ return {
+ label: text,
+ value: text,
+ option: this
+ };
+ }) );
+ },
+ select: function( event, ui ) {
+ ui.item.option.selected = true;
+ },
+ change: function( event, ui ) {
+ if ( !ui.item ) {
+ var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
+ valid = false;
+ select.children( "option" ).each(function() {
+ if ( $( this ).text().match( matcher ) ) {
+ this.selected = valid = true;
+ return false;
+ }
+ });
+ if ( !valid ) {
+ // remove invalid value, as it didn't match anything
+ $( this ).val( "" );
+ select.val( "" );
+ input.data( "autocomplete" ).term = "";
+ return false;
+ }
+ }
+ }
+ })
+ .addClass( "ui-widget ui-widget-content ui-corner-left" );
+
+ input.data( "autocomplete" )._renderItem = function( ul, item ) {
+ return $( "<li></li>" )
+ .data( "item.autocomplete", item )
+ .append( "<a>" + item.label + "</a>" )
+ .appendTo( ul );
+ };
+
+ showById('valueButton');
+ var button = $( "#valueButton" )
+ .attr( "title", i18n_show_all_items )
+ .button({
+ icons: {
+ primary: "ui-icon-triangle-1-s"
+ },
+ text: false
+ })
+ .removeClass( "ui-corner-all" )
+ .addClass( "ui-corner-right ui-button-icon" )
+ .click(function() {
+ // close if already visible
+ if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
+ input.autocomplete( "close" );
+ return;
+ }
+
+ // work around a bug (likely same cause as #5265)
+ $( this ).blur();
+
+ // pass empty string as value to search for, displaying all results
+ input.autocomplete( "search", "" );
+ input.focus();
+ });
+}
=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/jsonAttributeValues.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/jsonAttributeValues.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/jsonAttributeValues.vm 2012-03-29 04:55:32 +0000
@@ -0,0 +1,9 @@
+#set( $size = $values.size() )
+{ "attributeValues": [
+ #foreach( $value in $values )
+ {
+ "value": "$!encoder.jsonEncode( $value )"
+ }#if( $velocityCount < $size ),#end
+ #end
+ ]
+}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/select.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/select.vm 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry/select.vm 2012-03-29 04:55:32 +0000
@@ -37,7 +37,7 @@
var i18n_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "dataset_is_locked" ) , "'")';
var i18n_register_complete_failed_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "register_complete_failed_dataset_is_locked" ) , "'")';
var i18n_unregister_complete_failed_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "unregister_complete_failed_dataset_is_locked" ) , "'")';
-
+var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
jQuery(document).ready( function(){
getAttributes();
});
@@ -68,7 +68,7 @@
</tr>
<tr>
<td><label for="selectedPeriodId">$i18n.getString( "period" )</label></td>
- <td><select id="selectedPeriodId" name="selectedPeriodId" style="width:215px" disabled="disabled"></select>
+ <td><select id="selectedPeriodId" name="selectedPeriodId" style="width:215px" disabled="disabled" onchange='enable("loadButton")' ></select>
<input type="button" id="prevButton" style="width:75px" value="$i18n.getString( 'prev_year' )" title="$i18n.getString('earlier_periods')" onclick="previousPeriodsSelected()" disabled="disabled">
<input type="button" id="nextButton" style="width:75px" value="$i18n.getString( 'next_year' )" title="$i18n.getString('later_periods')" onclick="nextPeriodsSelected()" disabled="disabled">
</td>
@@ -77,16 +77,19 @@
<tr>
<td><label for="attributeId">$i18n.getString( "attribute" )</label></td>
<td>
- <select id="attributeId" name="attributeId" style="width:215px" >
- </select>
- <input id='value' name='value' />
+ <select id="attributeId" name="attributeId" style="width:215px" onchange='getSuggestedAttrValue();'></select>
+ <select id='value' name='value' style='display:none;' /></select>
+
+ <input type="text" id="valueInput" name="valueInput" />
+ <button type='button' id='valueButton' class='small-button' > </button>
+
</td>
</tr>
<tr>
<td><p></p></td>
<td>
- <input type='button' value='$i18n.getString("load_entry_form")' onclick='periodSelected();'>
+ <input type='button' id='loadButton' value='$i18n.getString("load_entry_form")' onclick='periodSelected();'>
</td>
</tr>
</table>