From 0b174af34294d10751e3ce06426e5651d6a0ba14 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 14 Aug 2020 14:49:24 -0400 Subject: [PATCH] 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 Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- Open-ILS/src/eg2/src/app/share/grid/grid.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 13e7167d86..c22289e798 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.ts @@ -400,6 +400,19 @@ export class GridColumnSet { this.columns.filter(c => c.required && !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; -- 2.11.0