},
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();
},
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() +
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
}
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 {
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());