feat: setup node edit action

This commit is contained in:
Rucha Mahabal
2021-06-29 21:51:21 +05:30
parent f15e8b7f5a
commit c40b9d276e
4 changed files with 30 additions and 6 deletions

View File

@@ -1,14 +1,16 @@
erpnext.HierarchyChart = class {
/* Options:
- doctype
- wrapper: wrapper for the hierarchy view
- method:
- to get the data for each node
- this method should return id, name, title, image, and connections for each node
*/
constructor(wrapper, method) {
constructor(doctype, wrapper, method) {
this.wrapper = $(wrapper);
this.page = wrapper.page;
this.method = method;
this.doctype = doctype;
this.page.main.css({
'min-height': '300px',
@@ -36,6 +38,7 @@ erpnext.HierarchyChart = class {
me.nodes[this.id] = this;
me.make_node_element(this);
me.setup_node_click_action(this);
me.setup_edit_node_action(this);
}
}
}
@@ -363,6 +366,15 @@ erpnext.HierarchyChart = class {
});
}
setup_edit_node_action(node) {
let node_element = $(`#${node.id}`);
let me = this;
node_element.find('.btn-edit-node').click(function() {
frappe.set_route('Form', me.doctype, node.id);
});
}
remove_levels_after_node(node) {
let level = $(`#${node.id}`).parent().parent().parent();