← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15092: UI for setting date format, adds two basic date formats, yyyy-MM-dd, dd-MM-yyyy

 

------------------------------------------------------------
revno: 15092
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-29 15:55:17 +0545
message:
  UI for setting date format, adds two basic date formats, yyyy-MM-dd, dd-MM-yyyy
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.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/CalendarService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java	2014-04-29 07:28:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/CalendarService.java	2014-04-29 10:10:17 +0000
@@ -44,6 +44,12 @@
     List<Calendar> getAllCalendars();
 
     /**
+     * Gets all available date formats as list.
+     * @return All available date formats
+     */
+    List<DateFormat> getAllDateFormats();
+
+    /**
      * Gets the currently selected system calendar.
      * @return System calendar
      */

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java	2014-04-29 07:28:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/calendar/DefaultCalendarService.java	2014-04-29 10:10:17 +0000
@@ -54,6 +54,11 @@
 
     private Map<String, Calendar> calendarMap = Maps.newHashMap();
 
+    private List<DateFormat> dateFormats = Lists.newArrayList(
+        new DateFormat( "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-mm-dd" ),
+        new DateFormat( "dd-MM-yyyy", "dd-MM-yyyy", "dd-MM-yyyy", "dd-mm-yyyy" )
+    );
+
     @PostConstruct
     public void init()
     {
@@ -72,6 +77,12 @@
     }
 
     @Override
+    public List<DateFormat> getAllDateFormats()
+    {
+        return dateFormats;
+    }
+
+    @Override
     public Calendar getSystemCalendar()
     {
         String calendarKey = (String) settingManager.getSystemSetting( SystemSettingManager.KEY_CALENDAR, SystemSettingManager.DEFAULT_CALENDAR );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java	2014-04-29 07:28:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java	2014-04-29 10:10:17 +0000
@@ -31,6 +31,7 @@
 import com.opensymphony.xwork2.Action;
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.CalendarService;
+import org.hisp.dhis.calendar.DateFormat;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.configuration.Configuration;
 import org.hisp.dhis.configuration.ConfigurationService;
@@ -170,6 +171,11 @@
         return calendarService.getAllCalendars();
     }
 
+    public List<DateFormat> getDateFormats()
+    {
+        return calendarService.getAllDateFormats();
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java	2014-04-29 10:10:17 +0000
@@ -175,6 +175,13 @@
         this.calendar = calendar;
     }
 
+    private String dateFormat;
+
+    public void setDateFormat( String dateFormat )
+    {
+        this.dateFormat = dateFormat;
+    }
+
     private String message;
 
     public String getMessage()
@@ -196,6 +203,7 @@
     public String execute()
     {
         systemSettingManager.saveSystemSetting( KEY_CALENDAR, calendar );
+        systemSettingManager.saveSystemSetting( KEY_DATE_FORMAT, dateFormat );
         systemSettingManager.saveSystemSetting( KEY_CACHE_STRATEGY, cacheStrategy );
         systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, omitIndicatorsZeroNumeratorDataMart );
         systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2014-04-29 10:10:17 +0000
@@ -64,6 +64,7 @@
 system_overview=System overview
 cache_strategy=Cache strategy
 calendar=Calendar
+date_format=Date Format
 no_cache=No cache
 cache_until_6am_tomorrow=Cache until 6 AM tomorrow
 cache_for_two_weeks=Cache for two weeks

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm	2014-04-29 10:10:17 +0000
@@ -4,6 +4,7 @@
       jQuery.postUTF8('setSystemGeneralSettings.action', {
         cacheStrategy: getFieldValue('cacheStrategy'),
         calendar: getFieldValue('calendar'),
+        dateFormat: getFieldValue('dateFormat'),
         infrastructuralDataElements: getFieldValue('infrastructuralDataElements'),
         infrastructuralPeriodType: getFieldValue('infrastructuralPeriodType'),
         feedbackRecipients: getFieldValue('feedbackRecipients'),
@@ -44,6 +45,16 @@
 </select>
 </div>
 
+<div class="settingLabel">$i18n.getString( "date_format" )</div>
+
+<div class="setting">
+<select id="dateFormat" name="dateFormat">
+#foreach( $dateFormat in $dateFormats )
+  <option value="$dateFormat.name()" #if( $keyDateFormat == $dateFormat.name() )selected="selected"#end>$i18n.getString( $dateFormat.name() )</option>
+#end
+</select>
+</div>
+
 <div class="settingLabel">$i18n.getString( "infrastructural_data_elements" )</div>
 
 <div class="setting">
@@ -90,7 +101,7 @@
 
 <div class="settingLabel">$i18n.getString( "data_analysis_factor" )</div>
 <div class="setting">
-	<input type="text" id="factorDeviation" name="factorDeviation" value="$!factorDeviation"/>	
+	<input type="text" id="factorDeviation" name="factorDeviation" value="$!factorDeviation"/>
 </div>
 
 <div class="settingLabel">$i18n.getString( "phone_number_area_code" )</div>