fixed profile order in the selector dialog - fixes #5537

This commit is contained in:
Eugene Pankov
2022-03-12 18:31:59 +01:00
parent fc4bbfcd5d
commit 2c00b9a4bc
5 changed files with 17 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import { firstBy } from 'thenby'
import { Component, Input, HostListener, ViewChildren, QueryList, ElementRef } from '@angular/core' // eslint-disable-line @typescript-eslint/no-unused-vars
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { SelectorOption } from '../api/selector'
@@ -52,8 +53,11 @@ export class SelectorModalComponent<T> {
onFilterChange (): void {
const f = this.filter.trim().toLowerCase()
if (!f) {
this.filteredOptions = this.options.slice()
.sort((a, b) => a.group?.localeCompare(b.group ?? '') ?? 0)
this.filteredOptions = this.options.slice().sort(
firstBy<SelectorOption<T>, number>(x => x.weight ?? 0)
.thenBy<SelectorOption<T>, string>(x => x.group ?? '')
.thenBy<SelectorOption<T>, string>(x => x.name)
)
.filter(x => !x.freeInputPattern)
} else {
const terms = f.split(' ')