← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13833: Option sets for comments, part 1

 

------------------------------------------------------------
revno: 13833
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-23 21:05:43 +0200
message:
  Option sets for comments, part 1
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  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/UpdateDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties
  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-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2014-01-23 14:09:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2014-01-23 19:05:43 +0000
@@ -188,11 +188,16 @@
     private Set<AttributeValue> attributeValues = new HashSet<AttributeValue>();
 
     /**
-     * The option set for this data element.
+     * The option set for data values linked to this data element.
      */
     private OptionSet optionSet;
     
     /**
+     * The option set for comments linked to this data element.
+     */
+    private OptionSet commentOptionSet;
+    
+    /**
      * The legend set for this data element.
      */
     private MapLegendSet legendSet;
@@ -642,6 +647,19 @@
     }
 
     @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public OptionSet getCommentOptionSet()
+    {
+        return commentOptionSet;
+    }
+
+    public void setCommentOptionSet( OptionSet commentOptionSet )
+    {
+        this.commentOptionSet = commentOptionSet;
+    }
+
+    @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2013-10-10 15:32:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2014-01-23 19:05:43 +0000
@@ -84,6 +84,9 @@
     <many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet" column="optionsetid"
       foreign-key="fk_dataelement_optionsetid" />
 
+    <many-to-one name="commentOptionSet" class="org.hisp.dhis.option.OptionSet" column="commentoptionsetid"
+      foreign-key="fk_dataelement_optionsetid" />
+
     <many-to-one name="legendSet" class="org.hisp.dhis.mapping.MapLegendSet" column="legendsetid"
       foreign-key="fk_dataelement_legendset" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-01-23 09:31:23 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-01-23 19:05:43 +0000
@@ -592,7 +592,7 @@
         enableSectionFilter();
 
         loadDataValues();
-        insertOptionSets();
+        dhis2.de.insertOptionSets();
     }
     else
     {
@@ -618,7 +618,7 @@
                 $( '#currentOrganisationUnit' ).html( i18n_no_organisationunit_selected );
             }
 
-            insertOptionSets();
+            dhis2.de.insertOptionSets();
             loadDataValues();
         } );
     }
@@ -1878,7 +1878,7 @@
     downloadRemoteForms();
 
     DAO.store.open().done( function() {
-        loadOptionSets();
+        dhis2.de.loadOptionSets();
     });
 }
 
@@ -2513,7 +2513,7 @@
 // Option set
 // -----------------------------------------------------------------------------
 
-function searchOptionSet( uid, query, success ) 
+dhis2.de.searchOptionSet = function( uid, query, success ) 
 {
     if ( window.DAO !== undefined && window.DAO.store !== undefined ) {
         DAO.store.get( 'optionSets', uid ).done( function ( obj ) {
@@ -2522,7 +2522,8 @@
 
                 if ( query == null || query == '' ) {
                     options = obj.optionSet.options.slice( 0, MAX_DROPDOWN_DISPLAYED - 1 );
-                } else {
+                } 
+                else {
                     query = query.toLowerCase();
 
                     for ( var idx=0, len = obj.optionSet.options.length; idx < len; idx++ ) {
@@ -2544,16 +2545,19 @@
                         id: item
                     };
                 } ) );
-            } else {
-                getOptions( uid, query, success );
+            } 
+            else {
+                dhis2.de.getOptions( uid, query, success );
             }
         } );
-    } else {
-        getOptions( uid, query, success );
+    } 
+    else {
+        dhis2.de.getOptions( uid, query, success );
     }
-}
+};
 
-function getOptions( uid, query, success ) {
+dhis2.de.getOptions = function( uid, query, success ) 
+{
     $.ajax( {
         url: '../api/optionSets/' + uid + '.json?links=false&q=' + query,
         dataType: "json",
@@ -2568,9 +2572,10 @@
             } ) );
         }
     } );
-}
+};
 
-function loadOptionSets() {
+dhis2.de.loadOptionSets = function() 
+{
     var options = _.values( dhis2.de.optionSets );
     var uids = [];
 
@@ -2606,9 +2611,10 @@
     } );
 
     deferred.resolve();
-}
+};
 
-function insertOptionSets() {
+dhis2.de.insertOptionSets = function() 
+{
     $( '.entryoptionset').each( function( idx, item ) {
     	var optionSetKey = splitFieldId(item.id);
 
@@ -2621,11 +2627,12 @@
 
         item = item + '-val';
         optionSetKey = optionSetKey.dataElementId + '-' + optionSetKey.optionComboId;
-        autocompleteOptionSetField( item, dhis2.de.optionSets[optionSetKey].uid );
+        dhis2.de.autocompleteOptionSetField( item, dhis2.de.optionSets[optionSetKey].uid );
     } );
-}
+};
 
-function autocompleteOptionSetField( idField, optionSetUid ) {
+dhis2.de.autocompleteOptionSetField = function( idField, optionSetUid ) 
+{
     var input = jQuery( '#' + idField );
 
     if ( !input ) {
@@ -2637,7 +2644,7 @@
         delay: 0,
         minLength: 0,
         source: function ( request, response ) {
-            searchOptionSet( optionSetUid, input.val(), response );
+            dhis2.de.searchOptionSet( optionSetUid, input.val(), response );
         },
         select: function ( event, ui ) {
             input.val( ui.item.value );
@@ -2677,7 +2684,7 @@
             input.autocomplete( 'search', '' );
             input.focus();
         } );
-}
+};
 
 // -----------------------------------------------------------------------------
 // Various

=== 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	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2014-01-23 19:05:43 +0000
@@ -223,6 +223,13 @@
         this.selectedOptionSetId = selectedOptionSetId;
     }
     
+    private Integer selectedCommentOptionSetId;
+    
+    public void setSelectedCommentOptionSetId( Integer selectedCommentOptionSetId )
+    {
+        this.selectedCommentOptionSetId = selectedCommentOptionSetId;
+    }
+
     private Integer selectedLegendSetId;
 
     public void setSelectedLegendSetId( Integer selectedLegendSetId )
@@ -265,6 +272,7 @@
             .getDataElementCategoryCombo( selectedCategoryComboId );
 
         OptionSet optionSet = optionService.getOptionSet( selectedOptionSetId );
+        OptionSet commentOptionSet = optionService.getOptionSet( selectedCommentOptionSetId );
         MapLegendSet legendSet = mappingService.getMapLegendSet( selectedLegendSetId );
 
         dataElement.setName( name );
@@ -291,6 +299,7 @@
         dataElement.setCategoryCombo( categoryCombo );
         dataElement.setAggregationLevels( new ArrayList<Integer>( ConversionUtils.getIntegerCollection( aggregationLevels ) ) );
         dataElement.setOptionSet( optionSet );
+        dataElement.setCommentOptionSet( commentOptionSet );
         dataElement.setLegendSet( legendSet );
 
         if ( jsonAttributeValues != null )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2014-01-23 19:05:43 +0000
@@ -248,6 +248,13 @@
         this.selectedOptionSetId = selectedOptionSetId;
     }
 
+    private Integer selectedCommentOptionSetId;
+    
+    public void setSelectedCommentOptionSetId( Integer selectedCommentOptionSetId )
+    {
+        this.selectedCommentOptionSetId = selectedCommentOptionSetId;
+    }
+
     private Integer selectedLegendSetId;
 
     public void setSelectedLegendSetId( Integer selectedLegendSetId )
@@ -295,6 +302,7 @@
             .getDataElementCategoryCombo( selectedCategoryComboId );
 
         OptionSet optionSet = optionService.getOptionSet( selectedOptionSetId );
+        OptionSet commentOptionSet = optionService.getOptionSet( selectedCommentOptionSetId );
         MapLegendSet legendSet = mappingService.getMapLegendSet( selectedLegendSetId );
 
         dataElement.setName( name );
@@ -324,6 +332,7 @@
         dataElement.setAggregationLevels( new ArrayList<Integer>( ConversionUtils
             .getIntegerCollection( aggregationLevels ) ) );
         dataElement.setOptionSet( optionSet );
+        dataElement.setCommentOptionSet( commentOptionSet );
         dataElement.setLegendSet( legendSet );
 
         Set<DataSet> dataSets = dataElement.getDataSets();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2014-01-23 15:36:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2014-01-23 19:05:43 +0000
@@ -189,7 +189,7 @@
 negative_integer=Negative Integer
 view_1=View 1
 view_2=View 2
-store_zero_data_values=Store Zero Data Value
+store_zero_data_values=Store zero data values
 form_name=Form name
 compulsory=Compulsory
 data_dimension=Data Dimension
@@ -213,4 +213,6 @@
 use=use
 dimension_type=Dimension type
 disaggregation=Disaggregation
-attribute=Attribute
\ No newline at end of file
+attribute=Attribute
+option_set_for_data_values=Option set for data values
+option_set_for_comments=Option set for comments
\ No newline at end of file

=== 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-01-23 15:36:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm	2014-01-23 19:05:43 +0000
@@ -95,7 +95,7 @@
 			</select>
 		</td>
 	</tr>
-	<tr #if( $calculatedDataElement ) style="display:none" #end>
+	<tr>
 		<td><label for="valueType">$i18n.getString( "value_type" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
             <select id="valueType" name="valueType" onchange="changeValueType( this.value )">
@@ -165,7 +165,7 @@
         <td><label for="url">$i18n.getString( "url" )</label></td>
         <td><input type="text" id="url" name="url" value="$!encoder.htmlEncode( $!dataElement.url )"></td>
     </tr>
-	<tr #if( $calculatedDataElement ) style="display:none" #end >	
+	<tr>	
 		<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()=='patient') disabled #end>>
@@ -182,12 +182,8 @@
 			<input type="hidden" id="submitCategoryComboId" name="selectedCategoryComboId"/>
 		</td>
 	</tr>
-    <tr>
-        <td style="width:200px">$i18n.getString( "aggregation_levels" )</td>
-        <td><input type="checkbox" #if ( $!dataElement.hasAggregationLevels() )checked="checked"#end onclick="toggleById( 'aggregationLevelsContainer' )"/></td>
-    </tr>
 	<tr>
-		<td>$i18n.getString( 'option_set' )</td>			
+		<td>$i18n.getString( 'option_set_for_data_values' )</td>			
 		<td>
 			<select id="selectedOptionSetId" name="selectedOptionSetId">
 				<option value="0">[$i18n.getString('please_select')]</option>
@@ -198,6 +194,17 @@
 		</td>
     </tr>
     <tr>
+        <td>$i18n.getString( 'option_set_for_comments' )</td>            
+        <td>
+            <select id="selectedCommentOptionSetId" name="selectedCommentOptionSetId">
+                <option value="0">[$i18n.getString('please_select')]</option>
+                #foreach ( $optionSet in $optionSets )
+                <option value="$optionSet.id" #if( $!dataElement.commentOptionSet && $!dataElement.commentOptionSet.id == "$optionSet.id" ) selected #end>$!encoder.htmlEncode( $optionSet.displayName )</option>
+                #end
+            </select>
+        </td>
+    </tr>
+    <tr>
         <td>$i18n.getString( 'legend_set' )</td>            
         <td>
             <select id="selectedLegendSetId" name="selectedLegendSetId">
@@ -208,6 +215,10 @@
             </select>
         </td>
     </tr>
+    <tr>
+        <td style="width:200px">$i18n.getString( "aggregation_levels" )</td>
+        <td><input type="checkbox" #if ( $!dataElement.hasAggregationLevels() )checked="checked"#end onclick="toggleById( 'aggregationLevelsContainer' )"/></td>
+    </tr>
 </table>
 
 <div id="aggregationLevelsContainer" style="border:1px solid #808080;padding:10px;width:465px;#if( !$!dataElement.hasAggregationLevels() ) display:none;#else display:block;#end">