123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080 |
- dojo.require("dojo.string");
- dojo.require("dojo._base.array");
- dojo.require("bux.dialogs.WidgetPropertiesFromJSON");
- dojo.require("ActiveReportIWidgetProperties");
- dojo.require("bux.IWidgetUtils");
- dojo.provide("ActiveReportIWidget");
- var globalActiveViewerIdentifier = 1;
- dojo.declare("ActiveReportIWidget", bux.reportViewer, {
- namespacePrefix: "a",
- iframe: null,
- ACTIVEREPORT_VERSION: "2",
- EVENT_NAME_FILTER_ITEMS_GET: 'com.ibm.bux.filter.items.get',
- EVENT_NAME_FILTER_ITEMS_GET_DONE: 'com.ibm.bux.filter.items.get.done',
- EVENT_NAME_FILTER_VALUES_GET: 'com.ibm.bux.filter.values.get',
- EVENT_NAME_FILTER_VALUES_GET_DONE: 'com.ibm.bux.filter.values.get.done',
- m_isActiveReportOutputPreCaspianVersion: false,
- m_sActiveReportOutputVersion: null,
- m_oPublicVariableNames: null,
- m_oCanvasContext: null,
- m_oCanvasContextCollection: null,
- m_oSelectionFilterBasePayload: null,
- m_bApplicationLoaded: false,
- m_aWaitUntilLoadedQueue: null,
- m_sDivHeight: null,
- m_sDivWidth: null,
-
- m_oWidgetContextManager: null,
- constructor: function() {
- this.viewerIdentifier = (globalActiveViewerIdentifier++).toString();
- this.m_aWaitUntilLoadedQueue = [];
- this.m_oPublicVariableNames = null;
- this.m_oSelectionFilterBasePayload = null;
- this.m_oCanvasContextCollection = {};
- this.m_oWidgetContextManager = new WidgetContextManager(this);
- },
- getViewerId: function() {
- return this.namespacePrefix + this.viewerIdentifier;
- },
- getIFrameId: function() {
- return "CVIFrame" + this.getViewerId();
- },
- getContentId: function() {
- return "RVContent" + this.getViewerId();
- },
- getLoadingId: function() {
- return "loading" + this.getViewerId();
- },
- getDisplayName: function() {
- return this.getAttributeValue("widgetTitle");
- },
- getAttributeValue: function(name) {
- return this.iContext.getiWidgetAttributes().getItemValue(name);
- },
- getApplication: function () {
- if (this.iframe && this.iframe.contentWindow && this.iframe.contentWindow.Application) {
- return this.iframe.contentWindow.Application;
- }
- return null;
- },
- getIFrameDocument: function() {
- if (this.iframe.contentDocument) {
-
- return this.iframe.contentDocument;
- }
- if (this.iframe.contentWindow) {
-
- return this.iframe.contentWindow.document;
- }
- return null;
- },
- onLoad: function() {
- this.inherited(arguments);
- var reportStoreID = this.getAttributeValue("originalReport");
- var properties = this.getAttributeValue( "viewerProperties");
- this.properties = this.createProperties(properties);
-
- var oContent = {
- "b_action": "cognosViewer",
- "ui.action": "buxDropActiveReportOnCanvas",
- "ui.object": reportStoreID,
- "cv.responseFormat": "activeReport",
- "cv.id": this.getViewerId(),
- "bux": "true",
- "cv.buxCurrentUserRole": this.getUserRole()
- };
- if (this.getAttributeValue("savedOutputSearchPath") != null) {
- this.setSavedOutputSearchPath(this.getAttributeValue("savedOutputSearchPath"));
- oContent["ui.savedOutputSearchPath"] = this.getAttributeValue("savedOutputSearchPath");
- }
- if(this.isOpeningSavedDashboard()) {
- oContent["widget.openingSavedWidget"] = "true";
- var selectionFilterEnabled = this.getAttributeValue("selectionFilterEnabled");
-
- if (typeof selectionFilterEnabled == "undefined" || selectionFilterEnabled === null) {
- this.m_bSelectionFilterSwitch = true;
- }
- else {
- this.m_bSelectionFilterSwitch = selectionFilterEnabled == "true" ? true : false;
- }
- }
- this.iContext.iEvents.svc.addWire(this.iContext.widgetId, "com.ibm.bux.data.filterCache.init", "widgetBuxCanvasTabs", "com.ibm.bux.data.filterCache.init");
-
- this.postReport(oContent);
- },
-
- postReport: function(content) {
- this.m_viewerLoadInitiated = true;
- if(content) {
- var args = {
- url: this.buildPostUrl(),
- sync: false,
- preventCache: true,
- content: content,
- error: dojo.hitch(this, function(response){
- this.fireEvent("com.ibm.bux.widget.render.done", null, {noAutoResize:true});
- this.fireEvent("com.ibm.bux.widget.notification", null, {type: "error", message: response.message, description: response.description});
- })
- };
- if (typeof xhrMultiPart !== "undefined" && xhrMultiPart.active) {
- args.load = dojo.hitch(this, function(response){
- this.loadContent(response.responseText);
- this.postLoadContent();
- });
- xhrMultiPart.Post(args);
- } else {
- args.load = dojo.hitch(this, function(response, ioArgs){
- var responseContentType = ioArgs.xhr.getResponseHeader("Content-Type");
- if (responseContentType!=null && responseContentType.indexOf("text/html") != -1 && response!=null&& response.match(/<ERROR_CODE>CAM_PASSPORT_ERROR<\/ERROR_CODE>/)!=null) {
- this.handlePassportErrorFromDispatcher();
- } else {
- this.loadContent(response);
- this.postLoadContent();
- }
- });
- dojo.xhrPost(args);
- }
- }
- },
-
- postLoadContent: function(){
- var bIsOpeningSavedDashboard = this.isOpeningSavedDashboard();
- this.iframe = dojo.byId(this.getIFrameId());
- if(this.iframe) {
- this.iframe.Application_OnLoad = dojo.hitch(this, "onActiveReportLoaded", bIsOpeningSavedDashboard);
- this.iframe.Application_OnBeforeLoad = dojo.hitch(this, "onActiveReportBeforeLoad");
- }
- if (bIsOpeningSavedDashboard && this._isWidgetPreCaspianVersion() ) {
-
- this._disableListenToNewlySupportedEvents();
- }
- this.hideLoading();
-
- if(dojo.isIos){
-
-
- var chromeDiv = this._getChromeObject()._pane;
- chromeDiv.setAttribute( "style", "overflow:auto; -webkit-overflow-scrolling:touch;" );
-
- this.iframe.setAttribute( "style", "-webkit-transform: translateZ(0px);" );
- }
- },
-
- onActiveReportBeforeLoad: function()
- {
- this.hideLoading();
- },
-
- onActiveReportLoaded: function(bOpeningSavedWidget)
- {
- var v_oFrameApp = this.getApplication();
- v_oFrameApp.SetChangeStateHandler(dojo.hitch(this, "onActiveReportStateChange"));
- this.m_isActiveReportOutputPreCaspianVersion = this._isActiveReportOutputPreCaspianVersion();
- this._getFilterableItems();
- if (bOpeningSavedWidget) {
- this._restoreSavedState(v_oFrameApp);
- } else {
- if (this.m_oCanvasContext) {
- if (this._hasFunctionProperty(v_oFrameApp, 'SetWidgetContext')) {
- v_oFrameApp.SetWidgetContext(this.m_oCanvasContext);
- }
- }
- }
- this.setupKeys();
- this._adjustWidgetDimension(v_oFrameApp, bOpeningSavedWidget);
- this._applicationLoaded();
- this.fireEvent("com.ibm.bux.widget.render.done", null, {hasIframe: true});
- this.hideLoading();
- },
-
- _invokeWhenLoaded: function(fCallback) {
- if(!this.m_bApplicationLoaded && this.m_aWaitUntilLoadedQueue) {
- this.m_aWaitUntilLoadedQueue.push(fCallback);
- } else {
- fCallback.call();
- }
- },
-
- _applicationLoaded: function() {
- while(!this.m_bApplicationLoaded && this.m_aWaitUntilLoadedQueue.length) {
- var fCallback = this.m_aWaitUntilLoadedQueue.shift();
- if(fCallback) {
- fCallback.call();
- }
- }
- this.m_bApplicationLoaded = true;
- },
-
- _adjustWidgetDimension: function (theApp, bOpeningSavedWidget) {
-
- var iframe = dojo.byId( this.getIFrameId());
- var appDimensions = null;
- if ( theApp && iframe ) {
- if (!bOpeningSavedWidget) {
-
- iframe.style.width = "20px";
- iframe.style.height = "20px";
- }
- iframe.setAttribute("loadState","complete");
-
- appDimensions = theApp.GetApplicationDimensions();
- iframe.style.width = appDimensions.width + "px";
- iframe.style.height = appDimensions.height + "px";
-
- var v_oPane = this._getChromeObject()._pane;
- v_oPane.defaultH = appDimensions.height;
- v_oPane.defaultW = appDimensions.width;
- }
- if (appDimensions) {
- this.setReportContentDimensions(appDimensions.width, appDimensions.height);
- }
- },
-
- _restoreSavedState: function (theApp) {
-
- var oSavedState = this.properties.getActiveReportState();
- if(oSavedState) {
- if (this._hasFunctionProperty(theApp, 'SetFullState')) {
- theApp.SetFullState(oSavedState);
- }
- }
- },
- setReportContentDimensions: function(width, height) {
- var nContent = dojo.byId(this.getContentId());
- if (nContent) {
- nContent.style.width = width + 'px';
- nContent.style.height = height + 'px';
- }
- },
- showLoading: function() {
- dojo.byId(this.getLoadingId()).style.display = "";
-
-
-
-
- var nContent = dojo.byId(this.getContentId());
- nContent.style.position = "absolute";
- nContent.style.visibility = "hidden";
-
-
- this.m_sDivWidth = nContent.style.width;
- this.m_sDivHeight = nContent.style.height;
- nContent.style.width = "0px";
- nContent.style.height = "0px";
- },
- hideLoading: function() {
- var nContent = dojo.byId(this.getContentId());
- if (nContent) {
- nContent.style.position = "static";
- nContent.style.visibility = "visible";
- if (this.m_sDivHeight && this.m_sDivWidth) {
- nContent.style.width = this.m_sDivWidth;
- nContent.style.height = this.m_sDivHeight;
- }
- }
- dojo.byId(this.getLoadingId()).style.display = "none";
- },
-
- postOnFault: function() {
- this.hideLoading();
- },
-
- onActiveReportStateChange: function()
- {
- if (!this.m_bSelectionFilterSwitch) {
- return;
- }
-
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- return;
- }
- var oStatePayload = null;
- if (this.m_isActiveReportOutputPreCaspianVersion) {
- if (this._hasFunctionProperty(oFrameApp, 'GetState')) {
- oStatePayload = oFrameApp.GetState();
- }
- } else {
- if (this._hasFunctionProperty(oFrameApp, 'GetWidgetContext')) {
- oStatePayload = oFrameApp.GetWidgetContext();
- this._convertRangeContext(oStatePayload, true);
- }
- }
- if (oStatePayload) {
- if (!oStatePayload.clientId) {
- oStatePayload.clientId = this.getWidgetId();
- }
-
- if (this.m_oSelectionFilterBasePayload) {
- oStatePayload["com.ibm.widget.context.bux.selection"] = this.m_oSelectionFilterBasePayload;
- }
-
- this.fireEvent( "com.ibm.widget.contextChanged", null, oStatePayload);
-
- this.setSelectionFilterSent(true);
- }
- },
-
- broadcastSelectionFilter: function() {
- this.onActiveReportStateChange();
- },
-
- somethingSelected: function()
- {
- return (this.m_oSelectionFilterBasePayload)? true: false;
- },
-
-
- onWidgetSave: function(evt) {
- this.cleanSavedAttributes();
-
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- this.fireEvent( "com.ibm.bux.widget.save.done", null, {'status':false});
- return;
- }
- if (this._hasFunctionProperty(oFrameApp, 'GetFullState')) {
- var oState = oFrameApp.GetFullState();
- if (oState) {
- this.properties.setActiveReportState(oState);
- }
- }
- this.updateSavedAttributes( "savedOutput" );
- this.fireEvent( "com.ibm.bux.widget.save.done", null, {'status':true});
- },
-
- onOtherWidgetsContextChanged: function(evt) {
- var payload = evt.payload;
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- return;
- }
- if (this.m_isActiveReportOutputPreCaspianVersion) {
-
-
- if (this._isPayloadSupportedByPreCaspianActiveReport(payload)) {
- if (this._hasFunctionProperty(oFrameApp, 'SetState')) {
- oFrameApp.SetState(payload);
- }
- }
- } else {
- this.processSetWidgetContext(oFrameApp, payload);
- }
- },
-
- processSetWidgetContext: function(oApplication, genericPayload) {
- if (this.hasPublicVariables() && this._hasFunctionProperty(oApplication, 'SetWidgetContext')) {
- this.m_oWidgetContextManager.updateContextCollection(genericPayload);
- this.m_oCanvasContext = this.m_oWidgetContextManager.genMergedWidgetContextObject(this.m_oCanvasContextCollection);
-
- oApplication.SetWidgetContext(this.m_oCanvasContext);
- }
- },
- onUnload: function(evt) {
- var iframe = dojo.byId(this.getIFrameId());
- if (iframe) {
- dojo.destroy(iframe);
- }
- this.inherited(arguments);
- },
- onWidgetRefresh: function ( evt ){
- var refreshDonePayload = {};
- if (this.iframe) {
- var viewerObject = this.getViewerObject();
- if( evt && viewerObject){
- viewerObject.executeAction( "RefreshActiveReport" );
- }
- }
- this.fireEvent( "com.ibm.bux.widget.refresh.done", null, refreshDonePayload);
- },
- onWidgetResize: function(evt) {
- var iframe = dojo.byId(this.getIFrameId());
- if ( iframe ) {
- this.setReportContentDimensions(evt.payload.resize.w, evt.payload.resize.h);
- iframe.width = evt.payload.resize.w;
- iframe.height = evt.payload.resize.h;
- if ( iframe.style ) {
- iframe.style.width = evt.payload.resize.w + "px";
- iframe.style.height = evt.payload.resize.h + "px";
- }
- }
- },
- buildPostUrl: function () {
- return this.getAttributeValue("gateway");
- },
- isSavedOutput: function(){
- return false;
- },
- isSaveNecessary: function() {
- var sHasAlreadySaved = this.getAttributeValue("mostRecentSavedOutput");
- var sSavedOutputSearchPath = this.getAttributeValue("savedOutputSearchPath");
- return (sHasAlreadySaved === "true" || sSavedOutputSearchPath) ? false : true;
- },
- handleFault: function() {
- this.inherited(arguments);
- this.hideLoading();
- },
- setupKeys: function() {
-
- var doc = this.getIFrameDocument();
- if(doc) {
- dojo.connect(doc.body, "onkeypress", dojo.hitch(this, function(evt) {
- switch(evt.charOrCode) {
- case dojo.keys.F10:
- this.focusOnToolbar(evt);
- break;
- case dojo.keys.F12:
- if (evt.shiftKey) {
- this.focusOnPane(evt);
- }
- break;
- }
- }));
- }
-
-
- this._makeInvisibleFocusDiv("before", "first");
- this._makeInvisibleFocusDiv("before", "last");
- this._makeInvisibleFocusDiv("after", "first");
- },
- _makeInvisibleFocusDiv: function(placePosition, focusPosition) {
-
- var div = dojo.create(
- "div",
- {
- tabIndex: 0,
- visibility: "hidden",
- position: "absolute"
- },
- this.iframe,
- placePosition
- );
-
- dojo.connect(div, "onfocus", dojo.hitch(this, function(){
- this.cycleFocus(focusPosition);
- }));
- },
- cycleFocus: function(position) {
-
- var tabElems = dijit._getTabNavigable(this.getIFrameDocument().body);
- var toFocus;
- if (position === "first") {
- toFocus = tabElems.lowest || tabElems.first;
- } else {
- toFocus = tabElems.highest || tabElems.last;
- }
- if (toFocus) {
- dijit.focus(toFocus);
- }
- },
- _getChromeObject: function() {
- var chromeObjectId = bux.IWidgetUtils.widgetIdToChromeId(this.iContext.widgetId);
- return bux.IWidgetUtils.getChromeById(chromeObjectId);
- },
- focusOnToolbar: function(evt) {
- var chromeObject = this._getChromeObject();
- if (chromeObject) {
- chromeObject._pane.focusToolbar(this.iframe);
- }
- if (dojo.isIE || dojo.isTrident) {
- evt.keyCode = 0;
- }
- dojo.stopEvent(evt);
- },
- focusOnPane: function(evt) {
- var chromeObject = this._getChromeObject();
- if (chromeObject) {
- chromeObject._pane._focusBorder();
- }
- dojo.stopEvent(evt);
- },
-
- onGenericEvent: function(evt) {
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- return;
- }
- if ( !this.m_isActiveReportOutputPreCaspianVersion ) {
- this.processSetWidgetContext(oFrameApp, evt.payload);
- }
- },
-
- createProperties: function(properties) {
- return new ActiveReportIWidgetProperties( this, properties );
- },
- temporaryStateCleanup: function(oState) {
- var oCleanState = {};
- if (oState && oState.variables) {
- var oVariables = oState.variables;
- for(var sName in oVariables) {
- var oValues = oVariables[sName];
- var aValues = [];
- for(var sValue in oValues) {
- if (typeof(oValues[sValue]) == 'string') {
- aValues.push(oValues[sValue]);
- }
- }
- if (aValues.length>0) {
- oCleanState[sName] = aValues;
- }
- }
- return {'variables': oCleanState};
- }
- return oState;
- },
-
- _isWidgetPreCaspianVersion: function() {
- var sSavedVersion = this.getAttributeValue("version");
- return this._isOlderVersion(this.BUX_REPORT_VERSION, sSavedVersion);
- },
- _isOlderVersion: function(sBaseVersion, sTest) {
- if (!sBaseVersion || !sTest) {
- return true;
- }
- return (sBaseVersion > sTest);
- },
-
- _disableListenToNewlySupportedEvents: function() {
- var payload = {};
- payload[ '*' ] = { blockedEvents:[
- this.m_oWidgetContextManager.EVENT_NAME_PROMPT,
- this.m_oWidgetContextManager.EVENT_NAME_DRILL,
- this.m_oWidgetContextManager.EVENT_NAME_SELECTVALUECONTROL,
- this.EVENT_NAME_FILTER_ITEMS_GET,
- this.EVENT_NAME_FILTER_VALUES_GET
- ]
- };
- this.fireEvent("com.ibm.bux.widget.updateEventFilter", null, payload);
- },
-
- _isActiveReportOutputPreCaspianVersion: function() {
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- return null;
- }
- var sVersion = '0';
- if ( this._hasFunctionProperty(oFrameApp, 'GetOutputVersion')) {
- sVersion = oFrameApp.GetOutputVersion();
- this.m_sActiveReportOutputVersion = sVersion;
- }
- return this._isOlderVersion( this.ACTIVEREPORT_VERSION, sVersion);
- },
-
- getActiveReportOutputVersion: function() {
- return this.m_sActiveReportOutputVersion;
- },
-
- getPublicVariableNames: function() {
- return this.m_oPublicVariableNames || {};
- },
-
- _isPayloadSupportedByPreCaspianActiveReport: function(oPayload) {
- for (var sPropertyName in oPayload) {
- var oNameValuePairObject = oPayload[sPropertyName];
- for (var sName in oNameValuePairObject) {
- var oValue = oNameValuePairObject[sName];
- if (typeof(oValue) == 'object') {
- for (var sArrayPropertyName in oValue) {
- if (typeof(oValue[sArrayPropertyName]) == 'function') {
- return true;
- }
- }
- }
- }
- }
- return false;
- },
-
- _hasFunctionProperty:function(obj, functionName) {
- if (obj && functionName) {
- if (obj[functionName] && typeof obj[functionName] == 'function') {
- return true;
- }
- }
- return false;
- },
-
- _convertRangeContext:function(oActiveReportContext, bFromActiveReportForGeneric) {
- var oWidgetContext = oActiveReportContext[this.m_oWidgetContextManager.PP_WIDGET_CONTEXT];
- if (oWidgetContext) {
- var oRanges = oWidgetContext[this.m_oWidgetContextManager.PP_RANGES];
- if (oRanges) {
- var newRanges = {};
- for (var sName in oRanges) {
- var value = oRanges[sName];
- if (bFromActiveReportForGeneric) {
-
- newRanges[sName] = [value];
- } else {
-
- if (value && value.length>0) {
- newRanges[sName] = value[0];
- }
- }
- }
- oWidgetContext[this.m_oWidgetContextManager.PP_RANGES] = newRanges;
- }
- }
- },
-
- onGetFilterableItems: function(evt) {
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- this.fireEvent('com.ibm.bux.filter.items.get.done', null, {});
- return;
- }
- var aItems = this._getFilterableItems();
- var payload = {
- 'invisible' : [],
- 'visible' : aItems
- };
- this.fireEvent('com.ibm.bux.filter.items.get.done', null, payload);
- },
- _getFilterableItems: function() {
- var aItems = [];
- var oFrameApp = this.getApplication();
- if (!oFrameApp) {
- return aItems;
- }
- this.m_oPublicVariableNames = this.m_oPublicVariableNames || {};
-
- var hasDiscriteValues = false;
- if (this._hasFunctionProperty(oFrameApp, 'GetDiscreteVariables')) {
- var aDiscreteVariables = [].concat(oFrameApp.GetDiscreteVariables());
-
- for (var idx in aDiscreteVariables) {
- aItems.push( this._genFilterableItemObject( aDiscreteVariables[idx], false) );
- this.m_oPublicVariableNames[aDiscreteVariables[idx]] = 'D';
- hasDiscriteValues = true;
- }
- }
- if (this._hasFunctionProperty(oFrameApp, 'GetRanges')) {
- var aRanges = [].concat(oFrameApp.GetRanges());
- for (var idx in aRanges) {
- aItems.push( this._genFilterableItemObject( aRanges[idx], true) );
- this.m_oPublicVariableNames[aRanges[idx]] = 'R';
- }
- }
-
- if (hasDiscriteValues) {
- this.m_oSelectionFilterBasePayload = {
- "selection":{
- "id":this.getWidgetId(),
- "valueType":"string"
- }
- };
- }
- return aItems;
- },
-
-
- hasPublicVariables: function() {
- var found = false;
- for(var name in this.m_oPublicVariableNames) {
- found = true;
- break;
- }
- return found;
- },
-
- _genFilterableItemObject: function (sItemName, /*isRange*/ isRange) {
- var object = {
- 'label' : sItemName,
- 'name' : sItemName
- };
- if (isRange) {
- object['range'] = true;
- }
- return object;
- },
- onGetFilterValues: function(evt) {
- var oItem = evt.payload.payload;
- var sName = oItem.name;
- var oPayload = {name: sName};
- if (!evt.payload || !evt.payload.payload) {
- this.fireEvent(this.EVENT_NAME_FILTER_VALUES_GET_DONE, null, oPayload);
- return;
- }
-
- this._invokeWhenLoaded(dojo.hitch(this, function() {
-
- if(!this.m_oPublicVariableNames) {
- this._getFilterableItems();
- }
- if (!this.m_oPublicVariableNames[sName]) {
- this.fireEvent(this.EVENT_NAME_FILTER_VALUES_GET_DONE, null, oPayload);
- return;
- }
- var oFrameApp = this.getApplication();
- var aNewValues = [];
- try {
- if (this.m_oPublicVariableNames[sName] === 'R') {
-
- if (this._hasFunctionProperty(oFrameApp, 'GetRangeValues')) {
- var oRange = oFrameApp.GetRangeValues(sName);
- var newObj = {'max': null, 'min': null};
- if (typeof oRange.min != 'undefined' && typeof oRange.max != 'undefined') {
- newObj.min = parseFloat(oRange.min);
- newObj.max = parseFloat(oRange.max);
- }
- oPayload.range = newObj;
- }
- } else if (this.m_oPublicVariableNames[sName] === 'D') {
-
- if (this._hasFunctionProperty(oFrameApp, 'GetValuesForDiscreteVariable')) {
- var aValues = [].concat(oFrameApp.GetValuesForDiscreteVariable(sName));
- if (aValues && aValues.length>0) {
- for (var idx in aValues) {
- aNewValues.push(
- {'mun': 'unknown',
- 'caption': aValues[idx]}
- );
- }
- }
- oPayload.values = aNewValues;
- }
- }
- } catch (e) {
- throw e;
- } finally {
- oPayload.modelInfo = { 'path': 'unknow_' + this.getWidgetId() };
- this.fireEvent(this.EVENT_NAME_FILTER_VALUES_GET_DONE, null, oPayload);
- }
- }));
- },
- onWidgetShow: function(evt) {
-
- if(this.getViewerObject().getAdvancedServerProperty("VIEWER_JS_RELOAD_AR_IE8") === "true" && evt.payload.isVisible && !this.m_bActiveReportRedrawn && dojo.isIE == 8) {
- this.m_bActiveReportRedrawn = true;
- var sBackupSrc = this.iframe.src;
- this.iframe.src="";
- this.iframe.src = sBackupSrc;
- }
- },
-
-
- reselectSelectionFilterObjects: function() {
- var value = this.getAttributeValue( "selectionFilterSent" );
- this.setSelectionFilterSent(value === "true");
- this.removeAttributeValue("selectionFilterSent");
- },
-
-
- updateSavedAttributes: function(attribType) {
- this.inherited(arguments);
-
- if (this.selectionFilterSent()) {
- this.setAttributeValue( "selectionFilterSent", "true" );
- }
- },
-
- cleanSavedAttributes: function() {
- this.inherited(arguments);
- this.removeAttributeValue("selectionFilterSent");
- },
-
-
-
- updateFilterCache: function(iEvent){
- this.m_oWidgetContextManager.updateContextCollection(iEvent.payload);
- },
-
-
- onGetWidgetContext: function(iEvent) {
- var payload = {};
- if (this.iframe && this.isSelectionFilterEnabled()) {
- var oFrameApp = this.getApplication();
- if (this._hasFunctionProperty(oFrameApp, 'GetWidgetContext')) {
- payload = oFrameApp.GetWidgetContext();
- payload.clientId = this.getWidgetId();
- }
- }
- this.fireEvent( 'com.ibm.widget.context.get.done', null , payload);
- },
-
-
- onGetCanvasContextDone: function(evt) {
- var aPayload = evt.payload;
- for(var i=0; i<aPayload.length; i++ ) {
- this.m_oWidgetContextManager.updateContextCollection(aPayload[i]);
- }
- this.m_oCanvasContext = this.m_oWidgetContextManager.genMergedWidgetContextObject();
- },
-
- DEBUG_LOG: function(msg, obj) {
- if (this.isDebugMode()) {
- if (console) {
- if (msg && obj) {
- console.log("%s %o", msg, obj);
- } else if (msg){
- console.log(msg);
- } else if (obj) {
- console.log(obj);
- }
- }
- }
- },
-
- DEUBG_LOG: function(msg, obj) {
- this.DEBUG_LOG(msg,obj);
- },
- isDebugMode: function() {
- return (dojo && dojo['config'] && dojo['config']['isDebug']);
- }
- });
|