From e54017f10e58734d67cf6f0979c730e895b37d12 Mon Sep 17 00:00:00 2001 From: Maksim Kozhukh Date: Tue, 26 Jun 2018 11:31:29 +0300 Subject: [PATCH] [add] order of view handlers --- sources/app.js | 42 +++++++++++---------- sources/events.js | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 sources/events.js diff --git a/sources/app.js b/sources/app.js index 79c1c28..fba47cc 100644 --- a/sources/app.js +++ b/sources/app.js @@ -1,25 +1,26 @@ import {JetApp, JetView, EmptyRouter } from "webix-jet"; -import windows from "windows"; -import appguard from "appguard"; -import viewguard from "viewguard"; -import pluginsunload from "plugins-unload"; -import redirects from "redirects"; -import viewresolve from "viewresolve"; -import promises from "promises"; -import routes from "routes"; -import pluginslocale from "plugins-locale"; -import pluginstheme from "plugins-theme"; -import pluginsstatus from "plugins-status"; -import routersurl from "routers-url"; -import urlparams from "urlparams"; -import screensize from "screensize"; -import viewapp from "viewapp"; -import tabbar from "tabbar"; -import dashboard from "dashboard"; -import addview from "addview"; -import datatable from "datatable"; -import webixview from "webixview"; +import events from "./events"; +import windows from "./windows"; +import appguard from "./appguard"; +import viewguard from "./viewguard"; +import pluginsunload from "./plugins-unload"; +import redirects from "./redirects"; +import viewresolve from "./viewresolve"; +import promises from "./promises"; +import routes from "./routes"; +import pluginslocale from "./plugins-locale"; +import pluginstheme from "./plugins-theme"; +import pluginsstatus from "./plugins-status"; +import routersurl from "./routers-url"; +import urlparams from "./urlparams"; +import screensize from "./screensize"; +import viewapp from "./viewapp"; +import tabbar from "./tabbar"; +import dashboard from "./dashboard"; +import addview from "./addview"; +import datatable from "./datatable"; +import webixview from "./webixview"; const samples = new webix.DataCollection({ data:[ @@ -31,6 +32,7 @@ const samples = new webix.DataCollection({ data:[ { group:1, value:"Resolving Files", app: viewresolve, id:"viewresolve" }, { group:1, value:"Promises in views", app: promises, id:"promises" }, { group:1, value:"Url Routes", app: routes, id:"routes" }, + { group:1, value:"View life-cycle", app: events, id:"events" }, { group:2, value:"Locales", app: pluginslocale, id:"plugins-locale" }, { group:2, value:"Themes", app: pluginstheme, id:"plugins-theme" }, diff --git a/sources/events.js b/sources/events.js new file mode 100644 index 0000000..81414b8 --- /dev/null +++ b/sources/events.js @@ -0,0 +1,93 @@ +import {JetApp, JetView} from "webix-jet"; + +class allowed extends JetView{ + config(){ + return { template:"Some cotent here" }; + } +} +class PageA extends JetView{ + config(){ + return { template:"Here is Alpha" }; + } + + init(){ + webix.message("init Alpha"); + } + ready(){ + webix.message("ready Alpha"); + } + urlChange(){ + webix.message("urlChange Alpha"); + } + destroy(){ + webix.message("destroy Alpha"); + } +} +class PageB extends JetView{ + config(){ + return { template:"Here is Betta" }; + } + init(){ + webix.message("init Betta"); + } + ready(){ + webix.message("ready Betta"); + } + urlChange(){ + webix.message("urlChange Betta"); + } + destroy(){ + webix.message("destroy Betta"); + } +} + +class TopView extends JetView { + config(){ + return { + type:"space", rows:[ + { view:"toolbar", cols:[ + { view:"label", label:"View life-cycle"} + ]}, + { + type:"wide",cols:[ + { view:"form", width: 200, rows:[ + { view:"button", value:"Page A", click:() => + this.show("pageA") }, + { view:"button", value:"Page B", click:() => + this.show("pageB") }, + { view:"button", value:"Destroy the app", click:() => + this.app.destructor() }, + {} + ]}, + { $subview: true } + ] + } + ] + }; + } + init(){ + webix.message("init Top"); + } + ready(){ + webix.message("ready Top"); + } + urlChange(){ + webix.message("urlChange Top"); + } + destroy(){ + webix.message("destroy Top"); + } +} + + +const app = new JetApp({ + id: "windows", + start: "/top/pageA", + views:{ + top: TopView, + pageA: PageA, + pageB: PageB + } +}); + +export default app; \ No newline at end of file