web/admin: fix Transport Form not loading mode correctly on edit

closes #1453

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-23 16:16:38 +02:00
parent 5df60e4d87
commit 40a62ac1e5
1 changed files with 9 additions and 9 deletions

View File

@ -20,8 +20,13 @@ import { first } from "../../utils";
@customElement("ak-event-transport-form") @customElement("ak-event-transport-form")
export class TransportForm extends ModelForm<NotificationTransport, string> { export class TransportForm extends ModelForm<NotificationTransport, string> {
loadInstance(pk: string): Promise<NotificationTransport> { loadInstance(pk: string): Promise<NotificationTransport> {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsRetrieve({ return new EventsApi(DEFAULT_CONFIG)
.eventsTransportsRetrieve({
uuid: pk, uuid: pk,
})
.then((transport) => {
this.onModeChange(transport.mode);
return transport;
}); });
} }
@ -72,12 +77,6 @@ export class TransportForm extends ModelForm<NotificationTransport, string> {
`; `;
} }
firstUpdated(): void {
if (this.instance) {
this.onModeChange(this.instance.mode);
}
}
onModeChange(mode: string): void { onModeChange(mode: string): void {
if ( if (
mode === NotificationTransportModeEnum.Webhook || mode === NotificationTransportModeEnum.Webhook ||
@ -114,6 +113,7 @@ export class TransportForm extends ModelForm<NotificationTransport, string> {
?hidden=${!this.showWebhook} ?hidden=${!this.showWebhook}
label=${t`Webhook URL`} label=${t`Webhook URL`}
name="webhookUrl" name="webhookUrl"
?required=${true}
> >
<input <input
type="text" type="text"