dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36241
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18557: Fixed bug - Exception thrown when to create new, rename, update data element Group member in View...
------------------------------------------------------------
revno: 18557
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-10 18:58:42 +0700
message:
Fixed bug - Exception thrown when to create new, rename, update data element Group member in View 1 and 2; and no group is displayed when a DE is selected in View 2 ( Data Element Group Editor form )
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/dataelementgroup/GetAssignedGroupsByDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/AssignGroupsForDataElementAction.java 2015-03-10 11:58:42 +0000
@@ -58,9 +58,9 @@
// Input & Output
// -------------------------------------------------------------------------
- private Integer dataElementId;
+ private String dataElementId;
- public void setDataElementId( Integer dataElementId )
+ public void setDataElementId( String dataElementId )
{
this.dataElementId = dataElementId;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetAssignedGroupsByDataElementAction.java 2015-03-10 11:58:42 +0000
@@ -61,9 +61,9 @@
// Input & Output
// -------------------------------------------------------------------------
- private Integer dataElementId;
+ private String dataElementId;
- public void setDataElementId( Integer dataElementId )
+ public void setDataElementId( String dataElementId )
{
this.dataElementId = dataElementId;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView.vm 2014-08-28 09:15:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupEditorView.vm 2015-03-10 11:58:42 +0000
@@ -1,12 +1,16 @@
<script type="text/javascript">
var dataElementGroups = new Array();
+ var dataElementGroupShortNames = new Array();
+ var dataElementGroupCodes = new Array();
#foreach( $dataElementGroup in $dataElementGroups )
dataElementGroups['$dataElementGroup.id'] = '$encoder.jsEscape( $dataElementGroup.displayName, "'" )';
+ dataElementGroupShortNames['$dataElementGroup.id'] = '$!encoder.jsEscape( $dataElementGroup.shortName, "'" )';
+ dataElementGroupCodes['$dataElementGroup.id'] = '$!encoder.jsEscape( $dataElementGroup.code, "'" )';
#end
var availableDataElements = new Array();
#foreach( $dataElement in $dataElements )
- availableDataElements['$dataElement.id'] = '$encoder.jsEscape( $dataElement.displayName, "'" )';
+ availableDataElements['$dataElement.uid'] = '$encoder.jsEscape( $dataElement.displayName, "'" )';
#end
var selectedDataElements = new Array();
@@ -17,7 +21,7 @@
var i18n_new = '$encoder.jsEscape( $i18n.getString( "new" ) , "'")';
var i18n_save = '$encoder.jsEscape( $i18n.getString( "save" ) , "'")';
var i18n_rename = '$encoder.jsEscape( $i18n.getString( "rename" ) , "'")';
-
+ var i18n_this_field_is_required = '$encoder.jsEscape( $i18n.getString( "this_field_is_required" ) , "'")';
</script>
<style type="text/css">
@@ -62,7 +66,7 @@
<select class="select" id="dataElementGroups" size="30" onchange="getDataElementsByGroup()"/>
</td>
<td>
- <select class="select" id="selectedDataElements" multiple="multiple" size="30" ondblclick="moveSelectedById(this.id, 'availableDataElements');" />
+ <select class="select" id="selectedDataElements" style="width:300px;" multiple="multiple" size="30" ondblclick="moveSelectedById(this.id, 'availableDataElements');" />
</td>
<td>
@@ -70,7 +74,7 @@
<input type="button" value=">" onclick="moveSelectedById('selectedDataElements', 'availableDataElements');" style="width:42px"/>
</td>
<td>
- <select class="select" id="availableDataElements" multiple="multiple" size="30" ondblclick="moveSelectedById(this.id, 'selectedDataElements');"/>
+ <select class="select" id="availableDataElements" style="width:300px;" multiple="multiple" size="30" ondblclick="moveSelectedById(this.id, 'selectedDataElements');"/>
</td>
</tr>
<tr>
@@ -113,10 +117,10 @@
<tr>
<td>
- <select class="select" id="availableDataElements2" size="30" onchange="getAssignedDataElementGroups()"/>
+ <select class="select" id="availableDataElements2" style="width:300px;" size="30" onchange="getAssignedDataElementGroups()"/>
</td>
<td>
- <select class="select" id="assignedGroups" multiple="multiple" size="30" ondblclick="moveSelectedById(this.id, 'availableGroups');"/>
+ <select class="select" id="assignedGroups" style="width:300px;" multiple="multiple" size="30" ondblclick="moveSelectedById(this.id, 'availableGroups');"/>
</td>
<td>
<input type="button" value="<" onclick="moveSelectedById('availableGroups', 'assignedGroups');" style="width:42px"/><br/><br/>
@@ -143,6 +147,18 @@
</div>
<div id="addDataElementGroupForm">
- <label>$i18n.getString( "name" )</label>
- <input type="text" id="name" name="name" style="width:20em" class="{validate:{required:true}}"/>
+ <table>
+ <tr>
+ <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="name" name="name" style="width:20em" maxlength="160" class="{validate:{required:true}}"/></td>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString( "short_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="shortName" name="shortName" style="width:20em" maxlength="50" class="{validate:{required:true}}"/></td>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString( "code" )</label></td>
+ <td><input type="text" id="code" name="code" style="width:20em" maxlength="50"/></td>
+ </tr>
+ </table>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.js 2015-03-10 07:43:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.js 2015-03-10 11:58:42 +0000
@@ -28,13 +28,13 @@
{
if( !checkSelectedDataElement( id ) )
{
- list_1.append( '<option value="' + id + '">' + text + '</option>' );
+ list_1.append( '<option value="' + id + '" title="' + text + '">' + text + '</option>' );
}
}
if ( text.toLowerCase().indexOf( filter_2.toLowerCase() ) != -1 )
{
- list_2.append( '<option value="' + id + '">' + text + '</option>' );
+ list_2.append( '<option value="' + id + '" title="' + text + '">' + text + '</option>' );
}
}
@@ -83,8 +83,8 @@
if ( text.toLowerCase().indexOf( filter_1.toLowerCase() ) != -1 )
{
- list_1.append( '<option value="' + id + '">' + text + '</option>' );
- list_2.append( '<option value="' + id + '">' + text + '</option>' );
+ list_1.append( '<option value="' + id + '" title="' + text + '">' + text + '</option>' );
+ list_2.append( '<option value="' + id + '" title="' + text + '">' + text + '</option>' );
}
}
@@ -124,11 +124,11 @@
var text = item.name;
if ( text.toLowerCase().indexOf( filter_1.toLowerCase() ) != -1 )
{
- list_1.append( '<option value="' + item.id + '">' + text + '</option>' );
+ list_1.append( '<option value="' + item.uid + '" title="' + text + '">' + text + '</option>' );
}
jQuery( "#view_1 #availableDataElements" ).children().each( function( k, it )
{
- if ( item.id == it.value )
+ if ( item.uid == it.value )
{
jQuery( it ).remove();
}
@@ -140,37 +140,59 @@
function showAddGroup()
{
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'title', i18n_new );
+ jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'width', '350px' );
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'buttons', [ {
text : i18n_save,
click : function()
{
- jQuery.postJSON( "validateDataElementGroup.action", {
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- }
- }, function( json )
- {
- if ( json.response == 'success' )
- {
- jQuery.postJSON( "addDataElementGroupEditor.action", {
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- }
- }, function( json )
- {
- dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
- loadAvailableGroups();
- loadAvailableDataElements();
- jQuery( "#view_1 #selectedDataElements" ).empty();
- jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
- } );
- } else
- {
- markInvalid( "addDataElementGroupForm #name", json.message );
- }
- } );
+ if( jQuery( '#addDataElementGroupForm #name' ).val() == "" ){
+ markValid( "addDataElementGroupForm #shortName" );
+ markInvalid( "addDataElementGroupForm #name", i18n_this_field_is_required );
+ }
+ else if( jQuery( '#addDataElementGroupForm #shortName' ).val() == "" ){
+ markValid( "addDataElementGroupForm #name" );
+ markInvalid( "addDataElementGroupForm #shortName", i18n_this_field_is_required );
+ }
+ else
+ {
+ jQuery.postJSON( "validateDataElementGroup.action", {
+ name : function()
+ {
+ return jQuery( '#addDataElementGroupForm #name' ).val();
+ }
+ ,shortName : function()
+ {
+ return jQuery( '#addDataElementGroupForm #shortName' ).val();
+ }
+ ,code : function()
+ {
+ return jQuery( '#addDataElementGroupForm #code' ).val();
+ }
+ }, function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ markValid( "addDataElementGroupForm #name" );
+ markValid( "addDataElementGroupForm #shortName" );
+
+ jQuery.postJSON( "addDataElementGroupEditor.action", {
+ name : jQuery( '#addDataElementGroupForm #name' ).val(),
+ shortName : jQuery( '#addDataElementGroupForm #shortName' ).val(),
+ code : jQuery( '#addDataElementGroupForm #code' ).val()
+ }, function( json )
+ {
+ dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
+ loadAvailableGroups();
+ loadAvailableDataElements();
+ jQuery( "#view_1 #selectedDataElements" ).empty();
+ jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
+ } );
+ } else
+ {
+ markInvalid( "addDataElementGroupForm #name", json.message );
+ }
+ } );
+ }
}
} ] );
@@ -180,37 +202,48 @@
function showAddGroupView2()
{
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'title', i18n_new );
+ jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'width', '350px' );
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'buttons', [ {
text : i18n_save,
click : function()
{
- jQuery.postJSON( "validateDataElementGroup.action", {
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- }
- }, function( json )
- {
- if ( json.response == 'success' )
- {
- jQuery.postJSON( "addDataElementGroupEditor.action", {
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- }
- }, function( json )
- {
- dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
- loadAvailableGroups();
- jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
- } );
- } else
- {
- markInvalid( "addDataElementGroupForm #name", json.message );
- }
- } );
+ if( jQuery( '#addDataElementGroupForm #name' ).val() == "" ){
+ markValid( "addDataElementGroupForm #shortName" );
+ markInvalid( "addDataElementGroupForm #name", i18n_this_field_is_required );
+ }
+ else if( jQuery( '#addDataElementGroupForm #shortName' ).val() == "" ){
+ markValid( "addDataElementGroupForm #name" );
+ markInvalid( "addDataElementGroupForm #shortName", i18n_this_field_is_required );
+ }
+ else
+ {
+ jQuery.postJSON( "validateDataElementGroup.action", {
+ name : jQuery( '#addDataElementGroupForm #name' ).val(),
+ shortName : jQuery( '#addDataElementGroupForm #shortName' ).val(),
+ code : jQuery( '#addDataElementGroupForm #code' ).val()
+ }, function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ jQuery.postJSON( "addDataElementGroupEditor.action", {
+ name : jQuery( '#addDataElementGroupForm #name' ).val(),
+ shortName : jQuery( '#addDataElementGroupForm #shortName' ).val(),
+ code : jQuery( '#addDataElementGroupForm #code' ).val()
+ }, function( json )
+ {
+ dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
+ loadAvailableGroups();
+ jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
+ } );
+ } else
+ {
+ markInvalid( "addDataElementGroupForm #name", json.message );
+ }
+ } );
+ }
}
} ] );
+
jQuery( '#addDataElementGroupForm' ).dialog( 'open' );
}
@@ -218,90 +251,104 @@
{
var id = jQuery( "#view_1 #dataElementGroups" ).val();
var text = jQuery( "#view_1 #dataElementGroups option[value=" + id + "]" ).text();
+
jQuery( '#addDataElementGroupForm #name' ).val( text );
+ jQuery( '#addDataElementGroupForm #shortName' ).closest('tr').hide();
+ jQuery( '#addDataElementGroupForm #code' ).closest('tr').hide();
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'buttons', [ {
text : i18n_save,
click : function()
{
- jQuery.postJSON( "validateDataElementGroup.action", {
- id : id,
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- }
- }, function( json )
- {
- if ( json.response == 'success' )
- {
- jQuery.postJSON( "renameDataElementGroupEditor.action", {
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- },
- id : id
- }, function( json )
- {
- dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
- loadAvailableGroups();
- jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
- setHeaderDelayMessage( i18n_update_success );
- } );
- } else
- {
- markInvalid( "addDataElementGroupForm #name", json.message );
- }
- } );
+ if( jQuery( '#addDataElementGroupForm #name' ).val() == "" ){
+ markInvalid( "addDataElementGroupForm #name", i18n_this_field_is_required );
+ }
+ else
+ {
+ jQuery.postJSON( "validateDataElementGroup.action", {
+ id : id,
+ name :jQuery( '#addDataElementGroupForm #name' ).val()
+ }, function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ markValid( "addDataElementGroupForm #name" );
+
+ jQuery.postJSON( "renameDataElementGroupEditor.action", {
+ name : function()
+ {
+ return jQuery( '#addDataElementGroupForm #name' ).val();
+ },
+ id : id
+ }, function( json )
+ {
+ dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
+ loadAvailableGroups();
+ jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
+ setHeaderDelayMessage( i18n_update_success );
+ } );
+ } else
+ {
+ markInvalid( "addDataElementGroupForm #name", json.message );
+ }
+ } );
+ }
}
} ] );
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'title', i18n_rename );
+ jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'width', '350px' );
jQuery( '#addDataElementGroupForm' ).dialog( 'open' );
}
function showUpdateGroup2()
{
- var id = jQuery( "#view_2 #availableGroups" ).val();
+ var id = jQuery( "#view_2 #availableGroups option:selected" ).val();
var text = jQuery( "#view_2 #availableGroups option[value=" + id + "]" ).text();
jQuery( '#addDataElementGroupForm #name' ).val( text );
+ jQuery( '#addDataElementGroupForm #shortName' ).closest('tr').hide();
+ jQuery( '#addDataElementGroupForm #code' ).closest('tr').hide();
+
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'buttons', [ {
text : i18n_save,
click : function()
{
-
- jQuery.postJSON( "validateDataElementGroup.action", {
- id : id,
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- }
- }, function( json )
- {
- if ( json.response == 'success' )
- {
- jQuery.postJSON( "renameDataElementGroupEditor.action", {
- name : function()
- {
- return jQuery( '#addDataElementGroupForm #name' ).val();
- },
- id : id
- }, function( json )
- {
- dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
- loadAvailableGroups();
- jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
- setHeaderDelayMessage( i18n_update_success );
- } );
- } else
- {
- markInvalid( "addDataElementGroupForm #name", json.message );
- }
- } );
+ if( jQuery( '#addDataElementGroupForm #name' ).val() == "" ){
+ markInvalid( "addDataElementGroupForm #name", i18n_this_field_is_required );
+ }
+ else
+ {
+ jQuery.postJSON( "validateDataElementGroup.action", {
+ id : id,
+ name : jQuery( '#addDataElementGroupForm #name' ).val()
+ }, function( json )
+ {
+ if ( json.response == 'success' )
+ {
+ markValid( "addDataElementGroupForm #name" );
+
+ jQuery.postJSON( "renameDataElementGroupEditor.action", {
+ name :jQuery( '#addDataElementGroupForm #name' ).val(),
+ id : id
+ }, function( json )
+ {
+ dataElementGroups[json.dataElementGroup.id] = json.dataElementGroup.name;
+ loadAvailableGroups();
+ jQuery( '#addDataElementGroupForm' ).dialog( 'close' );
+ setHeaderDelayMessage( i18n_update_success );
+ } );
+ } else
+ {
+ markInvalid( "addDataElementGroupForm #name", json.message );
+ }
+ } );
+ }
}
} ] );
jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'title', i18n_rename );
+ jQuery( '#addDataElementGroupForm' ).dialog( 'option', 'width', '350px' );
jQuery( '#addDataElementGroupForm' ).dialog( 'open' );
}
@@ -318,6 +365,7 @@
if ( json.response == 'success' )
{
dataElementGroups.splice( id, 1 );
+ clearListById('view_1 #selectedDataElements');
loadAvailableGroups();
setHeaderDelayMessage( json.message );
} else
@@ -354,9 +402,12 @@
function updateGroupMembers()
{
var id = jQuery( "#view_1 #dataElementGroups" ).val();
+ var shortName = dataElementGroupShortNames[id];
+ var code = dataElementGroupCodes[id];
jQuery.getJSON( "updateDataElementGroupEditor.action?id=" + id + "&"
- + toQueryString( '#view_1 #selectedDataElements', 'groupMembers' ), function( json )
+ + "shortName=" + shortName + "&code=" + code + "&"
+ + toQueryString( '#view_1 #selectedDataElements', 'deSelected' ), function( json )
{
setHeaderDelayMessage( i18n_update_success );
} );
@@ -390,7 +441,7 @@
jQuery.each( json.dataElementGroups, function( i, item )
{
- list_2.append( '<option value="' + item.id + '">' + item.name + '</option>' );
+ list_2.append( '<option value="' + item.id + '" title="' + item.name + '">' + item.name + '</option>' );
jQuery( "#view_2 #availableGroups" ).children().each( function( k, it )
{