dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30648
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15573: minor bugfixes to calendar for add/edit orgUnit
------------------------------------------------------------
revno: 15573
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-06-06 14:39:37 +0200
message:
minor bugfixes to calendar for add/edit orgUnit
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.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
--
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-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java 2014-05-21 11:12:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java 2014-06-06 12:39:37 +0000
@@ -181,7 +181,8 @@
public DateUnit today()
{
DateTime dateTime = DateTime.now( ISOChronology.getInstance() );
- return fromIso( DateUnit.fromDateTime( dateTime ) );
+ DateUnit dateUnit = new DateUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), true );
+ return fromIso( dateUnit );
}
@Override
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java 2014-06-06 12:39:37 +0000
@@ -28,17 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.system.util.ValidationUtils.coordinateIsValid;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.attribute.comparator.AttributeSortOrderComparator;
+import org.hisp.dhis.calendar.CalendarService;
+import org.hisp.dhis.calendar.DateUnit;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -48,8 +43,15 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.system.util.AttributeUtils;
import org.hisp.dhis.system.util.ValidationUtils;
-
-import com.opensymphony.xwork2.Action;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.hisp.dhis.system.util.ValidationUtils.coordinateIsValid;
/**
* @author Torgeir Lorange Ostby
@@ -61,33 +63,20 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
private OrganisationUnitService organisationUnitService;
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
+ @Autowired
private OrganisationUnitGroupService organisationUnitGroupService;
- public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
- {
- this.organisationUnitGroupService = organisationUnitGroupService;
- }
-
+ @Autowired
private DataSetService dataSetService;
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
+ @Autowired
private AttributeService attributeService;
- public void setAttributeService( AttributeService attributeService )
- {
- this.attributeService = attributeService;
- }
+ @Autowired
+ private CalendarService calendarService;
// -------------------------------------------------------------------------
// Input & Output
@@ -148,7 +137,7 @@
{
return attributeValues;
}
-
+
private boolean point;
public boolean isPoint()
@@ -164,12 +153,26 @@
}
private String latitude;
-
+
public String getLatitude()
{
return latitude;
}
+ private String openingDate;
+
+ public String getOpeningDate()
+ {
+ return openingDate;
+ }
+
+ private String closedDate;
+
+ public String getClosedDate()
+ {
+ return closedDate;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -181,15 +184,15 @@
numberOfChildren = organisationUnit.getChildren().size();
- availableDataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
+ availableDataSets = new ArrayList<>( dataSetService.getAllDataSets() );
availableDataSets.removeAll( organisationUnit.getDataSets() );
- dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
+ dataSets = new ArrayList<>( organisationUnit.getDataSets() );
- groupSets = new ArrayList<OrganisationUnitGroupSet>(
+ groupSets = new ArrayList<>(
organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSetsWithMembers() );
- attributes = new ArrayList<Attribute>( attributeService.getOrganisationUnitAttributes() );
+ attributes = new ArrayList<>( attributeService.getOrganisationUnitAttributes() );
attributeValues = AttributeUtils.getAttributeValueMap( organisationUnit.getAttributeValues() );
@@ -205,7 +208,21 @@
point = organisationUnit.getCoordinates() == null || coordinateIsValid( organisationUnit.getCoordinates() );
longitude = ValidationUtils.getLongitude( organisationUnit.getCoordinates() );
latitude = ValidationUtils.getLatitude( organisationUnit.getCoordinates() );
-
+
+ if ( organisationUnit.getOpeningDate() != null )
+ {
+ DateUnit dateUnit = DateUnit.fromJdkDate( organisationUnit.getOpeningDate() );
+ dateUnit = calendarService.getSystemCalendar().fromIso( dateUnit );
+ openingDate = calendarService.getSystemCalendar().formattedDate( dateUnit );
+ }
+
+ if ( organisationUnit.getClosedDate() != null )
+ {
+ DateUnit dateUnit = DateUnit.fromJdkDate( organisationUnit.getClosedDate() );
+ dateUnit = calendarService.getSystemCalendar().fromIso( dateUnit );
+ closedDate = calendarService.getSystemCalendar().formattedDate( dateUnit );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java 2014-06-06 12:39:37 +0000
@@ -32,16 +32,17 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.attribute.comparator.AttributeSortOrderComparator;
+import org.hisp.dhis.calendar.CalendarService;
+import org.hisp.dhis.calendar.DateUnit;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.period.Cal;
+import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
/**
@@ -54,34 +55,25 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
private DataSetService dataSetService;
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
+ @Autowired
private OrganisationUnitGroupService organisationUnitGroupService;
- public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
- {
- this.organisationUnitGroupService = organisationUnitGroupService;
- }
-
+ @Autowired
private AttributeService attributeService;
- public void setAttributeService( AttributeService attributeService )
- {
- this.attributeService = attributeService;
- }
+ @Autowired
+ private CalendarService calendarService;
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
- private Date defaultDate;
+ private String defaultDate;
- public Date getDefaultDate()
+ public String getDefaultDate()
{
return defaultDate;
}
@@ -113,14 +105,15 @@
public String execute()
{
- defaultDate = new Cal().set( 1900, 1, 1 ).time();
-
- dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-
- groupSets = new ArrayList<OrganisationUnitGroupSet>(
+ DateUnit today = calendarService.getSystemCalendar().today();
+ defaultDate = calendarService.getSystemCalendar().formattedDate( today );
+
+ dataSets = new ArrayList<>( dataSetService.getAllDataSets() );
+
+ groupSets = new ArrayList<>(
organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSetsWithMembers() );
- attributes = new ArrayList<Attribute>( attributeService.getOrganisationUnitAttributes() );
+ attributes = new ArrayList<>( attributeService.getOrganisationUnitAttributes() );
Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2014-01-19 06:27:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2014-06-06 12:39:37 +0000
@@ -13,12 +13,7 @@
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunit.GetOrganisationUnitAction" class="org.hisp.dhis.oum.action.organisationunit.GetOrganisationUnitAction"
- scope="prototype">
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
- </bean>
+ scope="prototype" />
<bean id="org.hisp.dhis.oum.action.organisationunit.ValidateOrganisationUnitAction" class="org.hisp.dhis.oum.action.organisationunit.ValidateOrganisationUnitAction"
scope="prototype">
@@ -60,11 +55,7 @@
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunit.ShowAddOrganisationUnitFormAction" class="org.hisp.dhis.oum.action.organisationunit.ShowAddOrganisationUnitFormAction"
- scope="prototype">
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
- <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
- </bean>
+ scope="prototype" />
<!-- OrganisationUnitGroup -->
=== 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 2014-04-29 14:29:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm 2014-06-06 12:39:37 +0000
@@ -2,41 +2,40 @@
var previousName = '';
var adding_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "adding_the_org_unit_failed" ) , "'" )';
- jQuery(document).ready(function() {
- validation2('addOrganisationUnitForm', function(form) {
+ jQuery(document).ready(function() {
+ validation2('addOrganisationUnitForm', function( form ) {
$.ajax({
- url: '../dhis-web-commons/ouwt/getselected.action',
- dataType: 'json'
- } ).done(function(data) {
+ url: '../dhis-web-commons/ouwt/getselected.action',
+ dataType: 'json'
+ }).done(function( data ) {
console.log(data);
- if(data.selectedUnits.length == 0) {
- if ( confirm( '$i18n.getString( "create_new_root" )' ) ) {
- selectAllById( "dataSets" );
- form.submit();
- }
+ if( data.selectedUnits.length == 0 ) {
+ if( confirm('$i18n.getString( "create_new_root" )') ) {
+ selectAllById("dataSets");
+ form.submit();
+ }
} else {
- selectAllById( "dataSets" );
- form.submit();
+ selectAllById("dataSets");
+ form.submit();
}
});
- }, {
- 'beforeValidateHandler' : function()
- {
- #tblDynamicAttributesJavascript()
- },
- 'rules' : getValidationRules("organisationUnit")
- });
+ }, {
+ 'beforeValidateHandler': function() {
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules': getValidationRules("organisationUnit")
+ });
checkValueIsExistWarning("name", "validateOrganisationUnit.action");
checkValueIsExist("code", "validateOrganisationUnit.action");
- jQuery( "div[id=dynamicAttributesContainer] table tr td:first-child" ).attr( "style", "width: 120px" );
- jQuery( "div[id=dynamicAttributesContainer] table tr td:last-child *" ).attr( "style", "" );
+ jQuery("div[id=dynamicAttributesContainer] table tr td:first-child").attr("style", "width: 120px");
+ jQuery("div[id=dynamicAttributesContainer] table tr td:last-child *").attr("style", "");
jQuery("#name").focus();
dhis2.period.picker.createInstance('#openingDate');
- });
+ });
</script>
<h3>$i18n.getString( "create_new_org_unit" ) #openHelp( "ou_edit" )</h3>
@@ -64,7 +63,7 @@
</tr>
<tr>
<td><label for="openingDate">$i18n.getString( "opening_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="openingDate" name="openingDate" value="$format.formatDate( $defaultDate )"></td>
+ <td><input type="text" id="openingDate" name="openingDate" value="$defaultDate"></td>
<td></td>
</tr>
<tr>
=== 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 2014-05-05 08:33:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2014-06-06 12:39:37 +0000
@@ -1,28 +1,26 @@
<script type="text/javascript">
- jQuery( document ).ready( function()
- {
- validation2('updateOrganisationUnitForm', function(form) {
- selectAllById("dataSets");
- form.submit();
- }, {
- 'beforeValidateHandler' : function()
- {
- #tblDynamicAttributesJavascript()
- },
- 'rules' : getValidationRules("organisationUnit")
- });
-
- checkValueIsExistWarning( "name", "validateOrganisationUnit.action", { id : $organisationUnit.id } );
- checkValueIsExist( "code", "validateOrganisationUnit.action", { id : $organisationUnit.id } );
-
- dhis2.period.picker.createRangedInstance('#openingDate', '#closedDate', true);
-
- jQuery( "div[id=dynamicAttributesContainer] table tr td:first-child" ).attr( "style", "width: 120px" );
- jQuery( "div[id=dynamicAttributesContainer] table tr td:last-child *" ).attr( "style", "" );
- });
-
- var previousName = '$encoder.jsEscape( $organisationUnit.name, "'" )';
- var saving_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "saving_the_org_unit_failed" ) , "'" )';
+ jQuery(document).ready(function() {
+ validation2('updateOrganisationUnitForm', function( form ) {
+ selectAllById("dataSets");
+ form.submit();
+ }, {
+ 'beforeValidateHandler': function() {
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules': getValidationRules("organisationUnit")
+ });
+
+ checkValueIsExistWarning("name", "validateOrganisationUnit.action", { id: $organisationUnit.id });
+ checkValueIsExist("code", "validateOrganisationUnit.action", { id: $organisationUnit.id });
+
+ dhis2.period.picker.createRangedInstance('#openingDate', '#closedDate');
+
+ jQuery("div[id=dynamicAttributesContainer] table tr td:first-child").attr("style", "width: 120px");
+ jQuery("div[id=dynamicAttributesContainer] table tr td:last-child *").attr("style", "");
+ });
+
+ var previousName = '$encoder.jsEscape( $organisationUnit.name, "'" )';
+ var saving_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "saving_the_org_unit_failed" ) , "'" )';
</script>
<h3>$i18n.getString( "edit_org_unit" ) #openHelp( "ou_edit" )</h3>
@@ -55,12 +53,12 @@
</tr>
<tr>
<td><label for="openingDate">$i18n.getString( "opening_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="openingDate" name="openingDate" value="$!format.formatDate( $organisationUnit.openingDate )"></td>
+ <td><input type="text" id="openingDate" name="openingDate" value="$!openingDate"></td>
<td></td>
</tr>
<tr>
<td><label for="closedDate">$i18n.getString( "closed_date" )</label></td>
- <td><input type="text" id="closedDate" name="closedDate" value="$!format.formatDate( $organisationUnit.closedDate )"></td>
+ <td><input type="text" id="closedDate" name="closedDate" value="$!closedDate"></td>
</tr>
<tr>
<td><label for="active">$i18n.getString( "registers_data" )</label></td>