summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-04-13 21:31:40 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-04-13 21:32:33 +0200
commit0fb9d12078b07947f8df732564477bd3f8eabaea (patch)
treea44ea3fd15a3f589d2113c5c1b3f8974ebe9cad0
parent96c61e433a8be50d80da01f09143a6669c48aee7 (diff)
MlkLazychatSubmissionForm: Make Flow type checker happy.
Change-Id: I39ad254ea853e657b82069580e369ab701eafd81
-rw-r--r--src/main/resources/META-INF/resources/lazychat/MlkLazychatSubmissionForm.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main/resources/META-INF/resources/lazychat/MlkLazychatSubmissionForm.js b/src/main/resources/META-INF/resources/lazychat/MlkLazychatSubmissionForm.js
index 6cb3059..5b67cee 100644
--- a/src/main/resources/META-INF/resources/lazychat/MlkLazychatSubmissionForm.js
+++ b/src/main/resources/META-INF/resources/lazychat/MlkLazychatSubmissionForm.js
@@ -30,6 +30,7 @@ template.innerHTML = `
export class MlkLazychatSubmissionForm extends HTMLElement {
/*::
+ mainForm: HTMLFormElement;
textInput: HTMLTextAreaElement;
visibilityInput: HTMLInputElement;
loaded: boolean;
@@ -41,10 +42,13 @@ export class MlkLazychatSubmissionForm extends HTMLElement {
let shadow = this.attachShadow({mode: "open"});
shadow.appendChild(template.content.cloneNode(true));
+ this.mainForm =
+ cast(shadow.getElementById('main-form'));
this.textInput =
cast(shadow.getElementById('text-input'));
this.visibilityInput =
cast(shadow.getElementById('visibility-input'));
+
this.loaded = false;
}
@@ -52,8 +56,12 @@ export class MlkLazychatSubmissionForm extends HTMLElement {
return [];
}
- get editedId() {
- return this.getAttribute("edited-id");
+ get editedId() /*:number | null*/ {
+ let attr = this.getAttribute("edited-id");
+ if (attr === undefined || attr === null) {
+ return null;
+ }
+ return parseInt(attr);
}
get isEditor() {
@@ -61,10 +69,9 @@ export class MlkLazychatSubmissionForm extends HTMLElement {
}
connectedCallback() {
- if (this.isEditor) {
- let form = this.shadowRoot.getElementById("main-form");
- form.method = "post";
- form.action = `/lazychat/p/${this.editedId}/edit`;
+ if (this.editedId !== null) {
+ this.mainForm.method = "post";
+ this.mainForm.action = `/lazychat/p/${this.editedId}/edit`;
}
}
@@ -78,7 +85,7 @@ export class MlkLazychatSubmissionForm extends HTMLElement {
}
async load() {
- if (!this.editedId || this.loaded) {
+ if (this.editedId === null || this.loaded) {
return;
}