dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09220
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2388: Simple add/update orgunit feature type validation added + validation js centralized.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2388 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-16 14:30:55 +0100
message:
Simple add/update orgunit feature type validation added + validation js centralized.
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-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/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/javascript/organisationUnit.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.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-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-12-15 15:34:38 +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-16 13:29:08 +0000
@@ -49,7 +49,7 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private I18nFormat format;
public void setFormat( I18nFormat format )
=== 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-12-14 07:12:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2010-12-16 13:23:27 +0000
@@ -43,7 +43,7 @@
class="org.hisp.dhis.oum.action.organisationunit.PrepareAddOrganisationUnitAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm</param>
- <param name="javascripts">javascript/shortName.js,../dhis-web-commons/ouwt/ouwt.js</param>
+ <param name="javascripts">javascript/shortName.js,javascript/featureType.js,../dhis-web-commons/ouwt/ouwt.js</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_ADD</param>
</action>
@@ -72,7 +72,7 @@
class="org.hisp.dhis.oum.action.organisationunit.GetOrganisationUnitAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm</param>
- <param name="javascripts">javascript/shortName.js,../dhis-web-commons/ouwt/ouwt.js</param>
+ <param name="javascripts">javascript/shortName.js,javascript/featureType.js,../dhis-web-commons/ouwt/ouwt.js</param>
<param name="requiredAuthorities">F_ORGANISATIONUNIT_UPDATE</param>
</action>
=== 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-15 15:34:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2010-12-16 13:29:08 +0000
@@ -11,7 +11,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>
@@ -40,7 +40,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>
@@ -80,4 +84,5 @@
nameField.select();
nameField.focus();
var adding_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "adding_the_org_unit_failed" ) , "'" )';
-</script>
\ No newline at end of file
+
+</script>
=== 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-16 13:23:27 +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 ) == "]" )
+ {
+ field.value = "Point";
+ return;
+ }
+
+ if ( c.length >= 8 )
+ {
+ if ( c.substring( 0, 4 ) == "[[[[" && c.substring( c.length - 4, c.length ) == "]]]]")
+ {
+ 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.style.color = "#ff0000";
+ fField.style.fontStyle = "italic";
+ fField.value = "Unrecognized coordinate string!";
+ 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/javascript/organisationUnit.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js 2010-12-13 15:26:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js 2010-12-16 13:23:27 +0000
@@ -55,4 +55,4 @@
function removeOrganisationUnit( unitId, unitName )
{
removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeOrganisationUnit.action' );
-}
\ 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-15 15:34:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2010-12-16 13:29:08 +0000
@@ -21,7 +21,7 @@
<h3>$i18n.getString( "edit_org_unit" ) #openHelp( "ou_edit" )</h3>
-<form id="updateOrganisationUnitForm" action="updateOrganisationUnit.action" method="post">
+<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"/>
@@ -69,7 +69,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>
@@ -100,6 +104,8 @@
</form>
<script type="text/javascript">
+
var previousName = '$encoder.jsEscape( $organisationUnit.name, "'" )';
var saving_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "saving_the_org_unit_failed" ) , "'" )';
+
</script>