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;
addEdgeForm(new Edge(graph, null, graph.getVertex(from), graph.getVertex(to)));
},
});
form.button({
})
.button({
id: 'save',
name: 'Save',
cb: ({ form: { value } }, { initializing }) => {
@ -118,6 +117,14 @@ export class Edge {
}
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;
form
.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: 'label', name: 'label', defaultValue: vertex.label })
.button({
id: 'save',
name: 'Save',
@ -69,9 +68,14 @@ export class Vertex {
}
},
})
.button({
id: 'cancel',
name: 'Cancel',
cb: (_, { initializing }) => {
if (initializing) return;
doc.clear();
},
});
return doc;
}
}