From 79b30cad29dc7d98d0a76966f06d5e2b94488dfe Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 13 Aug 2013 17:01:06 -0700 Subject: [PATCH] Add ability to set current selected value of groups and connections. --- guacamole/src/main/webapp/scripts/guac-ui.js | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index b2ae6a233..081e0ee41 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -926,6 +926,20 @@ GuacUI.GroupView = function(root_group, multiselect) { var element = GuacUI.createElement("div", "group-view"); var list = GuacUI.createChildElement(element, "div", "list"); + /** + * Set of all group checkboxes, indexed by ID. Only applicable when + * multiselect is enabled. + * @private + */ + var group_checkboxes = {}; + + /** + * Set of all connection checkboxes, indexed by ID. Only applicable when + * multiselect is enabled. + * @private + */ + var connection_checkboxes = {}; + /** * Set of all connections, indexed by ID. */ @@ -976,6 +990,28 @@ GuacUI.GroupView = function(root_group, multiselect) { return element; }; + /** + * Sets the current value of the group with the given ID. This function + * only has an effect when multiselect is enabled. + * + * @param {String} id The ID of the group to change. + * @param {Boolean} value Whether the group should be selected. + */ + this.setGroupValue = function(id, value) { + group_checkboxes[id].checked = value; + }; + + /** + * Sets the current value of the connection with the given ID. This function + * only has an effect when multiselect is enabled. + * + * @param {String} id The ID of the connection to change. + * @param {Boolean} value Whether the connection should be selected. + */ + this.setConnectionValue = function(id, value) { + connection_checkboxes[id].checked = value; + }; + // Create pager for contents var pager = new GuacUI.Pager(list); pager.page_capacity = 20; @@ -1031,6 +1067,9 @@ GuacUI.GroupView = function(root_group, multiselect) { connection_checkbox.addEventListener("click", fire_connection_change, false); connection_checkbox.addEventListener("change", fire_connection_change, false); + // Add checbox to set of connection checkboxes + connection_checkboxes[connection.id] = connection_checkbox; + } else appendChild(guacui_connection.getElement()); @@ -1085,6 +1124,9 @@ GuacUI.GroupView = function(root_group, multiselect) { group_checkbox.addEventListener("click", fire_group_change, false); group_checkbox.addEventListener("change", fire_group_change, false); + // Add checbox to set of group checkboxes + group_checkboxes[child_group.id] = group_checkbox; + } else appendChild(list_group.getElement());