Implement filter in devices page
This commit is contained in:
1 parent
eda43083ec
commit
ccf548081f
7 files changed
+198
-47
No files matched your search
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
import m from "mithril";
|
||||
|
||||
import config from "./config";
|
||||
|
||||
const component = {
|
||||
view: vnode => {
|
||||
let a = m(
|
||||
"datalist#filters",
|
||||
config.filter.map(f => m("option", { value: `${f.label} = ` }))
|
||||
);
|
||||
|
||||
const filterList = vnode.attrs.filterList.filter(f => {
|
||||
return !!f;
|
||||
});
|
||||
filterList.push("");
|
||||
|
||||
return m(
|
||||
"div.filter",
|
||||
[m("b", "Filter"), a].concat(
|
||||
filterList.map((fltr, idx) => {
|
||||
return m("input", {
|
||||
type: "string",
|
||||
list: "filters",
|
||||
value: fltr,
|
||||
onchange: function(e) {
|
||||
e.redraw = false;
|
||||
filterList[idx] = this.value;
|
||||
m.route.set("/devices", {
|
||||
filter: filterList.filter(f => !!f)
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default component;
|
||||
Reference in new issue
Block a user