feat: setup node edit action
diff --git a/erpnext/hr/page/organizational_chart/organizational_chart.js b/erpnext/hr/page/organizational_chart/organizational_chart.js
index ca98552..a138886 100644
--- a/erpnext/hr/page/organizational_chart/organizational_chart.js
+++ b/erpnext/hr/page/organizational_chart/organizational_chart.js
@@ -11,9 +11,9 @@
let method = 'erpnext.hr.page.organizational_chart.organizational_chart.get_children';
if (frappe.is_mobile()) {
- organizational_chart = new erpnext.HierarchyChartMobile(wrapper, method);
+ organizational_chart = new erpnext.HierarchyChartMobile('Employee', wrapper, method);
} else {
- organizational_chart = new erpnext.HierarchyChart(wrapper, method);
+ organizational_chart = new erpnext.HierarchyChart('Employee', wrapper, method);
}
organizational_chart.show();
});
diff --git a/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js b/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
index 052f140..0823ec7 100644
--- a/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
+++ b/erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
@@ -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 @@
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 @@
});
}
+ 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();
diff --git a/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js b/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js
index 1b8bc2e..4b09714 100644
--- a/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js
+++ b/erpnext/public/js/hierarchy_chart/hierarchy_chart_mobile.js
@@ -1,14 +1,16 @@
erpnext.HierarchyChartMobile = 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 @@
me.nodes[this.id] = this;
me.make_node_element(this);
me.setup_node_click_action(this);
+ me.setup_edit_node_action(this);
}
}
}
@@ -385,6 +388,15 @@
});
}
+ 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);
+ });
+ }
+
setup_node_group_action() {
let me = this;
diff --git a/erpnext/public/js/templates/node_card.html b/erpnext/public/js/templates/node_card.html
index e42e54f..30aedab 100644
--- a/erpnext/public/js/templates/node_card.html
+++ b/erpnext/public/js/templates/node_card.html
@@ -17,9 +17,9 @@
<div class="node-title text-muted ellipsis">{{ title }}</div>
{% if connections == 1 %}
- <div class="node-connections text-muted ml-2 ellipsis">· {{ connections }}</div>
+ <div class="node-connections text-muted ml-2 ellipsis">· {{ connections }} Connection</div>
{% else %}
- <div class="node-connections text-muted ml-2 ellipsis">· {{ connections }}</div>
+ <div class="node-connections text-muted ml-2 ellipsis">· {{ connections }} Connections</div>
{% endif %}
</div>
</div>