added getters from main app element to other elements

This commit is contained in:
Fran Jurmanović
2021-06-03 19:18:50 +02:00
parent 7e3332e32c
commit b36e7f0ca6
6 changed files with 38 additions and 14 deletions

View File

@@ -1,22 +1,23 @@
import { controller, target } from "@github/catalyst";
import { AppService, HttpClient, RouterService } from "core/services";
import { AuthStore } from "core/store";
import { BaseComponentElement } from "common/";
import { AppModalElement, AppRootElement } from "components/";
import { closest } from "core/utils";
@controller
class AppMainElement extends BaseComponentElement {
class AppMainElement extends HTMLElement {
public routerService: RouterService;
public authStore: AuthStore;
private httpClient: HttpClient;
public appService: AppService;
@target appModal: AppModalElement;
@target mainRoot: AppRootElement;
@closest appMain: AppMainElement;
constructor() {
super();
}
elementConnected = () => {
connectedCallback() {
if (this.appMain !== this) return;
const mainRoot = this.createMainRoot();
this.httpClient = new HttpClient();
@@ -48,6 +49,11 @@ class AppMainElement extends BaseComponentElement {
layout: "menu-layout",
middleware: this.isAuth,
children: [
{
path: "/all",
component: "wallet-list",
layout: "menu-layout",
},
{
path: "/:walletId",
component: "history-page",
@@ -86,7 +92,7 @@ class AppMainElement extends BaseComponentElement {
},
]);
this.routerService.init();
};
}
middleAuth = () => {
if (!this.isAuth) {