Skip to content

Commit

Permalink
filtered copying
Browse files Browse the repository at this point in the history
  • Loading branch information
aimaj-salesforce committed Oct 16, 2023
1 parent 91b7339 commit 3e87b92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addon/data-export-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export async function dataExportTest(test) {
// Autocomplete object
setQuery("select Id from OpportunityLi", "", "");
assertEquals("Objects suggestions:", vm.autocompleteResults.title);
assertEquals(["OpportunityLineItem"], getValues(vm.autocompleteResults.results));
assertEquals(["OpportunityLineItem", "OpportunityLineItemSplit"], getValues(vm.autocompleteResults.results));

// Autocomplete unknown object
setQuery("select Id from UnknownObj", "", "");
Expand Down
15 changes: 13 additions & 2 deletions addon/data-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class Model {
copyToClipboard(this.exportedData.csvSerialize(","));
}
copyAsJson() {
copyToClipboard(JSON.stringify(this.exportedData.filteredRecords, null, " "));
copyToClipboard(JSON.stringify(this.exportedData.getVisibleTable(), null, " "));
}
/**
* Notify React that we changed something, so it will rerender the view.
Expand Down Expand Up @@ -882,7 +882,7 @@ function RecordTable(vm) {
discoverColumns(record, "", row);
}
},
csvSerialize: separator => rt.filteredRecords.map(row => row.map(cell => "\"" + cellToString(cell).split("\"").join("\"\"") + "\"").join(separator)).join("\r\n"),
csvSerialize: separator => rt.getVisibleTable().map(row => row.map(cell => "\"" + cellToString(cell).split("\"").join("\"\"") + "\"").join(separator)).join("\r\n"),
updateVisibility() {
let filter = vm.resultsFilter;
let previousFilterResult = rt.filteredRecords.length;
Expand All @@ -899,6 +899,17 @@ function RecordTable(vm) {
} else if (!filter && previousFilterResult != 0) {
vm.exportStatus = "Exported " + rt.table.length + " record(s).";
}
},
getVisibleTable() {
if (vm.resultsFilter) {
let filteredTable = [];
for (let i = 0; i < rt.table.length; i++) {
if (rt.rowVisibilities[i])
filteredTable.push(rt.table[i]);
}
return filteredTable;
}
return rt.table;
}
};
return rt;
Expand Down

0 comments on commit 3e87b92

Please sign in to comment.