← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15986: bugfix for clone, make sure that dropdowns are updated, wip

 

------------------------------------------------------------
revno: 15986
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-07-07 09:47:35 +0700
message:
  bugfix for clone, make sure that dropdowns are updated, wip
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowDataElementFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.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
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowDataElementFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowDataElementFormAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowDataElementFormAction.java	2014-07-07 02:47:35 +0000
@@ -65,138 +65,120 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    public Map<Integer, String> attributeValues = new HashMap<Integer, String>();
     private DataElementService dataElementService;
+    private DataElementCategoryService dataElementCategoryService;
+    private OrganisationUnitService organisationUnitService;
+    private AttributeService attributeService;
+    private OptionService optionService;
+    private MappingService mappingService;
+    private Integer id;
+    private DataElement dataElement;
+    private Collection<DataElementGroup> dataElementGroups;
+    private List<DataElementCategoryCombo> dataElementCategoryCombos;
+    private List<OrganisationUnitLevel> organisationUnitLevels;
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+    private List<OrganisationUnitLevel> aggregationLevels = new ArrayList<OrganisationUnitLevel>();
+    private DataElementCategoryCombo defaultCategoryCombo;
+    private List<DataElementGroupSet> groupSets;
+    private List<Attribute> attributes;
+    private List<OptionSet> optionSets;
+    private List<MapLegendSet> legendSets;
+    private boolean update;
 
     public void setDataElementService( DataElementService dataElementService )
     {
         this.dataElementService = dataElementService;
     }
 
-    private DataElementCategoryService dataElementCategoryService;
-
     public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
     {
         this.dataElementCategoryService = dataElementCategoryService;
     }
 
-    private OrganisationUnitService organisationUnitService;
-
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
     {
         this.organisationUnitService = organisationUnitService;
     }
 
-    private AttributeService attributeService;
-
     public void setAttributeService( AttributeService attributeService )
     {
         this.attributeService = attributeService;
     }
 
-    private OptionService optionService;
-
     public void setOptionService( OptionService optionService )
     {
         this.optionService = optionService;
     }
 
-    private MappingService mappingService;
-
     public void setMappingService( MappingService mappingService )
     {
         this.mappingService = mappingService;
     }
 
-    // -------------------------------------------------------------------------
-    // Input/output
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
     public void setId( Integer id )
     {
         this.id = id;
     }
 
-    private DataElement dataElement;
-
     public DataElement getDataElement()
     {
         return dataElement;
     }
 
-    private Collection<DataElementGroup> dataElementGroups;
-
     public Collection<DataElementGroup> getDataElementGroups()
     {
         return dataElementGroups;
     }
 
-    private List<DataElementCategoryCombo> dataElementCategoryCombos;
-
     public List<DataElementCategoryCombo> getDataElementCategoryCombos()
     {
         return dataElementCategoryCombos;
     }
 
-    private List<OrganisationUnitLevel> organisationUnitLevels;
-
     public List<OrganisationUnitLevel> getOrganisationUnitLevels()
     {
         return organisationUnitLevels;
     }
 
-    private List<OrganisationUnitLevel> aggregationLevels = new ArrayList<OrganisationUnitLevel>();
-
     public List<OrganisationUnitLevel> getAggregationLevels()
     {
         return aggregationLevels;
     }
 
-    private DataElementCategoryCombo defaultCategoryCombo;
-
     public DataElementCategoryCombo getDefaultCategoryCombo()
     {
         return defaultCategoryCombo;
     }
 
-    private List<DataElementGroupSet> groupSets;
-
     public List<DataElementGroupSet> getGroupSets()
     {
         return groupSets;
     }
 
-    private List<Attribute> attributes;
-
     public List<Attribute> getAttributes()
     {
         return attributes;
     }
 
-    public Map<Integer, String> attributeValues = new HashMap<Integer, String>();
-
     public Map<Integer, String> getAttributeValues()
     {
         return attributeValues;
     }
 
-    private List<OptionSet> optionSets;
-
     public List<OptionSet> getOptionSets()
     {
         return optionSets;
     }
 
-    private List<MapLegendSet> legendSets;
-
     public List<MapLegendSet> getLegendSets()
     {
         return legendSets;
     }
 
-    private boolean update;
-
     public boolean isUpdate()
     {
         return update;
@@ -235,6 +217,11 @@
 
             attributeValues = AttributeUtils.getAttributeValueMap( dataElement.getAttributeValues() );
         }
+        else
+        {
+            dataElement = new DataElement();
+            dataElement.setCategoryCombo( defaultCategoryCombo );
+        }
 
         organisationUnitLevels = new ArrayList<OrganisationUnitLevel>( levelMap.values() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm	2014-06-26 09:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm	2014-07-07 02:47:35 +0000
@@ -97,11 +97,7 @@
 			</select>
 		</td>
 	</tr>
-    #if( $update )
-    <tr id='numberTypeTR' #if( $!dataElement.type != 'int' ) style="display:none" #end>
-    #else
-    <tr id='numberTypeTR'>
-    #end
+    <tr id='numberTypeTR' #if( $!dataElement.id > 0 && $!dataElement.type != 'int' ) style="display:none" #end>
 		<td><label for="numberValueType">$i18n.getString( "number_value_type" )</label></td>
 		<td>
             <select id="numberType" name="numberType">
@@ -145,7 +141,7 @@
    				<option value="true" #if( $!dataElement.zeroIsSignificant ) selected="selected" #end>$i18n.getString( "yes" )</option>
    			</select>
    			<script>
-   				if( '$!dataElement.type' == 'int' ){
+   				if( $!dataElement == '' || $!dataElement.type' == 'int' ){
    					enable('zeroIsSignificant');
    				}else{
    					disable('zeroIsSignificant');
@@ -161,14 +157,8 @@
 		<td><label for="selectedCategoryComboId">$i18n.getString( "category_combo" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
 			<select id="selectedCategoryComboId" #if( $!dataElement.getDomainTypeNullSafe()=='tracker') disabled #end>>
-            #if( $update )
-                #foreach( $dataElementCategoryCombo in $!dataElementCategoryCombos )
-                    <option value="$!dataElementCategoryCombo.id" #if( $!dataElementCategoryCombo.id == $!dataElement.categoryCombo.id ) selected="selected" #end>$!encoder.htmlEncode( $!dataElementCategoryCombo.displayName )</option>
-                #end
-            #else
-                #foreach( $dataElementCategoryCombo in $dataElementCategoryCombos )
-                    <option value="$dataElementCategoryCombo.id" #if( $dataElementCategoryCombo.id == $defaultCategoryCombo.id ) selected="selected" #end>$encoder.htmlEncode( $dataElementCategoryCombo.displayName )</option>
-                #end
+            #foreach( $dataElementCategoryCombo in $!dataElementCategoryCombos )
+                <option value="$!dataElementCategoryCombo.id" #if( $!dataElementCategoryCombo.id == $!dataElement.categoryCombo.id ) selected="selected" #end>$!encoder.htmlEncode( $!dataElementCategoryCombo.displayName )</option>
             #end
 			</select>
 			<input type="hidden" id="submitCategoryComboId" name="selectedCategoryComboId"/>