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":%@}'
// "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);
}
});