123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Viewer
- *| (C) Copyright IBM Corp. 2001, 2012
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- // constants
- CSubscriptionManager.k_SubscriptionWizardName = "subscriptionWizard";
- function CSubscriptionManager(cv)
- {
- this.m_cv = cv;
- /**
- @type boolean
- @private
- */
- this.m_bInitialized = false;
- /**
- @type array
- @private
- */
- this.m_aWatchRules = null;
- /**
- @type string
- @private
- */
- this.m_sEmail = "";
- /**
- @type string
- @private
- */
- this.m_sAlertNewVersionConfirm = "";
- /**
- @type boolean
- @private
- */
- this.m_sQueryNotificationResponse = "";
- /**
- @type boolean
- @private
- */
- this.m_bAllowNotification = false;
- /**
- @type boolean
- @private
- */
- this.m_bAllowSubscription = false;
- /**
- @type boolean
- @private
- */
- this.m_bCanCreateNewWatchRule = false;
- /**
- @type boolean
- @private
- */
- this.m_bCanGetNotified = false;
- /**
- @type boolean
- @private
- */
- this.m_bAllowAnnotations = false;
- /**
- @type boolean
- @private
- */
- this.m_bCanCreateAnnotations = false;
- /**
- @type string
- @private
- */
- this.m_windowOptions = "width=450,height=350,toolbar=0,location=0,status=0,menubar=0,resizable,scrollbars=1";
- //"width=500,height=350,toolbar=0,location=0,status=0,menubar=0,resizable,scrollbars=1";
- }
- CSubscriptionManager.prototype.getViewer = function() {
- return this.m_cv;
- };
- /**
- Initialize the subscription member variables with the server response
- */
- CSubscriptionManager.prototype.Initialize = function(response)
- {
- try
- {
- var oJSONResponse = response.getJSONResponseObject();
- var formWarpRequest = document.forms['formWarpRequest' + this.m_cv.getId()];
- if (oJSONResponse["annotationInfo"]) {
- var oAnnotationInfo = oJSONResponse["annotationInfo"];
- this.m_AnnotationsCount = oAnnotationInfo.annotations.length;
- // Push the whole annotations in current session
- this.m_annotations = oAnnotationInfo.annotations;
- this.m_bAllowAnnotations = oAnnotationInfo.allowAnnotations;
- this.m_bCanCreateAnnotations = oAnnotationInfo.traverse == "true";
- return true;
- }
- if (oJSONResponse["subscriptionInfo"])
- {
- var oSubscriptionInfo = oJSONResponse["subscriptionInfo"];
- if (!this.m_bInitialized)
- {
- this.m_sEmail = oSubscriptionInfo.sEmail;
- this.m_bAllowNotification = oSubscriptionInfo.bAllowNotification;
- this.m_bAllowSubscription = oSubscriptionInfo.bAllowSubscription;
- this.m_sAlertNewVersionConfirm = oSubscriptionInfo.sAlertNewVersionConfirm;
- if (formWarpRequest["ui.action"] && formWarpRequest["ui.action"].value == 'view')
- {
- /*
- Can the user create new watch rules
- - Report output is in HTML with interactive information
- - User has the 'Create and Run Watch Rules' capability
- - Alerts using watch rules are allowed for the report
- */
- if (formWarpRequest["ui.format"])
- {
- this.m_bCanCreateNewWatchRule = (formWarpRequest["ui.format"].value == 'HTML') && this.m_cv.bCanUseCognosViewerConditionalSubscriptions && this.m_bAllowSubscription;
- }
- /*
- Can the user subscribe to notifications
- - the report must not be bursted
- - user cannot have scheduled the report
- - report must allow notifications
- */
- this.m_bCanGetNotified = (!formWarpRequest["ui.burstKey"] || (formWarpRequest["ui.burstKey"] && formWarpRequest["ui.burstKey"].value == "")) && this.m_bAllowNotification;
- }
- }
- if (oSubscriptionInfo.sQueryNotificationResponse)
- {
- this.m_sQueryNotificationResponse = oSubscriptionInfo.sQueryNotificationResponse;
- }
- if (oSubscriptionInfo.aWatchRules)
- {
- var aWatchRules = oSubscriptionInfo.aWatchRules;
- this.m_aWatchRules = [];
- for (var i=0; i < aWatchRules.length; i++)
- {
- this.m_aWatchRules.push( aWatchRules[i] );
- }
- }
- this.m_bInitialized = true;
- return true;
- }
- }
- catch(exception)
- {
- return false;
- }
- return false;
- };
- /**
- Checks the current selection to see if it's valid for creating a new Watch Rule
- */
- CSubscriptionManager.prototype.IsValidSelectionForNewRule = function()
- {
- var selectionController = this.m_cv.getSelectionController();
- if (selectionController && !selectionController.hasSelectedChartNodes())
- {
- var selectedObjects = selectionController.getAllSelectedObjects();
- if (selectedObjects.length === 1)
- {
- if (selectedObjects[0] != null && selectedObjects[0].getLayoutType() != 'columnTitle')
- {
- return true;
- }
- }
- }
- return false;
- };
- /**
- Can the user create new watch rules
- */
- CSubscriptionManager.prototype.CanCreateNewWatchRule = function()
- {
- if (typeof this.m_cv.UIBlacklist != "undefined" && this.m_cv.UIBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_ALERT_USING_NEW_WATCH_RULE ') != -1)
- {
- return false;
- }
- // if we haven't been initialized yet and we're looking at saved output
- if (!this.m_bInitialized && this.getViewer().envParams["ui.action"] == 'view')
- {
- var oCV = this.getViewer();
- var request = new JSONDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.forceSynchronous();
- request.addFormField("ui.action", "getSubscriptionInfo");
- request.addFormField("cv.responseFormat", "subscriptionManager");
- request.addFormField("contextMenu", "true");
- this.addCommonFormFields(request);
- request.setCallbacks({"complete":{"object":this, "method":this.Initialize}});
- oCV.dispatchRequest(request);
- }
- return this.m_bCanCreateNewWatchRule;
- };
- /**
- Has the logic to determine if the current user can modify the Watch Rules
- */
- CSubscriptionManager.prototype.CanModifyWatchRule = function()
- {
- return this.m_cv.bCanUseCognosViewerConditionalSubscriptions && this.m_bAllowSubscription;
- };
- /**
- Has the logic to determine if the current user can subscribe to notifications
- */
- CSubscriptionManager.prototype.CanGetNotified = function()
- {
- if (typeof this.m_cv.UIBlacklist != "undefined" && this.m_cv.UIBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_ALERT_ABOUT_NEW_VERSIONS ') != -1)
- {
- return false;
- }
- return this.m_bCanGetNotified;
- };
- /**
- Updates the subscription dropdown menu
- */
- CSubscriptionManager.prototype.UpdateSubscribeMenu = function()
- {
- var toolbar = this.getStandaloneViewerToolbarControl();
- var subscribeButton = toolbar? toolbar.getItem("watchNewVersions") : null;
- var sWebContentRoot = this.m_cv.getWebContentRoot();
- var sSkin = this.m_cv.getSkin();
- if (subscribeButton)
- {
- var subscribeDropDownMenu = subscribeButton.getMenu();
- // Clear the menu
- this.ClearSubscriptionMenu();
- var bAddSeperator = false;
- if ( this.CanGetNotified() )
- {
- if (this.m_sQueryNotificationResponse == 'on')
- {
- new CMenuItem(subscribeDropDownMenu, RV_RES.RV_DO_NOT_ALERT_NEW_VERSION, "javascript:" + this.m_cv.getObjectId() + ".getSubscriptionManager().DeleteNotification();", sWebContentRoot + '/rv/images/action_remove_from_list.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- bAddSeperator = true;
- }
- else if (this.m_sQueryNotificationResponse == 'off' && this.m_sEmail != "")
- {
- new CMenuItem(subscribeDropDownMenu, RV_RES.RV_ALERT_NEW_VERSION, "javascript:" + this.m_cv.getObjectId() + ".getSubscriptionManager().AddNotification();", sWebContentRoot + '/rv/images/action_add_to_list.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- bAddSeperator = true;
- }
- }
- if (this.CanCreateNewWatchRule())
- {
- if (bAddSeperator)
- {
- subscribeDropDownMenu.add(gMenuSeperator);
- }
- var newSubscription = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NEW_WATCH_RULE, "javascript:" + this.m_cv.getObjectId() + ".getSubscriptionManager().NewSubscription();", sWebContentRoot + '/rv/images/action_new_subscription.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- if (!this.IsValidSelectionForNewRule())
- {
- newSubscription.disable();
- }
- bAddSeperator = true;
- }
- var sBlacklist = "";
- if (typeof this.m_cv.UIBlacklist != "undefined")
- {
- sBlacklist = this.m_cv.UIBlacklist;
- }
- var noWatchRules;
- //iterate through existing subscriptions
- if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES ') == -1)
- {
- if (bAddSeperator)
- {
- subscribeDropDownMenu.add(gMenuSeperator);
- }
- if ( this.m_aWatchRules && this.m_aWatchRules.length > 0)
- {
- var bCanModifyWatchRules = this.CanModifyWatchRule();
- for(var sub = 0; sub < this.m_aWatchRules.length; ++sub)
- {
- var menu = new CMenuItem(subscribeDropDownMenu, this.m_aWatchRules[sub].name, "", sWebContentRoot + "/rv/images/icon_subscription.gif", gMenuItemStyle, sWebContentRoot, sSkin);
- var subMenu = menu.createCascadedMenu(gMenuStyle);
- subMenu.m_oCV = this.m_cv;
- if (bCanModifyWatchRules && sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES_MODIFY ') == -1) {
- new CMenuItem(subMenu, RV_RES.RV_MODIFY_WATCH_RULE, this.m_cv.getObjectId() + ".getSubscriptionManager().ModifySubscription("+sub+");", sWebContentRoot + '/rv/images/action_edit.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- }
- if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES_DELETE ') == -1)
- {
- new CMenuItem(subMenu, RV_RES.RV_DELETE_WATCH_RULE, this.m_cv.getObjectId() + ".getSubscriptionManager().DeleteSubscription("+sub+");", sWebContentRoot + '/rv/images/action_delete.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- }
- }
- }
- else
- {
- noWatchRules = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NO_WATCH_RULES, "", '', gMenuItemStyle, sWebContentRoot, sSkin);
- noWatchRules.disable();
- }
- }
- if (subscribeDropDownMenu.getNumItems() == 0)
- {
- noWatchRules = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NO_WATCH_RULES, "", '', gMenuItemStyle, sWebContentRoot, sSkin);
- noWatchRules.disable();
- }
- // make sure we don't use the callback when drawing the menu
- subscribeDropDownMenu.setForceCallback(false);
- subscribeDropDownMenu.draw();
- if (subscribeDropDownMenu.isVisible()) {
- subscribeDropDownMenu.show();
- }
- // make sure our callback is used when the menu gets opened again
- subscribeDropDownMenu.setForceCallback(true);
- }
- };
- /**
- Updates the subscription dropdown menu
- */
- CSubscriptionManager.prototype.UpdateAnnotationMenu = function()
- {
- var toolbar = this.getStandaloneViewerToolbarControl();
- var annotationButton = toolbar? toolbar.getItem("addAnnotations") : null;
- var sWebContentRoot = this.m_cv.getWebContentRoot();
- var sSkin = this.m_cv.getSkin();
- var annotDropDownMenu = annotationButton.getMenu();
- // Clear the menu
- this.ClearAnnotationMenu();
- // add the create menu item
- var menu = new CMenuItem(annotDropDownMenu, RV_RES.RV_NEW_COMMENT, "javascript:" + this.m_cv.getObjectId() + ".getSubscriptionManager().NewAnnotation();", sWebContentRoot + "/rv/images/action_comment_add.gif", gMenuItemStyle, sWebContentRoot, sSkin);
- var annotationsCount = this.m_annotations.length;
- if (annotationsCount > 0) {
- annotDropDownMenu.add(gMenuSeperator);
- }
- // disable the item if allowAnnotations is false.
- if (!this.m_bAllowAnnotations || !this.m_bCanCreateAnnotations)
- {
- menu.disable();
- }
- //iterate through existing annotations
- var menuName;
- var bidi = isViewerBidiEnabled() ? BidiUtils.getInstance() : null;
- for(var i=0; i<annotationsCount; i++){
- var defName = this.m_annotations[i].defaultName ;
- menuName = defName.length>60 ? defName.substring(0, 60)+'...' : defName;
- if(isViewerBidiEnabled()){
- menuName = bidi.btdInjectUCCIntoStr(menuName, getViewerBaseTextDirection());
- }
- // check all the permissions
- var readPermission = Boolean(this.m_annotations[i].permissions.read);
- var modifyPermission = Boolean(this.m_annotations[i].permissions.write);
- var deletePermission = Boolean(this.m_annotations[i].permissions.traverse) && Boolean(this.m_annotations[i].permissions.write);
- var dispCmd = "javascript:" + this.m_cv.getObjectId() + ".getSubscriptionManager().ViewAnnotation("+i+");";
- var alertMsg = "javascript:alert('Permission denied')" ;
- dispCmd = readPermission ? dispCmd : alertMsg;
- // decide if we want to add a separator - which we do if the layoutElementId has changed
- if (i > 0 && this.m_annotations[i].layoutElementId != this.m_annotations[i-1].layoutElementId) {
- annotDropDownMenu.add(gMenuSeperator);
- }
- var menuItemImage = "/rv/images/action_comment.gif";
- if (this.m_annotations[i].layoutElementId != "") {
- menuItemImage = "/rv/images/action_subscribe.gif";
- }
- menu = new CMenuItem(annotDropDownMenu, menuName, dispCmd, sWebContentRoot + menuItemImage, gMenuItemStyle, sWebContentRoot, sSkin);
- // we only create the cascaded menu if can alter things
- var subMenu = menu.createCascadedMenu(gMenuStyle);
-
- // add an info pane to the top of the menu
- var infoPanel = new CInfoPanel("300px", sWebContentRoot, subMenu.getId() + "_comments");
- infoPanel.setParent(subMenu);
- // add all the properties that we want
- defName = this.m_annotations[i].defaultName ;
- var menuName1 = defName.length>60 ? defName.substring(0, 60)+'...' : defName;
- if(isViewerBidiEnabled()){
- menuName1 = bidi.btdInjectUCCIntoStr(menuName1, getViewerBaseTextDirection());
- }
- infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_NAME,html_encode(menuName1));
- infoPanel.addSpacer(4);
-
- var cmnt = this.m_annotations[i].description ;
- var shortComment = cmnt.length>590 ? cmnt.substring(0, 590)+'...' : cmnt;
- if(isViewerBidiEnabled()){
- shortComment = bidi.btdInjectUCCIntoStr(shortComment, getViewerBaseTextDirection());
- }
- infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_CONTENTS, replaceNewLine(html_encode(shortComment)));
- infoPanel.addSpacer(4);
-
- var modifyTime = this.m_annotations[i].modificationTime ;
-
- if(isViewerBidiEnabled()){
- modifyTime = bidi.btdInjectUCCIntoStr(modifyTime, getViewerBaseTextDirection());
- }
- infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_MODTIME,modifyTime);
-
- var ownerName = this.m_annotations[i].owner.defaultName ;
-
- if(isViewerBidiEnabled()){
- ownerName = bidi.btdInjectUCCIntoStr(ownerName, getViewerBaseTextDirection());
- }
-
- infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_OWNER, ownerName);
- // add the pane to the menu
- subMenu.add(infoPanel);
- // add a separator if we have actions
- if (modifyPermission || deletePermission) {
- subMenu.add(gMenuSeperator);
- }
- new CMenuItem(subMenu, RV_RES.RV_VIEW_COMMENT, this.m_cv.getObjectId() + ".getSubscriptionManager().ViewAnnotation("+i+");", sWebContentRoot + '/rv/images/action_comment_view.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- if (modifyPermission) {
- new CMenuItem(subMenu, RV_RES.RV_MODIFY_WATCH_RULE, this.m_cv.getObjectId() + ".getSubscriptionManager().ModifyAnnotation("+i+");", sWebContentRoot + '/rv/images/action_comment_modify.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- }
- if (deletePermission)
- {
- new CMenuItem(subMenu, RV_RES.RV_DELETE_WATCH_RULE, this.m_cv.getObjectId() + ".getSubscriptionManager().DeleteAnnotation("+i+");", sWebContentRoot + '/rv/images/action_comment_delete.gif', gMenuItemStyle, sWebContentRoot, sSkin);
- }
- }
- // make sure we don't use the callback when drawing the menu
- annotDropDownMenu.setForceCallback(false);
- annotDropDownMenu.draw();
- if (annotDropDownMenu.isVisible()) {
- annotDropDownMenu.show();
- }
- // make sure our callback is used when the menu gets opened again
- annotDropDownMenu.setForceCallback(true);
- };
- /**
- Called when the user clicked on the 'Alert Me About New Versions' link
- */
- CSubscriptionManager.prototype.AddNotification = function()
- {
- alert(this.m_sAlertNewVersionConfirm);
- var oCV = this.getViewer();
- var request = new DataDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.addFormField("ui.action", "addNotification");
- request.addFormField("cv.responseFormat", "data");
- this.addCommonFormFields(request);
- oCV.dispatchRequest(request);
- };
- /**
- Called when the user clicked on the 'Do Not Alert Me About New Versions' link
- */
- CSubscriptionManager.prototype.DeleteNotification = function()
- {
- alert(RV_RES.RV_DO_NOT_ALERT_NEW_VERSION_CONFIRM);
- var oCV = this.getViewer();
- var request = new DataDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.addFormField("ui.action", "deleteNotification");
- request.addFormField("cv.responseFormat", "data");
- this.addCommonFormFields(request);
- oCV.dispatchRequest(request);
- };
- /**
- Called when the user clicked on the 'Add annotation' link
- */
- CSubscriptionManager.prototype.NewAnnotation = function()
- {
- var oFWR = document.forms["formWarpRequest" + this.m_cv.getId()];
- var searchPath = oFWR["ui.object"].value;
- var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(), CSubscriptionManager.k_SubscriptionWizardName);
- GUtil.createFormField(form, "ui.object", searchPath);
- GUtil.createFormField(form, "b_action", "xts.run");
- GUtil.createFormField(form, "m", "rv/annotation1.xts");
- GUtil.createFormField(form, "backURL", "javascript:window.close();");
- GUtil.createFormField(form, "action_hint", "create");
- var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
- window.open(sPath, form.target, this.m_windowOptions);
- };
- /**
- Called when the user clicked on an annotation' link
- */
- CSubscriptionManager.prototype.ViewAnnotation = function(idx)
- {
- var sub = this.m_annotations[idx];
- var searchPath = sub.searchPath;
- var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(), CSubscriptionManager.k_SubscriptionWizardName);
- GUtil.createFormField(form, "ui.object", searchPath);
- GUtil.createFormField(form, "b_action", "xts.run");
- GUtil.createFormField(form, "m", "rv/annotation1.xts");
- GUtil.createFormField(form, "backURL", "javascript:window.close();");
- var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
- window.open(sPath, form.target, this.m_windowOptions);
- };
- /**
- User clicked the 'Modify...' link for a Watch Rule
- @param idx - index of the rule that was clicked on
- */
- CSubscriptionManager.prototype.ModifyAnnotation = function(idx)
- {
- var sub = this.m_annotations[idx];
- var searchPath = this.m_annotations[idx].searchPath;
- // we need report version here
- if (sub && searchPath)
- {
- var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(),
- CSubscriptionManager.k_SubscriptionWizardName);
- GUtil.createFormField(form, "ui.object", searchPath);
- GUtil.createFormField(form, "b_action", "xts.run");
- GUtil.createFormField(form, "m", "rv/annotation1.xts");
- GUtil.createFormField(form, "backURL", "javascript:window.close();");
- GUtil.createFormField(form, "action_hint", "save");
- var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
- window.open(sPath, form.target, this.m_windowOptions);
- }
- };
- /**
- Deletes an Annotation
- @param idx - index of the rule that was clicked on
- */
- CSubscriptionManager.prototype.DeleteAnnotation = function(idx)
- {
- var sub = this.m_annotations[idx];
- if (sub && sub.searchPath && confirm(RV_RES.RV_CONFIRM_DELETE_WATCH_RULE))
- {
- var oCV = this.getViewer();
- var request = new DataDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.addFormField("ui.action", "deleteAnnotation");
- request.addFormField("cv.responseFormat", "data");
- this.addCommonFormFields(request, sub.searchPath);
- oCV.dispatchRequest(request);
- }
- };
- /**
- Called when the user clicked on the 'Alert Using New Watch Rule' link
- */
- CSubscriptionManager.prototype.NewSubscription = function()
- {
- var sc = this.m_cv.getSelectionController();
- var oFWR = document.forms["formWarpRequest" + this.m_cv.getId()];
- var searchPath = oFWR.reRunObj.value;
- if (searchPath && sc && sc.getAllSelectedObjects().length === 1 )
- {
- var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(), CSubscriptionManager.k_SubscriptionWizardName);
- var fWR = document.getElementById("formWarpRequest" + this.m_cv.getId());
- var selectionXml = new CSelectionXml( fWR["ui.burstID"].value,
- fWR["ui.contentLocale"].value,
- fWR["ui.outputLocale"].value
- );
- selectionXml.BuildSelectionFromController(sc);
- //display a selectable-prompt containing the xml output -- TESTING ONLY
- //prompt("SelectionXML: ", selectionXml.toXml());
- GUtil.createFormField(form, "rv.selectionSpecXML", selectionXml.toXml());
- GUtil.createFormField(form, "rv.periodicalProducer", searchPath);
- GUtil.createFormField(form, "b_action", "xts.run");
- GUtil.createFormField(form, "m", "subscribe/conditional_subscribe1.xts");
- GUtil.createFormField(form, "backURL", "javascript:window.close();");
- var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
- window.open(sPath, form.target, "toolbar,location,status,menubar,resizable,scrollbars=1");
- }
- else
- {
- // for debugging
- // alert("Invalid Context: sc: " + sc + "\n searchPath: " + searchPath);
- }
- };
- /**
- Deletes a watch rule
- @param idx - index of the rule that was clicked on
- */
- CSubscriptionManager.prototype.DeleteSubscription = function(idx)
- {
- var sub = this.m_aWatchRules[idx];
- if (sub && sub.searchPath && confirm(RV_RES.RV_CONFIRM_DELETE_WATCH_RULE))
- {
- var oCV = this.getViewer();
- var request = new DataDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.addFormField("ui.action", "deleteSubscription");
- request.addFormField("cv.responseFormat", "data");
- this.addCommonFormFields(request, sub.searchPath);
- oCV.dispatchRequest(request);
- }
- };
- /**
- User clicked the 'Modify...' link for a Watch Rule
- @param idx - index of the rule that was clicked on
- */
- CSubscriptionManager.prototype.ModifySubscription = function(idx)
- {
- var sub = this.m_aWatchRules[idx];
- if (sub && sub.searchPath)
- {
- var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(),
- CSubscriptionManager.k_SubscriptionWizardName);
- GUtil.createFormField(form, "m_obj", sub.searchPath);
- GUtil.createFormField(form, "m_name", sub.name);
- GUtil.createFormField(form, "b_action", "xts.run");
- GUtil.createFormField(form, "m_class", "reportDataServiceAgentDefinition");
- GUtil.createFormField(form, "m", "portal/properties_subscription.xts");
- GUtil.createFormField(form, "backURL", "javascript:window.close();");
- var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
- window.open(sPath, form.target, "toolbar,location,status,menubar,resizable,scrollbars=1");
- }
- };
- /**
- Does an AJAX call to get the needed information, and then updated the
- drop down menu
- */
- CSubscriptionManager.prototype.OpenSubscriptionMenu = function()
- {
- var oCV = this.getViewer();
- var request = new JSONDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.addFormField("ui.action", "getSubscriptionInfo");
- request.addFormField("cv.responseFormat", "subscriptionManager");
- this.addCommonFormFields(request);
- request.setCallbacks({"complete":{"object":this, "method":this.OpenSubscriptionMenuResponse}});
- oCV.dispatchRequest(request);
- };
- /**
- Does an AJAX call to get the needed information, and then updated the
- drop down menu
- */
- CSubscriptionManager.prototype.OpenAnnotationMenu = function()
- {
- var oCV = this.getViewer();
- var request = new JSONDispatcherEntry(oCV);
- request.setKey("subscriptionManager");
- request.addFormField("ui.action", "getAnnotationInfo");
- request.addFormField("cv.responseFormat", "getAnnotations");
- var uiObject = oCV.envParams["ui.object"];
- this.addCommonFormFields(request, uiObject ? uiObject : "");
- request.setCallbacks({"complete":{"object":this, "method":this.OpenAnnotationMenuResponse}});
- oCV.dispatchRequest(request);
- };
- /**
- OpenSubscriptionMenuCallback will initialzie the CSubscriptionManager object and open the menu
- @param {httpRequest} the XML response from the viewer
- */
- CSubscriptionManager.prototype.OpenAnnotationMenuResponse = function(response)
- {
- if (this.Initialize(response)) {
- this.UpdateAnnotationMenu();
- }
- else {
- // something bad happened, just clear the menu
- this.ClearAnnotationMenu();
- }
- };
- /**
- OpenSubscriptionMenuCallback will initialzie the CSubscriptionManager object and open the menu
- @param {httpRequest} the XML response from the viewer
- */
- CSubscriptionManager.prototype.OpenSubscriptionMenuResponse = function(response)
- {
- if (this.Initialize(response))
- {
- this.UpdateSubscribeMenu();
- }
- else
- {
- // something bad happened, just clear the menu
- this.AddEmptySubscriptionMenuItem();
- }
- };
- CSubscriptionManager.prototype.addCommonFormFields = function(request, searchPath) {
- if (searchPath && searchPath != "") {
- request.addFormField("ui.object", searchPath);
- }
- else {
- var formWarpRequest = document["formWarpRequest" + this.getViewer().getId()];
- if (formWarpRequest && formWarpRequest["reRunObj"]) {
- request.addFormField("ui.object", formWarpRequest["reRunObj"].value);
- }
- }
- // if we're already initialized it'll cut down on the number of CM queries we need to do
- if (request.getFormField("ui.action") == "getSubscriptionInfo") {
- request.addFormField("initialized", this.m_bInitialized ? "true" : "false");
- }
- request.addFormField("cv.id", this.getViewer().getId());
- };
- /**
- * When there's nothing else to show in the Subscription menu, show
- * a disabled menu item
- */
- CSubscriptionManager.prototype.AddEmptySubscriptionMenuItem = function()
- {
- var toolbar = this.getStandaloneViewerToolbarControl();
- if (toolbar)
- {
- var subscribeButton = toolbar.getItem("watchNewVersions");
- if (subscribeButton)
- {
- subscribeButton.getMenu().clear();
- }
- var sWebContentRoot = this.m_cv.getWebContentRoot();
- var sSkin = this.m_cv.getSkin();
- var subscribeDropDownMenu = subscribeButton.getMenu();
- var noWatchRules = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NO_WATCH_RULES, "", '', gMenuItemStyle, sWebContentRoot, sSkin);
- noWatchRules.disable();
- // make sure we don't use the callback when drawing the menu
- subscribeDropDownMenu.setForceCallback(false);
- subscribeDropDownMenu.draw();
- if (subscribeDropDownMenu.isVisible()) {
- subscribeDropDownMenu.show();
- }
- // make sure our callback is used when the menu gets opened again
- subscribeDropDownMenu.setForceCallback(true);
- }
- };
- /**
- Removes all the menu items from the 'Watch New Versions' menu
- */
- CSubscriptionManager.prototype.ClearSubscriptionMenu = function()
- {
- var toolbar = this.getStandaloneViewerToolbarControl();
- if (toolbar)
- {
- var subscribeButton = toolbar.getItem("watchNewVersions");
- if (subscribeButton)
- {
- subscribeButton.getMenu().clear();
- }
- }
- };
- /**
- Removes all the menu items from the 'add Annotations' menu
- */
- CSubscriptionManager.prototype.ClearAnnotationMenu = function()
- {
- var toolbar = this.getStandaloneViewerToolbarControl();
- if (toolbar)
- {
- var annotationButton = toolbar.getItem("addAnnotations");
- if (annotationButton)
- {
- annotationButton.getMenu().clear();
- }
- }
- };
- /**
- Removes all the menu items from the 'add Annotations' menu
- */
- CSubscriptionManager.prototype.ClearContextAnnotationMenu = function()
- {
- var contextMenu = this.getStandaloneViewerContextMenu();
- if (contextMenu)
- {
- var commentFindAnnotationsMenu = contextMenu.getFindCommentMenuItem();
- if (commentFindAnnotationsMenu)
- {
- commentFindAnnotationsMenu.getMenu().clear();
- }
- }
- };
- CSubscriptionManager.prototype.getStandaloneViewerToolbarControl = function()
- {
- if(typeof this.m_cv.rvMainWnd != "undefined" && this.m_cv.rvMainWnd != null && typeof this.m_cv.rvMainWnd.getToolbarControl == "function")
- {
- return this.m_cv.rvMainWnd.getToolbarControl();
- }
- else
- {
- return null;
- }
- };
- CSubscriptionManager.prototype.getStandaloneViewerContextMenu = function()
- {
- if(typeof this.m_cv.rvMainWnd != "undefined" && this.m_cv.rvMainWnd != null && typeof this.m_cv.rvMainWnd.getContextMenu == "function")
- {
- return this.m_cv.rvMainWnd.getContextMenu();
- }
- else
- {
- return null;
- }
- };
|