123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- // 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);
- }
-
- }
|