fix: Org Chart fixes (#27290)

* fix(org chart): multiple root nodes not expanding on clicking Expand All

* fix: unstable filter inserts duplicate nodes

(cherry picked from commit f828d853e3)

# Conflicts:
#	erpnext/public/js/hierarchy_chart/hierarchy_chart_desktop.js
#	erpnext/utilities/hierarchy_chart.py
This commit is contained in:
Rucha Mahabal
2021-09-01 23:07:26 +05:30
committed by Mergify
parent f5160dc83d
commit 40f382347a
2 changed files with 20 additions and 0 deletions

View File

@@ -223,7 +223,11 @@ erpnext.HierarchyChart = class {
let node = undefined;
$.each(r.message, (_i, data) => {
<<<<<<< HEAD
if ($(`[id="${data.id}"]`).length)
=======
if ($(`#${data.id}`).length)
>>>>>>> f828d853e3 (fix: Org Chart fixes (#27290))
return;
node = new me.Node({
@@ -351,13 +355,21 @@ erpnext.HierarchyChart = class {
}
get_all_nodes() {
<<<<<<< HEAD
let me = this;
=======
>>>>>>> f828d853e3 (fix: Org Chart fixes (#27290))
return new Promise(resolve => {
frappe.call({
method: 'erpnext.utilities.hierarchy_chart.get_all_nodes',
args: {
<<<<<<< HEAD
method: me.method,
company: me.company
=======
method: this.method,
company: this.company
>>>>>>> f828d853e3 (fix: Org Chart fixes (#27290))
},
callback: (r) => {
resolve(r.message);

View File

@@ -8,7 +8,11 @@ from frappe import _
@frappe.whitelist()
def get_all_nodes(method, company):
<<<<<<< HEAD
"""Recursively gets all data from nodes"""
=======
'''Recursively gets all data from nodes'''
>>>>>>> f828d853e3 (fix: Org Chart fixes (#27290))
method = frappe.get_attr(method)
if method not in frappe.whitelisted:
@@ -21,9 +25,13 @@ def get_all_nodes(method, company):
for root in root_nodes:
data = method(root.id, company)
result.append(dict(parent=root.id, parent_name=root.name, data=data))
<<<<<<< HEAD
nodes_to_expand.extend(
[{"id": d.get("id"), "name": d.get("name")} for d in data if d.get("expandable")]
)
=======
nodes_to_expand.extend([{'id': d.get('id'), 'name': d.get('name')} for d in data if d.get('expandable')])
>>>>>>> f828d853e3 (fix: Org Chart fixes (#27290))
while nodes_to_expand:
parent = nodes_to_expand.pop(0)