From 8d7edf3fe0ed5cf1d4775ac17e2d2b33c7fd0148 Mon Sep 17 00:00:00 2001 From: Garry Collum Date: Tue, 12 Jan 2021 16:21:58 -0500 Subject: [PATCH] LP1908763 Survey column sorting broken Fixes the sorting on the Administration > Local Administration > Surveys table. To test. 1. Create a 3 or more surveys and note that none of the columns sort. 2. Apply the patch. 3. Sorting should now work. Signed-off-by: Garry Collum Signed-off-by: Mike Risher Signed-off-by: Galen Charlton --- .../app/staff/admin/local/survey/survey.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/survey/survey.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/survey/survey.component.ts index 9865a4b3e6..7bec134b89 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/survey/survey.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/survey/survey.component.ts @@ -30,6 +30,8 @@ export class SurveyComponent implements OnInit { @ViewChild('endSurveyFailedString', { static: true }) endSurveyFailedString: StringComponent; @ViewChild('endSurveySuccessString', { static: true }) endSurveySuccessString: StringComponent; + @Input() sortField: string; + @Input() idlClass='asv'; @Input() dialogSize: 'sm' | 'lg' = 'lg'; constructor( @@ -44,7 +46,21 @@ export class SurveyComponent implements OnInit { ngOnInit() { this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { - return this.pcrud.retrieveAll('asv', {}); + const orderBy: any = {}; + if (sort.length) { + // Sort specified from grid + orderBy[this.idlClass] = sort[0].name + ' ' + sort[0].dir; + } else if (this.sortField) { + // Default sort field + orderBy[this.idlClass] = this.sortField; + } + + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + return this.pcrud.retrieveAll('asv', searchOps, {}); }; this.grid.onRowActivate.subscribe( -- 2.11.0