web/admin: select all password stage backends by default

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-08-23 17:54:19 +02:00
parent 1b8750e13b
commit 5face5410f
4 changed files with 21 additions and 7 deletions

View File

@ -156,11 +156,20 @@ export class IdentificationStageForm extends ModelForm<IdentificationStage, stri
.sourcesAllList({})
.then((sources) => {
return sources.results.map((source) => {
const selected = Array.from(
let selected = Array.from(
this.instance?.sources || [],
).some((su) => {
return su == source.pk;
});
// Creating a new instance, auto-select built-in source
// Only when no other sources exist
if (
!this.instance &&
source.component === "" &&
sources.results.length < 2
) {
selected = true;
}
return html`<option
value=${ifDefined(source.pk)}
?selected=${selected}

View File

@ -46,8 +46,11 @@ export class PasswordStageForm extends ModelForm<PasswordStage, string> {
};
isBackendSelected(field: BackendsEnum): boolean {
if (!this.instance) {
return true;
}
return (
(this.instance?.backends || []).filter((isField) => {
this.instance.backends.filter((isField) => {
return field === isField;
}).length > 0
);