Add cancel buttons

This commit is contained in:
Ladd Hoffman 2023-07-09 16:33:11 -05:00
parent f978c20104
commit 56132b2fec
2 changed files with 33 additions and 22 deletions

View File

@ -99,9 +99,8 @@ export class Edge {
if (initializing) return; if (initializing) return;
addEdgeForm(new Edge(graph, null, graph.getVertex(from), graph.getVertex(to))); addEdgeForm(new Edge(graph, null, graph.getVertex(from), graph.getVertex(to)));
}, },
}); })
.button({
form.button({
id: 'save', id: 'save',
name: 'Save', name: 'Save',
cb: ({ form: { value } }, { initializing }) => { cb: ({ form: { value } }, { initializing }) => {
@ -118,6 +117,14 @@ export class Edge {
} }
graph.redraw(); graph.redraw();
}, },
})
.button({
id: 'cancel',
name: 'Cancel',
cb: (_, { initializing }) => {
if (initializing) return;
doc.clear();
},
}); });
} }
} }

View File

@ -48,11 +48,10 @@ export class Vertex {
const form = doc.form().lastElement; const form = doc.form().lastElement;
form form
.textField({ .textField({
id: 'id', name: 'id', defaultValue: vertex.id, disabled: true, id: 'id', name: 'id', defaultValue: vertex.id,
}) })
.textField({ id: 'type', name: 'type', defaultValue: vertex.type }) .textField({ id: 'type', name: 'type', defaultValue: vertex.type })
.textField({ id: 'label', name: 'label', defaultValue: vertex.label }) .textField({ id: 'label', name: 'label', defaultValue: vertex.label })
.button({ .button({
id: 'save', id: 'save',
name: 'Save', name: 'Save',
@ -69,9 +68,14 @@ export class Vertex {
} }
}, },
}) })
.button({
id: 'cancel',
name: 'Cancel',
cb: (_, { initializing }) => {
if (initializing) return;
doc.clear();
}, },
}); });
return doc; return doc;
} }
} }