Blame SOURCES/bz1366307-01-web-ui-fix-bad-using-of-html-ids.patch

15f218
From 25413c28853e1d350982feba7e306e05b6e74f49 Mon Sep 17 00:00:00 2001
15f218
From: Ondrej Mular <omular@redhat.com>
15f218
Date: Sun, 14 Aug 2016 13:38:52 +0200
15f218
Subject: [PATCH] web UI: fix bad using of HTML ids
15f218
15f218
---
15f218
 pcsd/public/js/nodes-ember.js |  5 +++++
15f218
 pcsd/public/js/pcsd.js        | 11 ++++++++---
15f218
 pcsd/views/main.erb           |  4 ++--
15f218
 3 files changed, 15 insertions(+), 5 deletions(-)
15f218
15f218
diff --git a/pcsd/public/js/nodes-ember.js b/pcsd/public/js/nodes-ember.js
15f218
index c51a341..f176c39 100644
15f218
--- a/pcsd/public/js/nodes-ember.js
15f218
+++ b/pcsd/public/js/nodes-ember.js
15f218
@@ -823,6 +823,11 @@ Pcs.ResourceObj = Ember.Object.extend({
15f218
   id: null,
15f218
   _id: Ember.computed.alias('id'),
15f218
   name: Ember.computed.alias('id'),
15f218
+  treeview_element_id: function() {
15f218
+    if (this.get("id")) {
15f218
+      return this.get("id") + "-treeview-element";
15f218
+    }
15f218
+  }.property("id"),
15f218
   parent: null,
15f218
   meta_attr: [],
15f218
   meta_attributes: Ember.computed.alias('meta_attr'),
15f218
diff --git a/pcsd/public/js/pcsd.js b/pcsd/public/js/pcsd.js
15f218
index 56219d4..1060bd3 100644
15f218
--- a/pcsd/public/js/pcsd.js
15f218
+++ b/pcsd/public/js/pcsd.js
15f218
@@ -2077,8 +2077,13 @@ function fix_auth_of_cluster() {
15f218
   });
15f218
 }
15f218
 
15f218
-function get_tree_view_element_id(element) {
15f218
-  return $(element).parents('table.tree-element')[0].id;
15f218
+function get_tree_view_resource_id(element) {
15f218
+  var suffix = '-treeview-element';
15f218
+  var element_id = $(element).parents('table.tree-element')[0].id;
15f218
+  if (element_id && element_id.endsWith(suffix)) {
15f218
+    return element_id.substr(0, element_id.lastIndexOf(suffix));
15f218
+  }
15f218
+  return null;
15f218
 }
15f218
 
15f218
 function get_list_view_element_id(element) {
15f218
@@ -2166,7 +2171,7 @@ function tree_view_onclick(resource_id) {
15f218
 }
15f218
 
15f218
 function tree_view_select(element_id) {
15f218
-  var e = $('#' + element_id);
15f218
+  var e = $(`#${element_id}-treeview-element`);
15f218
   var view = e.parents('table.tree-view');
15f218
   view.find('div.arrow').hide();
15f218
   view.find('tr.children').hide();
15f218
diff --git a/pcsd/views/main.erb b/pcsd/views/main.erb
15f218
index 64fe560..8de1c60 100644
15f218
--- a/pcsd/views/main.erb
15f218
+++ b/pcsd/views/main.erb
15f218
@@ -99,8 +99,8 @@
15f218
   </script>
15f218
 
15f218
   <script type="text/x-handlebars" data-template-name="components/resource-tree-element">
15f218
-    
15f218
-    
15f218
+    
15f218
+    
15f218
         
15f218
           <input type="checkbox" onchange="tree_view_checkbox_onchange(this)">
15f218
         
15f218
-- 
15f218
1.8.3.1
15f218