import m from "mithril"
import stream from "mithril/stream"
import {
Toolbar,
ToolbarTitle,
Shadow,
List,
ListTile,
Search,
IconButton
} from "polythene-mithril"
import Dept from "../../models/beta/Dept"
const barsIcon = ""
const backIcon = ""
const searchIcon = ""
const searchBox = {
view: function() {
return m(Search, {
textfield: {label: "Search"},
buttons: {
none: {
after: m(IconButton, {
icon: {svg: m.trust(searchIcon)},
inactive: true
})
}
}
})
}
}
const menuList = {
oninit: function(vnode) {
const show = stream(false)
vnode.state = {
show
}
},
view: function(vnode) {
const state = vnode.state
const show = state.show()
return m("div", [
m(Toolbar, {
style: {
position: "fixed",
zIndex: "11",
width: "100%",
backgroundColor: "rgba(255, 255, 255, .93)"
}
}, [
m("#bars", {
style: {cursor: "pointer", display: "inline-block", marginLeft: "1em"},
onclick: function() {
this.classList.toggle("change")
state.show(!state.show())
}
}, [
m(".bar1"),
m(".bar2"),
m(".bar3")
]),
m(ToolbarTitle, {
text: vnode.attrs.title
})
]),
m("#menu", {
style: {
left: show ? "0" : "-100%"
}
}, [
m(Shadow),
m(List, {
id: "menu-list",
tiles: [
m(ListTile, {
title: "All Users",
hoverable: true,
events: {
onclick: function() {
m.route.set("/beta/users")
}
}
}),
m(ListTile, {
header: true,
title: "Department List"
}),
vnode.attrs.list.map(function(o) {
return m(ListTile, {
title: o.name,
hoverable: true,
events: {
onclick: function() {
state.show(false)
document.getElementById("bars")
.classList.toggle("change")
m.route.set("/beta/departments/" + o.id)
}
}
})
})
]
})
]),
m("#menu-overlay", {
style: {
opacity: ".4",
display: show ? "block" : "none"
},
onclick: function() {
if (show) {
state.show(false)
document.getElementById("bars")
.classList.toggle("change")
}
}
})
])
}
}
export default menuList