diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-08 16:05:56 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-08 16:07:15 -0400 |
| commit | 565feb87740dcc693be50f8dbde4887e4ebdc79f (patch) | |
| tree | 28dae4359936c05ca7df20a7e2bb11c9490e6a0f /app/node_modules/okutil/index.js | |
| parent | 5d676437f64791b435d7554d9ec4f4628d0abcc3 (diff) | |
Move fetchTemplateData back into OKAdminView
Diffstat (limited to 'app/node_modules/okutil/index.js')
| -rw-r--r-- | app/node_modules/okutil/index.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/app/node_modules/okutil/index.js b/app/node_modules/okutil/index.js index 01041b6..3142ae1 100644 --- a/app/node_modules/okutil/index.js +++ b/app/node_modules/okutil/index.js @@ -10,45 +10,6 @@ var Q = require('q'); module.exports = { /** - * Takes a meta data query and an array of resource queries - * and returns a promise for an object merging all queried - * data, pluralizing keys where necessary. - * - * Lil bit convoluted, sorry. - */ - fetchTemplateData: function fetchTemplateData(meta, queries, options) { - return Q.promise(function(resolve, reject) { - return Q.all( - [meta.get()].concat(queries.map(function(query) { - return query.get(options); - }))) - .then(function(results) { - var metadata = results.shift(); - var normalized = results.reduce(function(cache, result, i) { - var resource = queries[i].resource; - var type = queries[i].type; - var plural = pluralize(type); - if (isarray(result)) { - result = result.map(function(data) { - // Inform template of ID in generic way - data.id = data[resource.idField]; - return data; - }); - } else { - // Inform template of ID in generic way - result.id = result[resource.idField]; - result = [result] - } - cache[plural] = cache[plural] || []; - cache[plural] = cache[plural].concat(result); - return cache; - }, {meta: metadata}); - resolve(normalized); - }).fail(reject); - }); - }, - - /** * Return a copy of the route with a trailing slash */ withTrailingSlash: function withTrailingSlash(route) { |
