------------------------------------------------------------ revno: 4198 committer: Lars Helge Overland <larshe...@gmail.com> branch nick: dhis2 timestamp: Fri 2011-07-22 11:17:04 +0200 message: Using json rather than xml for a few actions in ouwt and oust modified: dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java 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/responseDataSets.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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2011-07-21 20:33:57 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2011-07-22 09:17:04 +0000 @@ -297,7 +297,7 @@ { String hql = "from DataElement d where d.groups.size = 0"; - return sessionFactory.getCurrentSession().createQuery( hql ).list(); + return getQuery( hql ).list(); } @SuppressWarnings( "unchecked" ) @@ -305,7 +305,7 @@ { String hql = "from DataElement d where d.dataSets.size = 0"; - return sessionFactory.getCurrentSession().createQuery( hql ).list(); + return getQuery( hql ).list(); } @SuppressWarnings( "unchecked" ) @@ -313,7 +313,7 @@ { String hql = "from DataElement d where d.dataSets.size > 0"; - return sessionFactory.getCurrentSession().createQuery( hql ).list(); + return getQuery( hql ).list(); } public boolean dataElementExists( int id ) === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2011-07-21 07:11:13 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2011-07-22 09:17:04 +0000 @@ -53,12 +53,7 @@ if ( linkTags[0].className == 'selected' ) { - $.ajax({ - url: selectionTreePath + 'removeorgunit.action?id=' + unitId, - cache: false, - dataType: "xml", - success: responseReceived - }); + $.post( selectionTreePath + 'removeorgunit.action', { id:unitId }, responseReceived ); linkTags[0].className = ''; } @@ -66,23 +61,13 @@ { if ( multipleSelectionAllowed ) { - $.ajax({ - url: selectionTreePath + 'addorgunit.action?id=' + unitId, - cache: false, - dataType: "xml", - success: responseReceived - }); + $.post( selectionTreePath + 'addorgunit.action', { id:unitId }, responseReceived ); linkTags[0].className = 'selected'; } else { - $.ajax({ - url: selectionTreePath + 'setorgunit.action?id=' + unitId, - cache: false, - dataType: "xml", - success: responseReceived - }); + $.post( selectionTreePath + 'setorgunit.action', { id:unitId }, responseReceived ); // Remove all select marks var treeTag = document.getElementById( 'selectionTree' ); @@ -101,25 +86,23 @@ } }; - function responseReceived( rootElement ) + function responseReceived( json ) { - selectedOrganisationUnit = new Array(); - - var unitIds = new Array(); - - var unitIdElements = $(rootElement).find( 'unitId' ); - - for ( var i = 0, unitIdElement; ( unitIdElement = unitIdElements[i] ); ++i ) - { - unitIds[i] = unitIdElement.firstChild.nodeValue; - selectedOrganisationUnit.push( unitIds[i] ); - } - if ( !listenerFunction ) { return; } + selectedOrganisationUnit = new Array(); + + var unitIds = new Array(); + + for ( i in json.selectedUnits ) + { + unitIds[i] = json.selectedUnits[i].id; + selectedOrganisationUnit.push( unitIds[i] ); + } + listenerFunction( unitIds ); } === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-07-20 08:49:53 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-07-22 09:17:04 +0000 @@ -49,34 +49,19 @@ if ( $linkTag.hasClass( "selected" ) && unselectAllowed ) { - $.post( organisationUnitTreePath + "removeorgunit.action", { - id : unitId - }, function( data ) - { - responseReceived( data.firstChild ); - }, 'xml' ); - + $.post( organisationUnitTreePath + "removeorgunit.action", { id : unitId }, responseReceived ); + $linkTag.removeClass( "selected" ); } else { if ( multipleSelectionAllowed ) { - $.post( organisationUnitTreePath + "addorgunit.action", { - id : unitId - }, function( data ) - { - responseReceived( data.firstChild ); - }, 'xml' ); + $.post( organisationUnitTreePath + "addorgunit.action", { id : unitId }, responseReceived ); $linkTag.addClass( "selected" ); } else { - $.ajax( { - type : "POST", - url : organisationUnitTreePath + "setorgunit.action?id=" + unitId, - dataType : "xml", - success : responseReceived - } ); + $.post( organisationUnitTreePath + "setorgunit.action", { id : unitId }, responseReceived ); $( "#orgUnitTree" ).find( "a" ).removeClass( "selected" ); $linkTag.addClass( "selected" ); @@ -84,21 +69,23 @@ } }; - function responseReceived( rootElement ) + function responseReceived( json ) { if ( !listenerFunction ) { return; } - var unitIds = new Array(); + var unitIds = []; + var unitNames = []; - $( rootElement ).find( "unitId" ).each( function( i, item ) + for ( i in json.selectedUnits ) { - unitIds[i] = $( item ).text() - } ); - - listenerFunction( unitIds ); + unitIds[i] = json.selectedUnits[i].id; + unitNames[i] = json.selectedUnits[i].name; + } + + listenerFunction( unitIds, unitNames ); } function getTagId( unitId ) === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm 2011-07-18 10:46:40 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm 2011-07-22 09:17:04 +0000 @@ -1,6 +1,9 @@ -<?xml version="1.0" encoding="UTF-8"?> -<selected> +#set( $size = $selectedUnits.size() ) +{ "selectedUnits": [ #foreach( $unit in $selectedUnits ) - <unitId>$unit.id</unitId> + { + "id":"${unit.id}", + "name":"$encoder.jsonEncode( ${unit.name} )" + }#if( $velocityCount < $size ),#end #end -</selected> +] } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-07-21 15:16:53 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-07-22 09:17:04 +0000 @@ -123,19 +123,19 @@ </action> <action name="setorgunit" class="org.hisp.dhis.oust.action.SetSelectedOrganisationUnitAction"> - <result name="success" type="velocity"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> <action name="addorgunit" class="org.hisp.dhis.oust.action.AddSelectedOrganisationUnitAction"> - <result name="success" type="velocity"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> <action name="removeorgunit" class="org.hisp.dhis.oust.action.RemoveSelectedOrganisationUnitAction"> - <result name="success" type="velocity"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> @@ -149,7 +149,7 @@ </action> <action name="selectallorgunit" class="org.hisp.dhis.oust.action.SelectAllOrganisationUnitAction"> - <result name="success" type="velocity-xml"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> @@ -179,19 +179,19 @@ </action> <action name="setorgunit" class="org.hisp.dhis.ouwt.action.SetSelectedOrganisationUnitAction"> - <result name="success" type="velocity-xml"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> <action name="addorgunit" class="org.hisp.dhis.ouwt.action.AddSelectedOrganisationUnitAction"> - <result name="success" type="velocity-xml"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> <action name="removeorgunit" class="org.hisp.dhis.ouwt.action.RemoveSelectedOrganisationUnitAction"> - <result name="success" type="velocity-xml"> + <result name="success" type="velocity-json"> /dhis-web-commons/ouwt/responseSelect.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java 2011-07-22 08:19:01 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java 2011-07-22 09:17:04 +0000 @@ -96,14 +96,7 @@ { return dataSets; } - - private OrganisationUnit organisationUnit; - - public OrganisationUnit getOrganisationUnit() - { - return organisationUnit; - } - + private boolean dataSetValid; public boolean isDataSetValid() @@ -117,7 +110,7 @@ public String execute() { - organisationUnit = selectionManager.getSelectedOrganisationUnit(); + OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); if ( organisationUnit != null ) { === 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 2011-07-22 08:19:01 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-07-22 09:17:04 +0000 @@ -116,9 +116,10 @@ // OrganisationUnit Selection // ----------------------------------------------------------------------------- -function organisationUnitSelected( orgUnits ) +function organisationUnitSelected( orgUnits, orgUnitNames ) { currentOrganisationUnitId = orgUnits[0]; + var organisationUnitName = orgUnitNames[0]; $( '#selectedDataSetId' ).removeAttr( 'disabled' ); @@ -131,8 +132,8 @@ $.getJSON( url, { dataSetId:dataSetId }, function( json ) { - $( '#selectedOrganisationUnit' ).val( json.organisationUnit.name ); - $( '#currentOrganisationUnit' ).html( json.organisationUnit.name ); + $( '#selectedOrganisationUnit' ).val( organisationUnitName ); + $( '#currentOrganisationUnit' ).html( organisationUnitName ); addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' ); === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSets.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSets.vm 2011-07-22 08:19:01 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataSets.vm 2011-07-22 09:17:04 +0000 @@ -6,10 +6,5 @@ "name": "$!encoder.jsonEncode( ${dataSet.name} )" }#if( $velocityCount < $size ),#end #end ], - "organisationUnit": - { - "id": $!{organisationUnit.id}, - "name": "$!encoder.jsonEncode( ${organisationUnit.name} )" - }, "dataSetValid": ${dataSetValid} } \ No newline at end of file
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp