=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-09-08 15:28:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-09-08 19:22:56 +0000 @@ -380,22 +380,36 @@ "chartGroup" : { "name" : { "required" : true, - "rangelength" : [ 3, 230 ], + "rangelength" : [ 3, 230 ], "alphanumericwithbasicpuncspaces" : true - } + } }, "reportGroup" : { "name" : { "required" : true, - "rangelength" : [ 3, 230 ], + "rangelength" : [ 3, 230 ], "alphanumericwithbasicpuncspaces" : true - } + } }, "reportTableGroup" : { "name" : { "required" : true, - "rangelength" : [ 3, 230 ], - "alphanumericwithbasicpuncspaces" : true - } + "rangelength" : [ 3, 230 ], + "alphanumericwithbasicpuncspaces" : true + } + }, + "attribute" : { + "name" : { + "required" : true, + "rangelength" : [ 3, 230 ], + "alphanumericwithbasicpuncspaces" : true + } + }, + "attributeOption" : { + "name" : { + "required" : true, + "rangelength" : [ 3, 230 ], + "alphanumericwithbasicpuncspaces" : true + } } }; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2011-09-08 10:38:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2011-09-08 19:22:56 +0000 @@ -120,18 +120,18 @@ attribute.setIndicator( indicator ); attribute.setOrganisationUnit( organisationUnit ); + Set attributeOptions = new HashSet(); + if ( valueType.compareTo( "multiple_choice" ) == 0 ) { - Set attributeOptions = new HashSet(); - for ( Integer id : selectedAttributeOptions ) { attributeOptions.add( attributeService.getAttributeOption( id ) ); } - - attribute.setAttributeOptions( attributeOptions ); } + attribute.setAttributeOptions( attributeOptions ); + attributeService.addAttribute( attribute ); return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2011-09-08 10:38:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2011-09-08 19:22:56 +0000 @@ -27,7 +27,13 @@ package org.hisp.dhis.dataadmin.action.attribute; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.hisp.dhis.attribute.Attribute; +import org.hisp.dhis.attribute.AttributeOption; import org.hisp.dhis.attribute.AttributeService; import com.opensymphony.xwork2.Action; @@ -67,6 +73,48 @@ this.name = name; } + private String valueType; + + public void setValueType( String valueType ) + { + this.valueType = valueType; + } + + private Boolean mandatory = false; + + public void setMandatory( Boolean mandatory ) + { + this.mandatory = mandatory; + } + + private Boolean dataElement = false; + + public void setDataElement( Boolean dataElement ) + { + this.dataElement = dataElement; + } + + private Boolean indicator = false; + + public void setIndicator( Boolean indicator ) + { + this.indicator = indicator; + } + + private Boolean organisationUnit = false; + + public void setOrganisationUnit( Boolean organisationUnit ) + { + this.organisationUnit = organisationUnit; + } + + private List selectedAttributeOptions = new ArrayList(); + + public void setSelectedAttributeOptions( List selectedAttributeOptions ) + { + this.selectedAttributeOptions = selectedAttributeOptions; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -79,6 +127,23 @@ if ( attribute != null ) { attribute.setName( name ); + attribute.setValueType( valueType ); + attribute.setMandatory( mandatory ); + attribute.setDataElement( dataElement ); + attribute.setIndicator( indicator ); + attribute.setOrganisationUnit( organisationUnit ); + + Set attributeOptions = new HashSet(); + + if ( valueType.compareTo( "multiple_choice" ) == 0 ) + { + for ( Integer id : selectedAttributeOptions ) + { + attributeOptions.add( attributeService.getAttributeOption( id ) ); + } + } + + attribute.setAttributeOptions( attributeOptions ); attributeService.updateAttribute( attribute ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2011-09-08 10:38:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2011-09-08 19:22:56 +0000 @@ -1,26 +1,22 @@ + + + +

$i18n.getString( "edit_attribute" )

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "details" )
$i18n.getString( "assigned_to" ) +
+
+
+
+ +
+
+ + +
+ +
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeOptionForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeOptionForm.vm 2011-09-07 13:42:12 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeOptionForm.vm 2011-09-08 19:22:56 +0000 @@ -8,7 +8,7 @@ 'rules': rules }); - checkValueIsExist( "name", "validateAttributeOption.action" ); + checkValueIsExist( "name", "validateAttributeOption.action", {id: $attributeOption.id} ); });