Add files page

This commit is contained in:
Shweelan Samson authored and Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent f1c3e21ba3
commit 41229ffb85
12 files changed
+521 -8

No files matched your search

+22 -4
View File
@@ -7,7 +7,8 @@ import "codemirror/mode/javascript/javascript";
const singular = {
presets: "preset",
provisions: "provision",
virtualParameters: "virtual parameter"
virtualParameters: "virtual parameter",
files: "file"
};
function createField(current, attr, focus) {
@@ -52,6 +53,20 @@ function createField(current, attr, focus) {
if (focus) editor.focus();
}
});
} else if (attr.type === "file") {
return m("input", {
type: "file",
name: attr.id,
oncreate: focus
? _vnode => {
_vnode.dom.focus();
}
: null,
onchange: e => {
current.object[attr.id] = e.target.files;
e.redraw = false;
}
});
}
return m("input", {
@@ -102,7 +117,8 @@ const component = {
);
}
let buttons = [m("button.primary", { type: "submit" }, "Save")];
const submit = m("button.primary", { type: "submit" }, "Save");
let buttons = [submit];
if (!current.isNew)
buttons.push(
@@ -129,9 +145,11 @@ const component = {
"form",
{
onsubmit: e => {
e.target.disabled = true;
e.preventDefault();
e.redraw = false;
e.target.onsubmit = null;
e.preventDefault();
for (let elem of e.target.elements) elem.disabled = true;
submit.dom.textContent = "Loading ...";
actionHandler("save", current.object);
}
},