web/admin: only pre-select items when creating a new object

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-20 20:32:47 +02:00
parent 76131e40ec
commit 7ccf8bcdc8
5 changed files with 8 additions and 8 deletions

View File

@ -196,7 +196,7 @@ export class OAuthSourceForm extends Form<OAuthSource> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.source?.authenticationFlow === flow.pk;
if (!this.source?.authenticationFlow && flow.slug === "default-source-authentication") {
if (!this.source?.pk && !this.source?.authenticationFlow && flow.slug === "default-source-authentication") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;
@ -216,7 +216,7 @@ export class OAuthSourceForm extends Form<OAuthSource> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.source?.enrollmentFlow === flow.pk;
if (!this.source?.enrollmentFlow && flow.slug === "default-source-enrollment") {
if (!this.source?.pk && !this.source?.enrollmentFlow && flow.slug === "default-source-enrollment") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;

View File

@ -227,7 +227,7 @@ export class SAMLSourceForm extends Form<SAMLSource> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.source?.preAuthenticationFlow === flow.pk;
if (!this.source?.preAuthenticationFlow && flow.slug === "default-source-pre-authentication") {
if (!this.source?.pk && !this.source?.preAuthenticationFlow && flow.slug === "default-source-pre-authentication") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;
@ -247,7 +247,7 @@ export class SAMLSourceForm extends Form<SAMLSource> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.source?.authenticationFlow === flow.pk;
if (!this.source?.authenticationFlow && flow.slug === "default-source-authentication") {
if (!this.source?.pk && !this.source?.authenticationFlow && flow.slug === "default-source-authentication") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;
@ -267,7 +267,7 @@ export class SAMLSourceForm extends Form<SAMLSource> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.source?.enrollmentFlow === flow.pk;
if (!this.source?.enrollmentFlow && flow.slug === "default-source-enrollment") {
if (!this.source?.pk && !this.source?.enrollmentFlow && flow.slug === "default-source-enrollment") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;

View File

@ -78,7 +78,7 @@ export class AuthenticatorStaticStageForm extends Form<AuthenticatorStaticStage>
}).then(flows => {
return flows.results.map(flow => {
let selected = this.stage?.configureFlow === flow.pk;
if (!this.stage?.configureFlow && flow.slug === "default-otp-time-configure") {
if (!this.stage?.pk && !this.stage?.configureFlow && flow.slug === "default-otp-time-configure") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;

View File

@ -84,7 +84,7 @@ export class AuthenticatorTOTPStageForm extends Form<AuthenticatorTOTPStage> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.stage?.configureFlow === flow.pk;
if (!this.stage?.configureFlow && flow.slug === "default-otp-time-configure") {
if (!this.stage?.pk && !this.stage?.configureFlow && flow.slug === "default-otp-time-configure") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;

View File

@ -94,7 +94,7 @@ export class PasswordStageForm extends Form<PasswordStage> {
}).then(flows => {
return flows.results.map(flow => {
let selected = this.stage?.configureFlow === flow.pk;
if (!this.stage?.configureFlow && flow.slug === "default-password-change") {
if (!this.stage?.pk && !this.stage?.configureFlow && flow.slug === "default-password-change") {
selected = true;
}
return html`<option value=${ifDefined(flow.pk)} ?selected=${selected}>${flow.name} (${flow.slug})</option>`;