← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14785: ER, show ou hierarchy.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14785 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-04-11 02:14:51 +0200
message:
  ER, show ou hierarchy.
modified:
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js


--
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-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-04-10 20:31:46 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-04-11 00:13:08 +0000
@@ -805,12 +805,16 @@
 					name = '';
 
 				if (service.layout.isHierarchy(layout, response, id)) {
-					var a = Ext.Array.clean(metaData.ouHierarchy[id].split('/'));
+					var a = metaData.names[id].split('/');
 					a.shift();
 
-					for (var i = 0; i < a.length; i++) {
-						name += (isHtml ? '<span class="text-weak">' : '') + metaData.names[a[i]] + (isHtml ? '</span>' : '') + ' / ';
+					for (var i = 0, isLast; i < a.length; i++) {
+						isLast = !!(i === a.length - 1);
+
+						name += (isHtml && !isLast ? '<span class="text-weak">' : '') + a[i] + (isHtml && !isLast ? '</span>' : '') + (!isLast ? ' / ' : '');
 					}
+
+					return name;
 				}
 
 				name += metaData.names[id];
@@ -1561,9 +1565,13 @@
                                 parsedId = parseFloat(id);
                                 displayId = Ext.isNumber(parsedId) ? parsedId : (names[id] || id);
 
+								// update names
                                 names[fullId] = (isMeta ? '' : header.column + ' ') + displayId;
+
+								// update rows
                                 response.rows[j][i] = fullId;
 
+								// number sorting
                                 objects.push({
                                     id: fullId,
                                     sortingId: parsedId
@@ -1574,6 +1582,8 @@
                             header.ids = Ext.Array.pluck(objects, 'id');
                         }
                         else {
+							var objects = [];
+
                             for (var j = 0, id, fullId, name, isHierarchy; j < response.rows.length; j++) {
                                 id = response.rows[j][i] || emptyId;
                                 fullId = header.name + id;
@@ -1586,11 +1596,23 @@
                                 name = isHierarchy ? service.layout.getHierarchyName(ouHierarchy, names, id) : (names[id] || id);
 
                                 names[fullId] = name;
+
+                                // update rows
                                 response.rows[j][i] = fullId;
-                                header.ids.push(fullId);
+
+                                // update ou hierarchy
+                                if (isHierarchy) {
+									ouHierarchy[fullId] = ouHierarchy[id];
+								}
+
+								objects.push({
+									id: fullId,
+									sortingId: name
+								});
                             }
 
-                            header.ids.sort();
+                            support.prototype.array.sort(objects, 'ASC', 'sortingId');
+                            header.ids = Ext.Array.pluck(objects, 'id');
                         }
                     }