dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21173
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9949: Allow to remove long/lat of events.
------------------------------------------------------------
revno: 9949
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-03-02 13:07:36 +0700
message:
Allow to remove long/lat of events.
added:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveCoordinatesEventAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/save.png
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.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
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveCoordinatesEventAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveCoordinatesEventAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveCoordinatesEventAction.java 2013-03-02 06:07:36 +0000
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.caseentry;
+
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.system.util.ValidationUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version SaveCoordinatesEventAction.java 7:39:48 PM Mar 1, 2013 $
+ */
+public class SaveCoordinatesEventAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ // --------------------------------------------------------------------------
+ // Input/Output
+ // --------------------------------------------------------------------------
+
+ private Integer programStageInstanceId;
+
+ public void setProgramStageInstanceId( Integer programStageInstanceId )
+ {
+ this.programStageInstanceId = programStageInstanceId;
+ }
+
+ private String longitude;
+
+ public void setLongitude( String longitude )
+ {
+ this.longitude = longitude;
+ }
+
+ private String latitude;
+
+ public void setLatitude( String latitude )
+ {
+ this.latitude = latitude;
+ }
+
+ // --------------------------------------------------------------------------
+ // Action implementation
+ // --------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ longitude = (longitude == null || longitude.isEmpty() ) ? null : longitude;
+ latitude = (latitude == null || latitude.isEmpty() ) ? null : latitude;
+
+ // ---------------------------------------------------------------------
+ // Set coordinates and feature type to point if valid
+ // ---------------------------------------------------------------------
+
+ ProgramStageInstance programStageInstance = programStageInstanceService
+ .getProgramStageInstance( programStageInstanceId );
+
+ if ( longitude != null && latitude != null )
+ {
+ String coordinates = ValidationUtils.getCoordinate( longitude, latitude );
+
+ if ( ValidationUtils.coordinateIsValid( coordinates ) )
+ {
+ programStageInstance.setCoordinates( coordinates );
+ }
+ }
+ else
+ {
+ programStageInstance.setCoordinates( null );
+ }
+
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-03-02 05:09:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-03-02 06:07:36 +0000
@@ -566,4 +566,5 @@
enter_a_value_less_than_or_equal_to_90 = Please enter a value less than or equal to 90.
enter_a_value_greater_than_or_equal_to_nagetive_90 = Please enter a value greater than or equal to -90.
enter_values_for_longitude_and_latitude_fields = Please enter values for both longitude and latitude fields
-enter_a_valid_number = Please enter a valid number.
\ No newline at end of file
+enter_a_valid_number = Please enter a valid number.
+enter_a_number = Enter a number
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm 2013-03-02 05:09:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm 2013-03-02 06:07:36 +0000
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# 2.11-SNAPSHOT V22
+# 2.11-SNAPSHOT V23
NETWORK:
*
CACHE:
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2013-03-02 05:09:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2013-03-02 06:07:36 +0000
@@ -37,8 +37,10 @@
<th class='coordinates1'><label for="longitude">$i18n.getString( "longitude" )</label></th>
<th class='coordinates2'><input type="text" class='criteria' id="longitude" name="longitude" value="$!{longitude}" class="{validate:{number:true,min:-180,max:180}}" placeholder='$i18n.getString("enter_a_number")' ></th>
<th class='coordinates1'><label for="latitude">$i18n.getString( "latitude" )</label></th>
- <th class='coordinates2'><input type="text" class='criteria' id="latitude" name="latitude" value="$!{latitude}" class="{validate:{number:true,min:-90,max:90}}" placeholder='$i18n.getString("enter_a_number")' ></th>
- <th><input type='button' value='$i18n.getString("save")' class='normal-button' onclick='saveCoordinatesEvent($!programStageInstance.id);' /></th>
+ <th class='coordinates2'>
+ <input type="text" class='criteria' id="latitude" name="latitude" value="$!{latitude}" class="{validate:{number:true,min:-90,max:90}}" placeholder='$i18n.getString("enter_a_number")' >
+ <img style='cursor:pointer' src='images/save.png' title='$i18n.getString("save")' onclick='saveCoordinatesEvent($!programStageInstance.id);' />
+ </th>
</tr>
</table>
#end
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/save.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/save.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/images/save.png 2013-03-02 06:07:36 +0000 differ
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-03-02 05:09:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-03-02 06:07:36 +0000
@@ -1921,7 +1921,10 @@
var latitude = jQuery.trim(getFieldValue('latitude'));
var isValid = true;
- if(longitude=='' || latitude==''){
+ if(longitude=='' && latitude==''){
+ isValid = true;
+ }
+ else if(longitude=='' || latitude==''){
alert(i18n_enter_values_for_longitude_and_latitude_fields);
isValid = false;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2013-03-02 05:09:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2013-03-02 06:07:36 +0000
@@ -40,7 +40,6 @@
</th>
<th class='coordinates1'><label for="dueDate">$i18n.getString( "due_date" ) </label></th>
<th class='coordinates2'><input type="text" id="dueDate" name="dueDate" class='criteria' value="$!format.formatDate( $programStageInstance.dueDate )" readonly > </th>
- <th></th>
</tr>
</table>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm 2013-03-02 05:09:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm 2013-03-02 06:07:36 +0000
@@ -46,7 +46,6 @@
</script>
<th class='coordinates1' id="dueDateLbl"><label for="dueDate"> $i18n.getString( "due_date" )</label> </th>
<th class='coordinates2' id="dueDateField"><input type="text" class='criteria' id="dueDate" name="dueDate" value="$!format.formatDate( $programStageInstance.dueDate )" disabled="disabled"> </th>
- <th></th>
</tr>
</table>
#end