diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 6ac112d..49f56df 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -1181,12 +1181,23 @@ class Localuser { if (_.message) { alert(_.errors.name._errors[0].message); } else { + loading.hide(); full.hide(); } }); }); form.addFileInput(I18n.getTranslation("guild.icon:"), "icon", {files: "one"}); form.addTextInput(I18n.getTranslation("guild.name:"), "name", {required: true}); + const loading = new Dialog(""); + loading.float.options.addTitle(I18n.guild.creating()); + form.onFormError = () => { + loading.hide(); + full.show(); + }; + form.addPreprocessor(() => { + loading.show(); + full.hide(); + }); } full.show(); } diff --git a/src/webpage/settings.ts b/src/webpage/settings.ts index f20f0b5..af4db84 100644 --- a/src/webpage/settings.ts +++ b/src/webpage/settings.ts @@ -1219,6 +1219,7 @@ class Form implements OptionsElement { addPreprocessor(func: (obj: Object) => void) { this.preprocessor = func; } + onFormError = (f: FormError) => {}; async submit() { if (this.options.subOptions) { this.options.subOptions.submit(); @@ -1233,6 +1234,7 @@ class Form implements OptionsElement { (build as any)[key] = thing(); } catch (e: any) { if (e instanceof FormError) { + this.onFormError(e); const elm = this.options.html.get(e.elem); if (elm) { const html = elm.deref(); @@ -1290,6 +1292,7 @@ class Form implements OptionsElement { this.preprocessor(build); } catch (e) { if (e instanceof FormError) { + this.onFormError(e); const elm = this.options.html.get(e.elem); if (elm) { const html = elm.deref(); @@ -1324,6 +1327,7 @@ class Form implements OptionsElement { } catch (e) { console.error(e); if (e instanceof FormError) { + this.onFormError(e); const elm = this.options.html.get(e.elem); if (elm) { const html = elm.deref(); @@ -1340,6 +1344,7 @@ class Form implements OptionsElement { await this.onSubmit(build, build); } catch (e) { if (e instanceof FormError) { + this.onFormError(e); const elm = this.options.html.get(e.elem); if (elm) { const html = elm.deref(); diff --git a/translations/en.json b/translations/en.json index a93165b..77a6fbb 100644 --- a/translations/en.json +++ b/translations/en.json @@ -150,6 +150,7 @@ "roleColors": "Disable role colors" }, "channel": { + "creating": "Creating channel", "name": "Channel", "copyId": "Copy channel id", "markRead": "Mark as read", @@ -236,6 +237,7 @@ "nevermind": "Nevermind", "submit": "submit", "guild": { + "creating": "Creating guild", "copyId": "Copy guild id", "markRead": "Mark as read", "notifications": "Notifications",