/** * the container where the list process instance preview is placed on the process list */ var processListInstancePreviewContainer = "process_list_instance_preview"; /** * the container for the instance preview data, inside the processListInstancePreviewContainer */ var instanceContainer = "process_list_instance_preview_container"; /** * the navigation container for the preview */ var instanceContainerNavigation = "process_list_instance_preview_container_navigation"; /** * Ajax call to get the data of a given process instance to be viewed on the process list */ function previewInstance(instanceId, viewId){ var txturl = "ajax.do" var params = "function=de.tto.monitoring.get.instance.preview&value=" + instanceId + "&processId=" + viewId + "#preview_instance"; var callback = handleInstanceResponse; $(process_list_instance_preview).update("
"); CommonUtils.showLoader("Loading..."); // highlight row highlightSelectedListRow(instanceId); // init request as last step because sometimes it is faster than js is preparing the content target initRequest('get', txturl, params, callback); } /** * closes the list instance preview */ function closeInstancePreview(){ var previewBox = $(process_list_instance_preview); var innerContainer = $(instanceContainer); if(previewBox && innerContainer){ previewBox.removeChild(innerContainer); // restore background color of all rows highlightSelectedListRow(-1); } } /** * get the response xml from ajax request for process instance */ function handleInstanceResponse(request){ var columnCount = 3; var mobile = false; inlineAttributes = new Array(); var xmlResponse = request.responseXML; var previewBox = $(process_list_instance_preview); if(xmlResponse && previewBox){ var result = "
"; result += "
"; /* Add the Navigation for the preview... */ /* ##################################### */ result += "
" result += "
"; result += "
"; result += "
"; result += "
"; /* ##################################### */ var attributeGroups = xmlResponse.getElementsByTagName("attributeGroup"); var anchor = "instance_preview"; result += ""; result += ""; if (attributeGroups && attributeGroups.length > 0) { var attributeGroupsLength = attributeGroups.length; for (var g = 0; g < attributeGroupsLength; g++) { var attributeGroup = attributeGroups[g]; var groupName = "N/A"; var groupDescription = "N/A"; var groupAttributes = attributeGroup.attributes; if(groupAttributes){ var gAttLength = groupAttributes.length; for(var j=0; j" + groupName + ""; result += ""; result += ""; var recordAttributes = attributeGroup.getElementsByTagName("attribute"); var counter = 1; var recordAttributesLength = recordAttributes.length; for(var i=0; i" + name + ""; if(counter == columnCount || i+1 == recordAttributesLength){ result += ""; counter = 0; } counter++; } } } } result += "
" + value + "
"; var tasks = xmlResponse.getElementsByTagName("task"); var tasksLength = tasks.length; if(tasksLength > 0){ result += ""; result += ""; result += ""; result += ""; result += ""; result += ""; result += ""; result += ""; if (!mobile) result += ""; result += ""; result += ""; result += ""; for(var i=0; i"; result += ""; result += ""; result += ""; if (!mobile) result += ""; result += ""; } } result += ""; result += "
" + MessageProperties.PROCESS_LIST_INSTANCE_PREVIEW_TASKS + "
" + MessageProperties.COMMON_ID + "" + MessageProperties.COMMON_STATUS + "" + MessageProperties.COMMON_BPTS + "" + MessageProperties.COMMON_NAME + "" + MessageProperties.COMMON_DESCRIPTION + "
"; if (icon && icon != "") { result += ""; } result += ""; result += "" + bpts + "" + name + "" + descr + "
"; } result += "
"; result += "
"; previewBox.update(result); CommonUtils.clearLoaderDelayed(1000); // jump to named anchor window.location.hash=anchor; } if (inlineAttributes) { var length = inlineAttributes.length; if (length > 0) { for (var i = 0; i < length; i++) { var ids = inlineAttributes[i]; InlineCallValue.showRecordAttributeInlineValue(ids[0], ids[1]); } } } } /* ###### Functions for Tree Preview of a Record ######################## */ var instance_tree_preview_area; var recordTreePreviewContainerPrefix = "record_tree_preview_container_"; function showRecordTreePreview(where, recordId, viewId){ instance_tree_preview_area = where; var container = $(where); var innerContainerName = recordTreePreviewContainerPrefix +"_" + where; var innerContainer = $(innerContainerName); var closingAnchor = "closing_anchor"; // the anchor name where to jump to when closing a process instance preview if(container && innerContainer){ innerContainer.parentNode.removeChild(innerContainer); // jump to named anchor window.location.hash=closingAnchor; } else { var txturl = "ajax.do" var params = "function=de.tto.monitoring.get.instance.preview&value=" + recordId + "&processId=" + viewId ; var callback = handleTreePreviewResponse; initRequest('get', txturl, params, callback); CommonUtils.showLoader("Loading..."); } } function handleTreePreviewResponse(request){ var xmlResponse = request.responseXML; if(xmlResponse){ var innerContainerName = recordTreePreviewContainerPrefix + "_" + instance_tree_preview_area; var anchorName = "anchor_" + innerContainerName; var result = ""; result += "
"; result += ""; var instance_preview_value = ""; var instance_preview_id = ""; var instance_preview_viewId = ""; var instance_preview_viewName = ""; var data = xmlResponse.getElementsByTagName("data"); if (data && data.length > 0) { var valueElem = data[0].getElementsByTagName("value"); if (valueElem && valueElem.length > 0) { var attributes = valueElem[0].attributes; if(attributes){ var tmp = valueElem[0].getAttribute('value'); if (tmp) instance_preview_value = tmp; } } var idElem = data[0].getElementsByTagName("id"); if (idElem && idElem.length > 0) { var attributes = idElem[0].attributes; if(attributes){ var tmp = idElem[0].getAttribute('value'); if (tmp) instance_preview_id = tmp; } } var viewElem = data[0].getElementsByTagName("view"); if (viewElem && viewElem.length > 0) { var attributes = viewElem[0].attributes; if(attributes){ var tmp = viewElem[0].getAttribute('value'); if (tmp) instance_preview_viewId = tmp; } } var nameElem = data[0].getElementsByTagName("viewName"); if (nameElem && nameElem.length > 0) { var attributes = nameElem[0].attributes; if(attributes){ var tmp = nameElem[0].getAttribute('value'); if (tmp) instance_preview_viewName = tmp; } } } var title = MessageProperties.COMMON_PREVIEW + " | " + instance_preview_viewName + " | " + instance_preview_value; var header = ""; header += ""; header += ""; var content = ""; var tasks = xmlResponse.getElementsByTagName("task"); var tasksLength = tasks.length; var tasksAvailable = 0; for(var i=0; i"; if (icon && icon != "") { content += ""; } content += ""; content += ""; } } if(tasksAvailable == 1){ result += header; result += content; } else { result += ""; result += ""; result += ""; result += ""; } result += "
" + title + "
" + MessageProperties.COMMON_STATUS + "" + MessageProperties.COMMON_NAME + "" + MessageProperties.COMMON_DESCRIPTION + "
" + name + "" + descr + "
" + MessageProperties.PROCESS_LIST_INSTANCE_PREVIEW_NO_TASKS + "
"; result += "
"; $(instance_tree_preview_area).update(result); // jump to named anchor window.location.hash=anchorName; // stop the loader CommonUtils.clearLoaderDelayed(1000); } } var height = 250; var width = 400; function changeChartSize(value, chartType, target){ if(value == "+"){ height = height + 40; width = width + 80; } else { if(height >= 200){ height = height - 40; width = width - 80; } } } /* ###### Functions for TimeRange Input ################################# */ var datePreferencesBoxName = "date_preferences_box"; var datePreferencesBoxFooterName = "date_preferences_box_footer"; var datePreferencesBoxTitle = "date_preferences_box_title"; var datePreferencesBoxContent = "date_preferences_box_content"; /* * function to show the form where the user can specify his date preferences */ function showDatePreferences(where, webAppContext){ var area = $(where); var dateBox = $(datePreferencesBoxName); var dateBoxFooter = $(datePreferencesBoxFooterName); if(area && dateBox){ // if both are avialable, the remove it area.removeChild(dateBox); area.removeChild(dateBoxFooter); } else if(area){ // if only area is available, add input fields... $(area).update("
" + renderDatePreferences(where, webAppContext) + "
"); } } /* * Build a table to show the users date preferences form. * The user can now modifiy his preferences regarding date / time of the lists etc. * @param where - the container where to place the date preferences * @param webAppContext - the web app context * Theses parameters are only used here to use them on the cancel button to savely remove the popup from the page if cancel is pressed ! */ function renderDatePreferences(where, webAppContext){ //alert("0 | 0 | 0 | 0 \n 0 | 0 | 0 | 0"); var html = "
" + MessageProperties.DATE_PREFERENCES_TITLE + "
"; html += "
"; html += '
'; html += ""; html += ""; html += ""; html += ""; html += ''; html += '"; html += ""; html += ""; html += ""; html += ''; html += '"; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += ""; html += "
 
" + MessageProperties.COMMON_START + "'; html += ""; html += ''; html += "
" + MessageProperties.COMMON_END + "'; html += ""; html += ''; html += "
" + MessageProperties.COMMON_START + ""; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_DAYS + " "; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_HOURS + " "; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_MINUTES + " "; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_SECONDS + " 
" + MessageProperties.COMMON_END + ""; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_DAYS + " "; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_HOURS + " "; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_MINUTES + " "; html += '"; html += "" + MessageProperties.DATE_PREFERENCES_SECONDS + " 
" + MessageProperties.DATE_PREFERENCES_TIMESPAN + ""; html += '"; html += "
"; html += ' '; html += " "; html += "
"; html += '
'; html += "
"; return html; } /** * this funtion is used to set the date input fields to the values that have been chosen * via the time range dropdown (this qarter, this week...) */ function updateTimeRangeField(){ if(document.date_preferences_form){ var dateForm = document.date_preferences_form; if(dateForm){ var dateRangeBox = dateForm.dateRange; if(dateRangeBox){ var value = dateRangeBox.options[dateRangeBox.selectedIndex].value; if(value){ dateForm.startDate.value = value; dateForm.endDate.value = value; } } var formElements = dateForm.elements; if(formElements){ for(var i=0; i 0) { var l = cells.length; for (var i = 0; i < l; i++) { if (cells[i] && cells[i].id == attributeName+"TaskColumn") { SortAttributesOnDateilPage.columnIndex = i; break; } } } } if (SortAttributesOnDateilPage.columnIndex > -1) { var rows = new Array(); var attributeRows = new Array(); var tableRows = table.tBodies[0].rows; if (tableRows && tableRows.length > 0) { var l = tableRows.length; var start = false; for (var i = 0; i < l; i++) { if (tableRows[i]) { if (tableRows[i].id.indexOf('task_attributes_') > -1) { var eventId = tableRows[i].id.substring(16, tableRows[i].id.lastIndexOf("_")); attributeRows[eventId] = tableRows[i]; } else { rows.push(tableRows[i]); } } } } if (attributeName == 'id') rows.sort(SortAttributesOnDateilPage.sortByNumber); else if (attributeName == 'bpts' || attributeName == 'datetime' || attributeName == 'modified') rows.sort(SortAttributesOnDateilPage.sortByDate); else rows.sort(SortAttributesOnDateilPage.sortByText); var l = rows.length; var bgcolor="#E6E6E6"; for (var i = 0; i < l; i++) { rows[i].style.background = bgcolor; if (bgcolor == "#E6E6E6") bgcolor = "#FFFFFF"; else bgcolor="#E6E6E6"; var lc = rows[i].cells.length; for (var j = 0; j < lc; j++) { rows[i].cells[j].className = ""; } rows[i].cells[SortAttributesOnDateilPage.columnIndex].className = "table_sorted"; table.tBodies[0].appendChild(rows[i]); var eventId = rows[i].id.substring(5, rows[i].id.lastIndexOf("_")); if (attributeRows[eventId]) { table.tBodies[0].appendChild(attributeRows[eventId]); } } //remove sort icon from header cells var headerCells = header.cells; var l = headerCells.length; for (var i = 0; i < l; i++) { var hasLabel = false; var cell = headerCells[i]; var childs = cell.childNodes; var child = null; if (childs && childs.length > 0) { var cl = childs.length; for (var j = 0; j < cl; j++) { if (childs[j].tagName && childs[j].tagName.toUpperCase() == "SPAN") { child = childs[j]; break; } } } if (child && child != null) { var innerHTML = ""; innerHTML += " 0) { var al = attributes.length; for (var j = 0; j < al; j++) { var attributeName = attributes[j].nodeName; var attributeValue = attributes[j].nodeValue; if (attributeName == 'title') { if (SortAttributesOnDateilPage.direction == 1) { attributeValue = 'Sort descending'; } else { attributeValue = 'Sort ascending'; } } innerHTML += attributeName+"=\""+attributeValue+"\" "; } } innerHTML += ">"; childs = child.childNodes; if (childs && childs.length > 0) { var cl = childs.length; for (var j = 0; j < cl; j++) { if (childs[j] && childs[j].nodeType == 3) { innerHTML +=childs[j].nodeValue; } } } innerHTML += ""; if (innerHTML) cell.innerHTML = innerHTML; } } //add sort icon to sorted header cell var sortedCell = headerCells[SortAttributesOnDateilPage.columnIndex]; if (sortedCell) { var image = ""; if (SortAttributesOnDateilPage.direction == 1) { image = " "; } else { image = " "; } var innerHTML = sortedCell.innerHTML; innerHTML = image + innerHTML; sortedCell.innerHTML = innerHTML; } } if (SortAttributesOnDateilPage.direction == 1) SortAttributesOnDateilPage.direction = 0; else SortAttributesOnDateilPage.direction = 1; } }, sortByNumber : function(rowA, rowB) { if (SortAttributesOnDateilPage.direction == 1) return SortAttributesOnDateilPage.getInnerText(rowA.cells[SortAttributesOnDateilPage.columnIndex]) - SortAttributesOnDateilPage.getInnerText(rowB.cells[SortAttributesOnDateilPage.columnIndex]); else return SortAttributesOnDateilPage.getInnerText(rowB.cells[SortAttributesOnDateilPage.columnIndex]) - SortAttributesOnDateilPage.getInnerText(rowA.cells[SortAttributesOnDateilPage.columnIndex]); }, sortByText : function(rowA, rowB) { var value1 = ""; var value2 = ""; if (SortAttributesOnDateilPage.direction == 1) { value1 = SortAttributesOnDateilPage.getInnerText(rowA.cells[SortAttributesOnDateilPage.columnIndex]); value2 = SortAttributesOnDateilPage.getInnerText(rowB.cells[SortAttributesOnDateilPage.columnIndex]); } else { value1 = SortAttributesOnDateilPage.getInnerText(rowB.cells[SortAttributesOnDateilPage.columnIndex]); value2 = SortAttributesOnDateilPage.getInnerText(rowA.cells[SortAttributesOnDateilPage.columnIndex]); } if (value1==value2) { return 0; } if (value1 0) hour1 += 12; if (time2.indexOf("PM") > 0) hour2 += 12; } if (year1year2) { return 1; } if (month1month2) { return 1; } if (day1day2) { return 1; } if (hour1hour2) { return 1; } if (minute1minute2) { return 1; } if (second1second2) { return 1; } return 0; }, getInnerText : function(element) { if (typeof element == "string") return element; if (typeof element == "undefined") { return element }; if (element.innerText) return element.innerText; //Not needed but it is faster var str = ""; var childs = element.childNodes; var l = childs.length; for (var i = 0; i < l; i++) { switch (childs[i].nodeType) { case 1: //ELEMENT_NODE if (childs[i].tagName.toUpperCase() == "IMG") { str += childs[i].src; } else { str += SortAttributesOnDateilPage.getInnerText(childs[i]); } break; case 3: //TEXT_NODE str += childs[i].nodeValue; break; } } return str; } };