← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7109: (patient) Add Edit/Delete/View functions for one stage-instance into TB (WIP).

 

------------------------------------------------------------
revno: 7109
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-05-30 22:51:44 +0700
message:
  (patient) Add Edit/Delete/View functions for one stage-instance into TB (WIP).
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/delete.png
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/view.png
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/ajax-loader-circle.gif
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-05-28 10:17:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-05-30 15:51:44 +0000
@@ -194,6 +194,8 @@
     {
         Grid grid = new ListGrid();
         
+        grid.addHeader( new GridHeader( "id", true, true ) );
+        
         grid.addHeader( new GridHeader( "Report date", false, true ) );
         
         //TODO hidden cols
@@ -257,7 +259,7 @@
         
         String selector = count ? "count(*) " : "* ";
         
-        String sql = "select " + selector + "from ( select psi.executiondate,";
+        String sql = "select " + selector + "from ( select psi.programstageinstanceid, psi.executiondate,";
         
         for ( int i = 0; i < maxLevel; i++ )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2012-03-16 02:00:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2012-05-30 15:51:44 +0000
@@ -101,6 +101,13 @@
         this.dataElementId = dataElementId;
     }
 
+    private Integer programStageInstanceId;
+
+    public void setProgramStageInstanceId( Integer programStageInstanceId )
+    {
+        this.programStageInstanceId = programStageInstanceId;
+    }
+
     public int getDataElementId()
     {
         return dataElementId;
@@ -113,6 +120,8 @@
         return statusCode;
     }
 
+    private ProgramStageInstance programStageInstance;
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -120,7 +129,14 @@
     public String execute()
         throws Exception
     {
-        ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance();
+        if ( programStageInstanceId == null )
+        {
+            programStageInstance = selectedStateManager.getSelectedProgramStageInstance();
+        }
+        else
+        {
+            programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
+        }
 
         DataElement dataElement = dataElementService.getDataElement( dataElementId );
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-05-30 07:22:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-05-30 15:51:44 +0000
@@ -343,4 +343,7 @@
 identifiers_and_attributes = Identifiers and Attributes
 first_name = First name
 middle_name = Middle name
-last_name = Last name
\ No newline at end of file
+last_name = Last name
+confirmation = Confirmation
+data_entry_form = Data entry form
+view = View
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-05-29 07:37:37 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-05-30 15:51:44 +0000
@@ -737,6 +737,13 @@
             <result name="success" type="velocity-json">
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
         </action>
+        
+        <action name="viewRecord"
+			class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<param name="page">/dhis-web-caseentry/programStageDataEntryForm.vm</param>
+			<param name="stylesheets">../style/dataEntry.css</param>
+		</action>
 		
 	</package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-05-30 06:36:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-05-30 15:51:44 +0000
@@ -47,6 +47,9 @@
 			favorite_rename: 'updateTabularReportName.action',
 			favorite_save: 'saveTabularReport.action',
             favorite_delete: 'deleteTabularReport.action',
+			datavalue_save: 'saveValue.action',
+			datavalue_view: 'viewRecord.action',
+			datavalue_delete: 'removeCurrentEncounter.action',
             redirect: 'index.action'
         },
         params: {
@@ -116,6 +119,8 @@
 		grid_favorite_height: 250,
         window_favorite_ypos: 100,
         window_confirm_width: 250,
+		window_record_width: 450,
+		window_record_height: 300,
     }
 };
 
@@ -644,13 +649,9 @@
         },
         datatable: null,
         getDataTableStore: function() {
-
 			this.datatable = Ext.create('Ext.data.ArrayStore', {
 				fields: TR.value.fields,
-				data: TR.value.values,
-				remoteSort: true,
-				autoLoad: false,
-				storage: {}
+				data: TR.value.values
 			});
         },
 		favorite: Ext.create('Ext.data.Store', {
@@ -722,7 +723,8 @@
 						TR.value.values=json.items;
 						
 						var fields = [];
-						for( var index=0; index < TR.value.columns.length; index++ )
+						fields[0] = 'id';
+						for( var index=1; index < TR.value.columns.length; index++ )
 						{
 							fields[index] = 'col' + index;
 						}
@@ -950,22 +952,88 @@
     TR.value = {
 		columns: [],
 		fields: [],
-		values: []
+		values: [],
+		save: function( psiId, deId, value)
+		{
+			var params = 'programStageInstanceId=' + psiId; 
+				params += '&dataElementId=' + deId;
+				params += '&value=' ;
+			if( value != '')
+				params += value;
+			
+			Ext.Ajax.request({
+				url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.datavalue_save,
+				method: 'POST',
+				params: params,
+				success: function() {}
+			});
+		},
+		view: function( psiId )
+		{
+			var params = 'programStageInstanceId=' + psiId;
+			Ext.Ajax.request({
+				url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.datavalue_view,
+				method: 'GET',
+				params: params,
+				success: function ( response, request ) { 
+					var htmlWindow = Ext.create('Ext.window.Window', {
+						title: TR.i18n.data_entry_form,
+						cls: 'tr-messagebox',
+						modal: true,
+						width: TR.conf.layout.window_record_width,
+						height: TR.conf.layout.window_record_height,
+						autoScroll: true,
+					}).show();
+					
+					htmlWindow.update(response.responseText);
+					document.getElementById('programDiv').style.display = 'none';
+				}
+			});
+		},
+		remove: function( psiId, rowIdx )
+		{
+			Ext.Msg.confirm( TR.i18n.confirmation, TR.i18n.are_you_sure, function(btn){
+				if (btn == 'yes')
+				{
+					var params = 'programStageInstanceId=' + psiId; 
+					Ext.Ajax.request({
+						url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.datavalue_delete,
+						method: 'GET',
+						params: params,
+						success: function() {
+							var grid = TR.datatable.datatable;
+							grid.getView().getNode(rowIdx).classList.add('hidden');
+						}
+					});
+				}
+            });
+		}
     };
       
     TR.datatable = {
         datatable: null,
-		rowEditing: null,
+		cellEditing: null,
 		getDataTable: function() {
 						
 			var orgUnitCols = ( TR.init.system.maxLevels + 1 - TR.cmp.settings.level.getValue() );
 			var index = 0;
 			var cols = [];
 			
-			// Report date column
+			// id of event
 			
 			cols[index] = {
 				header: TR.value.columns[index].name, 
+				dataIndex: 'id',
+				width: 50,
+				height: TR.conf.layout.east_gridcolumn_height,
+				sortable: false,
+				draggable: false,
+				hidden: true,
+				menuDisabled: true
+			};
+			
+			cols[++index] = {
+				header: TR.value.columns[index].name, 
 				dataIndex: 'col' + index,
 				width: 50,
 				height: TR.conf.layout.east_gridcolumn_height,
@@ -1027,7 +1095,9 @@
 					hidden: eval(TR.value.columns[index].hidden ),
 					sortable: false,
 					draggable: true,
+					isEditAllowed: true,
 					emptyText: TR.i18n.et_no_data,
+					selectOnTab: true,
 					editor: {
 						xtype: TR.value.columns[index].valueType,
 						queryMode: 'local',
@@ -1043,25 +1113,71 @@
 				};
 			});
 			
-			this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+			cols[++index]={
+				xtype:'actioncolumn',
+				width:50,
+				//locked: true,
+				items: [{
+					icon: 'images/view.png',  // Use a URL in the icon config
+					tooltip: TR.i18n.view,
+					handler: function(grid, rowIndex, colIndex) {
+						var psiId = grid.getStore().getAt(rowIndex).data['id'];
+						TR.value.view( psiId );
+					}
+				},
+				'->',
+				{
+					icon: 'images/delete.png',
+					tooltip: 'Delete',
+					handler: function(grid, rowIndex, colIndex) {
+						var psiId = grid.getStore().getAt(rowIndex).data['id'];
+						TR.value.remove( psiId, rowIndex );
+					}
+				}]
+			}
+			
+			this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
 				clicksToEdit: 1,
-				editStyle: 'row',
 				autoScroll: true,
-				errorSummary: false,
+				errorSummary: true,
 				listeners: {
-					beforeedit: function( editor, e) 
+					beforeedit: function( e, editor) 
 					{
-						if( editor.rowIdx > 0 )
+						if( e.rowIdx > 0 && !e.column.isEditAllowed )
 						{
 							return false;
 						}
 					},
 					edit: function( editor, e ){
-						TR.exe.execute();
+						var grid = TR.datatable.datatable;
+						grid.getView().getNode(e.rowIdx).classList.remove('hidden');
+						
+						var oldValue = e.originalValue;
+						var newValue = e.value;
+						if( newValue != oldValue)
+						{
+							// filter
+							if( e.rowIdx==0 ){
+								TR.exe.execute();
+							}
+							// save data-value of data element
+							else{
+								var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
+								var deId = e.column.name.split('_')[1];
+								TR.value.save( psiId, deId, newValue);
+								//e.record.commit();
+							}
+						}
 					},
 					canceledit: function( grid, eOpts ){
-						var grid = TR.datatable.datatable;
-						grid.getView().getNode(0).classList.add('hidden');
+						if( e.rowIdx == 0 ){
+							var grid = TR.datatable.datatable;
+							grid.getView().getNode(0).classList.add('hidden');
+						}
+					},
+					validateedit: function( editor, e, eOpts )
+					{
+						return true;
 					}
 				}
 			});
@@ -1073,6 +1189,7 @@
 				columns: cols,
 				scroll: 'both',
 				title: TR.cmp.settings.program.rawValue + " - " + TR.cmp.params.programStage.rawValue + " " + TR.i18n.report,
+				selType: 'cellmodel',
 				viewConfig: {
 					getRowClass: function(record, rowIndex, rp, ds){ 
 						if(rowIndex == 0){
@@ -1168,12 +1285,12 @@
 						}
 					}
 				], 
-				plugins: [this.rowEditing],
+				plugins: [this.cellEditing],
 				store: TR.store.datatable
 			});
 										
 			if (Ext.grid.RowEditor) {
-				Ext.apply(Ext.grid.RowEditor.prototype, {
+				Ext.apply(Ext.grid.CellEditor.prototype, {
 					saveBtnText : TR.i18n.filter,
 					cancelBtnText : TR.i18n.cancel
 				});
@@ -1266,7 +1383,7 @@
                             items: [
                             {
 								xtype: 'label',
-								text: TR.i18n.programs,
+								text: TR.i18n.program,
 								style: 'font-size:11px; font-weight:bold; padding:0 0 0 3px'
 							},
 							{ bodyStyle: 'padding:1px 0; border-style:none;	background-color:transparent' },
@@ -1960,10 +2077,9 @@
 								grid.getView().getNode(0).classList.remove('hidden');
 								var record = grid.getView().getRecord( grid.getView().getNode(0) );
 								grid.getView().getSelectionModel().select(record, false, false);
-								TR.datatable.rowEditing.startEdit(0, 0);
 							}
 							else {
-								TR.exe.execute();
+								grid.getView().getNode(0).classList.add('hidden');
 							}
 						}
 					},

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-05-07 04:34:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-05-30 15:51:44 +0000
@@ -716,4 +716,118 @@
 
 .tr-menu-item-desc {
     background-image:url('../images/hmenu-desc.gif');
-}
\ No newline at end of file
+}
+
+
+
+
+
+
+
+
+/*----------------------------------------------------------------------------*/
+/* For data entry form                                                        */
+/*----------------------------------------------------------------------------*/
+
+.entryScreen
+{
+ margin-bottom:20px; 
+ width:60%;
+ font-size: 13px; 
+ line-height:18px;
+}
+
+input.inputText
+{
+	width:220px; 
+	text-align:center;
+}
+
+select.inputText
+{
+	width:225px; 
+	text-align:center;
+}
+
+input.optionset
+{
+	width:195px; 
+	text-align:center;
+}
+
+.text-column
+{
+	text-align:left;
+	padding-right:20px; 
+	padding-left:5px; 
+}
+
+.hidden 
+{
+	display: none;
+}
+
+.visible
+{
+	display: block;
+}
+
+/*----------------------------------------------------------------------------*/
+/* For Program Stages History/Plan                                            */
+/*----------------------------------------------------------------------------*/
+
+td.row
+{
+	border-bottom-style:dotted;
+}
+
+table.history
+{
+	width:350px; 
+	margin-left:10px;
+	margin-top:10px;
+	margin-right:10px;
+	margin-bottom:10px;
+}
+
+div#currentSelection
+{
+	float:right;
+	color: black;  
+	font-size: 12px; 
+}
+
+/*----------------------------------------------------------------------------*/
+/* Action fiels in entry form                                                 */
+/*----------------------------------------------------------------------------*/
+
+input.button
+{
+	width: 150px;
+	padding-left:5px;
+	padding-right:5px;
+}
+
+.criteria
+{
+	width:350px;
+	padding-left:5px;
+}
+
+.inputWidth
+{
+	width:350px;
+}
+
+div.actions
+{
+  float: right;
+  width: 170px;
+  text-align: right;
+}
+
+.small-button {
+	font-size: .8em !important;
+}
+
+.ui-autocomplete { height: 100px; overflow-y: scroll; overflow-x: hidden;}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/delete.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/delete.png	1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/delete.png	2012-05-30 15:51:44 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/view.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/view.png	1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/view.png	2012-05-30 15:51:44 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html	2012-04-15 08:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html	2012-05-30 15:51:44 +0000
@@ -2,7 +2,9 @@
 <head>
     <title>DHIS 2 Beneficary Tabular Report</title>
     <link rel="stylesheet" type="text/css" href="../../dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css" />
-    <link rel="stylesheet" type="text/css" href="css/style.css" />    
+    <link rel="stylesheet" type="text/css" href="css/style.css" />  
+	<link type="text/css" rel="stylesheet" media="screen" href="../../dhis-web-commons/css/widgets.css" />
+	<link type="text/css" rel="stylesheet" media="screen" href="../../dhis-web-commons/css/light_blue/light_blue.css" />
 </head>
 
 <body>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-05-30 03:30:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-05-30 15:51:44 +0000
@@ -1,5 +1,3 @@
-<link rel="stylesheet" href="javascript/customcheckbox/prettyCheckboxes.css" type="text/css" media="screen" title="prettyComment main stylesheet" charset="utf-8" />
-
 <script>
 	jQuery("#entryFormContainer").ready(function(){
 	

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-05-30 07:10:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-05-30 15:51:44 +0000
@@ -69,5 +69,8 @@
 overwrite:'$encoder.jsEscape($i18n.getString( 'overwrite' ) , "'")',
 et_no_programs: '$encoder.jsEscape($i18n.getString( 'et_no_programs' ) , "'")',
 favorites:'$encoder.jsEscape($i18n.getString( 'favorites' ) , "'")',
-name_already_in_use: '$encoder.jsEscape($i18n.getString( 'name_already_in_use' ) , "'")'
+name_already_in_use: '$encoder.jsEscape($i18n.getString( 'name_already_in_use' ) , "'")',
+view: '$encoder.jsEscape($i18n.getString( 'view' ) , "'")',
+confirmation:'$encoder.jsEscape($i18n.getString( 'confirmation' ) , "'")',
+data_entry_form:'$encoder.jsEscape($i18n.getString( 'data_entry_form' ) , "'")',
 };
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/ajax-loader-circle.gif'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/ajax-loader-circle.gif	1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/ajax-loader-circle.gif	2012-05-30 15:51:44 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm	2012-05-30 03:30:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageDataEntryForm.vm	2012-05-30 15:51:44 +0000
@@ -35,7 +35,7 @@
 </table>
 #end
 
-<table>    
+<table id='programDiv'>    
    <tr>
         <td><label for="programId">$i18n.getString( "program" )</label></td>
         <td>