dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12794
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4001: Fix bug: Data element text field doesn't show its name.
------------------------------------------------------------
revno: 4001
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-06-23 15:27:07 +0700
message:
Fix bug: Data element text field doesn't show its name.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.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/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2011-06-23 04:27:05 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2011-06-23 08:27:07 +0000
@@ -56,8 +56,12 @@
private static final String UNKNOW_CLINIC = "unknow_clinic";
private static final String NOTAVAILABLE = "not_available";
-
- private static final String DATA_ELEMENT_DOES_NOT_EXIST = "<i>Data element doesn't exist.</i>";
+
+ private static final String DATA_ELEMENT_DOES_NOT_EXIST = "[ Data element doesn't exist ]";
+
+ private static final String EMPTY_VALUE_TAG = "value=\"\"";
+
+ private static final String EMPTY_TITLE_TAG = "title=\"\"";
// -------------------------------------------------------------------------
// Dependencies
@@ -136,15 +140,15 @@
}
public String prepareDataEntryFormForEdit( String htmlCode )
- {
+ {
String result = populateCustomDataEntryForTextBox( htmlCode );
-
+
result = populateCustomDataEntryForCombo( result );
-
+
result = populateCustomDataEntryForBoolean( result );
-
+
result = populateCustomDataEntryForDate( result );
-
+
return result;
}
@@ -177,14 +181,15 @@
// -----------------------------------------------------------------
String dataElementCode = inputMatcher.group( 1 );
-
+
String inputHTML = inputMatcher.group();
-
+ inputHTML = inputHTML.replace( ">", "" );
+
Matcher identifierMatcher = IDENTIFIER_PATTERN_TEXTBOX.matcher( dataElementCode );
if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
{
-
+
// -------------------------------------------------------------
// Get data element ID of data element
// -------------------------------------------------------------
@@ -196,23 +201,29 @@
DataElementCategoryOptionCombo optionCombo = categoryService
.getDataElementCategoryOptionCombo( optionComboId );
- if ( dataElement == null || optionCombo == null )
- {
- inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
- }
- else
- {
- inputMatcher.appendReplacement( sb, inputHTML );
- }
-
+ String displayValue = (dataElement == null || optionCombo == null) ? "value=\""
+ + DATA_ELEMENT_DOES_NOT_EXIST + "\"" : "value=\"[ " + dataElement.getName() + " "
+ + optionCombo.getName() + " ]\"";
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = (dataElement == null || optionCombo == null) ? "title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : "title=\"-- ID:" + dataElement.getId() + " - Name:" + dataElement.getShortName() + " - "
+ + optionComboId + " - " + optionCombo.getName() + " - Type:" + dataElement.getType() + "\"";
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
+
+ inputMatcher.appendReplacement( sb, inputHTML );
}
}
inputMatcher.appendTail( sb );
-
- return ( sb.toString().isEmpty() ) ? htmlCode : sb.toString();
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
}
-
+
private String populateCustomDataEntryForBoolean( String htmlCode )
{
// ---------------------------------------------------------------------
@@ -234,6 +245,7 @@
while ( inputMatcher.find() )
{
String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
// -----------------------------------------------------------------
// Get HTML input field code
@@ -248,24 +260,30 @@
// -------------------------------------------------------------
// Get data element ID of data element
// -------------------------------------------------------------
-
+
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ String displayValue = (dataElement == null) ? "value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : "value=\"[ " + dataElement.getName() + " ]\"";
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = (dataElement == null) ? "title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\"" : "title=\"-- ID:"
+ + dataElement.getId() + " - Name:" + dataElement.getShortName() + " - Type:"
+ + dataElement.getType() + "\"";
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
- if ( dataElement == null )
- {
- inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
- }
- else
- {
- inputMatcher.appendReplacement( sb, inputHTML );
- }
+ inputMatcher.appendReplacement( sb, inputHTML );
}
}
-
+
inputMatcher.appendTail( sb );
-
- return ( sb.toString().isEmpty() ) ? htmlCode : sb.toString();
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
}
private String populateCustomDataEntryForCombo( String htmlCode )
@@ -290,6 +308,8 @@
{
String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
+
// -----------------------------------------------------------------
// Get HTML input field code
// -----------------------------------------------------------------
@@ -303,24 +323,30 @@
// -------------------------------------------------------------
// Get data element ID of data element
// -------------------------------------------------------------
-
+
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ String displayValue = (dataElement == null) ? "value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : "value=\"[ " + dataElement.getName() + " ]\"";
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = (dataElement == null) ? "title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\"" : "title=\"-- ID:"
+ + dataElement.getId() + " - Name:" + dataElement.getShortName() + " - Type:"
+ + dataElement.getType() + "\"";
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
- if ( dataElement == null )
- {
- inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
- }
- else
- {
- inputMatcher.appendReplacement( sb, inputHTML );
- }
+ inputMatcher.appendReplacement( sb, inputHTML );
}
}
-
+
inputMatcher.appendTail( sb );
-
- return ( sb.toString().isEmpty() ) ? htmlCode : sb.toString();
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
}
private String populateCustomDataEntryForDate( String htmlCode )
@@ -345,6 +371,8 @@
{
String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
+
// -----------------------------------------------------------------
// Get HTML input field code
// -----------------------------------------------------------------
@@ -358,23 +386,30 @@
// -------------------------------------------------------------
// Get data element ID of data element
// -------------------------------------------------------------
-
+
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
- if ( dataElement == null )
- {
- inputMatcher.appendReplacement( sb, DATA_ELEMENT_DOES_NOT_EXIST );
- } else
- {
- inputMatcher.appendReplacement( sb, inputHTML );
- }
+ String displayValue = (dataElement == null) ? "value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : "value=\"[ " + dataElement.getName() + " ]\"";
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
+ : inputHTML + " " + displayValue;
+
+ String displayTitle = (dataElement == null ) ? "title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : "title=\"-- ID:" + dataElement.getId() + " - Name:" + dataElement.getShortName() + " - "
+ + " - Type:" + dataElement.getType() + "\"";
+ inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
+ : inputHTML + " " + displayTitle;
+
+ inputHTML = inputHTML + ">";
+
+ inputMatcher.appendReplacement( sb, inputHTML );
}
}
-
+
inputMatcher.appendTail( sb );
-
- return ( sb.toString().isEmpty() ) ? htmlCode : sb.toString();
+
+ return (sb.toString().isEmpty()) ? htmlCode : sb.toString();
}
private String populateCustomDataEntryForTextBox( String dataEntryFormCode,
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm 2011-06-23 05:53:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm 2011-06-23 08:27:07 +0000
@@ -138,12 +138,12 @@
</tr>
<tr>
<td>
- <b>$i18n.getString( "view_as" )</b><br>
+ <!-- <b>$i18n.getString( "view_as" )</b><br>
<select name="viewBySelector" id="viewBySelector" style="width:150px">
<option value="deid">$i18n.getString( "id" )</option>
<option value="dename">$i18n.getString( "name" )</option>
<option value="deshortname" selected>$i18n.getString( "short_name" )</option>
- </select>
+ </select> -->
<input type="button" value="Insert" id="insert" name="insert" onclick="insertDataElement( '#dataElementSelection', '$programStage.id')"/>
</td>
<td>
@@ -180,12 +180,12 @@
</tr>
<tr>
<td>
- <b>$i18n.getString( "view_as" )</b><br>
+ <!-- <b>$i18n.getString( "view_as" )</b><br>
<select name="viewBySelector" id="viewBySelector" style="width:150px">
<option value="deid">$i18n.getString( "id" )</option>
<option value="dename">$i18n.getString( "name" )</option>
<option value="deshortname" selected>$i18n.getString( "short_name" )</option>
- </select>
+ </select> -->
<input type="button" value="Insert" id="insert" name="insert" onclick="insertDataElement( '#otherProgramStageDataElements', byId('programStageIds').value )"/>
</td>
<td>