123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Viewer
- *| (C) Copyright IBM Corp. 2013, 2014
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- function EditContentAction()
- {
- this._oMissingMemberRecoveryMode = null;
- }
- EditContentAction.prototype = new CognosViewerAction();
- EditContentAction.superclass = CognosViewerAction.prototype;
- EditContentAction.prototype.execute = function() {
- if (typeof this.preferencesChanged != "undefined" && this.preferencesChanged !== null && this.preferencesChanged === true ) {
- this.deleteCWAContainer();
- return;
- }
- window.CVEditContentActionInstance = this;
- var buaAlreadyLoaded = window.viewerCWAContainer ? true : false;
-
- if (!window.viewerCWAContainer) {
- this.createCWAContainer();
- }
-
- this.addWindowEventListeners();
- this.buildBUAObjects();
-
- window.viewerCWAContainer.show();
-
- if (buaAlreadyLoaded) {
- window.BUAEvent("appReady");
- }
- };
- EditContentAction.prototype.createCWAContainer = function() {
- this.deleteCWAContainer();
-
- var containerDiv = this.createCWAIFrame();
- var blocker = this.createBlocker();
- window.viewerCWAContainer = {
- "type" : "iframe",
- "containerDiv" : containerDiv,
- "blocker" : blocker,
- "iframePadding" : "18",
- "show" : function() {
- this.resize();
- this.containerDiv.style.display = "block";
- this.blocker.style.display = "block";
- },
- "hide" : function() {
- this.blocker.style.display = "none";
- this.containerDiv.style.display = "none";
- },
- "resize" : function() {
- var windowBox = dojo.window.getBox();
- this.containerDiv.style.height = windowBox.h - this.iframePadding + "px";
- this.containerDiv.style.width = windowBox.w - this.iframePadding + "px";
- }
- };
- };
- EditContentAction.prototype.deleteCWAContainer = function() {
- var containerObj = window.viewerCWAContainer;
- if (containerObj) {
- containerObj.hide();
- document.body.removeChild(containerObj.containerDiv);
- document.body.removeChild(containerObj.blocker);
-
- delete window.viewerCWAContainer;
- window.viewerCWAContainer = null;
- }
- };
- EditContentAction.prototype.hideCWAContainer = function() {
- this.removeWindowEventListeners();
- if (window.viewerCWAContainer) {
- window.viewerCWAContainer.hide();
- }
- window.CVEditContentActionInstance = null;
- };
- EditContentAction.prototype.createCWAIFrame = function() {
- var containerDiv = document.createElement("div");
- containerDiv.className = "buaContainer";
- document.body.appendChild(containerDiv);
-
- var iframeElement = document.createElement("iframe");
- iframeElement.setAttribute("id","buaIframe");
- iframeElement.setAttribute("src", this.getWebContent() + "/pat/rsapp.htm");
- iframeElement.setAttribute("name", "buaIframe");
- iframeElement.setAttribute("frameborder",'0');
- iframeElement.className = "buaIframe";
-
- containerDiv.appendChild(iframeElement);
-
- return containerDiv;
- };
- EditContentAction.prototype.createBlocker = function() {
- var blocker = document.createElement("div");
- blocker.setAttribute("id","reportBlocker");
- blocker.setAttribute("name", "reportBlocker");
- blocker.setAttribute("tabIndex", "1");
- blocker.className = "reportBlocker";
-
- document.body.appendChild(blocker);
-
- return blocker;
- };
- EditContentAction.prototype.buildBUAObjects = function() {
- window.RSParameters = {
- "rs_UIProfile" : "BUA",
- "ui.action" : "edit",
- "gateway" : location.protocol + "//" + location.host + this.getGateway(),
- "theme" : "corporate",//make look&feel consistent between CW and CWA
- "capabilitiesXML" : this.getCapabilitiesXml(),
- "cafcontextid" : this.getCafContextId(),
- "paneOnRight" : this.getViewerIWidget().getPaneOnRight()
- };
- var viewerWidget = this.getViewerIWidget();
- if(viewerWidget !== null) {
- var cvGateway = viewerWidget.getAttributeValue("gateway");
- if(cvGateway) {
- window.RSParameters["cv.gateway"] = cvGateway;
- }
- var cvWebcontent = viewerWidget.getAttributeValue("webcontent");
- if(cvWebcontent) {
- window.RSParameters["cv.webcontent"] = cvWebcontent;
- }
- }
- this.addExtraLaunchParameters(window.RSParameters);
- };
- EditContentAction.prototype.getBUAIframe = function() {
- return document.getElementById("buaIframe");
- };
- EditContentAction.prototype.getBUAWindow = function() {
- var buaWindow = null;
- var buaIframe = this.getBUAIframe();
- if(buaIframe !== null) {
- buaWindow = buaIframe.contentWindow;
- }
- return buaWindow;
- };
- EditContentAction.prototype.setReportSettings = function() {
- var oCV = this.getCognosViewer();
- var widget = oCV.getViewerWidget();
- //Fire an IWidget event to get the title
- widget.fireEvent("com.ibm.bux.widget.getDisplayTitle", null, { callback: function(sTitle) { window.CVEditContentActionInstance.openReportWithBUA(sTitle); } });
- };
- EditContentAction.prototype.openReportWithBUA = function(sTitle) {
- var subStringIndex = this.m_oCV.envParams["ui.spec"].indexOf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- if (subStringIndex == -1) { subStringIndex = 0; } else { subStringIndex = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>".length; }
- var sReportXML = this.m_oCV.envParams["ui.spec"].substr(subStringIndex, this.m_oCV.envParams["ui.spec"].length);
- var oContext = {
- "displayName" : xml_decode(sTitle), //Chrome HTML encoded this sTtitle
- "parameterValues" : this.m_oCV.getExecutionParameters(),
- "reportXML" : sReportXML,
- "showOpenTransition" : false
- };
-
- if (this.ifPassTrackingtoBUA()) {
- oContext.tracking = this.m_oCV.getTracking();
- }
-
- var buaWindow = this.getBUAWindow();
- buaWindow.Application.SetBUAContext(oContext);
- };
- EditContentAction.prototype.getViewerIWidget = function() {
- return this.m_oCV.getViewerWidget();
- };
- EditContentAction.prototype.getGateway = function() {
- return this.m_oCV.getGateway();
- };
- EditContentAction.prototype.getCapabilitiesXml = function() {
- return this.m_oCV.capabilitiesXML;
- };
- EditContentAction.prototype.getCafContextId = function() {
- return typeof this.m_oCV.cafContextId != "undefined" ? this.m_oCV.cafContextId : "";
- };
- EditContentAction.prototype.getWebContent = function() {
- return this.getCognosViewer().getWebContentRoot();
- };
- EditContentAction.prototype.addExtraLaunchParameters = function(RSParameters) {};
- EditContentAction.prototype.runUpdatedReportFromBUA = function() {
- var buaWindow = this.getBUAWindow();
- var originalSpec = this.m_oCV.envParams["ui.spec"];
- var oContext = buaWindow.Application.GetBUAContext();
- if (oContext.isSpecModified) {
- this.m_oCV.envParams["ui.spec"] = oContext.reportXML;
- this.m_oCV.setTracking(oContext.tracking);
- this.m_oCV.setExecutionParameters(oContext.parameterValues);
- this._invokeRedrawAction(originalSpec);
- }
- };
- EditContentAction.prototype._invokeRedrawAction = function(originalSpec)
- {
- this.getUndoRedoQueue().setOriginalSpec(originalSpec);
- var redrawAction = this.m_oCV.getAction("Redraw");
- redrawAction.setSpecUpdated(true);
- this.m_oCV.getViewerWidget().setPromptParametersRetrieved(false);
- redrawAction.execute();
- };
- EditContentAction.prototype.ifPassTrackingtoBUA = function()
- {
- if (this.m_oCV.getRAPReportInfo()) {
- return this.m_oCV.getRAPReportInfo().getPassTrackingtoBUA();
- }
- return true;
- };
- EditContentAction.prototype.setRequestParms = function(params) {
- EditContentAction.superclass.setRequestParms(params);
- if (params) {
- if (params.preferencesChanged) {
- this.preferencesChanged = params.preferencesChanged;
- }
-
- if (params.MissingMemberRecoveryMode) {
- this._oMissingMemberRecoveryMode = params.MissingMemberRecoveryMode;
- }
- }
- };
- EditContentAction.prototype.runUpdatedReportFromBUA_MissingMemberRecoveryMode = function() {
- var buaWindow = this.getBUAWindow();
- var originalSpec = this.m_oCV.envParams["ui.spec"];
- var oContext = buaWindow.Application.GetBUAContext();
-
- this.m_oCV.setTracking(oContext.tracking);
-
- this.m_oCV.envParams["ui.spec"] = oContext.reportXML;
- this.m_oCV.setExecutionParameters(oContext.parameterValues);
-
- if (this._oMissingMemberRecoveryMode && this._oMissingMemberRecoveryMode.oFaultDialog) {
- this._oMissingMemberRecoveryMode.oFaultDialog.hide();
- }
-
- this._invokeRedrawAction(originalSpec);
- };
- EditContentAction.prototype.cancelPressed = function() {};
- EditContentAction.prototype.addWindowEventListeners = function() {
- if (window.attachEvent) {
- window.attachEvent("onresize", window.CVEditContentActionInstance.onWindowResize);
- }
- else {
- window.addEventListener("resize", window.CVEditContentActionInstance.onWindowResize, false);
- }
- };
- EditContentAction.prototype.removeWindowEventListeners = function() {
- if (window.detachEvent) {
- window.detachEvent("onresize", window.CVEditContentActionInstance.onWindowResize);
- }
- else {
- window.removeEventListener("resize", window.CVEditContentActionInstance.onWindowResize, false);
- }
- };
- EditContentAction.prototype.onWindowResize = function() {
- var containerObj = window.viewerCWAContainer;
- if (containerObj) {
- containerObj.resize();
- }
- };
- /**
- * Interface that CWA will call
- * @param eventType
- */
- function BUAEvent(eventType)
- {
- var editContentObj = window.CVEditContentActionInstance;
- switch (eventType)
- {
- case "appReady":
- editContentObj.setReportSettings();
- break;
- case "donePressed":
- editContentObj.hideCWAContainer();
- if (editContentObj._oMissingMemberRecoveryMode) {
- editContentObj.runUpdatedReportFromBUA_MissingMemberRecoveryMode();
- } else {
- editContentObj.runUpdatedReportFromBUA();
- }
- break;
- case "cancelPressed":
- editContentObj.cancelPressed();
- editContentObj.hideCWAContainer();
- break;
- }
- }
|