From: Bill Erickson Date: Fri, 14 Aug 2020 18:49:24 +0000 (-0400) Subject: LP1891699 Ang grid column picker sorting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7555e04cf195baff5956a2dba68e4e38b751548d;p=Evergreen.git LP1891699 Ang grid column picker sorting Angular grid column picker displays colums in the following order: 1. Visible colums first, sorted alphabetically. 2. Non-visible columns second, sorted alphabetically. Signed-off-by: Bill Erickson Signed-off-by: Mike Risher Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html index eb701ce233..14607b7c5f 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html @@ -140,7 +140,8 @@ + (click)="col.visible=!col.visible" + *ngFor="let col of gridContext.columnSet.sortForColPicker()"> {{col.label}} diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.ts index c45acb39f8..72c09478b9 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -274,6 +274,19 @@ export class GridColumnSet { return this.columns.filter(c => c.visible); } + // Sorted visible columns followed by sorted non-visible columns. + // Note we don't sort this.columns directly as it would impact + // grid column display ordering. + sortForColPicker(): GridColumn[] { + const visible = this.columns.filter(c => c.visible); + const invisible = this.columns.filter(c => !c.visible); + + visible.sort((a, b) => a.label < b.label ? -1 : 1); + invisible.sort((a, b) => a.label < b.label ? -1 : 1); + + return visible.concat(invisible); + } + insertBefore(source: GridColumn, target: GridColumn) { let targetIdx = -1; let sourceIdx = -1;