// Licensed Materials - Property of IBM // // IBM Cognos Products: pps // // (C) Copyright IBM Corp. 2005, 2017 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. //This class overides some default event handlers on the HAL tree function AdminTreeHandler(admCommands,ppesAdminEventHandler) { //Private Variables var adminCom = admCommands; var m_currentTreeView = null; var m_currentNode = null; var m_oEventHandler = ppesAdminEventHandler; var SORT_DEF = 0; var SORT_ASC = 1; var SORT_DESC = 2; //Event handlers this.F_ClearTree = function(v_oTreeView) { v_oTreeView.F_Clear(); } this.setCurrentNode = function(v_nTreeNode) { m_currentNode = v_nTreeNode; } this.F_SelectNode = function(v_oTreeView,v_nTreeNode) { if (v_nTreeNode.getAttribute("objName")) { //Attach the current and previous selection to the tree view object for reference later if (v_oTreeView.ppesAdminCurrentSelection) v_oTreeView.ppesAdminPreviousSelection = v_oTreeView.ppesAdminCurrentSelection; v_oTreeView.ppesAdminCurrentSelection = v_nTreeNode; v_oTreeView.F_SelectNode(v_nTreeNode,true,true); } } this.F_returnToPreviousSelection = function(v_oTreeView) { v_oTreeView.ppesAdminCurrentSelection = v_oTreeView.ppesAdminPreviousSelection; v_oTreeView.ppesAdminPreviousSelection = null; v_oTreeView.F_SelectNode(v_oTreeView.ppesAdminCurrentSelection,true,false); } this.F_TreeView_OnNodeClick = function(v_oTreeView,v_nTreeNode,v_iMouseButton) { if (v_iMouseButton == U_DOM.K_iRightMouseButton) { m_currentNode = v_nTreeNode; m_currentTreeView = v_oTreeView; } else { if (v_nTreeNode.getAttribute("objName")) { //Attach the current and previous selection to the tree view object for reference later if (v_oTreeView.ppesAdminCurrentSelection) v_oTreeView.ppesAdminPreviousSelection = v_oTreeView.ppesAdminCurrentSelection; v_oTreeView.ppesAdminCurrentSelection = v_nTreeNode; if (v_nTreeNode.parentNode.tagName == "treeView") //root node, so no parent m_oEventHandler.F_TreeItemSelected(v_nTreeNode.getAttribute("objName"),null); else m_oEventHandler.F_TreeItemSelected(v_nTreeNode.getAttribute("objName"),v_nTreeNode.parentNode.getAttribute("objName")); } } }// F_TreeView_OnNodeClick() this.F_TreeView_OnPopulateChildren = function(v_oTreeView,v_nTreeNode) { m_currentNode = v_nTreeNode; m_currentTreeView = v_oTreeView; var sObjName = ""; if ((typeof (v_nTreeNode.getAttribute("objName")) != "undefined") && v_nTreeNode.getAttribute("objName") != null) sObjName = v_nTreeNode.getAttribute("objName"); var sortType = SORT_DEF; if (v_nTreeNode.getAttribute("sort") != null) sortType = parseInt(v_nTreeNode.getAttribute("sort")); if (m_currentNode.tagName == "treeView") //Initial Load m_oEventHandler.F_ShowProgressDialog(null,G_ResManager.F_GetString("IDS_PPESADMIN_WORKING")); var isSearch; if (m_currentNode.getAttribute("isSearch")) isSearch = true; //Send load command adminCom.GetObjChildren(sObjName, sortType, this.HandleGetChildrenResponse, isSearch); return true; //Load the children } this.HandleGetChildrenResponse = function(response) { if (response.getNode("error")) { switch (response.getString("error")) { case "PassportExpired": location.href = location.pathname + "?b_action=cogadmin"; break; default: m_oEventHandler.F_HideProgressDialog(); D_MsgBox.F_Show(null,response.getString("error")," ",D_MsgBox.K_iError); break; } } else { var content = response.getNode("Content"); if (content && content.getChildren() && content.getChildren().length) { //Sort the children of content in alphabetical order content.sortChildren(); var children = content.getChildren(); //Re-order the content as folders and packages first, then reports. var contentArray = new Array(); var sortType = SORT_DEF; if (m_currentNode.getAttribute("sort")) sortType = m_currentNode.getAttribute("sort"); for (var i = 0; i < children.length; i++) { // User var classType = response.getString("Content." + children[i].name + ".Properties.objectClass",""); if (classType == "user") { contentArray[contentArray.length] = children[i]; } } for (var i = 0; i < children.length; i++) { //Packages and folders var classType = response.getString("Content." + children[i].name + ".Properties.objectClass",""); if (classType == "package" || classType == "folder") { contentArray[contentArray.length] = children[i]; } } for (var i = 0; i < children.length; i++) { //Reports var classType = response.getString("Content." + children[i].name + ".Properties.objectClass",""); if (classType == "powerPlay8Report") { contentArray[contentArray.length] = children[i]; } } for (var i = 0; i < children.length; i++) { //Others var classType = response.getString("Content." + children[i].name + ".Properties.objectClass",""); if (classType != "powerPlay8Report" && classType != "package" && classType != "folder" && classType != "user") { contentArray[contentArray.length] = children[i]; } } //We now have an ordered list of children containing packages and folders first. //Now populate the tree for (var i = 0; i < contentArray.length; i++) { var objName = decodeURIComponent(contentArray[i].name); var uniqueID = response.getString("Content." + contentArray[i].name + ".Properties.objectID",""); var classType = response.getString("Content." + contentArray[i].name + ".Properties.objectClass",""); var node = m_currentNode.appendChild( m_currentNode.ownerDocument.createElement( "treeNode" ) ); node.setAttribute( "label", objName ); node.setAttribute( "objName", uniqueID ); node.setAttribute( "hideCheckbox" , "true" ); node.setAttribute( "classType" , classType ); switch (classType) { case "package": { node.setAttribute( "expandable", "true" ); node.setAttribute( "smallIcon", "hal/../ps/portal/images/icon_package.gif" ); node.setAttribute( "sort", sortType); } break; case "folder": { node.setAttribute( "expandable", "true" ); node.setAttribute( "smallIcon", "hal/../ps/portal/images/icon_folder.gif" ); node.setAttribute( "sort", sortType); } break; case "powerPlay8Report": { node.setAttribute( "expandable", "false" ); node.setAttribute( "smallIcon", "hal/../ps/portal/images/icon_pp8_report.gif" ); } break; case "content": { node.setAttribute( "expandable", "true" ); node.setAttribute( "smallIcon", "hal/../ps/portal/images/icon_publicfolder.gif" ); } break; case "user": { node.setAttribute( "expandable", "false" ); node.setAttribute( "smallIcon", "hal/../ps/portal/images/icon_user.gif" ); } break; } } } m_currentTreeView.F_EndAsyncLoad( true ); if (m_currentNode.tagName == "treeView") { m_currentTreeView.F_Draw(); m_oEventHandler.F_HideProgressDialog(); m_oEventHandler.F_TreeInitialized(); } } } /** * * Sorts or Refreshes the contents of a folder. * * @param {String} userRequest "ascending" or "descending" for sorts, blank for refresh * */ this.ContextWindowRequest = function(userRequest){ var sortType = parseInt(m_currentNode.getAttribute("sort")); if (userRequest == 0 || userRequest == 1 || userRequest == 2) sortType = parseInt(userRequest); m_currentNode.setAttribute("sort", sortType); m_currentTreeView.F_DrawNode(m_currentNode); } }