dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41353
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21065: Update attribute to use ValueType enum
------------------------------------------------------------
revno: 21065
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-16 12:51:35 +0700
message:
Update attribute to use ValueType enum
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
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/UpdateAttributeAction.java
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/javascript/attribute.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java
--
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-api/src/main/java/org/hisp/dhis/attribute/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2015-10-05 17:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2015-11-16 05:51:35 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.common.DxfNamespaces;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.option.OptionSet;
@@ -51,7 +52,7 @@
public class Attribute
extends BaseIdentifiableObject
{
- private String valueType;
+ private ValueType valueType;
private boolean dataElementAttribute;
@@ -98,7 +99,7 @@
}
- public Attribute( String name, String valueType )
+ public Attribute( String name, ValueType valueType )
{
this.name = name;
this.valueType = valueType;
@@ -107,12 +108,12 @@
@JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public String getValueType()
+ public ValueType getValueType()
{
return valueType;
}
- public void setValueType( String valueType )
+ public void setValueType( ValueType valueType )
{
this.valueType = valueType;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-11-08 13:56:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-11-16 05:51:35 +0000
@@ -191,6 +191,17 @@
executeSql( "update trackedentityattribute set valuetype='TEXT' where valuetype is null" );
executeSql( "update optionset set valuetype='TEXT' where valuetype is null" );
+
+ executeSql( "update attribute set valuetype='TEXT' where valuetype='string'" );
+ executeSql( "update attribute set valuetype='LONG_TEXT' where valuetype='text'" );
+ executeSql( "update attribute set valuetype='BOOLEAN' where valuetype='bool'" );
+ executeSql( "update attribute set valuetype='DATE' where valuetype='date'" );
+ executeSql( "update attribute set valuetype='NUMBER' where valuetype='number'" );
+ executeSql( "update attribute set valuetype='INTEGER' where valuetype='integer'" );
+ executeSql( "update attribute set valuetype='INTEGER_POSITIVE' where valuetype='positive_integer'" );
+ executeSql( "update attribute set valuetype='INTEGER_NEGATIVE' where valuetype='negative_integer'" );
+ executeSql( "update attribute set valuetype='TEXT' where valuetype='option_set'" );
+ executeSql( "update attribute set valuetype='TEXT' where valuetype is null" );
}
private void upgradeProgramStageDataElements()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml 2015-08-19 05:26:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml 2015-11-16 05:51:35 +0000
@@ -17,7 +17,13 @@
<property name="name" column="name" not-null="true" unique="true" length="230" />
- <property name="valueType" not-null="true" />
+ <property name="valueType" length="50" not-null="true">
+ <type name="org.hibernate.type.EnumType">
+ <param name="enumClass">org.hisp.dhis.common.ValueType</param>
+ <param name="useNamed">true</param>
+ <param name="type">12</param>
+ </type>
+ </property>
<property name="mandatory" not-null="true" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeServiceTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeServiceTest.java 2015-11-16 05:51:35 +0000
@@ -28,13 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.ValueType;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static org.junit.Assert.*;
-import org.hisp.dhis.DhisSpringTest;
-
/**
* @author mortenoh
*/
@@ -48,33 +48,33 @@
public void testAddAttribute()
{
Attribute attribute = new Attribute();
- attribute.setValueType( "string" );
+ attribute.setValueType( ValueType.TEXT );
attribute.setName( "attribute1" );
attributeService.addAttribute( attribute );
attribute = attributeService.getAttribute( attribute.getId() );
assertNotNull( attribute );
+ assertEquals( ValueType.TEXT, attribute.getValueType() );
assertEquals( "attribute1", attribute.getName() );
- assertEquals( "string", attribute.getValueType() );
}
@Test
public void testUpdateAttribute()
{
Attribute attribute = new Attribute();
- attribute.setValueType( "string" );
+ attribute.setValueType( ValueType.TEXT );
attribute.setName( "attribute1" );
attributeService.addAttribute( attribute );
- attribute.setValueType( "int" );
+ attribute.setValueType( ValueType.INTEGER );
attribute.setName( "attribute2" );
attributeService.updateAttribute( attribute );
attribute = attributeService.getAttribute( attribute.getId() );
- assertEquals( "int", attribute.getValueType() );
+ assertEquals( ValueType.INTEGER, attribute.getValueType() );
assertEquals( "attribute2", attribute.getName() );
}
@@ -82,7 +82,7 @@
public void testDeleteAttribute()
{
Attribute attribute = new Attribute();
- attribute.setValueType( "string" );
+ attribute.setValueType( ValueType.TEXT );
attribute.setName( "attribute1" );
attributeService.addAttribute( attribute );
@@ -91,7 +91,7 @@
assertNotNull( attribute );
int attributeId = attribute.getId();
-
+
attributeService.deleteAttribute( attribute );
attribute = attributeService.getAttribute( attributeId );
@@ -102,7 +102,7 @@
public void testGetAttribute()
{
Attribute attribute = new Attribute();
- attribute.setValueType( "string" );
+ attribute.setValueType( ValueType.TEXT );
attribute.setName( "attribute1" );
attributeService.addAttribute( attribute );
@@ -115,11 +115,11 @@
public void testGetAllAttributes()
{
Attribute attribute1 = new Attribute();
- attribute1.setValueType( "string" );
+ attribute1.setValueType( ValueType.TEXT );
attribute1.setName( "attribute1" );
Attribute attribute2 = new Attribute();
- attribute2.setValueType( "string" );
+ attribute2.setValueType( ValueType.TEXT );
attribute2.setName( "attribute2" );
attributeService.addAttribute( attribute1 );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeStoreTest.java 2015-11-16 05:51:35 +0000
@@ -28,12 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.ValueType;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import static org.junit.Assert.*;
-
-import org.hisp.dhis.DhisSpringTest;
+import static org.junit.Assert.assertEquals;
public class AttributeStoreTest
extends DhisSpringTest
@@ -50,13 +50,13 @@
{
attribute1 = new Attribute();
attribute1.setName( "attribute_simple" );
- attribute1.setValueType( "string" );
+ attribute1.setValueType( ValueType.TEXT );
attribute1.setIndicatorAttribute( true );
attribute1.setDataElementAttribute( true );
attribute2 = new Attribute();
attribute2.setName( "attribute_with_options" );
- attribute2.setValueType( "string" );
+ attribute2.setValueType( ValueType.TEXT );
attribute2.setOrganisationUnitAttribute( true );
attribute2.setDataElementAttribute( true );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueServiceTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueServiceTest.java 2015-11-16 05:51:35 +0000
@@ -28,13 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.common.ValueType;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static org.junit.Assert.*;
-import org.hisp.dhis.DhisSpringTest;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -47,15 +47,15 @@
private AttributeValue attributeValue1;
private AttributeValue attributeValue2;
-
+
@Override
protected void setUpTest()
{
attributeValue1 = new AttributeValue( "value 1" );
attributeValue2 = new AttributeValue( "value 2" );
- Attribute attribute1 = new Attribute( "attribute 1", "string" );
- Attribute attribute2 = new Attribute( "attribute 2", "string" );
+ Attribute attribute1 = new Attribute( "attribute 1", ValueType.TEXT );
+ Attribute attribute2 = new Attribute( "attribute 2", ValueType.TEXT );
attributeService.addAttribute( attribute1 );
attributeService.addAttribute( attribute2 );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java 2015-11-16 05:51:35 +0000
@@ -28,24 +28,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import javax.annotation.Resource;
-
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.common.GenericStore;
+import org.hisp.dhis.common.ValueType;
import org.junit.Test;
+import javax.annotation.Resource;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
public class AttributeValueStoreTest
extends DhisSpringTest
{
- @Resource(name="org.hisp.dhis.attribute.AttributeValueStore")
+ @Resource( name = "org.hisp.dhis.attribute.AttributeValueStore" )
private GenericStore<AttributeValue> attributeValueStore;
-
- @Resource(name="org.hisp.dhis.attribute.AttributeStore")
+
+ @Resource( name = "org.hisp.dhis.attribute.AttributeStore" )
private AttributeStore attributeStore;
-
+
private AttributeValue attributeValue1;
private AttributeValue attributeValue2;
@@ -55,7 +56,7 @@
{
Attribute attribute1 = new Attribute();
attribute1.setName( "attribute_simple" );
- attribute1.setValueType( "string" );
+ attribute1.setValueType( ValueType.TEXT );
attributeStore.save( attribute1 );
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2015-07-16 05:27:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2015-11-16 05:51:35 +0000
@@ -337,31 +337,33 @@
#set( $text = $attribute.displayName )
#set( $id = $attribute.id )
#set( $mandatory = $attribute.mandatory )
+ #set( $valueType = $attribute.valueType )
+
#if( $!args.attributeValues.get( $attribute.id ) )
#set( $value = $!args.attributeValues.get( $attribute.id ) )
#else
#set( $value = "" )
#end
- #if( $attribute.valueType == "string" )
+ #if( $attribute.optionSet )
+ #trOptionSetInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value, "attribute": $attribute } )
+ #elseif( $valueType == "TEXT" )
#trStringInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "text" )
+ #elseif( $valueType == "LONG_TEXT" )
#trTextInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "bool" )
+ #elseif( $valueType == "BOOLEAN" )
#trBooleanSelectInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "date" )
+ #elseif( $valueType == "DATE" )
#trDateInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "number" )
+ #elseif( $valueType == "NUMBER" )
#trNumberInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "integer" )
+ #elseif( $valueType == "INTEGER" )
#trIntegerInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "positive_integer" )
+ #elseif( $valueType == "INTEGER_POSITIVE" )
#trPositiveIntegerInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "negative_integer" )
+ #elseif( $valueType == "INTEGER_NEGATIVE" )
#trNegativeIntegerInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
- #elseif( $attribute.valueType == "option_set" )
- #trOptionSetInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value, "attribute": $attribute } )
- #end
+ #end
#end
</table>
</div>
=== 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 2015-08-19 05:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java 2015-11-16 05:51:35 +0000
@@ -29,10 +29,10 @@
*/
import com.opensymphony.xwork2.Action;
-
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.springframework.beans.factory.annotation.Autowired;
@@ -71,9 +71,9 @@
this.code = code;
}
- private String valueType;
+ private ValueType valueType;
- public void setValueType( String valueType )
+ public void setValueType( ValueType valueType )
{
this.valueType = valueType;
}
@@ -211,19 +211,10 @@
@Override
public String execute()
{
- OptionSet optionSet = null;
-
- if ( "option_set".equals( valueType ) )
- {
- optionSet = optionService.getOptionSet( optionSetUid );
-
- if ( optionSet == null )
- {
- return INPUT;
- }
- }
-
- Attribute attribute = new Attribute( StringUtils.trimToNull( name ), StringUtils.trimToNull( valueType ) );
+ OptionSet optionSet = optionService.getOptionSet( optionSetUid );
+ valueType = optionSet != null && optionSet.getValueType() != null ? optionSet.getValueType() : valueType;
+
+ Attribute attribute = new Attribute( StringUtils.trimToNull( name ), valueType );
attribute.setCode( StringUtils.trimToNull( code ) );
attribute.setMandatory( mandatory );
attribute.setDataElementAttribute( dataElementAttribute );
=== 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 2015-08-19 05:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java 2015-11-16 05:51:35 +0000
@@ -32,6 +32,7 @@
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.option.OptionService;
import org.hisp.dhis.option.OptionSet;
import org.springframework.beans.factory.annotation.Autowired;
@@ -77,9 +78,9 @@
this.code = code;
}
- private String valueType;
+ private ValueType valueType;
- public void setValueType( String valueType )
+ public void setValueType( ValueType valueType )
{
this.valueType = valueType;
}
@@ -221,21 +222,13 @@
if ( attribute != null )
{
- if ( "option_set".equals( attribute.getValueType() ) )
- {
- OptionSet optionSet = optionService.getOptionSet( optionSetUid );
-
- if ( optionSet == null )
- {
- return INPUT;
- }
-
- attribute.setOptionSet( optionSet );
- }
+ OptionSet optionSet = optionService.getOptionSet( optionSetUid );
+ valueType = optionSet != null && optionSet.getValueType() != null ? optionSet.getValueType() : valueType;
attribute.setName( StringUtils.trimToNull( name ) );
attribute.setCode( StringUtils.trimToNull( code ) );
- attribute.setValueType( StringUtils.trimToNull( valueType ) );
+ attribute.setValueType( valueType );
+ attribute.setOptionSet( optionSet );
attribute.setMandatory( mandatory );
attribute.setDataElementAttribute( dataElementAttribute );
attribute.setDataElementGroupAttribute( dataElementGroupAttribute );
=== 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 2015-08-19 05:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm 2015-11-16 05:51:35 +0000
@@ -14,8 +14,8 @@
checkValueIsExist( "name", "validateAttribute.action" );
checkValueIsExist( "code", "validateAttribute.action" );
- $("#valueType").bind("change", onValueTypeChange);
- $("#valueType").change();
+ $("#optionSet").bind("change", onOptionSetChange);
+ $("#optionSet").change();
});
</script>
@@ -71,26 +71,26 @@
<tr>
<td><label for="valueType">$i18n.getString( "value_type" )</td>
<td>
- <select id="valueType" name="valueType">
- <option value="string">$i18n.getString( "text" )</option>
- <option value="text">$i18n.getString( "long_text" )</option>
- <option value="bool">$i18n.getString( "yes_no" )</option>
- <option value="date">$i18n.getString( "date" )</option>
- <option value="number">$i18n.getString( "number" )</option>
- <option value="integer" >$i18n.getString( "integer" )</option>
- <option value="positive_integer">$i18n.getString( "positive_integer" )</option>
- <option value="negative_integer">$i18n.getString( "negative_integer" )</option>
- <option value="option_set">$i18n.getString( "option_set" )</option>
+ <select id="valueType" name="valueType" style="width: 310px">
+ <option value="TEXT">$i18n.getString( "text" )</option>
+ <option value="LONG_TEXT">$i18n.getString( "long_text" )</option>
+ <option value="BOOLEAN">$i18n.getString( "yes_no" )</option>
+ <option value="DATE">$i18n.getString( "date" )</option>
+ <option value="NUMBER">$i18n.getString( "number" )</option>
+ <option value="INTEGER" >$i18n.getString( "integer" )</option>
+ <option value="INTEGER_POSITIVE">$i18n.getString( "positive_integer" )</option>
+ <option value="INTEGER_NEGATIVE">$i18n.getString( "negative_integer" )</option>
</select>
</td>
</tr>
<tr>
- <td></td>
+ <td><label>$i18n.getString( 'option_set' )</label></td>
<td>
- <select id="optionSet" name="optionSetUid" style="display: none;">
+ <select id="optionSet" name="optionSetUid" style="width: 310px">
+ <option value="0">[$i18n.getString('please_select')]</option>
#foreach( $optionSet in $optionSets )
- <option value="$optionSet.uid">$optionSet.displayName</option>
+ <option value="$optionSet.uid">$optionSet.displayName</option>
#end
</select>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/attribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/attribute.js 2015-03-20 07:08:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/attribute.js 2015-11-16 05:51:35 +0000
@@ -1,4 +1,4 @@
-function onValueTypeChange( e ) {
+function onValueTypeChange(e) {
var val = $(this).find(":selected").val();
if( val == "option_set" ) {
@@ -8,9 +8,25 @@
}
}
-function showAttributeDetails( context ) {
- jQuery.post('getAttribute.action', {id: context.id},
- function( json ) {
+function onOptionSetChange(e) {
+ var val = $(this).find(":selected").val();
+
+ if( val != 0 ) {
+ $('#valueType').css({
+ color: 'white',
+ backgroundColor: 'lightgrey'
+ }).attr('disabled', true);
+ } else {
+ $('#valueType').css({
+ color: 'black',
+ backgroundColor: 'white'
+ }).removeAttr('disabled');
+ }
+}
+
+function showAttributeDetails(context) {
+ jQuery.post('getAttribute.action', { id: context.id },
+ function(json) {
setInnerHTML('nameField', json.attribute.name);
setInnerHTML('mandatoryField', json.attribute.mandatory);
setInnerHTML('dataelementField', json.attribute.dataelement);
@@ -23,10 +39,10 @@
});
}
-function removeAttribute( context ) {
+function removeAttribute(context) {
removeItem(context.id, context.name, i18n_confirm_delete, 'removeAttribute.action');
}
-function showUpdateAttributeForm( context ) {
+function showUpdateAttributeForm(context) {
location.href = 'showUpdateAttributeForm.action?id=' + context.id;
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2015-08-19 05:26:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm 2015-11-16 05:51:35 +0000
@@ -14,8 +14,8 @@
checkValueIsExist( "name", "validateAttribute.action", {id: $attribute.id} );
checkValueIsExist( "code", "validateAttribute.action", {id: $attribute.id} );
- $("#valueType").bind("change", onValueTypeChange);
- $("#valueType").change();
+ $("#optionSet").bind("change", onOptionSetChange);
+ $("#optionSet").change();
});
</script>
@@ -73,16 +73,15 @@
<tr>
<td><label for="valueType">$i18n.getString( "value_type" )</td>
<td>
- <select id="valueType" name="valueType" style="width:20em">
- <option value="string" #if( $attribute.valueType == 'string') selected="selected" #end>$i18n.getString( "text" )</option>
- <option value="text" #if( $attribute.valueType == 'text') selected="selected" #end>$i18n.getString( "long_text" )</option>
- <option value="bool" #if( $attribute.valueType == 'bool') selected="selected" #end>$i18n.getString( "yes_no" )</option>
- <option value="date" #if( $attribute.valueType == 'date') selected="selected" #end>$i18n.getString( "date" )</option>
- <option value="number" #if( $attribute.valueType == 'number') selected="selected" #end>$i18n.getString( "number" )</option>
- <option value="integer" #if( $attribute.valueType == 'integer') selected="selected" #end>$i18n.getString( "integer" )</option>
- <option value="positive_integer" #if( $attribute.valueType == 'positive_integer') selected="selected" #end>$i18n.getString( "positive_integer" )</option>
- <option value="negative_integer" #if( $attribute.valueType == 'negative_integer') selected="selected" #end>$i18n.getString( "negative_integer" )</option>
- <option value="option_set" #if( $attribute.valueType == 'option_set') selected="selected" #end>$i18n.getString( "option_set" )</option>
+ <select id="valueType" name="valueType" style="width: 310px">
+ <option value="TEXT" #if( $attribute.valueType == 'TEXT') selected="selected" #end>$i18n.getString( "text" )</option>
+ <option value="LONG_TEXT" #if( $attribute.valueType == 'LONG_TEXT') selected="selected" #end>$i18n.getString( "long_text" )</option>
+ <option value="BOOLEAN" #if( $attribute.valueType == 'BOOLEAN') selected="selected" #end>$i18n.getString( "yes_no" )</option>
+ <option value="DATE" #if( $attribute.valueType == 'DATE') selected="selected" #end>$i18n.getString( "date" )</option>
+ <option value="NUMBER" #if( $attribute.valueType == 'NUMBER') selected="selected" #end>$i18n.getString( "number" )</option>
+ <option value="INTEGER" #if( $attribute.valueType == 'INTEGER') selected="selected" #end>$i18n.getString( "integer" )</option>
+ <option value="INTEGER_POSITIVE" #if( $attribute.valueType == 'INTEGER_POSITIVE') selected="selected" #end>$i18n.getString( "positive_integer" )</option>
+ <option value="INTEGER_NEGATIVE" #if( $attribute.valueType == 'INTEGER_NEGATIVE') selected="selected" #end>$i18n.getString( "negative_integer" )</option>
</select>
</td>
</tr>
@@ -90,7 +89,8 @@
<tr>
<td></td>
<td>
- <select id="optionSet" name="optionSetUid" style="display: none;">
+ <select id="optionSet" name="optionSetUid" style="width: 310px">
+ <option value="0">[$i18n.getString('please_select')]</option>
#foreach( $optionSet in $optionSets )
<option value="$optionSet.uid" #if( $attribute.optionSet && $attribute.optionSet.uid == $optionSet.uid )selected="selected"#end>$optionSet.displayName</option>
#end
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java 2015-10-19 19:21:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java 2015-11-16 05:51:35 +0000
@@ -216,7 +216,7 @@
LegendSet legendSet = legendService.getLegendSet( selectedLegendSetId );
valueType = optionSet != null && optionSet.getValueType() != null ? optionSet.getValueType() : valueType;
-
+
dataElement.setName( StringUtils.trimToNull( name ) );
dataElement.setShortName( StringUtils.trimToNull( shortName ) );
dataElement.setCode( StringUtils.trimToNull( code ) );