web/admin: select service connection by default when only one exists

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-13 20:12:01 +02:00
parent bb8559ee18
commit c9dda17c68
1 changed files with 5 additions and 1 deletions

View File

@ -102,7 +102,11 @@ export class OutpostForm extends ModelForm<Outpost, string> {
ordering: "pk"
}).then(scs => {
return scs.results.map(sc => {
return html`<option value=${ifDefined(sc.pk)} ?selected=${this.instance?.serviceConnection === sc.pk}>
let selected = this.instance?.serviceConnection === sc.pk;
if (scs.results.length === 1 && !this.instance) {
selected = true;
}
return html`<option value=${ifDefined(sc.pk)} ?selected=${selected}>
${sc.name} (${sc.verboseName})
</option>`;
});