b985b042293c33331f867fe6a66e35bf7263b61f
[ccsdk/features.git] /
1 (function( app ) {
2
3         var data = app.ns("data");
4
5         data.ResultDataSourceInterface = data.DataSourceInterface.extend({
6                 results: function(res) {
7                         this._getSummary(res);
8                         this._getMeta(res);
9                         this._getData(res);
10                         this.sort = {};
11                         this.fire("data", this);
12                 },
13                 _getData: function(res) {
14                         var columns = this.columns = [];
15                         this.data = res.hits.hits.map(function(hit) {
16                                 var row = (function(path, spec, row) {
17                                         for(var prop in spec) {
18                                                 if(acx.isObject(spec[prop])) {
19                                                         arguments.callee(path.concat(prop), spec[prop], row);
20                                                 } else if(acx.isArray(spec[prop])) {
21                                                         if(spec[prop].length) {
22                                                                 arguments.callee(path.concat(prop), spec[prop][0], row)
23                                                         }
24                                                 } else {
25                                                         var dpath = path.concat(prop).join(".");
26                                                         if(! columns.contains(dpath)) {
27                                                                 columns.push(dpath);
28                                                         }
29                                                         row[dpath] = (spec[prop] || "null").toString();
30                                                 }
31                                         }
32                                         return row;
33                                 })([ hit._type ], hit, {});
34                                 row._source = hit;
35                                 return row;
36                         }, this);
37                 }
38         });
39
40 })( this.app );