/**************************************************************** ** Licensed Materials - Property of IBM ** ** BI and PM: qs ** ** (C) Copyright IBM Corp. 2001, 2015 ** ** US Government Users Restricted Rights - Use, duplication or ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *****************************************************************/ // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others. function init() { attachMouseEvents(); if (cf.dlgGlobalGetParm('xxCVColumnName') != null) document.f.calc_label_text.value = cf.dlgGlobalGetParm('xxCVColumnName'); if (WO1076_flag) { var MQ = cf.cfgGet('MiniQueryObj'); var columns = MQ.getElementsByTagName('Column'); var columnIdx = parseInt(cf.dlgGlobalGetParm('xxColumnIndex'),10); var c = columns[columnIdx]; var ge = c.getElementsByTagName('GroupExpression'); if (ge && ge.length) { MQge = ge[0]; var ce = cf.sXmlDecode(MQge.getAttribute('columnExpr')); cf.dlgGlobalSetParm('xxColumnExpression',ce); var cn = ce.replace(/.*\[/gi,'').replace(/\]\s*$/,''); cf.dlgGlobalSetParm('xxColumnName',cn); var FEs = MQge.getElementsByTagName('FE'); for (var i=0;i0;i--) { if (FEs[i].getAttribute('default')=='true') { if (FEs[i].getAttribute('label')) { document.f.range_name_text.value = cf.sXmlDecode(FEs[i].getAttribute('label')); document.f.remaining_values_options[2].checked = true; } else if (FEs[i].getAttribute('nullOption')=='include'){ document.f.remaining_values_options[1].checked = true; } break; } } } else { if (cf.dlgGlobalGetParm('xxExistingRemainingGroup') == false) document.f.remaining_values_options[1].checked = true else { if (cf.dlgGlobalGetParm('xxExistingRemainingGroup') == null) document.f.remaining_values_options[0].checked = true; else { document.f.range_name_text.value = cf.dlgGlobalGetParm('xxExistingRemainingGroup'); document.f.remaining_values_options[2].checked = true; } } } showHideApplyRemaining(false); }; function execute() { var usingXMLFilter = false; var before_col_id = cf.dlgGlobalGetParm('xxInsBeforeColId'); var calcExpr = ""; var calcFormat = "none"; var calcOp = "none"; var colName = cf.dlgGlobalGetParm('xxColumnName'); var colExp = cf.dlgGlobalGetParm('xxColumnExpression'); if (cf.dlgGlobalGetParm('xxCustomType') == '0') calcOp = "groupString"; else if (cf.dlgGlobalGetParm('xxCustomType') == '1') calcOp = "groupNumber"; var isFirst = true; var ifOutput = false; var XMLFilters = new Array(); for (var i = 0; i < customGroupValues.length; i++) { var thisCalcExpr = ""; if (typeof customGroupValues[i] == "object") { var arrayName = getCustomGroupValues(i); if (arrayName.length > 0) { if (arrayName[0] instanceof cf.CFilterValue) { usingXMLFilter = true; var fe = new cf.CFilterExpression(); fe.setLabel(customGroupNames[i].replace(/''/g, "'")); if (cf.dlgGlobalGetParm('xxUseMUN') == true) { if (cf.determineDataType(dataType) == 0) fe.setDataType('number'); else fe.setDataType('MUN'); } else if (cf.dlgGlobalGetParm('xxCustomType') == '0') fe.setDataType('string'); for (var j = 0; j < arrayName.length; j++) fe.addValue(arrayName[j]); XMLFilters[XMLFilters.length] = fe; } else { if (isFirst) { thisCalcExpr = "if ("; isFirst = false; } else thisCalcExpr += " else if ("; if (calcOp != "groupString") { if(gsCustomGroups == "TRUE") thisCalcExpr += "CAST(" + colExp + " as varchar(30)) in ("; else thisCalcExpr += "CAST(" + colExp + " as nvarchar(30)) in ("; } else thisCalcExpr += colExp + " in ("; var isFirstVal = true; for (var j = 0; j < arrayName.length; j++) { if (isFirstVal) isFirstVal = false; else thisCalcExpr += ","; thisCalcExpr += "'" + arrayName[j] + "'"; ifOutput = true; } if(gsCustomGroups == "TRUE") thisCalcExpr += ")) then (CAST('" + customGroupNames[i] + "' as varchar(30)))"; else thisCalcExpr += ")) then (CAST('" + customGroupNames[i] + "' as nvarchar(30)))"; } } calcExpr += thisCalcExpr; } } if (usingXMLFilter) { if (document.f.remaining_values_options[1].checked == true) { var fe = new cf.CFilterExpression(); fe.setNullOption('include'); fe.setDefault(true); if (cf.dlgGlobalGetParm('xxUseMUN') == true) { if (cf.determineDataType(dataType) == 0) fe.setDataType('number'); else fe.setDataType('MUN'); } else if (cf.dlgGlobalGetParm('xxCustomType') == '0') fe.setDataType('string'); XMLFilters[XMLFilters.length] = fe; } else if (document.f.remaining_values_options[2].checked == true) { var fe = new cf.CFilterExpression(); fe.setLabel(document.f.range_name_text.value); fe.setDefault(true); if (cf.dlgGlobalGetParm('xxUseMUN') == true) { if (cf.determineDataType(dataType) == 0) fe.setDataType('number'); else fe.setDataType('MUN'); } else if (cf.dlgGlobalGetParm('xxCustomType') == '0') fe.setDataType('string'); XMLFilters[XMLFilters.length] = fe; } calcExpr = ''; for (var i = 0; i < XMLFilters.length; i++) calcExpr += XMLFilters[i].getXML(); calcExpr += ''; } else { if (ifOutput) calcExpr += " else ("; else if (document.f.group_names.options.length == 0) { var oMQMgr = goDialogManager.getMiniQueryManager(); var oMQCols = oMQMgr.getElementsByAttribute("expression", colExp); if (oMQCols.length > 0 && oMQMgr.isNumeric(oMQCols[0])) { calcExpr = "if (" + colExp + " in_range {1:0}) then (null) else ("; } else { calcExpr = "if (" + colExp + " in ('')) then (null) else ("; } } if (calcExpr != "") { if (document.f.remaining_values_options[0].checked == true) { if (cf.dlgGlobalGetParm('xxCustomType') == 0) calcExpr += colExp; else { if(gsCustomGroups == "TRUE") calcExpr += "CAST(" + colExp + " as varchar(30))"; else calcExpr += "CAST(" + colExp + " as nvarchar(30))"; } } else if ((document.f.remaining_values_options[1].checked == true) || (document.f.remaining_values_options[2].checked == true && document.f.range_name_text.value == "")) calcExpr += "null"; else { if(gsCustomGroups == "TRUE") calcExpr += "CAST('" + document.f.range_name_text.value.replace(/'/g, "''") + "' as varchar(30))"; else calcExpr += "CAST('" + document.f.range_name_text.value.replace(/'/g, "''") + "' as nvarchar(30))"; } calcExpr += ")"; } } if (calcExpr != "") { if (document.f.calc_label_text.value != "") sCalcName = document.f.calc_label_text.value; else sCalcName = stringReplace (sCalcName, "\\^0", colName); if (cf.dlgGlobalGetParm('xxExistingCol') != null) { var cmd = cf.generateReplaceExpressionCmd(calcExpr, calcExpr, calcOp); cmd += ";" + cf.generateNcCmd(cf.dlgGlobalGetParm('xxColumnIndex'), sCalcName) var oMQMgr = goDialogManager.getMiniQueryManager(); if(oMQMgr && oMQMgr.getPageBreak()) cmd+=";OP:"; cf.sendCmd(cmd, "", true); } else cf.addCalcColumn(before_col_id, calcExpr, calcExpr, sCalcName, "none", calcOp, "none", "none", dataType, 7, "none", -1, "none"); } else cf.hideDialogFrame(); }; function stringReplace (origString, valToReplace, newString) { var strRegExp = new RegExp(); strRegExp.compile(valToReplace, "g"); return origString.replace(strRegExp, newString); }; function setupDataType(newDataType) { var iDataType = cf.getDataTypeFromString(newDataType); if (iDataType != -1) dataType = iDataType; }; function removeFromAvailableValues(incommingValue) { var u = incommingValue; if (u instanceof cf.CFilterValue){u=u.getUse();} for (var i = 0; i < document.f.available_values.options.length; i++) { if (document.f.available_values.options[i].value == u) { document.f.available_values.options[i] = null; return; } } }; function createOrAddToCustomGroupWithValue(grpName, grpVal) { var newGroupSlot = -1; var i; for (i = 0; i < customGroupNames.length; i++) { if (customGroupNames[i] == grpName) { newGroupSlot = i; break; } } if (newGroupSlot == -1) { newGroupSlot = customGroupNames.length customGroupNames[newGroupSlot] = grpName; document.f.group_names.options[document.f.group_names.options.length] = new Option(grpName.replace(/''/g, "'"), grpName.replace(/''/g, "'")); } if (grpVal != "") { if (typeof customGroupValues[newGroupSlot] != "object") customGroupValues[newGroupSlot] = new Array(); customGroupValues[newGroupSlot][customGroupValues[newGroupSlot].length] = grpVal; if (cf.dlgGlobalGetParm('xxAdvanced') == '0') { if (typeof grpVal == 'string') grpVal = grpVal.replace(/''/g, "'"); removeFromAvailableValues(grpVal); } } }; function addToCustomGroup(newValue) { if (typeof customGroupValues[customGroupSelectedIndex] != "object") { customGroupValues[customGroupSelectedIndex] = new Array(); var newGroup = document.f.group_names.options[customGroupSelectedIndex].text; newGroup = newGroup.replace(/'/g, "''"); customGroupNames[customGroupSelectedIndex] = newGroup; } else { for (var i = 0; i < customGroupValues[customGroupSelectedIndex].length; i++) { if (typeof customGroupValues[customGroupSelectedIndex][i] == "undefined") { if (typeof newValue == 'string') newValue = newValue.replace(/'/g, "''"); customGroupValues[customGroupSelectedIndex][i] = newValue; return; } } } if (typeof newValue == 'string') newValue = newValue.replace(/'/g, "''"); customGroupValues[customGroupSelectedIndex][customGroupValues[customGroupSelectedIndex].length] = newValue; }; function getCustomGroupValues(arrayIndex) { var tempArray = new Array(); if (typeof customGroupValues[arrayIndex] == "object") { for (var i = 0; i < customGroupValues[arrayIndex].length; i++) { if (typeof customGroupValues[arrayIndex][i] != "undefined") tempArray[tempArray.length] = customGroupValues[arrayIndex][i]; } } return tempArray; }; function removeFromCustomGroup(oldValue) { for (var i = 0; i < customGroupValues[customGroupSelectedIndex].length; i++) { var u = customGroupValues[customGroupSelectedIndex][i]; if (u instanceof cf.CFilterValue){u=u.getUse();} if (u==oldValue){ delete customGroupValues[customGroupSelectedIndex][i]; return; } } }; function reshuffleCustomGroupArray() { for (var i = customGroupSelectedIndex; i < (customGroupValues.length - 1); i++) customGroupValues[i] = customGroupValues[i + 1]; for (var i = customGroupSelectedIndex; i < (customGroupNames.length - 1); i++) customGroupNames[i] = customGroupNames[i + 1]; delete customGroupValues[customGroupValues.length - 1]; delete customGroupNames[customGroupNames.length - 1]; }; function addValue() { if (cf.dlgGlobalGetParm('xxAdvanced') == '0') { if (customGroupSelectedIndex > -1) { var iter = 0; while (iter < document.f.available_values.options.length) { if (document.f.available_values.options[iter].selected == true) { var displayValue = cf.getDisplayValueForOption(document.f.available_values.options[iter]); document.f.group_values.options[document.f.group_values.options.length] = new Option(displayValue, document.f.available_values.options[iter].value); if (WO1076_flag) { addToCustomGroup(new cf.CFilterValue(document.f.available_values.options[iter].value, displayValue)); } else { addToCustomGroup(document.f.available_values.options[iter].value); } document.f.available_values.options[iter] = null; } else iter++; } } else textBoxgroup_name.checkFail(); } else if (cf.dlgGlobalGetParm('xxCustomType') == '0' || cf.dlgGlobalGetParm('xxCustomType') == '1') { if (customGroupSelectedIndex <= -1 || document.f._textEditBoxcustom_value.value == "") textBoxgroup_name.checkFail(); else { document.f.group_values.options[document.f.group_values.options.length] = new Option(document.f._textEditBoxcustom_value.value, document.f._textEditBoxcustom_value.value); if (WO1076_flag) { addToCustomGroup(new cf.CFilterValue(document.f._textEditBoxcustom_value.value, document.f._textEditBoxcustom_value.value)); } else { addToCustomGroup(document.f._textEditBoxcustom_value.value); } } } }; function removeValue() { if (customGroupSelectedIndex > -1) { var iter = 0; while (iter < document.f.group_values.options.length) { if (document.f.group_values.options[iter].selected == true) { if (cf.dlgGlobalGetParm('xxAdvanced') == '0') document.f.available_values.options[document.f.available_values.options.length] = new Option(cf.getDisplayValueForOption(document.f.group_values.options[iter]), document.f.group_values.options[iter].value); removeFromCustomGroup(document.f.group_values.options[iter].value); document.f.group_values.options[iter] = null; } else iter++; } } }; function deleteFromCustomGroupsValues() { while (document.f.group_values.options.length) { if (cf.dlgGlobalGetParm('xxAdvanced') == '0') document.f.available_values.options[document.f.available_values.options.length] = new Option(cf.getDisplayValueForOption(document.f.group_values.options[0]), document.f.group_values.options[0].value); document.f.group_values.options[0] = null; } customGroupValues[customGroupSelectedIndex] = new Array(); delete customGroupNames[customGroupSelectedIndex]; }; function customGroupItemSelected() { customGroupSelectedIndex = document.f.group_names.selectedIndex; while (document.f.group_values.options.length) document.f.group_values.options[0] = null; var arrayVals = getCustomGroupValues(customGroupSelectedIndex); var i; for (i = 0; i < arrayVals.length; i++) { if (arrayVals[i] instanceof cf.CFilterValue) { document.f.group_values.options[document.f.group_values.options.length] = new Option(arrayVals[i].getDisplay(), arrayVals[i].getUse()); } else if (typeof arrayVals[i] == 'object') { document.f.group_values.options[document.f.group_values.options.length] = new Option(arrayVals[i][1], arrayVals[i][0]); } else { document.f.group_values.options[document.f.group_values.options.length] = new Option(arrayVals[i].replace(/''/g, "'"), arrayVals[i].replace(/''/g, "'")); } } }; function addGroup() { var group_name = textBoxgroup_name.sGetValue(); if (group_name != "") { var custom_groups = new Array(); var i; for (i = 0; i < document.f.group_names.options.length; i++) { if (group_name == document.f.group_names.options[i].value) return; } var newSlot = document.f.group_names.options.length; document.f.group_names.options[newSlot] = new Option(group_name, group_name); document.f.group_names.options[newSlot].selected = true; customGroupItemSelected(); } document.f._textEditBoxgroup_name.value = ""; }; function deleteCustomGroup() { if (document.f.group_names.selectedIndex >= 0) { deleteFromCustomGroupsValues(); reshuffleCustomGroupArray(); document.f.group_names.options[document.f.group_names.selectedIndex] = null; customGroupSelectedIndex = -1; } }; function selectAll(arrayName) { for (i = 0; i < eval("document.f." + arrayName + ".options.length"); i++) eval("document.f." + arrayName + ".options[" + i + "].selected = true"); }; function deselectAll(arrayName) { for (i = 0; i < eval("document.f." + arrayName + ".options.length"); i++) eval("document.f." + arrayName + ".options[" + i + "].selected = false"); }; function customTypeChange() { var customType = document.f.customizationType.value; if (customType == 1) { if (cf.dlgGlobalGetParm('xxExistingCol') == 'range') goDialogManager.getFeatureManager().launchFeature('CustomGroups'); else cf.loadCustomRange(); } }; function addToAvailableValues(useVal, displayVal) { if (useVal == "") return; if (!displayVal) displayVal = useVal; for (var i = 0; i < allAvailableValues.length; i++) { if (allAvailableValues[i][0] == useVal) return; } allAvailableValues[allAvailableValues.length] = [useVal, displayVal]; }; function sendRequestForList() { showLoading(); var url = "m=/" + cf.qs_dir + "/customizeGroupsRequest.xts&b_action=xts.run"; if (cf.dlgGlobalGetParm('xxColumnName')) url += "&xxColumnName=" + encodeURIComponent(cf.dlgGlobalGetParm('xxColumnName')); if (cf.dlgGlobalGetParm('xxModelName')) url += "&xxModelName=" + encodeURIComponent(cf.dlgGlobalGetParm('xxModelName')); for (var i = 0; i < cf.dlgGlobalSize('xxOtherColIds'); i++) url += "&xxOtherCols=" + cf.dlgGlobalConstructPairParm(url, encodeURIComponent(cf.dlgGlobalGetParmAt('xxOtherColIds', i)), encodeURIComponent(cf.dlgGlobalGetParmAt('xxOtherColExps', i))); if (cf.dlgGlobalGetParm('xxDesignMode')) url += "&xxDesignMode=" + encodeURIComponent(cf.dlgGlobalGetParm('xxDesignMode')); if (cf.dlgGlobalGetParm('xxColumnExpression')) url += "&xxColumnExpression=" + encodeURIComponent(cf.dlgGlobalGetParm('xxColumnExpression')); if (cf.dlgGlobalGetParm('xxDetailAggregateType')) url += "&xxDetailAggregateType=" + encodeURIComponent(cf.dlgGlobalGetParm('xxDetailAggregateType')); for (var i = 0; i < cf.dlgGlobalSize('xxPromptValues'); i++) url += "&xxPromptValues=" + encodeURIComponent(cf.dlgGlobalGetParmAt('xxPromptValues', i)); if (cf.cafContextId != "") url += "&ui.cafcontextid=" + cf.cafContextId; if (cf.dlgGlobalGetParm('xxUseMUN')) url += "&xxUseMUN=" + encodeURIComponent(cf.dlgGlobalGetParm('xxUseMUN')); if (cf.dlgGlobalGetParm('xxExprLocale')) url += "&xxExprLocale=" + encodeURIComponent(cf.dlgGlobalGetParm('xxExprLocale')); if (cf.dlgGlobalGetParm('xxExecutionParameters')) url += "&xxExecutionParameters=" + encodeURIComponent(cf.dlgGlobalGetParm('xxExecutionParameters')); if (typeof cf.routingServerGroup != "undefined") { url += "&ui.routingServerGroup=" + encodeURIComponent(cf.routingServerGroup); } if (cf.cfgGet("markup_track") != "undefined") { url += "&markup_track=" + cf.cfgGet("markup_track"); } cf.sendDispatcherRequest(url, processResponse); }; function processResponse(response) { if (!cf.checkResponse(response, document, "customGroups", init)) { hideLoading(); return; } eval(response); if(typeof status != "undefined" && status == "working" && typeof tracking != "undefined" && tracking != "") { requestTracking = tracking; var url = "m=/" + cf.qs_dir + "/customizeGroupsRequest.xts&b_action=xts.run&ui.action=wait&m_tracking="; url += tracking; if (typeof cf.routingServerGroup != "undefined") { url += "&ui.routingServerGroup=" + encodeURIComponent(cf.routingServerGroup); } if (cf.cafContextId != "") { url += "&ui.cafcontextid=" + cf.cafContextId; } setTimeout("customizeGroups_sendWaitRequest('" + url + "');", 100); return; } if (cf.dlgGlobalGetParm('xxAdvanced') == '0') { for (var allVals = 0; allVals < allAvailableValues.length; allVals++) document.f.available_values.options[document.f.available_values.options.length] = new Option(allAvailableValues[allVals][1], allAvailableValues[allVals][0]); } if (WO1076_flag && MQge != null) { var FEs = MQge.childNodes; for (var i = 0; i < FEs.length; i++) { var values = FEs[i].childNodes; var gn = cf.sXmlDecode(FEs[i].getAttribute('label')); for (var j = 0; j < values.length; j++) { createOrAddToCustomGroupWithValue(gn, new cf.CFilterValue(cf.sXmlDecode(values[j].getAttribute('use')), cf.sXmlDecode(values[j].getAttribute('display')))); } } } else { for (var i = 0; i < cf.dlgGlobalSize('xxExistingGroups'); i++) { var existGroup = cf.dlgGlobalGetParmAt('xxExistingGroups', i); createOrAddToCustomGroupWithValue(existGroup[0], existGroup[1]); } } var sel = document.getElementById("available_values"); if (sel) sel.style.display = "inline"; hideLoading(); }; function showLoading() { var loadingDiv = document.getElementById("loadingDiv"); if (loadingDiv == null || typeof loadingDiv == 'undefined') { loadingTimer = setTimeout(showLoading, 50); } else { var theSelect = document.getElementById("available_values"); if (theSelect != null && typeof theSelect != 'undefined') { theSelect.style.display = "none"; } var loadingIcon = document.createElement("IMG"); loadingIcon.align = "middle"; loadingIcon.src = cf.TREE_LOADING; loadingDiv.appendChild(loadingIcon); var newSpanText = document.createElement("SPAN"); newSpanText.appendChild(document.createTextNode(PMT_TRE_TREE_LOADING)); newSpanText.style.paddingLeft = "4px"; newSpanText.className = "clsCheckBox"; loadingDiv.appendChild(newSpanText); } }; function hideLoading() { var theDiv = document.getElementById("loadingDiv"); if (theDiv == null || typeof theDiv == 'undefined') { clearTimeout(loadingTimer); } else { theDiv.parentNode.removeChild(theDiv); var theSelect = document.getElementById("available_values"); if (theSelect != null && typeof theSelect != 'undefined') { theSelect.style.display = "inline"; } } }; function showHideApplyRemaining(show) { var remainingValuesRow = document.getElementById("remainingValuesRow"); var applyRemainingImg = document.getElementById("applyRemainingImg"); var individualValuesText = document.getElementById("individualValuesText"); var noRangeNameText = document.getElementById("noRangeNameText"); var rangeNameText = document.getElementById("rangeNameText"); var isReload = (typeof show != "undefined" && show == "reload"); if ((!isReload) && (remainingValuesRow.style.display == "none" || (typeof show != "undefined" && show == true))) { if (document.all) remainingValuesRow.style.display = "inline"; else remainingValuesRow.style.display = "table-row"; applyRemainingImg.src = sDialogSkinPath + "/prompting/images/prompt_option_collapse.gif"; individualValuesText.style.display = "none"; noRangeNameText.style.display = "none"; rangeNameText.style.display = "none"; cf.showDialogFrame(advOpenSize); } else { if (isReload) { individualValuesText.style.display = "none"; noRangeNameText.style.display = "none"; rangeNameText.style.display = "none"; } else { remainingValuesRow.style.display = "none"; applyRemainingImg.src = sDialogSkinPath + "/prompting/images/prompt_option_expand.gif"; } var doAction = ((isReload && (remainingValuesRow.style.display == "none")) || !isReload); if (document.f.remaining_values_options[0].checked == true) { if (doAction) { if (document.all) individualValuesText.style.display = "inline"; else individualValuesText.style.display = "table-row"; } } else if (document.f.remaining_values_options[1].checked == true || (document.f.remaining_values_options[2].checked == true && document.f.range_name_text.value == "")) { document.f.remaining_values_options[1].checked = true; if (doAction) { if (document.all) noRangeNameText.style.display = "inline"; else noRangeNameText.style.display = "table-row"; } } else { if (doAction) { if (document.all) rangeNameText.style.display = "inline"; else rangeNameText.style.display = "table-row"; } var rnv = document.getElementById("rangeNameValue") var rnvChild = stringReplace (sValuesRangeName, "\\^0", document.f.range_name_text.value); while (rnv.hasChildNodes()) rnv.removeChild(rnv.firstChild); rnv.appendChild(document.createTextNode(rnvChild)); } if (doAction) cf.showDialogFrame(advClosedSize); } }; function customizeGroups_sendWaitRequest(url) { cf.sendDispatcherRequest(url, processResponse); };