web/admin: fix message when object is created

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-29 15:57:38 +02:00
parent 0804b5e6c5
commit fac8d53163
2 changed files with 12 additions and 2 deletions

View file

@ -41,6 +41,10 @@ export class Form<T> 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<T> extends LitElement {
return this.send(data).then((r) => {
showMessage({
level: MessageLevel.success,
message: this.successMessage
message: this.getSuccessMessage()
});
return r;
}).catch((ex: Response) => {

View file

@ -16,7 +16,13 @@ export class GroupForm extends Form<Group> {
@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<Group> => {
if (this.group) {