Skip to content

Commit

Permalink
Merge pull request #149 from GSA/feature/15_export_csv_filters
Browse files Browse the repository at this point in the history
Adjusting the CSV Download based on the table filtering
  • Loading branch information
BuckinghamAJ authored Nov 4, 2024
2 parents c8318a1 + b2a7d46 commit f407fa9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ <h1 class="srt-page-title srt-blue" style="padding-bottom: 5px;" role="heading"
</div>
<div class="solic-export-cursor">
<img tabindex="0" id="csvlogo" aria-label="export as csv" alt="export as csv"
src="../../../assets/downloadcsv.jpeg" style="float:left" (keydown.enter)="exportCSV({})"
(click)="exportCSV({})">
src="../../../assets/downloadcsv.jpeg" style="float:left" (keydown.enter)="exportCSV({}, gb.filters)"
(click)="exportCSV({}, gb.filters)">
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ export class SolicitationReportComponent extends BaseComponent implements OnInit
* Copied from the PrimeNG prototype and then modified
*
* @param options
* @param filters - Filter values associated with the soliciation p-table
*/
exportCSV (options) {
exportCSV (options, filters) {
const csvSeparator = ',';
let csv = '';

Expand All @@ -367,7 +368,14 @@ export class SolicitationReportComponent extends BaseComponent implements OnInit
}
}

const filter = {first: 0, rows: 1000};
let filter = {first: 0, rows: 1000, filters: {}};

// The filters parameter is passed from the p-table element with the template reference variable #gb.
// It contains the current filtering criteria applied to the table, allowing the export to include only the filtered data.
if (filters) {
filter.filters = filters;
}

const appendSolicitations = (solicitations) => {
document.body.style.cursor = 'wait';
for (const s of solicitations.predictions) {
Expand All @@ -388,7 +396,7 @@ export class SolicitationReportComponent extends BaseComponent implements OnInit
.subscribe(appendSolicitations);
}
};

this.solicitationService
.getFilteredSolicitations(filter)
.subscribe( appendSolicitations );
Expand Down

0 comments on commit f407fa9

Please sign in to comment.