| |
| // define the class here so we don't need to load the detail implementations |
| function ProcessElementPage() { |
| |
| this.par_proc = null; |
| this.par_path = null; |
| |
| // images for the activity, generated dynamically when publishing |
| this.imageFiles = []; |
| |
| // suppressed items for the activity, generated dynamically when publishing |
| this.suppressedItems = []; |
| |
| // element urls for the activity, generated dynamically when publishing |
| this.elementUrls = []; |
| |
| this.treeTable = null; |
| |
| }; |
| |
| ProcessElementPage.prototype.init = function(hasTree) { |
| |
| var parameters = contentPage.getUrlParameters(contentPage.queryStr.substring(1)); |
| this.par_proc = parameters["proc"]; |
| this.par_path = parameters["path"]; |
| if ( this.par_proc == null || this.par_path == null ) { |
| parameters = contentPage.getUrlParameters(contentPage.defaultQueryStr.substring(1)); |
| this.par_proc = parameters["proc"]; |
| this.par_path = parameters["path"]; |
| } |
| |
| if ( hasTree) { |
| this.createTree(contentPage.imgPath); |
| } |
| }; |
| |
| ProcessElementPage.prototype.createTree = function(imgPath) { |
| this.treeTable = new ActivityTreeTable(this); |
| this.treeTable.initialize(imgPath); |
| }; |
| |
| ProcessElementPage.prototype.fixTabUrl = function(a) |
| { |
| if (a == null || queryStr == null ) return; |
| var url = a.getAttribute("href") + queryStr; |
| |
| a.setAttribute("href", url); |
| } |
| |
| |
| ProcessElementPage.prototype.getActivityItemUrl = function(url, process, elementProcessPath, relProcessPath) |
| { |
| queryString = "?proc=" + process + "&path=" + elementProcessPath + relProcessPath; |
| return contentPage.resolveUrl(url) + queryString; |
| |
| }; |
| |
| ProcessElementPage.prototype.getDiagramImageUrl = function(process, elementProcessPath, diagramType) |
| { |
| // get the diagram image file for the specified element path and process |
| // retutns null if noting |
| // diagram type is Activity, ActivityDetail, |
| //alert("get " + diagramType + " diagram for " + elementProcessPath); |
| return contentPage.resolveUrl(this.imageFiles[elementProcessPath+diagramType]); |
| }; |
| |
| ProcessElementPage.prototype.isSuppressed = function(process, elementProcessPath) |
| { |
| flag = (this.suppressedItems[elementProcessPath] == true); |
| //if ( flag ) alert("got one: " + elementProcessPath); |
| |
| return flag; |
| }; |
| |
| ProcessElementPage.prototype.buildTeamTree = function(teamTree) { |
| |
| var el = document.getElementById("teamTree"); |
| if ( el == null ) return; |
| |
| if ( teamTree == null || teamTree.length == 0 ) { |
| return; |
| } |
| |
| teamTree[0][0] = teamTree[0][0].replace(/(\'|\")/g, "\\$1"); |
| |
| var teamBuffer = ""; |
| for ( var i = 0; i < teamTree.length; i++ ) { |
| |
| if ( !this.isTeamSuppressed(teamTree[i]) ) { |
| teamBuffer += "<div class=\"teamStructure\" align=\"left\">"; |
| teamBuffer += this.getTeamTreeHtml(teamTree[i]); |
| teamBuffer += "</div><br/>"; |
| } |
| |
| } |
| |
| //alert(teamBuffer); |
| //document.write(teamBuffer); |
| el.innerHTML = teamBuffer; |
| }; |
| |
| |
| // format is [url, title, relPath, suppressed] |
| ProcessElementPage.prototype.getTeamTreeHtml = function(teamTree) { |
| |
| if ( teamTree == null || teamTree.length < 4) { |
| return ""; |
| } |
| |
| var url = teamTree[0]; |
| var title = teamTree[1]; |
| var relPath = teamTree[2]; |
| |
| url = this.getActivityItemUrl(url, this.par_proc, this.par_path, relPath); |
| |
| var teamBuffer = "<a href=\"" + url + "\">" + title + "</a>"; |
| |
| if ( teamTree.length > 4 && teamTree[4] != null && teamTree[4] != "" && teamTree[4] != undefined ) { |
| teamBuffer += "<ul>"; |
| for ( var i = 4; i < teamTree.length; i++ ) { |
| if (typeof teamTree[i] == "object" && !this.isTeamSuppressed(teamTree[i]) ) { |
| |
| teamBuffer += "<li>"; |
| teamBuffer += this.getTeamTreeHtml(teamTree[i]); |
| teamBuffer += "</li>"; |
| } |
| } |
| teamBuffer += "</ul>"; |
| } |
| |
| return teamBuffer; |
| }; |
| |
| ProcessElementPage.prototype.isTeamSuppressed = function(teamTree) { |
| |
| if ( teamTree == null || teamTree.length < 4) { |
| return true; |
| } |
| |
| var relPath = teamTree[2]; |
| var sup = teamTree[3]; |
| |
| if ( sup == "" ) { |
| return this.isSuppressed(this.par_proc, this.par_path + relPath); |
| } else { |
| return (sup == "true"); |
| } |
| |
| }; |
| |
| ProcessElementPage.prototype.buildProcessElementBreadCrumb = function(url, backPath) { |
| |
| var div = document.getElementById("breadcrumbs"); |
| if ( div == null ) return; |
| |
| var linksText = ""; |
| var start = 0; |
| var viewFrame = contentPage.getViewFrame(); |
| |
| if (viewFrame != null && viewFrame.getBreadcrumbsHtml ) { |
| linksText = viewFrame.getBreadcrumbsHtml(url); |
| if ( linksText != null && linksText != "" ) { |
| start = 999; |
| } else if ( viewFrame.getBreadcrumbsHtmlByGuid ) { |
| linksText = viewFrame.getBreadcrumbsHtmlByGuid(this.par_proc); |
| start = 1; |
| } |
| } |
| //alert(start); |
| var paths = this.par_path.split(","); |
| |
| if ( start < paths.length ) { |
| var path = ""; |
| for (var i = 0; i < paths.length; i++) { |
| var guid = paths[i]; |
| if ( path != "" ) path += ","; |
| path += guid; |
| if ( i < start ) continue; |
| |
| var text = this.getProcessElementLinkHtmlFromId(guid, path, backPath); |
| if ( text != "" ) { |
| if ( linksText != "" ) { |
| linksText += " > "; |
| } |
| |
| linksText += text; |
| } |
| } |
| } |
| |
| var html = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">" |
| + "<tr><td align=\"right\">" + linksText + "</td><tr>" |
| + "</table>"; |
| div.innerHTML = html; |
| |
| }; |
| |
| |
| ProcessElementPage.prototype.getProcessElementLinkHtmlFromId = function(guid, elementPath, backPath) { |
| |
| var str = ""; |
| var item = this.elementUrls[guid]; |
| if ( item != null ) { |
| var text = item[0]; |
| var url = backPath + item[1]; |
| |
| url = this.getActivityItemUrl(url, this.par_proc, elementPath, ''); |
| |
| // escape the quotes |
| url = url.replace(/'/g, "\\'"); |
| url = url.replace(/\"/g, "\\\""); |
| |
| str = "<a href=\"" + url + "\">" + text + "</a>"; |
| } |
| |
| |
| return str; |
| }; |
| |