← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6630: local/in coldchain catalog attribute type work in progress

 

------------------------------------------------------------
revno: 6630
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-18 14:54:36 +0530
message:
  local/in coldchain catalog attribute type work in progress
added:
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddColdChainCatalogTypeAttributeForm.java
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addColdChainCatalogTypeAttributeForm.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/style.css
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogTypeAttribute.js
modified:
  local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml
  local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties
  local/in/dhis-web-coldchain/src/main/resources/struts.xml
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.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 directory 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog'
=== added directory 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action'
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddColdChainCatalogTypeAttributeForm.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddColdChainCatalogTypeAttributeForm.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/AddColdChainCatalogTypeAttributeForm.java	2012-04-18 09:24:36 +0000
@@ -0,0 +1,32 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import org.hisp.dhis.program.Program;
+
+import com.opensymphony.xwork2.Action;
+
+public class AddColdChainCatalogTypeAttributeForm  implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+    
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+
+
+        return SUCCESS;
+    }
+    
+    
+}

=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetColdChainCatalogTypeAttributeListAction.java	2012-04-18 09:24:36 +0000
@@ -0,0 +1,27 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetColdChainCatalogTypeAttributeListAction  implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+    
+    
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+    
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute() throws Exception
+    {
+        
+        return SUCCESS;
+    }
+    
+}

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-04-17 10:41:26 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml	2012-04-18 09:24:36 +0000
@@ -2,11 +2,24 @@
 <beans xmlns="http://www.springframework.org/schema/beans";
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 	xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd";>
+	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd";>
 
+	<!-- Home page -->
 	<bean id="org.hisp.dhis.coldchain.action.NoAction"
         class="org.hisp.dhis.coldchain.action.NoAction"
         scope="prototype">
     </bean>
-	
+
+<!-- catalog -->	
+
+	<bean id="org.hisp.dhis.coldchain.catalog.action.GetColdChainCatalogTypeAttributeListAction"
+        class="org.hisp.dhis.coldchain.catalog.action.GetColdChainCatalogTypeAttributeListAction"
+        scope="prototype">
+    </bean>	
+
+	<bean id="org.hisp.dhis.coldchain.catalog.action.AddColdChainCatalogTypeAttributeForm"
+        class="org.hisp.dhis.coldchain.catalog.action.AddColdChainCatalogTypeAttributeForm"
+        scope="prototype">
+    </bean>	
+				
 </beans>
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties'
--- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties	2012-04-17 10:41:26 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties	2012-04-18 09:24:36 +0000
@@ -1,3 +1,16 @@
 
 coldchain = Cold Chain
-coldchain_management = Cold Chain Management
\ No newline at end of file
+coldchain_management = Cold Chain Management
+coldchain_catalog_type_attribute_management = Cold Chain catalog type attribute management
+filter_by_name = Filter by name
+catalogType_attribute = Catalog Type Attribute
+create_new_catalog_type_attribute = Create new catalog Type attribute
+catalog_type_attribute_details = Catalog Type attribute details
+mandatory = Mandatory
+no_of_char = Number of characters
+attribute_combo_type = Predefined value
+field_is_required = This field is required
+attribute_options = Attribute options
+add_more_option = Add Option
+at_least_2_option = Please add at least two attribute options
+remove_option = Remove Option
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-04-17 10:41:26 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-04-18 09:24:36 +0000
@@ -3,17 +3,35 @@
 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 "http://struts.apache.org/dtds/struts-2.0.dtd";>
 <struts>
-	<include file="dhis-web-commons.xml"/>
+<include file="dhis-web-commons.xml"/>
 	
 	<package name="dhis-web-coldchain" extends="dhis-web-commons" namespace="/dhis-web-coldchain">
-		
- 	   <action name="index"
-			class="org.hisp.dhis.coldchain.action.NoAction">
+
+<!-- Home page -->
+		<action name="index" class="org.hisp.dhis.coldchain.action.NoAction">
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-coldchain/welcome.vm</param>
 			<param name="menu">/dhis-web-coldchain/menu.vm</param>
 		</action>
 		
-	</package>
-
+
+<!-- catalog -->
+		<action name="coldChainCatalogTypeAttribute" class="org.hisp.dhis.coldchain.catalog.action.GetColdChainCatalogTypeAttributeListAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm</param>
+			<param name="menu">/dhis-web-coldchain/menu.vm</param>
+			<param name="javascripts">javascript/catalogTypeAttribute.js</param>
+			
+		</action>	
+
+		<action name="showAddColdChainCatalogTypeAttributeForm" class="org.hisp.dhis.coldchain.catalog.action.AddColdChainCatalogTypeAttributeForm">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-coldchain/addColdChainCatalogTypeAttributeForm.vm</param>
+			<param name="javascripts">javascript/catalogTypeAttribute.js</param>
+			<param name="stylesheets">css/style.css</param>
+		</action>
+		
+		
+				
+	</package>		
 </struts>
\ No newline at end of file

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addColdChainCatalogTypeAttributeForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addColdChainCatalogTypeAttributeForm.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addColdChainCatalogTypeAttributeForm.vm	2012-04-18 09:24:36 +0000
@@ -0,0 +1,79 @@
+<h3>$i18n.getString( "create_new_catalog_type_attribute" )</h3>
+<form id="addCatalogTypeAttributeForm" action="addcatalogTypeAttribute.action" method="post" >
+
+<table id="attrTable"> 
+	<thead>
+		<tr><th colspan="2">$i18n.getString( "catalog_type_attribute_details" )</th></tr>
+    </thead>
+	
+    <tbody>
+    <tr>
+        <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td><input type="text" id="name" name="name" class="{validate:{required:true,rangelength:[2,160]}}"/></td>
+        <td></td>
+    </tr>   
+    
+    <tr>
+        <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td><input type="text" id="description" name="description" class="{validate:{required:true,minlength:2}}"/></td>
+        <td></td>
+    </tr>
+    
+    <tr>
+		<td><label for="mandatory">$i18n.getString( "mandatory" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td>
+			<select id="mandatory" name="mandatory">
+				<option value="true" >$i18n.getString( "yes" )</option>
+				<option value="false" selected="selected">$i18n.getString( "no" )</option>
+			</select>
+		</td>		
+		<td></td>				
+	</tr>
+    
+    <tr>
+		<td><label for="noChar">$i18n.getString( "no_of_char" )</label></td>
+		<td>
+			<input type="text" name="noChars" id="noChars" class="{validate:{required:false, number:true}}" />
+		</td>		
+		<td></td>				
+	</tr>
+		
+    <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="ATTRIBUTE_OPTION.selectValueType(this);">
+                <option value="NUMBER" selected="selected">$i18n.getString( "number" )</option>
+                <option value="TEXT">$i18n.getString( "text" )</option>
+                <option value="YES/NO">$i18n.getString( "yes_no" )</option>
+                <option value="DATE">$i18n.getString( "date" )</option>
+                <option value="COMBO">$i18n.getString( "attribute_combo_type" )</option>
+            </select>
+        </td>
+        <td></td>
+    </tr>  
+	<tr id="attributeComboRow"> 
+		<td><label>$i18n.getString( "attribute_options" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td ><table id="attrOptionContainer"></table><a href="#" style="text-decoration: none;margin-top: 0.5em" onclick="ATTRIBUTE_OPTION.addOption()">[ $i18n.getString( "add_more_option" ) ]</a>
+		</td>
+		<td><span id="attrMessage"  name="attrMessage" style="color:red;"></span></td>
+	</tr>
+	
+    </tbody>
+	<tr>
+		<td></td>
+		<td>
+			<input type="submit" value="$i18n.getString( 'add' )" />
+   		    <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='coldChainCatalogTypeAttribute.action'" />
+		</td>
+	</tr>
+</table>
+<span id='message'></span>
+
+</form>   
+
+<script type="text/javascript">
+	var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
+	var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
+	var i118_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
+	var isSubmit = true;
+</script>

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/coldChainCatalogTypeAttribute.vm	2012-04-18 09:24:36 +0000
@@ -0,0 +1,69 @@
+
+<h3>$i18n.getString( "coldchain_catalog_type_attribute_management" )</h3>
+<table class="mainPageTable">
+  <tr>
+    <td style="vertical-align:top">
+		<table width="100%">
+			<tr>
+				<td>
+					$i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+				</td>
+				<td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddColdChainCatalogTypeAttributeForm.action'" style="width:70px"></td>
+			</tr>
+		</table>
+		
+		<table class="listTable">
+			<col>          
+			<col width="20">
+			<col width="20">
+			<col width="20">          		  
+			<thead>
+			  <tr>
+				<th>$i18n.getString( "name" )</th>
+				<th colspan="3">$i18n.getString( "operations" )</th>
+			  </tr>
+			</thead>
+			<tbody id="list"><!--
+            #foreach( $patientAttribute in $patientAttributes )
+              <tr id="tr${patientAttribute.id}">
+              
+                <td>$encoder.htmlEncode( $patientAttribute.name )</td>                
+                
+                <td style="text-align:center">
+                  <a href="showUpdatePatientAttributeForm.action?id=$patientAttribute.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+                </td>                
+ 
+                <td style="text-align:center">
+                  <a href="javascript:removePatientAttribute( '$patientAttribute.id', '$encoder.jsEncode( $patientAttribute.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+                </td>            
+                
+                <td style="text-align:center">
+                  <a href="javascript:showPatientAttributeDetails( $patientAttribute.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
+                </td>
+                
+              </tr>
+			#end
+		-->		
+          </tbody>
+
+        </table>
+    </td>
+	
+		<td style="width:20em; padding-left:2em; vertical-align:top">
+
+			<div id="detailsArea" style="display:none">
+				<div style="float:right">
+					<a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"></a>
+				</div>				
+                <p><label class="bold">$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>
+                <p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
+                <p><label class="bold">$i18n.getString( "mandatory" ):</label><br><span id="mandatoryField"></span></p>
+                <p><label class="bold">$i18n.getString( "inheritable" ):</label><br><span id="inheritableField"></span></p>
+                <p><label class="bold">$i18n.getString( "value_type" ):</label><br><span id="valueTypeField"></span></p>
+				<p><label class="bold">$i18n.getString( "program" ):</label><br><span id="programField"></span></p>
+			</div>
+
+		</td>
+  </tr>
+</table>
+

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/style.css'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/style.css	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/style.css	2012-04-18 09:24:36 +0000
@@ -0,0 +1,90 @@
+.heading-column { width : 30.5em;}
+td.input-column { width : 30.5em;}
+td.input-column input, td.input-column select { width: 28.5em;}
+td.error {padding-left:1em}
+
+textarea{
+	width:320px; 
+	text-align:left;
+}
+
+input[type="text"]{
+	width:320px; 
+	text-align:left;
+}
+
+select
+{
+	width:325px; 
+	text-align:left;
+}
+
+input[type="button"], input[type="submit"]
+{
+	width: 160px;
+	padding-left:5px;
+	padding-right:5px;
+}
+
+input.filterButton
+{
+	width: 30px;
+	padding-left:5px;
+	padding-right:5px;
+	text-align:center;
+}
+
+.hidden 
+{
+	display: none;
+}
+
+.visible
+{
+	display: block;
+}
+
+.imgButton
+{
+	cursor:pointer;
+}
+
+fieldset
+{
+	border: 1px solid #3f5d8e;
+}
+
+tr.selected{
+	background-color:#3399FF;
+	color:#FFFFFF;
+}
+
+#selectedList tr{
+	cursor:pointer;
+}
+
+.dataElementDiv
+{
+	overflow:auto; 
+	height:20em; 
+	width:30em;
+	border:1px solid #9DA1AA;
+}
+
+.dataElementDiv table
+{
+	width:100%;
+}
+
+.small-button {
+	font-size: .8em !important;
+}
+
+.ui-autocomplete { height: 100px; overflow-y: scroll; overflow-x: hidden; }
+
+
+input.autocompleted-field
+{
+	width:25em; 
+	text-align:left;
+}
\ No newline at end of file

=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogTypeAttribute.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogTypeAttribute.js	1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalogTypeAttribute.js	2012-04-18 09:24:36 +0000
@@ -0,0 +1,69 @@
+
+
+ATTRIBUTE_OPTION = 
+{
+	selectValueType : 	function (this_)
+	{
+		if ( jQuery(this_).val() == "COMBO" )
+		{
+			jQuery("#attributeComboRow").show();
+			if( jQuery("#attrOptionContainer").find("input").length ==0 ) 
+			{
+				ATTRIBUTE_OPTION.addOption();
+				ATTRIBUTE_OPTION.addOption();
+			}
+		}else {
+			jQuery("#attributeComboRow").hide();
+		}
+	},
+	checkOnSubmit : function ()
+	{
+		if( jQuery("#valueType").val() != "COMBO" ) 
+		{
+			jQuery("#attrOptionContainer").children().remove();
+			return true;
+		}else {
+			$("input","#attrOptionContainer").each(function(){ 
+				if( !jQuery(this).val() )
+					jQuery(this).remove();
+			});
+			if( $("input","#attrOptionContainer").length < 2)
+			{
+				alert(i118_at_least_2_option);
+				return false;
+			}else return true;
+		}
+	},
+	addOption : function ()
+	{
+		jQuery("#attrOptionContainer").append(ATTRIBUTE_OPTION.createInput());
+	},
+	remove : function (this_, optionId)
+	{
+		
+		if( jQuery(this_).siblings("input").attr("name") != "attrOptions")
+		{
+			jQuery.get("removePatientAttributeOption.action?id="+optionId,function(data){
+				if( data.response == "success")
+				{
+					jQuery(this_).parent().parent().remove();
+					showSuccessMessage( data.message );
+				}else 
+				{
+					showErrorMessage( data.message );
+				}
+			});
+		}else
+		{
+			jQuery(this_).parent().parent().remove();
+		}
+	},
+	removeInAddForm : function(this_)
+	{
+		jQuery(this_).parent().parent().remove();
+	},
+	createInput : function ()
+	{
+		return "<tr><td><input type='text' name='attrOptions' /><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"'  onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
+	}
+}
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-04-17 10:41:26 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-04-18 09:24:36 +0000
@@ -1,2 +1,6 @@
 
 <h2>$i18n.getString( "coldchain" )</h2>
+<ul>
+	<li><a href="coldChainCatalogTypeAttribute.action">$i18n.getString( "catalogType_attribute" )</a></li>
+	
+</ul>
\ No newline at end of file