feat: setup node edit action
This commit is contained in:
parent
f15e8b7f5a
commit
c40b9d276e
@ -11,9 +11,9 @@ frappe.pages['organizational-chart'].on_page_load = function(wrapper) {
|
||||
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();
|
||||
});
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 @@ erpnext.HierarchyChartMobile = class {
|
||||
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 @@ erpnext.HierarchyChartMobile = 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);
|
||||
});
|
||||
}
|
||||
|
||||
setup_node_group_action() {
|
||||
let me = this;
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user