← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20887: PT noext

 

------------------------------------------------------------
revno: 20887
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-28 15:56:41 +0100
message:
  PT noext
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core2.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-apps/src/main/webapp/dhis-web-pivot/scripts/core2.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core2.js	2015-10-28 13:50:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core2.js	2015-10-28 14:56:41 +0000
@@ -630,21 +630,64 @@
                 return this;
             };
         })();
+
+        // Header
+        (function() {
+            var Header = NS.Api.Header = function(config) {
+                var t = this;
+
+                config = NS.isObject(config) ? config : {};
+
+                // constructor
+                $.extend(this, config);
+
+                // uninitialized
+                t.index;
+            };
+        };
+
+        // Reponse
+        (function() {
+            var Response = NS.Api.Response = function(config) {
+                var t = this;
+
+                config = NS.isObject(config) ? config : {};
+
+                t.headers = config.headers;
+                t.metaData = config.metaData;
+                t.rows = config.rows;
+
+                // transient
+                t.nameHeaderMap = function() {
+                    for (var i = 0, map = {}; i < t.headers.length; i++) {
+                        map[t.headers[i].name] = t.headers[i];
+                    }
+
+                    return map;
+                })();
+
+                // uninitialized
+                t.idValueMap = {};
+
+                // Header: index
+                (function() {
+                    for (var i = 0; i < t.headers.length; i++) {
+                        t.headers[i].index = i;
+                    }
+                })();
+            };
+
+            Response.prototype.getHeaderByName = function(name) {
+                return this.nameHeaderMap[name];
+            };
+
+            Response.prototype.getHeaderIndexByName = function(name) {
+                return this.nameHeaderMap[name].index;
+            };
+
+            Response.prototype.getNameById = function(id) {
+                return this.metaData.names[id];
+            };
+        })();
     })();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 });