mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-11-11 07:41:09 +00:00
created login page
This commit is contained in:
@@ -9,6 +9,7 @@ import { RouterService } from "core/services";
|
||||
class AppLinkElement extends HTMLElement {
|
||||
@closest appMain: AppMainElement;
|
||||
@attr to: string;
|
||||
@attr goBack: string;
|
||||
@attr title: string;
|
||||
@target main: Element;
|
||||
routerService: RouterService;
|
||||
@@ -17,27 +18,44 @@ class AppLinkElement extends HTMLElement {
|
||||
}
|
||||
|
||||
public connectedCallback(): void {
|
||||
this.update();
|
||||
this.routerService = this.appMain?.routerService;
|
||||
this.main.addEventListener("click", this.goTo);
|
||||
this.update();
|
||||
if (isTrue(this.goBack)) {
|
||||
window.addEventListener("routechanged", () => {
|
||||
this.update();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public disconnectedCallback(): void {
|
||||
this.main.removeEventListener("click", this.goTo);
|
||||
}
|
||||
public disconnectedCallback(): void {}
|
||||
|
||||
goTo = () => {
|
||||
this.routerService.goTo(this.to);
|
||||
if (!isTrue(this.goBack) && this.to) {
|
||||
this.routerService.goTo(this.to);
|
||||
} else {
|
||||
this.routerService.goBack();
|
||||
}
|
||||
this.update();
|
||||
};
|
||||
|
||||
get disabled() {
|
||||
return isTrue(this.goBack) && this.routerService.emptyState;
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`${this.disabled
|
||||
? html`<span data-target="app-link.main" style="color:grey"
|
||||
>${this.title}</span
|
||||
>`
|
||||
: html`<span
|
||||
data-target="app-link.main"
|
||||
data-action="click:app-link#goTo"
|
||||
style="text-decoration: underline; cursor: pointer;"
|
||||
>${this.title}</span
|
||||
>`}`;
|
||||
}
|
||||
|
||||
update() {
|
||||
render(
|
||||
html`<span
|
||||
data-target="app-link.main"
|
||||
style="text-decoration: underline; cursor: pointer;"
|
||||
>${this.title}</span
|
||||
>`,
|
||||
this
|
||||
);
|
||||
render(this.render(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@ class AppMainElement extends HTMLElement {
|
||||
public authStore: AuthStore;
|
||||
private httpClient: HttpClient;
|
||||
public appService: AppService;
|
||||
@closest appMain;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
connectedCallback() {
|
||||
if (this.appMain !== this) return;
|
||||
this.httpClient = new HttpClient();
|
||||
this.appService = new AppService(this, this.httpClient);
|
||||
this.routerService = new RouterService(this);
|
||||
@@ -32,16 +34,22 @@ class AppMainElement extends HTMLElement {
|
||||
component: "home-page",
|
||||
},
|
||||
{
|
||||
path: "/rb",
|
||||
path: "/register",
|
||||
component: "register-page",
|
||||
layout: "menu-layout",
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
component: "login-page",
|
||||
layout: "menu-layout",
|
||||
},
|
||||
{
|
||||
path: "/unauthorized",
|
||||
component: "register-page",
|
||||
component: "login-page",
|
||||
},
|
||||
{
|
||||
path: "token-expired",
|
||||
component: "register-page",
|
||||
component: "login-page",
|
||||
},
|
||||
]);
|
||||
this.routerService.init();
|
||||
|
||||
@@ -33,6 +33,10 @@ class InputFieldElement extends HTMLElement {
|
||||
return !!this.error;
|
||||
}
|
||||
|
||||
get required(): boolean {
|
||||
return this.rules.includes("required");
|
||||
}
|
||||
|
||||
@update
|
||||
validate(): boolean {
|
||||
let _return = true;
|
||||
@@ -67,12 +71,14 @@ class InputFieldElement extends HTMLElement {
|
||||
|
||||
update() {
|
||||
render(
|
||||
html`<span data-target="input-field.main">
|
||||
html`<div data-target="input-field.main">
|
||||
${this.label &&
|
||||
html`<label for="${this.randId}">${this.label}</label>`}
|
||||
html`<label for="${this.randId}"
|
||||
>${this.label}${this.required ? " (*)" : ""}</label
|
||||
>`}
|
||||
<input type="${this.type}" data-target="input-field.inp" />
|
||||
${this.error && html`<span>${this.error}</span>`}
|
||||
</span>`,
|
||||
</div>`,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user