DodoApp: Make form disabling logic work with all forms on the page
Change-Id: Ib82aa2fbd9c607fbc373fc0944fd5729813b128e
diff --git a/core/installer/welcome/dodo-app-tmpl/base.html b/core/installer/welcome/dodo-app-tmpl/base.html
index 450ab25..a4917de 100644
--- a/core/installer/welcome/dodo-app-tmpl/base.html
+++ b/core/installer/welcome/dodo-app-tmpl/base.html
@@ -17,6 +17,7 @@
</nav>
{{- block "content" . }}
{{- end }}
+ <script src="/stat/dodo-app.js?v=0.0.9"></script>
</body>
</html>
{{ define "resources" }}
diff --git a/core/installer/welcome/dodo-app-tmpl/index.html b/core/installer/welcome/dodo-app-tmpl/index.html
index 67b20f6..5ea0a4b 100644
--- a/core/installer/welcome/dodo-app-tmpl/index.html
+++ b/core/installer/welcome/dodo-app-tmpl/index.html
@@ -31,5 +31,4 @@
</ul>
</nav>
</aside>
-<script src="/stat/dodo-app.js?v=0.0.8"></script>
{{- end -}}
diff --git a/core/installer/welcome/stat/dodo-app.js b/core/installer/welcome/stat/dodo-app.js
index ccb5252..15e3bb2 100644
--- a/core/installer/welcome/stat/dodo-app.js
+++ b/core/installer/welcome/stat/dodo-app.js
@@ -1,20 +1,16 @@
-function triggerForm(status, buttonTxt) {
- const form = document.getElementById("create-app");
- const elements = form.querySelectorAll("input, select, textarea, button");
- const button = document.getElementById("create-app-button");
- button.textContent = buttonTxt;
- button.setAttribute("aria-busy", status);
- elements.forEach(element => {
- element.disabled = status;
- });
+function makeFormBusyOnSubmit(form, submitter) {
+ submitter.setAttribute("aria-busy", true);
+ form.querySelectorAll("input, select, textarea, button").forEach((element) => {
+ element.disabled = true;
+ });
}
document.addEventListener("DOMContentLoaded", () => {
- const form = document.getElementById("create-app");
+ document.querySelectorAll("form").forEach((form) => {
form.addEventListener("submit", (event) => {
- setTimeout(() => {
- triggerForm(true, "creating app ...");
- }, 0);
- });
- triggerForm(false, "create app");
+ // TODO(gio): Find better way to disable fields
+ setTimeout(() => makeFormBusyOnSubmit(event.target, event.submitter), 0);
+ return true;
+ });
+ });
});