dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02714
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 905: add deleted file, i confused
------------------------------------------------------------
revno: 905
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Mon 2009-10-26 22:50:56 +0700
message:
add deleted file,i confused
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js
--
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.
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.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/dataElementGroup.js 2009-10-26 15:50:56 +0000
@@ -0,0 +1,206 @@
+// -----------------------------------------------------------------------------
+// View details
+// -----------------------------------------------------------------------------
+
+function showDataElementGroupDetails( dataElementGroupId )
+{
+ var request = new Request();
+ request.setResponseTypeXML( 'dataElementGroup' );
+ request.setCallbackSuccess( dataElementGroupReceived );
+ request.send( 'getDataElementGroup.action?id=' + dataElementGroupId );
+}
+
+function dataElementGroupReceived( dataElementGroupElement )
+{
+ setFieldValue( 'nameField', getElementValue( dataElementGroupElement, 'name' ) );
+ setFieldValue( 'memberCountField', getElementValue( dataElementGroupElement, 'memberCount' ) );
+
+ showDetails();
+}
+
+// -----------------------------------------------------------------------------
+// Remove data element group
+// -----------------------------------------------------------------------------
+
+function removeDataElementGroup( dataElementGroupId, dataElementGroupName )
+{
+ var result = window.confirm( i18n_confirm_delete + '\n\n' + dataElementGroupName );
+
+ if ( result )
+ {
+ window.location.href = 'removeDataElementGroup.action?id=' + dataElementGroupId;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Add data element group
+// -----------------------------------------------------------------------------
+
+function validateAddDataElementGroup()
+{
+ var request = new Request();
+ request.setResponseTypeXML( 'message' );
+ request.setCallbackSuccess( addValidationCompleted );
+ request.send( 'validateDataElementGroup.action?name=' + getFieldValue( 'name' ) );
+
+ return false;
+}
+
+function addValidationCompleted( messageElement )
+{
+ var type = messageElement.getAttribute( 'type' );
+ var message = messageElement.firstChild.nodeValue;
+
+ if ( type == 'success' )
+ {
+ var availableDataElements = document.getElementById( 'availableDataElements' );
+ availableDataElements.selectedIndex = -1;
+
+ selectAllById( 'groupMembers' );
+
+ document.getElementById( 'addDataElementGroupForm' ).submit();
+ }
+ else if ( type == 'error' )
+ {
+ window.alert( i18n_adding_data_element_group_failed + ':' + '\n' + message );
+ }
+ else if ( type == 'input' )
+ {
+ setMessage( message );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Update data element group
+// -----------------------------------------------------------------------------
+
+function validateUpdateDataElementGroup()
+{
+ var request = new Request();
+ request.setResponseTypeXML( 'message' );
+ request.setCallbackSuccess( updateValidationCompleted );
+ request.send( 'validateDataElementGroup.action?id=' + getFieldValue( 'id' ) +
+ '&name=' + getFieldValue( 'name' ) );
+
+ return false;
+}
+
+function updateValidationCompleted( messageElement )
+{
+ var type = messageElement.getAttribute( 'type' );
+ var message = messageElement.firstChild.nodeValue;
+
+ if ( type == 'success' )
+ {
+ var availableDataElements = document.getElementById( 'availableDataElements' );
+ availableDataElements.selectedIndex = -1;
+
+ selectAllById( 'groupMembers' );
+
+ document.getElementById( 'updateDataElementGroupForm' ).submit();
+ }
+ else if ( type == 'error' )
+ {
+ window.alert( i18n_saving_data_element_group_failed + ':' + '\n' + message );
+ }
+ else if ( type == 'input' )
+ {
+ setMessage( message );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Select lists
+// -----------------------------------------------------------------------------
+
+function initLists()
+{
+ var list = document.getElementById( 'groupMembers' );
+ var id;
+
+ for ( id in groupMembers )
+ {
+ list.add( new Option( groupMembers[id], id ), null );
+ }
+
+ list = document.getElementById( 'availableDataElements' );
+
+ for ( id in availableDataElements )
+ {
+ list.add( new Option( availableDataElements[id], id ), null );
+ }
+}
+
+function filterGroupMembers()
+{
+ var filter = document.getElementById( 'groupMembersFilter' ).value;
+ var list = document.getElementById( 'groupMembers' );
+
+ list.options.length = 0;
+
+ for ( var id in groupMembers )
+ {
+ var value = groupMembers[id];
+
+ if ( value.toLowerCase().indexOf( filter.toLowerCase() ) != -1 )
+ {
+ list.add( new Option( value, id ), null );
+ }
+ }
+}
+
+function filterAvailableDataElements()
+{
+ var filter = document.getElementById( 'availableDataElementsFilter' ).value;
+ var list = document.getElementById( 'availableDataElements' );
+
+ list.options.length = 0;
+
+ for ( var id in availableDataElements )
+ {
+ var value = availableDataElements[id];
+
+ if ( value.toLowerCase().indexOf( filter.toLowerCase() ) != -1 )
+ {
+ list.add( new Option( value, id ), null );
+ }
+ }
+}
+
+function addGroupMembers()
+{
+ var list = document.getElementById( 'availableDataElements' );
+
+ while ( list.selectedIndex != -1 )
+ {
+ var id = list.options[list.selectedIndex].value;
+
+ list.options[list.selectedIndex].selected = false;
+
+ groupMembers[id] = availableDataElements[id];
+
+ delete availableDataElements[id];
+ }
+
+ filterGroupMembers();
+ filterAvailableDataElements();
+}
+
+function removeGroupMembers()
+{
+ var list = document.getElementById( 'groupMembers' );
+
+ while ( list.selectedIndex != -1 )
+ {
+ var id = list.options[list.selectedIndex].value;
+
+ list.options[list.selectedIndex].selected = false;
+
+ //availableDataElements[id] = groupMembers[id];
+
+ delete groupMembers[id];
+ }
+
+ filterGroupMembers();
+ filterAvailableDataElements();
+}