From fac8d531636750a2209f7d568b5b241ce79e777e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 29 Mar 2021 15:57:38 +0200 Subject: [PATCH] web/admin: fix message when object is created Signed-off-by: Jens Langhammer --- web/src/elements/forms/Form.ts | 6 +++++- web/src/pages/groups/GroupForm.ts | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/web/src/elements/forms/Form.ts b/web/src/elements/forms/Form.ts index bb7689e7e..56b63c581 100644 --- a/web/src/elements/forms/Form.ts +++ b/web/src/elements/forms/Form.ts @@ -41,6 +41,10 @@ export class Form extends LitElement { `]; } + getSuccessMessage(): string { + return this.successMessage; + } + serializeForm(form: IronFormElement): T { const elements = form._getSubmittableElements(); const json: { [key: string]: unknown } = {}; @@ -69,7 +73,7 @@ export class Form extends LitElement { return this.send(data).then((r) => { showMessage({ level: MessageLevel.success, - message: this.successMessage + message: this.getSuccessMessage() }); return r; }).catch((ex: Response) => { diff --git a/web/src/pages/groups/GroupForm.ts b/web/src/pages/groups/GroupForm.ts index aa3c1adf6..57c46c36d 100644 --- a/web/src/pages/groups/GroupForm.ts +++ b/web/src/pages/groups/GroupForm.ts @@ -16,7 +16,13 @@ export class GroupForm extends Form { @property({attribute: false}) group?: Group; - successMessage = gettext("Successfully updated group"); + getSuccessMessage(): string { + if (this.group) { + return gettext("Successfully updated group"); + } else { + return gettext("Successfully created group"); + } + } send = (data: Group): Promise => { if (this.group) {