From ee06c0a5caf87a8160e06fc2bb251cae8eca026d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 14 Aug 2013 13:29:21 -0700 Subject: [PATCH] Track list of all groups by ID within GroupView. Soft fail when set*() called on group or connection that isn't present in GroupView. --- guacamole/src/main/webapp/scripts/guac-ui.js | 26 ++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index 3fe23963c..fcfc7d0ab 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -940,6 +940,11 @@ GuacUI.GroupView = function(root_group, multiselect) { */ var connection_checkboxes = {}; + /** + * Set of all connection groups, indexed by ID. + */ + this.groups = {}; + /** * Set of all connections, indexed by ID. */ @@ -1000,6 +1005,8 @@ GuacUI.GroupView = function(root_group, multiselect) { this.setGroupEnabled = function(id, value) { var checkbox = group_checkboxes[id]; + if (!checkbox) + return; // If enabled, show checkbox, allow select if (value) { @@ -1025,6 +1032,8 @@ GuacUI.GroupView = function(root_group, multiselect) { this.setConnectionEnabled = function(id, value) { var checkbox = connection_checkboxes[id]; + if (!checkbox) + return; // If enabled, show checkbox, allow select if (value) { @@ -1048,7 +1057,13 @@ GuacUI.GroupView = function(root_group, multiselect) { * @param {Boolean} value Whether the group should be selected. */ this.setGroupValue = function(id, value) { - group_checkboxes[id].checked = value; + + var checkbox = group_checkboxes[id]; + if (!checkbox) + return; + + checkbox.checked = value; + }; /** @@ -1059,7 +1074,13 @@ GuacUI.GroupView = function(root_group, multiselect) { * @param {Boolean} value Whether the connection should be selected. */ this.setConnectionValue = function(id, value) { - connection_checkboxes[id].checked = value; + + var checkbox = connection_checkboxes[id]; + if (!checkbox) + return; + + checkbox.checked = value; + }; // Create pager for contents @@ -1078,6 +1099,7 @@ GuacUI.GroupView = function(root_group, multiselect) { function addGroup(group, appendChild) { var i; + group_view.groups[group.id] = group; // Add all contained connections for (i=0; i