1
0
Fork 0

Move zxx to its own group in select-languages component (#4664)

* Move zxx to its own group in select-languages component

* Fix lint

* Fix lint, again

* Apply requested changes
This commit is contained in:
Florian CUNY 2021-12-24 09:27:27 +01:00 committed by GitHub
parent 5354af75b3
commit 1e9c1b1b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -20,7 +20,7 @@ export class SelectLanguagesComponent implements ControlValueAccessor, OnInit {
@Input() maxLanguages: number
selectedLanguages: ItemSelectCheckboxValue[]
availableLanguages: SelectOptionsItem[] = []
availableLanguages: (SelectOptionsItem & { groupOrder: number })[] = []
allLanguagesGroup = $localize`All languages`
@ -38,10 +38,20 @@ export class SelectLanguagesComponent implements ControlValueAccessor, OnInit {
this.server.getVideoLanguages()
.subscribe(
languages => {
this.availableLanguages = [ { label: $localize`Unknown language`, id: '_unknown', group: this.allLanguagesGroup } ]
this.availableLanguages = [ {
label: $localize`Unknown language`,
id: '_unknown',
group: this.allLanguagesGroup,
groupOrder: 1
} ]
this.availableLanguages = this.availableLanguages
.concat(languages.map(l => ({ label: l.label, id: l.id, group: this.allLanguagesGroup })))
.concat(languages.map(l => {
if (l.id === 'zxx') return { label: l.label, id: l.id, group: $localize`Other`, groupOrder: 0 }
return { label: l.label, id: l.id, group: this.allLanguagesGroup, groupOrder: 1 }
}))
this.availableLanguages.sort((a, b) => a.groupOrder - b.groupOrder)
this.loaded = true
this.writeValue(this.toWrite)