Merge pull request #182 from Newbytee/submit-for-login

Use submit event for login instead of click
This commit is contained in:
Bruno Windels 2020-11-10 14:09:56 +00:00 committed by GitHub
commit 1c978f060e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View File

@ -94,7 +94,7 @@ export const TAG_NAMES = {
[HTML_NS]: [ [HTML_NS]: [
"br", "a", "ol", "ul", "li", "div", "h1", "h2", "h3", "h4", "h5", "h6", "br", "a", "ol", "ul", "li", "div", "h1", "h2", "h3", "h4", "h5", "h6",
"p", "strong", "em", "span", "img", "section", "main", "article", "aside", "p", "strong", "em", "span", "img", "section", "main", "article", "aside",
"pre", "button", "time", "input", "textarea", "label"], "pre", "button", "time", "input", "textarea", "label", "form"],
[SVG_NS]: ["svg", "circle"] [SVG_NS]: ["svg", "circle"]
}; };

View File

@ -46,6 +46,12 @@ export class LoginView extends TemplateView {
t.div({className: "LoginView form"}, [ t.div({className: "LoginView form"}, [
t.h1([vm.i18n`Sign In`]), t.h1([vm.i18n`Sign In`]),
t.if(vm => vm.error, t.createTemplate(t => t.div({className: "error"}, vm => vm.error))), t.if(vm => vm.error, t.createTemplate(t => t.div({className: "error"}, vm => vm.error))),
t.form({
onSubmit: evnt => {
evnt.preventDefault();
vm.login(username.value, password.value, homeserver.value);
}
}, [
t.div({className: "form-row"}, [t.label({for: "username"}, vm.i18n`Username`), username]), t.div({className: "form-row"}, [t.label({for: "username"}, vm.i18n`Username`), username]),
t.div({className: "form-row"}, [t.label({for: "password"}, vm.i18n`Password`), password]), t.div({className: "form-row"}, [t.label({for: "password"}, vm.i18n`Password`), password]),
t.div({className: "form-row"}, [t.label({for: "homeserver"}, vm.i18n`Homeserver`), homeserver]), t.div({className: "form-row"}, [t.label({for: "homeserver"}, vm.i18n`Homeserver`), homeserver]),
@ -57,10 +63,10 @@ export class LoginView extends TemplateView {
}, [vm.i18n`Go Back`]), }, [vm.i18n`Go Back`]),
t.button({ t.button({
className: "button-action primary", className: "button-action primary",
onClick: () => vm.login(username.value, password.value, homeserver.value), type: "submit"
disabled
}, vm.i18n`Log In`), }, vm.i18n`Log In`),
]), ]),
]),
// use t.mapView rather than t.if to create a new view when the view model changes too // use t.mapView rather than t.if to create a new view when the view model changes too
t.p(hydrogenGithubLink(t)) t.p(hydrogenGithubLink(t))
]) ])