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 { serializeForm(form: IronFormElement): T {
const elements = form._getSubmittableElements(); const elements = form._getSubmittableElements();
const json: { [key: string]: unknown } = {}; const json: { [key: string]: unknown } = {};
@ -69,7 +73,7 @@ export class Form<T> extends LitElement {
return this.send(data).then((r) => { return this.send(data).then((r) => {
showMessage({ showMessage({
level: MessageLevel.success, level: MessageLevel.success,
message: this.successMessage message: this.getSuccessMessage()
}); });
return r; return r;
}).catch((ex: Response) => { }).catch((ex: Response) => {

View File

@ -16,7 +16,13 @@ export class GroupForm extends Form<Group> {
@property({attribute: false}) @property({attribute: false})
group?: Group; 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> => { send = (data: Group): Promise<Group> => {
if (this.group) { if (this.group) {