← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8913: Disable edit data values and remove ebents functions in tabular report; minor fix for program val...

 

------------------------------------------------------------
revno: 8913
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-11-06 22:44:27 +0700
message:
  Disable edit data values and remove ebents functions in tabular report; minor fix for program validation rules.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
  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/validationResult.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/DefaultProgramValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-11-06 08:39:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-11-06 15:44:27 +0000
@@ -141,7 +141,11 @@
     public ProgramValidationResult runValidation( ProgramValidation validation,
         ProgramStageInstance programStageInstance, I18nFormat format )
     {
-        if ( !validation.getDateType() )
+        if ( validation.getDateType() )
+        {
+            return runDateExpression( validation, programStageInstance, format );
+        }
+        else
         {
             String resultLeft = runExpression( validation.getLeftSide(), programStageInstance );
             String resultRight = runExpression( validation.getRightSide(), programStageInstance );
@@ -155,11 +159,9 @@
                         resultLeft.split( SEPARATE_SIDE_VALUE )[1], resultRight.split( SEPARATE_SIDE_VALUE )[1] );
                 }
             }
-
-            return null;
         }
-
-        return runDateExpression( validation, programStageInstance, format );
+        
+        return null;
     }
 
     public Collection<ProgramValidation> getProgramValidation( Program program )
@@ -260,25 +262,21 @@
                         valid = (value.after( dueDate ) || value.equals( dueDate ));
                         break;
                     default:
+                        rightValidation = Integer.parseInt( rightSide.substring( 0, index ) );
+                        int daysValue = Integer.parseInt( rightSide.substring( index + 1, rightSide.length() ) );
+                        if ( rightValidation == BEFORE_DUE_DATE_PLUS_OR_MINUS_MAX_DAYS )
+                        {
+                            long maxDays = dueDate.getTime() / 86400000 + daysValue;
+                            long minDays = dueDate.getTime() / 86400000 - daysValue;
+                            long valueDays = value.getTime() / 86400000;
+                            valid = (valueDays <= maxDays && valueDays >= minDays);
+                        }
                         break;
                     }
                 }
-
-                int rightValidation = Integer.parseInt( rightSide.substring( 0, index ) );
-
-                int daysValue = Integer.parseInt( rightSide.substring( index + 1, rightSide.length() ) );
-
-                if ( rightValidation == BEFORE_DUE_DATE_PLUS_OR_MINUS_MAX_DAYS )
-                {
-                    long maxDays = dueDate.getTime() / 86400000 + daysValue;
-                    long minDays = dueDate.getTime() / 86400000 - daysValue;
-                    long valueDays = value.getTime() / 86400000;
-                    valid = (valueDays <= maxDays && valueDays >= minDays);
-                }
-
                 if ( !valid )
                 {
-                    String result = dataValue + " " + operator + " " + format.formatDate( currentDate );
+                    String result = dataValue.getValue() + " " + operator + " " + format.formatDate( currentDate );
                     return new ProgramValidationResult( programStageInstance, programValidation, result, null );
                 }
             }
@@ -388,9 +386,9 @@
         String leftSideValue = getOneSideExpressionValue( sides[0].trim(), programStageInstance );
         String rightSideValue = getOneSideExpressionValue( sides[1].trim(), programStageInstance );
 
-        if( leftSideValue==null  && rightSideValue== null )
+        if ( leftSideValue == null && rightSideValue == null )
         {
-            return "false&& ";
+            return "true&&null";
         }
         else if ( expression.indexOf( SUM_OPERATOR_IN_EXPRESSION ) != -1 )
         {
@@ -404,18 +402,20 @@
         }
         else
         {
-            if ( rightSideValue!= null && rightSideValue.equals( NOT_NULL_VALUE_IN_EXPRESSION ) )
+            if ( rightSideValue != null && rightSideValue.equals( NOT_NULL_VALUE_IN_EXPRESSION ) )
             {
                 valid = !(leftSideValue == null);
             }
-            else if (leftSideValue!=null && rightSideValue!= null &&  (comparetor.equals( "==" ) && leftSideValue.equals( rightSideValue ))
+            else if ( leftSideValue != null
+                && rightSideValue != null
+                && ((comparetor.equals( "==" ) && leftSideValue.equals( rightSideValue ))
                 || (comparetor.equals( "<" ) && leftSideValue.compareTo( rightSideValue ) < 0)
                 || (comparetor.equals( "<=" ) && (leftSideValue.equals( rightSideValue ) || leftSideValue
                     .compareTo( rightSideValue ) < 0))
                 || (comparetor.equals( ">" ) && leftSideValue.compareTo( rightSideValue ) > 0)
                 || (comparetor.equals( ">=" ) && (leftSideValue.equals( rightSideValue ) || leftSideValue
                     .compareTo( rightSideValue ) > 0))
-                || (comparetor.equals( "!=" ) && !leftSideValue.equals( rightSideValue )) )
+                || (comparetor.equals( "!=" ) && !leftSideValue.equals( rightSideValue )) ))
             {
                 valid = true;
             }
@@ -424,7 +424,7 @@
                 valid = false;
             }
         }
-
+System.out.println("\n\n === \n " + valid + SEPARATE_SIDE_VALUE + leftSideValue + " " + comparetor + " " + rightSideValue );
         return valid + SEPARATE_SIDE_VALUE + leftSideValue + " " + comparetor + " " + rightSideValue;
     }
 

=== 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-11-06 13:35:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-11-06 15:44:27 +0000
@@ -48,8 +48,6 @@
 			favorite_rename: 'updateTabularReportName.action',
 			favorite_save: 'saveTabularReport.action',
             favorite_delete: 'deleteTabularReport.action',
-			datavalue_save: 'saveValue.action',
-			datavalue_delete: 'removeCurrentEncounter.action',
 			suggested_dataelement_get: 'getOptions.action',
 			redirect: 'index.action'
         },
@@ -1101,82 +1099,11 @@
 			}
 			return 'textfield';
 		},
-		save: function(e)
-		{
-			var grid = TR.datatable.datatable;
-			grid.getView().getNode(e.rowIdx).classList.remove('hidden');
-			
-			var oldValue = e.originalValue;
-			var value = e.column.field.rawValue;
-			if( value == oldValue)
-			{
-				return false;
-			}
-			
-			var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
-			var deId = e.column.name.split('_')[1];
-			var params = 'programStageInstanceId=' + psiId; 
-				params += '&dataElementId=' + deId;
-				params += '&value=' ;
-			if( value != '')
-				params += encodeURIComponent(value);
-			
-			Ext.Ajax.request({
-				url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.datavalue_save,
-				method: 'POST',
-				params: params,
-				success: function(r) {
-					var json = Ext.JSON.decode(r.responseText);
-					if(json.response=="success")
-					{
-						var rowIdx = e.rowIdx;
-						var colIdx = e.colIdx + 1;
-						if( e.colIdx == TR.datatable.datatable.columns.length - 2 ){
-							colIdx = 0;
-							rowIdx++;
-						}
-						TR.datatable.cellEditing.startEditByPosition({row: rowIdx, column: colIdx});
-					}
-					else
-					{
-						TR.util.notification.error(TR.i18n.error, json.message);
-					}
-				}
-			});
-		},
-		remove: function( psiId, rowIdx )
-		{
-			Ext.Msg.confirm( TR.i18n.confirmation, TR.i18n.are_you_sure, function(btn){
-				if (btn == 'yes')
-				{
-					var params = 'id=' + psiId; 
-					Ext.Ajax.request({
-						url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.datavalue_delete,
-						method: 'POST',
-						params: params,
-						success: function(r) {
-							var json = Ext.JSON.decode(r.responseText);
-							if(json.response=="success")
-							{
-								var grid = TR.datatable.datatable;
-								grid.getView().getNode(rowIdx).classList.add('hidden');
-							}
-							else
-							{
-								TR.util.notification.error(TR.i18n.error, json.message);
-							}
-						}
-					});
-				}
-            });
-		}
-    };
+	};
       
     TR.datatable = {
         datatable: null,
-		cellEditing: null,
 		getDataTable: function() {
-			
 			var orgUnitCols = ( TR.init.system.maxLevels + 1 - TR.cmp.settings.level.getValue() );
 			var index = 0;
 			var cols = [];
@@ -1245,27 +1172,6 @@
 				cols[++index] = TR.datatable.createColumn( r.data.valueType, r.data.id, r.data.compulsory, r.data.name, index );
 			});
 			
-			cols[++index]={
-				xtype:'actioncolumn',
-				header: TR.i18n.operations,
-				width:80,
-				sortable: false,
-				draggable: false,
-				hideable: false,
-				items: [
-					{
-						icon: 'images/delete.png',
-						tooltip: 'Delete',
-						handler: function(grid, rowIndex, colIndex) {
-							var psiId = grid.getStore().getAt(rowIndex).data['id'];
-							TR.value.remove( psiId, rowIndex );
-						}
-					}
-				]
-			}
-			
-			TR.datatable.initCellEditing();
-	
 			// grid
 			this.datatable = Ext.create('Ext.grid.Panel', {
                 height: TR.util.viewport.getSize().y - 58,
@@ -1376,16 +1282,8 @@
 						text: TR.state.totalRecords + ' ' + TR.i18n.events
 					},
 				], 
-				plugins: [this.cellEditing],
 				store: TR.store.datatable
 			});
-										
-			if (Ext.grid.RowEditor) {
-				Ext.apply(Ext.grid.CellEditor.prototype, {
-					saveBtnText : TR.i18n.filter,
-					cancelBtnText : TR.i18n.cancel
-				});
-			}
 			
 			Ext.override(Ext.grid.header.Container, { 
 				sortAscText: TR.i18n.asc,
@@ -1398,61 +1296,6 @@
             return this.datatable;
             
         },
-		initCellEditing: function(){
-			this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
-				clicksToEdit: 1,
-				autoScroll: true,
-				errorSummary: true,
-				listeners: {
-					beforeedit: function( e, editor) 
-					{
-						if( e.rowIdx > 0 && !e.column.isEditAllowed )
-						{
-							return false;
-						}
-					},
-					edit: function( editor, e ){
-						TR.value.save(e);
-					},
-					canceledit: function( grid, eOpts ){
-						if( e.rowIdx == 0 ){
-							var grid = TR.datatable.datatable;
-							grid.getView().getNode(0).classList.add('hidden');
-						}
-					},
-					validateedit: function( editor, e, eOpts )
-					{
-						var newValue = e.column.field.rawValue;
-						if( e.column.compulsory && newValue =='' )
-						{
-							TR.util.notification.error( TR.i18n.not_empty, TR.i18n.not_empty );
-							return false;
-						}
-						
-						var valid = e.column.initialConfig.editor.xtype=="combobox" ? false : true;
-						if(!valid)
-						{
-							e.column.initialConfig.editor.store.each( function(r) {
-								if( newValue==r.data.name){
-									valid = true;
-								}
-							});
-						}
-						if( !valid ){
-							TR.cmp.statusbar.panel.setWidth(TR.cmp.region.center.getWidth());
-							TR.cmp.statusbar.panel.update('<img src="' + TR.conf.finals.ajax.path_images + TR.conf.statusbar.icon.error + '" style="padding:0 5px 0 0"/>' + TR.i18n.value_is_invalid );
-						}
-						else
-						{
-							TR.cmp.statusbar.panel.setWidth(TR.cmp.region.center.getWidth());
-							TR.cmp.statusbar.panel.update('<img src="' + TR.conf.finals.ajax.path_images + TR.conf.statusbar.icon.error + '" style="padding:0 5px 0 0"/>' + TR.i18n.value_is_valid );
-						}
-						return valid;
-					}
-				}
-			});
-			
-		},
 		createColumn: function( type, id, compulsory, colname, index )
 		{
 			var objectType = id.split('_')[0];

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm	2012-11-06 08:39:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/validationResult.vm	2012-11-06 15:44:27 +0000
@@ -26,12 +26,20 @@
 			<tbody>
 				#foreach( $validationResult in $programValidationResults )
 					<tr #alternate( $mark )>	    
-						<td>$validationResult.programValidation.description</td>
+						<td>$validationResult.programValidation.description 
+						#if($validationResult.programValidation.dateType=="true")
+							$rightsideFormulaMap.get( $validationResult.programValidation.id )
+						#end
+						</td>
 						<td>$leftsideFormulaMap.get( $validationResult.programValidation.id )</td>
 						<td>$validationResult.leftsideValue</td>
-						#if( $validationResult.programValidation.rightSide!="1==1")
-							<td>$validationResult.rightsideValue</td>
+						#if( $validationResult.programValidation.dateType=="false" 
+							&& $validationResult.programValidation.rightSide!="1==1")
+							<td>$!validationResult.rightsideValue</td>
 							<td>$rightsideFormulaMap.get( $validationResult.programValidation.id )</td>	        
+						#else
+							<td></td>
+							<td></td>
 						#end
 					#set( $mark = !$mark )
 				#end