fix(Org Chart): use attribute selectors instead of ID selector for node IDs with special characters (#27717) (#27718)

* fix(Org Chart): use attribute selectors instead of ID selector for node IDs with special chars

* fix: UI tests

(cherry picked from commit 9e08229b7b)

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
This commit is contained in:
mergify[bot]
2021-09-30 18:45:22 +05:30
committed by GitHub
parent 15c9c08261
commit 05374cb8b2
5 changed files with 27 additions and 25 deletions

View File

@@ -54,7 +54,7 @@ erpnext.HierarchyChartMobile = class {
});
node.parent.append(node_card);
node.$link = $(`#${node.id}`);
node.$link = $(`[id="${node.id}"]`);
node.$link.addClass('mobile-node');
}
@@ -184,7 +184,7 @@ erpnext.HierarchyChartMobile = class {
this.refresh_connectors(node.parent_id, node.id);
// rebuild incoming connections of parent
let grandparent = $(`#${node.parent_id}`).attr('data-parent');
let grandparent = $(`[id="${node.parent_id}"]`).attr('data-parent');
this.refresh_connectors(grandparent, node.parent_id);
}
@@ -221,7 +221,7 @@ erpnext.HierarchyChartMobile = class {
show_active_path(node) {
// mark node parent on active path
$(`#${node.parent_id}`).addClass('active-path');
$(`[id="${node.parent_id}"]`).addClass('active-path');
}
load_children(node) {
@@ -256,7 +256,7 @@ erpnext.HierarchyChartMobile = class {
if (child_nodes) {
$.each(child_nodes, (_i, data) => {
this.add_node(node, data);
$(`#${data.id}`).addClass('active-child');
$(`[id="${data.id}"]`).addClass('active-child');
setTimeout(() => {
this.add_connector(node.id, data.id);
@@ -293,9 +293,9 @@ erpnext.HierarchyChartMobile = class {
let connector = undefined;
if ($(`#${parent_id}`).hasClass('active')) {
if ($(`[id="${parent_id}"]`).hasClass('active')) {
connector = this.get_connector_for_active_node(parent_node, child_node);
} else if ($(`#${parent_id}`).hasClass('active-path')) {
} else if ($(`[id="${parent_id}"]`).hasClass('active-path')) {
connector = this.get_connector_for_collapsed_node(parent_node, child_node);
}
@@ -351,7 +351,7 @@ erpnext.HierarchyChartMobile = class {
set_path_attributes(path, parent_id, child_id) {
path.setAttribute("data-parent", parent_id);
path.setAttribute("data-child", child_id);
const parent = $(`#${parent_id}`);
const parent = $(`[id="${parent_id}"]`);
if (parent.hasClass('active')) {
path.setAttribute("class", "active-connector");
@@ -374,7 +374,7 @@ erpnext.HierarchyChartMobile = class {
setup_node_click_action(node) {
let me = this;
let node_element = $(`#${node.id}`);
let node_element = $(`[id="${node.id}"]`);
node_element.click(function() {
let el = undefined;
@@ -398,7 +398,7 @@ erpnext.HierarchyChartMobile = class {
}
setup_edit_node_action(node) {
let node_element = $(`#${node.id}`);
let node_element = $(`[id="${node.id}"]`);
let me = this;
node_element.find('.btn-edit-node').click(function() {
@@ -512,7 +512,7 @@ erpnext.HierarchyChartMobile = class {
}
remove_levels_after_node(node) {
let level = $(`#${node.id}`).parent().parent().index();
let level = $(`[id="${node.id}"]`).parent().parent().index();
level = $('.hierarchy-mobile > li:eq('+ level + ')');
level.nextAll('li').remove();
@@ -533,7 +533,7 @@ erpnext.HierarchyChartMobile = class {
const parent = $(path).data('parent');
const child = $(path).data('child');
if ($(`#${parent}`).length && $(`#${child}`).length)
if ($(`[id="${parent}"]`).length && $(`[id="${child}"]`).length)
return;
$(path).remove();