=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java 2010-07-01 10:08:55 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java 2010-07-27 03:51:10 +0000 @@ -27,6 +27,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.dataentryform.DataEntryFormAssociation; import org.hisp.dhis.dataentryform.DataEntryFormService; @@ -105,11 +108,86 @@ else { dataEntryForm.setName( nameField ); - dataEntryForm.setHtmlCode( designTextarea ); + dataEntryForm.setHtmlCode( prepareDataEntryFormInputs(designTextarea )); dataEntryFormService.updateDataEntryForm( dataEntryForm ); } return SUCCESS; } + + private String prepareDataEntryFormInputs( String preparedCode ) + { + // --------------------------------------------------------------------- + // Buffer to contain the final result. + // --------------------------------------------------------------------- + + StringBuffer sb = new StringBuffer(); + + // --------------------------------------------------------------------- + // Pattern to match data elements in the HTML code. + // --------------------------------------------------------------------- + + Pattern patDataElement = Pattern.compile( "(" ); + Matcher matDataElement = patDataElement.matcher( preparedCode ); + + // --------------------------------------------------------------------- + // Iterate through all matching data element fields. + // --------------------------------------------------------------------- + + boolean result = matDataElement.find(); + + while ( result ) + { + // ----------------------------------------------------------------- + // Get input HTML code (HTML input field code). + // ----------------------------------------------------------------- + + String dataElementCode = matDataElement.group( 1 ); + + // ----------------------------------------------------------------- + // Pattern to extract data element name from data element field + // ----------------------------------------------------------------- + + Pattern patDataElementName = Pattern.compile( "value=\"\\[ (.*) \\]\"" ); + Matcher matDataElementName = patDataElementName.matcher( dataElementCode ); + + Pattern patTitle = Pattern.compile( "title=\"-- (.*) --\"" ); + Matcher matTitle = patTitle.matcher( dataElementCode ); + + if ( matDataElementName.find() && matDataElementName.groupCount() > 0 ) + { + String temp = "[ " + matDataElementName.group( 1 ) + " ]"; + dataElementCode = dataElementCode.replace( temp, "" ); + + if ( matTitle.find() && matTitle.groupCount() > 0 ) + { + temp = "-- " + matTitle.group( 1 ) + " --"; + dataElementCode = dataElementCode.replace( temp, "" ); + } + + // ------------------------------------------------------------- + // Appends dataElementCode + // ------------------------------------------------------------- + + String appendCode = dataElementCode; + appendCode += "/>"; + matDataElement.appendReplacement( sb, appendCode ); + } + + // ----------------------------------------------------------------- + // Go to next data entry field + // ----------------------------------------------------------------- + + result = matDataElement.find(); + } + + // ----------------------------------------------------------------- + // Add remaining code (after the last match), and return formatted code. + // ----------------------------------------------------------------- + + matDataElement.appendTail( sb ); + + return sb.toString(); + } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java 2010-07-27 03:51:10 +0000 @@ -194,7 +194,7 @@ // ----------------------------------------------------------------- matDataElement.appendTail( sb ); - + return sb.toString(); } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2010-07-07 10:22:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2010-07-27 03:51:10 +0000 @@ -280,7 +280,7 @@ /main.vm /dhis-web-maintenance-dataset/viewDataEntryForm.vm - javascript/FCK/fckeditor.js, javascript/dataEntryForm.js + javascript/FCK/fckeditor.js, javascript/FCK/editor/js/fckeditorcode_gecko.js, javascript/dataEntryForm.js ,../dhis-web-commons/util/validate/jquery.validate.js,../dhis-web-commons/util/jquery.metadata.js ,../dhis-web-commons/util/validate/additional-methods.js,../dhis-web-commons/validationMessages.action css/cde.css === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js 2010-07-01 10:08:55 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js 2010-07-27 03:51:10 +0000 @@ -177,7 +177,6 @@ } } -var url; function autoSaveDataEntryForm(){ var field = FCKeditorAPI.GetInstance('designTextarea'); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2010-07-24 15:40:31 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2010-07-27 03:51:10 +0000 @@ -1,5 +1,3 @@ - -