← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4544: wip: added ui for adding attributes

 

------------------------------------------------------------
revno: 4544
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-08 12:38:20 +0200
message:
  wip: added ui for adding attributes
added:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributeOptions.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributes.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributeOptionsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributesAction.java
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  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/AddAttributeOptionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeOptionAction.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/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeOptionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeOptionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm


--
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-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributeOptions.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributeOptions.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributeOptions.vm	2011-09-08 10:38:20 +0000
@@ -0,0 +1,13 @@
+#set( $size = $attributeOptions.size() )
+{ "attributeOptions": [
+#foreach( $attributeOption in $attributeOptions )
+  {
+    "id": ${attributeOption.id},
+    "name": "$!encoder.jsonEncode( ${attributeOption.name} )"
+  }#if( $velocityCount < $size ),#end
+#end
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributes.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributes.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonAttributes.vm	2011-09-08 10:38:20 +0000
@@ -0,0 +1,13 @@
+#set( $size = $attributes.size() )
+{ "attributes": [
+#foreach( $attribute in $attributes )
+  {
+    "id": ${attribute.id},
+    "name": "$!encoder.jsonEncode( ${attribute.name} )"
+  }#if( $velocityCount < $size ),#end
+#end
+]
+#if( $usePaging ),
+	"paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" )
+#end
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributeOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributeOptionsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributeOptionsAction.java	2011-09-08 10:38:20 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2004-2011, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.commons.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.attribute.AttributeOption;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.comparator.AttributeOptionNameComparator;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author mortenoh
+ */
+public class GetAttributeOptionsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private AttributeService attributeService;
+
+    public void setAttributeService( AttributeService attributeService )
+    {
+        this.attributeService = attributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private List<AttributeOption> attributeOptions;
+
+    public List<AttributeOption> getAttributeOptions()
+    {
+        return attributeOptions;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        attributeOptions = new ArrayList<AttributeOption>( attributeService.getAllAttributeOptions() );
+
+        Collections.sort( attributeOptions, new AttributeOptionNameComparator() );
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributesAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributesAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAttributesAction.java	2011-09-08 10:38:20 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2004-2011, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.commons.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.comparator.AttributeNameComparator;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author mortenoh
+ */
+public class GetAttributesAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private AttributeService attributeService;
+
+    public void setAttributeService( AttributeService attributeService )
+    {
+        this.attributeService = attributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private List<Attribute> attributes;
+
+    public List<Attribute> getAttributes()
+    {
+        return attributes;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        attributes = new ArrayList<Attribute>( attributeService.getAllAttributes() );
+
+        Collections.sort( attributes, new AttributeNameComparator() );
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2011-08-17 11:17:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2011-09-08 10:38:20 +0000
@@ -622,4 +622,12 @@
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
   </bean>
 
+  <bean id="org.hisp.dhis.commons.action.GetAttributesAction" class="org.hisp.dhis.commons.action.GetAttributesAction">
+    <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
+  </bean>
+
+  <bean id="org.hisp.dhis.commons.action.GetAttributeOptionsAction" class="org.hisp.dhis.commons.action.GetAttributeOptionsAction">
+    <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
+  </bean>
+
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-08-19 18:37:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-09-08 10:38:20 +0000
@@ -25,7 +25,7 @@
       <result-type name="velocity-xml" class="org.hisp.dhis.result.VelocityXMLResult" />
       <result-type name="velocity-json" class="org.hisp.dhis.result.VelocityJsonResult" />
       <result-type name="velocity-javascript" class="org.hisp.dhis.result.VelocityJavascriptResult" />
-	  <result-type name="velocity-cache-manifest" class="org.hisp.dhis.result.VelocityCacheManifestResult" />
+      <result-type name="velocity-cache-manifest" class="org.hisp.dhis.result.VelocityCacheManifestResult" />
       <result-type name="outputStreamResult" class="org.hisp.dhis.result.OutputStreamResult" />
       <result-type name="gridCsvResult" class="org.hisp.dhis.result.GridCsvResult" />
       <result-type name="gridXlsResult" class="org.hisp.dhis.result.GridXlsResult" />
@@ -58,10 +58,7 @@
         <interceptor-ref name="params" />
         <interceptor-ref name="chain" />
         <interceptor-ref name="i18nInterceptor" />
-        <!--
-          The securityInterceptor is put after the i18nInterceptor so that
-          the access denied error pages can use internationalisation.
-        -->
+        <!-- The securityInterceptor is put after the i18nInterceptor so that the access denied error pages can use internationalisation. -->
         <interceptor-ref name="securityInterceptor" />
         <interceptor-ref name="loginInterceptor" />
         <interceptor-ref name="sortOrderInterceptor" />
@@ -105,7 +102,7 @@
         <param name="message">${exception.class.name}: ${exception.message}</param>
       </result>
     </global-results>
-	
+
   </package>
 
   <!-- Organisation Unit Selection Tree -->
@@ -269,12 +266,12 @@
 
   <package name="dhis-web-commons-i18n" extends="dhis-web-commons" namespace="/dhis-web-commons">
 
-	<!-- TODO give i18n its own namespace and move cacheManifest action to dhis-web-commons package -->
-
-	<action name="cacheManifest" class="org.hisp.dhis.commons.action.NoAction">
-		<result name="success" type="velocity-cache-manifest">/cacheManifest.vm</result>
-	</action>
-	
+    <!-- TODO give i18n its own namespace and move cacheManifest action to dhis-web-commons package -->
+
+    <action name="cacheManifest" class="org.hisp.dhis.commons.action.NoAction">
+      <result name="success" type="velocity-cache-manifest">/cacheManifest.vm</result>
+    </action>
+
     <action name="i18n" class="org.hisp.dhis.i18n.action.I18nAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-commons/i18n/translate.vm</param>
@@ -695,6 +692,20 @@
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 
+    <action name="getAttributes" class="org.hisp.dhis.commons.action.GetAttributesAction">
+      <result name="success" type="velocity-json">
+        /dhis-web-commons/ajax/jsonAttributes.vm
+      </result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+
+    <action name="getAttributeOptions" class="org.hisp.dhis.commons.action.GetAttributeOptionsAction">
+      <result name="success" type="velocity-json">
+        /dhis-web-commons/ajax/jsonAttributeOptions.vm
+      </result>
+      <param name="onExceptionReturn">plainTextError</param>
+    </action>
+
     <action name="getPeriod" class="org.hisp.dhis.commons.action.GetPeriodAction">
       <result name="success" type="velocity-json">
         /dhis-web-commons/ajax/jsonPeriod.vm

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-06 05:37:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2011-09-08 10:38:20 +0000
@@ -502,4 +502,7 @@
 
 constant							= Constant
 constants							= Constants
-no_constant_to_select				= No constants to select
\ No newline at end of file
+no_constant_to_select				= No constants to select
+
+#-- Dynamic Attributes  --------------------------------------------------------#
+multiple_choice						= Multiple Choice

=== 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-07 13:42:12 +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 10:38:20 +0000
@@ -27,11 +27,19 @@
 
 package org.hisp.dhis.dataadmin.action.attribute;
 
+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;
 
+/**
+ * @author mortenoh
+ */
 public class AddAttributeAction
     implements Action
 {
@@ -92,6 +100,13 @@
         this.organisationUnit = organisationUnit;
     }
 
+    private List<Integer> selectedAttributeOptions;
+
+    public void setSelectedAttributeOptions( List<Integer> selectedAttributeOptions )
+    {
+        this.selectedAttributeOptions = selectedAttributeOptions;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -105,6 +120,18 @@
         attribute.setIndicator( indicator );
         attribute.setOrganisationUnit( organisationUnit );
 
+        if ( valueType.compareTo( "multiple_choice" ) == 0 )
+        {
+            Set<AttributeOption> attributeOptions = new HashSet<AttributeOption>();
+
+            for ( Integer id : selectedAttributeOptions )
+            {
+                attributeOptions.add( attributeService.getAttributeOption( id ) );
+            }
+
+            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/AddAttributeOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeOptionAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeOptionAction.java	2011-09-08 10:38:20 +0000
@@ -32,6 +32,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class AddAttributeOptionAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/GetAttributeAction.java	2011-09-08 10:38:20 +0000
@@ -32,6 +32,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class GetAttributeAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeAction.java	2011-09-08 10:38:20 +0000
@@ -33,6 +33,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class RemoveAttributeAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeOptionAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/RemoveAttributeOptionAction.java	2011-09-08 10:38:20 +0000
@@ -33,6 +33,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class RemoveAttributeOptionAction
     implements Action
 {

=== 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-07 13:42:12 +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 10:38:20 +0000
@@ -32,6 +32,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class UpdateAttributeAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeOptionAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeOptionAction.java	2011-09-08 10:38:20 +0000
@@ -32,6 +32,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class UpdateAttributeOptionAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeAction.java	2011-09-08 10:38:20 +0000
@@ -33,6 +33,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class ValidateAttributeAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeOptionAction.java	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/ValidateAttributeOptionAction.java	2011-09-08 10:38:20 +0000
@@ -33,6 +33,9 @@
 
 import com.opensymphony.xwork2.Action;
 
+/**
+ * @author mortenoh
+ */
 public class ValidateAttributeOptionAction
     implements Action
 {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2011-09-08 10:38:20 +0000
@@ -350,3 +350,6 @@
 edit_attribute														= Edit Attribute 
 create_new_attribute_option											= Add Attribute Option 
 edit_attribute_option												= Edit Attribute Option
+assigned_to															= Assigned To
+available_attribute_options											= Available Attribute Options
+selected_attribute_options											= Selected Attribute Options

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2011-09-07 13:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml	2011-09-08 10:38:20 +0000
@@ -519,7 +519,7 @@
       <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
     </action>
 
-    <action name="addAttribute" class="org.hisp.dhis.dataadmin.action.attribute.AddAttributeOptionAction">
+    <action name="addAttribute" class="org.hisp.dhis.dataadmin.action.attribute.AddAttributeAction">
       <result name="success" type="redirect">attribute.action</result>
       <result name="error" type="redirect">index.action</result>
     </action>

=== 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-07 13:42:12 +0000
+++ 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
@@ -1,1 +1,127 @@
-addAttribute
\ No newline at end of file
+<script type="text/javascript">
+	function onValueTypeChange(e) {
+		var val = $(this).find(":selected").val();
+
+		if(val == "multiple_choice") {
+			$("#multipleChoice").show();
+		} else {
+			$("#multipleChoice").hide();
+		}
+	}
+
+	jQuery(document).ready(	function()
+	{
+		$("#valueType").bind("change", onValueTypeChange);
+	
+		var rules = getValidationRules("attribute");
+
+		validation2( 'addAttributeForm', function( form ){ form.submit(); },
+		{
+			'rules': rules
+		});
+
+		checkValueIsExist( "name", "validateAttribute.action" );
+
+		jQuery("#availableAttributeOptions").dhisAjaxSelect({
+			source: "../dhis-web-commons-ajax-json/getAttributeOptions.action",
+			iterator: "attributeOptions",
+			connectedTo: 'selectedAttributeOptions',
+			handler: function(item) {
+				var option = jQuery("<option />");
+				option.text( item.name );
+				option.attr( "value", item.id );
+
+				return option;
+			}
+		});
+	});
+</script>
+
+<h3>$i18n.getString( "create_new_attribute" )</h3>
+
+<form id="addAttributeForm" action="addAttribute.action" method="post" >
+
+<table>
+	<col style="width: 100px"/>
+	<col/>
+
+	<tr>
+		<th colspan="2">$i18n.getString( "details" )</th>
+	</tr>
+
+	<tr>
+		<td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td><input type="text" id="name" name="name" style="width:20em"/></td>
+	</tr>
+
+	<tr>
+		<td><label for="mandatory">$i18n.getString( "mandatory" )</td>
+		<td><input type="checkbox" id="mandatory" name="mandatory" value="true" /></td>
+	</tr>
+
+	<tr>
+		<td style="vertical-align: text-top;">$i18n.getString( "assigned_to" )</td>
+		<td>
+			<input type="checkbox" id="dataElement" name="dataElement" value="true" /><label for="dataElement">$i18n.getString( 'data_element' )</label> <br />
+			<input type="checkbox" id="indicator" name="indicator" value="true" /><label for="indicator">$i18n.getString( 'indicator' )</label> <br />
+			<input type="checkbox" id="organisationUnit" name="organisationUnit" value="true" /><label for="organisationUnit">$i18n.getString( 'organisation_unit' )</label> <br />
+		</td>
+	</tr>
+
+	<tr>
+		<td><label for="valueType">$i18n.getString( "value_type" )</td>
+		<td>
+			<select id="valueType" name="valueType" style="width:20em">
+				<option value="string">$i18n.getString( "text" )</option>
+				<option value="bool">$i18n.getString( "yes_no" )</option>
+				<option value="multiple_choice">$i18n.getString( "multiple_choice" )</option>
+			</select>
+		</td>
+	</tr>
+
+	<tr>
+		<td colspan="3" id="multipleChoice" style="display: none;"> 
+			<table>
+
+			<col style="width: 300px"/>
+    		<col/>
+    		<col style="width: 300px"/>
+
+			<tr>
+			<th>$i18n.getString( "available_attribute_options" )</th>
+			<th></th>
+			<th>$i18n.getString( "selected_attribute_options" )
+			    <select id="memberValidator" multiple="multiple" style="display:none"/>
+			</th>
+			</tr>
+
+			<tr>
+			<td>
+		        <select id="availableAttributeOptions" name="availableAttributeOptions" multiple="multiple" style="height: 200px; width: 100%;"></select>
+		    </td>
+		
+		    <td style="text-align:center">
+		    	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableUsersList' );"/><br/>
+		        <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'groupMembersList' );"/><br/>
+				<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableUsersList' );"/><br/>
+				<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'groupMembersList' );"/>
+		    </td>
+		
+		    <td>
+		        <select id="selectedAttributeOptions" name="selectedAttributeOptions" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;"></select>
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+
+	<tr>
+		<td colspan="2">
+			<br/>
+			<input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/>
+			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='attribute.action'" style="width:10em"/>
+		</td>
+	</tr>
+</table>
+
+</form>