From: Gil Moskowitz Date: Wed, 11 Jun 2014 15:37:57 +0000 (-0400) Subject: pass the desired attribute down to the datasource X-Git-Tag: v4.5.0-r1590-3~1^2~9^2~4 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=455db8348f1249a2af71aa6fea3de16766dc8541;p=xtuple pass the desired attribute down to the datasource --- diff --git a/lib/enyo-x/source/views/workspace.js b/lib/enyo-x/source/views/workspace.js index 93a9684e6..463f4e9eb 100644 --- a/lib/enyo-x/source/views/workspace.js +++ b/lib/enyo-x/source/views/workspace.js @@ -1059,12 +1059,12 @@ trailing:true, white:true, strict: false*/ return true; }, - // export the data for just one attr of the model displayed by the workspace + // export just one attribute of the model displayed by the workspace openExportTab: function (routeName, recordType, id, attr) { console.log('workspace exportAttr ' + recordType + '/' + attr + '(' + id + ')'); - var query = { parameters: [{ attribute: "uuid", value: id }] }; - // TODO: limit the data treated to just attribute: attr - + var query = { parameters: [{ attribute: "uuid", value: id }] + , details: { attr: attr } + }; // sending the locale information back over the wire saves a call to the db window.open(XT.getOrganizationPath() + '/%@?details={"nameSpace":"%@","type":"%@","query":%@,"culture":%@,"print":%@}' diff --git a/node-datasource/routes/export.js b/node-datasource/routes/export.js index d0edc6f2a..80269c2bf 100644 --- a/node-datasource/routes/export.js +++ b/node-datasource/routes/export.js @@ -161,8 +161,19 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ // "export" will have to do. } - resultAsCsv = jsonToCsv(result.data.data); - res.attachment(filename + ".csv"); + try { + var attr = requestDetails.query + && requestDetails.query.details + && requestDetails.query.details.attr; + if (attr) { + resultAsCsv = jsonToCsv(result.data.data[0][attr]); + } else { + resultAsCsv = jsonToCsv(result.data.data); + } + res.attachment(filename + ".csv"); + } catch (error) { + resultAsCsv = jsonToCsv(error); + } res.send(resultAsCsv); } });