Update mithril types
This commit is contained in:
1 parent
cd8d264f03
commit
cc885e7d04
8 files changed
+80
-44
No files matched your search
@@ -17,7 +17,7 @@
|
||||
* along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ClosureComponent, Component } from "mithril";
|
||||
import { ClosureComponent } from "mithril";
|
||||
import { m } from "./components";
|
||||
import * as store from "./store";
|
||||
import { yaml } from "./dynamic-loader";
|
||||
@@ -86,12 +86,20 @@ function putActionHandler(prefix: string[], dataYaml: string): Promise<any> {
|
||||
});
|
||||
}
|
||||
|
||||
const component: ClosureComponent = (): Component => {
|
||||
interface Attrs {
|
||||
prefix: string;
|
||||
name: string;
|
||||
data: { _id: string; value: string }[];
|
||||
onUpdate: (errs: Record<string, string>) => void;
|
||||
onError: (err: Error) => void;
|
||||
}
|
||||
|
||||
const component: ClosureComponent<Attrs> = () => {
|
||||
return {
|
||||
view: (vnode) => {
|
||||
const prefix = vnode.attrs["prefix"].split(".");
|
||||
const name = vnode.attrs["name"];
|
||||
const data = vnode.attrs["data"];
|
||||
const prefix = vnode.attrs.prefix.split(".");
|
||||
const name = vnode.attrs.name;
|
||||
const data = vnode.attrs.data;
|
||||
|
||||
if (prefix[prefix.length - 1] === "") prefix.pop();
|
||||
|
||||
@@ -135,8 +143,8 @@ const component: ClosureComponent = (): Component => {
|
||||
vnode.state["updatedYaml"] = yamlString;
|
||||
|
||||
putActionHandler(prefix, vnode.state["updatedYaml"])
|
||||
.then(vnode.attrs["onUpdate"])
|
||||
.catch(vnode.attrs["onError"]);
|
||||
.then(vnode.attrs.onUpdate)
|
||||
.catch(vnode.attrs.onError);
|
||||
},
|
||||
},
|
||||
[code, m(".actions-bar", [submit])]
|
||||
|
||||
Reference in new issue
Block a user