dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16175
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6079: Reimplemented org unit hierarchy operations using jquery
------------------------------------------------------------
revno: 6079
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-02-22 16:04:08 +0100
message:
Reimplemented org unit hierarchy operations using jquery
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/hierarchyOperations.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.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-organisationunit/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2012-02-13 20:04:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2012-02-22 15:04:08 +0000
@@ -28,10 +28,8 @@
</action>
<action name="validateOrganisationUnit" class="org.hisp.dhis.oum.action.organisationunit.ValidateOrganisationUnitAction">
- <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm
- </result>
- <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm
- </result>
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="error" type="velocity-json">../dhis-web-commons/ajax/jsonResponseError.vm</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -224,30 +222,16 @@
<param name="requiredAuthorities">F_ORGANISATIONUNIT_MOVE</param>
</action>
- <action name="validateOrganisationUnitToMove" class="org.hisp.dhis.oum.action.hierarchy.ValidateOrganisationUnitToMoveAction">
- <result name="success" type="velocity-xml">
- /dhis-web-maintenance-organisationunit/responseSuccess.vm
- </result>
- <result name="error" type="velocity-xml">
- /dhis-web-maintenance-organisationunit/responseError.vm
- </result>
- <result name="input" type="velocity-xml">
- /dhis-web-maintenance-organisationunit/responseInput.vm
- </result>
+ <action name="validateOrganisationUnitToMove" class="org.hisp.dhis.oum.action.hierarchy.ValidateOrganisationUnitToMoveAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="input" type="velocity-json">../dhis-web-commons/ajax/jsonResponseInput.vm</result>
<param name="onExceptionReturn">plainTextError</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_MOVE</param>
</action>
- <action name="validateNewParentOrganisationUnit" class="org.hisp.dhis.oum.action.hierarchy.ValidateNewParentOrganisationUnitAction">
- <result name="success" type="velocity-xml">
- /dhis-web-maintenance-organisationunit/responseSuccess.vm
- </result>
- <result name="error" type="velocity-xml">
- /dhis-web-maintenance-organisationunit/responseError.vm
- </result>
- <result name="input" type="velocity-xml">
- /dhis-web-maintenance-organisationunit/responseInput.vm
- </result>
+ <action name="validateNewParentOrganisationUnit" class="org.hisp.dhis.oum.action.hierarchy.ValidateNewParentOrganisationUnitAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="input" type="velocity-json">../dhis-web-commons/ajax/jsonResponseInput.vm</result>
<param name="onExceptionReturn">plainTextError</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_MOVE</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/hierarchyOperations.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/hierarchyOperations.js 2011-08-19 21:33:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/hierarchyOperations.js 2012-02-22 15:04:08 +0000
@@ -3,60 +3,45 @@
// Organisation unit to move
// -----------------------------------------------------------------------------
+selection.setListenerFunction( organisationUnitToMoveSelected );
+
function organisationUnitToMoveSelected( orgUnitIds )
{
hideHeaderMessage();
if ( orgUnitIds.length == 1 )
{
- var request = new Request();
- request.setResponseTypeXML( 'organisationUnit' );
- request.setCallbackSuccess( organisationUnitToMoveReceived );
- request.send( '../dhis-web-commons-ajax/getOrganisationUnit.action?id=' + orgUnitIds[0] );
+ var id = orgUnitIds[0];
+
+ $.getJSON( '../dhis-web-commons-ajax-json/getOrganisationUnit.action', { id:id }, function( json )
+ {
+ $( '#organisationUnitToMoveId' ).val( id );
+ $( '#toMoveNameField' ).html( json.organisationUnit.name );
+ $( '#confirmOrganisationUnitToMoveButton' ).removeAttr( 'disabled' );
+ } );
}
}
-selection.setListenerFunction( organisationUnitToMoveSelected );
-
-function organisationUnitToMoveReceived( unitElement )
-{
- var organisationUnit = parseUnitElement( unitElement );
-
- document.getElementById( 'organisationUnitToMoveId' ).value = organisationUnit['id'];
- document.getElementById( 'toMoveNameField' ).innerHTML = organisationUnit['name'];
-
- document.getElementById( 'confirmOrganisationUnitToMoveButton' ).disabled = false;
-}
-
function organisationUnitToMoveConfirmed()
{
- var id = document.getElementById( 'organisationUnitToMoveId' ).value;
-
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( organisationUnitToMoveFeedback );
- request.send( 'validateOrganisationUnitToMove.action?organisationUnitToMoveId=' + id );
-}
-
-function organisationUnitToMoveFeedback( messageElement )
-{
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
-
- if ( type == 'success' )
- {
- document.getElementById( 'confirmOrganisationUnitToMoveButton' ).disabled = true;
- document.getElementById( 'confirmNewParentOrganisationUnitButton' ).disabled = false;
-
- document.getElementById( 'step1' ).style.backgroundColor = 'white';
- document.getElementById( 'step2' ).style.backgroundColor = '#ccffcc';
-
- selection.setListenerFunction( newParentSelected );
- }
- else if ( type == 'input' || type == 'error' )
- {
- setHeaderMessage( message );
- }
+ var id = $( '#organisationUnitToMoveId' ).val();
+
+ $.getJSON( 'validateOrganisationUnitToMove.action', { organisationUnitToMoveId:id }, function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ $( '#confirmOrganisationUnitToMoveButton' ).attr( 'disabled', 'disabled' );
+
+ $( '#step1' ).css( 'background-color', '#ffffff' );
+ $( '#step2' ).css( 'background-color', '#ccffcc' );
+
+ selection.setListenerFunction( newParentSelected );
+ }
+ else
+ {
+ setHeaderMessage( json.message );
+ }
+ } );
}
// -----------------------------------------------------------------------------
@@ -69,69 +54,43 @@
if ( orgUnitIds.length == 1 )
{
- var request = new Request();
- request.setResponseTypeXML( 'organisationUnit' );
- request.setCallbackSuccess( newParentOrganisationUnitReceived );
- request.send( '../dhis-web-commons-ajax/getOrganisationUnit.action?id=' + orgUnitIds[0] );
+ var id = orgUnitIds[0];
+
+ $.getJSON( '../dhis-web-commons-ajax-json/getOrganisationUnit.action', { id:id }, function( json )
+ {
+ $( '#newParentOrganisationUnitId' ).val( id );
+ $( '#newParentNameField' ).html( json.organisationUnit.name );
+ $( '#confirmNewParentOrganisationUnitButton' ).removeAttr( 'disabled' );
+ } );
}
else if ( orgUnitIds.length == 0 )
{
- document.getElementById( 'newParentOrganisationUnitId' ).value = '';
- document.getElementById( 'newParentNameField' ).innerHTML = '[' + not_selected_moved_to_root_position + ']';
+ $( '#newParentOrganisationUnitId' ).val( '' );
+ $( '#newParentNameField' ).html( '[' + not_selected_moved_to_root_position + ']' );
}
}
-function newParentOrganisationUnitReceived( unitElement )
-{
- var organisationUnit = parseUnitElement( unitElement );
-
- document.getElementById( 'newParentOrganisationUnitId' ).value = organisationUnit['id'];
- document.getElementById( 'newParentNameField' ).innerHTML = organisationUnit['name'];
-}
-
function newParentOrganisationUnitConfirmed()
{
- var toMoveId = document.getElementById( 'organisationUnitToMoveId' ).value;
- var newParentId = document.getElementById( 'newParentOrganisationUnitId' ).value;
-
- var request = new Request();
- request.setResponseTypeXML( 'message' );
- request.setCallbackSuccess( newParentOrganisationUnitFeedback );
- request.send( 'validateNewParentOrganisationUnit.action?organisationUnitToMoveId=' + toMoveId +
- '&newParentOrganisationUnitId=' + newParentId );
-}
-
-function newParentOrganisationUnitFeedback( messageElement )
-{
- var type = messageElement.getAttribute( 'type' );
- var message = messageElement.firstChild.nodeValue;
-
- if ( type == 'success' )
- {
- document.getElementById( 'confirmNewParentOrganisationUnitButton' ).disabled = true;
- document.getElementById( 'submitButton' ).disabled = false;
-
- document.getElementById( 'step2' ).style.backgroundColor = 'white';
- document.getElementById( 'step3' ).style.backgroundColor = '#ccffcc';
-
- selection.setListenerFunction( null );
- }
- else if ( type == 'input' || type == 'error' )
- {
- setHeaderMessage( message );
- }
-}
-
-// -----------------------------------------------------------------------------
-// Common
-// -----------------------------------------------------------------------------
-
-function parseUnitElement( unitElement )
-{
- var organisationUnit = new Object();
-
- organisationUnit['id'] = unitElement.getElementsByTagName( 'id' )[0].firstChild.nodeValue;
- organisationUnit['name'] = unitElement.getElementsByTagName( 'name' )[0].firstChild.nodeValue;
-
- return organisationUnit;
+ var toMoveId = $( '#organisationUnitToMoveId' ).val();
+ var newParentId = $( '#newParentOrganisationUnitId' ).val();
+
+ $.getJSON( 'validateNewParentOrganisationUnit.action', {
+ organisationUnitToMoveId:toMoveId, newParentOrganisationUnitId:newParentId }, function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ $( '#confirmNewParentOrganisationUnitButton' ).attr( 'disabled', 'disabled' );
+ $( '#submitButton' ).removeAttr( 'disabled' );
+
+ $( '#step2' ).css( 'background-color', '#ffffff' );
+ $( '#step3' ).css( 'background-color', '#ccffcc' );
+
+ selection.setListenerFunction( null );
+ }
+ else
+ {
+ setHeaderMessage( message );
+ }
+ } );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm 2011-12-05 04:46:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm 2012-02-22 15:04:08 +0000
@@ -20,17 +20,14 @@
<th>$i18n.getString( "criteria" )</th>
<th>$i18n.getString( "options" )</th>
</tr>
-
<tr>
<td>$i18n.getString( "organisation_unit" )</td>
<td><input type="text" id="selectedOrganisationUnit" style="width:360px" readonly="true" value="${orgUnitText}"/></td>
</tr>
-
<tr>
<td>$i18n.getString( "name" )</th>
<td><input type="text" name="name" style="width:360px" value="$!{name}"/></td>
</tr>
-
#foreach( $groupSet in $groupSets )
<tr>
<td>$encoder.htmlEncode( $groupSet.name )</td>
@@ -45,26 +42,23 @@
</td>
</tr>
#end
-
<tr>
<td style="height:10px" colspan="2"></td>
</tr>
-
<tr>
<td></td>
<td><input type="button" value="$i18n.getString( 'search' )" style="width:120px" onclick="download( '' )"/><input
type="button" onclick="window.location.href='organisationUnitSearch.action?skipSearch=true'" value="$i18n.getString( 'clear' )" style="width:120px"/></td>
</tr>
-
<tr>
<td style="height:2px" colspan="2"></td>
</tr>
-
<tr>
<td></td>
- <td><input type="button" value="$i18n.getString( 'get_report_as_pdf' )" style="width:120px" onclick="download( 'pdf' )"/><input
- type="button" value="$i18n.getString( 'get_report_as_xls' )" style="width:120px" onclick="download( 'xls' )"/><input
- type="button" value="$i18n.getString( 'get_report_as_csv' )" style="width:120px" onclick="download( 'csv' )"/></td>
+ <td><input type="button" value="$i18n.getString( 'get_report_as_pdf' )" style="width:120px" onclick="download( 'pdf' )"/>
+ <input type="button" value="$i18n.getString( 'get_report_as_xls' )" style="width:120px" onclick="download( 'xls' )"/>
+ <input type="button" value="$i18n.getString( 'get_report_as_csv' )" style="width:120px" onclick="download( 'csv' )"/>
+ </td>
</tr>
<tr>
@@ -88,7 +82,7 @@
#foreach( $groupSet in $groupSets )
<th>$encoder.htmlEncode( $groupSet.name )</th>
#end
- <th class="{sorter: false}"></th>
+ <th class="{sorter: false}" style="width:60px"></th>
</tr>
</thead>