dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32329
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16499: ER calendars + i18n fallback to 'en'.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16499 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-08-25 13:31:58 +0200
message:
ER calendars + i18n fallback to 'en'.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/core.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/styles/style.css
--
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-apps/src/main/webapp/dhis-web-event-visualizer/app/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/index.html 2014-06-06 09:05:03 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/index.html 2014-08-25 10:14:13 +0000
@@ -7,6 +7,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="../../dhis-web-commons/javascripts/ext/resources/css/ext-all-gray.css"/>
+ <link rel="stylesheet" type="text/css" href="../../dhis-web-commons/javascripts/jQuery/calendars/css/jquery.calendars.picker.css"/>
<link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
@@ -20,7 +21,14 @@
<script src="../../dhis-web-commons/javascripts/ext-ux/layout/component/form/MultiSelect.js"></script>
<script src="../../dhis-web-commons/javascripts/ext-ux/form/MultiSelect.js"></script>
- <script src="../../dhis-web-commons/javascripts/periodTypeNoDep.js"></script>
+ <script src="../../dhis-web-commons/javascripts/jQuery/jquery.min.js"></script>
+ <script src="../../dhis-web-commons/javascripts/jQuery/jquery.plugin.min.js"></script>
+ <script src="../../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.min.js"></script>
+ <script src="../../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.plus.min.js"></script>
+ <script src="../../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.picker.min.js"></script>
+ <script src="../../dhis-web-commons/javascripts/dhis2/dhis2.util.js"></script>
+ <script src="../../dhis-web-commons/javascripts/date.js"></script>
+
<script src="../../dhis-web-commons/javascripts/simpleRegression.js"></script>
<script src="scripts/core.js"></script>
<script src="scripts/app.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js 2014-08-22 13:47:10 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/app.js 2014-08-25 10:14:13 +0000
@@ -2711,6 +2711,7 @@
periodMode,
onPeriodModeSelect,
getDateLink,
+ onDateFieldRender,
startDate,
endDate,
startEndDate,
@@ -3549,28 +3550,50 @@
}
});
};
-
- startDate = Ext.create('Ext.form.field.Date', {
+
+ onDateFieldRender = function(c) {
+ $('#' + c.inputEl.id).calendarsPicker({
+ calendar: ns.core.init.calendar,
+ dateFormat: ns.core.init.dateFormat
+ });
+ };
+
+ startDate = Ext.create('Ext.form.field.Text', {
fieldLabel: 'Start date',
labelAlign: 'top',
- labelCls: 'ns-form-item-label-top',
+ labelCls: 'ns-form-item-label-top ns-form-item-label-top-padding',
labelSeparator: '',
- width: (accBaseWidth / 2) - 1,
- style: 'margin:4px 1px 7px 0; color: #333;',
- format: 'Y-m-d',
- value: new Date( (new Date()).setMonth( (new Date()).getMonth() - 3))
- });
-
- endDate = Ext.create('Ext.form.field.Date', {
+ columnWidth: 0.5,
+ height: 44,
+ value: function() {
+ var greg = $.calendars.instance('gregorian'),
+ date = greg.parseDate('yyyy-mm-dd', (new Date( (new Date()).setMonth( (new Date()).getMonth() - 3))).toJSON().slice(0,10));
+
+ date = ns.core.init.calendar.fromJD(date.toJD());
+ return ns.core.init.calendar.formatDate(ns.core.init.dateFormat, date);
+ }(),
+ listeners: {
+ render: function(c) {
+ onDateFieldRender(c);
+ }
+ }
+ });
+
+ endDate = Ext.create('Ext.form.field.Text', {
fieldLabel: 'End date',
labelAlign: 'top',
- labelCls: 'ns-form-item-label-top',
+ labelCls: 'ns-form-item-label-top ns-form-item-label-top-padding',
labelSeparator: '',
- width: (accBaseWidth / 2) - 1,
- style: 'margin:4px 1px 7px 0; color: #333;',
- format: 'Y-m-d',
- value: new Date()
- });
+ columnWidth: 0.5,
+ height: 44,
+ style: 'margin-left: 1px',
+ value: ns.core.init.calendar.today().toString(),
+ listeners: {
+ render: function(c) {
+ onDateFieldRender(c);
+ }
+ }
+ });
startEndDate = Ext.create('Ext.container.Container', {
cls: 'ns-container-default',
@@ -6702,13 +6725,47 @@
Ext.Ajax.request({
url: init.contextPath + '/api/system/info.json',
success: function(r) {
- init.contextPath = Ext.decode(r.responseText).contextPath || init.contextPath;
+ var info = Ext.decode(r.responseText);
+
+ // context path
+ init.contextPath = info.contextPath || init.contextPath;
+
+ // calendars
+ init.dateFormat = info.dateFormat || 'yyyy-mm-dd';
+
+ (function() {
+ var dhis2PeriodUrl = '../../dhis-web-commons/javascripts/dhis2/dhis2.period.js',
+ defaultCalendarId = 'gregorian',
+ calendarIdMap = {'iso8601': defaultCalendarId},
+ calendarId = calendarIdMap[info.calendar] || info.calendar || defaultCalendarId,
+ calendarIds = ['coptic', 'ethiopian', 'islamic', 'julian', 'nepali', 'thai'],
+ calendarScriptUrl,
+ createGenerator;
+
+ // calendar
+ createGenerator = function() {
+ init.calendar = $.calendars.instance(calendarId);
+ init.periodGenerator = new dhis2.period.PeriodGenerator(init.calendar, init.dateFormat);
+ };
+
+ if (Ext.Array.contains(calendarIds, calendarId)) {
+ calendarScriptUrl = '../../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.' + calendarId + '.min.js';
+
+ Ext.Loader.injectScriptElement(calendarScriptUrl, function() {
+ Ext.Loader.injectScriptElement(dhis2PeriodUrl, createGenerator);
+ });
+ }
+ else {
+ Ext.Loader.injectScriptElement(dhis2PeriodUrl, createGenerator);
+ }
+ }());
// user info, i18n
requests.push({
url: init.contextPath + '/api/me/user-account.json',
success: function(r) {
- init.keyUiLocale = Ext.decode(r.responseText).settings.keyUiLocale || 'en';
+ var defaultKeyUiLocale = 'en';
+ init.keyUiLocale = Ext.decode(r.responseText).settings.keyUiLocale || defaultKeyUiLocale;
// i18n
Ext.Ajax.request({
@@ -6716,6 +6773,30 @@
success: function(r) {
NS.i18n = Ext.decode(r.responseText);
fn();
+ },
+ failure: function() {
+ var failure = function() {
+ alert('No translations found for system locale (' + init.keyUiLocale + ') or default locale (' + defaultKeyUiLocale + ').');
+ };
+
+ if (init.keyUiLocale !== defaultKeyUiLocale) {
+ Ext.Ajax.request({
+ url: 'i18n/' + defaultKeyUiLocale + '.json',
+ success: function(r) {
+ console.log('No translations found for system locale (' + init.keyUiLocale + ').');
+ NS.i18n = Ext.decode(r.responseText);
+ },
+ failure: function() {
+ failure();
+ },
+ callback: function() {
+ fn();
+ }
+ });
+ }
+ else {
+ failure();
+ }
}
});
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/core.js 2014-08-10 22:54:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/scripts/core.js 2014-08-25 11:23:26 +0000
@@ -545,8 +545,8 @@
// dates
if (config.startDate && config.endDate) {
- layout.startDate = config.startDate;
- layout.endDate = config.endDate;
+ layout.startDate = config.startDate.substr(0,10);
+ layout.endDate = config.endDate.substr(0,10);
}
// properties
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/styles/style.css 2014-07-08 14:37:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/app/styles/style.css 2014-08-25 10:14:13 +0000
@@ -174,9 +174,11 @@
clear: none;
display: block;
margin-bottom: 2px !important;
- font-weight: bold;
color: #333;
}
+.ns-form-item-label-top-padding {
+ padding-top: 3px;
+}
.ns-container-default {
border: 0 none;