From: Gil Moskowitz Date: Tue, 17 Jun 2014 20:47:36 +0000 (-0400) Subject: address code review comments and jshint the test X-Git-Tag: v4.5.0-r1590-3~1^2~9^2 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=403663af83bee4d91774b8b9f4a20f419047124a;p=xtuple address code review comments and jshint the test --- diff --git a/lib/enyo-x/source/views/grid_box.js b/lib/enyo-x/source/views/grid_box.js index 1d55fee57..127853a49 100644 --- a/lib/enyo-x/source/views/grid_box.js +++ b/lib/enyo-x/source/views/grid_box.js @@ -531,9 +531,7 @@ trailing:true, white:true, strict: false*/ }, exportAttr: function (inSender, inEvent) { var gridbox = inEvent.originator.parent.parent; - this.doExportAttr({ recordType: gridbox.parent.parent.model, - uuid: gridbox.parent.parent.value.attributes.uuid, - attr: gridbox.attr }); + this.doExportAttr({ attr: gridbox.attr }); }, refreshLists: function () { this.$.aboveGridList.refresh(); diff --git a/lib/enyo-x/source/views/workspace.js b/lib/enyo-x/source/views/workspace.js index 849c58a0a..862278f74 100644 --- a/lib/enyo-x/source/views/workspace.js +++ b/lib/enyo-x/source/views/workspace.js @@ -1055,14 +1055,17 @@ trailing:true, white:true, strict: false*/ }, exportAttr: function (inSender, inEvent) { - this.openExportTab('export', inEvent.recordType, inEvent.uuid, inEvent.attr); + this.openExportTab('export', inEvent.attr); return true; }, // export just one attribute of the model displayed by the workspace - openExportTab: function (routeName, recordType, id, attr) { - var query = { parameters: [{ attribute: "uuid", value: id }], - details: { attr: attr } + openExportTab: function (routeName, attr) { + var recordType = this.$.workspace.value.recordType, + id = this.$.workspace.value.id, + idAttr = this.$.workspace.value.idAttribute, + query = { parameters: [{ attribute: idAttr, value: id }], + details: { attr: attr, id: id } }; // sending the locale information back over the wire saves a call to the db window.open(XT.getOrganizationPath() + diff --git a/node-datasource/routes/export.js b/node-datasource/routes/export.js index 6312135af..8f598caca 100644 --- a/node-datasource/routes/export.js +++ b/node-datasource/routes/export.js @@ -151,8 +151,9 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ var resultAsCsv, filename = "export", type, - number = result.data && result.data.data && result.data.data[0] && - (result.data.data[0].number || result.data.data[0].name), + number = requestDetails.query && + requestDetails.query.details && + requestDetails.query.details.id, attr = requestDetails.query && requestDetails.query.details && requestDetails.query.details.attr @@ -169,6 +170,8 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */ } try { + /* export requests have 2 flavors: export a list of records (data.data) + or export a list of children of the current record ([0][attr]) */ if (attr) { resultAsCsv = jsonToCsv(result.data.data[0][attr]); } else { diff --git a/test/extensions/all/grid_box.js b/test/extensions/all/grid_box.js index 804009bb9..09e017d73 100644 --- a/test/extensions/all/grid_box.js +++ b/test/extensions/all/grid_box.js @@ -58,18 +58,18 @@ assert.equal(gridBox.liveModels().length, startingRows += 1); }); - it('Check export', function() { - function getExportButton(obj) { + it('Check export', function () { + var getExportButton = function (obj) { var result = null; - if ("$" in obj) { - result = obj.$.exportButton - || _.find(obj.$, getExportButton); + if (_.isObject(obj.$)) { + result = obj.$.exportButton || + _.find(obj.$, getExportButton); } return result; - } + }; - var gridBox = component - , exportButton = getExportButton(gridBox); + var gridBox = component, + exportButton = getExportButton(gridBox); assert.ok(exportButton); // TODO: need to populate before we can export // assert.doesNotThrow(exportButton.doTap());