← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16496: ER row numbers for individual cases + Calendars supported.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16496 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-08-25 11:59:48 +0200
message:
  ER row numbers for individual cases + Calendars supported.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/index.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/styles/style.css
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/index.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/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-reports/app/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/index.html	2014-04-22 18:47:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/index.html	2014-08-25 09:12:15 +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>
 
@@ -15,7 +16,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="scripts/core.js"></script>
 	<script src="scripts/app.js"></script>
 </body>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-08-22 12:51:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-08-25 09:41:33 +0000
@@ -3068,6 +3068,7 @@
             periodMode,
             onPeriodModeSelect,
             getDateLink,
+            onDateFieldRender,
 			startDate,
 			endDate,
             startEndDate,
@@ -3911,27 +3912,49 @@
             });
         };
 
-        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',
@@ -4313,13 +4336,13 @@
 		});
 
         onPeriodTypeSelect = function(value) {
-            var ptype = new PeriodType(),
+            var periodType = value,
+                generator = ns.core.init.periodGenerator,
+                periods = generator.filterFuturePeriodsExceptCurrent(generator.generateReversedPeriods(periodType, this.periodOffset));
 
-                periods = ptype.get(value).generatePeriods({
-                    offset: periodType.periodOffset,
-                    filterFuturePeriods: true,
-                    reversePeriods: true
-                });
+            for (var i = 0; i < periods.length; i++) {
+                periods[i].id = periods[i].iso;
+            }
 
             fixedPeriodAvailableStore.setIndex(periods);
             fixedPeriodAvailableStore.loadData(periods);
@@ -7061,13 +7084,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({
@@ -7075,6 +7132,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-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-07-13 08:38:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-08-25 09:41:33 +0000
@@ -2785,15 +2785,18 @@
 				var dimensionHeaders = xResponse.dimensionHeaders,
 					rows = xResponse.rows,
                     names = xResponse.metaData.names,
+                    pager = xResponse.metaData.pager,
+                    count = pager.page * pager.pageSize - pager.pageSize
 					tableCls = 'pivot',
 					html = '';
-
+                    
 				xResponse.sortableIdObjects = [];
 
 				tableCls += layout.displayDensity ? ' ' + layout.displayDensity : '';
 				tableCls += layout.fontSize ? ' ' + layout.fontSize : '';
 
 				html += '<table class="' + tableCls + '"><tr>';
+                html += '<td class="pivot-dim pivot-dim-subtotal">' + '#' + '</td>';                
 
 				// get header indexes
 				for (var i = 0, header, uuid; i < dimensionHeaders.length; i++) {
@@ -2814,6 +2817,7 @@
 				for (var i = 0, row; i < rows.length; i++) {
 					row = rows[i];
 					html += '<tr>';
+                    html += '<td class="pivot-value align-right">' + (count + (i + 1)) + '</td>';                    
 
 					for (var j = 0, str, header, name; j < dimensionHeaders.length; j++) {
 						header = dimensionHeaders[j];

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/styles/style.css	2014-07-08 11:18:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/app/styles/style.css	2014-08-25 09:12:15 +0000
@@ -169,14 +169,16 @@
 }
 
 .ns-form-item-label-top {
-	padding-left: 4px;
+	padding-left: 2px;
 	float: none;
 	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;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/index.html	2014-08-15 10:50:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/index.html	2014-08-25 09:12:15 +0000
@@ -6,7 +6,6 @@
 	<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="jquery.calendars.picker.dhis2.css"/>
 	<link rel="stylesheet" type="text/css" href="styles/style.css" />
 </head>
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2014-08-21 13:57:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2014-08-25 09:12:15 +0000
@@ -4530,6 +4530,8 @@
                 calendar: gis.init.calendar,
                 dateFormat: gis.init.dateFormat
             });
+
+            Ext.get(c.id).setStyle('z-index', 100000);
         };
 
         startDate = Ext.create('Ext.form.field.Text', {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/styles/style.css	2014-08-14 16:20:15 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/app/styles/style.css	2014-08-25 09:12:15 +0000
@@ -242,6 +242,15 @@
 
 
 /*----------------------------------------------------------------------------
+ * jQuery calendar
+ *--------------------------------------------------------------------------*/
+
+.calendars-popup {
+    z-index: 100000;
+}
+
+
+/*----------------------------------------------------------------------------
  * NS Accordion
  *--------------------------------------------------------------------------*/