dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05032
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1683: Dataelement/indicatorgroup editor view 2 doesn't work.
------------------------------------------------------------
revno: 1683
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-03-22 17:21:47 +0700
message:
Dataelement/indicatorgroup editor view 2 doesn't work.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AssignGroupsForDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroup/AssignGroupsForIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView2.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView2.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/indicatorGroupEditorView2.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.
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AssignGroupsForDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AssignGroupsForDataElementAction.java 2010-02-25 08:57:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AssignGroupsForDataElementAction.java 2010-03-22 10:21:47 +0000
@@ -1,7 +1,5 @@
package org.hisp.dhis.dd.action.dataelementgroup;
-
-
/*
* Copyright (c) 2004-2007, University of Oslo
* All rights reserved.
@@ -30,6 +28,8 @@
*/
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
@@ -39,7 +39,7 @@
/**
* @author Tran Thanh Tri
- * @version $Id:
+ * @version $Id: AssignGroupsForDataElementAction.java 2869 2010-03-27 14:26:09Z Chau Thu Tran $
*/
public class AssignGroupsForDataElementAction
@@ -79,20 +79,32 @@
public String execute()
throws Exception
{
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ Set<DataElementGroup> selectedGroups = new HashSet<DataElementGroup>();
for ( Integer id : dataElementGroups )
{
DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( id );
-
+
+ selectedGroups.add( dataElementGroup );
+
dataElementGroup.getMembers().add( dataElement );
-
+
dataElementService.updateDataElementGroup( dataElementGroup );
- }
-
+ }
+
+ Set<DataElementGroup>removeGroups = new HashSet<DataElementGroup>( dataElementService
+ .getGroupsContainingDataElement( dataElement ) );
+ removeGroups.removeAll( selectedGroups );
+
+ for ( DataElementGroup removeGroup : removeGroups )
+ {
+ removeGroup.getMembers().remove( dataElement );
+ dataElementService.updateDataElementGroup( removeGroup );
+ }
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroup/AssignGroupsForIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroup/AssignGroupsForIndicatorAction.java 2010-02-26 06:40:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicatorgroup/AssignGroupsForIndicatorAction.java 2010-03-22 10:21:47 +0000
@@ -28,6 +28,8 @@
*/
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
@@ -37,7 +39,8 @@
/**
* @author Tran Thanh Tri
- * @version $Id: $
+ * @version $Id: AssignGroupsForIndicatorAction.java 2869 2010-03-27 15:01:079Z
+ * Chau Thu Tran $
*/
public class AssignGroupsForIndicatorAction
implements Action
@@ -79,16 +82,30 @@
Indicator indicator = indicatorService.getIndicator( indicatorId );
+ Set<IndicatorGroup> selectedGroups = new HashSet<IndicatorGroup>();
+
for ( Integer id : indicatorGroups )
{
IndicatorGroup group = indicatorService.getIndicatorGroup( id );
+ selectedGroups.add( group );
+
group.getMembers().add( indicator );
indicatorService.updateIndicatorGroup( group );
}
+ Set<IndicatorGroup> removeGroups = new HashSet<IndicatorGroup>( indicatorService
+ .getGroupsContainingIndicator( indicator ) );
+ removeGroups.removeAll( selectedGroups );
+
+ for ( IndicatorGroup removeGroup : removeGroups )
+ {
+ removeGroup.getMembers().remove( indicator );
+ indicatorService.updateIndicatorGroup( removeGroup );
+ }
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView2.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView2.vm 2010-02-25 19:44:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView2.vm 2010-03-22 10:21:47 +0000
@@ -22,12 +22,12 @@
$i18n.getString( "data_element_group_management" ) #openHelp( "dataElementGroupEditor" )
</h3>
-<span id='message' style="position:fixed;top:80px;right:5px;"></span>
+<span id='message' style="position:fixed;top:80px;right:5px;" onclick="hideById('message');"></span>
<table >
<tr>
<th>$i18n.getString( "available_dataelements" )</th>
- <th><span id="groupNameView" style="display:block;"></span></th>
+ <th><span id="groupNameView" style="display:block;"><span id="groupNameView" style="display:block;">$i18n.getString( "data_element_groups" )</span></span></th>
<td rowspan="2" style="text-align:center"><a href="dataElementGroupEditor.action" title="$i18n.getString( 'switch_view' )"><img src="../images/arrow_double_clockwise_y.png" title="$i18n.getString( 'switch_view' )"></a></td>
<th>$i18n.getString( "available_groups" )</th>
</tr>
@@ -52,9 +52,9 @@
<input type="button" value=">" onclick="removeSelectedGroups();" style="width:42px">
</td>
<td>
- <select class="select" id="availableGroups" multiple="multiple" size="30" ondblclick="addSelectedGroups()" onMouseOut="javascript: hideToolTip();">
- </select>
- </td>
+ <select name="select" size="30" multiple="multiple" class="select" id="availableGroups" ondblclick="addSelectedGroups()" onmouseout="javascript: hideToolTip();">
+ </select>
+</td>
</tr>
<tr>
<td></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView2.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView2.js 2010-03-18 23:56:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView2.js 2010-03-22 10:21:47 +0000
@@ -71,13 +71,34 @@
}
filterAssignedGroups();
+ visableAvailableDataElementGroups();
+}
+
+function visableAvailableDataElementGroups()
+{
+ var assignedGroups = byId( 'assignedGroups' );
+ var availableGroups = byId( 'availableGroups' );
+ var assignedOptions = assignedGroups.options;
+ var availableOptions = availableGroups.options;
+ for(var i=0;i<availableGroups.length;i++){
+ availableGroups.options[i].style.display='block';
+ for(var j=0;j<assignedOptions.length;j++){
+ if(availableGroups[i].value==assignedOptions[j].value){
+ availableGroups.options[i].style.display='none';
+ }
+ }
+ }
}
-
function addSelectedGroups()
{
- var list = document.getElementById( 'availableGroups' );
+ if(byId('availableDataElements').selectedIndex == -1){
+ setMessage(i18n_select_dataelement_group);
+ return;
+ }
+
+ var list = byId( 'availableGroups' );
while ( list.selectedIndex != -1 )
{
@@ -89,12 +110,13 @@
}
- filterAssignedGroups();
+ filterAssignedGroups();
+ visableAvailableDataElementGroups();
}
function removeSelectedGroups()
{
- var list = document.getElementById( 'assignedGroups' );
+ var list = byId( 'assignedGroups' );
while ( list.selectedIndex != -1 )
{
@@ -102,18 +124,19 @@
list.options[list.selectedIndex].selected = false;
- availableGroups[id] = assignedGroups[id];
-
- delete assignedGroups[id];
+ availableGroups[id] = assignedGroups[id];
+
+ delete assignedGroups[id];
}
- filterAssignedGroups();
+ filterAssignedGroups();
+ visableAvailableDataElementGroups();
}
function filterAvailableDataElements()
{
- var filter = document.getElementById( 'availableDataElementsFilter' ).value;
- var list = document.getElementById( 'availableDataElements' );
+ var filter = byId( 'availableDataElementsFilter' ).value;
+ var list = byId( 'availableDataElements' );
list.options.length = 0;
@@ -134,8 +157,8 @@
function filterAssignedGroups()
{
- var filter = document.getElementById( 'assignedGroupsFilter' ).value;
- var list = document.getElementById( 'assignedGroups' );
+ var filter = byId( 'assignedGroupsFilter' ).value;
+ var list = byId( 'assignedGroups' );
list.options.length = 0;
@@ -149,16 +172,15 @@
option.onmousemove = function(e){
showToolTip( e, value);
}
- list.add( option, null );
-
+ list.add( option, null );
}
}
}
function filterAvailableGroups()
{
- var filter = document.getElementById( 'availableGroupsFilter' ).value;
- var list = document.getElementById( 'availableGroups' );
+ var filter = byId( 'availableGroupsFilter' ).value;
+ var list = byId( 'availableGroups' );
list.options.length = 0;
@@ -180,7 +202,7 @@
function deleteDataElementGroup()
{
- var dataElementGroupsSelect = document.getElementById( 'availableGroups' );
+ var dataElementGroupsSelect = byId( 'availableGroups' );
try
{
@@ -206,7 +228,7 @@
if ( type=='success' )
{
- var dataElementGroupsSelect = document.getElementById( 'availableGroups' );
+ var dataElementGroupsSelect = byId( 'availableGroups' );
dataElementGroupsSelect.remove( dataElementGroupsSelect.selectedIndex );
}
}
@@ -232,7 +254,7 @@
function validateRenameDataElementGroup()
{
- var dataElementGroupsSelect = document.getElementById( 'availableGroups' );
+ var dataElementGroupsSelect = byId( 'availableGroups' );
var id = dataElementGroupsSelect.options[ dataElementGroupsSelect.selectedIndex ].value;
var name = document.getElementById( 'groupName' ).value;
var request = new Request();
@@ -270,17 +292,25 @@
function renameDataElementGroupReceived( xmlObject )
{
var name = xmlObject.getElementsByTagName( "name" )[0].firstChild.nodeValue;
- var list = document.getElementById( 'availableGroups' );
- list.options[ list.selectedIndex ].text = name;
- document.getElementById( 'groupNameView' ).innerHTML = name;
+ var id = xmlObject.getElementsByTagName( "id" )[0].firstChild.nodeValue;
+
+ var list = byId( 'availableGroups' );
+ availableGroups[id] = name;
+ var option = list.options[ list.selectedIndex ];
+ option.text = name;
+ option.onmousemove = function(e){
+ showToolTip( e, name);
+ }
+
+ byId( 'groupNameView' ).innerHTML = name;
showHideDiv( 'addDataElementGroupForm' );
deleteDivEffect();
}
function showAddDataElementGroupForm()
{
- document.getElementById( 'groupName' ).value='';
- document.getElementById( 'addRenameGroupButton' ).onclick=validateAddDataElementGroup;
+ byId( 'groupName' ).value='';
+ byId( 'addRenameGroupButton' ).onclick=validateAddDataElementGroup;
setPositionCenter( 'addDataElementGroupForm' );
showById('addDataElementGroupForm');
showDivEffect();
@@ -288,7 +318,7 @@
function validateAddDataElementGroup()
{
- var name = document.getElementById( 'groupName' ).value;
+ var name = byId( 'groupName' ).value;
var request = new Request();
request.setResponseTypeXML( 'xmlObject' );
request.setCallbackSuccess( validateAddDataElementGroupReceived );
@@ -311,7 +341,7 @@
function createNewGroup()
{
- var name = document.getElementById( 'groupName' ).value;
+ var name = byId( 'groupName' ).value;
var request = new Request();
request.setResponseTypeXML( 'xmlObject' );
request.setCallbackSuccess( createNewGroupReceived );
@@ -323,7 +353,14 @@
var id = xmlObject.getElementsByTagName( "id" )[0].firstChild.nodeValue;
var name = xmlObject.getElementsByTagName( "name" )[0].firstChild.nodeValue;
availableGroups[id] = name;
- filterAvailableGroups();
+ var list = byId( 'availableGroups' );
+ var option = new Option(name, id);
+ option.text = name;
+ option.onmousemove = function(e){
+ showToolTip( e, name);
+ }
+ list.add(option, null);
+ //filterAvailableGroups();
showHideDiv( 'addDataElementGroupForm' );
deleteDivEffect();
}
@@ -350,6 +387,7 @@
{
params += '&dataElementGroups=' + selectedGroups.options[i].value;
}
+
request.sendAsPost( params );
request.setResponseTypeXML( 'message' );
request.setCallbackSuccess( assignGroupsForDataElementReceived );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/indicatorGroupEditorView2.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/indicatorGroupEditorView2.js 2010-03-11 13:32:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/indicatorGroupEditorView2.js 2010-03-22 10:21:47 +0000
@@ -71,7 +71,8 @@
}
- filterAssignedGroups();
+ filterAssignedGroups();
+ visableAvailableIndicatorGroups();
}
function removeSelectedGroups()
@@ -89,7 +90,8 @@
delete assignedGroups[id];
}
- filterAssignedGroups();
+ filterAssignedGroups();
+ visableAvailableIndicatorGroups();
}
/*==============================================================================
@@ -99,17 +101,17 @@
function getAssignedIndicatorGroups( indicatorId )
{
var request = new Request();
- request.setResponseTypeXML( 'indicatorGroups' );
+ request.setResponseTypeXML( 'xmlObject' );
request.setCallbackSuccess( getAssignedIndicatorGroupsCompleted );
request.send( 'getAssignedIndicatorGroups.action?indicatorId=' + indicatorId );
}
-function getAssignedIndicatorGroupsCompleted( indicatorGroups )
+function getAssignedIndicatorGroupsCompleted( xmlObject )
{
assignedGroups = new Object();
- var availableIndicatorGroups = indicatorGroups.getElementsByTagName( 'indicatorGroup' );
-
+ var availableIndicatorGroups = xmlObject.getElementsByTagName( 'indicatorGroup' );
+
for( var i=0;i<availableIndicatorGroups.length;i++)
{
var id = availableIndicatorGroups.item(i).getElementsByTagName( 'id' )[0].firstChild.nodeValue;
@@ -118,6 +120,23 @@
}
filterAssignedGroups();
+ visableAvailableIndicatorGroups();
+}
+
+function visableAvailableIndicatorGroups()
+{
+ var assignedGroups = byId( 'assignedGroups' );
+ var availableGroups = byId( 'availableGroups' );
+ var assignedOptions = assignedGroups.options;
+ var availableOptions = availableGroups.options;
+ for(var i=0;i<availableGroups.length;i++){
+ availableGroups.options[i].style.display='block';
+ for(var j=0;j<assignedOptions.length;j++){
+ if(availableGroups[i].value==assignedOptions[j].value){
+ availableGroups.options[i].style.display ='none';
+ }
+ }
+ }
}
/*==============================================================================
@@ -242,7 +261,14 @@
var id = xmlObject.getElementsByTagName( "id" )[0].firstChild.nodeValue;
var name = xmlObject.getElementsByTagName( "name" )[0].firstChild.nodeValue;
availableGroups[id] = name;
- filterAvailableGroups();
+ var list = byId( 'availableGroups' );
+ var option = new Option(name, id);
+ option.text = name;
+ option.onmousemove = function(e){
+ showToolTip( e, name);
+ }
+ list.add(option, null);
+ //filterAvailableGroups();
toggleById( 'addIndicatorGroupForm' );
deleteDivEffect();
}
@@ -299,12 +325,28 @@
var name = document.getElementById( 'groupName' ).value;
var request = new Request();
request.setResponseTypeXML( 'xmlObject' );
- request.setCallbackSuccess( createNewGroupReceived );
+ request.setCallbackSuccess( renameGroupReceived );
var params = "name=" + name + "&mode=editor&id=" + byId('availableGroups').value;
request.sendAsPost( params );
request.send( 'renameIndicatorGroupEditor.action');
}
+function renameGroupReceived( xmlObject )
+{
+ var id = xmlObject.getElementsByTagName( "id" )[0].firstChild.nodeValue;
+ var name = xmlObject.getElementsByTagName( "name" )[0].firstChild.nodeValue;
+ availableGroups[id] = name;
+ var list = byId( 'availableGroups' );
+ var option = list.options[ list.selectedIndex ];
+ option.text = name;
+ option.onmousemove = function(e){
+ showToolTip( e, name);
+ }
+ list.add(option, null);
+ //filterAvailableGroups();
+ toggleById( 'addIndicatorGroupForm' );
+ deleteDivEffect();
+}
/*==============================================================================
* Update Member of Indicator Group