dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09230
[Branch ~dhis2-devs-core/dhis2/2.0.5] Rev 2107: Fixed bug: Name apostrophes breaking GIS + Fixed bug: Orgunits losing coordinates when edited + F...
------------------------------------------------------------
revno: 2107
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: 2.0.5
timestamp: Fri 2010-12-17 12:04:09 +0100
message:
Fixed bug: Name apostrophes breaking GIS + Fixed bug: Orgunits losing coordinates when edited + Feature type stored when adding/updating orgunits.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/featureType.js
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm
--
lp:~dhis2-devs-core/dhis2/2.0.5
https://code.launchpad.net/~dhis2-devs-core/dhis2/2.0.5
Your team DHIS 2 developers is subscribed to branch lp:~dhis2-devs-core/dhis2/2.0.5.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/2.0.5/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm 2010-08-17 07:26:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.vm 2010-12-17 11:04:09 +0000
@@ -133,5 +133,6 @@
,password: '$encoder.jsEscape($i18n.getString( 'password_must_contain_at_least_one_capital_letter_and_one_digit' ) , "'")'
,notOnlyDigits: '$encoder.jsEscape($i18n.getString('only_digits_are_not_allowed' ) , "'")'
,custome_regex: validatorFormat("{1}")
+ ,unrecognizedcoordinatestring: '$encoder.jsEscape($i18n.getString('unrecognized_coordinate_string' ) , "'")'
};
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java 2010-05-10 20:29:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/encoding/velocity/EncoderVelocityContext.java 2010-12-17 11:04:09 +0000
@@ -83,6 +83,15 @@
{
return StringEscapeUtils.escapeJavaScript( object );
}
+
+ /**
+ * Assumes " is used as quote char and not used inside values and does
+ * not escape '.
+ */
+ public String jsonEncode( String object )
+ {
+ return StringEscapeUtils.escapeJava( object );
+ }
@Deprecated
public String jsEscape( String object, String quoteChar )
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2010-12-09 12:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2010-12-17 11:04:09 +0000
@@ -310,6 +310,7 @@
please_fill_out_at_least_one_of_these_fields = Please fill out at least one of these fields.
password_must_contain_at_least_one_capital_letter_and_one_digit = Password must contain at least one capital letter and one digit
only_digits_are_not_allowed = Only digits are not allowed
+unrecognized_coordinate_string = Unrecognized coordinate string
please_enter_name = Please enter name!
please_select_period = Please select period!
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2010-05-26 09:57:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2010-12-17 11:04:09 +0000
@@ -116,7 +116,14 @@
{
this.coordinates = coordinates;
}
+
+ private String featureType;
+ public void setFeatureType( String featureType )
+ {
+ this.featureType = featureType;
+ }
+
private String url;
public void setUrl( String url )
@@ -145,6 +152,7 @@
code = nullIfEmpty( code );
comment = nullIfEmpty( comment );
coordinates = nullIfEmpty( coordinates );
+ featureType = nullIfEmpty( featureType );
url = nullIfEmpty( url );
Date date = format.parseDate( openingDate );
@@ -173,6 +181,7 @@
code, date, null, true, comment );
organisationUnit.setCoordinates( coordinates );
+ organisationUnit.setFeatureType( featureType );
organisationUnit.setUrl( url );
organisationUnit.setParent( parent );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2010-05-26 09:57:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2010-12-17 11:04:09 +0000
@@ -124,9 +124,16 @@
private String coordinates;
- public void setPolygonCoordinates( String polygonCoordinates )
- {
- this.coordinates = polygonCoordinates;
+ public void setCoordinates( String coordinates )
+ {
+ this.coordinates = coordinates;
+ }
+
+ private String featureType;
+
+ public void setFeatureType( String featureType )
+ {
+ this.featureType = featureType;
}
private String url;
@@ -146,6 +153,7 @@
code = nullIfEmpty( code );
comment = nullIfEmpty( comment );
coordinates = nullIfEmpty( coordinates );
+ featureType = nullIfEmpty( featureType );
url = nullIfEmpty( url );
Date oDate = format.parseDate( openingDate );
@@ -171,6 +179,7 @@
organisationUnit.setClosedDate( cDate );
organisationUnit.setComment( comment );
organisationUnit.setCoordinates( coordinates );
+ organisationUnit.setFeatureType( featureType );
organisationUnit.setUrl( url );
organisationUnitService.updateOrganisationUnit( organisationUnit );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties 2010-11-03 16:14:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/org/hisp/dhis/oum/i18n_module.properties 2010-12-17 11:04:09 +0000
@@ -121,4 +121,5 @@
intro_hierarchy_operations_menu = Move organisation units in the organisation unit tree. All children will be moved along with the unit.
filter_by_name = Filter by name
loading = Loading
-coordinates = Coordinates
\ No newline at end of file
+coordinates = Coordinates
+feature_type = Feature type
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2010-10-14 11:06:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2010-12-17 11:04:09 +0000
@@ -56,6 +56,7 @@
<param name="javascripts">
javascript/shortName.js,
javascript/organisationUnit.js,
+ javascript/featureType.js,
../dhis-web-commons/ouwt/ouwt.js
</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_ADD</param>
@@ -89,6 +90,7 @@
<param name="javascripts">
javascript/shortName.js,
javascript/organisationUnit.js,
+ javascript/featureType.js,
../dhis-web-commons/ouwt/ouwt.js
</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_UPDATE</param>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2010-12-09 10:39:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2010-12-17 11:04:09 +0000
@@ -8,7 +8,7 @@
<h3>$i18n.getString( "create_new_org_unit" ) #openHelp( "ou_edit" )</h3>
-<form id="addOrganisationUnitForm" action="addOrganisationUnit.action" method="post">
+<form id="addOrganisationUnitForm" name="addOrganisationUnitForm" action="addOrganisationUnit.action" method="post" onsubmit="return validateFeatureType(this.coordinates, this.featureType)">
<table>
<tr>
@@ -37,7 +37,11 @@
</tr>
<tr>
<td><label for="coordinates">$i18n.getString( "coordinates" )</label></td>
- <td><textarea id="coordinates" name="coordinates" style="width:20em; height:5em"></textarea></td>
+ <td><textarea id="coordinates" name="coordinates" style="width:20em; height:5em" onkeyup="setFeatureType(document.addOrganisationUnitForm.featureType, this.value)"></textarea></td>
+ </tr>
+ <tr>
+ <td><label for="featureType">$i18n.getString( "feature_type" )</label></td>
+ <td><input type="text" id="featureType" name="featureType" style="width:20em" readonly="readonly"/></td>
</tr>
<tr>
<td><label for="url">$i18n.getString( "url" )</label></td>
@@ -54,7 +58,6 @@
<span id="message"></span>
<script type="text/javascript">
-
var previousName = '';
var nameField = document.getElementById( 'name' );
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/featureType.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/featureType.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/featureType.js 2010-12-17 11:04:09 +0000
@@ -0,0 +1,50 @@
+
+// -----------------------------------------------------------------------------
+// Set feature type "Point" or "MultiPolygon" from coordinate string (no GeoJSON validation)
+// -----------------------------------------------------------------------------
+
+function setFeatureType( field, c )
+{
+ field.style.color = "#000000";
+ field.style.fontStyle = "normal";
+
+ if ( c.length >= 2 )
+ {
+ if ( c.substring( 0, 1 ) == "[" && c.substring( 1, 2 ) != "[" && c.substring( c.length - 1, c.length ) == "]" && c.substring( c.length - 2, c.length - 1 ) != "]" )
+ {
+ field.value = "Point";
+ return;
+ }
+
+ if ( c.length >= 8 )
+ {
+ if ( c.substring( 0, 4 ) == "[[[[" && c.substring( 4,5 ) != "[" && c.substring( c.length - 4, c.length ) == "]]]]" && c.substring( c.length - 5, c.length - 4) != "]" )
+ {
+ field.value = "MultiPolygon";
+ return;
+ }
+ }
+ }
+
+ if ( field.value )
+ {
+ field.value = "";
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Simple feature type / coordinates field validation
+// -----------------------------------------------------------------------------
+
+function validateFeatureType( cField, fField )
+{
+ if ( cField.value && ( !fField.value || fField.value == validationMessage.unrecognizedcoordinatestring ) )
+ {
+ fField.style.color = "#ff0000";
+ fField.style.fontStyle = "italic";
+ fField.value = validationMessage.unrecognizedcoordinatestring;
+ return false;
+ }
+
+ return true;
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2010-12-09 10:39:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2010-12-17 11:04:09 +0000
@@ -7,7 +7,7 @@
<h3>$i18n.getString( "edit_org_unit" ) #openHelp( "ou_edit" )</h3>
-<form id="updateOrganisationUnitForm" action="updateOrganisationUnit.action" method="post" onsubmit="return validateUpdateOrganisationUnit()">
+<form id="updateOrganisationUnitForm" name="updateOrganisationUnitForm" action="updateOrganisationUnit.action" method="post" onsubmit="return validateFeatureType(this.coordinates, this.featureType)">
<div>
<input type="hidden" id="id" name="id" value="$organisationUnit.id">
@@ -55,7 +55,11 @@
</tr>
<tr>
<td><label for="coordinates">$i18n.getString( "coordinates" )</label></td>
- <td><textarea id="coordinates" name="coordinates" style="width:20em; height:5em">$!encoder.htmlEncode( $organisationUnit.coordinates )</textarea></td>
+ <td><textarea id="coordinates" name="coordinates" style="width:20em; height:5em" onkeyup="setFeatureType(document.updateOrganisationUnitForm.featureType, this.value)">$!encoder.htmlEncode( $organisationUnit.coordinates )</textarea></td>
+ </tr>
+ <tr>
+ <td><label for="featureType">$i18n.getString( "feature_type" )</label></td>
+ <td><input type="text" id="featureType" name="featureType" value="$!encoder.htmlEncode( $organisationUnit.featureType )" style="width:20em" readonly="readonly"/></td>
</tr>
<tr>
<td><label for="url">$i18n.getString( "url" )</label></td>
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm 2010-10-13 14:59:09 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/pointShapefile.vm 2010-12-17 11:04:09 +0000
@@ -1,2 +1,2 @@
#set( $size = $object.size() )
-{"type":"FeatureCollection","features":[ #foreach ( $unit in $object ) {"type":"Feature","id":"${unit.id}","geometry":{"type":"Point","coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},"type":"Facility"}}#if( $velocityCount < $size ),#end #end ],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file
+{"type":"FeatureCollection","features":[ #foreach ( $unit in $object ) {"type":"Feature","id":"${unit.id}","geometry":{"type":"Point","coordinates":$!encoder.jsonEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsonEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},"type":"Facility"}}#if( $velocityCount < $size ),#end #end ],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm 2010-10-13 14:59:09 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/polygonShapefile.vm 2010-12-17 11:04:09 +0000
@@ -1,2 +1,2 @@
#set( $size = $object.size() )
-{"type":"FeatureCollection","features":[ #foreach ( $unit in $object ) {"type":"Feature","id":"districts.1","geometry":{"type":"MultiPolygon","coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()}}}#if( $velocityCount < $size ),#end #end],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file
+{"type":"FeatureCollection","features":[ #foreach ( $unit in $object ) {"type":"Feature","id":"districts.1","geometry":{"type":"MultiPolygon","coordinates":$!encoder.jsonEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsonEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()}}}#if( $velocityCount < $size ),#end #end],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file