/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Viewer *| (C) Copyright IBM Corp. 2001, 2013 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ function FilterAction() { this.m_sAction = "Filter"; this.m_sType = ""; this.m_sItem = ""; this.m_sFormattedNumber= ""; this.m_sFormattedEndNumber= ""; this.m_jsonDetails = ""; } FilterAction.prototype = new ModifyReportAction(); FilterAction.prototype.execute = function() { ModifyReportAction.prototype.execute.apply(this, arguments) if (this.m_sType.indexOf("remove") != -1) { this.getCognosViewer().getViewerWidget().clearRAPCache(); } }; FilterAction.prototype.genSelectionContextWithUniqueCTXIDs = function() { return true; }; FilterAction.prototype.getUndoHint = function() { if (this.m_sType.indexOf("remove") != -1) { return RV_RES.IDS_JS_REMOVE_FILTER; } else { return RV_RES.IDS_JS_FILTER; } }; FilterAction.prototype.setRequestParms = function( parms ) { if (parms.type!=null && typeof parms.type != "undefined") { this.m_sType = parms.type; if (parms.id!=null && typeof parms.id != "undefined") { this.m_sId = parms.id; } if (parms.item!=null && typeof parms.item != "undefined") { this.m_sItem = parms.item; } if (parms.details) { this.m_jsonDetails = parms.details; } if (parms.formattedNumber!=null && typeof parms.formattedNumber != "undefined") { this.m_sFormattedNumber = parms.formattedNumber; } if (parms.formattedEndNumber!=null && typeof parms.formattedEndNumber != "undefined") { this.m_sFormattedEndNumber = parms.formattedEndNumber; } } else { this.m_sType = parms; } }; FilterAction.prototype.addActionContextAdditionalParms = function() { var parms = "" + this.m_sType + ""; if (this.m_sId != null && typeof this.m_sId != "undefined") { parms+= ("" + xml_encode(this.m_sId) + ""); } if (this.m_sItem != null && typeof this.m_sItem != "undefined" && this.m_sItem!="") { parms+= ("" + xml_encode(this.m_sItem) + ""); } if (this.m_jsonDetails && this.m_jsonDetails!="") { parms+= "
" + xml_encode(this.m_jsonDetails) + "
"; } if (this.m_sFormattedNumber != null && typeof this.m_sFormattedNumber != "undefined" && this.m_sFormattedNumber!="") { parms+= ("" + this.m_sFormattedNumber + ""); } if (this.m_sFormattedEndNumber != null && typeof this.m_sFormattedEndNumber != "undefined" && this.m_sFormattedEndNumber!="") { parms+= ("" + this.m_sFormattedEndNumber + ""); } return parms; }; FilterAction.prototype.buildSelectedItemsString = function(selectedObjects) { var itemsLabel = ""; var numberOfSelectedItems = selectedObjects.length; var numberOfItemsToAdd = numberOfSelectedItems > 5 ? 5 : numberOfSelectedItems; for(var index = 0; index < numberOfSelectedItems; ++index) { var value = this.getItemLabel(selectedObjects[index]); if (typeof value == "undefined" || value == "") { //a selectedObject has neither displayValue nor useValue. return ""; } if((index) < numberOfItemsToAdd) { itemsLabel += value; } if((index+1) < numberOfItemsToAdd) { itemsLabel += ", "; } } if(numberOfSelectedItems > 5) { itemsLabel += ", ++"; } return itemsLabel; }; FilterAction.prototype.getItemLabel = function (selectedObject) { var value = selectedObject.getDisplayValues()[0]; if (typeof value == "undefined") { value = selectedObject.getUseValues()[0][0]; } return value; }; FilterAction.prototype.toggleMenu = function(jsonSpec, enabled) { if (enabled) { jsonSpec.iconClass = "filter"; jsonSpec.disabled = false; } else { jsonSpec.iconClass = "filterDisabled"; jsonSpec.disabled = true; } return jsonSpec; }; FilterAction.prototype.updateMenu = function(jsonSpec) { jsonSpec.visible = (this.ifContainsInteractiveDataContainer() && !this.detailFilteringIsDisabled()); var result = jsonSpec; if (jsonSpec.visible) { var canAddOrRemoveFilters=(this.m_oCV.getSelectionController().getAllSelectedObjects().length > 0 || this.isSelectionFilterable() || this.isRemoveAllValid()); if (!canAddOrRemoveFilters) { result = this.toggleMenu(jsonSpec, false); } else { this.buildMenu(jsonSpec); if (jsonSpec.disabled == true) { result = this.toggleMenu(jsonSpec, false); } else { result = this.buildDynamicMenuItem(jsonSpec, "Filter"); } } } return result; }; FilterAction.prototype.detailFilteringIsDisabled = function() { var oRAPReportInfo = this.getCognosViewer().getRAPReportInfo(); if (oRAPReportInfo) { return oRAPReportInfo.isDetailFilteringDisabled(); } return false; }; FilterAction.prototype.buildMenu = function(jsonSpec) { jsonSpec.visible = (this.ifContainsInteractiveDataContainer() && !this.detailFilteringIsDisabled()); if (! jsonSpec.visible) { return jsonSpec; } var selectionIsFilterable=this.isSelectionFilterable(); this.toggleMenu(jsonSpec, selectionIsFilterable); var filterItems = []; var filterValueActionsAdded = false; var renderedRemoveSeparator = false; var selectionController = this.m_oCV.getSelectionController(); var selectedObjects = selectionController.getAllSelectedObjects(); if(selectedObjects.length > 0 && selectionController.selectionsInSameDataContainer() && selectionController.selectionsFromSameDataItem()) { var refDataItem = selectedObjects[0].getDataItems()[0][0]; if (selectionIsFilterable) { filterValueActionsAdded = this.addFilterValueActionsToMenu(selectionController, filterItems, refDataItem); } if (this.isRemoveItemFilterValid(refDataItem)) { if (filterValueActionsAdded == true) { filterItems.push({separator: true}); renderedRemoveSeparator=true; } var label = this.getRefDataItemLabel(refDataItem); filterItems.push({ name: "RemoveFilterFor", label: RV_RES.IDS_JS_REMOVE_FILTER_FOR + " " + enforceTextDir(label), iconClass: "", action: { name: "Filter", payload: "remove" }, items: null }); } } if (this.isRemoveAllValid()==true) { if (filterValueActionsAdded && !renderedRemoveSeparator) { filterItems.push({separator: true}); } filterItems.push({ name: "RemoveAllFiltersForWidget", label: RV_RES.IDS_JS_REMOVE_ALL_FILTERS_FOR_WIDGET, iconClass: "", action: { name: "Filter", payload: "removeAllForWidget" }, items: null }); } if(filterItems.length == 0) { return this.toggleMenu(jsonSpec, false); } else { jsonSpec.items = filterItems; this.toggleMenu(jsonSpec, true); return jsonSpec; } }; FilterAction.prototype.getRefDataItemLabel = function(refDataItem) { var label = refDataItem; var oRAPReportInfo = this.m_oCV.getRAPReportInfo(); if (oRAPReportInfo) { var oFilter = oRAPReportInfo.getFilterObject(refDataItem, true); if (oFilter) { label = oFilter.itemLabel; } } return label; }; FilterAction.prototype.addFilterValueActionsToMenu = function(selectionController, filterItems, refDataItem) { var selectedObjects = selectionController.getAllSelectedObjectsWithUniqueCTXIDs(); // Don't add the filter actions if the data container is a list and the list // column header is selected var numberOfSelectedValues = selectedObjects.length; var sel = 0; if (selectedObjects[0].m_dataContainerType=='list') { for (sel=0; sel 0) { var cellRef = selectedObjects[0].getCellRef(); if (cellRef && cellRef.getAttribute && cellRef.getAttribute("no_data_item_column") === "true") { return false; } if (selectionController.hasSelectedChartNodes()) { //CHARTS: Selections are not filterable if: // 1) Any title is selected (eg legendTitle, numericAxisTitle, ordinalAxisTitle) // 2) A calc/measure that is on an edge is selected (eg. legendLabel, ordinalAxisLabel) var measureOrCalculationType=false; if (selectionController.selectionsAreDateTime() || (selectionController.selectionsHaveCalculationMetadata() && !selectionController.selectionsNonMeasureWithMUN() )) { measureOrCalculationType=true; } for (var sel=0; sel 0 ) { actionContext += this._getDrillResetActionContext(); } if(this.m_sForceCleanup) { actionContext += "" + dojo.toJson(this.m_sForceCleanup) + ""; } var processedRequestParamValues; var isXMLFilterPayload = (this.m_requestParams.charAt(0)==="<"); if ( this.m_isFacet || isXMLFilterPayload) { processedRequestParamValues = [ this.m_requestParams ]; } else { processedRequestParamValues = this.preProcessContextValues(); } for(var idx = 0; idx < processedRequestParamValues.length; ++idx) { var actionParams = processedRequestParamValues[idx]; actionContext += "" + inlineValues; actionContext += (isXMLFilterPayload) ? actionParams : xml_encode(actionParams); if(idx > 0) { actionContext += "true"; } if (!this.m_isFacet) { actionContext += this.addClientContextData(/*maxValuesPerRDI*/3); } actionContext += ""; actionContext += ""; actionContext += ""; } actionContext += ""; return actionContext; }; UpdateDataFilterAction.prototype._getDrillResetActionContext = function() { var drillResetAction = new DrillResetAction(); drillResetAction.setCognosViewer( this.getCognosViewer() ); var params = { drilledResetHUNs : this.m_drillResetHUN }; drillResetAction.setRequestParms( params ); drillResetAction.setUpdateInfoBar( false ); var drillResetActionContext = drillResetAction.getReportActionContext(); return drillResetActionContext; };