Skip to content

Commit

Permalink
[add] urlparams sample ( webix jet 1.3 )
Browse files Browse the repository at this point in the history
  • Loading branch information
mkozhukh committed Jan 10, 2018
1 parent b980c69 commit 9c3ed10
Show file tree
Hide file tree
Showing 7 changed files with 5,392 additions and 2 deletions.
1 change: 1 addition & 0 deletions .webroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://127.0.0.1:8080
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h3>Plugins</h3>
<h3>Routers</h3>
<ul>
<li><a href="./routers-url/">UrlRouter</a></li>
<li><a href="./urlparams.html">Url parameters</a></li>
</ul>

<h3>Recepies</h3>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"webpack-dev-server": "^2.8.2"
},
"dependencies": {
"webix-jet": "^1.1.0"
"webix-jet": "^1.3.0"
}
}
80 changes: 80 additions & 0 deletions sources/urlparams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {JetApp, JetView, plugins } from "webix-jet";

class TopView extends JetView {
config(){
return {
rows:[
{ view:"segmented", inputWidth:300, options:["full", "brief"], localId:"ms", on:{
onChange: function(){
this.$scope.setParam("mode", this.getValue(), true);
}
}},
{ $subview:true }
]
};
}
init(){
this.use(plugins.UrlParam, ["mode"]);

var mode = this.getParam("mode");
if (mode){
this.$$("ms").setValue(mode);
}
}
}

class SubView extends JetView {
config(){
return {
view:"template"
};
}
urlChange(view){
var id = this.getParam("id", true);
var mode = this.getParam("mode", true);
view.setHTML(mode+" mode for id="+id);
}
}

class DetailsView extends JetView {
config(){
return {
cols:[
{ width:200, view:"list", select:true, localId:"list",
on:{
onAfterSelect: (id) => {
this.setParam("id", id, true);
}
}
},
{ $subview:"sub" }
]
};
}
init(){
this.$$("list").parse([
{ id:1, value:"1. short data" },
{ id:2, value:"2. short data" },
]);
}
urlChange(){
var id = this.getParam("id");
if (id)
this.$$("list").select(id);
}
}

webix.ready(() => {
const app = new JetApp({
start: "/top/full/details",
views: {
top: TopView,
details: DetailsView,
sub: SubView
},
debug:true
});


app.render();
});
16 changes: 16 additions & 0 deletions urlparams.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<!-- Webix Library -->
<script type="text/javascript" src="//cdn.webix.com/edge/webix.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.webix.com/edge/webix.css">

<!-- App -->
<script type="text/javascript" src="codebase/urlparams.js"></script>
<link rel="stylesheet" type="text/css" href="assets/app.css">

</head>
<body></body>
</html>
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module.exports = function(env) {
"redirects" : "./sources/redirects.js",
"screensize" : "./sources/screensize.js",
"viewresolve" : "./sources/viewresolve.js",
"viewapp" : "./sources/viewapp.js"
"viewapp" : "./sources/viewapp.js",
"urlparams" : "./sources/urlparams.js"
},
output: {
path: path.join(__dirname, "codebase"),
Expand Down
Loading

0 comments on commit 9c3ed10

Please sign in to comment.