From 565feb87740dcc693be50f8dbde4887e4ebdc79f Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Wed, 8 Apr 2015 16:05:56 -0400 Subject: Move fetchTemplateData back into OKAdminView --- app/node_modules/okutil/index.js | 39 --------------------------------------- 1 file changed, 39 deletions(-) (limited to 'app/node_modules/okutil/index.js') 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 @@ -9,45 +9,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 */ -- cgit v1.2.3-70-g09d2