mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
refactor: add options to chart
- method to return the node data - wrapper for showing the hierarchy
This commit is contained in:
@@ -8,10 +8,12 @@ frappe.pages['organizational-chart'].on_page_load = function(wrapper) {
|
||||
$(wrapper).bind('show', () => {
|
||||
frappe.require('/assets/js/hierarchy-chart.min.js', () => {
|
||||
let organizational_chart = undefined;
|
||||
let method = 'erpnext.hr.page.organizational_chart.organizational_chart.get_children';
|
||||
|
||||
if (frappe.is_mobile()) {
|
||||
organizational_chart = new erpnext.HierarchyChartMobile(wrapper);
|
||||
organizational_chart = new erpnext.HierarchyChartMobile(wrapper, method);
|
||||
} else {
|
||||
organizational_chart = new erpnext.HierarchyChart(wrapper);
|
||||
organizational_chart = new erpnext.HierarchyChart(wrapper, method);
|
||||
}
|
||||
organizational_chart.show();
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ def get_children(parent=None, company=None, exclude_node=None, is_root=False, is
|
||||
filters.append(['company', '=', company])
|
||||
|
||||
if not fields:
|
||||
fields = ['employee_name', 'name', 'reports_to', 'image', 'designation']
|
||||
fields = ['employee_name as name', 'name as id', 'reports_to', 'image', 'designation as title']
|
||||
|
||||
if is_root:
|
||||
parent = ''
|
||||
@@ -27,9 +27,9 @@ def get_children(parent=None, company=None, exclude_node=None, is_root=False, is
|
||||
|
||||
for employee in employees:
|
||||
is_expandable = frappe.get_all('Employee', filters=[
|
||||
['reports_to', '=', employee.get('name')]
|
||||
['reports_to', '=', employee.get('id')]
|
||||
])
|
||||
employee.connections = get_connections(employee.name)
|
||||
employee.connections = get_connections(employee.id)
|
||||
employee.expandable = 1 if is_expandable else 0
|
||||
|
||||
return employees
|
||||
|
||||
Reference in New Issue
Block a user