viewer.extra.debug.js 575 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2014
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /*
  13. *+------------------------------------------------------------------------+
  14. *| Licensed Materials - Property of IBM
  15. *| IBM Cognos Products: Viewer
  16. *| (C) Copyright IBM Corp. 2001, 2014
  17. *|
  18. *| US Government Users Restricted Rights - Use, duplication or
  19. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  20. *|
  21. *+------------------------------------------------------------------------+
  22. */
  23. function ViewerA11YHelper(oCV) {
  24. this.m_oCV = oCV;
  25. }
  26. ViewerA11YHelper.prototype.onFocus = function(evt) {
  27. var targetNode = getCrossBrowserNode(evt);
  28. targetNode = ViewerA11YHelper.findChildOfTableCell(targetNode);
  29. this.updateCellAccessibility(targetNode, false);
  30. };
  31. ViewerA11YHelper.prototype.onKeyDown = function(evt) {
  32. //get the event in a cross-browser fashion
  33. evt = (evt) ? evt : ((event) ? event : null);
  34. var srcNode = getCrossBrowserNode(evt);
  35. // In IE, if the user clicked on the white space instead of the text in a cell, the srcNode
  36. // will point to the TD or TH. Get the span within the TD or TH
  37. if (ViewerA11YHelper.isTableCell(srcNode)) {
  38. for (var i=0; i < srcNode.childNodes.length; i++) {
  39. if (srcNode.childNodes[i].nodeName.toLowerCase() == "span") {
  40. srcNode = srcNode.childNodes[i];
  41. break;
  42. }
  43. }
  44. }
  45. // if the event didn't come from an element we'd select then let it bubble up
  46. if (!this.isValidNodeToSelect(srcNode)) {
  47. return true;
  48. }
  49. srcNode = ViewerA11YHelper.findChildOfTableCell(srcNode);
  50. if (srcNode) {
  51. if (evt.keyCode == "39") { // right arrow
  52. if (this.m_oCV.getState() && this.m_oCV.getState().getFindState() && evt.ctrlKey && evt.shiftKey ) { // Ctrl+Shilf+ right arrow
  53. this.m_oCV.executeAction("FindNext");
  54. } else {
  55. this.moveRight(srcNode);
  56. }
  57. return stopEventBubble(evt);
  58. }
  59. else if (evt.keyCode == "37") { // left arrow
  60. this.moveLeft(srcNode);
  61. return stopEventBubble(evt);
  62. }
  63. else if (evt.keyCode == "38") { // up arrow
  64. this.moveUp(srcNode);
  65. return stopEventBubble(evt);
  66. }
  67. else if (evt.keyCode == "40") { // down arrow
  68. this.moveDown(srcNode);
  69. return stopEventBubble(evt);
  70. }
  71. else if (evt.keyCode == "13") { // enter
  72. if (this.m_oCV.isBux) {
  73. if( this.m_oCV.getViewerWidget().isSelectionFilterEnabled() ){
  74. this.m_oCV.getViewerWidget().preprocessPageClicked( false /*invokingContextMenu*/, evt);
  75. if( this.m_oCV.getSelectionController().pageClicked(evt) !== false ){
  76. this.m_oCV.JAWSTalk( RV_RES.IDS_JS_SELECTION_FILTER_INFO_JAWS );
  77. this.m_oCV.getViewerWidget().updateToolbar();
  78. }
  79. } else {
  80. this.m_oCV.getSelectionController().pageClicked(evt);
  81. var selectionAction = this.m_oCV.getActionFactory().load("Selection");
  82. selectionAction.onKeyDown(evt);
  83. }
  84. this.m_oCV.getViewerWidget().onSelectionChange();
  85. } else {
  86. this.m_oCV.de(evt);
  87. }
  88. }
  89. else if (evt.keyCode == "32") { // space
  90. if( this.m_oCV.isBux )
  91. {
  92. this.m_oCV.getViewerWidget().preprocessPageClicked( false /*invokingContextMenu*/);
  93. if( this.m_oCV.getSelectionController().pageClicked(evt) !== false && this.m_oCV.getViewerWidget().isSelectionFilterEnabled() )
  94. {
  95. this.m_oCV.JAWSTalk( RV_RES.IDS_JS_SELECTION_FILTER_INFO_JAWS );
  96. }
  97. this.m_oCV.getViewerWidget().updateToolbar();
  98. this.m_oCV.getViewerWidget().onSelectionChange();
  99. } else {
  100. this.m_oCV.getSelectionController().pageClicked(evt);
  101. }
  102. return stopEventBubble(evt);
  103. }
  104. else if(evt.keyCode == "46" && this.m_oCV.isBux) { // delete key
  105. if (typeof this.m_oCV.envParams != "undefined" &&
  106. typeof this.m_oCV.envParams["ui.action"] != "undefined" &&
  107. this.m_oCV.envParams["ui.action"] != "view" &&
  108. !this.m_oCV.isLimitedInteractiveMode())
  109. {
  110. var deleteAction = this.m_oCV.getActionFactory().load("Delete");
  111. if(!this.m_oCV.isBlacklisted("Delete") && deleteAction.canDelete())
  112. {
  113. deleteAction.execute();
  114. return stopEventBubble(evt);
  115. }
  116. }
  117. }
  118. else if (this.m_oCV.isBux && evt.ctrlKey == true && evt.shiftKey == true && evt.keyCode == "49") { // Ctrl + shift + !
  119. var lid = this.m_oCV.getSelectionController().getSelectionObjectFactory().getLayoutElementId(srcNode);
  120. if (lid != "") {
  121. // get the lid without the Viewer id appended to it.
  122. lid = lid.split(this.m_oCV.getId())[0];
  123. var containerIdx = -1;
  124. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  125. if (oRAPReportInfo) {
  126. var container = oRAPReportInfo.getContainer(lid);
  127. if (typeof container.layoutIndex != "undefined") {
  128. containerIdx = container.layoutIndex;
  129. }
  130. }
  131. var infoBarHeaderButton = document.getElementById("infoBarHeaderButton" + containerIdx + this.m_oCV.getId());
  132. if (infoBarHeaderButton !== null) {
  133. this.m_oCV.setCurrentNodeFocus(getCrossBrowserNode(evt));
  134. infoBarHeaderButton.focus();
  135. }
  136. }
  137. return stopEventBubble(evt);
  138. }
  139. else if (!this.m_oCV.isBux && evt.shiftKey == true && evt.keyCode == "121") { // Shift - F10 (context menu) -- standalone viewer
  140. //Only cover Shift + F10. Menu button is already covered by the body's onContextMenu callback.
  141. var ocv = this.m_oCV;
  142. var openContextMenu = function() {
  143. //Some browsers don't populate the evt.clientX/Y fields on keyboard
  144. //events, which the display content menu function requires.
  145. if (typeof evt.clientX == "undefined" || typeof evt.clientY == "undefined") {
  146. var coords = clientToScreenCoords(evt.target, document.body);
  147. evt.clientX = coords.leftCoord;
  148. evt.clientY = coords.topCoord;
  149. }
  150. ocv.dcm(evt, true);
  151. };
  152. if(isFF()) {
  153. //In FF, need to invoke this code after this thread's execution is done.
  154. setTimeout(openContextMenu, 0);
  155. } else {
  156. //Other browsers, should invoke right away
  157. //(Espcially IE, where evt's state is cleared after)
  158. openContextMenu.call();
  159. }
  160. //Swallow event so browser's context menu is not shown
  161. return stopEventBubble(evt);
  162. }
  163. else if (this.m_oCV.isBux && (evt.keyCode == "93" || (evt.shiftKey == true && evt.keyCode == "121"))) { // Shift - F10 / menu button (context menu) -- BUX
  164. var viewerWidget = this.m_oCV.getViewerWidget();
  165. var selectionController = this.m_oCV.getSelectionController();
  166. viewerWidget.preprocessPageClicked( true /*invokingContextMenu*/);
  167. selectionController.pageClicked(evt);
  168. viewerWidget.updateToolbar();
  169. viewerWidget.onContextMenu(evt);
  170. }
  171. }
  172. };
  173. ViewerA11YHelper.prototype.isValidNodeToSelect = function(node) {
  174. return this.getValidNodeToSelect(node) ? true : false;
  175. };
  176. ViewerA11YHelper.prototype.getValidNodeToSelect = function(node) {
  177. if (node && node.style && node.style.visibility != "hidden" && node.style.display != "none") {
  178. var sNodeName = node.nodeName.toLowerCase();
  179. if (
  180. (sNodeName == "span" && (!node.getAttribute("class") || node.getAttribute("class").indexOf("expandButton") === -1)) ||
  181. (sNodeName == "div" && node.getAttribute("flashchartcontainer") == "true") ||
  182. (sNodeName == "div" && node.getAttribute("chartcontainer") == "true") ||
  183. (sNodeName == "img" && (!node.id || node.id.indexOf("sortimg") !== 0 ))
  184. ) {
  185. return node;
  186. }
  187. if (ViewerA11YHelper.isSemanticNode(node)) {
  188. var child = node.childNodes && node.childNodes.length ? node.childNodes[0] : null;
  189. if(child) {
  190. return this.getValidNodeToSelect(child);
  191. }
  192. }
  193. }
  194. return null;
  195. };
  196. ViewerA11YHelper.isSemanticNode = function(node) {
  197. if(!ViewerA11YHelper.isSemanticNode._semanticNodeNames) {
  198. ViewerA11YHelper.isSemanticNode._semanticNodeNames = [
  199. "strong", "em", "h1", "h2", "h3", "h4", "h5", "h6"
  200. ];
  201. }
  202. var sNodeName = node.nodeName.toLowerCase();
  203. for(var i = 0; i < ViewerA11YHelper.isSemanticNode._semanticNodeNames.length; i++) {
  204. if(sNodeName === ViewerA11YHelper.isSemanticNode._semanticNodeNames[i]) {
  205. return true;
  206. }
  207. }
  208. return false;
  209. };
  210. ViewerA11YHelper.isTableCell = function(node) {
  211. var sNodeName = node.nodeName.toLowerCase();
  212. return sNodeName === "td" || sNodeName === "th";
  213. };
  214. ViewerA11YHelper.findChildOfTableCell = function(startNode) {
  215. var srcNode = startNode;
  216. while(srcNode && srcNode.parentNode) {
  217. if (ViewerA11YHelper.getTableCell(srcNode)) {
  218. break;
  219. }
  220. srcNode = srcNode.parentNode;
  221. }
  222. return srcNode;
  223. };
  224. ViewerA11YHelper.getTableCell = function(node) {
  225. var parent = node.parentNode;
  226. if(ViewerA11YHelper.isTableCell(parent)) {
  227. return parent;
  228. }
  229. //Treat a semantic node under the <td> as parent of the <td>
  230. if (ViewerA11YHelper.isSemanticNode(parent) && ViewerA11YHelper.isTableCell(parent.parentNode)) {
  231. return parent.parentNode;
  232. }
  233. return null;
  234. };
  235. ViewerA11YHelper.prototype.moveRight = function(srcNode) {
  236. var nextNode = this.getNextNonTextSibling(srcNode);
  237. nextNode = this.getValidNodeToSelect(nextNode);
  238. // case where we have multiple spans inside a td
  239. if (nextNode) {
  240. this.setFocusToNode(nextNode);
  241. return true;
  242. }
  243. var tdNode = ViewerA11YHelper.getTableCell(srcNode);
  244. tdNode = this.getPfMainOutputCell(tdNode);
  245. while (tdNode.nextSibling) {
  246. if (this.moveToTD(tdNode.nextSibling)) {
  247. return true;
  248. }
  249. tdNode = tdNode.nextSibling;
  250. }
  251. var trNode = tdNode.parentNode;
  252. while (trNode.nextSibling) {
  253. var nextTR = trNode.nextSibling;
  254. if (this.moveToTD(nextTR.childNodes[0])) {
  255. return true;
  256. }
  257. trNode = trNode.nextSibling;
  258. }
  259. return false;
  260. };
  261. ViewerA11YHelper.prototype.moveLeft = function(srcNode) {
  262. var previousNode = this.getPreviousNonTextSibling(srcNode);
  263. previousNode = this.getValidNodeToSelect(previousNode);
  264. // case where we have multiple spans inside a td
  265. if (previousNode) {
  266. this.setFocusToNode(previousNode);
  267. return true;
  268. }
  269. var tdNode = ViewerA11YHelper.getTableCell(srcNode);
  270. tdNode = this.getPfMainOutputCell(tdNode);
  271. while (tdNode.previousSibling) {
  272. if (this.moveToTDFromTheRight(tdNode.previousSibling)) {
  273. return true;
  274. }
  275. tdNode = tdNode.previousSibling;
  276. }
  277. var trNode = tdNode.parentNode;
  278. while (trNode.previousSibling) {
  279. var previousTR = trNode.previousSibling;
  280. if (this.moveToTDFromTheRight(previousTR.lastChild)) {
  281. return true;
  282. }
  283. trNode = trNode.previousSibling;
  284. }
  285. return false;
  286. };
  287. ViewerA11YHelper.prototype.moveDown = function(srcNode) {
  288. var tdNode = ViewerA11YHelper.getTableCell(srcNode);
  289. tdNode = this.getPfMainOutputCell(tdNode);
  290. var srcColSpan = this.getColumnIndex(tdNode);
  291. srcColSpan += this.getColSpanFromRowSpans(tdNode);
  292. // if the current node has a rowSpan, we need to jump over a bunch of TR's
  293. var trNode = tdNode.parentNode;
  294. if (tdNode.rowSpan && tdNode.rowSpan > 1) {
  295. var nodeRowSpan = tdNode.rowSpan;
  296. for (var rowSpanIndex=1; rowSpanIndex < nodeRowSpan; rowSpanIndex++) {
  297. trNode = trNode.nextSibling;
  298. }
  299. }
  300. var bTriedNextColumn = false;
  301. while(trNode) {
  302. if (trNode.nextSibling) { // get the next TR
  303. trNode = trNode.nextSibling;
  304. } else if (tdNode.nextSibling && !bTriedNextColumn) { // move to the next column
  305. trNode = trNode.parentNode.firstChild;
  306. bTriedNextColumn = true;
  307. srcColSpan++;
  308. } else { // last span is selected
  309. return false;
  310. }
  311. if (this.doMoveUpDown(trNode, srcColSpan)) {
  312. return true;
  313. }
  314. }
  315. return false;
  316. };
  317. ViewerA11YHelper.prototype.moveUp = function(srcNode) {
  318. var tdNode = ViewerA11YHelper.getTableCell(srcNode);
  319. tdNode = this.getPfMainOutputCell(tdNode);
  320. var trNode = tdNode.parentNode;
  321. var srcColSpan = this.getColumnIndex(tdNode);
  322. srcColSpan += this.getColSpanFromRowSpans(tdNode);
  323. var bTriedPreviousColumn = false;
  324. while(trNode) {
  325. if (trNode.previousSibling) { // get the next TR
  326. trNode = trNode.previousSibling;
  327. } else if (tdNode.previousSibling && !bTriedPreviousColumn) { // move to the next column
  328. trNode = trNode.parentNode.lastChild;
  329. bTriedPreviousColumn = true;
  330. srcColSpan--;
  331. } else { // last span is selected
  332. return false;
  333. }
  334. if (this.doMoveUpDown(trNode, srcColSpan)) {
  335. return true;
  336. }
  337. }
  338. return false;
  339. };
  340. ViewerA11YHelper.prototype.getNextNonTextSibling = function(node) {
  341. while (node.nextSibling) {
  342. node = node.nextSibling;
  343. if (node.nodeName.toLowerCase() != '#text') {
  344. return node;
  345. }
  346. }
  347. if (ViewerA11YHelper.isSemanticNode(node.parentNode)) {
  348. return this.getNextNonTextSibling(node.parentNode);
  349. }
  350. return null;
  351. };
  352. ViewerA11YHelper.prototype.doMoveUpDown = function(trNode, srcColSpan) {
  353. if (trNode != null) {
  354. var currentColumn = trNode.firstChild;
  355. var pos = this.getColSpanFromRowSpans(currentColumn);
  356. while (currentColumn) {
  357. if (pos == srcColSpan) {
  358. return this.moveToTDFromTheRight(currentColumn);
  359. } else if (pos > srcColSpan) {
  360. break;
  361. }
  362. var nodeColSpan = 0;
  363. if (currentColumn.colSpan) {
  364. nodeColSpan = currentColumn.colSpan;
  365. } else {
  366. nodeColSpan++;
  367. }
  368. pos += nodeColSpan;
  369. currentColumn = currentColumn.nextSibling;
  370. }
  371. }
  372. };
  373. ViewerA11YHelper.prototype.moveToTDFromTheRight = function(td) {
  374. td = this.getPfVisibleCell(td);
  375. var childNodes = td.childNodes;
  376. for (var iChildIndex=childNodes.length-1; iChildIndex >= 0; iChildIndex--) {
  377. var node = this.getValidNodeToSelect(childNodes[iChildIndex]);
  378. if (node) {
  379. // sometimes have a span inside a span
  380. if (node.childNodes && node.childNodes[0] && node.childNodes[0].nodeName.toLowerCase() == "span") {
  381. node = node.childNodes[0];
  382. }
  383. if (node.tabIndex != -1 && node.tabIndex != 0) {
  384. node.tabIndex = -1;
  385. }
  386. this.setFocusToNode(node);
  387. return true;
  388. }
  389. }
  390. return false;
  391. };
  392. ViewerA11YHelper.prototype.moveToTD = function(td) {
  393. td = this.getPfVisibleCell(td);
  394. var childNodes = td.childNodes;
  395. for (var iChildIndex=0; iChildIndex < childNodes.length; iChildIndex++) {
  396. var node = this.getValidNodeToSelect(childNodes[iChildIndex]);
  397. if (node) {
  398. // sometimes have a span inside a span
  399. if (node.childNodes && node.childNodes[0] && node.childNodes[0].nodeName.toLowerCase() == "span") {
  400. node = node.childNodes[0];
  401. }
  402. if (node.tabIndex != -1 && node.tabIndex != 0) {
  403. node.tabIndex = -1;
  404. }
  405. this.setFocusToNode(node);
  406. return true;
  407. }
  408. }
  409. return false;
  410. };
  411. ViewerA11YHelper.prototype.setFocusToNode = function(node) {
  412. this.m_oCV.setCurrentNodeFocus(node);
  413. this.updateCellAccessibility(node, false);
  414. node.focus();
  415. if(this.m_oCV.m_pinFreezeManager) {
  416. var container = this.m_oCV.m_pinFreezeManager.nodeToContainer(node);
  417. if(container) {
  418. container.updateScroll(node);
  419. }
  420. }
  421. };
  422. /**
  423. * Given an element, return the main it is based on. This may be itself.
  424. */
  425. ViewerA11YHelper.prototype.getPfMainOutputCell = function(element) {
  426. var main = null
  427. var slid = element.getAttribute("pfslid");
  428. if(slid) {
  429. var lid = PinFreezeContainer.getLidFromSlid(slid);
  430. if(lid && this.m_oCV.m_pinFreezeManager) {
  431. lid = this.m_oCV.m_pinFreezeManager.removeNamespace(lid);
  432. var container = this.m_oCV.m_pinFreezeManager.getContainer(lid);
  433. if(container) {
  434. main = container.getMain(element);
  435. }
  436. }
  437. }
  438. return main ? main : element;
  439. };
  440. ViewerA11YHelper.prototype.getPreviousNonTextSibling = function(node) {
  441. while (node.previousSibling) {
  442. node = node.previousSibling;
  443. if (node.nodeName.toLowerCase() != '#text') {
  444. return node;
  445. }
  446. }
  447. if (ViewerA11YHelper.isSemanticNode(node.parentNode)) {
  448. return this.getPreviousNonTextSibling(node.parentNode);
  449. }
  450. return null;
  451. };
  452. /**
  453. * Returns the column index of the node with all the colspans.
  454. * This function excludes any td's that have a rowspan
  455. */
  456. ViewerA11YHelper.prototype.getColumnIndex = function(node) {
  457. var colIndex = 0;
  458. while (node.previousSibling) {
  459. node = node.previousSibling;
  460. if (node.rowSpan == 1) {
  461. if (node.colSpan) {
  462. colIndex += node.colSpan;
  463. } else {
  464. colIndex++;
  465. }
  466. }
  467. }
  468. return colIndex;
  469. };
  470. /**
  471. * Given an element, return the visible copy of it. This may be itself.
  472. */
  473. ViewerA11YHelper.prototype.getPfVisibleCell = function(element) {
  474. var copy = null;
  475. var slid = element.getAttribute("pfslid");
  476. if(slid) {
  477. var lid = PinFreezeContainer.getLidFromSlid(slid);
  478. if(lid && this.m_oCV.m_pinFreezeManager) {
  479. lid = this.m_oCV.m_pinFreezeManager.removeNamespace(lid);
  480. var container = this.m_oCV.m_pinFreezeManager.getContainer(lid);
  481. if(container) {
  482. copy = container.getCopy(element);
  483. }
  484. }
  485. }
  486. return copy ? copy : element;
  487. };
  488. ViewerA11YHelper.prototype.updateCellAccessibility = function(srcNode, force) {
  489. if (!srcNode) {
  490. return false;
  491. }
  492. var canDrillDown = false;
  493. var canDrillUp = false;
  494. var canDrillThrough = false;
  495. var ctxNode = srcNode.getAttribute("ctx") != null ? srcNode : srcNode.parentNode;
  496. if (srcNode.getAttribute("flashChartContainer") != "true") {
  497. if (ctxNode.getAttribute("ctx") != null) {
  498. if (this.m_oCV.isBux) {
  499. var action = this.m_oCV.getAction("DrillUpDown");
  500. action.updateDrillability(this.m_oCV, ctxNode);
  501. canDrillDown = action.canDrillDown();
  502. canDrillUp = action.canDrillUp();
  503. } else {
  504. var ctxAttribute = ctxNode.getAttribute("ctx");
  505. var ctxID = ctxAttribute.indexOf(':') == -1 ? ctxAttribute : ctxAttribute.substring(0, ctxAttribute.indexOf(":"));
  506. var selCon = this.m_oCV.getSelectionController();
  507. canDrillDown = selCon.canDrillDown(ctxID);
  508. canDrillUp = selCon.canDrillUp(ctxID);
  509. }
  510. }
  511. canDrillThrough = srcNode.parentNode.getAttribute("dtTargets") ? true : false;
  512. }
  513. var isImage = srcNode.nodeName.toLowerCase() == "img";
  514. var isColumnTitle = srcNode.parentNode.getAttribute("type") == "columnTitle";
  515. if ( !isImage && (force || ((srcNode.getAttribute("aria-labelledby") != null || isColumnTitle || this.m_oCV.isAccessibleMode())))) {
  516. var innerHTML = "";
  517. // crosstab corner
  518. if (srcNode.parentNode.getAttribute("cc") == "true") {
  519. innerHTML += " " + RV_RES.IDS_JS_CROSSTAB_CORNER;
  520. }
  521. if (srcNode.innerHTML.length === 0) {
  522. srcNode.innerHTML = "&nbsp;";
  523. innerHTML += " " + RV_RES.IDS_JS_EMPTY_CELL;
  524. }
  525. if (canDrillDown && canDrillUp) {
  526. innerHTML += " " + RV_RES.IDS_JS_DRILL_DOWN_UP_JAWS;
  527. } else if (canDrillDown) {
  528. innerHTML += " " + RV_RES.IDS_JS_DRILL_DOWN_JAWS;
  529. } else if (canDrillUp) {
  530. innerHTML += " " + RV_RES.IDS_JS_DRILL_UP_JAWS;
  531. }
  532. if (canDrillThrough) {
  533. innerHTML += " " + RV_RES.IDS_JS_DRILL_THROUGH_JAWS;
  534. }
  535. if (srcNode.altText && srcNode.altText.length > 0) {
  536. innerHTML = srcNode.altText;
  537. } else if (srcNode.getAttribute("flashChartContainer") == "true") {
  538. innerHTML = RV_RES.IDS_JS_CHART_IMAGE;
  539. }
  540. if( this.m_oCV.isBux ) {
  541. var sibling = srcNode.previousSibling;
  542. if (sibling) {
  543. var wid = sibling.getAttribute("widgetid");
  544. if (wid && wid.indexOf("comment")) {
  545. innerHTML += " " + RV_RES.IDS_JS_ANNOTATION_JAWS;
  546. }
  547. }
  548. if (srcNode.getAttribute("rp_name") || srcNode.parentNode.getAttribute("rp_name")) {
  549. innerHTML += " " + RV_RES.IDS_JS_LABEL_HAS_BEEN_RENAMED;
  550. }
  551. if (srcNode.nextSibling && srcNode.nextSibling.getAttribute("class") == "sortIconVisible") {
  552. innerHTML += " " + srcNode.nextSibling.getAttribute("alt");
  553. }
  554. }
  555. // is there any extra information that JAWS needs to speak out
  556. if (innerHTML.length > 0) {
  557. this.addAriaLabelledByOnCell(srcNode, innerHTML);
  558. }
  559. }
  560. if (canDrillUp || canDrillDown || canDrillThrough) {
  561. this.addDrillAccessibilityAttributes(srcNode, canDrillThrough);
  562. }
  563. if(srcNode.attachEvent) {
  564. srcNode.attachEvent("onblur", this.onBlur);
  565. } else {
  566. srcNode.addEventListener("blur", this.onBlur, false);
  567. }
  568. if ((isIE() && srcNode.getAttribute("tabIndex") != 0) || isImage) {
  569. srcNode.setAttribute("modifiedTabIndex", "true");
  570. srcNode.setAttribute("oldTabIndex", srcNode.getAttribute("tabIndex"));
  571. srcNode.setAttribute("tabIndex", 0);
  572. }
  573. };
  574. ViewerA11YHelper.prototype.addAriaLabelledByOnCell = function(srcNode, labelledBy) {
  575. // can have multiple spans inside a td, get the position to help make the id unique
  576. var srcNodePos = 0;
  577. var tempNode = srcNode;
  578. while (tempNode.previousSibling) {
  579. srcNodePos++;
  580. tempNode = tempNode.previousSibling;
  581. }
  582. var hiddenSpanId = srcNode.getAttribute("ariaHiddenSpanId");
  583. // if we already have a hidden span, use it
  584. if (hiddenSpanId && document.getElementById(hiddenSpanId)) {
  585. document.getElementById(hiddenSpanId).innerHTML = labelledBy;
  586. }
  587. else {
  588. if (!srcNode.parentNode.id && !srcNode.id) {
  589. srcNode.parentNode.id = Math.random();
  590. }
  591. var newSpan = document.createElement("span");
  592. newSpan.style.visibility = "hidden";
  593. newSpan.style.display = "none";
  594. newSpan.id = (srcNode.id == "" ? srcNode.parentNode.id : srcNode.id) + "_" + srcNodePos;
  595. newSpan.innerHTML = labelledBy;
  596. srcNode.parentNode.appendChild(newSpan);
  597. var ariaLabelledBy = "";
  598. if (srcNode.getAttribute("aria-labelledby") != null) {
  599. ariaLabelledBy += srcNode.getAttribute("aria-labelledby");
  600. } else {
  601. if (srcNode.id == "") {
  602. srcNode.id = srcNode.parentNode.id + "_main_" + srcNodePos;
  603. }
  604. ariaLabelledBy += srcNode.id;
  605. }
  606. ariaLabelledBy += " " + newSpan.id;
  607. srcNode.setAttribute("aria-labelledby", ariaLabelledBy);
  608. srcNode.setAttribute("ariaHiddenSpanId", newSpan.id);
  609. }
  610. };
  611. ViewerA11YHelper.prototype.addDrillAccessibilityAttributes = function(srcNode, canDrillThrough) {
  612. if (!srcNode.getAttribute("oldClassName")) {
  613. // drill throughs already have a link
  614. if (!canDrillThrough) {
  615. srcNode.setAttribute("oldClassName", srcNode.className);
  616. srcNode.className = "dl " + srcNode.className;
  617. }
  618. if (!srcNode.getAttribute("role")) {
  619. srcNode.setAttribute("role", "link");
  620. }
  621. }
  622. };
  623. ViewerA11YHelper.prototype.onBlur = function(evt) {
  624. var srcNode = null;
  625. if(isIE()) {
  626. srcNode = getNodeFromEvent(evt, true);
  627. } else {
  628. srcNode = this;
  629. }
  630. srcNode = ViewerA11YHelper.findChildOfTableCell(srcNode);
  631. if (srcNode) {
  632. if (srcNode.getAttribute("oldClassName")) {
  633. srcNode.className = srcNode.getAttribute("oldClassName");
  634. srcNode.removeAttribute("oldClassName");
  635. }
  636. if (srcNode.getAttribute("modifiedTabIndex") == "true") {
  637. srcNode.removeAttribute("modifiedTabIndex");
  638. srcNode.removeAttribute("tabIndex");
  639. if (srcNode.getAttribute("oldTabIndex")) {
  640. srcNode.setAttribute("tabIndex", srcNode.getAttribute("oldTabIndex"));
  641. }
  642. srcNode.removeAttribute("oldTabIndex");
  643. }
  644. // blank out any extra info for JAWS when we leave the cell.
  645. var ariaSpanId = srcNode.getAttribute("ariaHiddenSpanId");
  646. if (ariaSpanId)
  647. {
  648. var ariaSpanEle = document.getElementById(ariaSpanId);
  649. if (ariaSpanEle)
  650. {
  651. ariaSpanEle.innerHTML = "";
  652. }
  653. }
  654. }
  655. };
  656. /**
  657. * Method that walks the tree from the given TD and calculates
  658. * the colspans that are from TD's with rowspan's on them
  659. */
  660. ViewerA11YHelper.prototype.getColSpanFromRowSpans = function(tdNode) {
  661. var nodeColSpan = 0;
  662. var trNode = tdNode.parentNode;
  663. var trChildCount = 0;
  664. while (trNode) {
  665. var rowChildNode = trNode.firstChild;
  666. // if there's a diff in the #of columns, we must of found a new TD with a rowspan
  667. var colCountDiff = this.getColumnCount(trNode) - trChildCount;
  668. while (rowChildNode && rowChildNode.rowSpan > 1 && colCountDiff > 0 && rowChildNode != tdNode) {
  669. nodeColSpan += rowChildNode.colSpan;
  670. rowChildNode = rowChildNode.nextSibling;
  671. colCountDiff--;
  672. }
  673. // never decrease the column count, only increase it
  674. if (trNode.childNodes.length > trChildCount) {
  675. trChildCount = this.getColumnCount(trNode);
  676. }
  677. // get the previous TR.. keep walking the DOM
  678. trNode = trNode.previousSibling;
  679. }
  680. return nodeColSpan;
  681. };
  682. /**
  683. * Gets the column count for the given TR which includes all the colspans
  684. */
  685. ViewerA11YHelper.prototype.getColumnCount = function(trNode) {
  686. var columnCount = 0;
  687. var node = trNode.firstChild;
  688. while (node) {
  689. columnCount += node.colSpan;
  690. node = node.nextSibling;
  691. }
  692. return columnCount;
  693. };
  694. /**
  695. * Sets up the aria labelledBy for cells outside of a data container (list/crosstab)
  696. */
  697. ViewerA11YHelper.prototype.addLabelledByForItemsOutsideOfContainers = function() {
  698. // Only needs to be done when accesibility preference is set
  699. if (!this.m_oCV.isAccessibleMode()) {
  700. return;
  701. }
  702. var content = document.getElementById("RVContent" + this.m_oCV.getId());
  703. if (!content) {
  704. return;
  705. }
  706. // Get all the spans that have a tabinex of 0. This should be a small list
  707. var focusableSpans = getElementsByAttribute(content, "span", "tabindex", "0");
  708. if (!focusableSpans) {
  709. return;
  710. }
  711. for (var i=0; i < focusableSpans.length; i++) {
  712. var span = focusableSpans[i];
  713. this.updateCellAccessibility(span, false);
  714. }
  715. };/*
  716. *+------------------------------------------------------------------------+
  717. *| Licensed Materials - Property of IBM
  718. *| IBM Cognos Products: Viewer
  719. *| (C) Copyright IBM Corp. 2001, 2019
  720. *|
  721. *| US Government Users Restricted Rights - Use, duplication or
  722. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  723. *|
  724. *+------------------------------------------------------------------------+
  725. */
  726. /**
  727. CDrillManager -- shared class between Query Studio and Report Viewer, which handles drill up/down and drill through
  728. */
  729. function CtxArrayPlaceHolder(){}
  730. var self = window;
  731. // CDrillManager constructor
  732. function CDrillManager(oCV)
  733. {
  734. this.m_drawDrillTargets = false;
  735. this.setCV(oCV);
  736. }
  737. CDrillManager.prototype = new CViewerHelper();
  738. CDrillManager.prototype.getSelectionController = function()
  739. {
  740. var selectionController;
  741. try
  742. {
  743. selectionController = getCognosViewerSCObjectRef(this.getCV().getId());
  744. }
  745. catch(e)
  746. {
  747. selectionController = null;
  748. }
  749. return selectionController;
  750. };
  751. CDrillManager.prototype.getSelectedObject = function()
  752. {
  753. var selectionController = this.getSelectionController();
  754. if(selectionController == null)
  755. {
  756. return null;
  757. }
  758. var SelObj = null;
  759. var selectionList = null;
  760. if (selectionController.hasSelectedChartNodes()) {
  761. selectionList = selectionController.getSelectedChartNodes();
  762. } else {
  763. selectionList = selectionController.getSelections();
  764. }
  765. if(selectionList && selectionList.length == 1) {
  766. SelObj = selectionList[0];
  767. }
  768. return SelObj;
  769. };
  770. /***************************************************************************************************
  771. COMMON METHODS BETWEEN REPORT VIEWER AND QUERY STUDIO
  772. ****************************************************************************************************/
  773. CDrillManager.prototype.canDrillUp = function()
  774. {
  775. if(this.getDrillOption('drillUp') == true && this.hasMuns()) {
  776. return true;
  777. }
  778. return false;
  779. };
  780. CDrillManager.prototype.canDrillDown = function()
  781. {
  782. if(this.getDrillOption('drillDown') == true)
  783. {
  784. return true;
  785. }
  786. return false;
  787. };
  788. CDrillManager.prototype.hasMuns = function(selectionObj)
  789. {
  790. // if no selection object is passed in, get the current selected object from the selection controller
  791. if(typeof selectionObj == "undefined") {
  792. selectionObj = this.getSelectedObject();
  793. }
  794. if(selectionObj == null) {
  795. return false;
  796. }
  797. var munArray = selectionObj.getMuns();
  798. var muns="";
  799. for(var munIdx = 0; munIdx < munArray.length && muns == ""; ++munIdx)
  800. {
  801. if(typeof munArray[munIdx][0] != "undefined") {
  802. muns += munArray[munIdx][0];
  803. }
  804. }
  805. return (muns != "");
  806. };
  807. CDrillManager.prototype.getRefQuery = function()
  808. {
  809. var refQuery = "";
  810. var selectionObj = this.getSelectedObject();
  811. if(selectionObj == null) {
  812. return "";
  813. }
  814. var refQueries = selectionObj.getRefQueries();
  815. // for area charts, having a ctx of ::1:: is valid, so look for the first non empty refQuery
  816. for (var i=0; i < refQueries.length; i++) {
  817. if (refQueries[i] != null) {
  818. for (var j=0; j < refQueries[i].length; j++) {
  819. if (refQueries[i][j] != null && refQueries[i][j] != "") {
  820. return refQueries[i][j];
  821. }
  822. }
  823. }
  824. }
  825. return refQuery;
  826. };
  827. CDrillManager.prototype.isIsolated = function()
  828. {
  829. var selectionController = this.getSelectionController();
  830. if(selectionController == null || selectionController.getDrillUpDownEnabled() == false)
  831. {
  832. return false;
  833. }
  834. var selectionObj = this.getSelectedObject();
  835. if(selectionObj == null)
  836. {
  837. return false;
  838. }
  839. if(selectionObj instanceof CSelectionChartObject && selectionController != null)
  840. {
  841. var chartArea = selectionObj.getArea();
  842. if(chartArea != null)
  843. {
  844. var isolated = chartArea.getAttribute("isolated");
  845. if(typeof isolated != "undefined" && isolated != null && isolated == "true")
  846. {
  847. return true;
  848. }
  849. }
  850. }
  851. else
  852. {
  853. var cellRef = selectionObj.getCellRef();
  854. if(typeof cellRef == "object" && cellRef != null)
  855. {
  856. var spanElement = cellRef.getElementsByTagName("span");
  857. if(spanElement != null && typeof spanElement != "undefined" && spanElement.length > 0)
  858. {
  859. var sIsolated = spanElement[0].getAttribute("isolated");
  860. if(sIsolated != null && sIsolated != "undefined" && sIsolated == "true")
  861. {
  862. return true;
  863. }
  864. }
  865. }
  866. }
  867. return false;
  868. };
  869. CDrillManager.prototype.getDrillOption = function(drillOption)
  870. {
  871. var selectionController = this.getSelectionController();
  872. if(selectionController == null || selectionController.getDrillUpDownEnabled() == false || typeof drillOption == "undefined")
  873. {
  874. return false;
  875. }
  876. var selectionObj = this.getSelectedObject();
  877. if(selectionObj == null)
  878. {
  879. return false;
  880. }
  881. if (this.isIsolated())
  882. {
  883. if (drillOption == "drillDown")
  884. {
  885. return false;
  886. }
  887. else if (drillOption == "drillUp")
  888. {
  889. return true;
  890. }
  891. }
  892. if(drillOption == "drillDown")
  893. {
  894. if(selectionObj instanceof CSelectionChartObject && selectionController != null)
  895. {
  896. var chartArea = selectionObj.getArea();
  897. if(chartArea != null)
  898. {
  899. var bIsChartTitle = chartArea.getAttribute("isChartTitle");
  900. if (typeof bIsChartTitle != "undefined" && bIsChartTitle != null && bIsChartTitle == "true")
  901. {
  902. return false;
  903. }
  904. }
  905. }
  906. }
  907. var drillOptions = selectionObj.getDrillOptions();
  908. //Normally, look at the level closest to the data to determine if you can drill up or down on a particular node or cell.
  909. //But...when the drill submenu is enabled, return true if you can drill up/down on upper levels as well...because all items are in the menu.
  910. var processAllLevels = (typeof DrillContextMenuHelper !== "undefined" && DrillContextMenuHelper.needsDrillSubMenu(this.m_oCV));
  911. for(var idx = 0; idx < drillOptions.length; ++idx)
  912. {
  913. var maxLevel=(processAllLevels) ? drillOptions[idx].length : 1;
  914. for (var level = 0; level < maxLevel; ++level) {
  915. var currentDrillOption = drillOptions[idx][level];
  916. if(currentDrillOption == "3" /*drill up and down*/)
  917. {
  918. return true;
  919. }
  920. else if(drillOption == "drillUp" && currentDrillOption == "1")
  921. {
  922. return true;
  923. }
  924. else if(drillOption == "drillDown" && currentDrillOption == "2")
  925. {
  926. return true;
  927. }
  928. }
  929. }
  930. // if the drill option flag is not present, the user cannot drill on this cell
  931. return false;
  932. };
  933. CDrillManager.prototype.canDrillThrough = function()
  934. {
  935. var selectionController = this.getSelectionController();
  936. if(selectionController == null || selectionController.getModelDrillThroughEnabled() == false)
  937. {
  938. return false;
  939. }
  940. return true;
  941. };
  942. /**
  943. * Returns true if we did a drill up/down action
  944. */
  945. CDrillManager.prototype.singleClickDrillEvent = function(evt, app)
  946. {
  947. var selectionController = this.getSelectionController();
  948. if (selectionController != null)
  949. {
  950. if(this.getCV().bCanUseCognosViewerSelection == true)
  951. {
  952. selectionController.pageClicked(evt);
  953. }
  954. }
  955. var node = getCrossBrowserNode(evt);;
  956. try
  957. {
  958. if(node.className && node.className.indexOf("dl") == 0)
  959. {
  960. if(this.canDrillDown())
  961. {
  962. this.singleClickDrillDown(evt, app);
  963. return true;
  964. }
  965. else if(this.canDrillUp())
  966. {
  967. this.singleClickDrillUp(evt, app);
  968. return true;
  969. }
  970. }
  971. }
  972. catch (e)
  973. {
  974. }
  975. if(app == 'RV')
  976. {
  977. return this.getDrillThroughParameters('execute', evt);
  978. }
  979. return false;
  980. };
  981. CDrillManager.prototype.singleClickDrillDown = function(evt, app /*either 'qs' or 'rv'*/)
  982. {
  983. if(app == 'QS') {
  984. this.qsDrillDown();
  985. }
  986. else {
  987. this.rvDrillDown();
  988. }
  989. };
  990. CDrillManager.prototype.singleClickDrillUp = function(evt, app /*either 'QS' or 'RV'*/)
  991. {
  992. if(app == 'QS') {
  993. this.qsDrillUp();
  994. }
  995. else {
  996. this.rvDrillUp();
  997. }
  998. };
  999. CDrillManager.prototype.getDrillParameters = function(drillType, includeMetadata, bIsSyncDrill, userSelectedDrillItem)
  1000. {
  1001. var drillParamsArray = [];
  1002. var selectionObj = this.getSelectedObject();
  1003. if(selectionObj == null) {
  1004. return drillParamsArray; // return an empty array
  1005. }
  1006. if(typeof includeMetadata == "undefined")
  1007. {
  1008. includeMetadata = true;
  1009. }
  1010. var dataItemsArray = selectionObj.getDataItems();
  1011. var munArray = selectionObj.getMuns();
  1012. var lunArray = selectionObj.getDimensionalItems("lun");
  1013. var hunArray = selectionObj.getDimensionalItems("hun");
  1014. var drillOptions = selectionObj.getDrillOptions();
  1015. if(typeof dataItemsArray == "undefined" || typeof munArray == "undefined" || typeof drillOptions == "undefined" || munArray == null || dataItemsArray == null || drillOptions == null) {
  1016. return drillParamsArray; // return an empty array
  1017. }
  1018. if(munArray.length != dataItemsArray.length) {
  1019. return drillParamsArray; // return an empty array
  1020. }
  1021. var num_of_items = munArray.length;
  1022. for(var item_idx = 0; item_idx < num_of_items; ++item_idx) {
  1023. if(dataItemsArray[item_idx].length != 0) {
  1024. var iLevel=(userSelectedDrillItem) ? this.findUserSelectedDrillItem(userSelectedDrillItem, dataItemsArray[item_idx])
  1025. : 0;
  1026. if (iLevel<0) {
  1027. continue;
  1028. }
  1029. if( (bIsSyncDrill === true) || this.getDrillOption(drillType))
  1030. {
  1031. if(munArray[item_idx][iLevel] == "" || drillParamsArray.toString().indexOf(munArray[item_idx][iLevel],0) == -1) {
  1032. drillParamsArray[drillParamsArray.length] = dataItemsArray[item_idx][iLevel];
  1033. drillParamsArray[drillParamsArray.length] = munArray[item_idx][iLevel];
  1034. if(includeMetadata === true)
  1035. {
  1036. drillParamsArray[drillParamsArray.length] = lunArray[item_idx][iLevel];
  1037. drillParamsArray[drillParamsArray.length] = hunArray[item_idx][iLevel];
  1038. }
  1039. }
  1040. }
  1041. }
  1042. }
  1043. return drillParamsArray;
  1044. };
  1045. /**
  1046. * return the level within a list of data items where an item matching the userSelectedDrillItem was found.
  1047. * return -1 if not found.
  1048. */
  1049. CDrillManager.prototype.findUserSelectedDrillItem = function(userSelectedDrillItem, dimDataItems) {
  1050. for (var iLevel=0; iLevel<dimDataItems.length; ++iLevel) {
  1051. if (userSelectedDrillItem==dimDataItems[iLevel]) {
  1052. return iLevel;
  1053. }
  1054. }
  1055. return -1; //Not found...
  1056. };
  1057. CDrillManager.prototype.getModelDrillThroughContext = function(XMLBuilderLocation)
  1058. {
  1059. var modelDrillContext="";
  1060. if(this.canDrillThrough() === true)
  1061. {
  1062. if(typeof gUseNewSelectionContext == "undefined")
  1063. {
  1064. var modelPath = "";
  1065. if(typeof getConfigFrame != "undefined")
  1066. {
  1067. modelPath = decodeURIComponent(getConfigFrame().cfgGet("PackageBase"));
  1068. }
  1069. else if(this.getCV().getModelPath() !== "")
  1070. {
  1071. modelPath = this.getCV().getModelPath();
  1072. }
  1073. modelDrillContext = getViewerSelectionContext(this.getSelectionController(), new CSelectionContext(modelPath));
  1074. }
  1075. else
  1076. {
  1077. var parameterValues = new CParameterValues();
  1078. var selectionController = this.getSelectionController();
  1079. if(selectionController) {
  1080. var selectionList = selectionController.getAllSelectedObjects();
  1081. for(var sel_idx = 0; sel_idx < selectionList.length; ++ sel_idx) {
  1082. var selectionObj = selectionList[sel_idx];
  1083. var munArray = selectionObj.getMuns();
  1084. var metaDataItems = selectionObj.getMetadataItems();
  1085. var useValues = selectionObj.getUseValues();
  1086. for(var context_idx = 0; context_idx < metaDataItems.length; ++context_idx) {
  1087. for(var idx = 0; idx < metaDataItems[context_idx].length; ++idx) {
  1088. if(metaDataItems[context_idx][idx] == null || metaDataItems[context_idx][idx] == "") {
  1089. continue;
  1090. }
  1091. var name = metaDataItems[context_idx][idx];
  1092. var useValue;
  1093. // if we have a mun, set it as the use value, otherwise use the useValue we have stored
  1094. if(munArray[context_idx][idx] != null && munArray[context_idx][idx] != "") {
  1095. useValue = munArray[context_idx][idx];
  1096. }
  1097. else {
  1098. useValue = useValues[context_idx][idx];
  1099. }
  1100. // set the display value to what we have stored as the use value
  1101. var displayValue = useValues[context_idx][idx];
  1102. parameterValues.addSimpleParmValueItem(name, useValue, displayValue, "true");
  1103. }
  1104. }
  1105. }
  1106. }
  1107. var contextElement = XMLBuilderLocation.XMLBuilderCreateXMLDocument("context");
  1108. modelDrillContext = parameterValues.generateXML(XMLBuilderLocation, contextElement);
  1109. }
  1110. }
  1111. return modelDrillContext;
  1112. };
  1113. /***************************************************************************************************
  1114. REPORT VIEWER SPECIFIC METHODS
  1115. ****************************************************************************************************/
  1116. CDrillManager.prototype.rvDrillUp = function(payload)
  1117. {
  1118. this.getCV().executeAction("DrillUp", payload);
  1119. };
  1120. CDrillManager.prototype.rvDrillDown = function(payload)
  1121. {
  1122. this.getCV().executeAction("DrillDown", payload);
  1123. };
  1124. CDrillManager.prototype.rvBuildXMLDrillParameters = function(drillType, userSelectedDrillItem)
  1125. {
  1126. var drillParamsArray = this.getDrillParameters(drillType, true, false /*bIsSyncDrill*/, userSelectedDrillItem);
  1127. if(drillParamsArray.length == 0)
  1128. {
  1129. // handle the error
  1130. return drillParams; // TODO: drillParams ?? It does not exists here.
  1131. }
  1132. return this.buildDrillParametersSpecification(drillParamsArray);
  1133. };
  1134. CDrillManager.prototype.buildDrillParametersSpecification = function(drillParamsArray)
  1135. {
  1136. var drillParams = '<DrillParameters>';
  1137. var idx = 0;
  1138. while(idx < drillParamsArray.length) {
  1139. drillParams += '<DrillGroup>';
  1140. drillParams += '<DataItem>';
  1141. drillParams += sXmlEncode(drillParamsArray[idx++]);
  1142. drillParams += '</DataItem>';
  1143. drillParams += '<MUN>';
  1144. drillParams += sXmlEncode(drillParamsArray[idx++]);
  1145. drillParams += '</MUN>';
  1146. drillParams += '<LUN>';
  1147. drillParams += sXmlEncode(drillParamsArray[idx++]);
  1148. drillParams += '</LUN>';
  1149. drillParams += '<HUN>';
  1150. drillParams += sXmlEncode(drillParamsArray[idx++]);
  1151. drillParams += '</HUN>';
  1152. drillParams += '</DrillGroup>';
  1153. }
  1154. drillParams += '</DrillParameters>';
  1155. return drillParams;
  1156. };
  1157. CDrillManager.prototype.getAuthoredDrillsForCurrentSelection = function()
  1158. {
  1159. var sResult = null;
  1160. // get the report authored drills
  1161. var aReportAuthoredDrills = this.getAuthoredDrillThroughTargets();
  1162. if(aReportAuthoredDrills.length > 0)
  1163. {
  1164. var sAuthoredDrillThroughTargets = "<AuthoredDrillTargets>";
  1165. for(var iIndex = 0; iIndex < aReportAuthoredDrills.length; ++iIndex)
  1166. {
  1167. sAuthoredDrillThroughTargets += eval('"' + aReportAuthoredDrills[iIndex] + '"');
  1168. }
  1169. sAuthoredDrillThroughTargets += "</AuthoredDrillTargets>";
  1170. var cv = this.getCV();
  1171. var authoredDrillAction = cv.getAction("AuthoredDrill");
  1172. var drillTargetSpecifications = cv.getDrillTargets();
  1173. if(drillTargetSpecifications.length > 0)
  1174. {
  1175. sResult = authoredDrillAction.getAuthoredDrillThroughContext(sAuthoredDrillThroughTargets, drillTargetSpecifications);
  1176. }
  1177. }
  1178. return sResult;
  1179. };
  1180. CDrillManager.prototype.getAuthoredDrillsForGotoPage = function()
  1181. {
  1182. var sResult = "";
  1183. var rvDrillTargetsNode = this.getAuthoredDrillsForCurrentSelection();
  1184. if (rvDrillTargetsNode) {
  1185. sResult = XMLBuilderSerializeNode(rvDrillTargetsNode);
  1186. }
  1187. return sResult;
  1188. };
  1189. CDrillManager.prototype.launchGoToPage = function(drillTargets, bDirectLaunch)
  1190. {
  1191. var selectionController = this.getSelectionController();
  1192. if((selectionController != null && selectionController.getModelDrillThroughEnabled() == true) || (typeof drillTargets != "undefined" && drillTargets != null && drillTargets != ""))
  1193. {
  1194. // get the authored drills
  1195. var sAuthoredDrills = this.getAuthoredDrillsForGotoPage();
  1196. // build up the model drill context
  1197. var modelDrillContext = this.getModelDrillThroughContext(self);
  1198. var form = document.getElementById("drillForm");
  1199. if(form != null) {
  1200. document.body.removeChild(form);
  1201. }
  1202. form = document.createElement("form");
  1203. var cvid = this.getCVId();
  1204. var warpForm = document.forms["formWarpRequest" + cvid];
  1205. form.setAttribute("id", "drillForm");
  1206. form.setAttribute("name", "drillForm");
  1207. form.setAttribute("target", warpForm.getAttribute("target"));
  1208. form.setAttribute("method", "post");
  1209. form.setAttribute("action", warpForm.getAttribute("action"));
  1210. form.style.display = "none";
  1211. document.body.appendChild(form);
  1212. if(this.getCV().getModelPath() !== "")
  1213. {
  1214. form.appendChild(createHiddenFormField("modelPath", this.getCV().getModelPath()));
  1215. }
  1216. if(typeof warpForm["ui.object"] != "undefined" && warpForm["ui.object"].value != "")
  1217. {
  1218. form.appendChild(createFormField("drillSource", warpForm["ui.object"].value));
  1219. }
  1220. else if(typeof this.getCV().envParams["ui.spec"] != "undefined")
  1221. {
  1222. form.appendChild(createFormField("sourceSpecification", this.getCV().envParams["ui.spec"]));
  1223. }
  1224. if(sAuthoredDrills != "")
  1225. {
  1226. form.appendChild(createHiddenFormField("m", "portal/drillthrough.xts"));
  1227. form.appendChild(createFormField("invokeGotoPage", "true"));
  1228. form.appendChild(createFormField("m", "portal/drillthrough.xts"));
  1229. form.appendChild(createFormField("modelDrillEnabled", selectionController.getModelDrillThroughEnabled()));
  1230. if(typeof gUseNewSelectionContext == "undefined")
  1231. {
  1232. form.appendChild(createFormField("newSelectionContext", "true"));
  1233. }
  1234. }
  1235. else
  1236. {
  1237. if(typeof gUseNewSelectionContext == "undefined")
  1238. {
  1239. form.appendChild(createHiddenFormField("m", "portal/goto2.xts"));
  1240. }
  1241. else
  1242. {
  1243. form.appendChild(createHiddenFormField("m", "portal/goto.xts"));
  1244. }
  1245. }
  1246. form.appendChild(createHiddenFormField("b_action", "xts.run"));
  1247. form.appendChild(createHiddenFormField("drillTargets", sAuthoredDrills));
  1248. if(typeof gUseNewSelectionContext == "undefined")
  1249. {
  1250. form.appendChild(createHiddenFormField("drillContext", modelDrillContext));
  1251. }
  1252. else
  1253. {
  1254. form.appendChild(createHiddenFormField("modeledDrillthru", modelDrillContext));
  1255. }
  1256. form.appendChild(createHiddenFormField("errURL", "javascript:window.close();"));
  1257. if(typeof bDirectLaunch != "undefined" && bDirectLaunch == true)
  1258. {
  1259. form.appendChild(this.createFormField("directLaunch", "true"));
  1260. }
  1261. var routingServerGroup = "";
  1262. if(this.getCV().envParams["ui.routingServerGroup"])
  1263. {
  1264. routingServerGroup = this.getCV().envParams["ui.routingServerGroup"];
  1265. }
  1266. form.appendChild(createHiddenFormField("ui.routingServerGroup", routingServerGroup));
  1267. if(this.getCV().getExecutionParameters() != "") {
  1268. form.appendChild(createHiddenFormField("encExecutionParameters", this.getCV().getExecutionParameters()));
  1269. }
  1270. if(warpForm.lang && warpForm.lang.value != "")
  1271. {
  1272. form.appendChild(createHiddenFormField("lang", warpForm.lang.value));
  1273. }
  1274. if (!this.getCV() || !this.getCV().launchGotoPageForIWidgetMobile(drillForm)) {
  1275. if (typeof this.getCV().launchGotoPage === "function") {
  1276. this.getCV().launchGotoPage(form);
  1277. }
  1278. else {
  1279. var target = "winNAT_" + ( new Date() ).getTime();
  1280. var sPath = this.getCV().getWebContentRoot() + "/rv/blankDrillWin.html?cv.id=" + cvid;
  1281. window.open(sPath, target, "toolbar,location,status,menubar,resizable,scrollbars=1");
  1282. form.target = target;
  1283. }
  1284. }
  1285. }
  1286. };
  1287. CDrillManager.prototype.buildSearchPageXML = function(XMLBuilderLocation, pkg, model, ctxArr, defMeasArr, dataSpecification, filtArr)
  1288. {
  1289. var cognosSearchElement = null;
  1290. if (typeof XMLBuilderLocation.XMLElement == "function")
  1291. {
  1292. cognosSearchElement = XMLBuilderLocation.XMLBuilderCreateXMLDocument("cognosSearch");
  1293. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(cognosSearchElement.documentElement, "xmlns:cs", "http://developer.cognos.com/schemas/cs/1/");
  1294. var packageElement = cognosSearchElement.createElement("package");
  1295. if (typeof pkg == "string" && pkg !== "")
  1296. {
  1297. packageElement.appendChild(cognosSearchElement.createTextNode(pkg));
  1298. }
  1299. cognosSearchElement.documentElement.appendChild(packageElement);
  1300. var modelElement = cognosSearchElement.createElement("model");
  1301. if (typeof model == "string" && model !== "")
  1302. {
  1303. modelElement.appendChild(cognosSearchElement.createTextNode(model));
  1304. }
  1305. cognosSearchElement.documentElement.appendChild(modelElement);
  1306. var selectedContextElement = cognosSearchElement.createElement("selectedContext");
  1307. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xmlns:xs", "http://www.w3.org/2001/XMLSchema");
  1308. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xmlns:bus", "http://developer.cognos.com/schemas/bibus/3/");
  1309. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "SOAP-ENC:arrayType", "bus:parameterValue[]", "http://schemas.xmlsoap.org/soap/encoding/");
  1310. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
  1311. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(selectedContextElement, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  1312. cognosSearchElement.documentElement.appendChild(selectedContextElement);
  1313. for (var idxCtx in ctxArr)
  1314. {
  1315. var itemElement = cognosSearchElement.createElement("item");
  1316. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(itemElement, "xsi:type", "bus:parameterValue", "http://www.w3.org/2001/XMLSchema-instance");
  1317. var busNameElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:name", cognosSearchElement);
  1318. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busNameElement, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  1319. busNameElement.appendChild(cognosSearchElement.createTextNode(ctxArr[idxCtx].name));
  1320. var busValueElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:value", cognosSearchElement);
  1321. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busValueElement, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  1322. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busValueElement, "SOAP-ENC:arrayType", "bus:parmValueItem[]", "http://schemas.xmlsoap.org/soap/encoding/");
  1323. for (var j = 0; j < ctxArr[idxCtx].values.length; j++)
  1324. {
  1325. var itemChildElement = cognosSearchElement.createElement("item");
  1326. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(itemChildElement, "xsi:type", "bus:simpleParmValueItem", "http://www.w3.org/2001/XMLSchema-instance");
  1327. var busUseElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:use", cognosSearchElement);
  1328. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busUseElement, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  1329. busUseElement.appendChild(cognosSearchElement.createTextNode(ctxArr[idxCtx].values[j][0]));
  1330. var busDisplayElement = XMLBuilderLocation.XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:display", cognosSearchElement);
  1331. XMLBuilderLocation.XMLBuilderSetAttributeNodeNS(busDisplayElement, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  1332. var nodeValue = ctxArr[idxCtx].values[j][1] == null ? "" : ctxArr[idxCtx].values[j][1];
  1333. busDisplayElement.appendChild(cognosSearchElement.createTextNode(nodeValue));
  1334. itemChildElement.appendChild(busUseElement);
  1335. itemChildElement.appendChild(busDisplayElement);
  1336. busValueElement.appendChild(itemChildElement);
  1337. }
  1338. itemElement.appendChild(busNameElement);
  1339. itemElement.appendChild(busValueElement);
  1340. selectedContextElement.appendChild(itemElement);
  1341. }
  1342. var defaultMeasureElement = cognosSearchElement.createElement("defaultMeasure");
  1343. cognosSearchElement.documentElement.appendChild(defaultMeasureElement);
  1344. dataSpecification.buildXML(XMLBuilderLocation, cognosSearchElement, "data");
  1345. var filterElement = cognosSearchElement.createElement("filter");
  1346. cognosSearchElement.documentElement.appendChild(filterElement);
  1347. }
  1348. return cognosSearchElement;
  1349. };
  1350. CDrillManager.prototype.openSearchPage = function(objPath, sourceContext)
  1351. {
  1352. // build up the model drill context
  1353. this.getModelDrillThroughContext(self);
  1354. var searchForm = document.getElementById("searchPage");
  1355. if(searchForm != null) {
  1356. document.body.removeChild(searchForm);
  1357. }
  1358. searchForm = document.createElement("form");
  1359. searchForm.setAttribute("id", "searchPage");
  1360. searchForm.setAttribute("name", "searchPage");
  1361. searchForm.setAttribute("method", "post");
  1362. searchForm.setAttribute("target", searchForm.name);
  1363. searchForm.setAttribute("action", this.getCV().getGateway() + "/gosearch");
  1364. searchForm.style.display = "none";
  1365. document.body.appendChild(searchForm);
  1366. searchForm.appendChild(createHiddenFormField("csn.action", "search"));
  1367. searchForm.appendChild(createHiddenFormField("csn.drill", sourceContext));
  1368. var __search_win = window.open("", searchForm.name, "directories=no,location=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,top=100,left=100,height=480,width=640" );
  1369. __search_win.focus();
  1370. searchForm.submit();
  1371. };
  1372. CDrillManager.prototype.launchSearchPage = function()
  1373. {
  1374. var selCon = this.getSelectionController();
  1375. var warpForm = document.forms["formWarpRequest" + this.getCVId()];
  1376. var ctxArr = this.determineSelectionsForSearchPage(selCon);
  1377. var dataSpecification = this.getSearchContextDataSpecfication(selCon);
  1378. var spXML = this.buildSearchPageXML(self, warpForm.packageBase.value, this.getCV().getModelPath(), ctxArr, [], dataSpecification, []);
  1379. this.openSearchPage(warpForm.packageBase.value, XMLBuilderSerializeNode(spXML));
  1380. };
  1381. /***************************************************************************************************
  1382. QUERY STUDIO SPECIFIC METHODS
  1383. ****************************************************************************************************/
  1384. CDrillManager.prototype.qsDrillDown = function()
  1385. {
  1386. if(!this.canDrillDown()) {
  1387. // throw up a a generic error page (for now)
  1388. getConfigFrame().dlgGenericSelectionMessage(false);
  1389. return;
  1390. }
  1391. // build the drill down command
  1392. var drillCommand = 'DD:';
  1393. this.qsSendDrillCommand(drillCommand);
  1394. };
  1395. CDrillManager.prototype.qsDrillUp = function()
  1396. {
  1397. if(!this.canDrillUp()) {
  1398. // throw up a a generic error page (for now)
  1399. getConfigFrame().dlgGenericSelectionMessage(false);
  1400. return;
  1401. }
  1402. // build the drill up command
  1403. var drillCommand = 'DU:';
  1404. this.qsSendDrillCommand(drillCommand);
  1405. };
  1406. CDrillManager.prototype.qsSendDrillCommand = function(drillCommand)
  1407. {
  1408. var drillType;
  1409. if(drillCommand == "DU:") {
  1410. drillType = "drillUp";
  1411. }
  1412. else {
  1413. drillType = "drillDown";
  1414. }
  1415. var drillParamsArray = this.getDrillParameters(drillType, false, false /*bIsSyncDrill*/);
  1416. if(drillParamsArray.length == 0){
  1417. // throw up a a generic error page (for now)
  1418. getConfigFrame().dlgGenericSelectionMessage(false);
  1419. return;
  1420. }
  1421. for(var idx = 0; idx < drillParamsArray.length; ++idx) {
  1422. drillCommand += getConfigFrame().escapeParam(drillParamsArray[idx]);
  1423. if(idx+1 < drillParamsArray.length) {
  1424. drillCommand += ',';
  1425. }
  1426. }
  1427. getConfigFrame().sendCmd(drillCommand, "", true);
  1428. };
  1429. CDrillManager.prototype.qsLaunchGoToPage = function(bDirectLaunch)
  1430. {
  1431. var selectionController = this.getSelectionController();
  1432. if(selectionController != null && selectionController.getModelDrillThroughEnabled() == true)
  1433. {
  1434. // build up the model drill context
  1435. var modelDrillContext = this.getModelDrillThroughContext(cf);
  1436. if(modelDrillContext=="") {
  1437. // throw up a a generic error page (for now)
  1438. getConfigFrame().dlgGenericSelectionMessage(false);
  1439. return;
  1440. }
  1441. var gotoForm = document.getElementById("gotoPage");
  1442. if(gotoForm != null) {
  1443. document.body.removeChild(gotoForm);
  1444. }
  1445. gotoForm = document.createElement("form");
  1446. gotoForm.setAttribute("id", "gotoPage");
  1447. gotoForm.setAttribute("name", "gotoPage");
  1448. gotoForm.setAttribute("method", "post");
  1449. gotoForm.style.display = "none";
  1450. document.body.appendChild(gotoForm);
  1451. var configFrame = getConfigFrame();
  1452. gotoForm.appendChild(this.createFormField("objpath", decodeURIComponent(configFrame.cfgGet("PackageBase"))));
  1453. if(typeof gUseNewSelectionContext == "undefined")
  1454. {
  1455. gotoForm.appendChild(this.createFormField("m", "portal/goto2.xts"));
  1456. }
  1457. else
  1458. {
  1459. gotoForm.appendChild(this.createFormField("m", "portal/goto.xts"));
  1460. }
  1461. gotoForm.appendChild(this.createFormField("b_action", "xts.run"));
  1462. if(typeof gUseNewSelectionContext == "undefined")
  1463. {
  1464. gotoForm.appendChild(this.createFormField("drillContext", modelDrillContext));
  1465. }
  1466. else
  1467. {
  1468. gotoForm.appendChild(this.createFormField("modeledDrillthru", modelDrillContext));
  1469. }
  1470. if (typeof getConfigFrame().routingServerGroup != "undefined")
  1471. {
  1472. gotoForm.appendChild(this.createFormField("ui.routingServerGroup", getConfigFrame().routingServerGroup));
  1473. }
  1474. if(typeof bDirectLaunch != "undefined" && bDirectLaunch == true)
  1475. {
  1476. gotoForm.appendChild(this.createFormField("directLaunch", "true"));
  1477. }
  1478. var executionParameters = configFrame.goApplicationManager.getReportManager().getParameterManager().getExecutionParameters();
  1479. if (executionParameters)
  1480. {
  1481. gotoForm.appendChild(this.createFormField("encExecutionParameters", executionParameters));
  1482. }
  1483. var target = "winNAT_" + ( new Date() ).getTime();
  1484. var sPath = this.getCV().getWebContentRoot() + "/rv/blankDrillWin.html?cv.id=" + this.getCVId();
  1485. window.open(sPath, target, "toolbar,location,status,menubar,resizable,scrollbars=1");
  1486. gotoForm.target = target;
  1487. }
  1488. };
  1489. CDrillManager.prototype.qsLaunchSearchPage = function()
  1490. {
  1491. var cf = getConfigFrame();
  1492. var selCon = goWindowManager.getSelectionController();
  1493. var ctxArr = this.determineSelectionsForSearchPage(selCon);
  1494. var dataSpecification = this.getSearchContextDataSpecfication(selCon);
  1495. var pkgBase = decodeURIComponent(cf.cfgGet("PackageBase"));
  1496. var spXML = this.buildSearchPageXML(cf, pkgBase, decodeURIComponent(cf.cfgGet("cmLastModel")), ctxArr, [], dataSpecification, []);
  1497. this.openSearchPage(pkgBase, cf.XMLBuilderSerializeNode(spXML));
  1498. };
  1499. CDrillManager.prototype.determineSelectionsForSearchPage = function(selectionController)
  1500. {
  1501. var ctxArr = new CtxArrayPlaceHolder();
  1502. var allSelections = selectionController.getAllSelectedObjects();
  1503. for (var i = 0; i < allSelections.length; i++)
  1504. {
  1505. var colName = allSelections[i].getColumnName();
  1506. if (!this.containsByIndiceInArray(ctxArr, colName))
  1507. {
  1508. ctxArr[colName] = {};
  1509. ctxArr[colName].name = colName;
  1510. ctxArr[colName].values = [];
  1511. }
  1512. var idx0 = "";
  1513. var muns = allSelections[i].getMuns();
  1514. if (muns != null && muns.length > 0)
  1515. {
  1516. idx0 = muns[0][0];
  1517. }
  1518. var idx1 = allSelections[i].getDisplayValues()[0];
  1519. if (!(this.containsInArray(ctxArr[colName].values, 0, idx0) && this.containsInArray(ctxArr[colName].values, 1, idx1))) {
  1520. ctxArr[colName].values[ctxArr[colName].values.length] = [idx0, idx1];
  1521. }
  1522. }
  1523. return ctxArr;
  1524. };
  1525. CDrillManager.prototype.getSearchContextDataSpecfication = function(selectionController)
  1526. {
  1527. var parameterValues = new CParameterValues();
  1528. var dataManager = selectionController.getCCDManager();
  1529. var contextData = dataManager.m_cd;
  1530. for(var ctxId in contextData)
  1531. {
  1532. var sUsage = dataManager.GetUsage(ctxId);
  1533. if(sUsage != "2" /*2==MEASURE*/)
  1534. {
  1535. var sRefDataItem = dataManager.GetRDIValue(ctxId);
  1536. var sUseValue = dataManager.GetDisplayValue(ctxId);
  1537. parameterValues.addSimpleParmValueItem(sRefDataItem, sRefDataItem, sUseValue, "true");
  1538. }
  1539. }
  1540. return parameterValues;
  1541. };
  1542. CDrillManager.prototype.containsByIndiceInArray = function(a, v)
  1543. {
  1544. for (var i in a)
  1545. {
  1546. if (i == v) {
  1547. return true;
  1548. }
  1549. }
  1550. return false;
  1551. };
  1552. CDrillManager.prototype.containsInArray = function(a, idx, v)
  1553. {
  1554. for (var i in a)
  1555. {
  1556. if (a[i][idx] == v) {
  1557. return true;
  1558. }
  1559. }
  1560. return false;
  1561. };
  1562. // temp function for now
  1563. CDrillManager.prototype.createFormField = function(name, value)
  1564. {
  1565. var formField = document.createElement("input");
  1566. formField.setAttribute("type", "hidden");
  1567. formField.setAttribute("name", name);
  1568. formField.setAttribute("value", value);
  1569. return(formField);
  1570. };
  1571. /***************************************************************************************************
  1572. DRILL THROUGH METHODS
  1573. ****************************************************************************************************/
  1574. CDrillManager.prototype.getAuthoredDrillThroughTargets = function()
  1575. {
  1576. var aAuthoredDrillItems = [];
  1577. var selectionController = this.getSelectionController();
  1578. var oHtmlItem = null;
  1579. if(selectionController != null)
  1580. {
  1581. if(selectionController.getSelectedColumnIds().length == 1)
  1582. {
  1583. var selections = selectionController.getSelections();
  1584. for(var selectionIndex = 0; selectionIndex < selections.length; ++selectionIndex)
  1585. {
  1586. var selectionObject = selections[selectionIndex];
  1587. oHtmlItem = selectionObject.getCellRef();
  1588. while( oHtmlItem )
  1589. {
  1590. if(oHtmlItem.getAttribute("dtTargets") != null)
  1591. {
  1592. aAuthoredDrillItems.push("<rvDrillTargets>" + oHtmlItem.getAttribute("dtTargets") + "</rvDrillTargets>");
  1593. break;
  1594. }
  1595. else if(oHtmlItem.getAttribute("onclick") != null)
  1596. {
  1597. var onclickValue = oHtmlItem.getAttribute("onclick");
  1598. var localFunction = null;
  1599. if(onclickValue.indexOf("doSingleDrillThrough") != -1)
  1600. {
  1601. localFunction = onclickValue.replace("doSingleDrillThrough", "this.buildRvTargetsForSingleDrillThrough");
  1602. }
  1603. else if(onclickValue.indexOf("doMultipleDrillThrough") != -1)
  1604. {
  1605. localFunction = onclickValue.replace("doMultipleDrillThrough", "this.buildRvTargetsForMultipleDrillThrough");
  1606. }
  1607. if(localFunction != null)
  1608. {
  1609. var rvDrillTargets = eval(localFunction);
  1610. if(rvDrillTargets != null)
  1611. {
  1612. aAuthoredDrillItems.push(rvDrillTargets);
  1613. break;
  1614. }
  1615. }
  1616. }
  1617. oHtmlItem = XMLHelper_GetFirstChildElement( oHtmlItem );
  1618. }
  1619. }
  1620. }
  1621. else if(selectionController.hasSelectedChartNodes())
  1622. {
  1623. var chartNodes = selectionController.getSelectedChartNodes();
  1624. var selectedChartNode = chartNodes[0];
  1625. oHtmlItem = selectedChartNode.getArea();
  1626. if(oHtmlItem.getAttribute("dtTargets") != null)
  1627. {
  1628. aAuthoredDrillItems.push("<rvDrillTargets>" + oHtmlItem.getAttribute("dtTargets") + "</rvDrillTargets>");
  1629. }
  1630. }
  1631. else if (selectionController.getSelectedDrillThroughImage() != null) {
  1632. var imageNode = selectionController.getSelectedDrillThroughImage();
  1633. if(imageNode && imageNode.getAttribute("dtTargets") != null) {
  1634. aAuthoredDrillItems.push("<rvDrillTargets>" + imageNode.getAttribute("dtTargets") + "</rvDrillTargets>");
  1635. }
  1636. } else if( selectionController.getSelectDrillThroughSingleton() != null) {
  1637. var singletonNode = selectionController.getSelectDrillThroughSingleton();
  1638. if(singletonNode && singletonNode.getAttribute("dtTargets") != null) {
  1639. aAuthoredDrillItems.push("<rvDrillTargets>" + singletonNode.getAttribute("dtTargets") + "</rvDrillTargets>");
  1640. }
  1641. }
  1642. }
  1643. return aAuthoredDrillItems;
  1644. };
  1645. CDrillManager.prototype.getDrillThroughParameters = function(method, evt)
  1646. {
  1647. if(typeof method == "undefined")
  1648. {
  1649. method = 'query';
  1650. }
  1651. var aAuthoredDrillThroughTargets = [];
  1652. if(typeof evt != "undefined")
  1653. {
  1654. var cellRef = getCrossBrowserNode(evt, true);
  1655. try
  1656. {
  1657. while(cellRef)
  1658. {
  1659. if(typeof cellRef.getAttribute != "undefined" && cellRef.getAttribute("dtTargets"))
  1660. {
  1661. aAuthoredDrillThroughTargets.push("<rvDrillTargets>" + cellRef.getAttribute("dtTargets") + "</rvDrillTargets>");
  1662. break;
  1663. }
  1664. cellRef = cellRef.parentNode;
  1665. }
  1666. }
  1667. catch(e)
  1668. {
  1669. return false;
  1670. // if an exception occurs, just eat it
  1671. }
  1672. }
  1673. else
  1674. {
  1675. var oCV = this.getCV();
  1676. var oDrillMgr = oCV.getDrillMgr();
  1677. var selectionController = oDrillMgr.getSelectionController();
  1678. if(selectionController != null)
  1679. {
  1680. var chartArea = null;
  1681. if(selectionController.hasSelectedChartNodes())
  1682. {
  1683. var chartNodes = selectionController.getSelectedChartNodes();
  1684. var selectedChartNode = chartNodes[0];
  1685. chartArea = selectedChartNode.getArea();
  1686. }
  1687. if(chartArea != null)
  1688. {
  1689. aAuthoredDrillThroughTargets.push("<rvDrillTargets>" + chartArea.getAttribute("dtTargets") + "</rvDrillTargets>");
  1690. }
  1691. else
  1692. {
  1693. aAuthoredDrillThroughTargets = this.getAuthoredDrillThroughTargets();
  1694. }
  1695. }
  1696. }
  1697. if(aAuthoredDrillThroughTargets.length > 0)
  1698. {
  1699. var sAuthoredDrillThroughTargets = "<AuthoredDrillTargets>";
  1700. for(var iIndex = 0; iIndex < aAuthoredDrillThroughTargets.length; ++iIndex)
  1701. {
  1702. sAuthoredDrillThroughTargets += eval('"' + aAuthoredDrillThroughTargets[iIndex] + '"');
  1703. }
  1704. sAuthoredDrillThroughTargets += "</AuthoredDrillTargets>";
  1705. var authoredDrillAction = this.getCV().getAction("AuthoredDrill");
  1706. if(method == "query")
  1707. {
  1708. authoredDrillAction.populateContextMenu(sAuthoredDrillThroughTargets);
  1709. this.showOtherMenuItems();
  1710. }
  1711. else
  1712. {
  1713. if (this.getCV().envParams["cv.id"] == "AA")
  1714. {
  1715. this.getCV().m_viewerFragment.raiseAuthoredDrillClickEvent();
  1716. }
  1717. else
  1718. {
  1719. authoredDrillAction.execute(sAuthoredDrillThroughTargets);
  1720. }
  1721. }
  1722. return true;
  1723. }
  1724. else if (method == 'query')
  1725. {
  1726. this.showOtherMenuItems();
  1727. return true;
  1728. }
  1729. else
  1730. {
  1731. return false;
  1732. }
  1733. };
  1734. CDrillManager.prototype.executeAuthoredDrill = function(drillTargetsSpecification)
  1735. {
  1736. var unEncodedDrillTargetsSpecification = decodeURIComponent(drillTargetsSpecification);
  1737. var authoredDrillAction = this.getCV().getAction("AuthoredDrill");
  1738. authoredDrillAction.executeDrillTarget(unEncodedDrillTargetsSpecification);
  1739. };
  1740. CDrillManager.prototype.doesMoreExist = function(menuObj)
  1741. {
  1742. for(var i = 0; i < menuObj.getNumItems(); i++)
  1743. {
  1744. var menuItem = menuObj.get(i);
  1745. if(menuItem != null)
  1746. {
  1747. if((menuItem instanceof CMenuItem) && (menuItem.getLabel() == RV_RES.RV_MORE) && (menuItem.getAction() == this.getCVObjectRef() + '.getDrillMgr().launchGoToPage();')) {
  1748. return true;
  1749. }
  1750. }
  1751. }
  1752. return false;
  1753. };
  1754. CDrillManager.prototype.showOtherMenuItems = function()
  1755. {
  1756. // just add the more menu item
  1757. var cv = this.getCV();
  1758. var mainWnd = cv.rvMainWnd;
  1759. var toolbarCtrl = mainWnd.getToolbarControl();
  1760. var gtButton = null;
  1761. var gtDropDownMenu = null;
  1762. if (typeof toolbarCtrl != "undefined" && toolbarCtrl != null) {
  1763. gtButton = toolbarCtrl.getItem("goto");
  1764. if (gtButton)
  1765. {
  1766. gtDropDownMenu = gtButton.getMenu();
  1767. }
  1768. }
  1769. var contextMenu = mainWnd.getContextMenu();
  1770. var sBlackList = mainWnd.getUIHide();
  1771. var gtContextMenu = null;
  1772. if (typeof contextMenu != "undefined" && contextMenu != null && contextMenu.getGoToMenuItem()) {
  1773. gtContextMenu = contextMenu.getGoToMenuItem().getMenu();
  1774. }
  1775. var searchMenuItem = null;
  1776. var selectionController = this.getSelectionController();
  1777. // there's no report authored drills, just add the more menu item
  1778. if (gtDropDownMenu != null) {
  1779. //Do not add another more menu item if the dropdown menu already has one
  1780. if(this.doesMoreExist(gtDropDownMenu) == false)
  1781. {
  1782. if(typeof gMenuSeperator != "undefined" && gtDropDownMenu.getNumItems() > 0 && (cv.bCanUseCognosViewerIndexSearch || sBlackList.indexOf(' RV_TOOLBAR_BUTTONS_GOTO_RELATED_LINKS ') == -1))
  1783. {
  1784. gtDropDownMenu.add(gMenuSeperator);
  1785. }
  1786. var moreDropDownItem = new CMenuItem(gtDropDownMenu, RV_RES.RV_MORE, this.getCVObjectRef() + '.getDrillMgr().launchGoToPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1787. // if (cv.bCanUseCognosViewerIndexSearch) {
  1788. // searchMenuItem = new CMenuItem(gtDropDownMenu, RV_RES.RV_SEARCH, this.getCVObjectRef() + '.getDrillMgr().launchSearchPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1789. // }
  1790. if(sBlackList.indexOf(' RV_TOOLBAR_BUTTONS_GOTO_RELATED_LINKS ') != -1)
  1791. {
  1792. moreDropDownItem.hide();
  1793. }
  1794. else if(selectionController == null || selectionController.getModelDrillThroughEnabled() == false)
  1795. {
  1796. moreDropDownItem.disable();
  1797. }
  1798. }
  1799. }
  1800. if (gtContextMenu != null) {
  1801. if(typeof gMenuSeperator != "undefined" && gtContextMenu.getNumItems() > 0 && (cv.bCanUseCognosViewerIndexSearch || sBlackList.indexOf(' RV_CONTEXT_MENU_GOTO_RELATED_LINKS ') == -1))
  1802. {
  1803. gtContextMenu.add(gMenuSeperator);
  1804. }
  1805. var moreContextMenuItem = new CMenuItem(gtContextMenu, RV_RES.RV_MORE, this.getCVObjectRef() + '.getDrillMgr().launchGoToPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1806. // if (cv.bCanUseCognosViewerIndexSearch) {
  1807. // searchMenuItem = new CMenuItem(gtContextMenu, RV_RES.RV_SEARCH, this.getCVObjectRef() + '.getDrillMgr().launchSearchPage();', "", gMenuItemStyle, cv.getWebContentRoot(), cv.getSkin());
  1808. // }
  1809. if(sBlackList.indexOf(' RV_CONTEXT_MENU_GOTO_RELATED_LINKS ') != -1)
  1810. {
  1811. moreContextMenuItem.hide();
  1812. }
  1813. else if(selectionController == null || selectionController.getModelDrillThroughEnabled() == false)
  1814. {
  1815. moreContextMenuItem.disable();
  1816. }
  1817. }
  1818. if (searchMenuItem != null && selectionController != null)
  1819. {
  1820. var allSelections = selectionController.getAllSelectedObjects();
  1821. if (allSelections == null || allSelections.length === 0)
  1822. {
  1823. searchMenuItem.disable();
  1824. }
  1825. }
  1826. if (gtDropDownMenu != null) {
  1827. gtDropDownMenu.draw();
  1828. if (gtDropDownMenu.isVisible()) {
  1829. gtDropDownMenu.show();
  1830. }
  1831. }
  1832. if (gtContextMenu != null) {
  1833. gtContextMenu.draw();
  1834. if (gtContextMenu.isVisible()) {
  1835. gtContextMenu.show();
  1836. }
  1837. }
  1838. };
  1839. CDrillManager.prototype.ddc = function(evt) {
  1840. var node = getNodeFromEvent(evt);
  1841. if(node != null && node.getAttribute("ddc")!=="1") {
  1842. // adding a 'ddc' attribute to prevent processing the same node more than once.
  1843. node.setAttribute("ddc", "1");
  1844. if(node.getAttribute("dtTargets")) {
  1845. node.className = "dl " + node.className;
  1846. node.setAttribute("href", "#");
  1847. return;
  1848. }
  1849. var selectionController = this.getSelectionController();
  1850. if(selectionController != null) {
  1851. var selectedChartArea = selectionController.getSelectionObjectFactory().getSelectionChartObject(node);
  1852. if(selectedChartArea != null) {
  1853. var drillOptions = selectedChartArea.getDrillOptions();
  1854. for(var idx = 0; idx < drillOptions.length; ++idx) {
  1855. var currentDrillOption = drillOptions[idx][0];
  1856. if ((node.getAttribute("isChartTitle") === "true" && currentDrillOption == "1") || currentDrillOption == "3" || currentDrillOption == "2") {
  1857. node.className = "dl " + node.className;
  1858. node.setAttribute("href", "#");
  1859. break;
  1860. }
  1861. }
  1862. }
  1863. }
  1864. }
  1865. };
  1866. CDrillManager.prototype.buildRvTargetsForSingleDrillThrough = function(drillThroughContext)
  1867. {
  1868. if(typeof drillThroughContext == "undefined" || drillThroughContext == null)
  1869. {
  1870. return null;
  1871. }
  1872. var drillTargets = this.getCV().getDrillTargets();
  1873. if(!drillTargets || drillTargets.length == 0)
  1874. {
  1875. return null;
  1876. }
  1877. var drillTargetRefIdx = drillThroughContext[0][0];
  1878. if(typeof drillTargetRefIdx == "undefined" || drillTargetRefIdx == null)
  1879. {
  1880. return null;
  1881. }
  1882. var drillTargetRef = drillTargets[drillTargetRefIdx];
  1883. if(typeof drillTargetRef == "undefined" || drillTargetRef == null)
  1884. {
  1885. return null;
  1886. }
  1887. var drillTarget = "<drillTarget drillIdx=\\\"" + drillTargetRefIdx + "\\\" label=\\\"" + drillTargetRef.getLabel() + "\\\"/>";
  1888. return "<rvDrillTargets>" + drillTarget + "</rvDrillTargets>";
  1889. };
  1890. CDrillManager.prototype.buildRvTargetsForMultipleDrillThrough = function(drillThroughContext)
  1891. {
  1892. if(typeof drillThroughContext == "undefined" || drillThroughContext == null)
  1893. {
  1894. return null;
  1895. }
  1896. var drillTargets = this.getCV().getDrillTargets();
  1897. if(!drillTargets || drillTargets.length == 0)
  1898. {
  1899. return null;
  1900. }
  1901. var dtTargets = "";
  1902. for (var drillTargetIdx = 0; drillTargetIdx < drillThroughContext.length; ++drillTargetIdx)
  1903. {
  1904. var currentDrillThroughContext = drillThroughContext[drillTargetIdx];
  1905. if(currentDrillThroughContext.length < 2)
  1906. {
  1907. // there must be two or more parameters (drill idx, drill label)
  1908. continue;
  1909. }
  1910. var drillTargetRefIdx = currentDrillThroughContext[0];
  1911. if(typeof drillTargetRefIdx == "undefined" || drillTargetRefIdx == null)
  1912. {
  1913. continue;
  1914. }
  1915. var drillTargetLabel = currentDrillThroughContext[1];
  1916. if(typeof drillTargetLabel == "undefined" || drillTargetLabel == null)
  1917. {
  1918. continue;
  1919. }
  1920. var drillTargetRef = drillTargets[drillTargetRefIdx];
  1921. if(typeof drillTargetRef == "undefined" || drillTargetRef == null)
  1922. {
  1923. continue;
  1924. }
  1925. if(drillTargetLabel === null || drillTargetLabel === "")
  1926. {
  1927. drillTargetLabel = drillTargetRef.getLabel();
  1928. }
  1929. dtTargets += "<drillTarget drillIdx=\\\"" + drillTargetRefIdx + "\\\" label=\\\"" + drillTargetLabel + "\\\"/>";
  1930. }
  1931. if(dtTargets.length > 0)
  1932. {
  1933. return "<rvDrillTargets>" + dtTargets + "</rvDrillTargets>";
  1934. }
  1935. return null;
  1936. };
  1937. /*
  1938. *+------------------------------------------------------------------------+
  1939. *| Licensed Materials - Property of IBM
  1940. *| IBM Cognos Products: Viewer
  1941. *| (C) Copyright IBM Corp. 2011, 2015
  1942. *|
  1943. *| US Government Users Restricted Rights - Use, duplication or
  1944. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  1945. *|
  1946. *+------------------------------------------------------------------------+
  1947. */
  1948. /**
  1949. * Class responsibility: Add or remove Highlight image map areas
  1950. */
  1951. function CImageMapHighlight(map, webContentRoot)
  1952. {
  1953. this.m_webContentRoot = webContentRoot;
  1954. this.createHighlight = CImageMapHighlight.prototype.createHighlightElement;
  1955. this.initialize(map);
  1956. }
  1957. CImageMapHighlight.prototype.initialize = function(map) {
  1958. this.m_map = map;
  1959. this.m_areas = {};
  1960. this.m_areaNodes = {};
  1961. this.m_visibleAreas = [];
  1962. this.initImageBlank();
  1963. this.m_divCanvas = null;
  1964. this.m_creationNode = null;
  1965. this._setMapAreasId();
  1966. this.m_sDefaultFillColour = "#F7E1BC";
  1967. this.m_sDefaultStrokeColour = "#F0A630";
  1968. this.m_sFillColour = this.m_sDefaultFillColour;
  1969. this.m_sStrokeColour = this.m_sDefaultStrokeColour;
  1970. };
  1971. CImageMapHighlight.prototype.setFillColour = function( sFillColour ){
  1972. this.m_sFillColour = ( !sFillColour ) ? this.m_sDefaultFillColour : sFillColour;
  1973. };
  1974. CImageMapHighlight.prototype.getFillColour = function(){
  1975. return this.m_sFillColour;
  1976. };
  1977. CImageMapHighlight.prototype.setStrokeColour = function( sStrokeColour ){
  1978. this.m_sStrokeColour = (!sStrokeColour ) ? this.m_sDefaultStrokeColour : sStrokeColour ;
  1979. };
  1980. CImageMapHighlight.prototype.getStrokeColour = function(){
  1981. return this.m_sStrokeColour;
  1982. };
  1983. CImageMapHighlight.prototype.resetColours = function(){
  1984. this.m_sStrokeColour = this.m_sDefaultStrokeColour;
  1985. this.m_sFillColour = this.m_sDefaultFillColour;
  1986. };
  1987. CImageMapHighlight.prototype.initImageBlank = function() {
  1988. var img = this._getChartImageFromMap();
  1989. // this test is to avoid a javascript error, but it won't work
  1990. if (img === null) {
  1991. return;
  1992. }
  1993. this.m_img = img;
  1994. this.m_sImageHeight = img.offsetHeight + "px";
  1995. this.m_sImageWidth = img.offsetWidth + "px";
  1996. this.m_sUseMap = img.getAttribute( "usemap" );
  1997. this.m_imgLid = img.getAttribute( "lid" );
  1998. this.m_imgBlank = img.ownerDocument.createElement( "IMG" );
  1999. this.m_imgBlank.src = this.m_webContentRoot + "/rv/images/blank.gif";
  2000. this.m_imgBlank.style.height = this.m_sImageHeight;
  2001. this.m_imgBlank.style.width = this.m_sImageWidth;
  2002. this.m_imgBlank.style.position = "absolute";
  2003. this.m_imgBlank.border = "0";
  2004. this.m_imgBlank.useMap = this.m_sUseMap;
  2005. this.m_imgBlank.setAttribute("lid", this.m_imgLid);
  2006. this.m_imgBlank.setAttribute("rsvpchart", img.getAttribute( "rsvpchart"));
  2007. this.m_imgBlank.alt = img.alt;
  2008. if ( this.m_bShowPointer )
  2009. {
  2010. this.m_imgBlank.style.cursor = "auto";
  2011. }
  2012. this.m_imgBlank.v_bIsBlankImageMapImg = true;
  2013. img.parentNode.insertBefore( this.m_imgBlank, img );
  2014. this.f_copyStyle( img, this.m_imgBlank );
  2015. this.m_imgBlank.style.borderColor = "transparent";
  2016. };
  2017. /**
  2018. * Look in the DOM for the chart container image
  2019. * <map/> [<div/>] <div><span></div> [<svg|div/> <img-blank/>] <img-rsvpchart=true>
  2020. */
  2021. CImageMapHighlight.prototype._getChartImageFromMap = function() {
  2022. var map = this.m_map;
  2023. var result = null;
  2024. // 1. find the span which is the chart container (it should be in the next
  2025. var chartContainerSpan = null;
  2026. var mapNextSibling = map.nextSibling;
  2027. while (mapNextSibling) {
  2028. if(mapNextSibling.tagName == "DIV") {
  2029. var nDivChild = mapNextSibling.firstChild;
  2030. while (nDivChild) {
  2031. if ((nDivChild.tagName == "SPAN" || nDivChild.tagName == "DIV") && nDivChild.getAttribute("chartcontainer") == "true") {
  2032. chartContainerSpan = nDivChild;
  2033. break;
  2034. }
  2035. nDivChild = nDivChild.nextSibling;
  2036. }
  2037. }
  2038. if(chartContainerSpan) {
  2039. break;
  2040. }
  2041. mapNextSibling = mapNextSibling.nextSibling;
  2042. }
  2043. // 2. Find the image within the chart container Span
  2044. if (chartContainerSpan) {
  2045. var chartContainerChildren = chartContainerSpan.children;
  2046. var chartContainerChildrenCount = chartContainerChildren.length;
  2047. for (var i=0; i<chartContainerChildrenCount; i++) {
  2048. var el = chartContainerChildren[i];
  2049. if (el.tagName == "IMG" && el.getAttribute("rsvpchart") == "true" && el.getAttribute("usemap") == "#" + map.name) {
  2050. result = el;
  2051. break;
  2052. }
  2053. }
  2054. }
  2055. return result;
  2056. };
  2057. CImageMapHighlight.prototype._AREA_ID = "aid";
  2058. CImageMapHighlight.prototype._setMapAreasId = function() {
  2059. var mapLid_ = this.m_map.getAttribute( "lid" ) + "_";
  2060. var areas = this.m_map.childNodes;
  2061. var areaCount = areas.length;
  2062. for (var i=0; i<areaCount; i++ ) {
  2063. var a = areas[i];
  2064. var id = mapLid_ + i;
  2065. a.setAttribute(this._AREA_ID,id);
  2066. this.m_areaNodes[id]=a;
  2067. }
  2068. };
  2069. CImageMapHighlight.prototype.isAreaInitialized = function(area) {
  2070. return (area.getAttribute(this._AREA_ID) === null? false : true);
  2071. };
  2072. CImageMapHighlight.prototype.getAreaId = function(area) {
  2073. var areaId = area.getAttribute(this._AREA_ID);
  2074. if (areaId === null) {
  2075. // re-initialize
  2076. this.initialize(area.parentNode);
  2077. areaId = area.getAttribute(this._AREA_ID);
  2078. }
  2079. return areaId + this.getFillColour();
  2080. };
  2081. CImageMapHighlight.prototype.getAreaFromId = function(areaid) {
  2082. return this.m_areaNodes[areaid];
  2083. };
  2084. CImageMapHighlight.prototype.highlightArea = function(area, append) {
  2085. var areaId = this.getAreaId(area); //
  2086. // hide all but the one to highlight if not append
  2087. if (!append) {
  2088. var visibleAreas = this.m_visibleAreas;
  2089. var visiblesAreaCount = visibleAreas.length;
  2090. for (var i = 0; i < visiblesAreaCount; i++) {
  2091. if (areaId != visibleAreas[i]) {
  2092. this.hideAreaById(visibleAreas[i]);
  2093. }
  2094. }
  2095. this.m_visibleAreas = [];
  2096. }
  2097. this._highlightArea(area);
  2098. };
  2099. CImageMapHighlight.prototype.highlightAreas = function(areas, append) {
  2100. if (!append) {
  2101. this.hideAllAreas();
  2102. }
  2103. this._highlightAreas(areas);
  2104. };
  2105. /**
  2106. * highlight multiple areas
  2107. */
  2108. CImageMapHighlight.prototype._highlightAreas = function(areas) {
  2109. var areasCount = areas.length;
  2110. for (var i = 0; i < areasCount; i++) {
  2111. this._highlightArea(areas[i]);
  2112. }
  2113. };
  2114. CImageMapHighlight.prototype._highlightArea = function(area) {
  2115. var areaId = this.getAreaId(area);
  2116. if (!this.highlightAreaExists(areaId)) {
  2117. var highLight = this.createHighlight(area);
  2118. if (highLight) {
  2119. this.m_areas[areaId] = highLight;
  2120. highLight.style.visibility = "visible";
  2121. area.setAttribute("highlighted", "true");
  2122. }
  2123. } else {
  2124. // if not visible make it so
  2125. if (this.m_areas[areaId].style.visibility == "hidden") {
  2126. this.m_areas[areaId].style.visibility = "visible";
  2127. area.setAttribute("highlighted", "true");
  2128. }
  2129. }
  2130. this.m_visibleAreas.push(areaId);
  2131. };
  2132. CImageMapHighlight.prototype.highlightAreaExists = function(areaId){
  2133. return this.m_areas[areaId] ? true : false;
  2134. };
  2135. CImageMapHighlight.prototype.hideAreaById = function(areaId) {
  2136. if ( this.m_areas[areaId] && this.m_areas[areaId].style.visibility ) {
  2137. this.m_areas[areaId].style.visibility = "hidden";
  2138. }
  2139. };
  2140. CImageMapHighlight.prototype.hideAreas = function(areas) {
  2141. var areasCount = areas.length;
  2142. for (var i = 0; i < areasCount; i++) {
  2143. this.hideArea(areas[i]);
  2144. }
  2145. };
  2146. CImageMapHighlight.prototype.hideArea = function(area) {
  2147. this.hideAreaById(this.getAreaId(area));
  2148. area.setAttribute("highlighted", "false");
  2149. };
  2150. CImageMapHighlight.prototype.hideAllAreas = function() {
  2151. var visibleAreas = this.m_visibleAreas;
  2152. var visiblesAreaCount = visibleAreas.length;
  2153. for (var i = 0; i < visiblesAreaCount; i++) {
  2154. this.hideAreaById(visibleAreas[i]);
  2155. var areaNode = this.getAreaFromId(visibleAreas[i]);
  2156. if(areaNode) {
  2157. areaNode.setAttribute("highlighted", "false");
  2158. }
  2159. }
  2160. this.m_visibleAreas = [];
  2161. };
  2162. CImageMapHighlight.prototype.isAreaHighlighted = function(area) {
  2163. var areaId = this.getAreaId(area);
  2164. return this.m_areas[areaId] && this.m_areas[areaId].style.visibility == "visible";
  2165. };
  2166. CImageMapHighlight.prototype.removeAreaHighlights = function(areas) {
  2167. };
  2168. CImageMapHighlight.prototype.removeAllAreaHighlights = function() {
  2169. };
  2170. CImageMapHighlight.prototype.destroy = function(area) {
  2171. this.removeAllAreaHighlights();
  2172. };
  2173. CImageMapHighlight.prototype.createHighlightElement = function( v_elArea, v_bIsHover )
  2174. {
  2175. var doc = v_elArea.ownerDocument;
  2176. if ( !this.m_divCanvas )
  2177. {
  2178. for ( var v_elAncestor = this.m_img.parentNode; v_elAncestor; v_elAncestor = v_elAncestor.parentNode )
  2179. {
  2180. if ( ( v_elAncestor.nodeName == "DIV" ) && ( v_elAncestor.getAttribute( "sSpecName" ) == "block" ) )
  2181. {
  2182. var v_oStyle = doc.defaultView.getComputedStyle( v_elAncestor , null );
  2183. var v_sOverflow = v_oStyle.overflow;
  2184. if ( ( v_sOverflow == "auto" ) || ( v_sOverflow == "scroll" ) && ( v_oStyle.position != "relative" ) )
  2185. {
  2186. v_elAncestor.style.position = "relative";
  2187. }
  2188. }
  2189. }
  2190. this.m_divCanvas = doc.createElementNS( "http://www.w3.org/2000/svg", "svg" );
  2191. this.m_divCanvas.style.height = this.m_sImageHeight;
  2192. this.m_divCanvas.style.width = this.m_sImageWidth;
  2193. this.m_divCanvas.style.position = "absolute";
  2194. //this.m_divCanvas.style.border = "1px solid green";
  2195. //this.m_divCanvas.style.backgroundColor = "red";
  2196. this.m_img.parentNode.insertBefore( this.m_divCanvas, this.m_imgBlank );
  2197. this.f_copyStyle( this.m_imgBlank, this.m_divCanvas );
  2198. this.m_divCanvas.style.display = this.m_bHiddenCanvas ? "none" : "block";
  2199. }
  2200. var v_elPolyline = doc.createElementNS( "http://www.w3.org/2000/svg", "polyline" );
  2201. var v_sCoords = v_elArea.getAttribute( "coords" );
  2202. v_elPolyline.setAttribute( "points", v_elArea.getAttribute( "coords" ) + " " + v_sCoords.substr( 0, v_sCoords.indexOf( ",", v_sCoords.indexOf( "," ) + 1 ) ) );
  2203. v_elPolyline.style.position = "absolute";
  2204. v_elPolyline.style.top = "0px";
  2205. v_elPolyline.style.left = "0px";
  2206. v_elPolyline.style.visibility = "hidden";
  2207. v_elPolyline.setAttribute( "stroke", v_bIsHover ? "#F7CB83" : this.getStrokeColour() );
  2208. v_elPolyline.setAttribute( "stroke-width", ( v_elArea.getAttribute( "type" ) == "legendLabel" ) ? "1pt" : "1.75pt" );
  2209. v_elPolyline.setAttribute( "fill", v_bIsHover ? "#F7E1BC" : this.getFillColour() );
  2210. v_elPolyline.setAttribute( "fill-opacity", "0.4" );
  2211. this.m_divCanvas.appendChild( v_elPolyline );
  2212. return v_elPolyline;
  2213. };
  2214. CImageMapHighlight.prototype.f_copyStyle = function( v_elFrom, v_elTo )
  2215. {
  2216. var a = ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "border", "borderTop", "borderRight", "borderBottom", "borderLeft"];
  2217. var v_iLength = a.length;
  2218. for ( var i = 0; i < v_iLength; i++ )
  2219. {
  2220. var v_sName = a[i];
  2221. var v_sValue = v_elFrom.style[v_sName];
  2222. if ( v_sValue )
  2223. {
  2224. v_elTo.style[v_sName] = v_sValue;
  2225. }
  2226. }
  2227. };
  2228. /*
  2229. *+------------------------------------------------------------------------+
  2230. *| Licensed Materials - Property of IBM
  2231. *| IBM Cognos Products: Viewer
  2232. *| (C) Copyright IBM Corp. 2001, 2011
  2233. *|
  2234. *| US Government Users Restricted Rights - Use, duplication or
  2235. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  2236. *|
  2237. *+------------------------------------------------------------------------+
  2238. */
  2239. /*------------------------------------------------------------------------------------------
  2240. Object model for the selection context information
  2241. CSelectionXml = {
  2242. queries: {
  2243. <query_name>: { <!! SC_SingleQuery !!>
  2244. selections: [
  2245. { <!! SC_SingleSelection !!>
  2246. rows: [{},...],
  2247. cols: [{},...],
  2248. measures: [{},...],
  2249. sections: [{},...],
  2250. layoutElementId: <string>
  2251. },
  2252. ...
  2253. ],
  2254. slicers: [ { <!! SC_SingleSlicer !!> },... ],
  2255. filters: {
  2256. detailFilters: [ { <!! SC_SingleDetailFilter !!> },... ],
  2257. summaryFilters: [ { <!! SC_SingleSummaryFilter !!> },... ]
  2258. }
  2259. },
  2260. ...
  2261. },
  2262. burstContext: {
  2263. //TODO
  2264. }
  2265. }
  2266. ------------------------------------------------------------------------------------------*/
  2267. function CSelectionXml(burstID, contentLocale, expressionLocale) {
  2268. this.queries = {};
  2269. this.burstContext = burstID || "";
  2270. this.expressionLocale = contentLocale || "";
  2271. this.contentLocale = expressionLocale || "";
  2272. }
  2273. ///////////////////////////////////////////////////////////////
  2274. // NOTE: shallow functions for defining structure. They'll be
  2275. // treated as Objects within CSelectionXml.
  2276. // i.e., they're not expected to do self-serialization
  2277. ///////////////////////////////////////////////////////////////
  2278. function SC_SingleSelection() {
  2279. this.rows = [];
  2280. this.cols = [];
  2281. this.sections = [];
  2282. this.measures = [];
  2283. this.layoutElementId = "";
  2284. }
  2285. function SC_SingleQuery() {
  2286. this.selections = [];
  2287. this.slicers = [];
  2288. this.filters = [];
  2289. }
  2290. function SC_SingleSlicer() {}
  2291. function SC_SingleDetailFilter() {}
  2292. function SC_SingleSummaryFilter() {}
  2293. ////////////////////////////////////////////////////////////
  2294. CSelectionXml.prototype.BuildSelectionFromController = function(sc) {
  2295. if (sc) {
  2296. var selectedObjects = sc.getAllSelectedObjects();
  2297. for(var s = 0; s < selectedObjects.length; ++s) {
  2298. var selection = selectedObjects[s];
  2299. var selectionCtx = selection.getSelectedContextIds();
  2300. var muns = selection.getMuns();
  2301. var munCount = muns.length;
  2302. var singleSelection = new SC_SingleSelection();
  2303. singleSelection.layoutElementId = selection.getLayoutElementId();
  2304. var sQuery = null;
  2305. /********
  2306. To make this more generic in the future, all measure-oriented checks will need to be removed.
  2307. We should need to support member-only context, and other permutations.
  2308. ********/
  2309. for(var i = 0; i < munCount; ++i) {
  2310. var j, ctxId, displayValue;
  2311. if (i === 0 && munCount === 1) {
  2312. for(j = 0; j < muns[i].length; ++j) {
  2313. ctxId = selectionCtx[i][j];
  2314. if (ctxId != 0)
  2315. {
  2316. // place the selceted cell in the measure section. The wizard will take
  2317. // care of verifying that it's really a measure
  2318. if(j===0) {
  2319. //get the measure's query ref. This should be unique within a selection, except for sections.
  2320. sQuery = sc.getRefQuery(ctxId);
  2321. displayValue = selection.getDisplayValues()[j];
  2322. this._buildMeasureSelection(sc, ctxId, singleSelection.measures, displayValue, j, selection.getLayoutType());
  2323. } else {
  2324. //ignore other measures on the list report
  2325. if (sc.getUsageInfo(ctxId) != 2) {
  2326. this._buildEdgeSelection(sc, ctxId, singleSelection.cols, j);
  2327. }
  2328. }
  2329. }
  2330. }
  2331. } else {
  2332. for(j = 0; j < muns[i].length; ++j) {
  2333. ctxId = selectionCtx[i][j];
  2334. if (ctxId != 0)
  2335. {
  2336. if (i === 0) {
  2337. displayValue = selection.getDisplayValues()[j];
  2338. sQuery = sc.getRefQuery(ctxId);
  2339. this._buildMeasureSelection(sc, ctxId, singleSelection.measures, displayValue, j, selection.getLayoutType());
  2340. //get the measure's query ref. This should be unique within a selection, except for sections.
  2341. } else if (i === 1 ) {
  2342. this._buildEdgeSelection(sc, ctxId, singleSelection.rows, j);
  2343. } else if (i === 2) {
  2344. this._buildEdgeSelection(sc, ctxId, singleSelection.cols, j);
  2345. } else {
  2346. this._buildSectionSelection(sc, ctxId, singleSelection.sections, j);
  2347. }
  2348. }
  2349. }
  2350. }
  2351. }
  2352. this.AddSelection(sQuery, singleSelection);
  2353. }
  2354. }
  2355. };
  2356. CSelectionXml.prototype.AddSelection = function(queryName, context) {
  2357. if (!this.queries[queryName]) {
  2358. this.queries[queryName] = new SC_SingleQuery();
  2359. }
  2360. this.queries[queryName].selections.push(context);
  2361. };
  2362. CSelectionXml.prototype._buildMeasureSelection = function(sc, ctxId, measures, displayValue, idx, dataType) {
  2363. if (dataType == "" || dataType == null)
  2364. {
  2365. dataType = "datavalue";
  2366. }
  2367. if (ctxId) {
  2368. measures.push( {
  2369. name: sc.getRefDataItem(ctxId),
  2370. values: [ { use: sc.getUseValue(ctxId),
  2371. display: displayValue }],
  2372. order: idx,
  2373. hun: sc.getHun(ctxId),
  2374. dataType: dataType,
  2375. usage: sc.getUsageInfo(ctxId),
  2376. dtype: sc.getDataType(ctxId),
  2377. selection: "true" //TODO: is this supposed to be anything else?
  2378. });
  2379. }
  2380. };
  2381. CSelectionXml.prototype._buildEdgeSelection = function(sc, ctxId, edges, idx) {
  2382. if (ctxId) {
  2383. edges.push( {
  2384. name: sc.getRefDataItem(ctxId),
  2385. values: [ { use: this.getUseValue(sc, ctxId),
  2386. display: sc.getDisplayValue(ctxId) }],
  2387. order: idx,
  2388. lun: sc.getLun(ctxId),
  2389. hun: sc.getHun(ctxId),
  2390. dataType: "columnTitle",
  2391. usage: sc.getUsageInfo(ctxId),
  2392. dtype: sc.getDataType(ctxId)
  2393. });
  2394. }
  2395. };
  2396. CSelectionXml.prototype._buildSectionSelection = function(sc, ctxId, sections, idx) {
  2397. if (ctxId) {
  2398. sections.push( {
  2399. name: sc.getRefDataItem(ctxId),
  2400. values: [ { use: this.getUseValue(sc, ctxId),
  2401. display: sc.getDisplayValue(ctxId) }],
  2402. order: idx,
  2403. lun: sc.getLun(ctxId),
  2404. hun: sc.getHun(ctxId),
  2405. dataType: "section",
  2406. usage: sc.getUsageInfo(ctxId),
  2407. dtype: sc.getDataType(ctxId),
  2408. queryRef: sc.getRefQuery(ctxId)
  2409. });
  2410. }
  2411. };
  2412. /**
  2413. * If we have a MUN then use it, otherwise use the useValue
  2414. * @private
  2415. */
  2416. CSelectionXml.prototype.getUseValue = function(sc, ctxId)
  2417. {
  2418. var useValue = sc.getMun(ctxId);
  2419. if (useValue == "")
  2420. {
  2421. useValue = sc.getUseValue(ctxId);
  2422. }
  2423. return useValue;
  2424. };
  2425. /*===================================================
  2426. Serialization of the selection
  2427. Context
  2428. ====================================================*/
  2429. CSelectionXml.prototype.toXml = function() {
  2430. var xmlSelectionsDocument = XMLBuilderCreateXMLDocument("selections");
  2431. var xmlSelections = xmlSelectionsDocument.documentElement;
  2432. XMLBuilderSetAttributeNodeNS(xmlSelections, "xmlns:xs", "http://www.w3.org/2001/XMLSchema");
  2433. XMLBuilderSetAttributeNodeNS(xmlSelections, "xmlns:bus", "http://developer.cognos.com/schemas/bibus/3/");
  2434. XMLBuilderSetAttributeNodeNS(xmlSelections, "SOAP-ENC:arrayType", "bus:parameterValue[]", "http://schemas.xmlsoap.org/soap/encoding/");
  2435. XMLBuilderSetAttributeNodeNS(xmlSelections, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
  2436. XMLBuilderSetAttributeNodeNS(xmlSelections, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  2437. xmlSelections.setAttribute("contentLocale", this.contentLocale);
  2438. xmlSelections.setAttribute("expressionLocale", this.expressionLocale);
  2439. for(var q in this.queries) {
  2440. this._queryToXml(xmlSelections, q, this.queries[q]);
  2441. }
  2442. this._burstToXml(xmlSelections);
  2443. return XMLBuilderSerializeNode(xmlSelectionsDocument);
  2444. };
  2445. CSelectionXml.prototype._queryToXml = function(parent, name, obj) {
  2446. var xmlQuery = parent.ownerDocument.createElement("query");
  2447. xmlQuery.setAttribute("name", name);
  2448. for(var selection = 0; selection < obj.selections.length; ++selection) {
  2449. this._selectionToXml(xmlQuery, obj.selections[selection]);
  2450. }
  2451. for(var slicer = 0; slicer < obj.slicers.length; ++slicer) {
  2452. this._slicersToXml(xmlQuery, obj.slicers[slicer]);
  2453. }
  2454. for(var filter = 0; filter < obj.selections.length; ++filter) {
  2455. this._filtersToXml(xmlQuery, obj.selections[filter]);
  2456. }
  2457. parent.appendChild(xmlQuery);
  2458. };
  2459. CSelectionXml.prototype._selectionToXml = function(parent, selection) {
  2460. var doc = parent.ownerDocument;
  2461. var xmlSelection = doc.createElement("selection");
  2462. parent.appendChild(xmlSelection);
  2463. this._edgeToXml(xmlSelection, "row", selection.rows);
  2464. this._edgeToXml(xmlSelection, "column", selection.cols);
  2465. this._edgeToXml(xmlSelection, "measure", selection.measures);
  2466. this._edgeToXml(xmlSelection, "section", selection.sections);
  2467. var layoutElementId = doc.createElement("layoutElementId");
  2468. layoutElementId.appendChild(doc.createTextNode(selection.layoutElementId));
  2469. xmlSelection.appendChild(layoutElementId);
  2470. };
  2471. CSelectionXml.prototype._edgeToXml = function(parent, sEdge, aContext) {
  2472. var doc = parent.ownerDocument;
  2473. //row edge name: "row" + "s"
  2474. var xmlEdgeContainer = doc.createElement(sEdge+'s');
  2475. parent.appendChild(xmlEdgeContainer);
  2476. for(var i = 0; i < aContext.length; ++i) {
  2477. var xmlEdge = doc.createElement(sEdge);
  2478. xmlEdgeContainer.appendChild(xmlEdge);
  2479. var edge = aContext[i];
  2480. for(var j in edge) {
  2481. if (j !== "name" && j !== "values") {
  2482. //add all the properties of the object as attributes, except "name" and "values" which
  2483. //are added later. Check for null only. Nothing should be undefined, and we want to maintain
  2484. //0 as a number.
  2485. xmlEdge.setAttribute(j, edge[j] !== null ? edge[j] : "");
  2486. }
  2487. }
  2488. this._itemToXml(xmlEdge, edge.name, edge.values);
  2489. }
  2490. };
  2491. CSelectionXml.prototype._itemToXml = function(parent, name, values) {
  2492. var doc = parent.ownerDocument;
  2493. var xmlItem = doc.createElement("item");
  2494. XMLBuilderSetAttributeNodeNS(xmlItem, "xsi:type", "bus:parameterValue", "http://www.w3.org/2001/XMLSchema-instance");
  2495. var xmlBusName = XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:name", doc);
  2496. XMLBuilderSetAttributeNodeNS(xmlBusName, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  2497. xmlBusName.appendChild(doc.createTextNode(name));
  2498. xmlItem.appendChild(xmlBusName);
  2499. var xmlBusValue = XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:value", doc);
  2500. XMLBuilderSetAttributeNodeNS(xmlBusValue, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  2501. XMLBuilderSetAttributeNodeNS(xmlBusValue, "SOAP-ENC:arrayType", "bus:parmValueItem[]", "http://schemas.xmlsoap.org/soap/encoding/");
  2502. xmlItem.appendChild(xmlBusValue);
  2503. ///NOTE: We only expect one value currently, but we support a list
  2504. for (var j = 0; j < values.length; j++)
  2505. {
  2506. var xmlValueItem = doc.createElement("item");
  2507. XMLBuilderSetAttributeNodeNS(xmlValueItem, "xsi:type", "bus:simpleParmValueItem", "http://www.w3.org/2001/XMLSchema-instance");
  2508. var xmlValueUse = XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:use", doc);
  2509. XMLBuilderSetAttributeNodeNS(xmlValueUse, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  2510. if(values[j].use)
  2511. {
  2512. xmlValueUse.appendChild(doc.createTextNode(values[j].use));
  2513. }
  2514. else if (values[j].display)
  2515. {
  2516. xmlValueUse.appendChild(doc.createTextNode(values[j].display));
  2517. }
  2518. else
  2519. {
  2520. xmlValueUse.appendChild(doc.createTextNode(""));
  2521. }
  2522. var xmlValueDisplay = XMLBuilderCreateElementNS("http://developer.cognos.com/schemas/bibus/3/", "bus:display", doc);
  2523. XMLBuilderSetAttributeNodeNS(xmlValueDisplay, "xsi:type", "xs:string", "http://www.w3.org/2001/XMLSchema-instance");
  2524. if (values[j].display)
  2525. {
  2526. xmlValueDisplay.appendChild(doc.createTextNode(values[j].display));
  2527. }
  2528. else
  2529. {
  2530. xmlValueDisplay.appendChild(doc.createTextNode(""));
  2531. }
  2532. xmlValueItem.appendChild(xmlValueUse);
  2533. xmlValueItem.appendChild(xmlValueDisplay);
  2534. xmlBusValue.appendChild(xmlValueItem);
  2535. }
  2536. parent.appendChild(xmlItem);
  2537. };
  2538. CSelectionXml.prototype._burstToXml = function(parent) {
  2539. var doc = parent.ownerDocument;
  2540. var burstContext = doc.createElement("burst-context");
  2541. burstContext.appendChild(doc.createTextNode(this.burstContext));
  2542. parent.appendChild(burstContext);
  2543. };
  2544. CSelectionXml.prototype._slicersToXml = function(parent, slicers) {
  2545. //TODO: add later
  2546. };
  2547. CSelectionXml.prototype._filtersToXml = function(parent, filter) {
  2548. //TODO: add later
  2549. };
  2550. /*
  2551. *+------------------------------------------------------------------------+
  2552. *| Licensed Materials - Property of IBM
  2553. *| IBM Cognos Products: Viewer
  2554. *| (C) Copyright IBM Corp. 2001, 2012
  2555. *|
  2556. *| US Government Users Restricted Rights - Use, duplication or
  2557. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  2558. *|
  2559. *+------------------------------------------------------------------------+
  2560. */
  2561. // constants
  2562. CSubscriptionManager.k_SubscriptionWizardName = "subscriptionWizard";
  2563. function CSubscriptionManager(cv)
  2564. {
  2565. this.m_cv = cv;
  2566. /**
  2567. @type boolean
  2568. @private
  2569. */
  2570. this.m_bInitialized = false;
  2571. /**
  2572. @type array
  2573. @private
  2574. */
  2575. this.m_aWatchRules = null;
  2576. /**
  2577. @type string
  2578. @private
  2579. */
  2580. this.m_sEmail = "";
  2581. /**
  2582. @type string
  2583. @private
  2584. */
  2585. this.m_sAlertNewVersionConfirm = "";
  2586. /**
  2587. @type boolean
  2588. @private
  2589. */
  2590. this.m_sQueryNotificationResponse = "";
  2591. /**
  2592. @type boolean
  2593. @private
  2594. */
  2595. this.m_bAllowNotification = false;
  2596. /**
  2597. @type boolean
  2598. @private
  2599. */
  2600. this.m_bAllowSubscription = false;
  2601. /**
  2602. @type boolean
  2603. @private
  2604. */
  2605. this.m_bCanCreateNewWatchRule = false;
  2606. /**
  2607. @type boolean
  2608. @private
  2609. */
  2610. this.m_bCanGetNotified = false;
  2611. /**
  2612. @type boolean
  2613. @private
  2614. */
  2615. this.m_bAllowAnnotations = false;
  2616. /**
  2617. @type boolean
  2618. @private
  2619. */
  2620. this.m_bCanCreateAnnotations = false;
  2621. /**
  2622. @type string
  2623. @private
  2624. */
  2625. this.m_windowOptions = "width=450,height=350,toolbar=0,location=0,status=0,menubar=0,resizable,scrollbars=1";
  2626. //"width=500,height=350,toolbar=0,location=0,status=0,menubar=0,resizable,scrollbars=1";
  2627. }
  2628. CSubscriptionManager.prototype.getViewer = function() {
  2629. return this.m_cv;
  2630. };
  2631. /**
  2632. Initialize the subscription member variables with the server response
  2633. */
  2634. CSubscriptionManager.prototype.Initialize = function(response)
  2635. {
  2636. try
  2637. {
  2638. var oJSONResponse = response.getJSONResponseObject();
  2639. var formWarpRequest = document.forms['formWarpRequest' + this.m_cv.getId()];
  2640. if (oJSONResponse["annotationInfo"]) {
  2641. var oAnnotationInfo = oJSONResponse["annotationInfo"];
  2642. this.m_AnnotationsCount = oAnnotationInfo.annotations.length;
  2643. // Push the whole annotations in current session
  2644. this.m_annotations = oAnnotationInfo.annotations;
  2645. this.m_bAllowAnnotations = oAnnotationInfo.allowAnnotations;
  2646. this.m_bCanCreateAnnotations = oAnnotationInfo.traverse == "true";
  2647. return true;
  2648. }
  2649. if (oJSONResponse["subscriptionInfo"])
  2650. {
  2651. var oSubscriptionInfo = oJSONResponse["subscriptionInfo"];
  2652. if (!this.m_bInitialized)
  2653. {
  2654. this.m_sEmail = oSubscriptionInfo.sEmail;
  2655. this.m_bAllowNotification = oSubscriptionInfo.bAllowNotification;
  2656. this.m_bAllowSubscription = oSubscriptionInfo.bAllowSubscription;
  2657. this.m_sAlertNewVersionConfirm = oSubscriptionInfo.sAlertNewVersionConfirm;
  2658. if (formWarpRequest["ui.action"] && formWarpRequest["ui.action"].value == 'view')
  2659. {
  2660. /*
  2661. Can the user create new watch rules
  2662. - Report output is in HTML with interactive information
  2663. - User has the 'Create and Run Watch Rules' capability
  2664. - Alerts using watch rules are allowed for the report
  2665. */
  2666. if (formWarpRequest["ui.format"])
  2667. {
  2668. this.m_bCanCreateNewWatchRule = (formWarpRequest["ui.format"].value == 'HTML') && this.m_cv.bCanUseCognosViewerConditionalSubscriptions && this.m_bAllowSubscription;
  2669. }
  2670. /*
  2671. Can the user subscribe to notifications
  2672. - the report must not be bursted
  2673. - user cannot have scheduled the report
  2674. - report must allow notifications
  2675. */
  2676. this.m_bCanGetNotified = (!formWarpRequest["ui.burstKey"] || (formWarpRequest["ui.burstKey"] && formWarpRequest["ui.burstKey"].value == "")) && this.m_bAllowNotification;
  2677. }
  2678. }
  2679. if (oSubscriptionInfo.sQueryNotificationResponse)
  2680. {
  2681. this.m_sQueryNotificationResponse = oSubscriptionInfo.sQueryNotificationResponse;
  2682. }
  2683. if (oSubscriptionInfo.aWatchRules)
  2684. {
  2685. var aWatchRules = oSubscriptionInfo.aWatchRules;
  2686. this.m_aWatchRules = [];
  2687. for (var i=0; i < aWatchRules.length; i++)
  2688. {
  2689. this.m_aWatchRules.push( aWatchRules[i] );
  2690. }
  2691. }
  2692. this.m_bInitialized = true;
  2693. return true;
  2694. }
  2695. }
  2696. catch(exception)
  2697. {
  2698. return false;
  2699. }
  2700. return false;
  2701. };
  2702. /**
  2703. Checks the current selection to see if it's valid for creating a new Watch Rule
  2704. */
  2705. CSubscriptionManager.prototype.IsValidSelectionForNewRule = function()
  2706. {
  2707. var selectionController = this.m_cv.getSelectionController();
  2708. if (selectionController && !selectionController.hasSelectedChartNodes())
  2709. {
  2710. var selectedObjects = selectionController.getAllSelectedObjects();
  2711. if (selectedObjects.length === 1)
  2712. {
  2713. if (selectedObjects[0] != null && selectedObjects[0].getLayoutType() != 'columnTitle')
  2714. {
  2715. return true;
  2716. }
  2717. }
  2718. }
  2719. return false;
  2720. };
  2721. /**
  2722. Can the user create new watch rules
  2723. */
  2724. CSubscriptionManager.prototype.CanCreateNewWatchRule = function()
  2725. {
  2726. if (typeof this.m_cv.UIBlacklist != "undefined" && this.m_cv.UIBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_ALERT_USING_NEW_WATCH_RULE ') != -1)
  2727. {
  2728. return false;
  2729. }
  2730. // if we haven't been initialized yet and we're looking at saved output
  2731. if (!this.m_bInitialized && this.getViewer().envParams["ui.action"] == 'view')
  2732. {
  2733. var oCV = this.getViewer();
  2734. var request = new JSONDispatcherEntry(oCV);
  2735. request.setKey("subscriptionManager");
  2736. request.forceSynchronous();
  2737. request.addFormField("ui.action", "getSubscriptionInfo");
  2738. request.addFormField("cv.responseFormat", "subscriptionManager");
  2739. request.addFormField("contextMenu", "true");
  2740. this.addCommonFormFields(request);
  2741. request.setCallbacks({"complete":{"object":this, "method":this.Initialize}});
  2742. oCV.dispatchRequest(request);
  2743. }
  2744. return this.m_bCanCreateNewWatchRule;
  2745. };
  2746. /**
  2747. Has the logic to determine if the current user can modify the Watch Rules
  2748. */
  2749. CSubscriptionManager.prototype.CanModifyWatchRule = function()
  2750. {
  2751. return this.m_cv.bCanUseCognosViewerConditionalSubscriptions && this.m_bAllowSubscription;
  2752. };
  2753. /**
  2754. Has the logic to determine if the current user can subscribe to notifications
  2755. */
  2756. CSubscriptionManager.prototype.CanGetNotified = function()
  2757. {
  2758. if (typeof this.m_cv.UIBlacklist != "undefined" && this.m_cv.UIBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_ALERT_ABOUT_NEW_VERSIONS ') != -1)
  2759. {
  2760. return false;
  2761. }
  2762. return this.m_bCanGetNotified;
  2763. };
  2764. /**
  2765. Updates the subscription dropdown menu
  2766. */
  2767. CSubscriptionManager.prototype.UpdateSubscribeMenu = function()
  2768. {
  2769. var toolbar = this.getStandaloneViewerToolbarControl();
  2770. var subscribeButton = toolbar? toolbar.getItem("watchNewVersions") : null;
  2771. var sWebContentRoot = this.m_cv.getWebContentRoot();
  2772. var sSkin = this.m_cv.getSkin();
  2773. if (subscribeButton)
  2774. {
  2775. var subscribeDropDownMenu = subscribeButton.getMenu();
  2776. // Clear the menu
  2777. this.ClearSubscriptionMenu();
  2778. var bAddSeperator = false;
  2779. if ( this.CanGetNotified() )
  2780. {
  2781. if (this.m_sQueryNotificationResponse == 'on')
  2782. {
  2783. 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);
  2784. bAddSeperator = true;
  2785. }
  2786. else if (this.m_sQueryNotificationResponse == 'off' && this.m_sEmail != "")
  2787. {
  2788. 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);
  2789. bAddSeperator = true;
  2790. }
  2791. }
  2792. if (this.CanCreateNewWatchRule())
  2793. {
  2794. if (bAddSeperator)
  2795. {
  2796. subscribeDropDownMenu.add(gMenuSeperator);
  2797. }
  2798. 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);
  2799. if (!this.IsValidSelectionForNewRule())
  2800. {
  2801. newSubscription.disable();
  2802. }
  2803. bAddSeperator = true;
  2804. }
  2805. var sBlacklist = "";
  2806. if (typeof this.m_cv.UIBlacklist != "undefined")
  2807. {
  2808. sBlacklist = this.m_cv.UIBlacklist;
  2809. }
  2810. var noWatchRules;
  2811. //iterate through existing subscriptions
  2812. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES ') == -1)
  2813. {
  2814. if (bAddSeperator)
  2815. {
  2816. subscribeDropDownMenu.add(gMenuSeperator);
  2817. }
  2818. if ( this.m_aWatchRules && this.m_aWatchRules.length > 0)
  2819. {
  2820. var bCanModifyWatchRules = this.CanModifyWatchRule();
  2821. for(var sub = 0; sub < this.m_aWatchRules.length; ++sub)
  2822. {
  2823. var menu = new CMenuItem(subscribeDropDownMenu, this.m_aWatchRules[sub].name, "", sWebContentRoot + "/rv/images/icon_subscription.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  2824. var subMenu = menu.createCascadedMenu(gMenuStyle);
  2825. subMenu.m_oCV = this.m_cv;
  2826. if (bCanModifyWatchRules && sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES_MODIFY ') == -1) {
  2827. 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);
  2828. }
  2829. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES_DELETE ') == -1)
  2830. {
  2831. 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);
  2832. }
  2833. }
  2834. }
  2835. else
  2836. {
  2837. noWatchRules = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NO_WATCH_RULES, "", '', gMenuItemStyle, sWebContentRoot, sSkin);
  2838. noWatchRules.disable();
  2839. }
  2840. }
  2841. if (subscribeDropDownMenu.getNumItems() == 0)
  2842. {
  2843. noWatchRules = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NO_WATCH_RULES, "", '', gMenuItemStyle, sWebContentRoot, sSkin);
  2844. noWatchRules.disable();
  2845. }
  2846. // make sure we don't use the callback when drawing the menu
  2847. subscribeDropDownMenu.setForceCallback(false);
  2848. subscribeDropDownMenu.draw();
  2849. if (subscribeDropDownMenu.isVisible()) {
  2850. subscribeDropDownMenu.show();
  2851. }
  2852. // make sure our callback is used when the menu gets opened again
  2853. subscribeDropDownMenu.setForceCallback(true);
  2854. }
  2855. };
  2856. /**
  2857. Updates the subscription dropdown menu
  2858. */
  2859. CSubscriptionManager.prototype.UpdateAnnotationMenu = function()
  2860. {
  2861. var toolbar = this.getStandaloneViewerToolbarControl();
  2862. var annotationButton = toolbar? toolbar.getItem("addAnnotations") : null;
  2863. var sWebContentRoot = this.m_cv.getWebContentRoot();
  2864. var sSkin = this.m_cv.getSkin();
  2865. var annotDropDownMenu = annotationButton.getMenu();
  2866. // Clear the menu
  2867. this.ClearAnnotationMenu();
  2868. // add the create menu item
  2869. 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);
  2870. var annotationsCount = this.m_annotations.length;
  2871. if (annotationsCount > 0) {
  2872. annotDropDownMenu.add(gMenuSeperator);
  2873. }
  2874. // disable the item if allowAnnotations is false.
  2875. if (!this.m_bAllowAnnotations || !this.m_bCanCreateAnnotations)
  2876. {
  2877. menu.disable();
  2878. }
  2879. //iterate through existing annotations
  2880. var menuName;
  2881. var bidi = isViewerBidiEnabled() ? BidiUtils.getInstance() : null;
  2882. for(var i=0; i<annotationsCount; i++){
  2883. var defName = this.m_annotations[i].defaultName ;
  2884. menuName = defName.length>60 ? defName.substring(0, 60)+'...' : defName;
  2885. if(isViewerBidiEnabled()){
  2886. menuName = bidi.btdInjectUCCIntoStr(menuName, getViewerBaseTextDirection());
  2887. }
  2888. // check all the permissions
  2889. var readPermission = Boolean(this.m_annotations[i].permissions.read);
  2890. var modifyPermission = Boolean(this.m_annotations[i].permissions.write);
  2891. var deletePermission = Boolean(this.m_annotations[i].permissions.traverse) && Boolean(this.m_annotations[i].permissions.write);
  2892. var dispCmd = "javascript:" + this.m_cv.getObjectId() + ".getSubscriptionManager().ViewAnnotation("+i+");";
  2893. var alertMsg = "javascript:alert('Permission denied')" ;
  2894. dispCmd = readPermission ? dispCmd : alertMsg;
  2895. // decide if we want to add a separator - which we do if the layoutElementId has changed
  2896. if (i > 0 && this.m_annotations[i].layoutElementId != this.m_annotations[i-1].layoutElementId) {
  2897. annotDropDownMenu.add(gMenuSeperator);
  2898. }
  2899. var menuItemImage = "/rv/images/action_comment.gif";
  2900. if (this.m_annotations[i].layoutElementId != "") {
  2901. menuItemImage = "/rv/images/action_subscribe.gif";
  2902. }
  2903. menu = new CMenuItem(annotDropDownMenu, menuName, dispCmd, sWebContentRoot + menuItemImage, gMenuItemStyle, sWebContentRoot, sSkin);
  2904. // we only create the cascaded menu if can alter things
  2905. var subMenu = menu.createCascadedMenu(gMenuStyle);
  2906. // add an info pane to the top of the menu
  2907. var infoPanel = new CInfoPanel("300px", sWebContentRoot, subMenu.getId() + "_comments");
  2908. infoPanel.setParent(subMenu);
  2909. // add all the properties that we want
  2910. defName = this.m_annotations[i].defaultName ;
  2911. var menuName1 = defName.length>60 ? defName.substring(0, 60)+'...' : defName;
  2912. if(isViewerBidiEnabled()){
  2913. menuName1 = bidi.btdInjectUCCIntoStr(menuName1, getViewerBaseTextDirection());
  2914. }
  2915. infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_NAME,html_encode(menuName1));
  2916. infoPanel.addSpacer(4);
  2917. var cmnt = this.m_annotations[i].description ;
  2918. var shortComment = cmnt.length>590 ? cmnt.substring(0, 590)+'...' : cmnt;
  2919. if(isViewerBidiEnabled()){
  2920. shortComment = bidi.btdInjectUCCIntoStr(shortComment, getViewerBaseTextDirection());
  2921. }
  2922. infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_CONTENTS, replaceNewLine(html_encode(shortComment)));
  2923. infoPanel.addSpacer(4);
  2924. var modifyTime = this.m_annotations[i].modificationTime ;
  2925. if(isViewerBidiEnabled()){
  2926. modifyTime = bidi.btdInjectUCCIntoStr(modifyTime, getViewerBaseTextDirection());
  2927. }
  2928. infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_MODTIME,modifyTime);
  2929. var ownerName = this.m_annotations[i].owner.defaultName ;
  2930. if(isViewerBidiEnabled()){
  2931. ownerName = bidi.btdInjectUCCIntoStr(ownerName, getViewerBaseTextDirection());
  2932. }
  2933. infoPanel.addProperty(RV_RES.RV_VIEW_COMMENT_OWNER, ownerName);
  2934. // add the pane to the menu
  2935. subMenu.add(infoPanel);
  2936. // add a separator if we have actions
  2937. if (modifyPermission || deletePermission) {
  2938. subMenu.add(gMenuSeperator);
  2939. }
  2940. 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);
  2941. if (modifyPermission) {
  2942. 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);
  2943. }
  2944. if (deletePermission)
  2945. {
  2946. 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);
  2947. }
  2948. }
  2949. // make sure we don't use the callback when drawing the menu
  2950. annotDropDownMenu.setForceCallback(false);
  2951. annotDropDownMenu.draw();
  2952. if (annotDropDownMenu.isVisible()) {
  2953. annotDropDownMenu.show();
  2954. }
  2955. // make sure our callback is used when the menu gets opened again
  2956. annotDropDownMenu.setForceCallback(true);
  2957. };
  2958. /**
  2959. Called when the user clicked on the 'Alert Me About New Versions' link
  2960. */
  2961. CSubscriptionManager.prototype.AddNotification = function()
  2962. {
  2963. alert(this.m_sAlertNewVersionConfirm);
  2964. var oCV = this.getViewer();
  2965. var request = new DataDispatcherEntry(oCV);
  2966. request.setKey("subscriptionManager");
  2967. request.addFormField("ui.action", "addNotification");
  2968. request.addFormField("cv.responseFormat", "data");
  2969. this.addCommonFormFields(request);
  2970. oCV.dispatchRequest(request);
  2971. };
  2972. /**
  2973. Called when the user clicked on the 'Do Not Alert Me About New Versions' link
  2974. */
  2975. CSubscriptionManager.prototype.DeleteNotification = function()
  2976. {
  2977. alert(RV_RES.RV_DO_NOT_ALERT_NEW_VERSION_CONFIRM);
  2978. var oCV = this.getViewer();
  2979. var request = new DataDispatcherEntry(oCV);
  2980. request.setKey("subscriptionManager");
  2981. request.addFormField("ui.action", "deleteNotification");
  2982. request.addFormField("cv.responseFormat", "data");
  2983. this.addCommonFormFields(request);
  2984. oCV.dispatchRequest(request);
  2985. };
  2986. /**
  2987. Called when the user clicked on the 'Add annotation' link
  2988. */
  2989. CSubscriptionManager.prototype.NewAnnotation = function()
  2990. {
  2991. var oFWR = document.forms["formWarpRequest" + this.m_cv.getId()];
  2992. var searchPath = oFWR["ui.object"].value;
  2993. var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(), CSubscriptionManager.k_SubscriptionWizardName);
  2994. GUtil.createFormField(form, "ui.object", searchPath);
  2995. GUtil.createFormField(form, "b_action", "xts.run");
  2996. GUtil.createFormField(form, "m", "rv/annotation1.xts");
  2997. GUtil.createFormField(form, "backURL", "javascript:window.close();");
  2998. GUtil.createFormField(form, "action_hint", "create");
  2999. var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
  3000. window.open(sPath, form.target, this.m_windowOptions);
  3001. };
  3002. /**
  3003. Called when the user clicked on an annotation' link
  3004. */
  3005. CSubscriptionManager.prototype.ViewAnnotation = function(idx)
  3006. {
  3007. var sub = this.m_annotations[idx];
  3008. var searchPath = sub.searchPath;
  3009. var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(), CSubscriptionManager.k_SubscriptionWizardName);
  3010. GUtil.createFormField(form, "ui.object", searchPath);
  3011. GUtil.createFormField(form, "b_action", "xts.run");
  3012. GUtil.createFormField(form, "m", "rv/annotation1.xts");
  3013. GUtil.createFormField(form, "backURL", "javascript:window.close();");
  3014. var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
  3015. window.open(sPath, form.target, this.m_windowOptions);
  3016. };
  3017. /**
  3018. User clicked the 'Modify...' link for a Watch Rule
  3019. @param idx - index of the rule that was clicked on
  3020. */
  3021. CSubscriptionManager.prototype.ModifyAnnotation = function(idx)
  3022. {
  3023. var sub = this.m_annotations[idx];
  3024. var searchPath = this.m_annotations[idx].searchPath;
  3025. // we need report version here
  3026. if (sub && searchPath)
  3027. {
  3028. var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(),
  3029. CSubscriptionManager.k_SubscriptionWizardName);
  3030. GUtil.createFormField(form, "ui.object", searchPath);
  3031. GUtil.createFormField(form, "b_action", "xts.run");
  3032. GUtil.createFormField(form, "m", "rv/annotation1.xts");
  3033. GUtil.createFormField(form, "backURL", "javascript:window.close();");
  3034. GUtil.createFormField(form, "action_hint", "save");
  3035. var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
  3036. window.open(sPath, form.target, this.m_windowOptions);
  3037. }
  3038. };
  3039. /**
  3040. Deletes an Annotation
  3041. @param idx - index of the rule that was clicked on
  3042. */
  3043. CSubscriptionManager.prototype.DeleteAnnotation = function(idx)
  3044. {
  3045. var sub = this.m_annotations[idx];
  3046. if (sub && sub.searchPath && confirm(RV_RES.RV_CONFIRM_DELETE_WATCH_RULE))
  3047. {
  3048. var oCV = this.getViewer();
  3049. var request = new DataDispatcherEntry(oCV);
  3050. request.setKey("subscriptionManager");
  3051. request.addFormField("ui.action", "deleteAnnotation");
  3052. request.addFormField("cv.responseFormat", "data");
  3053. this.addCommonFormFields(request, sub.searchPath);
  3054. oCV.dispatchRequest(request);
  3055. }
  3056. };
  3057. /**
  3058. Called when the user clicked on the 'Alert Using New Watch Rule' link
  3059. */
  3060. CSubscriptionManager.prototype.NewSubscription = function()
  3061. {
  3062. var sc = this.m_cv.getSelectionController();
  3063. var oFWR = document.forms["formWarpRequest" + this.m_cv.getId()];
  3064. var searchPath = oFWR.reRunObj.value;
  3065. if (searchPath && sc && sc.getAllSelectedObjects().length === 1 )
  3066. {
  3067. var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(), CSubscriptionManager.k_SubscriptionWizardName);
  3068. var fWR = document.getElementById("formWarpRequest" + this.m_cv.getId());
  3069. var selectionXml = new CSelectionXml( fWR["ui.burstID"].value,
  3070. fWR["ui.contentLocale"].value,
  3071. fWR["ui.outputLocale"].value
  3072. );
  3073. selectionXml.BuildSelectionFromController(sc);
  3074. //display a selectable-prompt containing the xml output -- TESTING ONLY
  3075. //prompt("SelectionXML: ", selectionXml.toXml());
  3076. GUtil.createFormField(form, "rv.selectionSpecXML", selectionXml.toXml());
  3077. GUtil.createFormField(form, "rv.periodicalProducer", searchPath);
  3078. GUtil.createFormField(form, "b_action", "xts.run");
  3079. GUtil.createFormField(form, "m", "subscribe/conditional_subscribe1.xts");
  3080. GUtil.createFormField(form, "backURL", "javascript:window.close();");
  3081. var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
  3082. window.open(sPath, form.target, "toolbar,location,status,menubar,resizable,scrollbars=1");
  3083. }
  3084. else
  3085. {
  3086. // for debugging
  3087. // alert("Invalid Context: sc: " + sc + "\n searchPath: " + searchPath);
  3088. }
  3089. };
  3090. /**
  3091. Deletes a watch rule
  3092. @param idx - index of the rule that was clicked on
  3093. */
  3094. CSubscriptionManager.prototype.DeleteSubscription = function(idx)
  3095. {
  3096. var sub = this.m_aWatchRules[idx];
  3097. if (sub && sub.searchPath && confirm(RV_RES.RV_CONFIRM_DELETE_WATCH_RULE))
  3098. {
  3099. var oCV = this.getViewer();
  3100. var request = new DataDispatcherEntry(oCV);
  3101. request.setKey("subscriptionManager");
  3102. request.addFormField("ui.action", "deleteSubscription");
  3103. request.addFormField("cv.responseFormat", "data");
  3104. this.addCommonFormFields(request, sub.searchPath);
  3105. oCV.dispatchRequest(request);
  3106. }
  3107. };
  3108. /**
  3109. User clicked the 'Modify...' link for a Watch Rule
  3110. @param idx - index of the rule that was clicked on
  3111. */
  3112. CSubscriptionManager.prototype.ModifySubscription = function(idx)
  3113. {
  3114. var sub = this.m_aWatchRules[idx];
  3115. if (sub && sub.searchPath)
  3116. {
  3117. var form = GUtil.createHiddenForm("subscriptionForm", "post", this.m_cv.getId(),
  3118. CSubscriptionManager.k_SubscriptionWizardName);
  3119. GUtil.createFormField(form, "m_obj", sub.searchPath);
  3120. GUtil.createFormField(form, "m_name", sub.name);
  3121. GUtil.createFormField(form, "b_action", "xts.run");
  3122. GUtil.createFormField(form, "m_class", "reportDataServiceAgentDefinition");
  3123. GUtil.createFormField(form, "m", "portal/properties_subscription.xts");
  3124. GUtil.createFormField(form, "backURL", "javascript:window.close();");
  3125. var sPath = this.m_cv.getWebContentRoot() + "/rv/blankSubscriptionWin.html?cv.id=" + this.m_cv.getId();
  3126. window.open(sPath, form.target, "toolbar,location,status,menubar,resizable,scrollbars=1");
  3127. }
  3128. };
  3129. /**
  3130. Does an AJAX call to get the needed information, and then updated the
  3131. drop down menu
  3132. */
  3133. CSubscriptionManager.prototype.OpenSubscriptionMenu = function()
  3134. {
  3135. var oCV = this.getViewer();
  3136. var request = new JSONDispatcherEntry(oCV);
  3137. request.setKey("subscriptionManager");
  3138. request.addFormField("ui.action", "getSubscriptionInfo");
  3139. request.addFormField("cv.responseFormat", "subscriptionManager");
  3140. this.addCommonFormFields(request);
  3141. request.setCallbacks({"complete":{"object":this, "method":this.OpenSubscriptionMenuResponse}});
  3142. oCV.dispatchRequest(request);
  3143. };
  3144. /**
  3145. Does an AJAX call to get the needed information, and then updated the
  3146. drop down menu
  3147. */
  3148. CSubscriptionManager.prototype.OpenAnnotationMenu = function()
  3149. {
  3150. var oCV = this.getViewer();
  3151. var request = new JSONDispatcherEntry(oCV);
  3152. request.setKey("subscriptionManager");
  3153. request.addFormField("ui.action", "getAnnotationInfo");
  3154. request.addFormField("cv.responseFormat", "getAnnotations");
  3155. var uiObject = oCV.envParams["ui.object"];
  3156. this.addCommonFormFields(request, uiObject ? uiObject : "");
  3157. request.setCallbacks({"complete":{"object":this, "method":this.OpenAnnotationMenuResponse}});
  3158. oCV.dispatchRequest(request);
  3159. };
  3160. /**
  3161. OpenSubscriptionMenuCallback will initialzie the CSubscriptionManager object and open the menu
  3162. @param {httpRequest} the XML response from the viewer
  3163. */
  3164. CSubscriptionManager.prototype.OpenAnnotationMenuResponse = function(response)
  3165. {
  3166. if (this.Initialize(response)) {
  3167. this.UpdateAnnotationMenu();
  3168. }
  3169. else {
  3170. // something bad happened, just clear the menu
  3171. this.ClearAnnotationMenu();
  3172. }
  3173. };
  3174. /**
  3175. OpenSubscriptionMenuCallback will initialzie the CSubscriptionManager object and open the menu
  3176. @param {httpRequest} the XML response from the viewer
  3177. */
  3178. CSubscriptionManager.prototype.OpenSubscriptionMenuResponse = function(response)
  3179. {
  3180. if (this.Initialize(response))
  3181. {
  3182. this.UpdateSubscribeMenu();
  3183. }
  3184. else
  3185. {
  3186. // something bad happened, just clear the menu
  3187. this.AddEmptySubscriptionMenuItem();
  3188. }
  3189. };
  3190. CSubscriptionManager.prototype.addCommonFormFields = function(request, searchPath) {
  3191. if (searchPath && searchPath != "") {
  3192. request.addFormField("ui.object", searchPath);
  3193. }
  3194. else {
  3195. var formWarpRequest = document["formWarpRequest" + this.getViewer().getId()];
  3196. if (formWarpRequest && formWarpRequest["reRunObj"]) {
  3197. request.addFormField("ui.object", formWarpRequest["reRunObj"].value);
  3198. }
  3199. }
  3200. // if we're already initialized it'll cut down on the number of CM queries we need to do
  3201. if (request.getFormField("ui.action") == "getSubscriptionInfo") {
  3202. request.addFormField("initialized", this.m_bInitialized ? "true" : "false");
  3203. }
  3204. request.addFormField("cv.id", this.getViewer().getId());
  3205. };
  3206. /**
  3207. * When there's nothing else to show in the Subscription menu, show
  3208. * a disabled menu item
  3209. */
  3210. CSubscriptionManager.prototype.AddEmptySubscriptionMenuItem = function()
  3211. {
  3212. var toolbar = this.getStandaloneViewerToolbarControl();
  3213. if (toolbar)
  3214. {
  3215. var subscribeButton = toolbar.getItem("watchNewVersions");
  3216. if (subscribeButton)
  3217. {
  3218. subscribeButton.getMenu().clear();
  3219. }
  3220. var sWebContentRoot = this.m_cv.getWebContentRoot();
  3221. var sSkin = this.m_cv.getSkin();
  3222. var subscribeDropDownMenu = subscribeButton.getMenu();
  3223. var noWatchRules = new CMenuItem(subscribeDropDownMenu, RV_RES.RV_NO_WATCH_RULES, "", '', gMenuItemStyle, sWebContentRoot, sSkin);
  3224. noWatchRules.disable();
  3225. // make sure we don't use the callback when drawing the menu
  3226. subscribeDropDownMenu.setForceCallback(false);
  3227. subscribeDropDownMenu.draw();
  3228. if (subscribeDropDownMenu.isVisible()) {
  3229. subscribeDropDownMenu.show();
  3230. }
  3231. // make sure our callback is used when the menu gets opened again
  3232. subscribeDropDownMenu.setForceCallback(true);
  3233. }
  3234. };
  3235. /**
  3236. Removes all the menu items from the 'Watch New Versions' menu
  3237. */
  3238. CSubscriptionManager.prototype.ClearSubscriptionMenu = function()
  3239. {
  3240. var toolbar = this.getStandaloneViewerToolbarControl();
  3241. if (toolbar)
  3242. {
  3243. var subscribeButton = toolbar.getItem("watchNewVersions");
  3244. if (subscribeButton)
  3245. {
  3246. subscribeButton.getMenu().clear();
  3247. }
  3248. }
  3249. };
  3250. /**
  3251. Removes all the menu items from the 'add Annotations' menu
  3252. */
  3253. CSubscriptionManager.prototype.ClearAnnotationMenu = function()
  3254. {
  3255. var toolbar = this.getStandaloneViewerToolbarControl();
  3256. if (toolbar)
  3257. {
  3258. var annotationButton = toolbar.getItem("addAnnotations");
  3259. if (annotationButton)
  3260. {
  3261. annotationButton.getMenu().clear();
  3262. }
  3263. }
  3264. };
  3265. /**
  3266. Removes all the menu items from the 'add Annotations' menu
  3267. */
  3268. CSubscriptionManager.prototype.ClearContextAnnotationMenu = function()
  3269. {
  3270. var contextMenu = this.getStandaloneViewerContextMenu();
  3271. if (contextMenu)
  3272. {
  3273. var commentFindAnnotationsMenu = contextMenu.getFindCommentMenuItem();
  3274. if (commentFindAnnotationsMenu)
  3275. {
  3276. commentFindAnnotationsMenu.getMenu().clear();
  3277. }
  3278. }
  3279. };
  3280. CSubscriptionManager.prototype.getStandaloneViewerToolbarControl = function()
  3281. {
  3282. if(typeof this.m_cv.rvMainWnd != "undefined" && this.m_cv.rvMainWnd != null && typeof this.m_cv.rvMainWnd.getToolbarControl == "function")
  3283. {
  3284. return this.m_cv.rvMainWnd.getToolbarControl();
  3285. }
  3286. else
  3287. {
  3288. return null;
  3289. }
  3290. };
  3291. CSubscriptionManager.prototype.getStandaloneViewerContextMenu = function()
  3292. {
  3293. if(typeof this.m_cv.rvMainWnd != "undefined" && this.m_cv.rvMainWnd != null && typeof this.m_cv.rvMainWnd.getContextMenu == "function")
  3294. {
  3295. return this.m_cv.rvMainWnd.getContextMenu();
  3296. }
  3297. else
  3298. {
  3299. return null;
  3300. }
  3301. };
  3302. /*
  3303. *+------------------------------------------------------------------------+
  3304. *| Licensed Materials - Property of IBM
  3305. *| IBM Cognos Products: Viewer
  3306. *| (C) Copyright IBM Corp. 2001, 2011
  3307. *|
  3308. *| US Government Users Restricted Rights - Use, duplication or
  3309. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  3310. *|
  3311. *+------------------------------------------------------------------------+
  3312. */
  3313. function CSelectionMetadata()
  3314. {
  3315. this.m_sContextId = "";
  3316. this.m_sDataItem = "";
  3317. this.m_sMetadataModelItem = "";
  3318. this.m_sUseValue = "";
  3319. this.m_sUseValueType = "";
  3320. this.m_sType = null;
  3321. this.m_sDisplayValue = "";
  3322. this.m_sUsage = null;
  3323. this.m_refQuery = null;
  3324. this.m_sHun = null;
  3325. this.m_sDun = null;
  3326. }
  3327. CSelectionMetadata.prototype.setContextId = function(sContextId)
  3328. {
  3329. this.m_sContextId = sContextId;
  3330. };
  3331. CSelectionMetadata.prototype.getContextId = function()
  3332. {
  3333. return this.m_sContextId;
  3334. };
  3335. CSelectionMetadata.prototype.setRefQuery = function(sRefQuery)
  3336. {
  3337. this.m_refQuery = sRefQuery;
  3338. };
  3339. CSelectionMetadata.prototype.getRefQuery = function()
  3340. {
  3341. return this.m_refQuery;
  3342. };
  3343. CSelectionMetadata.prototype.setDataItem = function(sDataItem)
  3344. {
  3345. this.m_sDataItem = sDataItem;
  3346. };
  3347. CSelectionMetadata.prototype.getDataItem = function()
  3348. {
  3349. return this.m_sDataItem;
  3350. };
  3351. CSelectionMetadata.prototype.setMetadataModelItem = function(sMetadataModelItem)
  3352. {
  3353. this.m_sMetadataModelItem = sMetadataModelItem;
  3354. };
  3355. CSelectionMetadata.prototype.getMetadataModelItem = function()
  3356. {
  3357. return this.m_sMetadataModelItem;
  3358. };
  3359. CSelectionMetadata.prototype.setUseValue = function(sUseValue)
  3360. {
  3361. this.m_sUseValue = sUseValue;
  3362. };
  3363. CSelectionMetadata.prototype.getUseValue = function()
  3364. {
  3365. return this.m_sUseValue;
  3366. };
  3367. CSelectionMetadata.prototype.setUseValueType = function(sUseValueType)
  3368. {
  3369. this.m_sUseValueType = sUseValueType;
  3370. };
  3371. CSelectionMetadata.prototype.setType = function(sType)
  3372. {
  3373. this.m_sType = sType;
  3374. };
  3375. CSelectionMetadata.prototype.getType = function()
  3376. {
  3377. var sType = null;
  3378. switch(this.m_sUseValueType)
  3379. {
  3380. case 25: // MemberUniqueName
  3381. case 27: // DimensionUniqueName
  3382. case 30: // HierarchyUniqueName
  3383. case 32: // LevelUniqueName
  3384. sType = "memberUniqueName";
  3385. break;
  3386. case 26: //MemberCaption
  3387. sType = "memberCaption";
  3388. break;
  3389. case 1: // String
  3390. case 55: //I18NExternalBuffer
  3391. case 56: //I18NExternalBuffer
  3392. sType = "string";
  3393. break;
  3394. case 2: //Int8
  3395. case 3: //UInt8
  3396. case 4: //Int16
  3397. case 5: //UInt16
  3398. case 6: //Int32
  3399. case 7: //UInt32
  3400. case 8: //Int64
  3401. case 9: //UInt64
  3402. case 10: //float
  3403. case 11: //double
  3404. case 12: //decimal
  3405. case 16: //dt interval
  3406. case 17: //ym interval
  3407. case 18: //blob
  3408. case 19: //RowIterator
  3409. case 20: //DimInterator
  3410. case 22: //Variant
  3411. case 21: //MasterDataset
  3412. case 23: //Binary
  3413. case 24: //VarBinary
  3414. case 54: //numeric
  3415. sType = parseInt(this.m_sUseValueType,10);
  3416. break;
  3417. }
  3418. return sType;
  3419. };
  3420. CSelectionMetadata.prototype.getUseValueType = function()
  3421. {
  3422. if(this.m_sType == null)
  3423. {
  3424. this.m_sType = this.getType();
  3425. }
  3426. return this.m_sType;
  3427. };
  3428. CSelectionMetadata.prototype.setDisplayValue = function(sDisplayValue)
  3429. {
  3430. this.m_sDisplayValue = sDisplayValue;
  3431. };
  3432. CSelectionMetadata.prototype.getDisplayValue = function()
  3433. {
  3434. return this.m_sDisplayValue;
  3435. };
  3436. CSelectionMetadata.prototype.setUsage = function(sUsage)
  3437. {
  3438. this.m_sUsage = sUsage;
  3439. };
  3440. CSelectionMetadata.prototype.getUsage = function()
  3441. {
  3442. if(this.m_sUsage == "2")
  3443. {
  3444. return "measure";
  3445. }
  3446. else
  3447. {
  3448. return "nonMeasure";
  3449. }
  3450. };
  3451. CSelectionMetadata.prototype.setHun = function(sHun)
  3452. {
  3453. this.m_sHun = sHun;
  3454. };
  3455. CSelectionMetadata.prototype.getHun = function()
  3456. {
  3457. return this.m_sHun;
  3458. };
  3459. CSelectionMetadata.prototype.setDun = function(sDun)
  3460. {
  3461. this.m_sDun = sDun;
  3462. };
  3463. CSelectionMetadata.prototype.getDun = function()
  3464. {
  3465. return this.m_sDun;
  3466. };
  3467. function CSelectionMetadataIterator(selectionObject, axisIndex)
  3468. {
  3469. this.m_axisIndex = axisIndex;
  3470. this.m_index = 0;
  3471. this.m_selectionObject = selectionObject;
  3472. }
  3473. CSelectionMetadataIterator.prototype.getSelectionAxis = function()
  3474. {
  3475. var selectionAxis = null;
  3476. if(typeof this.m_selectionObject == "object" && this.m_axisIndex < this.m_selectionObject.getSelectedContextIds().length)
  3477. {
  3478. selectionAxis = this.m_selectionObject.getSelectedContextIds()[this.m_axisIndex];
  3479. }
  3480. return selectionAxis;
  3481. };
  3482. CSelectionMetadataIterator.prototype.hasNext = function()
  3483. {
  3484. var selectionAxis = this.getSelectionAxis();
  3485. if(selectionAxis != null)
  3486. {
  3487. return (this.m_index < selectionAxis.length);
  3488. }
  3489. else
  3490. {
  3491. return false;
  3492. }
  3493. };
  3494. CSelectionMetadataIterator.prototype.next = function()
  3495. {
  3496. var selectionMetadata = null;
  3497. if(this.hasNext())
  3498. {
  3499. selectionMetadata = new CSelectionMetadata();
  3500. selectionMetadata.setContextId(this.m_selectionObject.m_contextIds[this.m_axisIndex][this.m_index]);
  3501. selectionMetadata.setDataItem(this.m_selectionObject.getDataItems()[this.m_axisIndex][this.m_index]);
  3502. selectionMetadata.setMetadataModelItem(this.m_selectionObject.getMetadataItems()[this.m_axisIndex][this.m_index]);
  3503. if(this.m_selectionObject.getMuns()[this.m_axisIndex][this.m_index] != null && this.m_selectionObject.getMuns()[this.m_axisIndex][this.m_index] != "")
  3504. {
  3505. selectionMetadata.setUseValue(this.m_selectionObject.getMuns()[this.m_axisIndex][this.m_index]);
  3506. selectionMetadata.setType("memberUniqueName");
  3507. }
  3508. else
  3509. {
  3510. selectionMetadata.setUseValue(this.m_selectionObject.getUseValues()[this.m_axisIndex][this.m_index]);
  3511. }
  3512. if(typeof this.m_selectionObject.m_selectionController == "object")
  3513. {
  3514. var ctxId = this.m_selectionObject.getSelectedContextIds()[this.m_axisIndex][this.m_index];
  3515. if (this.m_selectionObject.useDisplayValueFromObject) //display value can be set by DrillAction.parseDrillSpec()
  3516. {
  3517. selectionMetadata.setDisplayValue(this.m_selectionObject.getDisplayValues()[this.m_axisIndex]);
  3518. }
  3519. else
  3520. {
  3521. var tableRow = null;
  3522. var displayValue = null;
  3523. //CQ: COGCQ00655050 - if we know we're getting the display values for a row,
  3524. //then instead of searching the entire report we search the Table Row for it
  3525. //and if it exists return the display value - if not search the entire report.
  3526. if (this.m_axisIndex === 0) {
  3527. var cellRef = this.m_selectionObject.getCellRef();
  3528. if (cellRef && cellRef.nodeName && cellRef.nodeName.toLowerCase() === "td") {
  3529. displayValue = this.m_selectionObject.m_selectionController.getDisplayValueFromDOM(ctxId, cellRef.parentNode);
  3530. }
  3531. }
  3532. if (displayValue == null) {
  3533. displayValue = this.m_selectionObject.m_selectionController.getDisplayValue(ctxId);
  3534. }
  3535. if (displayValue === "") {
  3536. displayValue = this.m_selectionObject.m_selectionController.getUseValue(ctxId);
  3537. }
  3538. selectionMetadata.setDisplayValue(displayValue);
  3539. }
  3540. selectionMetadata.setUseValueType(this.m_selectionObject.m_selectionController.getDataType(ctxId));
  3541. selectionMetadata.setUsage(this.m_selectionObject.m_selectionController.getUsageInfo(ctxId));
  3542. selectionMetadata.setRefQuery(this.m_selectionObject.m_selectionController.getRefQuery(ctxId));
  3543. selectionMetadata.setHun(this.m_selectionObject.m_selectionController.getHun(ctxId));
  3544. selectionMetadata.setDun(this.m_selectionObject.m_selectionController.getDun(ctxId));
  3545. }
  3546. ++this.m_index;
  3547. }
  3548. return selectionMetadata;
  3549. };
  3550. function CAxisSelectionIterator(selectionObject)
  3551. {
  3552. this.m_index = 0;
  3553. this.m_selectionObject = selectionObject;
  3554. }
  3555. CAxisSelectionIterator.prototype.hasNext = function()
  3556. {
  3557. return ((typeof this.m_selectionObject == "object") && (this.m_index < this.m_selectionObject.getSelectedContextIds().length));
  3558. };
  3559. CAxisSelectionIterator.prototype.next = function()
  3560. {
  3561. var selectionMetadataIterator = null;
  3562. if(this.hasNext())
  3563. {
  3564. selectionMetadataIterator = new CSelectionMetadataIterator(this.m_selectionObject, this.m_index);
  3565. ++this.m_index;
  3566. }
  3567. return selectionMetadataIterator;
  3568. };
  3569. function getSelectionContextIds(selectionController)
  3570. {
  3571. var contextIds = [];
  3572. var selectedObjects = selectionController.getAllSelectedObjects();
  3573. if(selectedObjects != null && selectedObjects.length > 0)
  3574. {
  3575. for(var index = 0; index < selectedObjects.length; ++index)
  3576. {
  3577. var selectedObject = selectedObjects[index];
  3578. var selectedContextIds = selectedObject.getSelectedContextIds();
  3579. var itemArray = [];
  3580. for(var item = 0; item < selectedContextIds.length; ++item)
  3581. {
  3582. var itemIdList = selectedContextIds[item].join(":");
  3583. itemArray.push(itemIdList);
  3584. }
  3585. contextIds.push(itemArray.join("::"));
  3586. }
  3587. }
  3588. return contextIds;
  3589. }
  3590. function getViewerSelectionContext(selectionController, selectionContext, uniqueCTXIDs)
  3591. {
  3592. var selectedObjects = uniqueCTXIDs == true ? selectionController.getAllSelectedObjectsWithUniqueCTXIDs() : selectionController.getAllSelectedObjects();
  3593. if(selectedObjects != null && selectedObjects.length > 0)
  3594. {
  3595. for(var index = 0; index < selectedObjects.length; ++index)
  3596. {
  3597. var usedIds = {};
  3598. var axisSelectionIterator = new CAxisSelectionIterator(selectedObjects[index]);
  3599. if(axisSelectionIterator.hasNext())
  3600. {
  3601. var selectionMetadataIterator = axisSelectionIterator.next();
  3602. if(selectionMetadataIterator.hasNext())
  3603. {
  3604. var selectionMetadata = selectionMetadataIterator.next();
  3605. var contextId = selectionMetadata.getContextId();
  3606. usedIds[contextId] = true;
  3607. var selectedCell = selectionContext.addSelectedCell(selectionMetadata.getDataItem(), selectionMetadata.getMetadataModelItem(), selectionMetadata.getUseValue(), selectionMetadata.getUseValueType(), selectionMetadata.getDisplayValue(), selectionMetadata.getUsage(), {"queryName":selectionMetadata.getRefQuery()});
  3608. if (selectionMetadata.getHun() != null)
  3609. {
  3610. selectedCell.addProperty("HierarchyUniqueName", selectionMetadata.getHun());
  3611. }
  3612. if (selectionMetadata.getDun() != null)
  3613. {
  3614. selectedCell.addProperty("DimensionUniqueName", selectionMetadata.getDun());
  3615. }
  3616. while(selectionMetadataIterator.hasNext())
  3617. {
  3618. selectionMetadata = selectionMetadataIterator.next();
  3619. contextId = selectionMetadata.getContextId();
  3620. if(typeof usedIds[contextId] == "undefined" || contextId === "")
  3621. {
  3622. usedIds[contextId] = true;
  3623. var definingCell = selectedCell.addDefiningCell(selectionMetadata.getDataItem(), selectionMetadata.getMetadataModelItem(), selectionMetadata.getUseValue(), selectionMetadata.getUseValueType(), selectionMetadata.getDisplayValue(), selectionMetadata.getUsage(), {"queryName":selectionMetadata.getRefQuery()});
  3624. if (selectionMetadata.getHun() != null)
  3625. {
  3626. definingCell.addProperty("HierarchyUniqueName", selectionMetadata.getHun());
  3627. }
  3628. if (selectionMetadata.getDun() != null)
  3629. {
  3630. definingCell.addProperty("DimensionUniqueName", selectionMetadata.getDun());
  3631. }
  3632. }
  3633. }
  3634. while(axisSelectionIterator.hasNext())
  3635. {
  3636. selectionMetadataIterator = axisSelectionIterator.next();
  3637. var starterCell = selectedCell;
  3638. while(selectionMetadataIterator.hasNext())
  3639. {
  3640. selectionMetadata = selectionMetadataIterator.next();
  3641. contextId = selectionMetadata.getContextId();
  3642. if(typeof usedIds[contextId] == "undefined" || contextId === "")
  3643. {
  3644. usedIds[contextId] = true;
  3645. starterCell = starterCell.addDefiningCell(selectionMetadata.getDataItem(), selectionMetadata.getMetadataModelItem(), selectionMetadata.getUseValue(), selectionMetadata.getUseValueType(), selectionMetadata.getDisplayValue(), selectionMetadata.getUsage(), {"queryName":selectionMetadata.getRefQuery()});
  3646. if (selectionMetadata.getHun() != null)
  3647. {
  3648. starterCell.addProperty("HierarchyUniqueName", selectionMetadata.getHun());
  3649. }
  3650. if (selectionMetadata.getDun() != null)
  3651. {
  3652. starterCell.addProperty("DimensionUniqueName", selectionMetadata.getDun());
  3653. }
  3654. }
  3655. }
  3656. }
  3657. }
  3658. }
  3659. }
  3660. }
  3661. var sSelectionContext = selectionContext.toString();
  3662. if (window.gViewerLogger)
  3663. {
  3664. window.gViewerLogger.log('Selection context', sSelectionContext, "xml");
  3665. }
  3666. return sSelectionContext;
  3667. }
  3668. /*
  3669. *+------------------------------------------------------------------------+
  3670. *| Licensed Materials - Property of IBM
  3671. *| IBM Cognos Products: Viewer
  3672. *| (C) Copyright IBM Corp. 2001, 2013
  3673. *|
  3674. *| US Government Users Restricted Rights - Use, duplication or
  3675. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  3676. *|
  3677. *+------------------------------------------------------------------------+
  3678. */
  3679. dojo.provide("bux.dialogs.CalculationDialog");
  3680. dojo.require("bux.dialogs.BaseCustomContentDialog");
  3681. dojo.require("bux.layout.TableContainer");
  3682. dojo.require("dijit.form.NumberTextBox");
  3683. dojo.require("dijit.form.Button");
  3684. dojo.declare("viewer.dialogs.CalculationDialog", bux.dialogs.BaseCustomContentDialog, {
  3685. sTitle: null,
  3686. sLabel: null, /*String the lablel of the calculation dialog*/
  3687. sDescription: null,
  3688. sContentLocale: null,
  3689. okHandler: null, /*Function?*/
  3690. cancelHandler:null, /*Function?*/
  3691. startup: function() {
  3692. this.updateTitle(this.sTitle);
  3693. this.inherited(arguments);
  3694. var tableContainer = new bux.layout.TableContainer({
  3695. // TODO remove this class
  3696. classname: "bux-InformationDialog"
  3697. },this.contentContainer);
  3698. var cell = null, row = null;
  3699. if (this.sDescription) {
  3700. row = new bux.layout.TableContainerRow({
  3701. parentContainer: tableContainer
  3702. });
  3703. cell = new bux.layout.TableContainerCell({
  3704. classname: "bux-dialog-info",
  3705. parentContainer: row
  3706. });
  3707. cell.addContent(document.createTextNode(this.sDescription));
  3708. dijit.setWaiState(this._buxBaseDialog.domNode, "describedBy", cell.id);
  3709. }
  3710. row = new bux.layout.TableContainerRow({
  3711. parentContainer: tableContainer
  3712. });
  3713. cell = new bux.layout.TableContainerCell({
  3714. classname: "bux-dialog-label",
  3715. parentContainer: row
  3716. });
  3717. this._calculationField = new dijit.form.NumberTextBox({
  3718. required:true,
  3719. onBlur:function() {
  3720. if(!this._cancelled && !this.isValid() ) {
  3721. this.focus();
  3722. }
  3723. },
  3724. _setOKBtnDisabled : function(oButtons, bDisabled) {
  3725. //note: localized label compare (product locale)
  3726. if(oButtons && oButtons[0] && oButtons[0].label === RV_RES.IDS_JS_OK) {
  3727. oButtons[0].set("disabled", bDisabled);
  3728. }
  3729. },
  3730. isValid: function(){
  3731. //the constraints will apply locale information when doing validation
  3732. var bIsValid = this.validator(this.get("displayedValue"), this.get("constraints"));
  3733. this._setOKBtnDisabled(this.oDlgBtns, !bIsValid);
  3734. return bIsValid;
  3735. }
  3736. });
  3737. if (this.sContentLocale != null) {
  3738. dojo.requireLocalization("dojo.cldr", "number", this.sContentLocale);
  3739. this._calculationField.constraints = {
  3740. locale: this.sContentLocale
  3741. };
  3742. }
  3743. var _label = document.createElement("label");
  3744. _label.appendChild(document.createTextNode(this.sLabel));
  3745. _label.setAttribute("for", this._calculationField.id);
  3746. cell.addContent(_label);
  3747. row = new bux.layout.TableContainerRow({
  3748. parentContainer: tableContainer
  3749. });
  3750. cell = new bux.layout.TableContainerCell({
  3751. classname: "bux-dialog-field",
  3752. parentContainer: row
  3753. });
  3754. cell.addContent(this._calculationField.domNode);
  3755. this._calculationField.oDlgBtns = this._buxBaseDialog._aButtonObjects;
  3756. },
  3757. onOK : function()
  3758. {
  3759. if (this._calculationField.state != "Error")
  3760. {
  3761. this.inherited(arguments);
  3762. this.okHandler(this._calculationField.get("value"));
  3763. this.hide();
  3764. }
  3765. },
  3766. onCancel : function() {
  3767. //this flag is used to make sure that the tooltip for the numberTextBox is not set to the wrong node when
  3768. //cancelled is called
  3769. this._calculationField._cancelled = true;
  3770. this.inherited( arguments );
  3771. }
  3772. });
  3773. /*
  3774. *+------------------------------------------------------------------------+
  3775. *| Licensed Materials - Property of IBM
  3776. *| IBM Cognos Products: Viewer
  3777. *| (C) Copyright IBM Corp. 2001, 2011
  3778. *|
  3779. *| US Government Users Restricted Rights - Use, duplication or
  3780. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  3781. *|
  3782. *+------------------------------------------------------------------------+
  3783. */
  3784. dojo.provide("bux.dialogs.ConfirmationDialog");
  3785. viewer.dialogs.ConfirmationDialog = function (_title,_sMainMessage, _sDescription, sInfoIconClass, callerObject, _yesHandlerOfCallerObject) {
  3786. dojo["require"]("bux.dialogs.InformationDialog"); //@lazyload
  3787. var ConfirmDialog = new bux.dialogs.Confirm(
  3788. _title,
  3789. _sMainMessage,
  3790. _sDescription,
  3791. dojo.hitch(callerObject, _yesHandlerOfCallerObject, callerObject ),
  3792. sInfoIconClass
  3793. );
  3794. return ConfirmDialog;
  3795. };
  3796. /*
  3797. *+------------------------------------------------------------------------+
  3798. *| Licensed Materials - Property of IBM
  3799. *| IBM Cognos Products: Viewer
  3800. *| (C) Copyright IBM Corp. 2001, 2012
  3801. *|
  3802. *| US Government Users Restricted Rights - Use, duplication or
  3803. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  3804. *|
  3805. *+------------------------------------------------------------------------+
  3806. */
  3807. dojo.provide("bux.dialogs.SelectSnapshot");
  3808. dojo.require("bux.dialogs.BaseCustomContentDialog");
  3809. dojo.require("bux.layout.TableContainer");
  3810. dojo.require("dijit.form.NumberTextBox");
  3811. dojo.require("dijit.form.Button");
  3812. dojo.declare("viewer.dialogs.SelectSnapshot", bux.dialogs.BaseCustomContentDialog, {
  3813. sTitle: null,
  3814. sLabel: null, /*String the lablel of the calculation dialog*/
  3815. okHandler: null, /*Function?*/
  3816. cancelHandler:null, /*Function?*/
  3817. startup: function() {
  3818. this.updateTitle(this.sTitle);
  3819. this.inherited(arguments);
  3820. var tableContainer = new bux.layout.TableContainer({
  3821. // TODO remove this class
  3822. classname: "bux-InformationDialog"
  3823. },this.contentContainer);
  3824. var row = new bux.layout.TableContainerRow({
  3825. parentContainer: tableContainer
  3826. });
  3827. var cell = new bux.layout.TableContainerCell({
  3828. classname: "bux-dialog-label",
  3829. parentContainer: row
  3830. });
  3831. this.createSnapshotsControl();
  3832. var _label = document.createElement("label");
  3833. _label.appendChild(document.createTextNode(this.sLabel));
  3834. _label.setAttribute("for", this._snapshots.id);
  3835. cell.addContent(_label);
  3836. row = new bux.layout.TableContainerRow({
  3837. parentContainer: tableContainer
  3838. });
  3839. cell = new bux.layout.TableContainerCell({
  3840. classname: "bux-dialog-field",
  3841. parentContainer: row
  3842. });
  3843. cell.addContent(this._snapshots);
  3844. },
  3845. onOK : function()
  3846. {
  3847. this.inherited(arguments);
  3848. var selectedIndex = this._snapshots.selectedIndex;
  3849. var selectionOption = this._snapshots.options[selectedIndex];
  3850. this.okHandler(selectionOption.getAttribute("storeID"), selectionOption.value);
  3851. this.hide();
  3852. },
  3853. createSnapshotsControl : function()
  3854. {
  3855. this._snapshots = document.createElement("select");
  3856. this._snapshots.id = this.dialogId + "snapshots";
  3857. this._snapshots.setAttribute("size", "8");
  3858. this._snapshots.setAttribute("name", this.dialogId + "snapshots");
  3859. var queryResult = XMLHelper_FindChildByTagName(this.cmResponse, "result", true);
  3860. var queryItems = XMLHelper_FindChildrenByTagName(queryResult, "item", false);
  3861. for (var iIndex=0; iIndex < queryItems.length; iIndex++) {
  3862. var queryItem = queryItems[iIndex];
  3863. var sItemLabel = XMLHelper_GetText(XMLHelper_FindChildByTagName(queryItem, "creationTime_localized", true));
  3864. var storeIDNode = XMLHelper_FindChildByTagName(queryItem, "storeID", true);
  3865. var sStoreID = XMLHelper_GetText(XMLHelper_FindChildByTagName(storeIDNode, "value", true));
  3866. var creationTimeNode = XMLHelper_FindChildByTagName(queryItem, "creationTime", true);
  3867. var sCreationTime = XMLHelper_GetText(XMLHelper_FindChildByTagName(creationTimeNode, "value", true));
  3868. this._snapshots.options[iIndex] = new Option(sItemLabel, sCreationTime);
  3869. this._snapshots.options[iIndex].setAttribute("storeID", sStoreID);
  3870. if (this.currentSnapshotCreationTime == sCreationTime) {
  3871. this._snapshots.options[iIndex].selected = true;
  3872. }
  3873. }
  3874. }
  3875. });
  3876. /*
  3877. *+------------------------------------------------------------------------+
  3878. *| Licensed Materials - Property of IBM
  3879. *| IBM Cognos Products: Viewer
  3880. *| (C) Copyright IBM Corp. 2001, 2013
  3881. *|
  3882. *| US Government Users Restricted Rights - Use, duplication or
  3883. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  3884. *|
  3885. *+------------------------------------------------------------------------+
  3886. */
  3887. /**
  3888. * CognosViewerAction constructor (base class for all cognos viewer action
  3889. * @constructor
  3890. */
  3891. function CognosViewerAction()
  3892. {
  3893. this.m_oCV = null;
  3894. }
  3895. CognosViewerAction.prototype.setRequestParms = function( parms ){};
  3896. CognosViewerAction.prototype.onMouseOver = function(evt) { return false; };
  3897. CognosViewerAction.prototype.onMouseOut = function(evt) { return false; };
  3898. CognosViewerAction.prototype.onMouseDown = function(evt) { return false; };
  3899. CognosViewerAction.prototype.onClick = function(evt) { return false; };
  3900. CognosViewerAction.prototype.onDoubleClick = function(evt) { return false; };
  3901. CognosViewerAction.prototype.updateMenu = function(jsonSpec) { return jsonSpec; };
  3902. CognosViewerAction.prototype.addAdditionalOptions = function(request) {};
  3903. CognosViewerAction.prototype.genSelectionContextWithUniqueCTXIDs = function() { return false; };
  3904. CognosViewerAction.prototype.doUndo = function() {if(typeof console != "undefined") { console.log("Required method doUndo not implemented.");}};
  3905. CognosViewerAction.prototype.doRedo = function() {if(typeof console != "undefined") { console.log("Required method doRedo not implemented.");}};
  3906. CognosViewerAction.prototype.forceRunSpecRequest = function() {return false;};
  3907. /**
  3908. * Method that gets called before the action context gets built. If
  3909. * there's anything special that the action needs to do, they should
  3910. * override this method.
  3911. */
  3912. CognosViewerAction.prototype.preProcess = function() {};
  3913. /**
  3914. * Sets the cognos viewer object (called by the action factory
  3915. * @param CCognosViewer object
  3916. * @private
  3917. */
  3918. CognosViewerAction.prototype.setCognosViewer = function(oCV)
  3919. {
  3920. this.m_oCV = oCV;
  3921. };
  3922. /**
  3923. * Returns an instance to the cognos viewer object
  3924. * @return CCognosViewer object
  3925. */
  3926. CognosViewerAction.prototype.getCognosViewer = function()
  3927. {
  3928. return this.m_oCV;
  3929. };
  3930. CognosViewerAction.prototype.getUndoRedoQueue = function()
  3931. {
  3932. if (this.getCognosViewer().getViewerWidget()) {
  3933. return this.getCognosViewer().getViewerWidget().getUndoRedoQueue();
  3934. }
  3935. return null;
  3936. };
  3937. CognosViewerAction.prototype.getViewerWidget = function()
  3938. {
  3939. return this.m_oCV.getViewerWidget();
  3940. };
  3941. /**
  3942. * Returns the object display name (custom name/report name/report part name)
  3943. */
  3944. CognosViewerAction.prototype.getObjectDisplayName = function()
  3945. {
  3946. var displayName = "";
  3947. if(this.m_oCV != null)
  3948. {
  3949. if(typeof this.m_oCV.envParams["reportpart_id"] != "undefined")
  3950. {
  3951. displayName = this.m_oCV.envParams["reportpart_id"];
  3952. }
  3953. else if(typeof this.m_oCV.envParams["ui.name"] != "undefined")
  3954. {
  3955. displayName = this.m_oCV.envParams["ui.name"];
  3956. }
  3957. }
  3958. return displayName;
  3959. };
  3960. /**
  3961. * Gets the container Id
  3962. */
  3963. CognosViewerAction.prototype.getContainerId = function(selectionController) {
  3964. var container = "";
  3965. if (selectionController && selectionController.getAllSelectedObjects) {
  3966. var allSel = selectionController.getAllSelectedObjects();
  3967. if (allSel) {
  3968. var selection = allSel[0];
  3969. if (selection && selection.getLayoutElementId) {
  3970. container = this.removeNamespace(selection.getLayoutElementId());
  3971. }
  3972. }
  3973. }
  3974. return container;
  3975. };
  3976. CognosViewerAction.prototype.removeNamespace = function(value)
  3977. {
  3978. var originalValue = value;
  3979. try
  3980. {
  3981. if(value != "")
  3982. {
  3983. var idIndex = value.indexOf(this.m_oCV.getId());
  3984. if(idIndex != -1)
  3985. {
  3986. value = value.replace(this.m_oCV.getId(), "");
  3987. }
  3988. }
  3989. return value;
  3990. }
  3991. catch(e)
  3992. {
  3993. return originalValue;
  3994. }
  3995. };
  3996. CognosViewerAction.prototype.doAddActionContext = function()
  3997. {
  3998. return true;
  3999. };
  4000. CognosViewerAction.prototype.getSelectionContext = function()
  4001. {
  4002. return getViewerSelectionContext(this.m_oCV.getSelectionController(), new CSelectionContext(this.m_oCV.envParams["ui.object"]), this.genSelectionContextWithUniqueCTXIDs());
  4003. };
  4004. CognosViewerAction.prototype.getNumberOfSelections = function()
  4005. {
  4006. var numberOfSelections = -1;
  4007. if(this.m_oCV != null && this.m_oCV.getSelectionController() != null)
  4008. {
  4009. numberOfSelections = this.m_oCV.getSelectionController().getSelections().length;
  4010. }
  4011. return numberOfSelections;
  4012. };
  4013. CognosViewerAction.prototype.buildDynamicMenuItem = function(jsonSpec, actionClass)
  4014. {
  4015. jsonSpec.action = {name: "LoadMenu", payload: {action:actionClass}};
  4016. jsonSpec.items = [{ "name": "loading",
  4017. "label" : RV_RES.GOTO_LOADING,
  4018. iconClass: "loading"}];
  4019. return jsonSpec;
  4020. };
  4021. /**
  4022. * TODO - dispatcherEntry cleanup
  4023. * @param {Object} requestType
  4024. */
  4025. CognosViewerAction.prototype.createCognosViewerDispatcherEntry = function( requestType )
  4026. {
  4027. var oReq = new ViewerDispatcherEntry(this.getCognosViewer());
  4028. oReq.addFormField("ui.action", requestType);
  4029. this.preProcess();
  4030. if( this.doAddActionContext() === true )
  4031. {
  4032. var actionContext = this.addActionContext();
  4033. oReq.addFormField("cv.actionContext", actionContext);
  4034. if (window.gViewerLogger)
  4035. {
  4036. window.gViewerLogger.log('Action context', actionContext, "xml");
  4037. }
  4038. }
  4039. oReq.addFormField("ui.object", this.m_oCV.envParams["ui.object"]);
  4040. if(typeof this.m_oCV.envParams["ui.spec"] != "undefined")
  4041. {
  4042. oReq.addFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  4043. }
  4044. if(this.m_oCV.getModelPath() !== "")
  4045. {
  4046. oReq.addFormField("modelPath", this.m_oCV.getModelPath());
  4047. }
  4048. if(typeof this.m_oCV.envParams["packageBase"] != "undefined")
  4049. {
  4050. oReq.addFormField("packageBase", this.m_oCV.envParams["packageBase"]);
  4051. }
  4052. if (typeof this.m_oCV.envParams["rap.state"] != "undefined")
  4053. {
  4054. oReq.addFormField("rap.state", this.m_oCV.envParams["rap.state"]);
  4055. }
  4056. if (typeof this.m_oCV.envParams["rapReportInfo"] != "undefined")
  4057. {
  4058. oReq.addFormField("rap.reportInfo", this.m_oCV.envParams["rapReportInfo"]);
  4059. }
  4060. this.addAdditionalOptions(oReq);
  4061. return oReq;
  4062. };
  4063. CognosViewerAction.prototype.fireModifiedReportEvent = function()
  4064. {
  4065. try
  4066. {
  4067. var viewerWidget = this.getCognosViewer().getViewerWidget();
  4068. if (viewerWidget) {
  4069. var payload = {'modified':true};
  4070. viewerWidget.fireEvent("com.ibm.bux.widget.modified", null, payload);
  4071. }
  4072. } catch(e) {}
  4073. };
  4074. CognosViewerAction.prototype.showCustomCursor = function(evt, id, imageRef)
  4075. {
  4076. var customCursor = document.getElementById(id);
  4077. if(customCursor == null)
  4078. {
  4079. customCursor = document.createElement("span");
  4080. customCursor.className = "customCursor";
  4081. customCursor.setAttribute("id", id);
  4082. document.body.appendChild(customCursor);
  4083. }
  4084. var imageSrcHtml = "<img src=\"" + this.getCognosViewer().getWebContentRoot() + imageRef + "\"/>";
  4085. customCursor.innerHTML = imageSrcHtml;
  4086. customCursor.style.position = "absolute";
  4087. customCursor.style.left = (evt.clientX + 15) + "px";
  4088. customCursor.style.top = (evt.clientY + 15) + "px";
  4089. customCursor.style.display = "inline";
  4090. };
  4091. CognosViewerAction.prototype.hideCustomCursor = function(id)
  4092. {
  4093. var customCursor = document.getElementById(id);
  4094. if(customCursor != null)
  4095. {
  4096. customCursor.style.display = "none";
  4097. }
  4098. };
  4099. CognosViewerAction.prototype.selectionHasContext = function()
  4100. {
  4101. var selections = this.getCognosViewer().getSelectionController().getAllSelectedObjects();
  4102. var bContext = false;
  4103. if(selections != null && selections.length > 0)
  4104. {
  4105. for (var i=0; i < selections.length; i++)
  4106. {
  4107. if (selections[i].hasContextInformation())
  4108. {
  4109. bContext = true;
  4110. break;
  4111. }
  4112. }
  4113. }
  4114. return bContext;
  4115. };
  4116. CognosViewerAction.prototype.isInteractiveDataContainer = function(displayTypeId)
  4117. {
  4118. var result = false;
  4119. if (typeof displayTypeId != "undefined" && displayTypeId != null) {
  4120. var id = displayTypeId.toLowerCase();
  4121. result = id == 'crosstab' || id == 'list' || this.getCognosViewer().getRAPReportInfo().isChart(id);
  4122. }
  4123. return result;
  4124. };
  4125. CognosViewerAction.prototype.getSelectedContainerId = function() {
  4126. var viewer = this.getCognosViewer();
  4127. var selectionController = viewer.getSelectionController();
  4128. var containerId = null;
  4129. if( selectionController != null && typeof selectionController != "undefined") {
  4130. containerId = this.getContainerId( selectionController );
  4131. }
  4132. return containerId;
  4133. };
  4134. CognosViewerAction.prototype.getSelectedReportInfo = function() {
  4135. var viewer = this.getCognosViewer();
  4136. var containerId = this.getSelectedContainerId();
  4137. var selectedObject = this.getReportInfo(containerId);
  4138. if( selectedObject == null )
  4139. {
  4140. //if there is more than one object, we'll return null
  4141. var oRAPReportInfo = viewer.getRAPReportInfo();
  4142. if(oRAPReportInfo.getContainerCount() == 1)
  4143. {
  4144. selectedObject = oRAPReportInfo.getContainerFromPos(0);
  4145. }
  4146. }
  4147. return selectedObject;
  4148. };
  4149. CognosViewerAction.prototype.getReportInfo = function(containerId) {
  4150. var selectedObject = null;
  4151. if( containerId != null && containerId.length > 0 )
  4152. {
  4153. var viewer = this.getCognosViewer();
  4154. var oRAPReportInfo = viewer.getRAPReportInfo();
  4155. selectedObject = oRAPReportInfo.getContainer(containerId);
  4156. }
  4157. return selectedObject;
  4158. };
  4159. CognosViewerAction.prototype.isSelectionOnChart = function() {
  4160. var viewer = this.getCognosViewer();
  4161. if (viewer.getSelectionController().hasSelectedChartNodes())
  4162. {
  4163. return true;
  4164. }
  4165. var containerId = this.getContainerId( viewer.getSelectionController());
  4166. if (typeof containerId != "undefined")
  4167. {
  4168. var reportInfo = this.getReportInfo(containerId);
  4169. if (reportInfo != null && reportInfo.displayTypeId)
  4170. {
  4171. var displayTypeId = reportInfo.displayTypeId.toLowerCase();
  4172. return viewer.getRAPReportInfo().isChart(displayTypeId);
  4173. }
  4174. }
  4175. return false;
  4176. };
  4177. CognosViewerAction.prototype.ifContainsInteractiveDataContainer = function()
  4178. {
  4179. var oRAPReportInfo = this.getCognosViewer().getRAPReportInfo();
  4180. if (oRAPReportInfo) {
  4181. return oRAPReportInfo.containsInteractiveDataContainer();
  4182. }
  4183. return false;
  4184. };
  4185. /**
  4186. * Detect from report Info if the widget is a prompt control or a prompt page and only one container (the global one)
  4187. *
  4188. */
  4189. CognosViewerAction.prototype.isPromptWidget = function()
  4190. {
  4191. var oCV = this.getCognosViewer();
  4192. if (oCV.getRAPReportInfo() && oCV.getRAPReportInfo().isPromptPart()) {
  4193. return true;
  4194. }
  4195. return false;
  4196. };
  4197. CognosViewerAction.prototype.getLayoutComponents = function()
  4198. {
  4199. var layoutComponents = [];
  4200. var reportTable = document.getElementById("rt" + this.m_oCV.getId());
  4201. if(reportTable != null)
  4202. {
  4203. layoutComponents = getElementsByAttribute(reportTable, "*", "lid");
  4204. }
  4205. return layoutComponents;
  4206. };
  4207. //For applicable RAP actions, add a subset of the context/metadata table as action arguments....
  4208. CognosViewerAction.prototype.addClientContextData = function(maxValuesPerRDI)
  4209. {
  4210. var selectionController = this.m_oCV.getSelectionController();
  4211. if (typeof selectionController!="undefined" && selectionController!=null &&
  4212. typeof selectionController.getCCDManager!="undefined" && selectionController.getCCDManager()!=null) {
  4213. var oCCDManager = selectionController.getCCDManager();
  4214. return ("<md>" + xml_encode(oCCDManager.MetadataToJSON()) + "</md>" +
  4215. "<cd>" + xml_encode(oCCDManager.ContextDataSubsetToJSON(maxValuesPerRDI)) + "</cd>");
  4216. }
  4217. return "";
  4218. };
  4219. //For applicable RAP actions, add a Map of dataItem names and a count of
  4220. CognosViewerAction.prototype.getDataItemInfoMap = function()
  4221. {
  4222. var selectionController = this.m_oCV.getSelectionController();
  4223. if (typeof selectionController!="undefined" && selectionController!=null &&
  4224. typeof selectionController.getCCDManager!="undefined" && selectionController.getCCDManager()!=null) {
  4225. var oCCDManager = selectionController.getCCDManager();
  4226. return ("<di>" + xml_encode(oCCDManager.DataItemInfoToJSON()) + "</di>" );
  4227. }
  4228. return "";
  4229. };
  4230. CognosViewerAction.prototype.getRAPLayoutTag = function(cellRef)
  4231. {
  4232. var tagValue = null;
  4233. if (typeof cellRef == "object" && cellRef != null ) {
  4234. tagValue = cellRef.getAttribute("rap_layout_tag");
  4235. }
  4236. return tagValue;
  4237. };
  4238. /**
  4239. * Helper method to add the correct properties to a menuItem so it shows up 'checked'
  4240. * @param {Object} bChecked - boolean if the menuItem should be checked
  4241. * @param {Object} oMenuItem - the menuItem object
  4242. * @param {Object} sUncheckedIconClass - optional css class to use if the menuItem is unchecked
  4243. */
  4244. CognosViewerAction.prototype.addMenuItemChecked = function(bChecked, oMenuItem, sUncheckedIconClass) {
  4245. if (bChecked) {
  4246. if (this.getCognosViewer().isHighContrast()) {
  4247. oMenuItem["class"] = "menuItemSelected";
  4248. }
  4249. oMenuItem.iconClass = "menuItemChecked";
  4250. }
  4251. else if (sUncheckedIconClass && sUncheckedIconClass.length > 0) {
  4252. oMenuItem.iconClass = sUncheckedIconClass;
  4253. }
  4254. };
  4255. CognosViewerAction.prototype.gatherFilterInfoBeforeAction = function(action) {
  4256. var widget = this.getCognosViewer().getViewerWidget();
  4257. widget.filterRequiredAction = action;
  4258. widget.clearRAPCache();
  4259. widget.fireEvent("com.ibm.bux.widget.action", null, { action: 'canvas.filters' } );
  4260. };
  4261. CognosViewerAction.prototype.addClientSideUndo = function(action, aParams) {
  4262. var undoCallback = GUtil.generateCallback(action.doUndo, aParams, action);
  4263. var redoCallback = GUtil.generateCallback(action.doRedo, aParams, action);
  4264. this.getUndoRedoQueue().addClientSideUndo({"tooltip" : action.getUndoHint(), "undoCallback" : undoCallback, "redoCallback" : redoCallback});
  4265. this.getCognosViewer().getViewerWidget().updateToolbar();
  4266. };
  4267. /*
  4268. * It is client side menu item checking depending upon two things
  4269. * - area: global area or regular tab
  4270. * - report type: whether it is prompt part or not
  4271. *
  4272. * Default:
  4273. * - not valid in gloabl area
  4274. * - not valid on prompt part in regular tab
  4275. * - valid on regular report in regular tab
  4276. *
  4277. * @override
  4278. */
  4279. CognosViewerAction.prototype.isValidMenuItem = function()
  4280. {
  4281. var viewer = this.getCognosViewer();
  4282. var widget = viewer.getViewerWidget();
  4283. if (this.isPromptWidget()) {
  4284. return false; //not valid on prompt part
  4285. }
  4286. return true;
  4287. };
  4288. CognosViewerAction.prototype.isPositiveInt = function(value) {
  4289. if (typeof value === "undefined" || value === null) {
  4290. return false;
  4291. }
  4292. var paresedValue = parseInt(value, 10);
  4293. return value && paresedValue === +value && paresedValue > 0 && value.indexOf('.') == -1;
  4294. };
  4295. /**
  4296. * Builds a PUBLIC object to return error information from an action.
  4297. * DO NOT CHANGE THIS API
  4298. */
  4299. CognosViewerAction.prototype.buildActionResponseObject = function(status, code, msg) {
  4300. return {
  4301. "status" : status,
  4302. "message" : msg ? msg : null,
  4303. "code" : code ? code : null,
  4304. getStatus : function() { return this.status; },
  4305. getMessage : function() { return this.message; },
  4306. getCode : function() { return this.code; }
  4307. };
  4308. };
  4309. /**
  4310. * LineageAction - implements lineage in cognos viewer
  4311. */
  4312. function LineageAction(){}
  4313. LineageAction.prototype = new CognosViewerAction();
  4314. LineageAction.prototype.getCommonOptions = function(request)
  4315. {
  4316. request.addFormField("cv.responseFormat", "asynchDetailMIMEAttachment");
  4317. request.addFormField("bux", this.m_oCV.getViewerWidget() ? "true" : "false");
  4318. request.addFormField("cv.id", this.m_oCV.envParams["cv.id"]);
  4319. };
  4320. LineageAction.prototype.getSelectionOptions = function(request)
  4321. {
  4322. var selectionController = this.m_oCV.getSelectionController();
  4323. var contextIds = getSelectionContextIds(selectionController);
  4324. request.addFormField("context.format", "initializer");
  4325. request.addFormField("context.type", "reportService");
  4326. request.addFormField("context.selection", "metadata," + contextIds.toString());
  4327. };
  4328. LineageAction.prototype.getPrimaryRequestOptions = function(request)
  4329. {
  4330. request.addFormField("specificationType", "metadataServiceLineageSpecification");
  4331. request.addFormField("ui.action", "runLineageSpecification");
  4332. request.addFormField("ui.object", this.m_oCV.envParams["ui.object"]);
  4333. };
  4334. LineageAction.prototype.getSecondaryRequestOptions = function(request)
  4335. {
  4336. request.addFormField("ui.conversation", this.m_oCV.getConversation());
  4337. request.addFormField("m_tracking", this.m_oCV.getTracking());
  4338. request.addFormField("ui.action", "lineage");
  4339. };
  4340. LineageAction.prototype.updateMenu = function(jsonSpec)
  4341. {
  4342. if (!this.getCognosViewer().bCanUseLineage) {
  4343. return "";
  4344. }
  4345. jsonSpec.disabled = !this.selectionHasContext();
  4346. return jsonSpec;
  4347. };
  4348. /**
  4349. * Execute the lineage request
  4350. */
  4351. LineageAction.prototype.execute = function()
  4352. {
  4353. var oCV = this.getCognosViewer();
  4354. var request = new AsynchDataDispatcherEntry(oCV);
  4355. this.getCommonOptions(request);
  4356. this.getSelectionOptions(request);
  4357. if(oCV.getConversation() == "")
  4358. {
  4359. this.getPrimaryRequestOptions(request);
  4360. }
  4361. else
  4362. {
  4363. this.getSecondaryRequestOptions(request);
  4364. }
  4365. request.setCallbacks({"complete":{"object":this, "method":this.handleLineageResponse}});
  4366. if (!oCV.m_viewerFragment) {
  4367. request.setRequestIndicator(oCV.getRequestIndicator());
  4368. var workingDialog = new WorkingDialog(oCV);
  4369. workingDialog.setSimpleWorkingDialogFlag(true);
  4370. request.setWorkingDialog(workingDialog);
  4371. }
  4372. oCV.dispatchRequest(request);
  4373. };
  4374. LineageAction.prototype.handleLineageResponse = function(oResponse) {
  4375. var oCV = this.getCognosViewer();
  4376. oCV.loadExtra();
  4377. // Need to up the asynch info in the Viewer object
  4378. oCV.setStatus(oResponse.getAsynchStatus());
  4379. oCV.setConversation(oResponse.getConversation());
  4380. oCV.setTracking(oResponse.getTracking());
  4381. var config = null;
  4382. if(typeof MDSRV_CognosConfiguration != "undefined")
  4383. {
  4384. config = new MDSRV_CognosConfiguration();
  4385. var lineageURI = "";
  4386. if(this.m_oCV.envParams["metadataInformationURI"])
  4387. {
  4388. lineageURI = this.m_oCV.envParams["metadataInformationURI"];
  4389. }
  4390. config.addProperty("lineageURI", lineageURI);
  4391. config.addProperty("gatewayURI", this.m_oCV.getGateway());
  4392. }
  4393. var searchPath = this.m_oCV.envParams["ui.object"];
  4394. var sSelectionContext = getViewerSelectionContext(this.m_oCV.getSelectionController(), new CSelectionContext(searchPath));
  4395. var lineageHelper = new MDSRV_LineageFragmentContext(config, sSelectionContext);
  4396. lineageHelper.setExecutionParameters(this.m_oCV.getExecutionParameters());
  4397. if (typeof searchPath == "string")
  4398. {
  4399. lineageHelper.setReportPath( searchPath );
  4400. }
  4401. lineageHelper.setReportLineage(oResponse.getResult());
  4402. lineageHelper.open();
  4403. };
  4404. /*
  4405. *+------------------------------------------------------------------------+
  4406. *| Licensed Materials - Property of IBM
  4407. *| IBM Cognos Products: Viewer
  4408. *| (C) Copyright IBM Corp. 2001, 2014
  4409. *|
  4410. *| US Government Users Restricted Rights - Use, duplication or
  4411. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  4412. *|
  4413. *+------------------------------------------------------------------------+
  4414. */
  4415. /**
  4416. * Base class for interactive report actions
  4417. */
  4418. function ModifyReportAction() {
  4419. this.m_reuseConversation = true;
  4420. }
  4421. ModifyReportAction.prototype = new CognosViewerAction();
  4422. ModifyReportAction.prototype.addActionContextAdditionalParms = function() {};
  4423. ModifyReportAction.prototype.runReport = function() { return true; };
  4424. ModifyReportAction.prototype.updateRunReport = function() {};
  4425. ModifyReportAction.prototype.reuseQuery = function() { return false; };
  4426. ModifyReportAction.prototype.reuseGetParameter = function() {return true; };
  4427. ModifyReportAction.prototype.reuseConversation = function(reuseConversation) {
  4428. if (typeof reuseConversation != "undefined") {
  4429. this.m_reuseConversation = reuseConversation;
  4430. }
  4431. return this.m_reuseConversation;
  4432. };
  4433. ModifyReportAction.prototype.updateInfoBar = function() { return true; };
  4434. ModifyReportAction.prototype.getUndoHint = function() { return ""; };
  4435. ModifyReportAction.prototype.isUndoable = function() { return true; };
  4436. ModifyReportAction.prototype.saveSpecForUndo = function() { return false; };
  4437. ModifyReportAction.prototype.keepFocusOnWidget = function() { return true; };
  4438. ModifyReportAction.prototype.keepRAPCache = function() { return true; };
  4439. ModifyReportAction.prototype.getActionKey = function() { return null; };
  4440. ModifyReportAction.prototype.canBeQueued = function() { return false; };
  4441. ModifyReportAction.prototype.getPromptOption = function() { return "false"; };
  4442. ModifyReportAction.prototype.createActionDispatcherEntry = function()
  4443. {
  4444. var actionDispatcherEntry = new ModifyReportDispatcherEntry(this.m_oCV);
  4445. actionDispatcherEntry.initializeAction(this);
  4446. return actionDispatcherEntry;
  4447. };
  4448. ModifyReportAction.prototype.isSelectSingleMember = function(selectedObject)
  4449. {
  4450. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  4451. var dataItems = selectedObject.getDataItems();
  4452. if (oRAPReportInfo && dataItems.length > 0) {
  4453. var containerId = this.getContainerId(this.m_oCV.getSelectionController());
  4454. var itemInfo = oRAPReportInfo.getItemInfo(containerId, dataItems[0][0]);
  4455. if (itemInfo.single =="true") {
  4456. return true;
  4457. }
  4458. }
  4459. return false;
  4460. };
  4461. ModifyReportAction.prototype.execute = function() {
  4462. var oCV = this.getCognosViewer();
  4463. oCV.setKeepFocus(this.keepFocusOnWidget());
  4464. this.updateRunReport();
  4465. if (this.runReport() == true) {
  4466. var actionDispatcherEntry = this.createActionDispatcherEntry();
  4467. this.addAdditionalOptions(actionDispatcherEntry);
  4468. oCV.dispatchRequest(actionDispatcherEntry);
  4469. }
  4470. else {
  4471. var cognosViewerRequest = this.createCognosViewerDispatcherEntry( "modifyReport" );
  4472. cognosViewerRequest.setCallbacks({"complete":{"object":this, "method":this.updateReportSpecCallback}});
  4473. oCV.dispatchRequest(cognosViewerRequest);
  4474. }
  4475. this.fireModifiedReportEvent();
  4476. };
  4477. ModifyReportAction.prototype.updateReportSpecCallback = function(oAsynchDataResposne) {
  4478. var state = oAsynchDataResposne.getResponseState();
  4479. var requestHanlder = new RequestHandler(this.m_oCV);
  4480. requestHanlder.updateViewerState(state);
  4481. // we'd sometimes add 2 items into the undo stack. One from the onclick and one from
  4482. // the onblur. Make sure we only add one item to the undo stack
  4483. if (!this.m_bUndoAdded)
  4484. {
  4485. this.m_bUndoAdded = true;
  4486. var oUndoRedoQueue = this.getUndoRedoQueue();
  4487. if(oUndoRedoQueue) {
  4488. oUndoRedoQueue.initUndoObj({"tooltip" : this.getUndoHint(), "saveSpec" : true});
  4489. oUndoRedoQueue.add({"reportUpdated": true});
  4490. }
  4491. var oWidget = this.getCognosViewer().getViewerWidget();
  4492. if(oWidget) {
  4493. oWidget.updateToolbar();
  4494. }
  4495. }
  4496. };
  4497. /**
  4498. * Builds the action context needed for the modifyReport action
  4499. */
  4500. ModifyReportAction.prototype.addActionContext = function() {
  4501. var actionContext = "<reportActions";
  4502. if(this.runReport() == false)
  4503. {
  4504. actionContext += " run=\"false\"";
  4505. }
  4506. actionContext += ">";
  4507. actionContext += this.getReportActionContext();
  4508. actionContext += "</reportActions>";
  4509. return actionContext;
  4510. };
  4511. ModifyReportAction.prototype.getReportActionContext = function()
  4512. {
  4513. var cognosViewer = this.getCognosViewer();
  4514. var selectionController = cognosViewer.getSelectionController();
  4515. var actionContext = "<" + this.m_sAction + ">";
  4516. var containerId = this.getContainerId(selectionController);
  4517. if(containerId != "")
  4518. {
  4519. actionContext += "<id>" + xml_encode(containerId) + "</id>";
  4520. }
  4521. actionContext += this.getRTStateInfo();
  4522. actionContext += this.getSelectionContext();
  4523. var sAdditionalParms = this.addActionContextAdditionalParms();
  4524. if( sAdditionalParms != null && sAdditionalParms != "undefined")
  4525. {
  4526. actionContext += sAdditionalParms;
  4527. }
  4528. actionContext += "</" + this.m_sAction + ">";
  4529. if(this.updateInfoBar())
  4530. {
  4531. actionContext += this.getGetInfoActionContext();
  4532. }
  4533. return actionContext;
  4534. };
  4535. ModifyReportAction.prototype.getGetInfoActionContext = function()
  4536. {
  4537. return "<GetInfo/>";
  4538. };
  4539. /*Get widget run time information, such as dashboard object title, search path, etc*/
  4540. ModifyReportAction.prototype.getRTStateInfo = function()
  4541. {
  4542. var oWidget = this.getCognosViewer().getViewerWidget();
  4543. if(oWidget && oWidget.getBUXRTStateInfoMap){
  4544. var oInfoMap = oWidget.getBUXRTStateInfoMap();
  4545. return oInfoMap ? oInfoMap : "";
  4546. }
  4547. return "";
  4548. };
  4549. ModifyReportAction.prototype.createEmptyMenuItem = function()
  4550. {
  4551. // Temporary UI String
  4552. return { name: "None", label: "(empty)", iconClass: "", action: null, items: null };
  4553. };
  4554. ModifyReportAction.prototype.getStateFromResponse = function(oResponse)
  4555. {
  4556. var oResponseState = null;
  4557. if( oResponse && typeof oResponse != "undefined" && oResponse.responseText && typeof oResponse.responseText != "undefined" && oResponse.responseText.length > 0 )
  4558. {
  4559. var responseXML = XMLBuilderLoadXMLFromString(oResponse.responseText);
  4560. var stateData = responseXML.getElementsByTagName("state");
  4561. if (stateData != null && stateData.length > 0)
  4562. {
  4563. try {
  4564. if (typeof stateData[0].text != "undefined")
  4565. {
  4566. oResponseState = eval("(" + stateData[0].text + ")");
  4567. }
  4568. else
  4569. {
  4570. oResponseState = eval("(" + stateData[0].textContent + ")");
  4571. }
  4572. }
  4573. catch(e) {
  4574. if (typeof console != "undefined" && console && console.log) {
  4575. console.log(e);
  4576. }
  4577. }
  4578. }
  4579. }
  4580. return oResponseState;
  4581. };
  4582. ModifyReportAction.prototype.getSelectedCellTags = function()
  4583. {
  4584. var params = "";
  4585. var selectionObjects = this.getCognosViewer().getSelectionController().getSelections();
  4586. for (var i = 0; i < selectionObjects.length; ++i)
  4587. {
  4588. var cellRef = selectionObjects[i].getCellRef();
  4589. var sDataItem = selectionObjects[i].getDataItems()[0];
  4590. if (typeof sDataItem == "undefined" || sDataItem == null)
  4591. {
  4592. sDataItem = "";
  4593. }
  4594. var tag = this.getRAPLayoutTag(cellRef);
  4595. if (tag != null)
  4596. {
  4597. params += "<tag><tagValue>" + xml_encode(tag) + "</tagValue><dataItem>" + xml_encode(sDataItem) + "</dataItem></tag>";
  4598. }
  4599. else
  4600. {
  4601. params += "<tag><tagValue/><dataItem>" + xml_encode(sDataItem) + "</dataItem></tag>";
  4602. }
  4603. }
  4604. if (params != "") {
  4605. params = "<selectedCellTags>" + params + "</selectedCellTags>";
  4606. }
  4607. return params;
  4608. };
  4609. ModifyReportAction.prototype.getIsNumericFromReportInfo = function(refDataItem)
  4610. {
  4611. var containerInfo = this.getSelectedReportInfo();
  4612. if (containerInfo != null && typeof containerInfo.itemInfo!="undefined")
  4613. {
  4614. //This container has filters....does it filter this item?
  4615. for (var item = 0; item < containerInfo.itemInfo.length; ++item)
  4616. {
  4617. if (refDataItem == containerInfo.itemInfo[item].item &&
  4618. typeof containerInfo.itemInfo[item].numeric != "undefined") {
  4619. return (containerInfo.itemInfo[item].numeric == "true");
  4620. }
  4621. }
  4622. }
  4623. return false;
  4624. };
  4625. /*
  4626. *+------------------------------------------------------------------------+
  4627. *| Licensed Materials - Property of IBM
  4628. *| IBM Cognos Products: Viewer
  4629. *| (C) Copyright IBM Corp. 2001, 2011
  4630. *|
  4631. *| US Government Users Restricted Rights - Use, duplication or
  4632. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  4633. *|
  4634. *+------------------------------------------------------------------------+
  4635. */
  4636. /**
  4637. * CognosViewerCalculation constructor (base class for all calculation rules)
  4638. * @constructor
  4639. */
  4640. function CognosViewerCalculation() {
  4641. this.m_oCV = null;
  4642. }
  4643. /**
  4644. * Sets the cognos viewer object (called by the action factory
  4645. * @param CCognosViewer object
  4646. * @private
  4647. */
  4648. CognosViewerCalculation.prototype.setCognosViewer = function(oCV) {
  4649. this.m_oCV = oCV;
  4650. };
  4651. /**
  4652. * Returns an instance to the cognos viewer object
  4653. * @return CCognosViewer object
  4654. */
  4655. CognosViewerCalculation.prototype.getCognosViewer = function() {
  4656. return this.m_oCV;
  4657. };
  4658. /**
  4659. * Most calculations require only 2 selected cells
  4660. */
  4661. CognosViewerCalculation.prototype.validSelectionLength = function(selectionController) {
  4662. try {
  4663. return selectionController.getAllSelectedObjects().length > 0;
  4664. } catch (e) {
  4665. return false;
  4666. }
  4667. };
  4668. /**
  4669. * Gets the display value to show in the calculation string. If the current selection is a column title, then
  4670. * simply use the display from the selection, if not then find the defining cells display value
  4671. */
  4672. CognosViewerCalculation.prototype.getDisplayValueFromSelection = function(selection) {
  4673. var displayValue = "";
  4674. if (!selection) {
  4675. return displayValue;
  4676. }
  4677. if (selection.getLayoutType() == "columnTitle") {
  4678. displayValue = selection.getDisplayValues()[0];
  4679. } else if (selection.getLayoutType() == "datavalue") {
  4680. // only time we'd be doing a calculation and wouldn't have columnTitles selected
  4681. // is in a list, so get the column header
  4682. var viewerAction = this.m_oCV.getAction("CognosViewer");
  4683. var selectionController = this.m_oCV.getSelectionController();
  4684. var containerId = viewerAction.getContainerId(selectionController);
  4685. displayValue = selection.getDataItemDisplayValue(viewerAction.getReportInfo(containerId));
  4686. }
  4687. if (displayValue.indexOf("+") != -1 || displayValue.indexOf("-") != -1 || displayValue.indexOf("*") != -1 || displayValue.indexOf("/") != -1) {
  4688. displayValue = "(" + displayValue + ")";
  4689. }
  4690. return displayValue;
  4691. };
  4692. /**
  4693. * Need to override this method if your class uses the CognosViewerCalculation getMenuItemString method
  4694. * +, -, *, /
  4695. */
  4696. CognosViewerCalculation.prototype.getCalcSymbol = function() {};
  4697. /**
  4698. * Generates the menu item string to be displayed in the context menu. Used for simply calculations like
  4699. * +, -, *, /
  4700. */
  4701. CognosViewerCalculation.prototype.getMenuItemString = function(menuEnabled) {
  4702. var cognosViewer = this.getCognosViewer();
  4703. var selectionController = cognosViewer.getSelectionController();
  4704. var sMenuItemString = "";
  4705. var selection, index;
  4706. if (menuEnabled) {
  4707. try {
  4708. var selectionLength = selectionController.getAllSelectedObjects().length;
  4709. if (selectionLength == 1) {
  4710. selection = selectionController.getAllSelectedObjects()[0];
  4711. if(this.m_bFlipSelection) {
  4712. sMenuItemString = RV_RES.IDS_JS_CALCULATE_NUMBER + " " + this.getCalcSymbol() + " " + this.getDisplayValueFromSelection(selection);
  4713. } else {
  4714. sMenuItemString = this.getDisplayValueFromSelection(selection) + " " + this.getCalcSymbol() + " " + RV_RES.IDS_JS_CALCULATE_NUMBER;
  4715. }
  4716. } else {
  4717. if (this.m_bFlipSelection) {
  4718. selectionLength--;
  4719. for (index=selectionLength; index >= 0; index--) {
  4720. selection = selectionController.getAllSelectedObjects()[index];
  4721. if (index != selectionLength) {
  4722. sMenuItemString += " " + this.getCalcSymbol() + " ";
  4723. }
  4724. sMenuItemString += this.getDisplayValueFromSelection(selection);
  4725. }
  4726. }
  4727. else {
  4728. for (index=0; index < selectionLength; index++) {
  4729. selection = selectionController.getAllSelectedObjects()[index];
  4730. if (index > 0) {
  4731. sMenuItemString += " " + this.getCalcSymbol() + " ";
  4732. }
  4733. sMenuItemString += this.getDisplayValueFromSelection(selection);
  4734. }
  4735. }
  4736. }
  4737. } catch (e) {
  4738. sMenuItemString = this.getCalcSymbol();
  4739. }
  4740. } else {
  4741. sMenuItemString = this.getCalcSymbol();
  4742. }
  4743. return sMenuItemString;
  4744. };
  4745. /**
  4746. * Percent Difference Calculation
  4747. */
  4748. function PercentDifferenceCalculation() {}
  4749. PercentDifferenceCalculation.prototype = new CognosViewerCalculation();
  4750. PercentDifferenceCalculation.prototype.validSelectionLength = function(selectionController) {
  4751. try {
  4752. return selectionController.getAllSelectedObjects().length == 2;
  4753. } catch (e) {
  4754. return false;
  4755. }
  4756. };
  4757. /**
  4758. * Generates the menu item string to be displayed in the context menu
  4759. */
  4760. PercentDifferenceCalculation.prototype.getMenuItemString = function(menuEnabled) {
  4761. var selectionController = this.getCognosViewer().getSelectionController();
  4762. var sMenuItemString = RV_RES.IDS_JS_CALCULATE_PERCENT_DIFFERENCE;
  4763. if (menuEnabled) {
  4764. try {
  4765. var selectionLength = selectionController.getAllSelectedObjects().length;
  4766. sMenuItemString += " (";
  4767. for (var index=0; index < selectionLength; index++) {
  4768. var selection = selectionController.getAllSelectedObjects()[index];
  4769. if (index > 0) {
  4770. sMenuItemString += ", ";
  4771. }
  4772. sMenuItemString += this.getDisplayValueFromSelection(selection);
  4773. }
  4774. sMenuItemString += ")";
  4775. } catch (e) {}
  4776. }
  4777. return sMenuItemString;
  4778. };
  4779. /**
  4780. * Percent Difference Calculation
  4781. */
  4782. function PercentDifferenceCalculationSwapOrder()
  4783. {
  4784. this.m_bFlipSelection = true;
  4785. }
  4786. PercentDifferenceCalculationSwapOrder.prototype = new PercentDifferenceCalculation();
  4787. /**
  4788. * Generates the menu item string to be displayed in the context menu
  4789. */
  4790. PercentDifferenceCalculationSwapOrder.prototype.getMenuItemString = function(menuEnabled) {
  4791. var selectionController = this.getCognosViewer().getSelectionController();
  4792. var sMenuItemString = RV_RES.IDS_JS_CALCULATE_PERCENT_DIFFERENCE;
  4793. if (menuEnabled) {
  4794. try {
  4795. var selectionLength = selectionController.getAllSelectedObjects().length;
  4796. sMenuItemString += " (";
  4797. selectionLength--;
  4798. for (var index=selectionLength; index >= 0; index--) {
  4799. var selection = selectionController.getAllSelectedObjects()[index];
  4800. if (index < selectionLength) {
  4801. sMenuItemString += ", ";
  4802. }
  4803. sMenuItemString += this.getDisplayValueFromSelection(selection);
  4804. }
  4805. sMenuItemString += ")";
  4806. } catch (e) {}
  4807. }
  4808. return sMenuItemString;
  4809. };
  4810. /**
  4811. * Addition calculation
  4812. */
  4813. function AdditionCalculation() {}
  4814. AdditionCalculation.prototype = new CognosViewerCalculation();
  4815. AdditionCalculation.prototype.getCalcSymbol = function() {
  4816. return "+";
  4817. };
  4818. /**
  4819. * Subtraction calculation
  4820. */
  4821. function SubtractionCalculation() {}
  4822. SubtractionCalculation.prototype = new CognosViewerCalculation();
  4823. SubtractionCalculation.prototype.getCalcSymbol = function() {
  4824. return "-";
  4825. };
  4826. /**
  4827. * Override the validSelectionLength method since additions allows from 1 to 2 selections
  4828. */
  4829. SubtractionCalculation.prototype.validSelectionLength = function(selectionController) {
  4830. try {
  4831. var selLength = selectionController.getAllSelectedObjects().length;
  4832. return selLength > 0 && selLength < 3;
  4833. } catch (e) {
  4834. return false;
  4835. }
  4836. };
  4837. /**
  4838. * Subtraction calculation when we flip the selection order
  4839. */
  4840. function SubtractionCalculationSwapOrder()
  4841. {
  4842. this.m_bFlipSelection = true;
  4843. }
  4844. SubtractionCalculationSwapOrder.prototype = new SubtractionCalculation();
  4845. /**
  4846. * Multiplication calculation
  4847. */
  4848. function MultiplicationCalculation() {}
  4849. MultiplicationCalculation.prototype = new CognosViewerCalculation();
  4850. MultiplicationCalculation.prototype.getCalcSymbol = function() {
  4851. return "*";
  4852. };
  4853. /**
  4854. * Division Calculation
  4855. */
  4856. function DivisionCalculation() {}
  4857. DivisionCalculation.prototype = new CognosViewerCalculation();
  4858. DivisionCalculation.prototype.getCalcSymbol = function() {
  4859. return "/";
  4860. };
  4861. DivisionCalculation.prototype.validSelectionLength = function(selectionController) {
  4862. try {
  4863. var selectionLength = selectionController.getAllSelectedObjects().length;
  4864. return (selectionLength > 0 && selectionLength < 3);
  4865. } catch (e) {
  4866. return false;
  4867. }
  4868. };
  4869. /**
  4870. * Division Calculation when we swap the order of selection
  4871. */
  4872. function DivisionCalculationSwapOrder()
  4873. {
  4874. this.m_bFlipSelection = true;
  4875. }
  4876. DivisionCalculationSwapOrder.prototype = new DivisionCalculation();
  4877. /**
  4878. * Calculation Actions (Addition, Subtraction, Multiplication, Division, PercentDifference etc.)
  4879. */
  4880. function CalculationAction()
  4881. {
  4882. this.m_payload = "";
  4883. this.m_menuBuilderClass = null;
  4884. this.m_defaultName = "";
  4885. this.m_constant = null;
  4886. }
  4887. CalculationAction.prototype = new ModifyReportAction();
  4888. CalculationAction.prototype.getUndoHint = function()
  4889. {
  4890. return RV_RES.IDS_JS_CALCULATION;
  4891. };
  4892. CalculationAction.prototype.keepRAPCache = function()
  4893. {
  4894. return false;
  4895. };
  4896. /**
  4897. * Specific rules for lists:
  4898. * 1. No two selections can be on the same column.
  4899. * 2. Selections have calculation Metadata
  4900. * @return true if the current selections are valid for calculations
  4901. */
  4902. CalculationAction.prototype.listRules = function() {
  4903. var selectionController = this.getCognosViewer().getSelectionController();
  4904. var aSelectionObjects = selectionController.getSelections();
  4905. if (aSelectionObjects.length > 1)
  4906. {
  4907. var tmp = {};
  4908. for (var i = 0; i < aSelectionObjects.length; ++i)
  4909. {
  4910. var columnRef = aSelectionObjects[i].getColumnRef();
  4911. if (typeof tmp[columnRef] == "undefined")
  4912. {
  4913. tmp[columnRef] = 1;
  4914. }
  4915. else
  4916. {
  4917. return false; //duplicate found
  4918. }
  4919. }
  4920. }
  4921. return selectionController.selectionsHaveCalculationMetadata();
  4922. };
  4923. /**
  4924. * Specific rules for crosstabs
  4925. * @return true if the current selections are valid for calculations
  4926. */
  4927. CalculationAction.prototype.crosstabRules = function() {
  4928. var selectionController = this.getCognosViewer().getSelectionController();
  4929. if (!selectionController.areSelectionsColumnRowTitles()) {
  4930. return false;
  4931. }
  4932. if (selectionController.isRelational()) {
  4933. if (!this.relationalCrosstabRules(selectionController)) {
  4934. return false;
  4935. }
  4936. } else {
  4937. if (!this.olapCrosstabRules(selectionController)) {
  4938. return false;
  4939. }
  4940. }
  4941. return true;
  4942. };
  4943. /**
  4944. * Specific rules for relational data
  4945. * @return true is the selections meet all the relational crosstab specific rules for allowing calculations
  4946. */
  4947. CalculationAction.prototype.relationalCrosstabRules = function(selectionController) {
  4948. return selectionController.selectionsHaveCalculationMetadata();
  4949. };
  4950. /**
  4951. * Specific rules for OLAP data
  4952. * @return true if the selections meet all the olap specific crosstab rules for allowing calculations
  4953. */
  4954. CalculationAction.prototype.olapCrosstabRules = function(selectionController) {
  4955. if (! selectionController.selectionsHaveCalculationMetadata())
  4956. {
  4957. return false;
  4958. }
  4959. if (!this.sameDimension(selectionController))
  4960. {
  4961. // Allow calculations between measures of different measure dimensions
  4962. // Only allow members calcs if all measures
  4963. return (typeof this.m_oCV.aQoSFunctions != "undefined") && this.m_oCV.aQoSFunctions.toString().indexOf('MULTIPLE_MEASURE_DIMENSION_CALCULATIONS') != -1 && selectionController.selectionsAreMeasures();
  4964. }
  4965. else
  4966. {
  4967. if (this.sameHierarchy(selectionController))
  4968. {
  4969. return true;
  4970. }
  4971. else
  4972. {
  4973. return (typeof this.m_oCV.aQoSFunctions != "undefined") && this.m_oCV.aQoSFunctions.toString().indexOf('VALUE_EXPRESSIONS_REF_MULTIPLE_HIERARCHIES_OF_SAME_DIMENSION') != -1;
  4974. }
  4975. }
  4976. };
  4977. /**
  4978. * Checks to see if the selected cells are from the same hierarchy
  4979. * @return true if the selections are from the same hierarchy, false otherwise
  4980. */
  4981. CalculationAction.prototype.sameDimension = function(selectionController) {
  4982. try {
  4983. var dim = "";
  4984. var selLength = selectionController.getAllSelectedObjects().length;
  4985. for (var selIndex = 0; selIndex < selLength; selIndex++) {
  4986. if (dim.length == 0) {
  4987. dim = selectionController.getAllSelectedObjects()[selIndex].getDimensionalItems('dun')[0][0];
  4988. } else if (dim != selectionController.getAllSelectedObjects()[selIndex].getDimensionalItems('dun')[0][0]){
  4989. return false;
  4990. }
  4991. }
  4992. return true;
  4993. }catch (e) {
  4994. return false;
  4995. }
  4996. };
  4997. CalculationAction.prototype.sameHierarchy = function(selectionController) {
  4998. try {
  4999. var dim = "";
  5000. var selLength = selectionController.getAllSelectedObjects().length;
  5001. for (var selIndex = 0; selIndex < selLength; selIndex++) {
  5002. if (dim.length == 0) {
  5003. dim = selectionController.getAllSelectedObjects()[selIndex].getDimensionalItems('hun')[0][0];
  5004. } else if (dim != selectionController.getAllSelectedObjects()[selIndex].getDimensionalItems('hun')[0][0]){
  5005. return false;
  5006. }
  5007. }
  5008. return true;
  5009. }catch (e) {
  5010. return false;
  5011. }
  5012. };
  5013. /**
  5014. * For calculations, pass the calculation string to the RAP for generating calculation column name.
  5015. */
  5016. CalculationAction.prototype.addActionContextAdditionalParms = function()
  5017. {
  5018. var additionalContextParms = "";
  5019. if(this.m_constant != null)
  5020. {
  5021. additionalContextParms += "<constant>" + xml_encode(this.m_constant) + "</constant>";
  5022. if(this.m_swapSelectionOrder)
  5023. {
  5024. additionalContextParms += "<constantFirst/>";
  5025. }
  5026. }
  5027. if(this.m_defaultName != "")
  5028. {
  5029. additionalContextParms += "<columnName>" + xml_encode(this.m_defaultName) + "</columnName>";
  5030. }
  5031. return additionalContextParms;
  5032. };
  5033. CalculationAction.prototype.setRequestParms = function(parms)
  5034. {
  5035. if(parms != null)
  5036. {
  5037. if(typeof parms.constant != null)
  5038. {
  5039. this.m_constant = parms.constant;
  5040. }
  5041. }
  5042. };
  5043. CalculationAction.prototype.buildDefaultName = function()
  5044. {
  5045. try {
  5046. var calc = this.getCognosViewer().getCalculation(this.m_menuBuilderClass);
  5047. this.m_defaultName = calc.getMenuItemString(true);
  5048. if(this.m_constant != null)
  5049. {
  5050. var numberLabel = "" + this.m_constant;
  5051. var separator = this.getCognosViewer().envParams['contentDecimalSeparator'];
  5052. if (typeof separator != "undefined" && separator != null && separator != ".")
  5053. {
  5054. numberLabel = numberLabel.replace(".", separator);
  5055. }
  5056. this.m_defaultName = this.m_defaultName.replace(RV_RES.IDS_JS_CALCULATE_NUMBER, numberLabel);
  5057. }
  5058. } catch (e) {
  5059. this.m_defaultName = "";
  5060. }
  5061. };
  5062. CalculationAction.prototype.preProcess = function()
  5063. {
  5064. var selectionCount = this.getNumberOfSelections();
  5065. this.buildDefaultName();
  5066. if(this.m_swapSelectionOrder && selectionCount == 2)
  5067. {
  5068. var selectionController = this.getCognosViewer().getSelectionController();
  5069. var sel1 = selectionController.getAllSelectedObjects()[0];
  5070. var sel2 = selectionController.getAllSelectedObjects()[1];
  5071. selectionController.m_aSelectedObjects = [sel2, sel1];
  5072. }
  5073. };
  5074. CalculationAction.prototype.isFactCellOnCrosstabOrEmpty = function()
  5075. {
  5076. var selectionController = this.m_oCV.getSelectionController();
  5077. var selectedObjects = selectionController.getAllSelectedObjects();
  5078. if (selectedObjects != null && typeof selectedObjects != "undefined") {
  5079. if (selectedObjects.length == 0) {
  5080. return true;
  5081. } else {
  5082. var selectedObject = selectedObjects[0];
  5083. //If the select object should be disabled when the user selects a fact cell(s).
  5084. if (selectionController.getDataContainerType() == "crosstab" && selectedObject.getLayoutType() == 'datavalue')
  5085. {
  5086. return true;
  5087. }
  5088. }
  5089. }
  5090. return false;
  5091. };
  5092. CalculationAction.prototype.isSummaryOrAggregateCell = function()
  5093. {
  5094. var selectionController = this.m_oCV.getSelectionController();
  5095. var selectedObjects = selectionController.getAllSelectedObjects();
  5096. if (selectedObjects != null && typeof selectedObjects != "undefined") {
  5097. var cellRef;
  5098. var reCrosstabLevel = /\b(ol|il)\b/;
  5099. for (var i = 0; i < selectedObjects.length; i++)
  5100. {
  5101. cellRef = selectedObjects[i].getCellRef();
  5102. if (cellRef != null && typeof cellRef != "undefined") {
  5103. if (selectedObjects[i].getLayoutType() == "summary" || (cellRef != null && reCrosstabLevel.test(cellRef.className)))
  5104. {
  5105. return true;
  5106. }
  5107. }
  5108. cellRef =null;
  5109. }
  5110. }
  5111. return false;
  5112. };
  5113. CalculationAction.prototype.isLastSelectionSingleDimensionNested = function()
  5114. {
  5115. var selectionController = this.m_oCV.getSelectionController();
  5116. var selectedObjects = selectionController.getAllSelectedObjects();
  5117. if (selectedObjects != null && typeof selectedObjects != "undefined" && selectedObjects.length) {
  5118. var lastSelection = selectedObjects[selectedObjects.length - 1];
  5119. var dimItemsAxis0 = lastSelection.getDimensionalItems('dun')[0];
  5120. //If dimension of this item is same as any of its parents, its SD nested.
  5121. if (dimItemsAxis0 && dimItemsAxis0.length && dimItemsAxis0[0]) {
  5122. for(var parent=1; parent<dimItemsAxis0.length; ++parent) {
  5123. if (dimItemsAxis0[parent]===dimItemsAxis0[0]) {
  5124. return true;
  5125. }
  5126. }
  5127. }
  5128. }
  5129. return false;
  5130. };
  5131. /**
  5132. * Checks to see if all types of calculation are possible. This function
  5133. * checks general conditions of selections that apply to all types of calculation.
  5134. */
  5135. CalculationAction.prototype.areCalculationsPossible = function()
  5136. {
  5137. var selectionController = this.getCognosViewer().getSelectionController();
  5138. if(this.isFactCellOnCrosstabOrEmpty())
  5139. {
  5140. return false;
  5141. }
  5142. if(this.isSelectionOnChart())
  5143. {
  5144. return false;
  5145. }
  5146. if(this.isSummaryOrAggregateCell())
  5147. {
  5148. return false;
  5149. }
  5150. if (!selectionController.selectionsInSameDataContainer())
  5151. {
  5152. return false;
  5153. }
  5154. // different rules for lists and crosstabs
  5155. if (selectionController.getDataContainerType() == "list")
  5156. {
  5157. return this.listRules(selectionController);
  5158. }
  5159. else if (selectionController.getDataContainerType() == "crosstab" && ! this.isLastSelectionSingleDimensionNested())
  5160. {
  5161. return this.crosstabRules(selectionController);
  5162. }
  5163. return false;
  5164. };
  5165. CalculationAction.prototype.updateMenu = function(toolbarItem,updateMenucallback)
  5166. {
  5167. toolbarItem.visible = this.ifContainsInteractiveDataContainer();
  5168. if (! toolbarItem.visible)
  5169. {
  5170. return toolbarItem;
  5171. }
  5172. if (! this.areCalculationsPossible())
  5173. {
  5174. return this.toggleMenu(toolbarItem, false);
  5175. }
  5176. this.toggleMenu(toolbarItem, true);
  5177. if(this.m_oCV.aQoSFunctions) {
  5178. toolbarItem = this.buildCalculationMenuItemsAgainstSelection(toolbarItem);
  5179. } else {
  5180. toolbarItem = this.buildDynamicMenuItem(toolbarItem, "Calculation");
  5181. }
  5182. return toolbarItem;
  5183. };
  5184. CalculationAction.prototype.toggleMenu = function(toolbarItem, enabled)
  5185. {
  5186. if (enabled)
  5187. {
  5188. toolbarItem.iconClass = "calculate";
  5189. toolbarItem.disabled = false;
  5190. }
  5191. else
  5192. {
  5193. toolbarItem.iconClass = "calculateDisabled";
  5194. toolbarItem.disabled = true;
  5195. }
  5196. return toolbarItem;
  5197. };
  5198. CalculationAction.prototype.buildMenu = function(toolbarItem, buildMenuCallback)
  5199. {
  5200. toolbarItem.visible = this.ifContainsInteractiveDataContainer();
  5201. if (! toolbarItem.visible)
  5202. {
  5203. return toolbarItem;
  5204. }
  5205. if (! this.areCalculationsPossible())
  5206. {
  5207. return this.toggleMenu(toolbarItem, false);
  5208. }
  5209. this.toggleMenu(toolbarItem, true);
  5210. // check to see if we have the QoS properies, if not, go fetch them
  5211. var viewerObject = this.getCognosViewer();
  5212. if(typeof viewerObject.aQoSFunctions == "undefined")
  5213. {
  5214. // bux context menu's don't support asynch callback yet, once the fix is in to support it, we have to do this request synchrounously.
  5215. this.fetchQoS(toolbarItem, buildMenuCallback, (typeof buildMenuCallback == "undefined") ? false : true);
  5216. }
  5217. if (typeof viewerObject.aQoSFunctions != "undefined")
  5218. {
  5219. return this.buildCalculationMenuItemsAgainstSelection(toolbarItem);
  5220. }
  5221. };
  5222. CalculationAction.prototype.fetchQoS = function(toolbarItem, buildMenuCallback, asynch) {
  5223. var callbacks = {
  5224. customArguments: [toolbarItem, buildMenuCallback],
  5225. "complete": {"object": this, "method": this.handleQoSResponse}
  5226. };
  5227. var asynchRequest = new AsynchJSONDispatcherEntry(this.m_oCV);
  5228. asynchRequest.setCallbacks(callbacks);
  5229. asynchRequest.addFormField("ui.action", "getQualityOfService");
  5230. asynchRequest.addFormField("parameterValues", this.m_oCV.getExecutionParameters());
  5231. asynchRequest.addFormField("bux", "true");
  5232. asynchRequest.addNonEmptyStringFormField("modelPath", this.m_oCV.getModelPath());
  5233. asynchRequest.addDefinedFormField("metaDataModelModificationTime", this.m_oCV.envParams["metaDataModelModificationTime"]);
  5234. if (!asynch) {
  5235. asynchRequest.forceSynchronous();
  5236. }
  5237. this.m_oCV.dispatchRequest(asynchRequest);
  5238. };
  5239. CalculationAction.prototype.handleQoSResponse = function(asynchJSONResponse, toolbarItem, buildMenuCallback)
  5240. {
  5241. this.m_oCV.aQoSFunctions = asynchJSONResponse.getResult();
  5242. this.buildCalculationMenuItemsAgainstSelection(toolbarItem, buildMenuCallback);
  5243. if (typeof buildMenuCallback == "function") {
  5244. buildMenuCallback();
  5245. }
  5246. };
  5247. CalculationAction.prototype.buildCalculationMenuItemsAgainstSelection = function(toolbarItem, buildMenuCallback)
  5248. {
  5249. var aCalculations = this.m_oCV.aBuxCalculations;
  5250. var calcItems = [];
  5251. for (var calcIndex=0; calcIndex < aCalculations.length; calcIndex++)
  5252. {
  5253. var calc = this.m_oCV.getCalculation(aCalculations[calcIndex]);
  5254. // There might be some cases (GetQualityOfServer request is generated and async is forced) where this.m_oCV.aQoSFunctions is null because asynchJSONResponse.getResult() returns null (see COGCQ00261753).
  5255. // This is a highly unlikly situation and the below condition is a safty net, just in case something goes really bad.
  5256. // So, if this is the case we do not alow any calculations.
  5257. if (this.m_oCV.aQoSFunctions == null || typeof this.m_oCV.aQoSFunctions == "undefined")
  5258. {
  5259. toolbarItem.disabled = true;
  5260. toolbarItem.iconClass = "calculate";
  5261. toolbarItem.items = null;
  5262. return toolbarItem;
  5263. }
  5264. if (calc && calc.validSelectionLength(this.getCognosViewer().getSelectionController()) && this.m_oCV.aQoSFunctions.toString().indexOf(aCalculations[calcIndex]) != -1)
  5265. {
  5266. var newCalcItem = {};
  5267. newCalcItem.name = aCalculations[calcIndex];
  5268. newCalcItem.label = calc.getMenuItemString(true);
  5269. newCalcItem.action = {};
  5270. var sIconClass = "";
  5271. if (aCalculations[calcIndex].indexOf("SwapOrder") != -1)
  5272. {
  5273. sIconClass = aCalculations[calcIndex].substring(0, aCalculations[calcIndex].indexOf("SwapOrder"));
  5274. }
  5275. else
  5276. {
  5277. sIconClass = aCalculations[calcIndex];
  5278. }
  5279. newCalcItem.iconClass = sIconClass;
  5280. if(this.getNumberOfSelections() == 1)
  5281. {
  5282. newCalcItem.action.name = "ConstantOperandCalculation";
  5283. newCalcItem.action.payload = aCalculations[calcIndex];
  5284. }
  5285. else
  5286. {
  5287. newCalcItem.action.name = aCalculations[calcIndex];
  5288. newCalcItem.action.payload = "";
  5289. }
  5290. if(newCalcItem.action.name == "PercentDifferenceCalculation")
  5291. {
  5292. calcItems.push({separator: true});
  5293. }
  5294. newCalcItem.items = null;
  5295. calcItems.push(newCalcItem);
  5296. }
  5297. }
  5298. if(calcItems.length == 0)
  5299. {
  5300. this.toggleMenu(toolbarItem, false);
  5301. calcItems.push({name: "None", label: RV_RES.IDS_JS_CALCULATION_SELECT_DATA, iconClass: "", action: null, items: null });
  5302. } else {
  5303. this.toggleMenu(toolbarItem, true);
  5304. }
  5305. toolbarItem.items = calcItems;
  5306. return toolbarItem;
  5307. };
  5308. /**
  5309. * Percent Difference calculation
  5310. */
  5311. function PercentDifferenceCalculationAction(){
  5312. this.m_sAction = "PercentDifference";
  5313. this.m_menuBuilderClass = "PercentDifferenceCalculation";
  5314. }
  5315. PercentDifferenceCalculationAction.prototype = new CalculationAction();
  5316. /**
  5317. * Percent Different with reversed order of selection
  5318. */
  5319. function PercentDifferenceCalculationSwapOrderAction() {
  5320. this.m_sAction = "PercentDifference";
  5321. this.m_menuBuilderClass = "PercentDifferenceCalculationSwapOrder";
  5322. this.m_swapSelectionOrder = true;
  5323. }
  5324. PercentDifferenceCalculationSwapOrderAction.prototype = new CalculationAction();
  5325. /**
  5326. * Addition calculation
  5327. */
  5328. function AdditionCalculationAction(){
  5329. this.m_sAction = "Addition";
  5330. this.m_menuBuilderClass = "AdditionCalculation";
  5331. }
  5332. AdditionCalculationAction.prototype = new CalculationAction();
  5333. /**
  5334. * Subtraction calculation
  5335. */
  5336. function SubtractionCalculationAction(){
  5337. this.m_sAction = "Subtraction";
  5338. this.m_menuBuilderClass = "SubtractionCalculation";
  5339. }
  5340. SubtractionCalculationAction.prototype = new CalculationAction();
  5341. /**
  5342. * Subtraction calculation with reversed selection (i.e. A-B vs B-A)
  5343. */
  5344. function SubtractionCalculationSwapOrderAction() {
  5345. this.m_sAction = "Subtraction";
  5346. this.m_menuBuilderClass = "SubtractionCalculationSwapOrder";
  5347. this.m_swapSelectionOrder = true;
  5348. }
  5349. SubtractionCalculationSwapOrderAction.prototype = new CalculationAction();
  5350. /**
  5351. * Multiplication calculation
  5352. */
  5353. function MultiplicationCalculationAction(){
  5354. this.m_sAction = "Multiplication";
  5355. this.m_menuBuilderClass = "MultiplicationCalculation";
  5356. }
  5357. MultiplicationCalculationAction.prototype = new CalculationAction();
  5358. /**
  5359. * Division calculation
  5360. */
  5361. function DivisionCalculationAction(){
  5362. this.m_sAction = "Division";
  5363. this.m_menuBuilderClass = "DivisionCalculation";
  5364. }
  5365. DivisionCalculationAction.prototype = new CalculationAction();
  5366. /**
  5367. * Division calculation with reversed selection (i.e. A / B vs. B / A)
  5368. * @return
  5369. */
  5370. function DivisionCalculationSwapOrderAction() {
  5371. this.m_sAction = "Division";
  5372. this.m_menuBuilderClass = "DivisionCalculationSwapOrder";
  5373. this.m_swapSelectionOrder = true;
  5374. }
  5375. DivisionCalculationSwapOrderAction.prototype = new CalculationAction();
  5376. function ConstantOperandCalculationAction()
  5377. {
  5378. this.m_action = null;
  5379. }
  5380. ConstantOperandCalculationAction.prototype = new CognosViewerAction();
  5381. ConstantOperandCalculationAction.prototype.setRequestParms = function(payload)
  5382. {
  5383. this.m_action = payload;
  5384. };
  5385. ConstantOperandCalculationAction.prototype.execute = function()
  5386. {
  5387. var cognosViewerObjectString = getCognosViewerObjectString(this.m_oCV.getId());
  5388. var action = this.m_action;
  5389. var calculation = this.m_oCV.getCalculation(action);
  5390. var menuItemString = calculation.getMenuItemString(true);
  5391. var dialogTitle = RV_RES.IDS_JS_CALCULATE_ENTER_NUMBER_TITLE;
  5392. var dialogDescription = RV_RES.IDS_JS_CALCULATE_ENTER_NUMBER_DESCRIPTION;
  5393. dialogDescription = dialogDescription.substring(0, dialogDescription.indexOf("{0}")) + menuItemString + dialogDescription.substring(dialogDescription.indexOf("{0}") + 3);
  5394. var enterNumberLabel = RV_RES.IDS_JS_CALCULATE_ENTER_NUMBER;
  5395. var contentLocale = this.m_oCV.envParams["contentLocale"];
  5396. var calculationDialog = new viewer.dialogs.CalculationDialog({
  5397. sTitle:dialogTitle,
  5398. sLabel:enterNumberLabel,
  5399. sDescription:dialogDescription,
  5400. sContentLocale : contentLocale,
  5401. okHandler: function(value)
  5402. {
  5403. window[cognosViewerObjectString].executeAction(action, {constant:value});
  5404. },
  5405. cancelHandler: function() {}
  5406. });
  5407. calculationDialog.startup();
  5408. window.setTimeout(function () { calculationDialog.show(); },0);
  5409. };
  5410. /*
  5411. *+------------------------------------------------------------------------+
  5412. *| Licensed Materials - Property of IBM
  5413. *| IBM Cognos Products: Viewer
  5414. *| (C) Copyright IBM Corp. 2001, 2013
  5415. *|
  5416. *| US Government Users Restricted Rights - Use, duplication or
  5417. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5418. *|
  5419. *+------------------------------------------------------------------------+
  5420. */
  5421. function FilterAction() {
  5422. this.m_sAction = "Filter";
  5423. this.m_sType = "";
  5424. this.m_sItem = "";
  5425. this.m_sFormattedNumber= "";
  5426. this.m_sFormattedEndNumber= "";
  5427. this.m_jsonDetails = "";
  5428. }
  5429. FilterAction.prototype = new ModifyReportAction();
  5430. FilterAction.prototype.execute = function()
  5431. {
  5432. ModifyReportAction.prototype.execute.apply(this, arguments)
  5433. if (this.m_sType.indexOf("remove") != -1) {
  5434. this.getCognosViewer().getViewerWidget().clearRAPCache();
  5435. }
  5436. };
  5437. FilterAction.prototype.genSelectionContextWithUniqueCTXIDs = function() { return true; };
  5438. FilterAction.prototype.getUndoHint = function()
  5439. {
  5440. if (this.m_sType.indexOf("remove") != -1) {
  5441. return RV_RES.IDS_JS_REMOVE_FILTER;
  5442. } else {
  5443. return RV_RES.IDS_JS_FILTER;
  5444. }
  5445. };
  5446. FilterAction.prototype.setRequestParms = function( parms )
  5447. {
  5448. if (parms.type!=null && typeof parms.type != "undefined") {
  5449. this.m_sType = parms.type;
  5450. if (parms.id!=null && typeof parms.id != "undefined") {
  5451. this.m_sId = parms.id;
  5452. }
  5453. if (parms.item!=null && typeof parms.item != "undefined") {
  5454. this.m_sItem = parms.item;
  5455. }
  5456. if (parms.details) {
  5457. this.m_jsonDetails = parms.details;
  5458. }
  5459. if (parms.formattedNumber!=null && typeof parms.formattedNumber != "undefined") {
  5460. this.m_sFormattedNumber = parms.formattedNumber;
  5461. }
  5462. if (parms.formattedEndNumber!=null && typeof parms.formattedEndNumber != "undefined") {
  5463. this.m_sFormattedEndNumber = parms.formattedEndNumber;
  5464. }
  5465. } else {
  5466. this.m_sType = parms;
  5467. }
  5468. };
  5469. FilterAction.prototype.addActionContextAdditionalParms = function()
  5470. {
  5471. var parms = "<type>" + this.m_sType + "</type>";
  5472. if (this.m_sId != null && typeof this.m_sId != "undefined") {
  5473. parms+= ("<id>" + xml_encode(this.m_sId) + "</id>");
  5474. }
  5475. if (this.m_sItem != null && typeof this.m_sItem != "undefined" && this.m_sItem!="") {
  5476. parms+= ("<item>" + xml_encode(this.m_sItem) + "</item>");
  5477. }
  5478. if (this.m_jsonDetails && this.m_jsonDetails!="")
  5479. {
  5480. parms+= "<details>" + xml_encode(this.m_jsonDetails) + "</details>";
  5481. }
  5482. if (this.m_sFormattedNumber != null && typeof this.m_sFormattedNumber != "undefined" && this.m_sFormattedNumber!="") {
  5483. parms+= ("<formattedNumber>" + this.m_sFormattedNumber + "</formattedNumber>");
  5484. }
  5485. if (this.m_sFormattedEndNumber != null && typeof this.m_sFormattedEndNumber != "undefined" && this.m_sFormattedEndNumber!="") {
  5486. parms+= ("<formattedEndNumber>" + this.m_sFormattedEndNumber + "</formattedEndNumber>");
  5487. }
  5488. return parms;
  5489. };
  5490. FilterAction.prototype.buildSelectedItemsString = function(selectedObjects)
  5491. {
  5492. var itemsLabel = "";
  5493. var numberOfSelectedItems = selectedObjects.length;
  5494. var numberOfItemsToAdd = numberOfSelectedItems > 5 ? 5 : numberOfSelectedItems;
  5495. for(var index = 0; index < numberOfSelectedItems; ++index)
  5496. {
  5497. var value = this.getItemLabel(selectedObjects[index]);
  5498. if (typeof value == "undefined" || value == "")
  5499. {
  5500. //a selectedObject has neither displayValue nor useValue.
  5501. return "";
  5502. }
  5503. if((index) < numberOfItemsToAdd)
  5504. {
  5505. itemsLabel += value;
  5506. }
  5507. if((index+1) < numberOfItemsToAdd)
  5508. {
  5509. itemsLabel += ", ";
  5510. }
  5511. }
  5512. if(numberOfSelectedItems > 5)
  5513. {
  5514. itemsLabel += ", ++";
  5515. }
  5516. return itemsLabel;
  5517. };
  5518. FilterAction.prototype.getItemLabel = function (selectedObject)
  5519. {
  5520. var value = selectedObject.getDisplayValues()[0];
  5521. if (typeof value == "undefined")
  5522. {
  5523. value = selectedObject.getUseValues()[0][0];
  5524. }
  5525. return value;
  5526. };
  5527. FilterAction.prototype.toggleMenu = function(jsonSpec, enabled)
  5528. {
  5529. if (enabled)
  5530. {
  5531. jsonSpec.iconClass = "filter";
  5532. jsonSpec.disabled = false;
  5533. }
  5534. else
  5535. { jsonSpec.iconClass = "filterDisabled";
  5536. jsonSpec.disabled = true;
  5537. }
  5538. return jsonSpec;
  5539. };
  5540. FilterAction.prototype.updateMenu = function(jsonSpec)
  5541. {
  5542. jsonSpec.visible = (this.ifContainsInteractiveDataContainer() && !this.detailFilteringIsDisabled());
  5543. var result = jsonSpec;
  5544. if (jsonSpec.visible) {
  5545. var canAddOrRemoveFilters=(this.m_oCV.getSelectionController().getAllSelectedObjects().length > 0
  5546. || this.isSelectionFilterable() || this.isRemoveAllValid());
  5547. if (!canAddOrRemoveFilters) {
  5548. result = this.toggleMenu(jsonSpec, false);
  5549. }
  5550. else {
  5551. this.buildMenu(jsonSpec);
  5552. if (jsonSpec.disabled == true) {
  5553. result = this.toggleMenu(jsonSpec, false);
  5554. }
  5555. else {
  5556. result = this.buildDynamicMenuItem(jsonSpec, "Filter");
  5557. }
  5558. }
  5559. }
  5560. return result;
  5561. };
  5562. FilterAction.prototype.detailFilteringIsDisabled = function()
  5563. {
  5564. var oRAPReportInfo = this.getCognosViewer().getRAPReportInfo();
  5565. if (oRAPReportInfo) {
  5566. return oRAPReportInfo.isDetailFilteringDisabled();
  5567. }
  5568. return false;
  5569. };
  5570. FilterAction.prototype.buildMenu = function(jsonSpec)
  5571. {
  5572. jsonSpec.visible = (this.ifContainsInteractiveDataContainer() &&
  5573. !this.detailFilteringIsDisabled());
  5574. if (! jsonSpec.visible)
  5575. {
  5576. return jsonSpec;
  5577. }
  5578. var selectionIsFilterable=this.isSelectionFilterable();
  5579. this.toggleMenu(jsonSpec, selectionIsFilterable);
  5580. var filterItems = [];
  5581. var filterValueActionsAdded = false;
  5582. var renderedRemoveSeparator = false;
  5583. var selectionController = this.m_oCV.getSelectionController();
  5584. var selectedObjects = selectionController.getAllSelectedObjects();
  5585. if(selectedObjects.length > 0 && selectionController.selectionsInSameDataContainer() && selectionController.selectionsFromSameDataItem())
  5586. {
  5587. var refDataItem = selectedObjects[0].getDataItems()[0][0];
  5588. if (selectionIsFilterable) {
  5589. filterValueActionsAdded = this.addFilterValueActionsToMenu(selectionController, filterItems, refDataItem);
  5590. }
  5591. if (this.isRemoveItemFilterValid(refDataItem)) {
  5592. if (filterValueActionsAdded == true) {
  5593. filterItems.push({separator: true});
  5594. renderedRemoveSeparator=true;
  5595. }
  5596. var label = this.getRefDataItemLabel(refDataItem);
  5597. filterItems.push({ name: "RemoveFilterFor", label: RV_RES.IDS_JS_REMOVE_FILTER_FOR + " " + enforceTextDir(label), iconClass: "", action: { name: "Filter", payload: "remove" }, items: null });
  5598. }
  5599. }
  5600. if (this.isRemoveAllValid()==true) {
  5601. if (filterValueActionsAdded && !renderedRemoveSeparator) {
  5602. filterItems.push({separator: true});
  5603. }
  5604. filterItems.push({ name: "RemoveAllFiltersForWidget", label: RV_RES.IDS_JS_REMOVE_ALL_FILTERS_FOR_WIDGET, iconClass: "", action: { name: "Filter", payload: "removeAllForWidget" }, items: null });
  5605. }
  5606. if(filterItems.length == 0)
  5607. {
  5608. return this.toggleMenu(jsonSpec, false);
  5609. } else {
  5610. jsonSpec.items = filterItems;
  5611. this.toggleMenu(jsonSpec, true);
  5612. return jsonSpec;
  5613. }
  5614. };
  5615. FilterAction.prototype.getRefDataItemLabel = function(refDataItem)
  5616. {
  5617. var label = refDataItem;
  5618. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  5619. if (oRAPReportInfo) {
  5620. var oFilter = oRAPReportInfo.getFilterObject(refDataItem, true);
  5621. if (oFilter) {
  5622. label = oFilter.itemLabel;
  5623. }
  5624. }
  5625. return label;
  5626. };
  5627. FilterAction.prototype.addFilterValueActionsToMenu = function(selectionController, filterItems, refDataItem)
  5628. {
  5629. var selectedObjects = selectionController.getAllSelectedObjectsWithUniqueCTXIDs();
  5630. // Don't add the filter actions if the data container is a list and the list
  5631. // column header is selected
  5632. var numberOfSelectedValues = selectedObjects.length;
  5633. var sel = 0;
  5634. if (selectedObjects[0].m_dataContainerType=='list') {
  5635. for (sel=0; sel<selectedObjects.length; ++sel) {
  5636. if (selectedObjects[sel].m_sLayoutType == 'columnTitle') {
  5637. numberOfSelectedValues=0;
  5638. break;
  5639. }
  5640. }
  5641. }
  5642. if (numberOfSelectedValues == 0)
  5643. {
  5644. return false;
  5645. }
  5646. var itemsLabel = this.buildSelectedItemsString(selectedObjects);
  5647. if (itemsLabel == "")
  5648. {
  5649. if (numberOfSelectedValues == 1 && selectedObjects[0].getLayoutType() == "datavalue")
  5650. {
  5651. itemsLabel = RV_RES.IDS_JS_NULL;
  5652. filterItems.push({ name: "InFilter", label: CViewerCommon.getMessage(RV_RES.IDS_JS_FILTER_INCLUDE, itemsLabel), iconClass: "", action: { name: "Filter", payload: "in" }, items: null });
  5653. filterItems.push({ name: "NotInFilter", label: CViewerCommon.getMessage(RV_RES.IDS_JS_FILTER_EXCLUDE, itemsLabel), iconClass: "", action: { name: "Filter", payload: "not" }, items: null });
  5654. }
  5655. }
  5656. else {
  5657. if (selectionController.selectionsAreDateTime() ||
  5658. (selectionController.selectionsHaveCalculationMetadata() && !selectionController.selectionsNonMeasureWithMUN() )) {
  5659. // Don't present numeric filtering options if column titles are
  5660. // selected
  5661. for (sel=0; sel<numberOfSelectedValues; ++sel) {
  5662. if (selectedObjects[sel].m_sLayoutType == 'columnTitle') {
  5663. return false;
  5664. }
  5665. }
  5666. if(numberOfSelectedValues == 1)
  5667. {
  5668. if (selectedObjects[0].getUseValues()[0][0]) {
  5669. filterItems.push({ name: "LessFilter", label: RV_RES.IDS_JS_FILTER_LESS_THAN + " " + itemsLabel, iconClass: "", action: { name: "Filter", payload: { type:"lessThan", formattedNumber: itemsLabel }}, items: null });
  5670. filterItems.push({ name: "LessEqualFilter", label: RV_RES.IDS_JS_FILTER_LESS_THAN_EQUAL + " " + itemsLabel, iconClass: "", action: { name: "Filter", payload: { type:"lessThanEqual", formattedNumber: itemsLabel }}, items: null });
  5671. filterItems.push({ name: "GreaterEqualFilter", label: RV_RES.IDS_JS_FILTER_GREATER_THAN_EQUAL + " " + itemsLabel, iconClass: "", action: { name: "Filter", payload: { type:"greaterThanEqual", formattedNumber: itemsLabel }}, items: null });
  5672. filterItems.push({ name: "GreaterFilter", label: RV_RES.IDS_JS_FILTER_GREATER_THAN + " " + itemsLabel, iconClass: "", action: { name: "Filter", payload: { type:"greaterThan", formattedNumber: itemsLabel }}, items: null });
  5673. }
  5674. }
  5675. else if(numberOfSelectedValues == 2)
  5676. {
  5677. if (selectedObjects[0].getUseValues()[0][0] && selectedObjects[1].getUseValues()[0][0]) {
  5678. var formattedNumber = this.getItemLabel(selectedObjects[0]);
  5679. var formattedEndNumber = this.getItemLabel(selectedObjects[1]);
  5680. filterItems.push({ name: "BetweenFilter", label: CViewerCommon.getMessage(RV_RES.IDS_JS_FILTER_BETWEEN, [formattedNumber, formattedEndNumber]), iconClass: "", action: { name: "Filter", payload: {type: "between", formattedNumber: formattedNumber, formattedEndNumber: formattedEndNumber}}, items: null });
  5681. filterItems.push({ name: "NotBetweenFilter", label: CViewerCommon.getMessage(RV_RES.IDS_JS_FILTER_NOT_BETWEEN, [formattedNumber, formattedEndNumber]), iconClass: "", action: { name: "Filter", payload: {type: "notBetween", formattedNumber: formattedNumber, formattedEndNumber: formattedEndNumber }}, items: null });
  5682. }
  5683. }
  5684. else
  5685. {
  5686. return false;
  5687. }
  5688. }
  5689. else
  5690. {
  5691. var containerType = selectionController.getDataContainerType();
  5692. if (containerType == "crosstab" && selectedObjects[0].getLayoutType() == 'columnTitle') {
  5693. if (this.isSelectSingleMember(selectedObjects[0])==true) {
  5694. return false;
  5695. }
  5696. }
  5697. filterItems.push({ name: "InFilter", label: CViewerCommon.getMessage(RV_RES.IDS_JS_FILTER_INCLUDE, enforceTextDir(itemsLabel)), iconClass: "", action: { name: "Filter", payload: "in" }, items: null });
  5698. filterItems.push({ name: "NotInFilter", label: CViewerCommon.getMessage(RV_RES.IDS_JS_FILTER_EXCLUDE, enforceTextDir(itemsLabel)), iconClass: "", action: { name: "Filter", payload: "not" }, items: null });
  5699. }
  5700. }
  5701. return true;
  5702. };
  5703. FilterAction.prototype.isRemoveAllValid = function()
  5704. {
  5705. // If the reportInfo has any filters for any container, remove all is valid.
  5706. var reportInfo = this.m_oCV.getRAPReportInfo();
  5707. if(reportInfo) {
  5708. return reportInfo.containsFilters();
  5709. }
  5710. return false;
  5711. };
  5712. FilterAction.prototype.isRemoveItemFilterValid = function(refDataItem)
  5713. {
  5714. var containerId = this.getContainerId(this.m_oCV.getSelectionController());
  5715. var reportInfo = this.m_oCV.getRAPReportInfo();
  5716. if(containerId != null && reportInfo)
  5717. {
  5718. var oFilter = reportInfo.getFilterObjectFromContainer(containerId, refDataItem, false);
  5719. return oFilter ? true : false;
  5720. }
  5721. return false;
  5722. };
  5723. FilterAction.prototype.isSelectionFilterable = function() {
  5724. var selectionController = this.m_oCV.getSelectionController();
  5725. var selectedObjects = selectionController.getAllSelectedObjects();
  5726. if (selectedObjects.length > 0) {
  5727. var cellRef = selectedObjects[0].getCellRef();
  5728. if (cellRef && cellRef.getAttribute && cellRef.getAttribute("no_data_item_column") === "true") {
  5729. return false;
  5730. }
  5731. if (selectionController.hasSelectedChartNodes()) {
  5732. //CHARTS: Selections are not filterable if:
  5733. // 1) Any title is selected (eg legendTitle, numericAxisTitle, ordinalAxisTitle)
  5734. // 2) A calc/measure that is on an edge is selected (eg. legendLabel, ordinalAxisLabel)
  5735. var measureOrCalculationType=false;
  5736. if (selectionController.selectionsAreDateTime() ||
  5737. (selectionController.selectionsHaveCalculationMetadata() && !selectionController.selectionsNonMeasureWithMUN() )) {
  5738. measureOrCalculationType=true;
  5739. }
  5740. for (var sel=0; sel<selectedObjects.length; ++sel) {
  5741. if (selectedObjects[sel].getLayoutType()) {
  5742. if (selectedObjects[sel].getLayoutType().match('Title$')=='Title') {
  5743. return false;
  5744. }
  5745. if (measureOrCalculationType && selectedObjects[sel].getLayoutType().match('Label$')=='Label') {
  5746. return false;
  5747. }
  5748. }
  5749. }
  5750. }
  5751. }
  5752. return true;
  5753. };
  5754. function GetFilterInfoAction()
  5755. {
  5756. this.m_requestParms = null;
  5757. }
  5758. GetFilterInfoAction.prototype = new ModifyReportAction();
  5759. GetFilterInfoAction.prototype.isUndoable = function()
  5760. {
  5761. return false;
  5762. };
  5763. GetFilterInfoAction.prototype.canBeQueued = function()
  5764. {
  5765. return true;
  5766. };
  5767. GetFilterInfoAction.prototype.setRequestParms = function( parms )
  5768. {
  5769. this.m_requestParms = parms;
  5770. };
  5771. GetFilterInfoAction.prototype.runReport = function()
  5772. {
  5773. return false;
  5774. };
  5775. GetFilterInfoAction.prototype.updateInfoBar = function()
  5776. {
  5777. return false;
  5778. };
  5779. GetFilterInfoAction.prototype.fireModifiedReportEvent = function()
  5780. {
  5781. // do nothing
  5782. };
  5783. GetFilterInfoAction.prototype.buildActionContextAdditionalParmsXML = function()
  5784. {
  5785. var itemDoc = XMLBuilderCreateXMLDocument("item");
  5786. var itemElement = itemDoc.documentElement;
  5787. for( var parm in this.m_requestParms )
  5788. {
  5789. if( this.m_requestParms.hasOwnProperty( parm ) )
  5790. {
  5791. var parameterElement = itemDoc.createElement( parm );
  5792. parameterElement.appendChild( itemDoc.createTextNode( this.m_requestParms[parm]));
  5793. itemElement.appendChild( parameterElement );
  5794. }
  5795. }
  5796. return itemDoc;
  5797. };
  5798. GetFilterInfoAction.prototype.addActionContextAdditionalParms = function()
  5799. {
  5800. if( this.m_requestParms === null )
  5801. {
  5802. return "";
  5803. }
  5804. return XMLBuilderSerializeNode( this.buildActionContextAdditionalParmsXML() );
  5805. };
  5806. GetFilterInfoAction.prototype.createFilterInfoDispatcherEntry = function()
  5807. {
  5808. var filterInfoDispatcherEntry = new ReportInfoDispatcherEntry(this.m_oCV);
  5809. filterInfoDispatcherEntry.initializeAction(this);
  5810. return filterInfoDispatcherEntry;
  5811. };
  5812. GetFilterInfoAction.prototype.execute = function() {
  5813. this.getCognosViewer().setKeepFocus(this.keepFocusOnWidget());
  5814. var filterInfoDispatcherEntry = this.createFilterInfoDispatcherEntry();
  5815. this.m_oCV.dispatchRequest(filterInfoDispatcherEntry);
  5816. this.fireModifiedReportEvent();
  5817. };
  5818. GetFilterInfoAction.prototype.getOnPromptingCallback = function(){
  5819. return this.getOnCompleteCallback();
  5820. };
  5821. function GetFilterValuesAction()
  5822. {
  5823. this.m_sAction = 'CollectFilterValues';
  5824. this.m_sRetryClass = 'GetFilterValues';
  5825. }
  5826. GetFilterValuesAction.prototype = new GetFilterInfoAction();
  5827. GetFilterValuesAction.prototype.addActionContextAdditionalParms = function()
  5828. {
  5829. if( this.m_requestParms === null )
  5830. {
  5831. return "";
  5832. }
  5833. var itemDoc = this.buildActionContextAdditionalParmsXML();
  5834. var itemElement = itemDoc.documentElement;
  5835. for( var parm in this.m_requestParms ) {
  5836. if (parm == "name") {
  5837. // If we can find a min and max, send it....
  5838. var selectionController = this.m_oCV.getSelectionController();
  5839. if (typeof selectionController != "undefined" &&
  5840. typeof selectionController.getCCDManager() != "undefined") {
  5841. var minMax = selectionController.getCCDManager().GetPageMinMaxForRDI(this.m_requestParms[parm]);
  5842. if (typeof minMax != "undefined") {
  5843. var pageMinElement = itemDoc.createElement( "pageMin" );
  5844. pageMinElement.appendChild( itemDoc.createTextNode( minMax.pageMin ) );
  5845. var pageMaxElement = itemDoc.createElement( "pageMax" );
  5846. pageMaxElement.appendChild( itemDoc.createTextNode( minMax.pageMax ) );
  5847. itemElement.appendChild(pageMinElement);
  5848. itemElement.appendChild(pageMaxElement);
  5849. }
  5850. if (this.m_oCV.isSinglePageReport() == true) {
  5851. var singlePage = itemDoc.createElement("singlePageReport");
  5852. itemElement.appendChild(singlePage);
  5853. }
  5854. }
  5855. break;
  5856. }
  5857. }
  5858. var additionalParms = XMLBuilderSerializeNode( itemDoc );
  5859. return (additionalParms + this.addClientContextData(/*maxValuesPerRDI*/3));
  5860. };
  5861. GetFilterValuesAction.prototype.getOnCompleteCallback = function()
  5862. {
  5863. var viewer = this.getCognosViewer();
  5864. var viewerWidget = viewer.getViewerWidget();
  5865. var params = this.m_requestParms;
  5866. var callback = function(response) {
  5867. viewerWidget.handleGetFilterValuesResponse(response, params);
  5868. };
  5869. return callback;
  5870. };
  5871. GetFilterValuesAction.prototype.canBeQueued = function() { return true; };
  5872. GetFilterValuesAction.prototype.getActionKey = function()
  5873. {
  5874. if (typeof this.m_requestParms != "undefined" &&
  5875. typeof this.m_requestParms.source != "undefined") {
  5876. return this.m_sAction+this.m_requestParms.source;
  5877. }
  5878. return null;
  5879. };
  5880. function GetFilterableItemsAction()
  5881. {
  5882. this.m_sAction = 'CollectFilterableItems';
  5883. }
  5884. GetFilterableItemsAction.prototype = new GetFilterInfoAction();
  5885. GetFilterableItemsAction.prototype.addActionContextAdditionalParms = function()
  5886. {
  5887. return this.addClientContextData(/*maxValuesPerRDI*/3);
  5888. };
  5889. GetFilterableItemsAction.prototype.getOnCompleteCallback = function()
  5890. {
  5891. var viewer = this.getCognosViewer();
  5892. var viewerWidget = viewer.getViewerWidget();
  5893. var callback = function(response) {
  5894. viewerWidget.handleGetFilterableItemsResponse(response);
  5895. };
  5896. return callback;
  5897. };
  5898. function UpdateDataFilterAction()
  5899. {
  5900. this.m_sAction = "UpdateDataFilter";
  5901. this.m_bForceRunSpec = false;
  5902. }
  5903. UpdateDataFilterAction.prototype = new ModifyReportAction();
  5904. UpdateDataFilterAction.prototype.runReport = function() {
  5905. return this.getViewerWidget().shouldReportBeRunOnAction();
  5906. };
  5907. UpdateDataFilterAction.prototype.getActionKey = function()
  5908. {
  5909. if (typeof this.m_requestParams != "undefined") {
  5910. try
  5911. {
  5912. var parms = eval("(" + this.m_requestParams + ")");
  5913. if (parms.clientId !== null) {
  5914. return this.m_sAction + parms.clientId;
  5915. }
  5916. }
  5917. catch (e)
  5918. {
  5919. // If eval fails for any reason, return a null actionKey.
  5920. }
  5921. }
  5922. return null;
  5923. };
  5924. UpdateDataFilterAction.prototype.canBeQueued = function()
  5925. {
  5926. return true;
  5927. };
  5928. UpdateDataFilterAction.prototype.keepFocusOnWidget = function()
  5929. {
  5930. return false;
  5931. };
  5932. UpdateDataFilterAction.prototype.isUndoable = function()
  5933. {
  5934. return false;
  5935. };
  5936. UpdateDataFilterAction.prototype.setRequestParms = function( parms )
  5937. {
  5938. this.m_requestParams = parms.filterPayload;
  5939. this.m_drillResetHUN = parms.drillResetHUN;
  5940. this.m_isFacet = parms.isFacet;
  5941. if (parms.forceCleanup) {
  5942. this.m_sForceCleanup = parms.forceCleanup;
  5943. }
  5944. };
  5945. UpdateDataFilterAction.prototype.forceRunSpecRequest = function() {
  5946. return this.m_bForceRunSpec;
  5947. };
  5948. UpdateDataFilterAction.prototype.preProcessContextValues = function() {
  5949. var resultingProcessedRequestParamsValues = [];
  5950. var requestParamsObject = dojo.fromJson(this.m_requestParams);
  5951. if(requestParamsObject && requestParamsObject["com.ibm.widget.context"] && (requestParamsObject["com.ibm.widget.context"]["values"] || requestParamsObject["com.ibm.widget.context"]["ranges"]) ) {
  5952. var oRAPReportInfo = this.m_oCV.m_RAPReportInfo;
  5953. var reportContainers = oRAPReportInfo.getContainers();
  5954. if(!reportContainers) {
  5955. resultingProcessedRequestParamsValues;
  5956. }
  5957. // strip out data items which we don't care about (aren't part report info)
  5958. var key = "";
  5959. var contextObject = "";
  5960. if(requestParamsObject["com.ibm.widget.context"]["values"]) {
  5961. key = "values";
  5962. contextObject = requestParamsObject["com.ibm.widget.context"]["values"];
  5963. } else {
  5964. key = "ranges";
  5965. contextObject = requestParamsObject["com.ibm.widget.context"]["ranges"];
  5966. }
  5967. var existingSliderInfo = oRAPReportInfo.collectSliderSetFromReportInfo();
  5968. for(dataItem in contextObject) {
  5969. if (oRAPReportInfo && oRAPReportInfo.isReferenced(dataItem)) {
  5970. var clonedRequestParam = dojo.clone(requestParamsObject);
  5971. var newValues = {};
  5972. newValues[dataItem] = requestParamsObject["com.ibm.widget.context"][key][dataItem];
  5973. clonedRequestParam["com.ibm.widget.context"][key] = newValues;
  5974. if(requestParamsObject["com.ibm.widget.context.bux.selectValueControl"] && requestParamsObject["com.ibm.widget.context.bux.selectValueControl"]["selectValueControl"] && requestParamsObject["com.ibm.widget.context.bux.selectValueControl"]["selectValueControl"]["itemSpecification"]) {
  5975. var newSpecification = {};
  5976. clonedRequestParam["com.ibm.widget.context.bux.selectValueControl"]["selectValueControl"]["itemSpecification"] = {};
  5977. var packageBase = document.forms["formWarpRequest" + this.m_oCV.getId()].packageBase.value;
  5978. for(modelItem in requestParamsObject["com.ibm.widget.context.bux.selectValueControl"]["selectValueControl"]["itemSpecification"]) {
  5979. if(modelItem.indexOf(packageBase) != -1) {
  5980. newSpecification[dataItem] = requestParamsObject["com.ibm.widget.context.bux.selectValueControl"]["selectValueControl"]["itemSpecification"][modelItem][dataItem];
  5981. if (newSpecification[dataItem]) {
  5982. clonedRequestParam["com.ibm.widget.context.bux.selectValueControl"]["selectValueControl"]["itemSpecification"][modelItem] = newSpecification;
  5983. break;
  5984. }
  5985. }
  5986. }
  5987. }
  5988. var itemCount = contextObject[dataItem] && key !== "ranges" ? contextObject[dataItem].length : 0;
  5989. if (this.checkIfFilterExpressionChanged(dataItem, requestParamsObject.clientId, itemCount, existingSliderInfo)) {
  5990. this.m_bForceRunSpec = true;
  5991. }
  5992. resultingProcessedRequestParamsValues.push(dojo.toJson(clonedRequestParam));
  5993. }
  5994. }
  5995. } else {
  5996. resultingProcessedRequestParamsValues.push(dojo.toJson(requestParamsObject));
  5997. }
  5998. return resultingProcessedRequestParamsValues;
  5999. };
  6000. /**
  6001. * Returns true if this is a new filter or if the filterExpression in the reportSpec will
  6002. * change because of this updateDataFilter action. It'll change if the slider/select value
  6003. * was re-configured on a different data item or if we're going from one item to multiple items
  6004. */
  6005. UpdateDataFilterAction.prototype.checkIfFilterExpressionChanged = function(dataItem, sliderId, itemCount, existingSliderInfo) {
  6006. if (!existingSliderInfo || !existingSliderInfo[sliderId] || existingSliderInfo[sliderId].name != dataItem) {
  6007. return true;
  6008. }
  6009. var existingItemCount = existingSliderInfo[sliderId].values ? existingSliderInfo[sliderId].values.length : 0;
  6010. if (itemCount == existingItemCount) {
  6011. return false;
  6012. }
  6013. // If we've gone from 1 value to multiple or from multiple to 1 then we need to do a runSpec
  6014. return (itemCount === 1) !== (existingItemCount === 1);
  6015. };
  6016. UpdateDataFilterAction.prototype.addActionContext = function()
  6017. {
  6018. var actionContext = "<reportActions";
  6019. var inlineValues = "";
  6020. if(!this.runReport()) {
  6021. actionContext += " run=\"false\"";
  6022. inlineValues = "<inlineValues/>";
  6023. }
  6024. actionContext += ">";
  6025. if( this.m_drillResetHUN && this.m_drillResetHUN.length > 0 ) {
  6026. actionContext += this._getDrillResetActionContext();
  6027. }
  6028. if(this.m_sForceCleanup) {
  6029. actionContext += "<reportAction name=\"" + this.m_sAction + "\">" + dojo.toJson(this.m_sForceCleanup) + "</reportAction>";
  6030. }
  6031. var processedRequestParamValues;
  6032. var isXMLFilterPayload = (this.m_requestParams.charAt(0)==="<");
  6033. if ( this.m_isFacet || isXMLFilterPayload) {
  6034. processedRequestParamValues = [ this.m_requestParams ];
  6035. } else {
  6036. processedRequestParamValues = this.preProcessContextValues();
  6037. }
  6038. for(var idx = 0; idx < processedRequestParamValues.length; ++idx) {
  6039. var actionParams = processedRequestParamValues[idx];
  6040. actionContext += "<reportAction name=\"" + this.m_sAction + "\">" + inlineValues;
  6041. actionContext += (isXMLFilterPayload) ? actionParams : xml_encode(actionParams);
  6042. if(idx > 0) {
  6043. actionContext += "<augment>true</augment>";
  6044. }
  6045. if (!this.m_isFacet) {
  6046. actionContext += this.addClientContextData(/*maxValuesPerRDI*/3);
  6047. }
  6048. actionContext += "</reportAction>";
  6049. actionContext += "<reportAction name=\"GetInfo\"><include><sliders/></include>";
  6050. actionContext += "</reportAction>";
  6051. }
  6052. actionContext += "</reportActions>";
  6053. return actionContext;
  6054. };
  6055. UpdateDataFilterAction.prototype._getDrillResetActionContext = function()
  6056. {
  6057. var drillResetAction = new DrillResetAction();
  6058. drillResetAction.setCognosViewer( this.getCognosViewer() );
  6059. var params = { drilledResetHUNs : this.m_drillResetHUN };
  6060. drillResetAction.setRequestParms( params );
  6061. drillResetAction.setUpdateInfoBar( false );
  6062. var drillResetActionContext = drillResetAction.getReportActionContext();
  6063. return drillResetActionContext;
  6064. };
  6065. /*
  6066. *+------------------------------------------------------------------------+
  6067. *| Licensed Materials - Property of IBM
  6068. *| IBM Cognos Products: Viewer
  6069. *| (C) Copyright IBM Corp. 2001, 2013
  6070. *|
  6071. *| US Government Users Restricted Rights - Use, duplication or
  6072. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6073. *|
  6074. *+------------------------------------------------------------------------+
  6075. */
  6076. function CognosViewerSort( event, oCV ) {
  6077. this.m_oCV = oCV;
  6078. if( event )
  6079. {
  6080. this.m_oEvent = event;
  6081. this.m_oNode = getCrossBrowserNode(event, true);
  6082. }
  6083. }
  6084. CognosViewerSort.prototype.setNode = function( node )
  6085. {
  6086. this.m_oNode = node;
  6087. };
  6088. CognosViewerSort.prototype.getNode = function()
  6089. {
  6090. return this.m_oNode;
  6091. };
  6092. /*
  6093. * Checks to see if this is a sort action
  6094. */
  6095. CognosViewerSort.prototype.isSort = function() {
  6096. if(this.m_oNode && this.m_oNode.nodeName == 'IMG' && (this.m_oNode.id).indexOf('sortimg') >= 0 )
  6097. {
  6098. return true;
  6099. }
  6100. else
  6101. {
  6102. return false;
  6103. }
  6104. };
  6105. CognosViewerSort.prototype.execute = function() {
  6106. var selectionController = getCognosViewerSCObjectRef(this.m_oCV.getId());
  6107. selectionController.selectSingleDomNode(this.m_oNode.parentNode);
  6108. var sortAction = this.getSortAction();
  6109. sortAction.setCognosViewer(this.m_oCV);
  6110. sortAction.execute();
  6111. if (window.gViewerLogger) {
  6112. window.gViewerLogger.addContextInfo(selectionController);
  6113. }
  6114. };
  6115. /*
  6116. * The order of sort is ascending, descending and none.
  6117. * Figure out what the current sort should be based on previous sort order.
  6118. * Eg. if previous sort order is ascending, then next sort order should be descending.
  6119. */
  6120. CognosViewerSort.prototype.getSortAction = function() {
  6121. var sortAction = this.m_oCV.getAction("Sort");
  6122. var sortOrder = this.m_oNode.getAttribute( 'sortOrder' );
  6123. if( sortOrder.indexOf('nosort') != -1 )
  6124. {
  6125. sortAction.setRequestParms({order:"ascending", type:"value"});
  6126. }
  6127. else if ( sortOrder.indexOf('ascending') != -1 )
  6128. {
  6129. sortAction.setRequestParms({order:"descending", type:"value"});
  6130. }
  6131. else if( sortOrder.indexOf('descending') != -1)
  6132. {
  6133. sortAction.setRequestParms({order:"none", type:"value"});
  6134. }
  6135. return sortAction;
  6136. };
  6137. function SortAction()
  6138. {
  6139. this.m_sAction = "Sort";
  6140. this.m_sortOrder = "none";
  6141. this.m_sortType = "";
  6142. this.m_sItem = "";
  6143. this.m_sId="";
  6144. }
  6145. SortAction.prototype = new ModifyReportAction();
  6146. SortAction.prototype.doExecute = function() {
  6147. //Abort execute iff existing sort is none and new sort is none
  6148. if (this.m_sortOrder === "none") {
  6149. //Allow the execute if there is no container - i.e. no field is selected.
  6150. //This occurs when the user cancels a sort from the infobar.
  6151. if (this.getContainerId(this.m_oCV.getSelectionController())) {
  6152. var currentSort = this.getCurrentSortFromSelection();
  6153. if (this.m_sortType === "value" && currentSort.indexOf("sortByValue") === -1) {
  6154. return false;
  6155. } else if (this.m_sortType === "label" && currentSort.indexOf("sortByLabel") === -1) {
  6156. return false;
  6157. }
  6158. }
  6159. }
  6160. return true;
  6161. };
  6162. SortAction.prototype.execute = function() {
  6163. if(this.doExecute()) {
  6164. ModifyReportAction.prototype.execute.call(this);
  6165. }
  6166. };
  6167. SortAction.prototype.getUndoHint = function()
  6168. {
  6169. if (this.m_sortOrder == "none") {
  6170. return RV_RES.IDS_JS_DONT_SORT;
  6171. }
  6172. else {
  6173. return RV_RES.IDS_JS_SORT;
  6174. }
  6175. };
  6176. SortAction.prototype.setRequestParms = function(payload)
  6177. {
  6178. this.m_sortOrder = payload.order;
  6179. this.m_sortType = payload.type;
  6180. if (payload.id!=null && typeof payload.id != "undefined") {
  6181. this.m_sId = payload.id;
  6182. }
  6183. if (payload.item!=null && typeof payload.item != "undefined") {
  6184. this.m_sItem = payload.item;
  6185. }
  6186. };
  6187. SortAction.prototype.addActionContextAdditionalParms = function()
  6188. {
  6189. var selectionController = this.m_oCV.getSelectionController();
  6190. var parms = "<order>" + this.m_sortOrder + "</order>";
  6191. if(this.m_sortType == "label")
  6192. {
  6193. parms += "<byLabel/>";
  6194. }
  6195. if (this.getContainerId(selectionController)=="" && this.m_sId != null && typeof this.m_sId != "undefined" && this.m_sId != "") {
  6196. parms+= ("<id>" + xml_encode(this.m_sId) + "</id>");
  6197. }
  6198. if (this.m_sItem != null && typeof this.m_sItem != "undefined" && this.m_sItem!="") {
  6199. parms+= ("<item>" + xml_encode(this.m_sItem) + "</item>");
  6200. }
  6201. parms += this.addClientContextData(/*maxValuesPerRDI*/3);
  6202. parms += this.getSelectedCellTags();
  6203. return parms;
  6204. };
  6205. SortAction.prototype.toggleMenu = function(jsonSpec, enabled)
  6206. {
  6207. if (enabled)
  6208. {
  6209. jsonSpec.iconClass = "sort";
  6210. jsonSpec.disabled = false;
  6211. }
  6212. else
  6213. {
  6214. jsonSpec.iconClass = "sortDisabled";
  6215. jsonSpec.disabled = true;
  6216. }
  6217. return jsonSpec;
  6218. };
  6219. SortAction.prototype.updateMenu = function(jsonSpec)
  6220. {
  6221. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  6222. if (! jsonSpec.visible)
  6223. {
  6224. return jsonSpec;
  6225. }
  6226. this.buildMenu(jsonSpec);
  6227. if (jsonSpec.disabled == true) {
  6228. return this.toggleMenu(jsonSpec, false);
  6229. }
  6230. return this.buildDynamicMenuItem(this.toggleMenu(jsonSpec, true), "Sort");
  6231. };
  6232. SortAction.prototype.buildSelectedItemsString = function(selectedObjects, isSortByValue/*isSortByValue=false means sortByLabel*/, containerReportInfo)
  6233. {
  6234. try {
  6235. var selObj = selectedObjects[selectedObjects.length -1];
  6236. if (isSortByValue) {
  6237. var itemsLabel = selObj.getDisplayValues()[0];
  6238. if (typeof itemsLabel == "undefined") {
  6239. itemsLabel = selObj.getUseValues()[0][0];
  6240. }
  6241. return itemsLabel;
  6242. } else {
  6243. return selObj.getDataItemDisplayValue(containerReportInfo);
  6244. }
  6245. }
  6246. catch (e) {
  6247. if (console && console.log) {
  6248. console.log(e);
  6249. }
  6250. }
  6251. };
  6252. SortAction.prototype.buildMenu = function(jsonSpec)
  6253. {
  6254. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  6255. if (! jsonSpec.visible)
  6256. {
  6257. return jsonSpec;
  6258. }
  6259. if(!this.isSelectionSortable())
  6260. {
  6261. return this.toggleMenu(jsonSpec, false);
  6262. }
  6263. jsonSpec = this.toggleMenu(jsonSpec, true);
  6264. var sortItems = [];
  6265. var selectionController = this.m_oCV.getSelectionController();
  6266. var selectedObjects = selectionController.getAllSelectedObjects();
  6267. if(selectedObjects.length == 1 && selectedObjects[0].isHomeCell() == false)
  6268. {
  6269. var containerType = selectionController.getDataContainerType();
  6270. var containerId = this.getContainerId( selectionController );
  6271. var selectedReportInfo = this.getReportInfo(containerId);
  6272. //if the selection is on the section of the sectioned list, the containerType is "".
  6273. if (containerType == "" && !this.isSelectionOnChart() && selectedObjects[0].getLayoutType() == "section") {
  6274. if (selectedReportInfo != null) {
  6275. containerType = selectedReportInfo.displayTypeId;
  6276. }
  6277. }
  6278. var reportInfo, sItemLabel, sSelectionInfo;
  6279. var currentSortFromSelection = this.getCurrentSortFromSelection();
  6280. var bSelectionOnChart = this.isSelectionOnChart();
  6281. var bSortByValue = currentSortFromSelection.indexOf("sortByValue") != -1;
  6282. var bSortByValueAscending = currentSortFromSelection.indexOf("sortByValueAscending") != -1;
  6283. var bSortByValueDescending = currentSortFromSelection.indexOf("sortByValueDescending") != -1;
  6284. var bIsIWidgetMobile = this.m_oCV.isIWidgetMobile();
  6285. if(containerType == "list" )
  6286. {
  6287. var oSortByValueAscendingMenuItem = { name: "SortAscending", label: RV_RES.IDS_JS_SORT_ASCENDING, action: { name: "Sort", payload: {order:"ascending", type:"value"} }, items: null };
  6288. this.addMenuItemChecked(bSortByValueAscending, oSortByValueAscendingMenuItem, "sortAscending");
  6289. sortItems.push(oSortByValueAscendingMenuItem);
  6290. var oSortByValueDescendingMenuItem = { name: "SortDescending", label: RV_RES.IDS_JS_SORT_DESCENDING, action: { name: "Sort", payload: { order:"descending", type:"value"} }, items: null };
  6291. this.addMenuItemChecked(bSortByValueDescending, oSortByValueDescendingMenuItem, "sortDescending");
  6292. sortItems.push(oSortByValueDescendingMenuItem);
  6293. var oSortMenuItem = { name: "DontSort", label: RV_RES.IDS_JS_DONT_SORT, action: { name: "Sort", payload: {order:"none",type:"value"} }, items: null };
  6294. this.addMenuItemChecked(!bSortByValue, oSortMenuItem, "sortNone");
  6295. sortItems.push(oSortMenuItem);
  6296. }
  6297. else if (containerType == "crosstab" || bSelectionOnChart)
  6298. {
  6299. if (selectedObjects[0].getLayoutType() == 'columnTitle' || bSelectionOnChart)
  6300. {
  6301. reportInfo = this.m_oCV.getRAPReportInfo();
  6302. if(this.canSortByValueOnCrosstab(selectedObjects[0], reportInfo))
  6303. {
  6304. sItemLabel = RV_RES.IDS_JS_SORT_BY_VALUE;
  6305. // need to show what item will get sorted if we're dealing with charts since
  6306. // charts don't show selection
  6307. if (bSelectionOnChart) {
  6308. sSelectionInfo = this.buildSelectedItemsString(selectedObjects, true /*sortByValue*/, selectedReportInfo);
  6309. if (typeof sSelectionInfo !== "undefined") {
  6310. sItemLabel += ":" + sSelectionInfo;
  6311. }
  6312. }
  6313. var oSortByValueMenuItem = { name: "SortByValue", label: sItemLabel, action: null, items: [{ name: "Ascending", label: RV_RES.IDS_JS_SORT_BY_ASCENDING, action: { name: "Sort", payload: {order:"ascending",type:"value"} }, items: null }, { name: "Descending", label: RV_RES.IDS_JS_SORT_BY_DESCENDING, action: { name: "Sort", payload: {order:"descending",type:"value"} }, items: null }, { name: "SortNone", label: RV_RES.IDS_JS_DONT_SORT, action: { name: "Sort", payload: {order:"none",type:"value"} }, items: null } ] };
  6314. this.addMenuItemChecked(bSortByValue, oSortByValueMenuItem);
  6315. this.addMenuItemChecked(bSortByValueAscending, oSortByValueMenuItem.items[0], "sortAscending");
  6316. this.addMenuItemChecked(bSortByValueDescending, oSortByValueMenuItem.items[1], "sortDescending");
  6317. this.addMenuItemChecked(!bSortByValue, oSortByValueMenuItem.items[2], "sortNone");
  6318. if (bIsIWidgetMobile) {
  6319. oSortByValueMenuItem.flatten = true;
  6320. }
  6321. sortItems.push(oSortByValueMenuItem);
  6322. }
  6323. if(this.canSortByLabelOnCrosstab(selectedObjects[0]))
  6324. {
  6325. sItemLabel = RV_RES.IDS_JS_SORT_BY_LABEL;
  6326. // need to show what item will get sorted if we're dealing with charts since
  6327. // charts don't show selection
  6328. if (bSelectionOnChart) {
  6329. sSelectionInfo = this.buildSelectedItemsString(selectedObjects, false /*sortByLabel*/, selectedReportInfo);
  6330. if (typeof sSelectionInfo !== "undefined") {
  6331. sItemLabel += ":" + sSelectionInfo;
  6332. }
  6333. }
  6334. var oSortByLabelMenuItem = { name: "SortByLabel", label: sItemLabel, action: null, items: [{ name: "Ascending", label: RV_RES.IDS_JS_SORT_BY_ASCENDING, action: { name: "Sort", payload: {order:"ascending",type:"label"} }, items: null }, { name: "Descending", label: RV_RES.IDS_JS_SORT_BY_DESCENDING, action: { name: "Sort", payload: {order:"descending",type:"label"} }, items: null }, { name: "SortNone", label: RV_RES.IDS_JS_DONT_SORT, action: { name: "Sort", payload: {order:"none",type:"label"} }, items: null } ] };
  6335. var bSortByLabel = currentSortFromSelection.indexOf("sortByLabel") != -1;
  6336. this.addMenuItemChecked(bSortByLabel, oSortByLabelMenuItem);
  6337. this.addMenuItemChecked(currentSortFromSelection.indexOf("sortByLabelAscending") != -1, oSortByLabelMenuItem.items[0], "sortAscending");
  6338. this.addMenuItemChecked(currentSortFromSelection.indexOf("sortByLabelDescending") != -1, oSortByLabelMenuItem.items[1], "sortDescending");
  6339. this.addMenuItemChecked(!bSortByLabel, oSortByLabelMenuItem.items[2], "sortNone");
  6340. if (bIsIWidgetMobile) {
  6341. oSortByLabelMenuItem.flatten = true;
  6342. }
  6343. sortItems.push(oSortByLabelMenuItem);
  6344. }
  6345. }
  6346. }
  6347. }
  6348. if(sortItems.length == 0)
  6349. {
  6350. this.toggleMenu(jsonSpec, false);
  6351. }
  6352. else
  6353. {
  6354. if (bIsIWidgetMobile) {
  6355. if (containerType == "crosstab" || bSelectionOnChart) {
  6356. jsonSpec.useChildrenItems = true;
  6357. }
  6358. else {
  6359. jsonSpec.flatten = true;
  6360. }
  6361. }
  6362. jsonSpec.items = sortItems;
  6363. this.toggleMenu(jsonSpec, true);
  6364. }
  6365. return jsonSpec;
  6366. };
  6367. SortAction.prototype.isSelectionSortable = function()
  6368. {
  6369. var selectionController = this.m_oCV.getSelectionController();
  6370. var selectedObjects = selectionController.getAllSelectedObjects();
  6371. if (selectedObjects.length == 1) {
  6372. var selectedObject = selectedObjects[0];
  6373. //If the select object should be disabled when the user selects a measured cell(s).
  6374. if (selectionController.getDataContainerType() == "crosstab" && selectedObject.getLayoutType() == 'datavalue')
  6375. {
  6376. return false;
  6377. }
  6378. if (selectionController.hasSelectedChartNodes())
  6379. {
  6380. var node = selectedObject.getArea();
  6381. if (node.nodeName == 'AREA' || node.nodeName == 'IMG')
  6382. {
  6383. return selectedObjects[0].getLayoutType() == 'ordinalAxisLabel' || selectedObjects[0].getLayoutType() == 'legendLabel';
  6384. }
  6385. }
  6386. else
  6387. {
  6388. var data = selectedObject.getDataItems();
  6389. if(selectedObject.getCellRef().getAttribute("type") == "datavalue" && !(data && data.length)) {
  6390. //Not sortable if there is no logical data in the selection
  6391. return false;
  6392. }
  6393. var oCell = selectedObject.getCellRef();
  6394. if (oCell.getAttribute("no_data_item_column") === "true") {
  6395. return false;
  6396. }
  6397. if (oCell.getAttribute("canSort") != "false") {
  6398. return true;
  6399. }
  6400. }
  6401. }
  6402. return false;
  6403. };
  6404. SortAction.prototype.getCurrentSortFromSelection = function()
  6405. {
  6406. var containerId = this.getContainerId(this.m_oCV.getSelectionController());
  6407. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  6408. var currentSortFromSelection = "";
  6409. if(containerId != "" && oRAPReportInfo) {
  6410. var container = oRAPReportInfo.getContainer(containerId);
  6411. if(typeof container.sort != "undefined") {
  6412. var selectionController = this.m_oCV.getSelectionController();
  6413. var selectedObjects = selectionController.getAllSelectedObjects();
  6414. if(selectedObjects.length == 1) {
  6415. var dataItems = selectedObjects[0].getDataItems();
  6416. if(dataItems.length < 1) {
  6417. return currentSortFromSelection;
  6418. }
  6419. var dataItem = dataItems[0][0];
  6420. for(var index = 0; index < container.sort.length; ++index) {
  6421. var sortInfo = container.sort[index];
  6422. if(typeof sortInfo.labels == "string" && sortInfo.labels == dataItem) {
  6423. currentSortFromSelection += sortInfo.order == "descending" ? "sortByLabelDescending" : "sortByLabelAscending";
  6424. }
  6425. if(typeof sortInfo.valuesOf == "string" && (sortInfo.valuesOf == dataItem || this.isSortedValueOnRenamedColumn(selectedObjects[0], sortInfo))) {
  6426. currentSortFromSelection += sortInfo.order == "descending" ? "sortByValueDescending" : "sortByValueAscending";
  6427. }
  6428. else if(sortInfo.valuesOf instanceof Array) {
  6429. var match = true;
  6430. for(var valueSortIdx = 0; valueSortIdx < sortInfo.valuesOf.length; ++valueSortIdx) {
  6431. if(valueSortIdx < selectedObjects[0].m_contextIds[0].length) {
  6432. var ctx = selectedObjects[0].m_contextIds[0][valueSortIdx];
  6433. var selectionDisplayValue = selectionController.getDisplayValue(ctx);
  6434. var sortDisplayValue = this.findItemLabel(container, sortInfo.valuesOf[valueSortIdx].item);
  6435. if(sortDisplayValue != selectionDisplayValue) {
  6436. match = false;
  6437. break;
  6438. }
  6439. }
  6440. }
  6441. if(match) {
  6442. currentSortFromSelection += sortInfo.valuesOf[0].order == "descending" ? "sortByValueDescending" : "sortByValueAscending";
  6443. }
  6444. }
  6445. }
  6446. }
  6447. }
  6448. }
  6449. return currentSortFromSelection;
  6450. };
  6451. SortAction.prototype.isSortedValueOnRenamedColumn =function(selectedObject, sortInfo){
  6452. if(sortInfo && selectedObject){
  6453. return (sortInfo.valuesOf === selectedObject.getColumnRP_Name() && selectedObject.getLayoutType() === "columnTitle");
  6454. }
  6455. };
  6456. SortAction.prototype.findItemLabel = function(container, item) {
  6457. var itemInfo = container.itemInfo;
  6458. if (itemInfo) {
  6459. for (var i = 0; i < itemInfo.length; i++) {
  6460. if (itemInfo[i].item === item) {
  6461. if (itemInfo[i].itemLabel) {
  6462. return itemInfo[i].itemLabel;
  6463. }
  6464. break;
  6465. }
  6466. }
  6467. }
  6468. return item;
  6469. };
  6470. SortAction.prototype.canSortByValueOnCrosstab = function(selectedObject, reportInfo)
  6471. {
  6472. var selectionController = this.m_oCV.getSelectionController();
  6473. var containerId = this.getContainerId(this.m_oCV.getSelectionController());
  6474. if (selectionController.isRelational() == true) {
  6475. return false;
  6476. }
  6477. if (selectionController.selectionsHaveCalculationMetadata() && this.selectedObjectIsLeaf(containerId, selectedObject, reportInfo)) {
  6478. //The DAM layer allows "tagging" of calculation values which are part of sets with uuid designators.
  6479. //These uuid's are simply passed through and returned as if they were mun's (but are not muns and can't be used in expressions)
  6480. //We don't support these as discrete values.
  6481. var aMuns = selectedObject.getMuns()[0];
  6482. for (var index = 0; index < aMuns.length; ++index)
  6483. {
  6484. if (aMuns[index] != null && aMuns[index].indexOf("uuid:") >= 0)
  6485. {
  6486. return false;
  6487. }
  6488. }
  6489. return true;
  6490. }
  6491. return false;
  6492. };
  6493. SortAction.prototype.selectedObjectIsLeaf = function (containerId, selectedObject, reportInfo)
  6494. {
  6495. if (reportInfo) {
  6496. var dataItems = selectedObject.getDataItems();
  6497. if (dataItems != null && typeof dataItems != "undefined" && dataItems.length > 0) {
  6498. var oDrillability = reportInfo.getDrillability(containerId, dataItems[0][0]);
  6499. if (oDrillability) {
  6500. return oDrillability.leaf == true;
  6501. }
  6502. }
  6503. }
  6504. return false;
  6505. };
  6506. SortAction.prototype.canSortByLabelOnCrosstab = function(selectedObject)
  6507. {
  6508. var selectionController = this.m_oCV.getSelectionController();
  6509. var selectedObjects = selectionController.getAllSelectedObjects();
  6510. if(selectedObjects.length == 1) {
  6511. // FIXME: This variable (selectedObject) is masking the first parameter. Remove variable or the parameter.
  6512. var selectedObject = selectedObjects[0];
  6513. if (this.isSelectSingleMember(selectedObject)==false)
  6514. {
  6515. if (selectionController.selectionsNonMeasureWithMUN() || !selectionController.selectionsHaveCalculationMetadata()) {
  6516. return true;
  6517. }
  6518. }
  6519. }
  6520. return false;
  6521. };
  6522. /*
  6523. *+------------------------------------------------------------------------+
  6524. *| Licensed Materials - Property of IBM
  6525. *| IBM Cognos Products: Viewer
  6526. *| (C) Copyright IBM Corp. 2013
  6527. *|
  6528. *| US Government Users Restricted Rights - Use, duplication or
  6529. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6530. *|
  6531. *+------------------------------------------------------------------------+
  6532. */
  6533. // This action is used to rerender the html output, using the same query
  6534. function RedrawAction() {
  6535. this.m_specUpdated = false;
  6536. }
  6537. RedrawAction.prototype = new ModifyReportAction();
  6538. RedrawAction.prototype.reuseQuery = function() { return true; };
  6539. RedrawAction.prototype.keepRAPCache = function() { return false; };
  6540. RedrawAction.prototype.setSpecUpdated = function(flag)
  6541. {
  6542. this.m_specUpdated = flag;
  6543. };
  6544. RedrawAction.prototype.getUndoHint = function()
  6545. {
  6546. return RV_RES.IDS_JS_ADVANCED_EDITING;
  6547. };
  6548. RedrawAction.prototype.addActionContext = function()
  6549. {
  6550. if (this.m_specUpdated) {
  6551. return "<reportActions><GetInfo><specUpdatedInBUA/></GetInfo></reportActions>";
  6552. }
  6553. return "<reportActions><GetInfo/></reportActions>";
  6554. };
  6555. /*
  6556. *+------------------------------------------------------------------------+
  6557. *| Licensed Materials - Property of IBM
  6558. *| IBM Cognos Products: Viewer
  6559. *| (C) Copyright IBM Corp. 2013, 2014
  6560. *|
  6561. *| US Government Users Restricted Rights - Use, duplication or
  6562. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6563. *|
  6564. *+------------------------------------------------------------------------+
  6565. */
  6566. function EditContentAction()
  6567. {
  6568. this._oMissingMemberRecoveryMode = null;
  6569. }
  6570. EditContentAction.prototype = new CognosViewerAction();
  6571. EditContentAction.superclass = CognosViewerAction.prototype;
  6572. EditContentAction.prototype.execute = function() {
  6573. if (typeof this.preferencesChanged != "undefined" && this.preferencesChanged !== null && this.preferencesChanged === true ) {
  6574. this.deleteCWAContainer();
  6575. return;
  6576. }
  6577. window.CVEditContentActionInstance = this;
  6578. var buaAlreadyLoaded = window.viewerCWAContainer ? true : false;
  6579. if (!window.viewerCWAContainer) {
  6580. this.createCWAContainer();
  6581. }
  6582. this.addWindowEventListeners();
  6583. this.buildBUAObjects();
  6584. window.viewerCWAContainer.show();
  6585. if (buaAlreadyLoaded) {
  6586. window.BUAEvent("appReady");
  6587. }
  6588. };
  6589. EditContentAction.prototype.createCWAContainer = function() {
  6590. this.deleteCWAContainer();
  6591. var containerDiv = this.createCWAIFrame();
  6592. var blocker = this.createBlocker();
  6593. window.viewerCWAContainer = {
  6594. "type" : "iframe",
  6595. "containerDiv" : containerDiv,
  6596. "blocker" : blocker,
  6597. "iframePadding" : "18",
  6598. "show" : function() {
  6599. this.resize();
  6600. this.containerDiv.style.display = "block";
  6601. this.blocker.style.display = "block";
  6602. },
  6603. "hide" : function() {
  6604. this.blocker.style.display = "none";
  6605. this.containerDiv.style.display = "none";
  6606. },
  6607. "resize" : function() {
  6608. var windowBox = dojo.window.getBox();
  6609. this.containerDiv.style.height = windowBox.h - this.iframePadding + "px";
  6610. this.containerDiv.style.width = windowBox.w - this.iframePadding + "px";
  6611. }
  6612. };
  6613. };
  6614. EditContentAction.prototype.deleteCWAContainer = function() {
  6615. var containerObj = window.viewerCWAContainer;
  6616. if (containerObj) {
  6617. containerObj.hide();
  6618. document.body.removeChild(containerObj.containerDiv);
  6619. document.body.removeChild(containerObj.blocker);
  6620. delete window.viewerCWAContainer;
  6621. window.viewerCWAContainer = null;
  6622. }
  6623. };
  6624. EditContentAction.prototype.hideCWAContainer = function() {
  6625. this.removeWindowEventListeners();
  6626. if (window.viewerCWAContainer) {
  6627. window.viewerCWAContainer.hide();
  6628. }
  6629. window.CVEditContentActionInstance = null;
  6630. };
  6631. EditContentAction.prototype.createCWAIFrame = function() {
  6632. var containerDiv = document.createElement("div");
  6633. containerDiv.className = "buaContainer";
  6634. document.body.appendChild(containerDiv);
  6635. var iframeElement = document.createElement("iframe");
  6636. iframeElement.setAttribute("id","buaIframe");
  6637. iframeElement.setAttribute("src", this.getWebContent() + "/pat/rsapp.htm");
  6638. iframeElement.setAttribute("name", "buaIframe");
  6639. iframeElement.setAttribute("frameborder",'0');
  6640. iframeElement.className = "buaIframe";
  6641. containerDiv.appendChild(iframeElement);
  6642. return containerDiv;
  6643. };
  6644. EditContentAction.prototype.createBlocker = function() {
  6645. var blocker = document.createElement("div");
  6646. blocker.setAttribute("id","reportBlocker");
  6647. blocker.setAttribute("name", "reportBlocker");
  6648. blocker.setAttribute("tabIndex", "1");
  6649. blocker.className = "reportBlocker";
  6650. document.body.appendChild(blocker);
  6651. return blocker;
  6652. };
  6653. EditContentAction.prototype.buildBUAObjects = function() {
  6654. window.RSParameters = {
  6655. "rs_UIProfile" : "BUA",
  6656. "ui.action" : "edit",
  6657. "gateway" : location.protocol + "//" + location.host + this.getGateway(),
  6658. "theme" : "corporate",//make look&feel consistent between CW and CWA
  6659. "capabilitiesXML" : this.getCapabilitiesXml(),
  6660. "cafcontextid" : this.getCafContextId(),
  6661. "paneOnRight" : this.getViewerIWidget().getPaneOnRight()
  6662. };
  6663. var viewerWidget = this.getViewerIWidget();
  6664. if(viewerWidget !== null) {
  6665. var cvGateway = viewerWidget.getAttributeValue("gateway");
  6666. if(cvGateway) {
  6667. window.RSParameters["cv.gateway"] = cvGateway;
  6668. }
  6669. var cvWebcontent = viewerWidget.getAttributeValue("webcontent");
  6670. if(cvWebcontent) {
  6671. window.RSParameters["cv.webcontent"] = cvWebcontent;
  6672. }
  6673. }
  6674. this.addExtraLaunchParameters(window.RSParameters);
  6675. };
  6676. EditContentAction.prototype.getBUAIframe = function() {
  6677. return document.getElementById("buaIframe");
  6678. };
  6679. EditContentAction.prototype.getBUAWindow = function() {
  6680. var buaWindow = null;
  6681. var buaIframe = this.getBUAIframe();
  6682. if(buaIframe !== null) {
  6683. buaWindow = buaIframe.contentWindow;
  6684. }
  6685. return buaWindow;
  6686. };
  6687. EditContentAction.prototype.setReportSettings = function() {
  6688. var oCV = this.getCognosViewer();
  6689. var widget = oCV.getViewerWidget();
  6690. //Fire an IWidget event to get the title
  6691. widget.fireEvent("com.ibm.bux.widget.getDisplayTitle", null, { callback: function(sTitle) { window.CVEditContentActionInstance.openReportWithBUA(sTitle); } });
  6692. };
  6693. EditContentAction.prototype.openReportWithBUA = function(sTitle) {
  6694. var subStringIndex = this.m_oCV.envParams["ui.spec"].indexOf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  6695. if (subStringIndex == -1) { subStringIndex = 0; } else { subStringIndex = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>".length; }
  6696. var sReportXML = this.m_oCV.envParams["ui.spec"].substr(subStringIndex, this.m_oCV.envParams["ui.spec"].length);
  6697. var oContext = {
  6698. "displayName" : xml_decode(sTitle), //Chrome HTML encoded this sTtitle
  6699. "parameterValues" : this.m_oCV.getExecutionParameters(),
  6700. "reportXML" : sReportXML,
  6701. "showOpenTransition" : false
  6702. };
  6703. if (this.ifPassTrackingtoBUA()) {
  6704. oContext.tracking = this.m_oCV.getTracking();
  6705. }
  6706. var buaWindow = this.getBUAWindow();
  6707. buaWindow.Application.SetBUAContext(oContext);
  6708. };
  6709. EditContentAction.prototype.getViewerIWidget = function() {
  6710. return this.m_oCV.getViewerWidget();
  6711. };
  6712. EditContentAction.prototype.getGateway = function() {
  6713. return this.m_oCV.getGateway();
  6714. };
  6715. EditContentAction.prototype.getCapabilitiesXml = function() {
  6716. return this.m_oCV.capabilitiesXML;
  6717. };
  6718. EditContentAction.prototype.getCafContextId = function() {
  6719. return typeof this.m_oCV.cafContextId != "undefined" ? this.m_oCV.cafContextId : "";
  6720. };
  6721. EditContentAction.prototype.getWebContent = function() {
  6722. return this.getCognosViewer().getWebContentRoot();
  6723. };
  6724. EditContentAction.prototype.addExtraLaunchParameters = function(RSParameters) {};
  6725. EditContentAction.prototype.runUpdatedReportFromBUA = function() {
  6726. var buaWindow = this.getBUAWindow();
  6727. var originalSpec = this.m_oCV.envParams["ui.spec"];
  6728. var oContext = buaWindow.Application.GetBUAContext();
  6729. if (oContext.isSpecModified) {
  6730. this.m_oCV.envParams["ui.spec"] = oContext.reportXML;
  6731. this.m_oCV.setTracking(oContext.tracking);
  6732. this.m_oCV.setExecutionParameters(oContext.parameterValues);
  6733. this._invokeRedrawAction(originalSpec);
  6734. }
  6735. };
  6736. EditContentAction.prototype._invokeRedrawAction = function(originalSpec)
  6737. {
  6738. this.getUndoRedoQueue().setOriginalSpec(originalSpec);
  6739. var redrawAction = this.m_oCV.getAction("Redraw");
  6740. redrawAction.setSpecUpdated(true);
  6741. this.m_oCV.getViewerWidget().setPromptParametersRetrieved(false);
  6742. redrawAction.execute();
  6743. };
  6744. EditContentAction.prototype.ifPassTrackingtoBUA = function()
  6745. {
  6746. if (this.m_oCV.getRAPReportInfo()) {
  6747. return this.m_oCV.getRAPReportInfo().getPassTrackingtoBUA();
  6748. }
  6749. return true;
  6750. };
  6751. EditContentAction.prototype.setRequestParms = function(params) {
  6752. EditContentAction.superclass.setRequestParms(params);
  6753. if (params) {
  6754. if (params.preferencesChanged) {
  6755. this.preferencesChanged = params.preferencesChanged;
  6756. }
  6757. if (params.MissingMemberRecoveryMode) {
  6758. this._oMissingMemberRecoveryMode = params.MissingMemberRecoveryMode;
  6759. }
  6760. }
  6761. };
  6762. EditContentAction.prototype.runUpdatedReportFromBUA_MissingMemberRecoveryMode = function() {
  6763. var buaWindow = this.getBUAWindow();
  6764. var originalSpec = this.m_oCV.envParams["ui.spec"];
  6765. var oContext = buaWindow.Application.GetBUAContext();
  6766. this.m_oCV.setTracking(oContext.tracking);
  6767. this.m_oCV.envParams["ui.spec"] = oContext.reportXML;
  6768. this.m_oCV.setExecutionParameters(oContext.parameterValues);
  6769. if (this._oMissingMemberRecoveryMode && this._oMissingMemberRecoveryMode.oFaultDialog) {
  6770. this._oMissingMemberRecoveryMode.oFaultDialog.hide();
  6771. }
  6772. this._invokeRedrawAction(originalSpec);
  6773. };
  6774. EditContentAction.prototype.cancelPressed = function() {};
  6775. EditContentAction.prototype.addWindowEventListeners = function() {
  6776. if (window.attachEvent) {
  6777. window.attachEvent("onresize", window.CVEditContentActionInstance.onWindowResize);
  6778. }
  6779. else {
  6780. window.addEventListener("resize", window.CVEditContentActionInstance.onWindowResize, false);
  6781. }
  6782. };
  6783. EditContentAction.prototype.removeWindowEventListeners = function() {
  6784. if (window.detachEvent) {
  6785. window.detachEvent("onresize", window.CVEditContentActionInstance.onWindowResize);
  6786. }
  6787. else {
  6788. window.removeEventListener("resize", window.CVEditContentActionInstance.onWindowResize, false);
  6789. }
  6790. };
  6791. EditContentAction.prototype.onWindowResize = function() {
  6792. var containerObj = window.viewerCWAContainer;
  6793. if (containerObj) {
  6794. containerObj.resize();
  6795. }
  6796. };
  6797. /**
  6798. * Interface that CWA will call
  6799. * @param eventType
  6800. */
  6801. function BUAEvent(eventType)
  6802. {
  6803. var editContentObj = window.CVEditContentActionInstance;
  6804. switch (eventType)
  6805. {
  6806. case "appReady":
  6807. editContentObj.setReportSettings();
  6808. break;
  6809. case "donePressed":
  6810. editContentObj.hideCWAContainer();
  6811. if (editContentObj._oMissingMemberRecoveryMode) {
  6812. editContentObj.runUpdatedReportFromBUA_MissingMemberRecoveryMode();
  6813. } else {
  6814. editContentObj.runUpdatedReportFromBUA();
  6815. }
  6816. break;
  6817. case "cancelPressed":
  6818. editContentObj.cancelPressed();
  6819. editContentObj.hideCWAContainer();
  6820. break;
  6821. }
  6822. }
  6823. /*
  6824. *+------------------------------------------------------------------------+
  6825. *| Licensed Materials - Property of IBM
  6826. *| IBM Cognos Products: Viewer
  6827. *| (C) Copyright IBM Corp. 2013
  6828. *|
  6829. *| US Government Users Restricted Rights - Use, duplication or
  6830. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6831. *|
  6832. *+------------------------------------------------------------------------+
  6833. */
  6834. function NewReportAction() {
  6835. this._viewerIWidget = null;
  6836. this._packageSearchPath = null;
  6837. this._webContentRoot = null;
  6838. this._gateway = null;
  6839. this._capabilitiesXml = null;
  6840. this._cafContextId = null;
  6841. }
  6842. NewReportAction.prototype = new EditContentAction();
  6843. NewReportAction.prototype.parent = EditContentAction.prototype;
  6844. NewReportAction.prototype.clearSelections = function() {};
  6845. NewReportAction.prototype.getCognosViewer = function() {
  6846. return this.getViewerIWidget().getViewerObject();
  6847. };
  6848. NewReportAction.prototype.setRequestParms = function(params) {
  6849. this.parent.setRequestParms.call(this, params);
  6850. this._packageSearchPath = params.packageSearchPath;
  6851. this._viewerIWidget = params.viewerIWidget;
  6852. this._webContentRoot = params.webContentRoot;
  6853. this._gateway = params.gateway;
  6854. this._capabilitiesXml = params.capabilitiesXml;
  6855. this._cafContextId = params.cafContextId;
  6856. };
  6857. NewReportAction.prototype.getViewerIWidget = function() {
  6858. return this._viewerIWidget;
  6859. };
  6860. NewReportAction.prototype.getGateway = function() {
  6861. return this._gateway;
  6862. };
  6863. NewReportAction.prototype.getCapabilitiesXml = function() {
  6864. return this._capabilitiesXml;
  6865. };
  6866. NewReportAction.prototype.getCafContextId = function() {
  6867. return this._cafContextId ? this._cafContextId : "";
  6868. };
  6869. NewReportAction.prototype.getWebContent = function() {
  6870. return this._webContentRoot;
  6871. };
  6872. NewReportAction.prototype.setReportSettings = function() {
  6873. var oContext = {
  6874. "showOpenTransition" : false,
  6875. "model" : this._packageSearchPath
  6876. };
  6877. var buaWindow = this.getBUAWindow();
  6878. buaWindow.Application.SetBUAContext(oContext);
  6879. };
  6880. /**
  6881. * Adds any extra parameters needed when creating a new report
  6882. */
  6883. NewReportAction.prototype.addExtraLaunchParameters = function(RSParameters) {
  6884. RSParameters.model = this._packageSearchPath;
  6885. };
  6886. NewReportAction.prototype.cancelPressed = function() {
  6887. this.getViewerIWidget().iContext.iEvents.fireEvent("com.ibm.bux.widget.action", null, { action: 'deleteWidget' });
  6888. };
  6889. /**
  6890. * Get the information from CWA and recall the onLoad of the Viewer iWidget
  6891. */
  6892. NewReportAction.prototype.runUpdatedReportFromBUA = function() {
  6893. var iWidget = this.getViewerIWidget();
  6894. iWidget.setAttributeValue("reportCreatedInCW", "true");
  6895. var oContext = this.getBUAWindow().Application.GetBUAContext();
  6896. iWidget.setNewReportInfo({
  6897. "ui.spec" : oContext.reportXML,
  6898. "m_tracking" : oContext.tracking ? oContext.tracking : "",
  6899. "parameterValues" : oContext.parameterValues ? oContext.parameterValues : ""
  6900. });
  6901. iWidget.onLoad();
  6902. };/*
  6903. *+------------------------------------------------------------------------+
  6904. *| Licensed Materials - Property of IBM
  6905. *| IBM Cognos Products: Viewer
  6906. *| (C) Copyright IBM Corp. 2001, 2016
  6907. *|
  6908. *| US Government Users Restricted Rights - Use, duplication or
  6909. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6910. *|
  6911. *+------------------------------------------------------------------------+
  6912. */
  6913. /**
  6914. * Implements authored drill through
  6915. */
  6916. function AuthoredDrillAction()
  6917. {
  6918. this.m_drillTargetSpecification = "";
  6919. }
  6920. AuthoredDrillAction.prototype = new CognosViewerAction();
  6921. AuthoredDrillAction.prototype.setRequestParms = function(drillTargetSpecification)
  6922. {
  6923. this.m_drillTargetSpecification = drillTargetSpecification;
  6924. };
  6925. AuthoredDrillAction.prototype.executeDrillTarget = function(drillTargetSpecification)
  6926. {
  6927. var drillTargetNode = XMLHelper_GetFirstChildElement( XMLBuilderLoadXMLFromString (drillTargetSpecification) );
  6928. var sBookmarkRef = encodeURIComponent(drillTargetNode.getAttribute("bookmarkRef"));
  6929. var sTargetPath = drillTargetNode.getAttribute("path");
  6930. var bShowInNewWindow = this._shouldShowInNewWindow(drillTargetNode);
  6931. var oCV = this.getCognosViewer();
  6932. if((sBookmarkRef !== null && sBookmarkRef !== "") && (sTargetPath === null || sTargetPath === ""))
  6933. {
  6934. var sBookmarkPage = drillTargetNode.getAttribute("bookmarkPage");
  6935. if (sBookmarkPage && sBookmarkPage !== "") {
  6936. oCV.executeAction("GotoPage",{ "pageNumber": sBookmarkPage,"anchorName": sBookmarkRef} );
  6937. } else {
  6938. document.location = "#" + sBookmarkRef;
  6939. }
  6940. }
  6941. else
  6942. {
  6943. var sTarget = "";
  6944. if(bShowInNewWindow)
  6945. {
  6946. sTarget = "_blank";
  6947. }
  6948. var aArguments = [];
  6949. var objPathArguments = [];
  6950. objPathArguments.push("obj");
  6951. objPathArguments.push(sTargetPath);
  6952. aArguments[aArguments.length] = objPathArguments;
  6953. var bHasPropertyToPass = false;
  6954. var drillParameterArguments, drillParameterNode, sValue, sName, sNil;
  6955. var drillParameterNodes = XMLHelper_FindChildrenByTagName(drillTargetNode, "drillParameter", false);
  6956. for(var index = 0; index < drillParameterNodes.length; ++index)
  6957. {
  6958. drillParameterArguments = [];
  6959. drillParameterNode = drillParameterNodes[index];
  6960. sValue = drillParameterNode.getAttribute("value");
  6961. sName = drillParameterNode.getAttribute("name");
  6962. if(sValue !== null && sValue !== "")
  6963. {
  6964. drillParameterArguments.push("p_" + sName);
  6965. drillParameterArguments.push(this.buildSelectionChoicesSpecification(drillParameterNode));
  6966. }
  6967. sNil = drillParameterNode.getAttribute("nil");
  6968. if(sNil !== null && sNil !== "")
  6969. {
  6970. drillParameterArguments.push("p_" + sName);
  6971. drillParameterArguments.push(this.buildSelectionChoicesNilSpecification());
  6972. }
  6973. if(drillParameterArguments.length > 0)
  6974. {
  6975. aArguments[aArguments.length] = drillParameterArguments;
  6976. }
  6977. if( !bHasPropertyToPass){
  6978. var sPropertyToPass = drillParameterNode.getAttribute( "propertyToPass");
  6979. bHasPropertyToPass = ( sPropertyToPass && sPropertyToPass.length > 0 ) ? true : false;
  6980. }
  6981. }
  6982. var sMethod = drillTargetNode.getAttribute("method");
  6983. var sOutputFormat = drillTargetNode.getAttribute("outputFormat");
  6984. var sOutputLocale = drillTargetNode.getAttribute("outputLocale");
  6985. var sPrompt = drillTargetNode.getAttribute("prompt");
  6986. var dynamicDrill = drillTargetNode.getAttribute("dynamicDrill");
  6987. var sSourceContext = this.getXMLNodeAsString(drillTargetNode, "parameters");
  6988. var sObjectPaths = this.getXMLNodeAsString(drillTargetNode, "objectPaths");
  6989. var oCVId = oCV.getId();
  6990. // if the source and target are the same report, and the prompt attribute in drill definition is not set to true, and we're not opening a new window, then do a forward instead of a drillThrough action
  6991. var formWarpRequest = document.forms["formWarpRequest" + oCVId];
  6992. var callForward = oCV.getAdvancedServerProperty("VIEWER_JS_CALL_FORWARD_DRILLTHROUGH_TO_SELF");
  6993. if ( (!callForward || callForward.toLowerCase() !== "false") && sPrompt != "true" && this.isSameReport(formWarpRequest, sTargetPath) && this.isSameReportFormat(sOutputFormat) && !bShowInNewWindow && !bHasPropertyToPass )
  6994. {
  6995. var cognosViewerRequest = new ViewerDispatcherEntry(oCV);
  6996. cognosViewerRequest.addFormField("ui.action", "forward");
  6997. if(oCV !== null && typeof oCV.rvMainWnd != "undefined")
  6998. {
  6999. oCV.rvMainWnd.addCurrentReportToReportHistory();
  7000. var reportHistorySpecification = oCV.rvMainWnd.saveReportHistoryAsXML();
  7001. cognosViewerRequest.addFormField("cv.previousReports", reportHistorySpecification);
  7002. }
  7003. // if we're drilling through to ourself we need to send empty parameters for
  7004. // the parameters that are setup to no send any parameter values
  7005. for(index = 0; index < drillParameterNodes.length; ++index)
  7006. {
  7007. drillParameterArguments = [];
  7008. drillParameterNode = drillParameterNodes[index];
  7009. sValue = drillParameterNode.getAttribute("value");
  7010. sName = drillParameterNode.getAttribute("name");
  7011. sNil = drillParameterNode.getAttribute("nil");
  7012. if((sNil === null || sNil === "") && (sValue === null || sValue === ""))
  7013. {
  7014. drillParameterArguments.push("p_" + sName);
  7015. drillParameterArguments.push(this.buildSelectionChoicesNilSpecification());
  7016. }
  7017. if(drillParameterArguments.length > 0)
  7018. {
  7019. aArguments[aArguments.length] = drillParameterArguments;
  7020. }
  7021. }
  7022. for (index=1; index < aArguments.length; index++)
  7023. {
  7024. cognosViewerRequest.addFormField(aArguments[index][0], aArguments[index][1]);
  7025. }
  7026. cognosViewerRequest.addFormField("_drillThroughToSelf", "true");
  7027. // If we're dealing with a tabbed report and drilling to ourselves, then make sure we show the first tab when the report refreshes
  7028. if (oCV.m_tabsPayload && oCV.m_tabsPayload.tabs) {
  7029. cognosViewerRequest.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup", oCV.m_tabsPayload.tabs[0].id)
  7030. }
  7031. oCV.setUsePageRequest(true);
  7032. oCV.dispatchRequest(cognosViewerRequest);
  7033. if (typeof oCV.m_viewerFragment == "undefined") {
  7034. var objectRef = getCognosViewerObjectRefAsString(oCVId);
  7035. setTimeout(objectRef+".getRequestIndicator().show()",10);
  7036. }
  7037. }
  7038. else
  7039. {
  7040. doSingleDrill(sTarget, aArguments, sMethod, sOutputFormat, sOutputLocale, sBookmarkRef, sSourceContext, sObjectPaths, this.getCognosViewer().getId(), sPrompt, dynamicDrill);
  7041. }
  7042. }
  7043. };
  7044. AuthoredDrillAction.prototype._shouldShowInNewWindow = function(drillTargetNode) {
  7045. return drillTargetNode.getAttribute("showInNewWindow") == "true";
  7046. };
  7047. AuthoredDrillAction.prototype.isSameReport = function( formWarpRequest, sTargetPath )
  7048. {
  7049. if( formWarpRequest["ui.object"] && sTargetPath == formWarpRequest["ui.object"].value )
  7050. {
  7051. return true;
  7052. }
  7053. return false;
  7054. };
  7055. AuthoredDrillAction.prototype.isSameReportFormat = function( drillTargetFormat )
  7056. {
  7057. var drillSourceFormat = this.getCognosViewer().envParams["run.outputFormat"];
  7058. if( drillSourceFormat )
  7059. {
  7060. if (drillTargetFormat == drillSourceFormat )
  7061. {
  7062. return true;
  7063. }
  7064. //the following case occurs when the target drill-thru definition is set to default format
  7065. // and the source format is HTML.
  7066. else if( drillSourceFormat == "HTML" && drillTargetFormat == "HTMLFragment")
  7067. {
  7068. return true;
  7069. }
  7070. }
  7071. return false;
  7072. };
  7073. AuthoredDrillAction.prototype.getXMLNodeAsString = function(drillTargetNode, sNodeName)
  7074. {
  7075. var sXML = "";
  7076. if(drillTargetNode != null)
  7077. {
  7078. var node = XMLHelper_FindChildByTagName(drillTargetNode, sNodeName, false);
  7079. if(node != null)
  7080. {
  7081. sXML = XMLBuilderSerializeNode(node);
  7082. }
  7083. }
  7084. return sXML;
  7085. };
  7086. AuthoredDrillAction.prototype.execute = function(rvDrillTargetsSpecification)
  7087. {
  7088. if(this.m_drillTargetSpecification != "")
  7089. {
  7090. this.executeDrillTarget(this.m_drillTargetSpecification);
  7091. }
  7092. else if(typeof rvDrillTargetsSpecification != "undefined")
  7093. {
  7094. var drillTargetSpecifications = this.getCognosViewer().getDrillTargets();
  7095. var rvDrillTargetsNode = this.getAuthoredDrillThroughContext(rvDrillTargetsSpecification, drillTargetSpecifications);
  7096. var drillTargets = rvDrillTargetsNode.childNodes;
  7097. if(drillTargets.length == 1)
  7098. {
  7099. this.executeDrillTarget(XMLBuilderSerializeNode(drillTargets[0]));
  7100. }
  7101. else
  7102. {
  7103. doMultipleDrills(XMLBuilderSerializeNode(rvDrillTargetsNode), this.getCognosViewer().getId());
  7104. //Need support from goto page
  7105. //this.showDrillTargets(drillTargets);
  7106. }
  7107. }
  7108. };
  7109. AuthoredDrillAction.prototype.showDrillTargets = function(drillTargets)
  7110. {
  7111. var sAuthoredDrillThroughContext = "<context>";
  7112. for(var index = 0; index < drillTargets.length; ++index)
  7113. {
  7114. var drillTarget = drillTargets[index];
  7115. sAuthoredDrillThroughContext += "<member>";
  7116. var sName = drillTarget.getAttribute("label");
  7117. sAuthoredDrillThroughContext += "<name>";
  7118. sAuthoredDrillThroughContext += sXmlEncode(sName);
  7119. sAuthoredDrillThroughContext += "</name>";
  7120. var sDrillThroughSearchPath = drillTarget.getAttribute("path");
  7121. sAuthoredDrillThroughContext += "<drillThroughSearchPath>";
  7122. sAuthoredDrillThroughContext += sXmlEncode(sDrillThroughSearchPath);
  7123. sAuthoredDrillThroughContext += "</drillThroughSearchPath>";
  7124. var sDrillThroughAction = drillTarget.getAttribute("method");
  7125. sAuthoredDrillThroughContext += "<drillThroughAction>";
  7126. sAuthoredDrillThroughContext += sXmlEncode(sDrillThroughAction);
  7127. sAuthoredDrillThroughContext += "</drillThroughAction>";
  7128. var sDrillThroughFormat = drillTarget.getAttribute("outputFormat");
  7129. sAuthoredDrillThroughContext += "<drillThroughFormat>";
  7130. sAuthoredDrillThroughContext += sXmlEncode(sDrillThroughFormat);
  7131. sAuthoredDrillThroughContext += "</drillThroughFormat>";
  7132. var sData = "parent." + this.getTargetReportRequestString(drillTarget);
  7133. sAuthoredDrillThroughContext += "<data>";
  7134. sAuthoredDrillThroughContext += sXmlEncode(sData);
  7135. sAuthoredDrillThroughContext += "</data>";
  7136. sAuthoredDrillThroughContext += "</member>";
  7137. }
  7138. sAuthoredDrillThroughContext += "</context>";
  7139. // need to fix the ui.backURL and errURL since they'll be getting rejected by caf. TODO post BSEINS
  7140. //cvLoadDialog(this.getCognosViewer(), {"m":"portal/goto.xts","ui.backURL":"javascript:parent.destroyCModal();", "errURL":"javascript:parent.destroyCModal();","authoredDrillthru":sAuthoredDrillThroughContext}, 600, 425);
  7141. };
  7142. AuthoredDrillAction.prototype.populateContextMenu = function(rvDrillTargetsSpecification)
  7143. {
  7144. var viewer = this.getCognosViewer();
  7145. var toolbarCtrl = viewer.rvMainWnd.getToolbarControl();
  7146. var authoredDrillDropDownMenu = null;
  7147. if (typeof toolbarCtrl != "undefined" && toolbarCtrl != null)
  7148. {
  7149. var toolbarButton = toolbarCtrl.getItem("goto");
  7150. if (toolbarButton)
  7151. {
  7152. authoredDrillDropDownMenu = toolbarButton.getMenu();
  7153. }
  7154. }
  7155. var cognosViewerContextMenu = viewer.rvMainWnd.getContextMenu();
  7156. var authoredDrillContextMenu = null;
  7157. if (typeof cognosViewerContextMenu != "undefined" && cognosViewerContextMenu != null)
  7158. {
  7159. authoredDrillContextMenu = cognosViewerContextMenu.getGoToMenuItem().getMenu();
  7160. }
  7161. if(authoredDrillDropDownMenu != null || authoredDrillContextMenu != null)
  7162. {
  7163. var drillTargetSpecifications = this.getCognosViewer().getDrillTargets();
  7164. var rvDrillTargetsNode = this.getAuthoredDrillThroughContext(rvDrillTargetsSpecification, drillTargetSpecifications);
  7165. var drillTargets = rvDrillTargetsNode.childNodes;
  7166. if(drillTargets.length > 0)
  7167. {
  7168. for(var index = 0; index < drillTargets.length; ++index)
  7169. {
  7170. var drillTarget = drillTargets[index];
  7171. var sRequestString = getCognosViewerObjectRefAsString(this.getCognosViewer().getId()) + ".m_oDrillMgr.executeAuthoredDrill(\"" + encodeURIComponent(XMLBuilderSerializeNode(drillTarget)) + "\");";
  7172. var sIconPath = this.getTargetReportIconPath(drillTarget);
  7173. var sLabel = drillTarget.getAttribute("label");
  7174. if(isViewerBidiEnabled()){
  7175. var bidi = BidiUtils.getInstance();
  7176. sLabel = bidi.btdInjectUCCIntoStr(sLabel, getViewerBaseTextDirection());
  7177. }
  7178. if (authoredDrillDropDownMenu != null)
  7179. {
  7180. new CMenuItem(authoredDrillDropDownMenu, sLabel, sRequestString, sIconPath, gMenuItemStyle, viewer.getWebContentRoot(), viewer.getSkin());
  7181. }
  7182. if (authoredDrillContextMenu != null)
  7183. {
  7184. new CMenuItem(authoredDrillContextMenu, sLabel, sRequestString, sIconPath, gMenuItemStyle, viewer.getWebContentRoot(), viewer.getSkin());
  7185. }
  7186. }
  7187. }
  7188. }
  7189. };
  7190. AuthoredDrillAction.prototype.buildSelectionChoicesNilSpecification = function()
  7191. {
  7192. return "<selectChoices/>";
  7193. };
  7194. AuthoredDrillAction.prototype.buildSelectionChoicesSpecification = function(drillParameterNode)
  7195. {
  7196. var sSelectionChoicesSpecification = "";
  7197. var sValue = drillParameterNode.getAttribute("value");
  7198. if(sValue != null)
  7199. {
  7200. var propToPass = drillParameterNode.getAttribute("propertyToPass");
  7201. sSelectionChoicesSpecification += "<selectChoices";
  7202. if (propToPass != null && propToPass != "")
  7203. {
  7204. sSelectionChoicesSpecification += " propertyToPass=\"";
  7205. sSelectionChoicesSpecification += sXmlEncode(propToPass);
  7206. sSelectionChoicesSpecification += "\"";
  7207. }
  7208. sSelectionChoicesSpecification += ">";
  7209. // if RSVP already generated the selectChoices, grab everything AFTER the <selectChoices>
  7210. if(sValue.indexOf("<selectChoices>") != -1)
  7211. {
  7212. sSelectionChoicesSpecification += sValue.substring(sValue.indexOf("<selectChoices>") + 15);
  7213. }
  7214. else if(sValue != "")
  7215. {
  7216. sSelectionChoicesSpecification += "<selectOption ";
  7217. var sMun = drillParameterNode.getAttribute("mun");
  7218. if(sMun != null && sMun != "")
  7219. {
  7220. var encodedMun = sXmlEncode(sMun);
  7221. sSelectionChoicesSpecification += "useValue=\"";
  7222. sSelectionChoicesSpecification += encodedMun;
  7223. sSelectionChoicesSpecification += "\" ";
  7224. sSelectionChoicesSpecification += "mun=\"";
  7225. sSelectionChoicesSpecification += encodedMun;
  7226. sSelectionChoicesSpecification += "\" ";
  7227. sSelectionChoicesSpecification += "displayValue=\"";
  7228. sSelectionChoicesSpecification += sXmlEncode(sValue);
  7229. sSelectionChoicesSpecification += "\"";
  7230. }
  7231. else
  7232. {
  7233. sSelectionChoicesSpecification += "useValue=\"";
  7234. sSelectionChoicesSpecification += sXmlEncode(sValue);
  7235. sSelectionChoicesSpecification += "\" ";
  7236. var sDisplayValue = drillParameterNode.getAttribute("displayValue");
  7237. if(sDisplayValue == null || sDisplayValue == "")
  7238. {
  7239. sDisplayValue = sValue;
  7240. }
  7241. sSelectionChoicesSpecification += "displayValue=\"";
  7242. sSelectionChoicesSpecification += sXmlEncode(sDisplayValue);
  7243. sSelectionChoicesSpecification += "\"";
  7244. }
  7245. sSelectionChoicesSpecification += "/>";
  7246. sSelectionChoicesSpecification += "</selectChoices>";
  7247. }
  7248. }
  7249. return sSelectionChoicesSpecification;
  7250. };
  7251. AuthoredDrillAction.prototype.getPropertyToPass = function(parameterName, parameterProperties)
  7252. {
  7253. if (parameterName != null && parameterName != "" && parameterProperties != null)
  7254. {
  7255. var parameterNodes = parameterProperties.childNodes;
  7256. if (parameterNodes != null)
  7257. {
  7258. for(var index = 0; index < parameterNodes.length; ++index)
  7259. {
  7260. var parameterNode = parameterNodes[index];
  7261. var sName = "";
  7262. if (parameterNode.getAttribute("name") != null)
  7263. {
  7264. sName = parameterNode.getAttribute("name");
  7265. }
  7266. if (sName == parameterName)
  7267. {
  7268. return parameterNode.getAttribute("propertyToPass");
  7269. }
  7270. }
  7271. }
  7272. }
  7273. return "";
  7274. };
  7275. AuthoredDrillAction.prototype.getTargetReportRequestString = function(drillTargetNode)
  7276. {
  7277. var sRequestString = "";
  7278. var sBookmarkRef = drillTargetNode.getAttribute("bookmarkRef");
  7279. var sTargetPath = drillTargetNode.getAttribute("path");
  7280. var sShowInNewWindow = drillTargetNode.getAttribute("showInNewWindow");
  7281. if((sBookmarkRef != null && sBookmarkRef != "") && (sTargetPath == null || sTargetPath == ""))
  7282. {
  7283. sRequestString += "document.location=\"#";
  7284. sRequestString += sBookmarkRef;
  7285. sRequestString += "\";";
  7286. }
  7287. else
  7288. {
  7289. sRequestString += "doSingleDrill(";
  7290. if(sShowInNewWindow == "true")
  7291. {
  7292. sRequestString += "\"_blank\",";
  7293. }
  7294. else
  7295. {
  7296. sRequestString += "\"\",";
  7297. }
  7298. sRequestString += "[[\"obj\",\"";
  7299. sRequestString += encodeURIComponent(sTargetPath);
  7300. sRequestString += "\"]";
  7301. var drillParameterNodes = XMLHelper_FindChildrenByTagName(drillTargetNode, "drillParameter", false);
  7302. for(var index = 0; index < drillParameterNodes.length; ++index)
  7303. {
  7304. var drillParameterNode = drillParameterNodes[index];
  7305. var sValue = drillParameterNode.getAttribute("value");
  7306. var sName = drillParameterNode.getAttribute("name");
  7307. if(sValue != null && sValue != "")
  7308. {
  7309. sRequestString += ", [\"p_" + sName + "\",\"" + encodeURIComponent(this.buildSelectionChoicesSpecification(drillParameterNode)) + "\"]";
  7310. }
  7311. var sNil = drillParameterNode.getAttribute("nil");
  7312. if(sNil != null && sNil != "")
  7313. {
  7314. sRequestString += "\", [\"p_" + sName + "\",\"" + encodeURIComponent(this.buildSelectionChoicesNilSpecification()) + "\"]";
  7315. }
  7316. }
  7317. sRequestString += "],";
  7318. var sMethod = drillTargetNode.getAttribute("method");
  7319. sRequestString += "\"" + encodeURIComponent(sMethod) + "\",";
  7320. var sOutputFormat = drillTargetNode.getAttribute("outputFormat");
  7321. sRequestString += "\"" + encodeURIComponent(sOutputFormat) + "\",";
  7322. var sOutputLocale = drillTargetNode.getAttribute("outputLocale");
  7323. sRequestString += "\"" + encodeURIComponent(sOutputLocale) + "\",";
  7324. sRequestString += "\"" + encodeURIComponent(sBookmarkRef) + "\",";
  7325. var sSourceContext = XMLBuilderSerializeNode(XMLHelper_FindChildByTagName(drillTargetNode, "parameters", false));
  7326. sRequestString += "\"" + encodeURIComponent(sSourceContext) + "\",";
  7327. var sObjectPaths = XMLBuilderSerializeNode(XMLHelper_FindChildByTagName(drillTargetNode, "objectPaths", false));
  7328. sRequestString += "\"" + encodeURIComponent(sObjectPaths) + "\",";
  7329. sRequestString += "\"" + encodeURIComponent(this.getCognosViewer().getId()) + "\",";
  7330. var sPrompt = drillTargetNode.getAttribute("prompt");
  7331. sRequestString += "\"" + encodeURIComponent(sPrompt) + "\",";
  7332. var dynamicDrill = drillTargetNode.getAttribute("dynamicDrill");
  7333. sRequestString += " " + encodeURIComponent(dynamicDrill);
  7334. sRequestString += ");";
  7335. }
  7336. return sRequestString;
  7337. };
  7338. AuthoredDrillAction.prototype.getTargetReportIconPath = function(drillTarget)
  7339. {
  7340. var sIconPath = "";
  7341. var sBookmarkRef = drillTarget.getAttribute("bookmarkRef");
  7342. var drillParameterNode = XMLHelper_FindChildByTagName(drillTarget, "drillParameter", false);
  7343. if((sBookmarkRef != null && sBookmarkRef != "") && drillParameterNode == null)
  7344. {
  7345. sIconPath = "/common/images/spacer.gif";
  7346. }
  7347. else
  7348. {
  7349. var sMethod = drillTarget.getAttribute("method");
  7350. switch(sMethod)
  7351. {
  7352. case "editAnalysis":
  7353. sIconPath = "/ps/portal/images/icon_ps_analysis.gif";
  7354. break;
  7355. case "editQuery":
  7356. sIconPath = "/ps/portal/images/icon_qs_query.gif";
  7357. break;
  7358. case "execute":
  7359. sIconPath = "/ps/portal/images/action_run.gif";
  7360. break;
  7361. case "view":
  7362. var sOutputFormat = drillTarget.getAttribute("outputFormat");
  7363. switch(sOutputFormat)
  7364. {
  7365. case "HTML":
  7366. case "XHTML":
  7367. case "HTMLFragment":
  7368. sIconPath = "/ps/portal/images/icon_result_html.gif";
  7369. break;
  7370. case "PDF":
  7371. sIconPath = "/ps/portal/images/icon_result_pdf.gif";
  7372. break;
  7373. case "XML":
  7374. sIconPath = "/ps/portal/images/icon_result_xml.gif";
  7375. break;
  7376. case "CSV":
  7377. sIconPath = "/ps/portal/images/icon_result_csv.gif";
  7378. break;
  7379. case "XLS":
  7380. sIconPath = "/ps/portal/images/icon_result_excel.gif";
  7381. break;
  7382. case "SingleXLS":
  7383. sIconPath = "/ps/portal/images/icon_result_excel_single.gif";
  7384. break;
  7385. case "XLWA":
  7386. sIconPath = "/ps/portal/images/icon_result_excel_web_arch.gif";
  7387. break;
  7388. default:
  7389. sIconPath = "/common/images/spacer.gif";
  7390. }
  7391. break;
  7392. default:
  7393. sIconPath = "/common/images/spacer.gif";
  7394. }
  7395. }
  7396. return this.getCognosViewer().getWebContentRoot() + sIconPath;
  7397. };
  7398. AuthoredDrillAction.prototype.getAuthoredDrillThroughContext = function(sAuthoredDrillThroughTargets, drillTargetSpecifications)
  7399. {
  7400. // validate the incoming arguments
  7401. if(typeof sAuthoredDrillThroughTargets != "string" || typeof drillTargetSpecifications != "object")
  7402. {
  7403. return null;
  7404. }
  7405. // parse the xml string and validate it
  7406. var xmlParsedDrillTargets = XMLBuilderLoadXMLFromString(sAuthoredDrillThroughTargets);
  7407. if(xmlParsedDrillTargets == null || xmlParsedDrillTargets.firstChild == null)
  7408. {
  7409. return null;
  7410. }
  7411. // validate the root node
  7412. var rootNode = XMLHelper_GetFirstChildElement( xmlParsedDrillTargets );
  7413. if(XMLHelper_GetLocalName(rootNode) != "AuthoredDrillTargets")
  7414. {
  7415. return null;
  7416. }
  7417. // validate the rvDrillTargets node
  7418. var rvDrillTargetNodes = XMLHelper_GetFirstChildElement( rootNode );
  7419. if(XMLHelper_GetLocalName(rvDrillTargetNodes) != "rvDrillTargets")
  7420. {
  7421. return null;
  7422. }
  7423. // validate the drillTargets node
  7424. var drillTargets = rvDrillTargetNodes.childNodes;
  7425. if(drillTargets === null || drillTargets.length === 0)
  7426. {
  7427. return null;
  7428. }
  7429. var rvDrillTargetsElement = self.XMLBuilderCreateXMLDocument("rvDrillTargets");
  7430. for(var drillTargetIdx = 0; drillTargetIdx < drillTargets.length; ++drillTargetIdx)
  7431. {
  7432. if(typeof drillTargets[drillTargetIdx].getAttribute == "undefined")
  7433. {
  7434. continue;
  7435. }
  7436. var drillTargetElement = rvDrillTargetsElement.createElement("drillTarget");
  7437. rvDrillTargetsElement.documentElement.appendChild(drillTargetElement);
  7438. var bookmarkRef = drillTargets[drillTargetIdx].getAttribute("bookmarkRef");
  7439. if(bookmarkRef === null)
  7440. {
  7441. drillTargetElement.setAttribute("bookmarkRef", "");
  7442. }
  7443. else
  7444. {
  7445. drillTargetElement.setAttribute("bookmarkRef", bookmarkRef);
  7446. }
  7447. var bookmarkPage = drillTargets[drillTargetIdx].getAttribute("bookmarkPage");
  7448. if(bookmarkPage === null)
  7449. {
  7450. drillTargetElement.setAttribute("bookmarkPage", "");
  7451. }
  7452. else
  7453. {
  7454. drillTargetElement.setAttribute("bookmarkPage", bookmarkPage);
  7455. }
  7456. var drillTargetRefIdx = drillTargets[drillTargetIdx].getAttribute("drillIdx");
  7457. if(drillTargetRefIdx == null)
  7458. {
  7459. continue;
  7460. }
  7461. if(drillTargetRefIdx >= drillTargetSpecifications.length)
  7462. {
  7463. continue;
  7464. }
  7465. var drillTargetRef = drillTargetSpecifications[drillTargetRefIdx];
  7466. if(typeof drillTargetRef != "object")
  7467. {
  7468. continue;
  7469. }
  7470. drillTargetElement.setAttribute("outputFormat", drillTargetRef.getOutputFormat());
  7471. drillTargetElement.setAttribute("outputLocale", drillTargetRef.getOutputLocale());
  7472. drillTargetElement.setAttribute("prompt", drillTargetRef.getPrompt());
  7473. drillTargetElement.setAttribute("dynamicDrill", drillTargetRef.isDynamicDrillThrough() ? "true" : "false");
  7474. var useLabel = drillTargets[drillTargetIdx].getAttribute("label");
  7475. if(useLabel === null || useLabel === "")
  7476. {
  7477. useLabel = drillTargetRef.getLabel();
  7478. }
  7479. drillTargetElement.setAttribute("label", useLabel);
  7480. drillTargetElement.setAttribute("path", drillTargetRef.getPath());
  7481. drillTargetElement.setAttribute("showInNewWindow", drillTargetRef.getShowInNewWindow());
  7482. drillTargetElement.setAttribute("method", drillTargetRef.getMethod());
  7483. var currentRvDrillTargetNode = rvDrillTargetNodes;
  7484. var oParameterProperties = "";
  7485. var drillTargetParamProps = drillTargetRef.getParameterProperties();
  7486. if (typeof drillTargetParamProps != "undefined" && drillTargetParamProps != null && drillTargetParamProps != "")
  7487. {
  7488. oParameterProperties = XMLHelper_GetFirstChildElement(XMLBuilderLoadXMLFromString(drillTargetRef.getParameterProperties()));
  7489. }
  7490. while(currentRvDrillTargetNode)
  7491. {
  7492. var drillParameters = currentRvDrillTargetNode.childNodes[drillTargetIdx].childNodes;
  7493. for(var drillParamIdx = 0; drillParamIdx < drillParameters.length; ++drillParamIdx)
  7494. {
  7495. var drillParameterElement = drillParameters[drillParamIdx].cloneNode(true);
  7496. if (oParameterProperties)
  7497. {
  7498. var propertyToPass = this.getPropertyToPass(drillParameterElement.getAttribute("name"), oParameterProperties);
  7499. if (propertyToPass != null && propertyToPass != "")
  7500. {
  7501. drillParameterElement.setAttribute("propertyToPass", propertyToPass);
  7502. }
  7503. }
  7504. drillTargetElement.appendChild(drillParameterElement);
  7505. }
  7506. currentRvDrillTargetNode = currentRvDrillTargetNode.nextSibling;
  7507. }
  7508. var rootOpenTag = '<root xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
  7509. var rootCloseTag = '</root>';
  7510. var drillTargetParametersString = rootOpenTag + drillTargetRef.getParameters() + rootCloseTag;
  7511. var drillTargetParametersXML = XMLBuilderLoadXMLFromString(drillTargetParametersString);
  7512. var oChild = XMLHelper_GetFirstChildElement( XMLHelper_GetFirstChildElement( drillTargetParametersXML ) );
  7513. if (oChild)
  7514. {
  7515. drillTargetElement.appendChild(oChild.cloneNode(true));
  7516. }
  7517. var drillTargetObjectPathsString = rootOpenTag + drillTargetRef.getObjectPaths() + rootCloseTag;
  7518. var drillTargetObjectPathsXML = XMLBuilderLoadXMLFromString(drillTargetObjectPathsString);
  7519. oChild = XMLHelper_GetFirstChildElement( XMLHelper_GetFirstChildElement( drillTargetObjectPathsXML ) );
  7520. if (oChild)
  7521. {
  7522. drillTargetElement.appendChild(oChild.cloneNode(true));
  7523. }
  7524. }
  7525. return XMLHelper_GetFirstChildElement(rvDrillTargetsElement);
  7526. };
  7527. /*
  7528. *+------------------------------------------------------------------------+
  7529. *| Licensed Materials - Property of IBM
  7530. *| IBM Cognos Products: Viewer
  7531. *| (C) Copyright IBM Corp. 2001, 2013
  7532. *|
  7533. *| US Government Users Restricted Rights - Use, duplication or
  7534. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7535. *|
  7536. *+------------------------------------------------------------------------+
  7537. */
  7538. function ChangeDisplayTypeAction()
  7539. {
  7540. this.m_requestParams = null;
  7541. this.m_sAction = 'ChangeDataContainerType';
  7542. this.m_iMAX_NUM_SUGGESTED_DISPLAY_TYPES = 5;
  7543. }
  7544. //base class for change display type action
  7545. ChangeDisplayTypeAction.prototype = new ModifyReportAction();
  7546. ChangeDisplayTypeAction.prototype.getUndoHint = function()
  7547. {
  7548. return RV_RES.IDS_JS_CHANGE_DISPLAY;
  7549. };
  7550. ChangeDisplayTypeAction.prototype.setRequestParms = function(parms)
  7551. {
  7552. this.m_requestParams = parms;
  7553. };
  7554. ChangeDisplayTypeAction.prototype.addActionContextAdditionalParms = function()
  7555. {
  7556. this._cleaerPinAndFreeze();
  7557. var bestVisualization = false;
  7558. if (this.m_requestParams.bestVisualization) {
  7559. bestVisualization = true;
  7560. } else if (((this.m_requestParams.targetType.targetType == undefined) ||
  7561. (this.m_requestParams.targetType.targetType == "undefined")) &&
  7562. (this.m_requestParams.targetType.templateId == undefined))
  7563. {
  7564. var paramObject = eval("(" + this.m_requestParams.targetType + ")"); //from dialog.
  7565. } else {
  7566. var paramObject = this.m_requestParams.targetType; //from dialog.
  7567. }
  7568. var canvas = this.m_oCV.getViewerWidget().findContainerDiv();
  7569. var sWidgetSize = "";
  7570. if (canvas) {
  7571. sWidgetSize = "<widgetWidth>" + (parseInt(canvas.style.width, 10) -ResizeChartAction.PADDING.getWidth()) + "px</widgetWidth>" +
  7572. "<widgetHeight>" + (parseInt(canvas.style.height, 10) - ResizeChartAction.PADDING.getHeight()) + "px</widgetHeight>";
  7573. }
  7574. var sActionContext = "";
  7575. if (bestVisualization) {
  7576. sActionContext += "<bestVisualization>true</bestVisualization>"
  7577. sActionContext += this.getDataItemInfoMap();
  7578. } else {
  7579. sActionContext += "<target>";
  7580. sActionContext += paramObject.targetType;
  7581. sActionContext += "</target>";
  7582. if (paramObject.templateId) {
  7583. sActionContext += "<templateId>";
  7584. sActionContext += ((paramObject.templateId)? paramObject.templateId : "");
  7585. sActionContext += "</templateId>";
  7586. sActionContext += "<variationId>";
  7587. sActionContext += ((paramObject.variationId)? paramObject.variationId : "");
  7588. sActionContext += "</variationId>";
  7589. sActionContext += this.getDataItemInfoMap();
  7590. }
  7591. sActionContext += "<label>";
  7592. sActionContext += paramObject.label;
  7593. sActionContext += "</label>";
  7594. }
  7595. sActionContext += sWidgetSize;
  7596. sActionContext += this.addClientContextData(/*maxValuesPerRDI*/3);
  7597. return (sActionContext);
  7598. };
  7599. ChangeDisplayTypeAction.prototype._cleaerPinAndFreeze = function() {
  7600. var pinFreezeManager = this.m_oCV.getPinFreezeManager();
  7601. if (pinFreezeManager) {
  7602. var containerId = this.getContainerId(this.m_oCV.getSelectionController());
  7603. pinFreezeManager.clearPinInfo(containerId);
  7604. }
  7605. };
  7606. ChangeDisplayTypeAction.prototype.updateMenu = function(jsonSpec)
  7607. {
  7608. var oRAPReportInfo = this.getCognosViewer().getRAPReportInfo();
  7609. jsonSpec.visible = (oRAPReportInfo) ? oRAPReportInfo.containsInteractiveDataContainer() : jsonSpec.visible;
  7610. if (! jsonSpec.visible)
  7611. {
  7612. return jsonSpec;
  7613. }
  7614. var reportInfo = this.getSelectedReportInfo();
  7615. jsonSpec.disabled = (reportInfo == null || reportInfo.displayTypeId == null || !this.isInteractiveDataContainer(reportInfo.displayTypeId));
  7616. if (jsonSpec.disabled)
  7617. {
  7618. jsonSpec.iconClass = "chartTypesDisabled";
  7619. return jsonSpec;
  7620. }
  7621. jsonSpec.iconClass = "chartTypes";
  7622. return this.buildDynamicMenuItem(jsonSpec, "ChangeDisplayType");
  7623. };
  7624. ChangeDisplayTypeAction.prototype.createEmptyMenuItem = function()
  7625. {
  7626. return {name: "None", label: RV_RES.IDS_JS_CHANGE_DISPLAY_SELECT_DATA, iconClass: "", action: null, items: null };
  7627. };
  7628. ChangeDisplayTypeAction.prototype.getActionContextString = function(groupId)
  7629. {
  7630. var actionContext = "<getInfoActions>";
  7631. actionContext += "<getInfoAction name=\"GetInfo\">";
  7632. actionContext += "<include><suggestedDisplayTypes/></include>";
  7633. actionContext += this.getDataItemInfoMap();
  7634. actionContext += "<groupId>";
  7635. actionContext += groupId;
  7636. actionContext += "</groupId>";
  7637. actionContext += this.addClientContextData(/*maxValuesPerRDI*/3);
  7638. actionContext += "</getInfoAction>";
  7639. actionContext += "</getInfoActions>";
  7640. return actionContext;
  7641. };
  7642. ChangeDisplayTypeAction.prototype.fetchSuggestedDisplayTypes = function(groupId)
  7643. {
  7644. var oCV = this.getCognosViewer();
  7645. var asynchRequest = new AsynchJSONDispatcherEntry(oCV);
  7646. asynchRequest.addFormField("ui.action", "getInfoFromReportSpec");
  7647. asynchRequest.addFormField("bux", "true");
  7648. asynchRequest.addFormField("ui.object", oCV.envParams["ui.object"]);
  7649. asynchRequest.addFormField("cv.actionContext", this.getActionContextString(groupId));
  7650. asynchRequest.addDefinedFormField("ui.spec", oCV.envParams["ui.spec"]);
  7651. asynchRequest.addNonEmptyStringFormField("modelPath", oCV.getModelPath());
  7652. if (groupId == "undefined") {
  7653. asynchRequest.setCallbacks({"complete" : {"object" : this, "method" : this.handleSuggestedDisplayTypesResponse}});
  7654. } else {
  7655. asynchRequest.setCallbacks({"complete" : {"object" : this, "method" : this.handleSuggestedDisplayVariationsResponse}});
  7656. }
  7657. oCV.dispatchRequest(asynchRequest);
  7658. };
  7659. ChangeDisplayTypeAction.prototype.handleSuggestedDisplayTypesResponse = function(asynchJSONResponse)
  7660. {
  7661. var viewer = this.getCognosViewer();
  7662. var viewerWidget = viewer.getViewerWidget();
  7663. this.addSuggestedDisplayTypesMenuItems(asynchJSONResponse.getResult());
  7664. };
  7665. ChangeDisplayTypeAction.prototype.addSuggestedDisplayTypesMenuItems = function (reportInfos)
  7666. {
  7667. var buttonSpec = this.getCognosViewer().findToolbarItem("ChangeDisplayType");
  7668. if (buttonSpec) {
  7669. buttonSpec.open = false;
  7670. }
  7671. var menuItems = [];
  7672. var reportInfo = this.getSelectedReportInfo();
  7673. var container = undefined;
  7674. for (var x=0; x < reportInfos.containers.length; x++)
  7675. {
  7676. if (reportInfo.container == reportInfos.containers[x].container)
  7677. {
  7678. container = reportInfos.containers[x];
  7679. break;
  7680. }
  7681. }
  7682. if (container == undefined)
  7683. {
  7684. return;
  7685. }
  7686. var nbrToDisplay = container.suggestedDisplayTypes.length <= this.m_iMAX_NUM_SUGGESTED_DISPLAY_TYPES ? container.suggestedDisplayTypes.length : this.m_iMAX_NUM_SUGGESTED_DISPLAY_TYPES;
  7687. menuItems.push({title: RV_RES.IDS_JS_CHANGE_DISPLAY_RECOMMENDED});
  7688. menuItems.push({separator: true});
  7689. for (var i=0; i < nbrToDisplay; i++)
  7690. {
  7691. menuItems.push({ name: container.suggestedDisplayTypes[i].name, label: container.suggestedDisplayTypes[i].title, description: container.suggestedDisplayTypes[i].description, iconClass: container.suggestedDisplayTypes[i].iconClass, action: { name: "ChangeDisplayType", payload: {targetType: {templateId: container.suggestedDisplayTypes[i].templateId }, label: container.suggestedDisplayTypes[i].title}}, items: null });
  7692. }
  7693. menuItems.push({separator: true});
  7694. menuItems.push({ name: "ChangeDisplayMore", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_MORE, iconClass: "ChartTypeOther", action: { name: "InvokeChangeDisplayTypeDialog", payload: {}}, items: null });
  7695. buttonSpec.open = true;
  7696. buttonSpec.items = menuItems;
  7697. var updateItems = [];
  7698. updateItems.push(buttonSpec);
  7699. this.getCognosViewer().getViewerWidget().fireEvent("com.ibm.bux.widgetchrome.toolbar.update", null, updateItems);
  7700. return menuItems;
  7701. };
  7702. ChangeDisplayTypeAction.prototype.buildMenu = function(jsonSpec)
  7703. {
  7704. var oRAPReportInfo = this.getCognosViewer().getRAPReportInfo();
  7705. jsonSpec.visible = (oRAPReportInfo) ? oRAPReportInfo.containsInteractiveDataContainer() : jsonSpec.visible;
  7706. if (! jsonSpec.visible)
  7707. {
  7708. return jsonSpec;
  7709. }
  7710. var reportInfo = this.getSelectedReportInfo();
  7711. jsonSpec.disabled = (reportInfo == null || reportInfo.displayTypeId == null || !this.isInteractiveDataContainer(reportInfo.displayTypeId));
  7712. if (jsonSpec.disabled)
  7713. {
  7714. jsonSpec.iconClass = "chartTypesDisabled";
  7715. }
  7716. else
  7717. {
  7718. jsonSpec.iconClass = "chartTypes";
  7719. var enableVisCoach = this.getCognosViewer().getAdvancedServerProperty("VIEWER_JS_enableVisCoach");
  7720. if (enableVisCoach !== 'false' && (typeof reportInfo.suggestedDisplayTypesEnabled != "undefined") && (reportInfo.suggestedDisplayTypesEnabled != null) && (reportInfo.suggestedDisplayTypesEnabled == "true"))
  7721. {
  7722. //toolbar menu, so generate the dynamic menu
  7723. this.fetchSuggestedDisplayTypes("undefined");
  7724. return this.buildDynamicMenuItem(jsonSpec, "ChangeDisplayType");
  7725. }
  7726. else
  7727. {
  7728. jsonSpec.items = [];
  7729. var isV2 = (reportInfo.displayTypeId.match("v2_") != null || reportInfo.displayTypeId == "crosstab" || reportInfo.displayTypeId == "list");
  7730. if(isV2)
  7731. {
  7732. jsonSpec.items.push({ name: "ChangeDisplayBar", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_BAR, iconClass: "ChartTypeBar", action: { name: "ChangeDisplayType", payload: {targetType: "v2_bar_rectangle_clustered" }}, items: null });
  7733. jsonSpec.items.push({ name: "ChangeDisplayColumn", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_COLUMN, iconClass: "ChartTypeColumn", action: { name: "ChangeDisplayType", payload: {targetType: "v2_column_rectangle_clustered" }}, items: null });
  7734. jsonSpec.items.push({ name: "ChangeDisplayLine", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_LINE, iconClass: "ChartTypeLine", action: { name: "ChangeDisplayType", payload: {targetType: "v2_line_clustered_markers" }}, items: null });
  7735. jsonSpec.items.push({ name: "ChangeDisplayPie", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_PIE, iconClass: "ChartTypePie", action: { name: "ChangeDisplayType", payload: {targetType: "v2_pie" }}, items: null });
  7736. jsonSpec.items.push({ name: "ChangeDisplayCrosstab", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_CROSSTAB, iconClass: "ChartTypeCrosstab", action: { name: "ChangeDisplayType", payload: {targetType: "Crosstab" }}, items: null });
  7737. jsonSpec.items.push({ name: "ChangeDisplayList", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_LIST, iconClass: "ChartTypeList", action: { name: "ChangeDisplayType", payload: {targetType: "List" }}, items: null });
  7738. jsonSpec.items.push({ name: "ChangeDisplayMore", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_MORE, iconClass: "ChartTypeOther", action: { name: "InvokeChangeDisplayTypeDialog", payload: "" }, items: null });
  7739. }
  7740. else
  7741. {
  7742. jsonSpec.items.push({ name: "ChangeDisplayBar", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_BAR, iconClass: "ChartTypeBar", action: { name: "ChangeDisplayType", payload: {targetType: "bar_clustered_flat" }}, items: null });
  7743. jsonSpec.items.push({ name: "ChangeDisplayColumn", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_COLUMN, iconClass: "ChartTypeColumn", action: { name: "ChangeDisplayType", payload: {targetType: "column_clustered_flat" }}, items: null });
  7744. jsonSpec.items.push({ name: "ChangeDisplayLine", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_LINE, iconClass: "ChartTypeLine", action: { name: "ChangeDisplayType", payload: {targetType: "line_clustered_flat_markers" }}, items: null });
  7745. jsonSpec.items.push({ name: "ChangeDisplayPie", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_PIE, iconClass: "ChartTypePie", action: { name: "ChangeDisplayType", payload: {targetType: "pie_flat" }}, items: null });
  7746. jsonSpec.items.push({ name: "ChangeDisplayCrosstab", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_CROSSTAB, iconClass: "ChartTypeCrosstab", action: { name: "ChangeDisplayType", payload: {targetType: "Crosstab" }}, items: null });
  7747. jsonSpec.items.push({ name: "ChangeDisplayList", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_LIST, iconClass: "ChartTypeList", action: { name: "ChangeDisplayType", payload: {targetType: "List" }}, items: null });
  7748. jsonSpec.items.push({ name: "ChangeDisplayMore", label: RV_RES.IDS_JS_CHANGE_DISPLAY_TYPE_MORE, iconClass: "ChartTypeOther", action: { name: "InvokeChangeDisplayTypeDialog", payload: "" }, items: null });
  7749. }
  7750. }
  7751. for (var i in jsonSpec.items)
  7752. {
  7753. jsonSpec.items[i].action.payload = { targetType: jsonSpec.items[i].action.payload };
  7754. jsonSpec.items[i].action.payload.targetType.label = jsonSpec.items[i].label;
  7755. }
  7756. }
  7757. return jsonSpec;
  7758. };
  7759. /*
  7760. *+------------------------------------------------------------------------+
  7761. *| Licensed Materials - Property of IBM
  7762. *| IBM Cognos Products: Viewer
  7763. *| (C) Copyright IBM Corp. 2001, 2011
  7764. *|
  7765. *| US Government Users Restricted Rights - Use, duplication or
  7766. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7767. *|
  7768. *+------------------------------------------------------------------------+
  7769. */
  7770. function ChangeDisplayVariationsAction(){}
  7771. ChangeDisplayVariationsAction.prototype = new CognosViewerAction();
  7772. function ChangeDisplayVariationsAction()
  7773. {
  7774. this.m_requestParams = null;
  7775. }
  7776. ChangeDisplayVariationsAction.prototype.setRequestParms = function(parms)
  7777. {
  7778. this.m_requestParams = parms;
  7779. };
  7780. ChangeDisplayVariationsAction.prototype.execute = function() {
  7781. var groupId = this.m_requestParams.groupId; //from dialog.
  7782. var viewer = this.getCognosViewer();
  7783. var selectedObject = this.getSelectedReportInfo();
  7784. if(selectedObject)
  7785. {
  7786. var viewerWidget = viewer.getViewerWidget();
  7787. if (typeof selectedObject.suggestedDisplayVariations == "undefined")
  7788. {
  7789. var asynchRequest = new AsynchJSONDispatcherEntry(this.m_oCV);
  7790. asynchRequest.setCallbacks({
  7791. "complete": {"object": this, "method": this.handleResponse}
  7792. });
  7793. asynchRequest.setRequestIndicator(viewer.getRequestIndicator());
  7794. asynchRequest.addFormField("ui.action", "getInfoFromReportSpec");
  7795. asynchRequest.addFormField("bux", "true");
  7796. asynchRequest.addNonEmptyStringFormField("modelPath", this.m_oCV.getModelPath());
  7797. asynchRequest.addFormField("ui.object", this.m_oCV.envParams["ui.object"]);
  7798. asynchRequest.addDefinedFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  7799. asynchRequest.addFormField("cv.actionContext", this.addActionContext(groupId));
  7800. viewer.dispatchRequest(asynchRequest);
  7801. }
  7802. else
  7803. {
  7804. viewerWidget.updateDisplayTypeDialogVariations(selectedObject.possibleDisplayTypes,selectedObject.suggestedDisplayVariations );
  7805. }
  7806. }
  7807. };
  7808. ChangeDisplayVariationsAction.prototype.handleResponse = function(asynchJSONResponse)
  7809. {
  7810. var viewer = this.getCognosViewer();
  7811. var viewerWidget = viewer.getViewerWidget();
  7812. var reportInfos = asynchJSONResponse.getResult();
  7813. for ( var i in reportInfos.containers)
  7814. {
  7815. var selectedReportInfo = this.getReportInfo(reportInfos.containers[i].container);
  7816. selectedReportInfo.possibleDisplayTypes = reportInfos.containers[i].possibleDisplayTypes;
  7817. selectedReportInfo.variationGroups = reportInfos.containers[i].variationGroups;
  7818. }
  7819. var selectedObject = this.getSelectedReportInfo();
  7820. viewerWidget.updateDisplayTypeDialogVariations(selectedObject.possibleDisplayTypes,selectedObject.variationGroups);
  7821. };
  7822. ChangeDisplayVariationsAction.prototype.addActionContext = function(groupId)
  7823. {
  7824. var actionContext = "<getInfoActions>";
  7825. actionContext += "<getInfoAction name=\"GetInfo\">";
  7826. actionContext += "<include><suggestedDisplayVariations/></include>";
  7827. actionContext += this.getDataItemInfoMap();;
  7828. actionContext += this.addClientContextData(/*maxValuesPerRDI*/3);
  7829. actionContext += "<groupId>";
  7830. actionContext += groupId;
  7831. actionContext += "</groupId>";
  7832. actionContext += "</getInfoAction>";
  7833. actionContext += "</getInfoActions>";
  7834. return actionContext;
  7835. };
  7836. /*
  7837. *+------------------------------------------------------------------------+
  7838. *| Licensed Materials - Property of IBM
  7839. *| IBM Cognos Products: Viewer
  7840. *| (C) Copyright IBM Corp. 2001, 2011
  7841. *|
  7842. *| US Government Users Restricted Rights - Use, duplication or
  7843. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7844. *|
  7845. *+------------------------------------------------------------------------+
  7846. */
  7847. function ChangePaletteAction()
  7848. {
  7849. this.m_sAction = "ChangePalette";
  7850. this.m_palette = "";
  7851. this.m_runReport = true;
  7852. this.m_aPaletteNames = ["Flow", "Classic", "Contemporary",
  7853. "Contrast", "Corporate", "Dynamic",
  7854. "Excel", "Excel 2007", "Gradients",
  7855. "Grey Scale", "Jazz", "Legacy",
  7856. "Metro", "Mixed", "Modern",
  7857. "Patterns"];
  7858. this.m_aPaletteIcons = ["changePaletteFlow", "changePaletteClassic", "changePaletteContemporary",
  7859. "changePaletteContrast", "changePaletteCorporate", "changePaletteDynamic",
  7860. "changePaletteExcel", "changePaletteExcel2007", "changePaletteGradients",
  7861. "changePaletteGreyScale", "changePaletteJazz", "changePaletteLegacy",
  7862. "changePaletteMetro", "changePaletteMixed", "changePaletteModern",
  7863. "changePalettePatterns"];
  7864. }
  7865. ChangePaletteAction.prototype = new ModifyReportAction();
  7866. ChangePaletteAction.baseclass = ModifyReportAction.prototype;
  7867. ChangePaletteAction.prototype.reuseQuery = function() { return true; };
  7868. ChangePaletteAction.prototype.preProcess = function()
  7869. {
  7870. // check to see if the report only contains flash charts, if so, we don't need to hit the report service, we can change the palette locally
  7871. this.updateRunReport();
  7872. if (this.m_runReport==false) {
  7873. var flashCharts = this.getLayoutComponents();
  7874. for(var index = 0; index < flashCharts.length; ++index)
  7875. {
  7876. var flashChart = flashCharts[index];
  7877. if(flashChart.getAttribute("flashChart") != null)
  7878. {
  7879. if(this.m_palette == "")
  7880. {
  7881. flashChart.setPalette("Flow");
  7882. }
  7883. else
  7884. {
  7885. flashChart.setPalette(this.m_palette);
  7886. }
  7887. }
  7888. }
  7889. }
  7890. };
  7891. ChangePaletteAction.prototype.updateRunReport = function()
  7892. {
  7893. this.m_runReport=true;
  7894. var reportTable = document.getElementById("rt" + this.m_oCV.getId());
  7895. if(reportTable != null) {
  7896. var serverSideCharts = getElementsByAttribute(reportTable, "*", "chartcontainer", "true");
  7897. if(serverSideCharts.length == 0) {
  7898. this.m_runReport=false;
  7899. }
  7900. }
  7901. };
  7902. ChangePaletteAction.prototype.runReport = function()
  7903. {
  7904. return this.m_runReport;
  7905. };
  7906. ChangePaletteAction.prototype.updateInfoBar = function()
  7907. {
  7908. return false;
  7909. };
  7910. ChangePaletteAction.prototype.getUndoHint = function()
  7911. {
  7912. return RV_RES.IDS_JS_CHANGE_PALETTE;
  7913. };
  7914. ChangePaletteAction.prototype.setRequestParms = function(palette)
  7915. {
  7916. if(typeof palette == "string")
  7917. {
  7918. this.m_palette = palette;
  7919. // Preserve the information on the selected palette in CCognosViewer object for latter retrieval
  7920. // and use in ChangePaletteAction.prototype.updateMenu().
  7921. if (this.m_oCV != null && typeof this.m_oCV != "undefined")
  7922. {
  7923. this.m_oCV.m_sPalette = palette;
  7924. }
  7925. }
  7926. };
  7927. ChangePaletteAction.prototype.addActionContextAdditionalParms = function()
  7928. {
  7929. if(this.m_palette != "")
  7930. {
  7931. return "<name>" + this.m_palette + "</name>";
  7932. }
  7933. return "";
  7934. };
  7935. ChangePaletteAction.prototype.updateMenu = function(jsonSpec)
  7936. {
  7937. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  7938. if (! jsonSpec.visible)
  7939. {
  7940. return jsonSpec;
  7941. }
  7942. var reportInfo = this.getSelectedReportInfo();
  7943. if (reportInfo != null && reportInfo.displayTypeId.indexOf("Chart") >= 0)
  7944. {
  7945. jsonSpec.disabled = false;
  7946. return jsonSpec;
  7947. }
  7948. jsonSpec.disabled = true;
  7949. return jsonSpec;
  7950. };
  7951. ChangePaletteAction.reset = function( oCV )
  7952. {
  7953. delete (oCV.m_sPalette);
  7954. };
  7955. /*
  7956. *+------------------------------------------------------------------------+
  7957. *| Licensed Materials - Property of IBM
  7958. *| IBM Cognos Products: Viewer
  7959. *| (C) Copyright IBM Corp. 2001, 2011
  7960. *|
  7961. *| US Government Users Restricted Rights - Use, duplication or
  7962. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7963. *|
  7964. *+------------------------------------------------------------------------+
  7965. */
  7966. function DragDropAction()
  7967. {
  7968. this.m_source = null;
  7969. this.m_target = null;
  7970. this.m_insertBefore = false;
  7971. this.m_sAction = "Reorder";
  7972. }
  7973. DragDropAction.prototype = new ModifyReportAction();
  7974. DragDropAction.prototype.getUndoHint = function()
  7975. {
  7976. return RV_RES.IDS_JS_MOVE;
  7977. };
  7978. DragDropAction.prototype.getOffsetCoords = function(startAt)
  7979. {
  7980. var rtTable = document.getElementById("rt" + this.getCognosViewer().getId());
  7981. var offsetParent = startAt;
  7982. var topCoord = 0;
  7983. var leftCoord = 0;
  7984. while(offsetParent != rtTable)
  7985. {
  7986. topCoord += offsetParent.offsetTop;
  7987. leftCoord += offsetParent.offsetLeft;
  7988. offsetParent = offsetParent.offsetParent;
  7989. }
  7990. return { left: leftCoord, top: topCoord };
  7991. };
  7992. DragDropAction.prototype.showDragDropCaret = function(evt, cell, parentTable)
  7993. {
  7994. var dragDropCaret = document.getElementById("VDDC" + this.getCognosViewer().getId());
  7995. if(dragDropCaret == null)
  7996. {
  7997. dragDropCaret = document.createElement("span");
  7998. dragDropCaret.setAttribute("id", "VDDC" + this.getCognosViewer().getId());
  7999. dragDropCaret.className = "dropCaret";
  8000. if(dragDropCaret.attachEvent)
  8001. {
  8002. dragDropCaret.attachEvent("onmousemove", stopEventBubble);
  8003. }
  8004. else
  8005. {
  8006. dragDropCaret.addEventListener("mousemove", stopEventBubble, false);
  8007. }
  8008. dragDropCaret.style.width = "8px";
  8009. dragDropCaret.innerHTML = "<img style=\"margin:1px;width:2px;height:100%;\" src=\"" + this.getCognosViewer().getWebContentRoot() + "/rv/images/drop_caret.gif\"/>";
  8010. parentTable.appendChild(dragDropCaret);
  8011. }
  8012. var offsetCoords = this.getOffsetCoords(parentTable);
  8013. dragDropCaret.style.top = (offsetCoords.top - 1) + "px";
  8014. var eventXCoord;
  8015. if(typeof evt.offsetX == "undefined") {
  8016. eventXCoord = evt.layerX;
  8017. } else {
  8018. offsetCoords = this.getOffsetCoords(evt.srcElement);
  8019. eventXCoord = evt.offsetX + offsetCoords.left;
  8020. }
  8021. offsetCoords = this.getOffsetCoords(cell);
  8022. var halfWayPoint = offsetCoords.left + (cell.clientWidth / 2);
  8023. this.m_insertBefore = (eventXCoord < halfWayPoint);
  8024. dragDropCaret.style.height = parentTable.clientHeight + "px";
  8025. if(this.m_insertBefore == false)
  8026. {
  8027. dragDropCaret.style.left = (offsetCoords.left + cell.clientWidth + 1) + "px";
  8028. }
  8029. else
  8030. {
  8031. dragDropCaret.style.left = offsetCoords.left + "px";
  8032. }
  8033. dragDropCaret.style.display = "inline";
  8034. };
  8035. DragDropAction.prototype.showDragDropIndicators = function(evt)
  8036. {
  8037. if(this.m_target != null)
  8038. {
  8039. var cell = this.m_target.getCellRef();
  8040. var parentTable = cell;
  8041. while(parentTable.getAttribute("lid") == null)
  8042. {
  8043. parentTable = parentTable.parentNode;
  8044. }
  8045. this.showDragDropCaret(evt, cell, parentTable);
  8046. }
  8047. };
  8048. DragDropAction.prototype.showDragDropToolTip = function(evt)
  8049. {
  8050. var imageRef = "";
  8051. if(this.canDrop() == true)
  8052. {
  8053. imageRef = "/rv/images/cursor_move.gif";
  8054. }
  8055. else
  8056. {
  8057. imageRef = "/rv/images/cursor_nodrop.gif";
  8058. }
  8059. this.showCustomCursor(evt, "viewerTooltipSpan", imageRef);
  8060. };
  8061. DragDropAction.prototype.canMove = function()
  8062. {
  8063. if (this.m_oCV.isBlacklisted("Move")) {
  8064. return false;
  8065. }
  8066. var selectionController = this.getCognosViewer().getSelectionController();
  8067. this.m_source = selectionController.getAllSelectedObjects();
  8068. if(this.m_source != null && this.m_source.length > 0)
  8069. {
  8070. if(typeof this.m_source[0].m_dataContainerType != "undefined" && this.m_source[0].m_dataContainerType == "list" && this.m_source[0].getLayoutType() != "summary")
  8071. {
  8072. return true;
  8073. }
  8074. }
  8075. return false;
  8076. };
  8077. DragDropAction.prototype.onDrag = function(evt)
  8078. {
  8079. clearTextSelection();
  8080. var sourceNode = getNodeFromEvent(evt);
  8081. var selectionController = this.getCognosViewer().getSelectionController();
  8082. this.m_target = selectionController.buildSelectionObject(sourceNode, evt);
  8083. this.showDragDropToolTip(evt);
  8084. if(this.canDrop())
  8085. {
  8086. this.showDragDropIndicators(evt);
  8087. }
  8088. else
  8089. {
  8090. this.hideDropIndicators();
  8091. }
  8092. };
  8093. DragDropAction.prototype.hideDropIndicators = function()
  8094. {
  8095. var dragDropIndicator = document.getElementById("VDDC" + this.getCognosViewer().getId());
  8096. if(dragDropIndicator != null)
  8097. {
  8098. dragDropIndicator.style.display = "none";
  8099. }
  8100. };
  8101. DragDropAction.prototype.onMouseDown = function(evt)
  8102. {
  8103. if(this.canMove())
  8104. {
  8105. window.oCVDragDropObject = { action:this, x:evt.clientX, y:evt.clientY, dragging:false };
  8106. }
  8107. };
  8108. DragDropAction.prototype.canDrop = function()
  8109. {
  8110. return this.m_target != null && this.m_source != null && this.m_target.getLayoutType() != "summary" && (this.m_target.getLayoutElementId() == this.m_source[0].getLayoutElementId());
  8111. };
  8112. DragDropAction.prototype.onDrop = function(evt)
  8113. {
  8114. this.hideCustomCursor("viewerTooltipSpan");
  8115. this.hideDropIndicators();
  8116. if(this.canDrop(evt)) {
  8117. //Determine if the user's drop results in a change in column
  8118. //order. A user can change column order in one or more of
  8119. //three ways:
  8120. //1. Drag one or more columns to a new destination.
  8121. //2. Select multiple columns which are not next to each
  8122. // other - so wherever they are dropped, at least one
  8123. // will change position.
  8124. //3. Select multiple columns in a new order - so wherever
  8125. // they are dropped, the selected columns will be in a
  8126. // new configuration relative to each other.
  8127. //A reorder occurs iff one or more of these conditions are
  8128. //met. If no reorder occurs, don't make a server request.
  8129. var executeDrop = true;
  8130. //Determine if the selected columns are all next to each
  8131. //other and in the original order.
  8132. var column;
  8133. var first = parseInt(this.m_source[0].getColumnRef(), 10);
  8134. var last = first;
  8135. var consecutiveColumns = true;
  8136. for(var index = 0; index < this.m_source.length; ++index) {
  8137. column = parseInt(this.m_source[index].getColumnRef(), 10);
  8138. if(index > 0 && column !== last + 1) {
  8139. consecutiveColumns = false;
  8140. break;
  8141. }
  8142. last = column;
  8143. }
  8144. if(consecutiveColumns) {
  8145. //Determine if the columns are being moved to a new location
  8146. var destination = parseInt(this.m_target.getColumnRef(), 10);
  8147. destination += this.m_insertBefore ? 0 : 1;
  8148. if (destination >= first && destination <= last + 1) {
  8149. //None of the three ways to move a column is satisfied -
  8150. //don't execute the drop action.
  8151. executeDrop = false;
  8152. }
  8153. }
  8154. if(executeDrop) {
  8155. this.execute();
  8156. }
  8157. }
  8158. };
  8159. DragDropAction.prototype.addActionContextAdditionalParms = function()
  8160. {
  8161. var tag = this.m_insertBefore == true ? "before" : "after";
  8162. //always use layout tag when it is available.
  8163. var cellRef = this.m_target.getCellRef();
  8164. var tagValue = this.getRAPLayoutTag(cellRef);
  8165. tagValue = (tagValue != null ) ? tagValue : this.m_target.getColumnName();
  8166. return this.getSelectedCellTags() + "<" + tag + ">" + xml_encode(tagValue) + "</" + tag + ">";
  8167. };
  8168. function DragDropAction_isDragging(evt)
  8169. {
  8170. var oCVDDO = window.oCVDragDropObject;
  8171. if(oCVDDO)
  8172. {
  8173. var currentX = evt.clientX;
  8174. var currentY = evt.clientY;
  8175. var originalX = oCVDDO.x;
  8176. var originalY = oCVDDO.y;
  8177. if((currentX >= (originalX+2)) || (currentX <= (originalX-2)) || (currentY >= (originalY+2)) || (currentY <= (originalY-2)))
  8178. {
  8179. oCVDDO.dragging = true;
  8180. }
  8181. return oCVDDO.dragging;
  8182. }
  8183. return false;
  8184. }
  8185. function DragDropAction_onmouseup(evt)
  8186. {
  8187. if(DragDropAction_isDragging(evt))
  8188. {
  8189. window.oCVDragDropObject.action.onDrop(evt);
  8190. }
  8191. window.oCVDragDropObject = null;
  8192. }
  8193. function DragDropAction_onmousemove(evt)
  8194. {
  8195. if(DragDropAction_isDragging(evt))
  8196. {
  8197. window.oCVDragDropObject.action.onDrag(evt);
  8198. }
  8199. }
  8200. /*
  8201. *+------------------------------------------------------------------------+
  8202. *| Licensed Materials - Property of IBM
  8203. *| IBM Cognos Products: Viewer
  8204. *| (C) Copyright IBM Corp. 2001, 2013
  8205. *|
  8206. *| US Government Users Restricted Rights - Use, duplication or
  8207. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8208. *|
  8209. *+------------------------------------------------------------------------+
  8210. */
  8211. function DrillAction() {
  8212. this.m_bUseReportInfoSelection = false; //default is false
  8213. this.m_aDrillSelectedObjects = []; //local array to store selected objects
  8214. this.m_useMARequest = false; //flag to enable action arguments block for use ma instead V5 request for getting child/parent information
  8215. this.m_userSelectedDrillItem = null;
  8216. }
  8217. DrillAction.prototype = new ModifyReportAction();
  8218. DrillAction.prototype.getHoverClassName = function() { return ""; };
  8219. /**
  8220. * Only set when the user has picked a specific entry off of the drill down or up subMenu
  8221. */
  8222. DrillAction.prototype.setRequestParms = function(parms) {
  8223. if (parms) {
  8224. this.m_userSelectedDrillItem = parms.userSelectedDrillItem;
  8225. }
  8226. };
  8227. DrillAction.prototype.setKeepFocusOnWidget = function(keepFocus)
  8228. {
  8229. this.m_bKeepFocusOnWidget = keepFocus;
  8230. };
  8231. DrillAction.prototype.keepFocusOnWidget = function()
  8232. {
  8233. if (typeof this.m_bKeepFocusOnWidget != "undefined")
  8234. {
  8235. return this.m_bKeepFocusOnWidget;
  8236. }
  8237. return true;
  8238. };
  8239. DrillAction.prototype.getDrillabilityForItemFromReportInfo = function(itemName)
  8240. {
  8241. if( !this.m_oCV )
  8242. {
  8243. return null;
  8244. }
  8245. var reportInfo = this.m_oCV.getRAPReportInfo();
  8246. if(!reportInfo)
  8247. {
  8248. return null;
  8249. }
  8250. var containers = reportInfo.getContainers();
  8251. for( var container in containers )
  8252. {
  8253. var drillability = reportInfo.getDrillability(container);
  8254. if( drillability[itemName])
  8255. {
  8256. return drillability[itemName];
  8257. }
  8258. }
  8259. return null;
  8260. };
  8261. DrillAction.prototype.onDoubleClick = function(evt)
  8262. {
  8263. this.execute();
  8264. };
  8265. DrillAction.prototype.preProcess = function()
  8266. {
  8267. //should only have drill spec if handling a synchronize drill event - in which
  8268. //case we don't want to fire drill event again
  8269. if( typeof this.m_drillSpec === "undefined" || this.m_drillSpec === null )
  8270. {
  8271. var aDrillSpecObjects = this.generateDrillSpecObjects();
  8272. if (!aDrillSpecObjects) {
  8273. return null;
  8274. }
  8275. var oCognosViewer = this.getCognosViewer();
  8276. var oViewerWidget = oCognosViewer.getViewerWidget();
  8277. if (oViewerWidget) {
  8278. var sModelPath = oCognosViewer.getModelPath();
  8279. oViewerWidget.getWidgetContextManager().raiseDrillEvent(aDrillSpecObjects, this.m_sAction, sModelPath);
  8280. }
  8281. }
  8282. };
  8283. /*
  8284. * returns array of Drill spec object
  8285. *
  8286. * drill spec object has following properties
  8287. *
  8288. oDrillSpecObject = {
  8289. "dataItem": "",
  8290. "mun": "",
  8291. "lun": "",
  8292. "hun": "",
  8293. "displayValue": "",
  8294. "summary": "" //optional
  8295. };
  8296. */
  8297. DrillAction.prototype.generateDrillSpecObjects = function()
  8298. {
  8299. try
  8300. {
  8301. var aDrillSpecObjects = [];
  8302. var oCV = this.getCognosViewer();
  8303. var drillMgr = oCV.getDrillMgr();
  8304. var selectionController = oCV.getSelectionController();
  8305. var bIsSyncDrill = true;
  8306. var aDrillParams = drillMgr.getDrillParameters(this.m_drillOption, true, bIsSyncDrill, this.m_userSelectedDrillItem );
  8307. if (aDrillParams.length === 0) {
  8308. return null;
  8309. }
  8310. var oSelectedObject = drillMgr.getSelectedObject();
  8311. if (aDrillParams.length > 3*4 && (oSelectedObject.getDataContainerType() == "crosstab" || oSelectedObject.getLayoutType() == "chartElement" )) {
  8312. //In drillParams, which is a flat array, each context id corresponds to 4 entries (value, mun, lun, hun).
  8313. //For crosstab and chart, the fourth ctx id and beyond are from master-detail links,
  8314. //need to remove them to avoid synced-drilling on them.
  8315. aDrillParams.length = 3 * 4;
  8316. }
  8317. var aContextIds = drillMgr.getSelectedObject().getSelectedContextIds();
  8318. for (var i=0, drillGroupIndex = 0; drillGroupIndex < aContextIds.length && i <aDrillParams.length; ++drillGroupIndex) {
  8319. var ctxValue = aContextIds[drillGroupIndex][0];
  8320. var sDataItem = selectionController.getRefDataItem(ctxValue);
  8321. var sMUN = selectionController.getMun(ctxValue);
  8322. var sDisplayValue = selectionController.getDisplayValue(ctxValue);
  8323. //Exclude the member that cannot be drilled on from the drill spec.
  8324. if( selectionController.getDrillFlagForMember( ctxValue ) === 0 ){
  8325. i = i + 4; //skip over the entries for the excluded member
  8326. continue;
  8327. }
  8328. var oDrillSpecObject = {
  8329. "dataItem": aDrillParams[i++],
  8330. "mun": aDrillParams[i++],
  8331. "lun": aDrillParams[i++],
  8332. "hun": aDrillParams[i++]
  8333. };
  8334. //insert the display values.
  8335. if (sDataItem != "" && sDisplayValue != "") {
  8336. if (oDrillSpecObject.dataItem === sDataItem) {
  8337. oDrillSpecObject.displayValue = sDisplayValue;
  8338. }
  8339. }
  8340. var sUsageValue = selectionController.getUsageInfo(ctxValue);
  8341. oDrillSpecObject.isMeasure = (sUsageValue === '2')? "true" : "false";
  8342. //insert if drilling on summary
  8343. var drillSummary = false;
  8344. if (sMUN != "" && sUsageValue != '2') {
  8345. var drillabilityObj = this.getDrillabilityForItemFromReportInfo(sDataItem);
  8346. if ((drillabilityObj != null && drillabilityObj.disableDown == true) || this.m_oCV.getSelectionController().getDrillFlagForMember(ctxValue) == 1) {
  8347. drillSummary = true;
  8348. }
  8349. }
  8350. if (drillSummary) {
  8351. if (oDrillSpecObject.dataItem === sDataItem) {
  8352. oDrillSpecObject.summary = "true";
  8353. }
  8354. }
  8355. aDrillSpecObjects.push(oDrillSpecObject);
  8356. }
  8357. return (aDrillSpecObjects.length>0)? aDrillSpecObjects : null;
  8358. } catch( e )
  8359. {
  8360. return null;
  8361. }
  8362. };
  8363. /*
  8364. * This function parses the drill spec and creates a selected object
  8365. * based on the spec.
  8366. * Returns false if an exception occurs, true otherwise
  8367. */
  8368. DrillAction.prototype.parseDrillSpec = function( evt )
  8369. {
  8370. try
  8371. {
  8372. var oCV = this.getCognosViewer();
  8373. if( oCV.getStatus() !== 'complete' || oCV.getConversation() === "")
  8374. {
  8375. return false;
  8376. }
  8377. this.m_drillSpec = evt.payload.drillSpec;
  8378. var xmlDom = XMLBuilderLoadXMLFromString(this.m_drillSpec);
  8379. var drillParametersNode = xmlDom.firstChild;
  8380. var selectionController = getCognosViewerSCObjectRef(oCV.getId());
  8381. selectionController.m_aSelectedObjects = []; //do we need to do this?
  8382. // For some testcases (please see COGCQ00245956), especially for charts, the selected chart area is not cleaned-up properly
  8383. // and the object of the old selection is hanging around creating strange behaviour.
  8384. // So, clear the selection chart area if an old one is hanging around. Here is the only place to do this.
  8385. if (selectionController.hasSelectedChartNodes())
  8386. {
  8387. selectionController.clearSelectionData();
  8388. }
  8389. var aDrillGroups = XMLHelper_FindChildrenByTagName(drillParametersNode, "DrillGroup", false);
  8390. for(var iDrillGroupIndex = 0; iDrillGroupIndex < aDrillGroups.length; ++iDrillGroupIndex)
  8391. {
  8392. var munNode = XMLHelper_FindChildByTagName(aDrillGroups[iDrillGroupIndex], "MUN", false);
  8393. var sMun = XMLHelper_GetText(munNode);
  8394. var sLun = "";
  8395. var sHun = "";
  8396. var sDisplayValue = "";
  8397. var sSummary = "";
  8398. var displayValueNode = XMLHelper_FindChildByTagName(aDrillGroups[iDrillGroupIndex], "DisplayValue", false);
  8399. if(displayValueNode != null)
  8400. {
  8401. sDisplayValue = XMLHelper_GetText(displayValueNode);
  8402. }
  8403. var lunNode = XMLHelper_FindChildByTagName(aDrillGroups[iDrillGroupIndex], "LUN", false);
  8404. if(lunNode != null)
  8405. {
  8406. sLun = XMLHelper_GetText(lunNode);
  8407. }
  8408. var hunNode = XMLHelper_FindChildByTagName(aDrillGroups[iDrillGroupIndex], "HUN", false);
  8409. if(hunNode != null)
  8410. {
  8411. sHun = XMLHelper_GetText(hunNode);
  8412. }
  8413. var summaryNode = XMLHelper_FindChildByTagName(aDrillGroups[iDrillGroupIndex], "Summary", false);
  8414. if(summaryNode != null)
  8415. {
  8416. sSummary = XMLHelper_GetText(summaryNode);
  8417. }
  8418. this.selectObject(sMun, sLun, sHun, sDisplayValue, sSummary, selectionController );
  8419. }
  8420. }
  8421. catch( e )
  8422. {
  8423. return false;
  8424. }
  8425. return( selectionController.m_aSelectedObjects.length > 0 );
  8426. };
  8427. DrillAction.prototype.parseDrillSpecObjects = function( aDrillSpecObjects )
  8428. {
  8429. if (this.useReportInfoSelection()) {
  8430. return this.parseDrillSpecObjectsWithReportInfo(aDrillSpecObjects);
  8431. }
  8432. try
  8433. {
  8434. var oCV = this.getCognosViewer();
  8435. if( oCV.getStatus() !== 'complete' || oCV.getConversation() === "")
  8436. {
  8437. return false;
  8438. }
  8439. this.m_drillSpec = "";
  8440. var selectionController = getCognosViewerSCObjectRef(oCV.getId());
  8441. selectionController.m_aSelectedObjects = []; //do we need to do this?
  8442. // For some testcases (please see COGCQ00245956), especially for charts, the selected chart area is not cleaned-up properly
  8443. // and the object of the old selection is hanging around creating strange behaviour.
  8444. // So, clear the selection chart area if an old one is hanging around. Here is the only place to do this.
  8445. if (selectionController.hasSelectedChartNodes())
  8446. {
  8447. selectionController.clearSelectionData();
  8448. }
  8449. for(var i in aDrillSpecObjects)
  8450. {
  8451. var oSpec = aDrillSpecObjects[i];
  8452. var sSummary = (oSpec.summary)? oSpec.summary :"";
  8453. //For sync drill, drill flags are ignored so that we can sychronized dataItemDimensionalEdgeSummary
  8454. var bIsSyncDrill = true;
  8455. this.selectObject(oSpec.mun, oSpec.lun, oSpec.hun, oSpec.displayValue, sSummary, selectionController, bIsSyncDrill );
  8456. }
  8457. }
  8458. catch( e )
  8459. {
  8460. return false;
  8461. }
  8462. return( selectionController.m_aSelectedObjects.length > 0 );
  8463. };
  8464. DrillAction.prototype.getDrillabilityForCtxValue = function(sCtxId){
  8465. if (console && console.log) {
  8466. console.log("Required method, getDrillabilityForCtxValue, not implemented.");
  8467. }
  8468. };
  8469. DrillAction.prototype.setDrillabilityForSelectObject = function(sCtxId){
  8470. this.drillability = this.getDrillabilityForCtxValue( sCtxId );
  8471. };
  8472. DrillAction.prototype.canDrillDown = function(){
  8473. if (console && console.log) {
  8474. console.log("Required method, canDrillDown, not implemented.");
  8475. }
  8476. };
  8477. DrillAction.prototype.canDrilUp = function(){
  8478. if (console && console.log) {
  8479. console.log("Required method, canDrilUp, not implemented.");
  8480. }
  8481. };
  8482. DrillAction.prototype.selectObject = function(sMun, sLun, sHun, sDisplayValue, sOnSummary, selectionController, bIsSyncDrill )
  8483. {
  8484. var sActualHun = sHun;
  8485. var sActualLun = sLun;
  8486. var sActualMun = sMun;
  8487. var bIgnoreDrillFlag = false;
  8488. var sCtxId = selectionController.getCtxIdFromMun(sMun);
  8489. var sCtxIdByMun = sCtxId;
  8490. if(sCtxId === "")
  8491. {
  8492. var oActualLunAndHun = selectionController.replaceNamespaceForSharedTM1DimensionOnly(sLun, sHun, sMun);
  8493. sActualLun = oActualLunAndHun.lun;
  8494. sActualHun = oActualLunAndHun.hun;
  8495. if(sActualHun !== sHun){//The HUN has been udpated with the new namespace for TM1 shared dimension
  8496. sActualMun = this._replaceNamespace(sMun, sActualHun);//Replace MUN with the new namespace for TM1 shared dimension
  8497. }
  8498. //set bIgnoreDrillFlag to true if this is sync drill and you're getting ctxId from metadata. This is to allow for sync of dataItemDimensionalEdgeSummary.
  8499. bIgnoreDrillFlag = ( bIsSyncDrill == true );
  8500. sCtxId = selectionController.getCtxIdFromMetaData(sActualLun, sActualHun, bIgnoreDrillFlag);
  8501. if( sCtxId === "" )
  8502. {
  8503. return false;
  8504. }
  8505. }
  8506. this.setDrillabilityForSelectObject(sCtxId);
  8507. if((bIgnoreDrillFlag == true) || (this.m_sAction == "DrillDown" && this.canDrillDown()) || (this.m_sAction == "DrillUp" && this.canDrillUp() ) )
  8508. {
  8509. var beforeNumber = selectionController.getSelections().length;
  8510. selectionController.selectObject( sActualMun, sActualLun, sActualHun, bIgnoreDrillFlag );
  8511. var selectionObjects = selectionController.getSelections();
  8512. if (sCtxIdByMun === "" && selectionObjects.length > beforeNumber) {
  8513. var aMuns = selectionObjects[selectionObjects.length -1].m_aMuns;
  8514. aMuns[aMuns.length] = [];
  8515. aMuns[aMuns.length-1].push(sActualMun);
  8516. var aDisplayValues = selectionObjects[selectionObjects.length -1].m_aDisplayValues;
  8517. aDisplayValues.push(sDisplayValue);
  8518. selectionObjects[selectionObjects.length -1].useDisplayValueFromObject = true;
  8519. }
  8520. if (sOnSummary == "true") {
  8521. selectionObjects = selectionController.getSelections();
  8522. selectionObjects[selectionObjects.length-1].onSummary = true;
  8523. }
  8524. }
  8525. };
  8526. DrillAction.prototype._replaceNamespace = function(mun, sActualHun) {
  8527. var sResult = null;
  8528. if(sActualHun){
  8529. var sNamespace = sActualHun.substr(0, sActualHun.indexOf("].[") + 1);
  8530. if(mun && sNamespace && !(mun.match("^" + sNamespace))){
  8531. var iFirstDotPos = mun.indexOf("].[");
  8532. sResult = sNamespace + mun.substr(iFirstDotPos + 1, mun.length);
  8533. }
  8534. }
  8535. return sResult || mun;
  8536. };
  8537. DrillAction.prototype.addActionContextAdditionalParms = function()
  8538. {
  8539. var params = "";
  8540. var selectionObjects = (this.useReportInfoSelection())? this.m_aDrillSelectedObjects : this.getCognosViewer().getSelectionController().getSelections();
  8541. var sItem = null;
  8542. for (var i = 0; i < selectionObjects.length; ++i)
  8543. {
  8544. if (selectionObjects[i].onSummary)
  8545. {
  8546. sItem = (this.useReportInfoSelection())? selectionObjects[i].item :
  8547. selectionObjects[i].getDataItems()[0][0]; //expect only one because this is passed down from drill event.
  8548. params += "<dataItem>" + xml_encode(sItem) + "</dataItem>";
  8549. }
  8550. }
  8551. if (params != "") {
  8552. params = "<onSummary>" + params + "</onSummary>";
  8553. }
  8554. if (this.m_userSelectedDrillItem) {
  8555. params += ("<userSelectedDrillItem>" + this.m_userSelectedDrillItem + "</userSelectedDrillItem>");
  8556. }
  8557. //following flags to make drill performance optimisation with switching V5 to MA for some requests
  8558. if (this.m_useMARequest === true) {
  8559. params = params + "<useMAGetChildRequest>false</useMAGetChildRequest>";
  8560. params = params + "<useMAGetParentRequest>false</useMAGetParentRequest>";
  8561. }
  8562. params += this.addClientContextData(/*maxValuesPerRDI*/3);
  8563. return params;
  8564. };
  8565. DrillAction.prototype.getDrillOptionsAsString = function(){
  8566. var oViewerWidget = this.getViewerWidget();
  8567. var result = "";
  8568. if(oViewerWidget){
  8569. result = "<addSummaryMembers>" + oViewerWidget.getDrillOptions().addSummaryMembers + "</addSummaryMembers>";
  8570. result = result + "<backwardsCompatible>" + oViewerWidget.getDrillOptions().backwardsCompatible + "</backwardsCompatible>";
  8571. }
  8572. return result;
  8573. };
  8574. DrillAction.prototype.getItemInfo = function( cognosViewer, itemName )
  8575. {
  8576. var rapReportInfo = cognosViewer.getRAPReportInfo()
  8577. if( !rapReportInfo )
  8578. {
  8579. return null;
  8580. }
  8581. var containers = rapReportInfo.getContainers();
  8582. for( var container in containers )
  8583. {
  8584. var itemInfo = rapReportInfo.getItemInfo( container );
  8585. if( itemInfo[itemName])
  8586. {
  8587. return itemInfo[itemName];
  8588. }
  8589. }
  8590. return null;
  8591. };
  8592. DrillAction.prototype.isSelectionFilterEnabled = function() {
  8593. var oWidget = this.getViewerWidget();
  8594. if (!oWidget) {
  8595. return false;
  8596. }
  8597. return oWidget.isSelectionFilterEnabled();
  8598. };
  8599. DrillAction.prototype.getHierarchyHasExpandedSet = function( cognosViewer, itemName )
  8600. {
  8601. var itemInfo = this.getItemInfo( cognosViewer, itemName );
  8602. return ( itemInfo && itemInfo.hierarchyHasExpandedMembers );
  8603. };
  8604. DrillAction.prototype.getIsRSDrillParent = function( cognosViewer, itemName )
  8605. {
  8606. var itemInfo = this.getItemInfo( cognosViewer, itemName );
  8607. return ( itemInfo && itemInfo.isRSDrillParent );
  8608. };
  8609. /*
  8610. * Sets m_bUseReportInfoSelection flag
  8611. */
  8612. DrillAction.prototype.setUseReportInfoSelection = function( bFlag )
  8613. {
  8614. this.m_bUseReportInfoSelection = bFlag;
  8615. }
  8616. /*
  8617. * returns m_bUseReportInfoSelection flag
  8618. */
  8619. DrillAction.prototype.useReportInfoSelection = function()
  8620. {
  8621. return this.m_bUseReportInfoSelection;
  8622. }
  8623. /*
  8624. * parses input object and populates m_aDrillSelectedObjects array.
  8625. */
  8626. DrillAction.prototype.parseDrillSpecObjectsWithReportInfo = function( aDrillSpecObjects )
  8627. {
  8628. try
  8629. {
  8630. var oReportInfo = this.m_oCV.getRAPReportInfo();
  8631. if(!oReportInfo){
  8632. return null;
  8633. }
  8634. this.m_drillSpec = "";
  8635. this.m_aDrillSelectedObjects = [];
  8636. for(var i in aDrillSpecObjects) {
  8637. this.populateSelectObjectWithReportInfo(aDrillSpecObjects[i], oReportInfo );
  8638. }
  8639. }
  8640. catch( e )
  8641. {
  8642. return false;
  8643. }
  8644. return( this.m_aDrillSelectedObjects.length > 0 );
  8645. };
  8646. /*
  8647. * Creates an object with enough infomation to create Lean-selection and
  8648. * adds the object to m_aDrillSelectedObjects array.
  8649. *
  8650. * The object has all the fields from returned object of getItemDetails and the drill-spec object
  8651. * obj = {
  8652. * item,
  8653. * hun,
  8654. * lid,
  8655. * queryName,
  8656. * mun,
  8657. * lun,
  8658. * displayValue,
  8659. * isMeasure,
  8660. * onSummary
  8661. * }
  8662. */
  8663. DrillAction.prototype.populateSelectObjectWithReportInfo = function(oSpec, oReportInfo)
  8664. {
  8665. var oItemDetails = oReportInfo.getItemDetails(oSpec.dataItem, oSpec.hun);
  8666. if (!oItemDetails) {
  8667. oItemDetails = oReportInfo.getItemDetailsByHun(oSpec.hun);
  8668. if (!oItemDetails) {
  8669. return null;
  8670. }
  8671. }
  8672. if (oSpec.mun) {
  8673. oItemDetails.mun = oSpec.mun;
  8674. }
  8675. if (oSpec.lun) {
  8676. oItemDetails.lun = oSpec.lun;
  8677. }
  8678. if (oSpec.displayValue) {
  8679. oItemDetails.displayValue = oSpec.displayValue;
  8680. }
  8681. if (oSpec.isMeasure === "true") {
  8682. oItemDetails.isMeasure = true;
  8683. }
  8684. if (oSpec.summary === "true") {
  8685. oItemDetails.onSummary = true;
  8686. }
  8687. this.m_aDrillSelectedObjects.push(oItemDetails);
  8688. };
  8689. /*
  8690. * Override
  8691. */
  8692. DrillAction.prototype.getSelectionContext = function()
  8693. {
  8694. if (this.useReportInfoSelection() ) {
  8695. return this.genLeanSelection();
  8696. } else {
  8697. return CognosViewerAction.prototype.getSelectionContext.call(this);
  8698. }
  8699. };
  8700. /*
  8701. * Returns string representing selectedCell elements.
  8702. * m_aDrillSelectedObjects array is used as source of selected cells.
  8703. */
  8704. DrillAction.prototype.genLeanSelection = function()
  8705. {
  8706. if (this.m_aDrillSelectedObjects.length ==0) {
  8707. return "";
  8708. }
  8709. var sSelection = "";
  8710. for (var idx in this.m_aDrillSelectedObjects) {
  8711. var obj = this.m_aDrillSelectedObjects[idx];
  8712. /*
  8713. * Fields of obj: queryName, hun, lun, mun, displayValue, lid, and onSummary
  8714. */
  8715. sSelection += "<selectedCell>";
  8716. sSelection += (
  8717. "<name>" + obj.item + "</name>" +
  8718. "<display>" + obj.displayValue + "</display>" +
  8719. "<rapLayoutTag>" + obj.lid + "</rapLayoutTag>" +
  8720. "<queryName>" + obj.queryName + "</queryName>"
  8721. );
  8722. if (obj.mun) {
  8723. sSelection += ("<nodeUse>" + obj.mun + "</nodeUse>");
  8724. sSelection += ("<nodeType>memberUniqueName</nodeType>");
  8725. }
  8726. if (obj.hun) {
  8727. sSelection += ("<nodeHierarchyUniqueName>" + obj.hun + "</nodeHierarchyUniqueName>");
  8728. }
  8729. var sUsage = (obj.isMeasure)? "measure" : "nonMeasure";
  8730. sSelection += ("<nodeUsage>" + sUsage + "</nodeUsage>");
  8731. sSelection += "</selectedCell>";
  8732. }
  8733. return ("<selection>" + sSelection + "</selection>");
  8734. };
  8735. /*
  8736. * Overrride
  8737. * This function is used in AddActionContexts, i.e <reportActions>
  8738. *
  8739. * If widget is not visible, we want <reportActions runReport=false>
  8740. */
  8741. DrillAction.prototype.runReport = function()
  8742. {
  8743. if (this.getViewerWidget()) {
  8744. return this.getViewerWidget().shouldReportBeRunOnAction()
  8745. }
  8746. else {
  8747. return true;
  8748. }
  8749. };
  8750. /*
  8751. * Override
  8752. *
  8753. * Enables Queuing if widget is not visible
  8754. */
  8755. DrillAction.prototype.canBeQueued = function()
  8756. {
  8757. if (this.getViewerWidget()) {
  8758. return !(this.getViewerWidget().isVisible());
  8759. }
  8760. else {
  8761. return false;
  8762. }
  8763. };
  8764. /*
  8765. *+------------------------------------------------------------------------+
  8766. *| Licensed Materials - Property of IBM
  8767. *| IBM Cognos Products: Viewer
  8768. *| (C) Copyright IBM Corp. 2001, 2011
  8769. *|
  8770. *| US Government Users Restricted Rights - Use, duplication or
  8771. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8772. *|
  8773. *+------------------------------------------------------------------------+
  8774. */
  8775. /**
  8776. * DrillUpDownAction - implements drill-related actions including drillability
  8777. * and returning/performing drilling in the "default drill direction" in cognos viewer
  8778. */
  8779. function DrillUpDownAction()
  8780. {
  8781. this.m_sAction = "DrillDown";
  8782. this.m_drillOption = "drillDown";
  8783. this.undoTooltip = "";
  8784. }
  8785. DrillUpDownAction.prototype = new DrillAction();
  8786. DrillUpDownAction.prototype.getHoverClassName = function() { return "dl"; };
  8787. DrillUpDownAction.prototype.getUndoHint = function()
  8788. {
  8789. return this.undoTooltip;
  8790. };
  8791. DrillUpDownAction.prototype.keepRAPCache = function()
  8792. {
  8793. return false;
  8794. };
  8795. DrillUpDownAction.prototype.updateDrillability = function(cognosViewer, ctxNode)
  8796. {
  8797. this.m_oCV = cognosViewer;
  8798. var ctxValueString = ctxNode.getAttribute("ctx");
  8799. this.drillability = 0;
  8800. if (ctxValueString) {
  8801. var ctxValues = ctxValueString.split("::");
  8802. if (ctxValues && ctxValues.length > 0) {
  8803. if (ctxValues.length > 2) {
  8804. this.drillability = this.getDrillabilityForIntersection(ctxValues[1].split(":")[0],
  8805. ctxValues[2].split(":")[0]);
  8806. } else if( ctxValues.length === 2 ) {
  8807. /**
  8808. * Handles the case for measure::categories ctx, which vizCharts like treemap generates.
  8809. */
  8810. this.drillability = this.getDrillabilityForCtxValue(ctxValues[1].split(":")[0]);
  8811. } else {
  8812. this.drillability = this.getDrillabilityForCtxValue(ctxValues[0].split(":")[0]);
  8813. }
  8814. }
  8815. }
  8816. //set the default action to match the default drill
  8817. if (this.isDefaultDrillUp(ctxNode)) {
  8818. this.m_sAction = "DrillUp";
  8819. this.m_drillOption = "drillUp";
  8820. this.undoTooltip = RV_RES.RV_DRILL_UP;
  8821. } else {
  8822. this.m_sAction = "DrillDown";
  8823. this.m_drillOption = "drillDown";
  8824. this.undoTooltip = RV_RES.RV_DRILL_DOWN;
  8825. }
  8826. return this.drillability;
  8827. };
  8828. DrillUpDownAction.prototype.updateDrillabilityFromSelections = function()
  8829. {
  8830. var selectionController = this.m_oCV.getSelectionController();
  8831. var selectedObjects = selectionController.getAllSelectedObjects();
  8832. this.drillability=0;
  8833. if (selectedObjects != null && typeof selectedObjects != "undefined"
  8834. && selectedObjects.length == 1 && selectedObjects[0].m_contextIds!=null)
  8835. {
  8836. if (selectedObjects[0].getLayoutType() == "section") {
  8837. this.drillability = 0; //no drilling on section header in a sectioned list.
  8838. } else if (selectedObjects[0].m_contextIds.length == 0) {
  8839. this.drillability = 0;
  8840. } else if (typeof DrillContextMenuHelper !== "undefined" && DrillContextMenuHelper.needsDrillSubMenu(this.m_oCV)) {
  8841. //Normally, look at the level closest to the data to determine if you can drill up or down on a particular node or cell.
  8842. //But...when the drill submenu is enabled, return true if you can drill up/down on upper levels as well...because all items are in the menu.
  8843. this.drillability = this.getDrillabilityForAll(selectedObjects[0].m_contextIds);
  8844. } else {
  8845. if (selectedObjects[0].m_contextIds.length > 2) {
  8846. this.drillability = this.getDrillabilityForIntersection(selectedObjects[0].m_contextIds[1][0],
  8847. selectedObjects[0].m_contextIds[2][0]);
  8848. } else {
  8849. this.drillability = this.getDrillabilityForCtxValue(selectedObjects[0].m_contextIds[0][0]);
  8850. }
  8851. }
  8852. }
  8853. return this.drillability;
  8854. };
  8855. DrillUpDownAction.prototype.getDrillabilityForCtxValue = function(ctxValue)
  8856. {
  8857. var drillability = 0;
  8858. var selectionController = this.m_oCV.getSelectionController();
  8859. var refDataItem = selectionController.getRefDataItem( ctxValue )
  8860. if( this.getHierarchyHasExpandedSet( this.m_oCV, refDataItem) && this.getIsRSDrillParent( this.m_oCV, refDataItem ) )
  8861. {
  8862. //we want to make sure that user can still drill up on the parent member when there is expanded set in the hierarchy
  8863. drillability = 1; //up
  8864. return drillability;
  8865. }
  8866. if (selectionController.getMun(ctxValue) !== "" && selectionController.getUsageInfo(ctxValue) !== '2')
  8867. {
  8868. //Start with the drill flags, then augment with reportInfo....
  8869. drillability = (+selectionController.getDrillFlagForMember(ctxValue));
  8870. var drillabilityObj = this.getDrillabilityForItemFromReportInfo(selectionController.getRefDataItem(ctxValue));
  8871. if (drillabilityObj != null) {
  8872. if (drillabilityObj.disableDown == true || drillabilityObj.isolated == true) {
  8873. if (drillability == 1 || drillability >= 3 || drillabilityObj.isolated == true) { //up or both
  8874. drillability = 1; //up
  8875. } else {
  8876. drillability = 0; //none
  8877. }
  8878. }
  8879. if (drillabilityObj.disableUp == true) {
  8880. if (drillability >= 2) { //down or both
  8881. drillability = 2; //down
  8882. } else {
  8883. drillability = 0; //none
  8884. }
  8885. }
  8886. }
  8887. }
  8888. return drillability;
  8889. };
  8890. DrillUpDownAction.prototype.getDrillabilityForIntersection = function(ctxValue1, ctxValue2)
  8891. {
  8892. var drillability1 = this.getDrillabilityForCtxValue(ctxValue1);
  8893. return this.mergeDrillability(drillability1, ctxValue2);
  8894. };
  8895. /**
  8896. * This function merges the drillability for all components of a selection (including nested parents)
  8897. * It is used for visualizations to determine whether we need to show drill up/drill down and a submenu
  8898. * (ie: it may not be possible to drill on the innermost but it may be possible to drill on one of the nested parents).
  8899. */
  8900. DrillUpDownAction.prototype.getDrillabilityForAll = function(contextArray)
  8901. {
  8902. //Process all levels...when 1 dimension, its an edge so process the first dimension
  8903. // when 2 dimensions, its an intersection so process dimensions 1 and 2 for all levels.
  8904. var iStartDim=(contextArray.length >= 2) ? 1 : 0;
  8905. var iEndDim;
  8906. if(contextArray.length == 2){
  8907. iEndDim = 1;
  8908. } else if (contextArray.length > 2) {
  8909. iEndDim = 2;
  8910. } else {
  8911. iEndDim = 0;
  8912. }
  8913. var netDrillability=0;
  8914. for (var iDim=iStartDim; iDim<=iEndDim; ++iDim) {
  8915. for (var iLevel=0; iLevel<contextArray[iDim].length; ++iLevel) {
  8916. netDrillability=this.mergeDrillability(netDrillability, contextArray[iDim][iLevel]);
  8917. }
  8918. }
  8919. return netDrillability;
  8920. };
  8921. DrillUpDownAction.prototype.mergeDrillability = function(drillability1, ctxValue2)
  8922. {
  8923. var drillability2 = this.getDrillabilityForCtxValue(ctxValue2);
  8924. if (drillability1 == drillability2) {
  8925. return drillability1;
  8926. }
  8927. //swap so that d2 > d1
  8928. if (drillability1 > drillability2) {
  8929. var temp = drillability1;
  8930. drillability1 = drillability2;
  8931. drillability2 = temp;
  8932. }
  8933. if (drillability1 == 1 && drillability2 == 2) {
  8934. return 3; //down or up
  8935. }
  8936. return drillability2;
  8937. };
  8938. DrillUpDownAction.prototype.hasPermission = function()
  8939. {
  8940. if( this.m_oCV)
  8941. {
  8942. if (this.m_oCV.isDrillBlackListed()) {
  8943. return false;
  8944. }
  8945. var envParams = this.m_oCV.envParams;
  8946. if( envParams )
  8947. {
  8948. return !( this.m_oCV.isLimitedInteractiveMode() || ( envParams['cv.objectPermissions'].indexOf( 'read' ) === -1 ));
  8949. }
  8950. }
  8951. return false;
  8952. };
  8953. DrillUpDownAction.prototype.canDrillUp = function()
  8954. {
  8955. //0=none, 1=up, 2=down, 3=downorup, 4=upordown
  8956. return ((this.drillability == 1 || this.drillability == 3 || this.drillability == 4) && this.hasPermission() );
  8957. };
  8958. DrillUpDownAction.prototype.canDrillDown = function()
  8959. {
  8960. //0=none, 1=up, 2=down, 3=downorup, 4=upordown
  8961. return ( (this.drillability == 2 || this.drillability == 3 || this.drillability == 4) && this.hasPermission() );
  8962. };
  8963. DrillUpDownAction.prototype.isDefaultDrillUp = function(ctxNode)
  8964. {
  8965. if (this.drillability == 1 || this.drillability == 4 || (ctxNode && ctxNode.getAttribute("ischarttitle") === "true")) {
  8966. return true;
  8967. } else {
  8968. return false;
  8969. }
  8970. };
  8971. DrillUpDownAction.prototype.doOnMouseOver = function(evt)
  8972. {
  8973. if (this.drillability > 0 && !this.getCognosViewer().isLimitedInteractiveMode()) {
  8974. var ctxNode = getCtxNodeFromEvent(evt);
  8975. this.addDrillableClass(ctxNode);
  8976. if (evt.toElement && evt.toElement.nodeName && evt.toElement.nodeName.toLowerCase() == "img") {
  8977. this.addDrillableClass(evt.toElement);
  8978. }
  8979. }
  8980. };
  8981. DrillUpDownAction.prototype.doOnMouseOut = function(evt)
  8982. {
  8983. var ctxNode = getCtxNodeFromEvent(evt);
  8984. if (ctxNode) {
  8985. this.removeDrillableClass(ctxNode);
  8986. if (evt.toElement && evt.toElement.nodeName && evt.toElement.nodeName.toLowerCase() == "img") {
  8987. this.removeDrillableClass(evt.toElement);
  8988. }
  8989. }
  8990. };
  8991. DrillUpDownAction.prototype.onMouseOver = function(evt)
  8992. {
  8993. this.doOnMouseOver(evt);
  8994. };
  8995. DrillUpDownAction.prototype.onMouseOut = function(evt)
  8996. {
  8997. this.doOnMouseOut(evt);
  8998. };
  8999. DrillUpDownAction.prototype.onDoubleClick = function(evt)
  9000. {
  9001. if (this.drillability > 0 && this.hasPermission() && !this.isSelectionFilterEnabled()) {
  9002. this.execute();
  9003. var ctxNode = getCtxNodeFromEvent(evt);
  9004. if (ctxNode!=null) {
  9005. this.removeDrillableClass(ctxNode);
  9006. }
  9007. }
  9008. };
  9009. DrillUpDownAction.prototype.addDrillableClass = function(node) {
  9010. if (! node.className.match(new RegExp('(\\s|^)' + this.getHoverClassName() + '(\\s|$)'))) {
  9011. node.className += " " + this.getHoverClassName();
  9012. }
  9013. };
  9014. DrillUpDownAction.prototype.removeDrillableClass = function(node) {
  9015. var className = node.className;
  9016. className = className.replace(new RegExp('(\\s|^)' + this.getHoverClassName() + '(\\s|$)'), ' ');
  9017. node.className = className.replace(/^\s*/, "").replace(/\s*$/, "");
  9018. };
  9019. /**
  9020. * DrillUpDownOrThroughAction - Manage drill cursors for authored drill/drillability and double-click "default drill" (charts only)
  9021. */
  9022. function DrillUpDownOrThroughAction()
  9023. {
  9024. this.m_hasAuthoredDrillTargets=false;
  9025. this.m_canDrillUpDown=false;
  9026. }
  9027. DrillUpDownOrThroughAction.prototype = new DrillUpDownAction();
  9028. DrillUpDownOrThroughAction.prototype.init = function(hasAuthoredDrillTargets, canDrillUpDown) {
  9029. if (this.getCognosViewer()) {
  9030. var oWidget = this.getCognosViewer().getViewerWidget();
  9031. if (oWidget && oWidget.isSelectionFilterEnabled()) {
  9032. return;
  9033. }
  9034. else if (this.m_oCV.isDrillBlackListed()) {
  9035. return;
  9036. }
  9037. }
  9038. this.m_hasAuthoredDrillTargets=hasAuthoredDrillTargets;
  9039. this.m_canDrillUpDown=canDrillUpDown;
  9040. };
  9041. DrillUpDownOrThroughAction.prototype.updateDrillabilityInfo = function(cognosViewer, ctxNode)
  9042. {
  9043. if (this.m_canDrillUpDown) {
  9044. return this.updateDrillability(cognosViewer, ctxNode);
  9045. }
  9046. return null;
  9047. };
  9048. DrillUpDownOrThroughAction.prototype.onMouseOver = function(evt)
  9049. {
  9050. if (this.m_hasAuthoredDrillTargets) {
  9051. var ctxNode = getCtxNodeFromEvent(evt);
  9052. if (ctxNode) {
  9053. this.addDrillableClass(ctxNode);
  9054. this._set_chartImage_drillThroughCursor_IE("pointer", evt);
  9055. }
  9056. }
  9057. if (this.m_canDrillUpDown && !this.isSelectionFilterEnabled() && !this.m_oCV.isDrillBlackListed()) {
  9058. this.doOnMouseOver(evt);
  9059. }
  9060. };
  9061. DrillUpDownOrThroughAction.prototype.onMouseOut = function(evt)
  9062. {
  9063. if (this.m_hasAuthoredDrillTargets) {
  9064. var ctxNode = getCtxNodeFromEvent(evt);
  9065. if (ctxNode) {
  9066. this.removeDrillableClass(ctxNode);
  9067. this._set_chartImage_drillThroughCursor_IE("default", evt);
  9068. }
  9069. }
  9070. if (this.m_canDrillUpDown && !this.isSelectionFilterEnabled() && !this.m_oCV.isDrillBlackListed()) {
  9071. this.doOnMouseOut(evt);
  9072. }
  9073. };
  9074. /**
  9075. * IE8 and IE9 has limitations to dynamically change an "AREA" element's cursor type
  9076. * by fliping pedefined CSS styles when there is cursor type css style defined in the
  9077. * "IMG" element's parent element, the function below is to get the IMG object from the
  9078. * onMouseOver event on the "AREA" and programatically change the img's cursor to show
  9079. * hand icon when it's drill through able.
  9080. * */
  9081. DrillUpDownOrThroughAction.prototype._getDrillThroughChartImage_from_chartArea = function(evt){
  9082. var oSrcElement = getCrossBrowserNode(evt);
  9083. if(oSrcElement){
  9084. var selectionController = this.m_oCV.getSelectionController();
  9085. return selectionController.getSelectedChartImageFromChartArea(oSrcElement);
  9086. }
  9087. };
  9088. DrillUpDownOrThroughAction.prototype._set_chartImage_drillThroughCursor_IE = function(sCursor, evt){
  9089. if(dojo.isIE || dojo.isTrident){//We only do this for IE
  9090. var oImg = this._getDrillThroughChartImage_from_chartArea( evt);
  9091. if(oImg){
  9092. oImg.style.cursor = sCursor;
  9093. }
  9094. }
  9095. };
  9096. /*
  9097. *+------------------------------------------------------------------------+
  9098. *| Licensed Materials - Property of IBM
  9099. *| IBM Cognos Products: Viewer
  9100. *| (C) Copyright IBM Corp. 2001, 2011
  9101. *|
  9102. *| US Government Users Restricted Rights - Use, duplication or
  9103. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9104. *|
  9105. *+------------------------------------------------------------------------+
  9106. */
  9107. /**
  9108. * DrillDownAction - implements drill down in cognos viewer
  9109. */
  9110. function DrillDownAction()
  9111. {
  9112. this.m_sAction = "DrillDown";
  9113. //TODO make it so that we can use m_sAction instead of a separate parameter
  9114. this.m_drillOption = "drillDown";
  9115. }
  9116. DrillDownAction.prototype = new DrillUpDownAction();
  9117. DrillDownAction.prototype.getUndoHint = function()
  9118. {
  9119. return RV_RES.RV_DRILL_DOWN;
  9120. };
  9121. DrillDownAction.prototype.getHoverClassName = function() { return "dl"; };
  9122. DrillDownAction.prototype.updateMenu = function(jsonSpec)
  9123. {
  9124. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  9125. if (! jsonSpec.visible)
  9126. {
  9127. return jsonSpec;
  9128. }
  9129. this.updateDrillabilityFromSelections();
  9130. if (!this.canDrillDown()) {
  9131. jsonSpec.disabled = true;
  9132. } else {
  9133. jsonSpec.disabled = false;
  9134. DrillContextMenuHelper.updateDrillMenuItems(jsonSpec, this.m_oCV, this.m_sAction);
  9135. }
  9136. return jsonSpec;
  9137. };
  9138. /*
  9139. *+------------------------------------------------------------------------+
  9140. *| Licensed Materials - Property of IBM
  9141. *| IBM Cognos Products: Viewer
  9142. *| (C) Copyright IBM Corp. 2001, 2011
  9143. *|
  9144. *| US Government Users Restricted Rights - Use, duplication or
  9145. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9146. *|
  9147. *+------------------------------------------------------------------------+
  9148. */
  9149. /**
  9150. * DrillUpAction - implements drill up in cognos viewer
  9151. */
  9152. function DrillUpAction()
  9153. {
  9154. this.m_sAction = "DrillUp";
  9155. this.m_drillOption = "drillUp";
  9156. }
  9157. DrillUpAction.prototype = new DrillUpDownAction();
  9158. DrillUpAction.prototype.getHoverClassName = function() { return "dl"; };
  9159. DrillUpAction.prototype.getUndoHint = function()
  9160. {
  9161. return RV_RES.RV_DRILL_UP;
  9162. };
  9163. DrillUpAction.prototype.updateMenu = function(jsonSpec)
  9164. {
  9165. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  9166. if (! jsonSpec.visible)
  9167. {
  9168. return jsonSpec;
  9169. }
  9170. this.updateDrillabilityFromSelections();
  9171. if (!this.canDrillUp()) {
  9172. jsonSpec.disabled = true;
  9173. } else {
  9174. jsonSpec.disabled = false;
  9175. DrillContextMenuHelper.updateDrillMenuItems(jsonSpec, this.m_oCV, this.m_sAction);
  9176. }
  9177. return jsonSpec;
  9178. };
  9179. /*
  9180. *+------------------------------------------------------------------------+
  9181. *| Licensed Materials - Property of IBM
  9182. *| IBM Cognos Products: Viewer
  9183. *| (C) Copyright IBM Corp. 2001, 2011
  9184. *|
  9185. *| US Government Users Restricted Rights - Use, duplication or
  9186. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9187. *|
  9188. *+------------------------------------------------------------------------+
  9189. */
  9190. function DeleteAction()
  9191. {
  9192. this.m_sAction = "Delete";
  9193. }
  9194. DeleteAction.prototype = new ModifyReportAction();
  9195. DeleteAction.baseclass = ModifyReportAction.prototype;
  9196. DeleteAction.prototype.getUndoHint = function()
  9197. {
  9198. return RV_RES.IDS_JS_DELETE;
  9199. };
  9200. DeleteAction.prototype.canDelete = function()
  9201. {
  9202. if(!this.m_oCV.isLimitedInteractiveMode()) {
  9203. var selectedObjects = this.m_oCV.getSelectionController().getAllSelectedObjects();
  9204. if (selectedObjects.length>0) {
  9205. for (var i=0; i<selectedObjects.length; ++i) {
  9206. var selObj=selectedObjects[i];
  9207. var cellRef=selObj.getCellRef();
  9208. if( !selObj.hasContextInformation() || selObj.isHomeCell() ||
  9209. (selObj.getLayoutType() != 'columnTitle' && selObj.getDataContainerType() != 'list' ) ||
  9210. cellRef.getAttribute("cc") == "true") {
  9211. return false;
  9212. }
  9213. }
  9214. return true;
  9215. }
  9216. }
  9217. return false;
  9218. };
  9219. DeleteAction.prototype.execute = function() {
  9220. DeleteAction.baseclass.execute.call(this);
  9221. //While the server is working, clear the selection and rebuild the
  9222. //context menu so that users won't be able to see commands from
  9223. //the deleted selection. (COGCQ00252407).
  9224. this.m_oCV.getSelectionController().clearSelectionData();
  9225. this.m_oCV.getViewerWidget().onContextMenu(null);
  9226. };
  9227. DeleteAction.prototype.keepRAPCache = function()
  9228. {
  9229. return false;
  9230. };
  9231. DeleteAction.prototype.updateMenu = function(jsonSpec)
  9232. {
  9233. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  9234. if (! jsonSpec.visible)
  9235. {
  9236. return jsonSpec;
  9237. }
  9238. jsonSpec.disabled = !this.canDelete();
  9239. return jsonSpec;
  9240. };
  9241. DeleteAction.prototype.addActionContextAdditionalParms = function()
  9242. {
  9243. return this.getSelectedCellTags();
  9244. };
  9245. /*
  9246. *+------------------------------------------------------------------------+
  9247. *| Licensed Materials - Property of IBM
  9248. *| IBM Cognos Products: Viewer
  9249. *| (C) Copyright IBM Corp. 2013
  9250. *|
  9251. *| US Government Users Restricted Rights - Use, duplication or
  9252. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9253. *|
  9254. *+------------------------------------------------------------------------+
  9255. */
  9256. function UndoableClientActionBase() {}
  9257. UndoableClientActionBase.prototype = new CognosViewerAction();
  9258. UndoableClientActionBase.prototype.setContainerId = function(containerId)
  9259. {
  9260. this.m_sContainerId = containerId;
  9261. };
  9262. UndoableClientActionBase.prototype.doRedo = function(containerId)
  9263. {
  9264. this.setContainerId(containerId)
  9265. this.execute();
  9266. };
  9267. UndoableClientActionBase.prototype.doUndo = function(containerId)
  9268. {
  9269. factory = this.getCognosViewer().getActionFactory();
  9270. var unfreezeAction = factory.load(this.getUndoClass());
  9271. unfreezeAction.setContainerId(containerId);
  9272. unfreezeAction.execute();
  9273. };
  9274. /**
  9275. * return the container id of the selected container (without namespace)
  9276. */
  9277. UndoableClientActionBase.prototype.getSelectedContainerId = function()
  9278. {
  9279. var selectedObjects = this.m_oCV.getSelectionController().getAllSelectedObjects();
  9280. if (selectedObjects && selectedObjects.length) {
  9281. var lid=selectedObjects[0].getLayoutElementId();
  9282. if (lid) {
  9283. return this.removeNamespace(lid);
  9284. }
  9285. }
  9286. return null;
  9287. };
  9288. /*
  9289. *+------------------------------------------------------------------------+
  9290. *| Licensed Materials - Property of IBM
  9291. *| IBM Cognos Products: Viewer
  9292. *| (C) Copyright IBM Corp. 2013
  9293. *|
  9294. *| US Government Users Restricted Rights - Use, duplication or
  9295. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9296. *|
  9297. *+------------------------------------------------------------------------+
  9298. */
  9299. function FreezeRowHeadingsAction()
  9300. {
  9301. }
  9302. FreezeRowHeadingsAction.prototype = new UndoableClientActionBase();
  9303. FreezeRowHeadingsAction.superclass = UndoableClientActionBase.prototype;
  9304. FreezeRowHeadingsAction.prototype.execute = function()
  9305. {
  9306. var lidToFreeze = this.m_sContainerId? this.m_sContainerId : this.getSelectedCrosstabContainerId();
  9307. if (lidToFreeze) {
  9308. //Selection borders in high contrast mode aren't cleaned up properly when cloned,
  9309. //so remove all selections before performing freeze
  9310. this.m_oCV.getSelectionController().resetSelections();
  9311. this.m_oCV.getPinFreezeManager().freezeContainerRowHeadings(lidToFreeze);
  9312. this.addClientSideUndo(this, [lidToFreeze]);
  9313. }
  9314. };
  9315. FreezeRowHeadingsAction.prototype.getUndoHint = function()
  9316. {
  9317. return RV_RES.IDS_JS_FREEZEROWHEADINGS;
  9318. };
  9319. FreezeRowHeadingsAction.prototype.getUndoClass = function()
  9320. {
  9321. return "UnfreezeRowHeadings";
  9322. };
  9323. FreezeRowHeadingsAction.prototype.getSelectedCrosstabContainerLid = function()
  9324. {
  9325. var selectedObjects = this.m_oCV.getSelectionController().getAllSelectedObjects();
  9326. if (selectedObjects && selectedObjects.length && selectedObjects[0].getDataContainerType() == "crosstab") {
  9327. var lid=(selectedObjects[0].getLayoutElementId());
  9328. if (lid) {
  9329. return lid;
  9330. }
  9331. }
  9332. return null;
  9333. };
  9334. /**
  9335. * return the selected container id (without namespace) if it is valid for pin freeze rows (ie: its a crosstab)
  9336. */
  9337. FreezeRowHeadingsAction.prototype.getSelectedCrosstabContainerId = function()
  9338. {
  9339. var lid = this.getSelectedCrosstabContainerLid();
  9340. if (lid) {
  9341. return this.removeNamespace(lid);
  9342. }
  9343. return null;
  9344. };
  9345. /**
  9346. * row headings can be frozen if the layout type is right and the row headings aren't already frozen.
  9347. */
  9348. FreezeRowHeadingsAction.prototype.canFreezeRowHeadings = function()
  9349. {
  9350. var pfManager = this.m_oCV.getPinFreezeManager();
  9351. if (pfManager) {
  9352. var containerId=this.getSelectedCrosstabContainerId();
  9353. if (containerId) {
  9354. if(!pfManager.hasFrozenRowHeadings(containerId) && pfManager.getValidSelectedContainerId(false)) {
  9355. return true;
  9356. }
  9357. }
  9358. }
  9359. return false;
  9360. };
  9361. FreezeRowHeadingsAction.prototype.updateMenu = function(jsonSpec)
  9362. {
  9363. jsonSpec.visible = this.canFreezeRowHeadings();
  9364. return jsonSpec;
  9365. };
  9366. /*
  9367. *+------------------------------------------------------------------------+
  9368. *| Licensed Materials - Property of IBM
  9369. *| IBM Cognos Products: Viewer
  9370. *| (C) Copyright IBM Corp. 2013
  9371. *|
  9372. *| US Government Users Restricted Rights - Use, duplication or
  9373. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9374. *|
  9375. *+------------------------------------------------------------------------+
  9376. */
  9377. function UnfreezeRowHeadingsAction()
  9378. {
  9379. }
  9380. UnfreezeRowHeadingsAction.prototype = new UndoableClientActionBase();
  9381. UnfreezeRowHeadingsAction.superclass = UndoableClientActionBase.prototype;
  9382. UnfreezeRowHeadingsAction.prototype.execute = function()
  9383. {
  9384. if (this.m_oCV.getPinFreezeManager()) {
  9385. var oReportDiv = document.getElementById("CVReport" + this.m_oCV.getId());
  9386. var containerId = this.m_sContainerId ? this.m_sContainerId : this.getSelectedContainerId();
  9387. //Selection borders in high contrast mode aren't cleaned up properly when cloned,
  9388. //so remove all selections before performing unfreeze
  9389. this.m_oCV.getSelectionController().resetSelections();
  9390. this.m_oCV.getPinFreezeManager().unfreezeContainerRowHeadings(containerId, oReportDiv);
  9391. this.addClientSideUndo(this, [containerId]);
  9392. }
  9393. };
  9394. UnfreezeRowHeadingsAction.prototype.getUndoHint = function()
  9395. {
  9396. return RV_RES.IDS_JS_UNFREEZEROWHEADINGS;
  9397. };
  9398. UnfreezeRowHeadingsAction.prototype.getUndoClass = function()
  9399. {
  9400. return "FreezeRowHeadings";
  9401. };
  9402. /**
  9403. * return true if the row headings for the selected container are frozen
  9404. */
  9405. UnfreezeRowHeadingsAction.prototype.areRowHeadingsFrozen = function()
  9406. {
  9407. if (this.m_oCV.getPinFreezeManager() && this.m_oCV.getPinFreezeManager().hasFrozenRowHeadings(this.getSelectedContainerId())) {
  9408. return true;
  9409. }
  9410. return false;
  9411. };
  9412. UnfreezeRowHeadingsAction.prototype.updateMenu = function(jsonSpec)
  9413. {
  9414. jsonSpec.visible = this.areRowHeadingsFrozen();
  9415. return jsonSpec;
  9416. };
  9417. /*
  9418. *+------------------------------------------------------------------------+
  9419. *| Licensed Materials - Property of IBM
  9420. *| IBM Cognos Products: Viewer
  9421. *| (C) Copyright IBM Corp. 2013
  9422. *|
  9423. *| US Government Users Restricted Rights - Use, duplication or
  9424. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9425. *|
  9426. *+------------------------------------------------------------------------+
  9427. */
  9428. function FreezeColumnHeadingsAction()
  9429. {
  9430. }
  9431. FreezeColumnHeadingsAction.prototype = new UndoableClientActionBase();
  9432. FreezeColumnHeadingsAction.superclass = UndoableClientActionBase.prototype;
  9433. FreezeColumnHeadingsAction.prototype.execute = function()
  9434. {
  9435. var lidToFreeze = this.m_sContainerId ? this.m_sContainerId : this.getSelectedCrosstabOrListContainerId();
  9436. if (lidToFreeze) {
  9437. //Selection borders in high contrast mode aren't cleaned up properly when cloned,
  9438. //so remove all selections before performing freeze
  9439. this.m_oCV.getSelectionController().resetSelections();
  9440. this.m_oCV.getPinFreezeManager().freezeContainerColumnHeadings(lidToFreeze);
  9441. this.addClientSideUndo(this, [lidToFreeze]);
  9442. }
  9443. };
  9444. FreezeColumnHeadingsAction.prototype.getUndoHint = function()
  9445. {
  9446. return RV_RES.IDS_JS_FREEZECOLUMNHEADINGS;
  9447. };
  9448. FreezeColumnHeadingsAction.prototype.getUndoClass = function()
  9449. {
  9450. return "UnfreezeColumnHeadings";
  9451. };
  9452. FreezeColumnHeadingsAction.prototype.getSelectedCrosstabOrListContainerLid = function()
  9453. {
  9454. var selectedObjects = this.m_oCV.getSelectionController().getAllSelectedObjects();
  9455. if (selectedObjects && selectedObjects.length &&
  9456. (selectedObjects[0].getDataContainerType() == "crosstab" ||
  9457. selectedObjects[0].getDataContainerType() == "list")) {
  9458. var lid=(selectedObjects[0].getLayoutElementId());
  9459. if (lid) {
  9460. return lid;
  9461. }
  9462. }
  9463. return null;
  9464. };
  9465. /**
  9466. * return the selected container id (without namespace) if it is valid for pin freeze Columns (ie: its a crosstab)
  9467. */
  9468. FreezeColumnHeadingsAction.prototype.getSelectedCrosstabOrListContainerId = function()
  9469. {
  9470. var lid = this.getSelectedCrosstabOrListContainerLid();
  9471. if (lid) {
  9472. return this.removeNamespace(lid);
  9473. }
  9474. return null;
  9475. };
  9476. /**
  9477. * Column headings can be frozen if the layout type is right and the Column headings aren't already frozen.
  9478. */
  9479. FreezeColumnHeadingsAction.prototype.canFreezeColumnHeadings = function()
  9480. {
  9481. var pfManager = this.m_oCV.getPinFreezeManager();
  9482. if (pfManager) {
  9483. var containerId=this.getSelectedCrosstabOrListContainerId();
  9484. if (containerId) {
  9485. if(!pfManager.hasFrozenColumnHeadings(containerId) && pfManager.getValidSelectedContainerId(true)) {
  9486. return true;
  9487. }
  9488. }
  9489. return false;
  9490. }
  9491. };
  9492. FreezeColumnHeadingsAction.prototype.updateMenu = function(jsonSpec)
  9493. {
  9494. jsonSpec.visible = this.canFreezeColumnHeadings();
  9495. return jsonSpec;
  9496. };
  9497. /*
  9498. *+------------------------------------------------------------------------+
  9499. *| Licensed Materials - Property of IBM
  9500. *| IBM Cognos Products: Viewer
  9501. *| (C) Copyright IBM Corp. 2013
  9502. *|
  9503. *| US Government Users Restricted Rights - Use, duplication or
  9504. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9505. *|
  9506. *+------------------------------------------------------------------------+
  9507. */
  9508. function UnfreezeColumnHeadingsAction()
  9509. {
  9510. }
  9511. UnfreezeColumnHeadingsAction.prototype = new UndoableClientActionBase();
  9512. UnfreezeColumnHeadingsAction.superclass = UndoableClientActionBase.prototype;
  9513. UnfreezeColumnHeadingsAction.prototype.execute = function()
  9514. {
  9515. if (this.m_oCV.getPinFreezeManager()) {
  9516. var oReportDiv = document.getElementById("CVReport" + this.m_oCV.getId());
  9517. var containerId = this.m_sContainerId ? this.m_sContainerId : this.getSelectedContainerId();
  9518. //Selection borders in high contrast mode aren't cleaned up properly when cloned,
  9519. //so remove all selections before performing unfreeze
  9520. this.m_oCV.getSelectionController().resetSelections();
  9521. this.m_oCV.getPinFreezeManager().unfreezeContainerColumnHeadings(containerId, oReportDiv);
  9522. this.addClientSideUndo(this, [containerId]);
  9523. }
  9524. };
  9525. UnfreezeColumnHeadingsAction.prototype.getUndoHint = function()
  9526. {
  9527. return RV_RES.IDS_JS_UNFREEZECOLUMNHEADINGS;
  9528. };
  9529. UnfreezeColumnHeadingsAction.prototype.getUndoClass = function()
  9530. {
  9531. return "FreezeColumnHeadings";
  9532. };
  9533. /**
  9534. * return true if the Column headings for the selected container are frozen
  9535. */
  9536. UnfreezeColumnHeadingsAction.prototype.areColumnHeadingsFrozen = function()
  9537. {
  9538. if (this.m_oCV.getPinFreezeManager() && this.m_oCV.getPinFreezeManager().hasFrozenColumnHeadings(this.getSelectedContainerId())) {
  9539. return true;
  9540. }
  9541. return false;
  9542. };
  9543. UnfreezeColumnHeadingsAction.prototype.updateMenu = function(jsonSpec)
  9544. {
  9545. jsonSpec.visible = this.areColumnHeadingsFrozen();
  9546. return jsonSpec;
  9547. };
  9548. /*
  9549. *+------------------------------------------------------------------------+
  9550. *| Licensed Materials - Property of IBM
  9551. *| IBM Cognos Products: Viewer
  9552. *| (C) Copyright IBM Corp. 2001, 2013
  9553. *|
  9554. *| US Government Users Restricted Rights - Use, duplication or
  9555. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9556. *|
  9557. *+------------------------------------------------------------------------+
  9558. */
  9559. /**
  9560. * GlossaryAction - implements IBM business glossary in cognos viewer
  9561. */
  9562. function GlossaryAction(){}
  9563. GlossaryAction.prototype = new CognosViewerAction();
  9564. /**
  9565. * Execute the IBM business glossary request
  9566. */
  9567. GlossaryAction.prototype.execute = function()
  9568. {
  9569. var cognosViewer = this.getCognosViewer();
  9570. cognosViewer.loadExtra();
  9571. var selectionController = cognosViewer.getSelectionController();
  9572. var selectionList = selectionController.getAllSelectedObjects();
  9573. if(selectionList.length > 0)
  9574. {
  9575. var config = null;
  9576. if(typeof MDSRV_CognosConfiguration != "undefined")
  9577. {
  9578. config = new MDSRV_CognosConfiguration();
  9579. var glossaryURI = "";
  9580. if(cognosViewer.envParams["glossaryURI"])
  9581. {
  9582. glossaryURI = cognosViewer.envParams["glossaryURI"];
  9583. }
  9584. config.addProperty("glossaryURI", glossaryURI);
  9585. config.addProperty("gatewayURI", cognosViewer.getGateway());
  9586. }
  9587. var searchPath = cognosViewer.envParams["ui.object"];
  9588. var sSelectionContext = getViewerSelectionContext(selectionController, new CSelectionContext(searchPath));
  9589. var glossaryHelper = new MDSRV_BusinessGlossary(config, sSelectionContext);
  9590. glossaryHelper.open();
  9591. }
  9592. };
  9593. GlossaryAction.prototype.updateMenu = function(jsonSpec)
  9594. {
  9595. if (!this.getCognosViewer().bCanUseGlossary) {
  9596. return "";
  9597. }
  9598. var bContext = this.selectionHasContext();
  9599. if (!bContext || this.getCognosViewer().envParams["glossaryURI"] == null || this.getCognosViewer().envParams["glossaryURI"] == "")
  9600. {
  9601. jsonSpec.disabled = true;
  9602. }
  9603. else
  9604. {
  9605. jsonSpec.disabled = false;
  9606. }
  9607. return jsonSpec;
  9608. };
  9609. /*
  9610. *+------------------------------------------------------------------------+
  9611. *| Licensed Materials - Property of IBM
  9612. *| IBM Cognos Products: Viewer
  9613. *| (C) Copyright IBM Corp. 2001, 2011
  9614. *|
  9615. *| US Government Users Restricted Rights - Use, duplication or
  9616. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9617. *|
  9618. *+------------------------------------------------------------------------+
  9619. */
  9620. function GroupAction()
  9621. {
  9622. this.m_sAction = "GroupColumn";
  9623. }
  9624. GroupAction.prototype = new ModifyReportAction();
  9625. GroupAction.prototype.getUndoHint = function()
  9626. {
  9627. return RV_RES.IDS_JS_GROUP_UNGROUP;
  9628. };
  9629. GroupAction.prototype.updateMenu = function(jsonSpec) {
  9630. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  9631. if (! jsonSpec.visible)
  9632. {
  9633. return jsonSpec;
  9634. }
  9635. var selectionController = this.m_oCV.getSelectionController();
  9636. var aSelectedObjects = selectionController.getAllSelectedObjects();
  9637. if (aSelectedObjects.length === 0 || selectionController.getDataContainerType() != 'list')
  9638. {
  9639. return this.disableMenuItem(jsonSpec);
  9640. }
  9641. if (aSelectedObjects[0].getCellRef().getAttribute("no_data_item_column") === "true")
  9642. {
  9643. return this.disableMenuItem(jsonSpec);
  9644. }
  9645. var bDimensionalDataSource = !selectionController.isRelational();
  9646. for (var index = 0; index < aSelectedObjects.length; ++index)
  9647. {
  9648. /* disable if a selected object is a measure and
  9649. * data source is dimentional or its layout type is 'summary
  9650. */
  9651. if (selectionController.getUsageInfo(aSelectedObjects[index].getSelectedContextIds()[0][0]) == selectionController.c_usageMeasure &&
  9652. (bDimensionalDataSource || aSelectedObjects[index].getLayoutType() === "summary")) {
  9653. return this.disableMenuItem(jsonSpec);
  9654. }
  9655. }
  9656. jsonSpec.disabled = false;
  9657. jsonSpec.iconClass = "group";
  9658. return jsonSpec;
  9659. };
  9660. GroupAction.prototype.disableMenuItem = function(jsonSpec)
  9661. {
  9662. jsonSpec.disabled = true;
  9663. jsonSpec.iconClass = "groupDisabled";
  9664. return jsonSpec;
  9665. };
  9666. GroupAction.prototype.addActionContextAdditionalParms = function()
  9667. {
  9668. return this.addClientContextData(/*maxValuesPerRDI*/3);
  9669. };
  9670. /*
  9671. *+------------------------------------------------------------------------+
  9672. *| Licensed Materials - Property of IBM
  9673. *| IBM Cognos Products: Viewer
  9674. *| (C) Copyright IBM Corp. 2001, 2011
  9675. *|
  9676. *| US Government Users Restricted Rights - Use, duplication or
  9677. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9678. *|
  9679. *+------------------------------------------------------------------------+
  9680. */
  9681. // Helper class which takes of of dynamic loading of menus
  9682. function LoadMenuAction()
  9683. {
  9684. this.m_action = null;
  9685. }
  9686. LoadMenuAction.prototype = new CognosViewerAction();
  9687. LoadMenuAction.prototype.FROM_TOOLBAR = 'toolbar';
  9688. LoadMenuAction.prototype.FROM_TOOLBAR_BLUEDOTMENU = 'toolbarBlueDotMenu';
  9689. LoadMenuAction.prototype.FROM_CONTEXTMENU = 'contextMenu';
  9690. LoadMenuAction.prototype.FROM_CONTEXTMENU_MOREACTIONS = 'contextMenuMoreActions';
  9691. LoadMenuAction.prototype.TOOLBAR_UPDATE_EVENT ="com.ibm.bux.widgetchrome.toolbar.update";
  9692. LoadMenuAction.prototype.CONTEXTMENU_UPDATE_EVENT ="com.ibm.bux.widget.contextMenu.update";
  9693. LoadMenuAction.prototype.setRequestParms = function(payload)
  9694. {
  9695. this.m_action = payload.action;
  9696. this.m_sFrom = (payload.from) ? payload.from : this.FROM_TOOLBAR;
  9697. };
  9698. LoadMenuAction.prototype.execute = function()
  9699. {
  9700. var actionFactory = this.m_oCV.getActionFactory();
  9701. var action = actionFactory.load(this.m_action);
  9702. var toolbarItem = this.getMenuSpec();
  9703. var buildMenuCallback = GUtil.generateCallback(this.buildMenuCallback, [toolbarItem], this);
  9704. toolbarItem = action.buildMenu(toolbarItem, buildMenuCallback);
  9705. if(toolbarItem != null)
  9706. {
  9707. this.buildMenuCallback(toolbarItem);
  9708. }
  9709. };
  9710. LoadMenuAction.prototype.buildMenuCallback = function(toolbarItem)
  9711. {
  9712. toolbarItem.open = true;
  9713. toolbarItem.action = null;
  9714. this.fireEvent(toolbarItem);
  9715. };
  9716. LoadMenuAction.prototype.getMenuSpec = function() {
  9717. var oCV = this.m_oCV;
  9718. var sFrom = this.m_sFrom;
  9719. if (!sFrom || !oCV) {
  9720. return null;
  9721. }
  9722. var parentNode = null;
  9723. var menuSpec = null;
  9724. switch (sFrom) {
  9725. case this.FROM_TOOLBAR:
  9726. parentNode = oCV.getToolbar();
  9727. break;
  9728. case this.FROM_TOOLBAR_BLUEDOTMENU:
  9729. parentNode = oCV.findBlueDotMenu();
  9730. break;
  9731. case this.FROM_CONTEXTMENU_MOREACTIONS:
  9732. parentNode = oCV.findToolbarItem("MoreActions", oCV.getContextMenu());
  9733. break;
  9734. }
  9735. if (parentNode) {
  9736. menuSpec = oCV.findToolbarItem(this.m_action, parentNode);
  9737. }
  9738. if (menuSpec) {
  9739. //attach 'from' to menuSpec
  9740. menuSpec.from = sFrom;
  9741. }
  9742. return menuSpec;
  9743. };
  9744. LoadMenuAction.prototype.fireEvent = function(buttonSpec) {
  9745. var updateItems = [];
  9746. if (buttonSpec) {
  9747. updateItems.push(buttonSpec);
  9748. }
  9749. var widget = this.m_oCV.getViewerWidget();
  9750. var sFrom = buttonSpec.from;
  9751. switch (sFrom) {
  9752. case this.FROM_TOOLBAR:
  9753. case this.FROM_TOOLBAR_BLUEDOTMENU:
  9754. widget.fireEvent( this.TOOLBAR_UPDATE_EVENT, null, updateItems);
  9755. break;
  9756. case this.FROM_CONTEXTMENU_MOREACTIONS:
  9757. widget.fireEvent( this.CONTEXTMENU_UPDATE_EVENT, null, updateItems);
  9758. break;
  9759. };
  9760. };/*
  9761. *+------------------------------------------------------------------------+
  9762. *| Licensed Materials - Property of IBM
  9763. *| IBM Cognos Products: Viewer
  9764. *| (C) Copyright IBM Corp. 2001, 2011
  9765. *|
  9766. *| US Government Users Restricted Rights - Use, duplication or
  9767. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9768. *|
  9769. *+------------------------------------------------------------------------+
  9770. */
  9771. function MoveAction()
  9772. {
  9773. this.m_sAction = "Reorder";
  9774. }
  9775. MoveAction.prototype = new DragDropAction();
  9776. MoveAction.prototype.setRequestParms = function(payload)
  9777. {
  9778. this.m_order = payload.order;
  9779. };
  9780. MoveAction.prototype.canMoveLeftRight = function(sDirection)
  9781. {
  9782. var selectionController = this.m_oCV.getSelectionController();
  9783. if (selectionController && selectionController.getAllSelectedObjects().length == 1)
  9784. {
  9785. var cellRef = selectionController.getAllSelectedObjects()[0].getCellRef();
  9786. if (sDirection == "right" && cellRef.nextSibling)
  9787. {
  9788. return true;
  9789. }
  9790. else if (sDirection == "left" && cellRef.previousSibling)
  9791. {
  9792. return true;
  9793. }
  9794. }
  9795. return false;
  9796. };
  9797. MoveAction.prototype.updateMenu = function(jsonSpec)
  9798. {
  9799. if (!this.canMove())
  9800. {
  9801. jsonSpec = "";
  9802. }
  9803. else
  9804. {
  9805. var selectionController = this.m_oCV.getSelectionController();
  9806. if (selectionController && selectionController.getAllSelectedObjects().length > 1)
  9807. {
  9808. jsonSpec.disabled = true;
  9809. jsonSpec.items = null;
  9810. }
  9811. else
  9812. {
  9813. jsonSpec.disabled = false;
  9814. jsonSpec.items = [];
  9815. jsonSpec.items.push({ disabled: !this.canMoveLeftRight("left"), name: "Move", label: RV_RES.IDS_JS_LEFT, iconClass: "moveLeft", action: { name: "Move", payload: {order:"left"} }, items: null });
  9816. jsonSpec.items.push({ disabled: !this.canMoveLeftRight("right"), name: "Move", label: RV_RES.IDS_JS_RIGHT, iconClass: "moveRight", action: { name: "Move", payload: {order:"right"} }, items: null });
  9817. }
  9818. }
  9819. return jsonSpec;
  9820. };
  9821. MoveAction.prototype.addActionContextAdditionalParms = function()
  9822. {
  9823. var selectionController = this.getCognosViewer().getSelectionController();
  9824. var targetRef = null;
  9825. if (this.m_order == "right")
  9826. {
  9827. targetRef = selectionController.getAllSelectedObjects()[0].getCellRef().nextSibling;
  9828. }
  9829. else
  9830. {
  9831. targetRef = selectionController.getAllSelectedObjects()[0].getCellRef().previousSibling;
  9832. }
  9833. var target = selectionController.buildSelectionObject(targetRef, null);
  9834. var tag = this.m_order == "right" ? "after" : "before";
  9835. //always use layout tag when it is available.
  9836. var tagValue = this.getRAPLayoutTag(targetRef);
  9837. tagValue = (tagValue != null ) ? tagValue : target.getColumnName();
  9838. return this.getSelectedCellTags() + "<" + tag + ">" + xml_encode(tagValue) + "</" + tag + ">";
  9839. };
  9840. /*
  9841. *+------------------------------------------------------------------------+
  9842. *| Licensed Materials - Property of IBM
  9843. *| IBM Cognos Products: Viewer
  9844. *| (C) Copyright IBM Corp. 2001, 2011
  9845. *|
  9846. *| US Government Users Restricted Rights - Use, duplication or
  9847. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9848. *|
  9849. *+------------------------------------------------------------------------+
  9850. */
  9851. /**
  9852. * This is the base class for refreshing the report. It'll get the latest
  9853. * saved output or rerun the report if there's no saved output
  9854. */
  9855. function RefreshViewAction()
  9856. {
  9857. this.m_bCanvasRefreshEvent = false;
  9858. }
  9859. RefreshViewAction.prototype = new CognosViewerAction();
  9860. RefreshViewAction.prototype.addCommonOptions = function(oRequest)
  9861. {
  9862. // removed the cache CM response about the saved outputs. This will
  9863. // force the Snapshots menu to get updated
  9864. var widget = this.getCognosViewer().getViewerWidget();
  9865. if (this.m_bCanvasRefreshEvent && widget.getSavedOutputSearchPath() != null)
  9866. {
  9867. oRequest.addFormField("ui.savedOutputSearchPath", encodeURIComponent(widget.getSavedOutputSearchPath()));
  9868. }
  9869. else
  9870. {
  9871. widget.setSavedOutputsCMResponse(null);
  9872. widget.setSavedOutputSearchPath(null);
  9873. }
  9874. oRequest.addFormField("run.outputFormat", "HTML");
  9875. // need since we might be going from saved output to live if the saved output is no longer available
  9876. oRequest.addFormField("widget.reloadToolbar", "true");
  9877. // Clear the properties dialog to it'll get rebuilt. This is needed for the 'View report specification' link in
  9878. // case we go from saved output to live during the refresh operation
  9879. widget.clearPropertiesDialog();
  9880. var formWarpRequest = document.getElementById("formWarpRequest" + this.getCognosViewer().getId());
  9881. oRequest.addFormField("ui.object", formWarpRequest["reRunObj"].value);
  9882. };
  9883. RefreshViewAction.prototype.execute = function()
  9884. {
  9885. var oRequest = this.createCognosViewerDispatcherEntry( "buxDropReportOnCanvas" );
  9886. this.addCommonOptions(oRequest);
  9887. var oCV = this.getCognosViewer();
  9888. var widget = oCV.getViewerWidget();
  9889. if (oCV.getCurrentlySelectedTab() && widget.getSavedOutput()) {
  9890. oCV.setKeepTabSelected(oCV.getCurrentlySelectedTab());
  9891. }
  9892. this.getCognosViewer().dispatchRequest(oRequest);
  9893. };
  9894. RefreshViewAction.prototype.doAddActionContext = function()
  9895. {
  9896. return false;
  9897. };
  9898. RefreshViewAction.prototype.updateMenu = function(jsonSpec)
  9899. {
  9900. jsonSpec.disabled = false;
  9901. var oCV = this.getCognosViewer();
  9902. if( oCV )
  9903. {
  9904. var widget = oCV.getViewerWidget();
  9905. if( widget && widget.getSavedOutputSearchPath() != null)
  9906. {
  9907. jsonSpec.disabled = true;
  9908. }
  9909. }
  9910. return jsonSpec;
  9911. };
  9912. /*
  9913. *+------------------------------------------------------------------------+
  9914. *| Licensed Materials - Property of IBM
  9915. *| IBM Cognos Products: Viewer
  9916. *| (C) Copyright IBM Corp. 2001, 2011
  9917. *|
  9918. *| US Government Users Restricted Rights - Use, duplication or
  9919. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9920. *|
  9921. *+------------------------------------------------------------------------+
  9922. */
  9923. /**
  9924. * This action is used when we get an event to refresh a view from the canvas
  9925. */
  9926. function RefreshViewEventAction()
  9927. {
  9928. this.m_bCanvasRefreshEvent = true;
  9929. }
  9930. RefreshViewEventAction.prototype = new RefreshViewAction();
  9931. /*
  9932. *+------------------------------------------------------------------------+
  9933. *| Licensed Materials - Property of IBM
  9934. *| IBM Cognos Products: Viewer
  9935. *| (C) Copyright IBM Corp. 2001, 2011
  9936. *|
  9937. *| US Government Users Restricted Rights - Use, duplication or
  9938. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9939. *|
  9940. *+------------------------------------------------------------------------+
  9941. */
  9942. function RenameDataItemAction()
  9943. {
  9944. this.m_sAction = "Rename";
  9945. this.m_newLabel = "";
  9946. this.m_prevLabel= "";
  9947. this.m_containerId = "";
  9948. this.m_bUndoAdded = false;
  9949. }
  9950. RenameDataItemAction.prototype = new ModifyReportAction();
  9951. RenameDataItemAction.prototype.getUndoHint = function()
  9952. {
  9953. return RV_RES.IDS_JS_RENAME;
  9954. };
  9955. RenameDataItemAction.prototype.saveSpecForUndo = function()
  9956. {
  9957. return true;
  9958. };
  9959. RenameDataItemAction.prototype.getContainerId = function()
  9960. {
  9961. return this.m_containerId;
  9962. };
  9963. RenameDataItemAction.prototype.addActionContextAdditionalParms = function()
  9964. {
  9965. var tagParams = this.getSelectedCellTags();
  9966. return (tagParams +
  9967. "<prevName>" + xml_encode(this.m_prevLabel) + "</prevName>" +
  9968. "<toName>" + xml_encode(this.m_newLabel) + "</toName>");
  9969. };
  9970. RenameDataItemAction.prototype.onMouseOver = function(evt)
  9971. {
  9972. var ctxNode = getCtxNodeFromEvent(evt);
  9973. ctxNode.style.cursor = this.canRename() ? "text" : "default";
  9974. };
  9975. RenameDataItemAction.prototype.onMouseOut = function(evt)
  9976. {
  9977. var ctxNode = getCtxNodeFromEvent(evt);
  9978. ctxNode.style.cursor = "default";
  9979. };
  9980. RenameDataItemAction.prototype.onDoubleClick = function(evt)
  9981. {
  9982. if (this.canRename()) {
  9983. var ctxNode = getCtxNodeFromEvent(evt);
  9984. this.insertTextArea(ctxNode);
  9985. }
  9986. };
  9987. RenameDataItemAction.prototype.canRename = function()
  9988. {
  9989. if (this.m_oCV.isBlacklisted("RenameFromContextMenu")) {
  9990. return false;
  9991. }
  9992. var selectionController = this.m_oCV.getSelectionController();
  9993. var selLength = selectionController.getAllSelectedObjects().length;
  9994. if (selLength==1 && !this.m_oCV.isLimitedInteractiveMode()) {
  9995. var selObj = selectionController.getAllSelectedObjects()[0];
  9996. if (selObj.hasContextInformation()) {
  9997. var ctxValue = selObj.getSelectedContextIds()[0][0];
  9998. var cellRef = selObj.getCellRef();
  9999. return this.checkRenamableConditions(selObj, cellRef, ctxValue, selectionController);
  10000. }
  10001. }
  10002. return false;
  10003. };
  10004. RenameDataItemAction.prototype.checkRenamableConditions = function(selObj, cellRef, ctxValue, selectionController)
  10005. {
  10006. if(selObj.isHomeCell()) {
  10007. return false;
  10008. }
  10009. if (selObj.getLayoutType() == 'columnTitle' && selectionController.selectionsHaveCalculationMetadata()) {
  10010. if (selObj.getDataContainerType() == 'crosstab' && !selectionController.areSelectionsMeasureOrCalculation()) {
  10011. return false;
  10012. }
  10013. return true;
  10014. }
  10015. if (selObj.getLayoutType() == 'columnTitle' && selObj.getDataContainerType() == 'crosstab' ) {
  10016. return false;
  10017. }
  10018. if (selObj.getLayoutType() != 'columnTitle') {
  10019. return false;
  10020. }
  10021. if (cellRef.getAttribute("cc") == "true") {
  10022. return false;
  10023. }
  10024. if (cellRef.getAttribute("CTNM") != null && selectionController.getMun(ctxValue) != "") {
  10025. return false;
  10026. }
  10027. return true;
  10028. };
  10029. RenameDataItemAction.prototype.insertTextArea = function(ctxNode)
  10030. {
  10031. var label = document.createElement("label");
  10032. label.style.height = "1px";
  10033. label.style.width = "1px";
  10034. label.style.overflow = "hidden";
  10035. label.style.position = "absolute";
  10036. label.style.left = "0px";
  10037. label.style.top = "-500px";
  10038. label.setAttribute("for", "rename" + this.m_oCV.getId());
  10039. label.id = "renameLabel" + this.m_oCV.getId();
  10040. label.innerHTML = RV_RES.IDS_JS_RENAME_LABEL;
  10041. var input = document.createElement("input");
  10042. input.id = "rename" + this.m_oCV.getId();
  10043. input.name = "rename" + this.m_oCV.getId();
  10044. input.type = "text";
  10045. input.value = ctxNode.childNodes[0].nodeValue;
  10046. input.style.backgroundColor = "transparent";
  10047. input.style.borderWidth = "0px";
  10048. input.style.padding = "0px";
  10049. input.style.margin = "0px";
  10050. input.setAttribute("role", "textbox");
  10051. input.setAttribute("aria-labelledby", "renameLabel" + this.m_oCV.getId());
  10052. // calculated the width of the textbox. Get the width of the TD and subtract the width of
  10053. // any none inside the TD that's not the currently selection
  10054. var width = ctxNode.parentNode.scrollWidth - 10;
  10055. var nextSibling = ctxNode.parentNode.firstChild;
  10056. while (nextSibling) {
  10057. if (nextSibling != ctxNode) {
  10058. width -= nextSibling.scrollWidth;
  10059. }
  10060. nextSibling = nextSibling.nextSibling;
  10061. }
  10062. input.style.width = width + "px";
  10063. input.ctxNode = ctxNode;
  10064. input.action = this;
  10065. input.originalLabel = ctxNode.childNodes[0].nodeValue;
  10066. if(isIE())
  10067. {
  10068. input.style.fontFamily = ctxNode.currentStyle.fontFamily;
  10069. input.style.fontSize = ctxNode.currentStyle.fontSize;
  10070. input.style.fontStyle = ctxNode.currentStyle.fontStyle;
  10071. input.style.fontVariant = ctxNode.currentStyle.fontVariant;
  10072. input.style.fontWeight = ctxNode.currentStyle.fontWeight;
  10073. input.attachEvent("onblur", this.onBlur);
  10074. input.attachEvent("onkeydown", this.onKeyDown);
  10075. input.style.overflow = "hidden";
  10076. }
  10077. else
  10078. {
  10079. input.style.font = "inherit";
  10080. input.addEventListener("blur", this.onBlur, false);
  10081. input.addEventListener("keydown", this.onKeyDown, false);
  10082. input.style.overflow = "visible";
  10083. }
  10084. ctxNode.innerHTML = "";
  10085. ctxNode.appendChild(label);
  10086. ctxNode.appendChild(input);
  10087. input.focus();
  10088. input.select();
  10089. };
  10090. /**
  10091. * Returns true if the mouse down event is on the rename input field
  10092. * @param {Object} evt
  10093. */
  10094. RenameDataItemAction.prototype.onMouseDown = function(evt) {
  10095. if (evt) {
  10096. try {
  10097. var node = evt.originalTarget ? evt.originalTarget : evt.srcElement;
  10098. if (node && node.getAttribute("id") === "rename" + this.m_oCV.getId()) {
  10099. return true;
  10100. }
  10101. }
  10102. catch(ex) {
  10103. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  10104. }
  10105. }
  10106. return false;
  10107. };
  10108. RenameDataItemAction.prototype.onBlur = function(evt)
  10109. {
  10110. var node;
  10111. if(isIE())
  10112. {
  10113. node = getNodeFromEvent(evt);
  10114. }
  10115. else
  10116. {
  10117. node = this;
  10118. }
  10119. var ctxNode = node.ctxNode;
  10120. var renameAction = node.action;
  10121. var newLabel = node.value != "" ? node.value : node.innerHTML;
  10122. renameAction.updateLabel(ctxNode, newLabel, node.originalLabel);
  10123. };
  10124. RenameDataItemAction.prototype.onKeyDown = function(evt)
  10125. {
  10126. var newLabel = "";
  10127. var node = getNodeFromEvent(evt);
  10128. if(evt.keyCode == "13")
  10129. {
  10130. newLabel = node.value != "" ? node.value : node.originalLabel;
  10131. }
  10132. else if(evt.keyCode == "27")
  10133. {
  10134. newLabel = node.originalLabel;
  10135. }
  10136. if(newLabel != "")
  10137. {
  10138. var ctxNode = node.ctxNode;
  10139. var renameAction = node.action;
  10140. renameAction.updateLabel(ctxNode, newLabel, node.originalLabel);
  10141. return stopEventBubble(evt);
  10142. }
  10143. else
  10144. {
  10145. return true;
  10146. }
  10147. };
  10148. RenameDataItemAction.prototype.updateLabel = function(ctxNode, newLabel, originalLabel)
  10149. {
  10150. this.m_newLabel = newLabel;
  10151. this.m_prevLabel= originalLabel;
  10152. ctxNode.innerHTML = "";
  10153. ctxNode.appendChild(document.createTextNode(newLabel));
  10154. var selectionController = this.m_oCV.getSelectionController();
  10155. if(selectionController != null && newLabel != originalLabel)
  10156. {
  10157. var selectionFactory = new CSelectionObjectFactory(selectionController);
  10158. this.m_containerId = this.removeNamespace(selectionFactory.getLayoutElementId(ctxNode));
  10159. var SelObj = selectionFactory.getSelectionObject(ctxNode.parentNode);
  10160. selectionController.m_aSelectedObjects[0] = SelObj;
  10161. // reset the focus to the span we just renamed.
  10162. var allChildren = SelObj.getCellRef().getElementsByTagName("span");
  10163. var span = null;
  10164. if (allChildren) {
  10165. for (var i = 0; i < allChildren.length; i++) {
  10166. span = allChildren[i];
  10167. if (span.getAttribute("ctx") != null && span.style.visibility != "hidden") {
  10168. span.focus();
  10169. break;
  10170. }
  10171. }
  10172. }
  10173. this.execute();
  10174. }
  10175. };
  10176. RenameDataItemAction.prototype.buildUrl = function()
  10177. {
  10178. var urlRequest = "b_action=cognosViewer&ui.action=modifyReport&cv.responseFormat=xml";
  10179. var actionContext = this.addActionContext();
  10180. urlRequest += "&cv.actionContext=" + encodeURIComponent(actionContext);
  10181. if (window.gViewerLogger)
  10182. {
  10183. window.gViewerLogger.log('Action context', actionContext, "xml");
  10184. }
  10185. urlRequest += "&ui.object=" + encodeURIComponent(this.m_oCV.envParams["ui.object"]);
  10186. if(typeof this.m_oCV.envParams["ui.spec"] != "undefined")
  10187. {
  10188. urlRequest += "&ui.spec=" + encodeURIComponent(this.m_oCV.envParams["ui.spec"]);
  10189. }
  10190. if(typeof this.m_oCV.getModelPath() != "")
  10191. {
  10192. urlRequest += "&modelPath=" + encodeURIComponent(this.m_oCV.getModelPath());
  10193. }
  10194. return urlRequest;
  10195. };
  10196. RenameDataItemAction.prototype.keepRAPCache = function()
  10197. {
  10198. return false;
  10199. };
  10200. RenameDataItemAction.prototype.reuseQuery = function() { return true; };
  10201. /*
  10202. *+------------------------------------------------------------------------+
  10203. *| Licensed Materials - Property of IBM
  10204. *| IBM Cognos Products: Viewer
  10205. *| (C) Copyright IBM Corp. 2001, 2011
  10206. *|
  10207. *| US Government Users Restricted Rights - Use, duplication or
  10208. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10209. *|
  10210. *+------------------------------------------------------------------------+
  10211. */
  10212. function RenameFromContextMenuAction() {}
  10213. RenameFromContextMenuAction.prototype = new RenameDataItemAction();
  10214. RenameFromContextMenuAction.prototype.canRename = function(selObj)
  10215. {
  10216. if (!selObj || selObj.hasContextInformation() == false)
  10217. {
  10218. return false;
  10219. }
  10220. var selectionController = this.m_oCV.getSelectionController();
  10221. var ctxValue = selObj.getSelectedContextIds()[0][0];
  10222. var cellRef = selObj.getCellRef();
  10223. return this.checkRenamableConditions(selObj, cellRef, ctxValue, selectionController);
  10224. };
  10225. RenameFromContextMenuAction.prototype.updateMenu = function(jsonSpec)
  10226. {
  10227. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  10228. if (! jsonSpec.visible)
  10229. {
  10230. return jsonSpec;
  10231. }
  10232. var selectionController = this.m_oCV.getSelectionController();
  10233. var selLength = selectionController.getAllSelectedObjects().length;
  10234. if (selLength != 1)
  10235. {
  10236. for (var selIndex=0; selIndex < selLength; selIndex++)
  10237. {
  10238. if (!this.canRename(selectionController.getAllSelectedObjects()[selIndex]))
  10239. {
  10240. return "";
  10241. }
  10242. }
  10243. jsonSpec.disabled = true;
  10244. }
  10245. else
  10246. {
  10247. if (!this.canRename(selectionController.getAllSelectedObjects()[0]))
  10248. {
  10249. jsonSpec = "";
  10250. }
  10251. else
  10252. {
  10253. jsonSpec.disabled = false;
  10254. }
  10255. }
  10256. return jsonSpec;
  10257. };
  10258. RenameFromContextMenuAction.prototype.getSpanFromCellRef = function(cellRef)
  10259. {
  10260. var allChildren = cellRef.getElementsByTagName("span");
  10261. var span = null;
  10262. if (allChildren) {
  10263. for (var i = 0; i < allChildren.length; i++) {
  10264. span = allChildren[i];
  10265. if (span.getAttribute("ctx") != null && span.style.visibility != "hidden") {
  10266. break;
  10267. }
  10268. }
  10269. }
  10270. return span;
  10271. };
  10272. RenameFromContextMenuAction.prototype.execute = function()
  10273. {
  10274. var cellRef = this.m_oCV.getSelectionController().getAllSelectedObjects()[0].getCellRef();
  10275. if (cellRef)
  10276. {
  10277. var span = this.getSpanFromCellRef(cellRef);
  10278. var renameDataItemAction = this.m_oCV.getAction("RenameDataItem");
  10279. renameDataItemAction.insertTextArea(span);
  10280. }
  10281. };
  10282. /*
  10283. *+------------------------------------------------------------------------+
  10284. *| Licensed Materials - Property of IBM
  10285. *| IBM Cognos Products: Viewer
  10286. *| (C) Copyright IBM Corp. 2001, 2014
  10287. *|
  10288. *| US Government Users Restricted Rights - Use, duplication or
  10289. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10290. *|
  10291. *+------------------------------------------------------------------------+
  10292. */
  10293. function ResetToOriginalAction() {}
  10294. ResetToOriginalAction.prototype = new CognosViewerAction();
  10295. ResetToOriginalAction.prototype.updateMenu = function(jsonSpec) {
  10296. var bBaseReportIsAvailable = this.getCognosViewer().envParams.baseReportAvailable;
  10297. jsonSpec.disabled = ( bBaseReportIsAvailable === "false" ) ? true : jsonSpec.disabled;
  10298. return jsonSpec;
  10299. };
  10300. ResetToOriginalAction.prototype.execute = function()
  10301. {
  10302. var confirmationDialog = viewer.dialogs.ConfirmationDialog(
  10303. RV_RES.IDS_JS_RESET_TO_ORIGINAL, /* title */
  10304. RV_RES.IDS_JS_RESET_TO_ORIGINAL_WARNING, /* main message */
  10305. RV_RES.IDS_JS_RESET_TO_ORIGINAL_WARNING_DESC, /* description */
  10306. null, /* icon class */
  10307. this, /* caller object */
  10308. this.executeAction /* yes Handler function of caller object. */
  10309. );
  10310. confirmationDialog.startup();
  10311. confirmationDialog.show();
  10312. };
  10313. ResetToOriginalAction.prototype.executeAction = function(actionObject)
  10314. {
  10315. this.gatherFilterInfoBeforeAction("ResetToOriginal");
  10316. ChangePaletteAction.reset(this.getCognosViewer());
  10317. };
  10318. ResetToOriginalAction.prototype.dispatchRequest = function(filters)
  10319. {
  10320. var viewer = this.getCognosViewer();
  10321. var widget = viewer.getViewerWidget();
  10322. widget.reset();
  10323. var sOriginalItem = widget.getAttributeValue("originalReport");
  10324. if (!sOriginalItem) {
  10325. //We can't reset to an original report....reset to the last saved report.
  10326. var sSavedItem = widget.getSavedItem();
  10327. if (widget.isSavedReport(sOriginalItem, sSavedItem)) {
  10328. sOriginalItem=sSavedItem;
  10329. }
  10330. }
  10331. var sOriginalReportPart = widget.getAttributeValue("originalReportPart");
  10332. var sCVobjectPermissions = viewer.envParams["cv.objectPermissions"];
  10333. //save the configuration info that shouldn't be deleted
  10334. var sBpmRestURI = viewer.envParams['bpmRestURI'];
  10335. var sGlossaryURI = viewer.envParams['glossaryURI'];
  10336. var sMetadataInformationURI = viewer.envParams['metadataInformationURI'];
  10337. var sRoutingServerGroup = viewer.envParams["ui.routingServerGroup"];
  10338. delete viewer.envParams;
  10339. viewer.envParams = {};
  10340. viewer.envParams["ui.object"] = sOriginalItem;
  10341. viewer.envParams["originalReport"] = sOriginalItem;
  10342. viewer.envParams["bux"] = "true";
  10343. viewer.envParams["cv.objectPermissions"] = sCVobjectPermissions;
  10344. viewer.envParams["ui.routingServerGroup"] = sRoutingServerGroup;
  10345. if( sBpmRestURI ){
  10346. viewer.envParams['bpmRestURI'] = sBpmRestURI;
  10347. }
  10348. if( sGlossaryURI ) {
  10349. viewer.envParams['glossaryURI'] = sGlossaryURI;
  10350. }
  10351. if( sMetadataInformationURI ) {
  10352. viewer.envParams['metadataInformationURI'] = sMetadataInformationURI ;
  10353. }
  10354. var cognosViewerRequest = this.createCognosViewerDispatcherEntry( "resetToOriginal" );
  10355. cognosViewerRequest.addFormField("run.outputFormat", "HTML");
  10356. cognosViewerRequest.addFormField( "widget.reloadToolbar", "true");
  10357. cognosViewerRequest.addFormField( "ui.reportDrop", "true");
  10358. // fix for COGCQ00897194
  10359. viewer.resetbHasPromptFlag();
  10360. cognosViewerRequest.addFormField("widget.forceGetParameters", "true");
  10361. if (filters != "") {
  10362. cognosViewerRequest.addFormField("cv.updateDataFilters", filters);
  10363. }
  10364. cognosViewerRequest.addFormField("run.prompt", "false");
  10365. var bIsReportPart = (sOriginalReportPart && sOriginalReportPart.length > 0);
  10366. if ( bIsReportPart ) {
  10367. cognosViewerRequest.addFormField( "reportpart_id", sOriginalReportPart );
  10368. }
  10369. viewer.hideReportInfo();
  10370. viewer.dispatchRequest( cognosViewerRequest );
  10371. //fire the modified event
  10372. this.fireModifiedReportEvent();
  10373. };
  10374. ResetToOriginalAction.prototype.doAddActionContext = function()
  10375. {
  10376. return false;
  10377. };
  10378. /*
  10379. * We want to show reset in Global area
  10380. * @override
  10381. */
  10382. ResetToOriginalAction.prototype.canShowMenuInGlobalArea = function()
  10383. {
  10384. return true;
  10385. };
  10386. /*
  10387. * This action is
  10388. * - valid on prompt part in gloabl area
  10389. * - valid on regular report in regular tab
  10390. * - not valid on prompt part in regular tab
  10391. *
  10392. * @override
  10393. */
  10394. ResetToOriginalAction.prototype.isValidMenuItem = function()
  10395. {
  10396. var viewer = this.getCognosViewer();
  10397. var widget = viewer.getViewerWidget();
  10398. if (widget.m_isInGlobalArea) {
  10399. return (this.isPromptWidget()? true : false);
  10400. } else {
  10401. return (this.isPromptWidget()? false : true);
  10402. }
  10403. };
  10404. /*
  10405. *+------------------------------------------------------------------------+
  10406. *| Licensed Materials - Property of IBM
  10407. *| IBM Cognos Products: Viewer
  10408. *| (C) Copyright IBM Corp. 2001, 2016
  10409. *|
  10410. *| US Government Users Restricted Rights - Use, duplication or
  10411. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10412. *|
  10413. *+------------------------------------------------------------------------+
  10414. */
  10415. function ResizeChartAction()
  10416. {
  10417. this.m_width = 0;
  10418. this.m_height = 0;
  10419. this.m_sAction = "ChangeDataContainerSize";
  10420. this.m_bRunReport = true;
  10421. this.m_oChart = null;
  10422. }
  10423. ResizeChartAction.prototype = new ModifyReportAction();
  10424. ResizeChartAction.prototype.isUndoable = function() { return false; };
  10425. ResizeChartAction.superclass = ModifyReportAction.prototype;
  10426. ResizeChartAction.prototype.runReport = function() { return this.m_bRunReport; };
  10427. ResizeChartAction.prototype.canBeQueued = function() { return true; };
  10428. ResizeChartAction.prototype.reuseQuery = function() { return true; };
  10429. ResizeChartAction.PADDING = {
  10430. getWidth: function() { return 2;},
  10431. getHeight: function() {return 2;}
  10432. };
  10433. ResizeChartAction.prototype.getActionKey = function() {
  10434. return "ResizeChartAction";
  10435. };
  10436. ResizeChartAction.prototype.setRequestParms = function(requestParms)
  10437. {
  10438. if(requestParms && requestParms.resize) {
  10439. this.m_width = parseInt(requestParms.resize.w, 10) - ResizeChartAction.PADDING.getWidth();
  10440. this.m_height = parseInt(requestParms.resize.h, 10) - ResizeChartAction.PADDING.getHeight();
  10441. }
  10442. };
  10443. ResizeChartAction.prototype.execute = function() {
  10444. if (this.m_oCV.m_readyToRespondToResizeEvent !== true) {
  10445. return; //not resize on initial loading.
  10446. }
  10447. if (this.m_oCV.getPinFreezeManager()) {
  10448. //Resize a container with frozen headings.
  10449. this.m_oCV.getPinFreezeManager().resize(this.m_width, this.m_height);
  10450. }
  10451. if (this.isActionApplicable()) {
  10452. var charts = this.getLayoutComponents();
  10453. if(charts && charts.length > 0) {
  10454. //chart is displayed.
  10455. for (var i = 0; i < charts.length; ++i) {
  10456. if (charts[i].nodeName === "IMG" || charts[0].getAttribute("flashChart") !== null) {
  10457. this.m_oChart = charts[i];
  10458. break;
  10459. }
  10460. }
  10461. if (this.m_oChart && this.isNewSizeDifferent()) {
  10462. if (charts[0].getAttribute("flashChart") !== null) {
  10463. this.m_bRunReport = false;
  10464. this.resizeFlashChart();
  10465. } else {
  10466. this.m_bRunReport = true;
  10467. this.resizeChart();
  10468. }
  10469. }
  10470. }
  10471. }
  10472. };
  10473. ResizeChartAction.prototype.isActionApplicable = function() {
  10474. var rapReportInfo = this.m_oCV.getRAPReportInfo();
  10475. if (rapReportInfo && rapReportInfo.isSingleContainer()) {
  10476. return true;
  10477. }
  10478. return false;
  10479. };
  10480. ResizeChartAction.prototype.resizeFlashChart = function() {
  10481. var size = this.getNewChartSize();
  10482. this.m_oChart.setAttribute("width", size.w + "px");
  10483. this.m_oChart.setAttribute("height", size.h + "px");
  10484. this.resizeChart(); //update report spec.
  10485. };
  10486. ResizeChartAction.prototype.resizeChart = function()
  10487. {
  10488. ResizeChartAction.superclass.execute.call(this);
  10489. };
  10490. ResizeChartAction.prototype.addActionContextAdditionalParms = function() {
  10491. var returnValue = "";
  10492. var size = this.getNewChartSize();
  10493. returnValue += "<height>" + size.h + "px</height>";
  10494. returnValue += "<width>" + size.w + "px</width>";
  10495. return returnValue;
  10496. };
  10497. ResizeChartAction.prototype.isNewSizeDifferent = function() {
  10498. var bFlashChart = (this.m_oChart.getAttribute("flashChart") !== null);
  10499. var chartWidth = bFlashChart ? this.m_oChart.getAttribute("width") : this.m_oChart.style.width;
  10500. var chartHeight = bFlashChart ? this.m_oChart.getAttribute("height") : this.m_oChart.style.height;
  10501. if (!chartWidth || chartWidth == "") {
  10502. chartWidth = this.m_oChart.width;
  10503. chartHeight = this.m_oChart.height;
  10504. }
  10505. return parseInt(chartWidth, 10) != this.m_width || parseInt(chartHeight, 10) != this.m_height;
  10506. };
  10507. ResizeChartAction.prototype.getNewChartSize = function () {
  10508. var myChart = this.m_oChart
  10509. var marginLeft = 0;
  10510. var marginRight = 0;
  10511. var marginTop = 0;
  10512. var marginBottom = 0;
  10513. var borderLeft = 0;
  10514. var borderRight = 0;
  10515. var borderTop = 0;
  10516. var borderBottom = 0;
  10517. var paddingLeft = 0;
  10518. var paddingRight = 0;
  10519. var paddingTop = 0;
  10520. var paddingBottom = 0;
  10521. require(["dojo/dom-style"], function (domStyle) {
  10522. marginLeft = domStyle.get(myChart, "marginLeft");
  10523. marginRight = domStyle.get(myChart, "marginRight");
  10524. marginTop = domStyle.get(myChart, "marginTop");
  10525. marginBottom = domStyle.get(myChart, "marginBottom");
  10526. borderLeft = domStyle.get(myChart, "borderLeftWidth");
  10527. borderRight = domStyle.get(myChart, "borderRightWidth");
  10528. borderTop = domStyle.get(myChart, "borderTopWidth");
  10529. borderBottom = domStyle.get(myChart, "borderBottomWidth");
  10530. paddingLeft = domStyle.get(myChart, "paddingLeft");
  10531. paddingRight = domStyle.get(myChart, "paddingRight");
  10532. paddingTop = domStyle.get(myChart, "paddingTop");
  10533. paddingBottom = domStyle.get(myChart, "paddingBottom");
  10534. });
  10535. this.m_width -= borderLeft + borderRight + marginLeft + marginRight + paddingLeft + paddingRight;
  10536. this.m_height -= borderTop + borderBottom + marginTop + marginBottom + paddingTop + paddingBottom;
  10537. if (this.m_keepRatio) {
  10538. var ratio = parseInt(this.m_oChart.style.width, 10)/parseInt(this.m_oChart.style.height, 10);
  10539. var newWidth = ratio * this.m_height;
  10540. if (newWidth > this.m_width) {
  10541. this.m_height = this.m_width / ratio;
  10542. }
  10543. var newHeight = this.m_width /ratio;
  10544. if (newHeight > this.m_height) {
  10545. this.m_width = this.m_height * ratio;
  10546. }
  10547. }
  10548. return {w:this.m_width, h:this.m_height};
  10549. };
  10550. /*
  10551. *+------------------------------------------------------------------------+
  10552. *| Licensed Materials - Property of IBM
  10553. *| IBM Cognos Products: Viewer
  10554. *| (C) Copyright IBM Corp. 2001, 2011
  10555. *|
  10556. *| US Government Users Restricted Rights - Use, duplication or
  10557. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10558. *|
  10559. *+------------------------------------------------------------------------+
  10560. */
  10561. function RetryRequestAction()
  10562. {
  10563. this.m_lastActionParams = null;
  10564. }
  10565. RetryRequestAction.prototype = new CognosViewerAction();
  10566. RetryRequestAction.prototype.setRequestParms = function(parms)
  10567. {
  10568. this.m_lastActionParams = parms;
  10569. };
  10570. RetryRequestAction.prototype.execute = function()
  10571. {
  10572. if (this.m_lastActionParams) {
  10573. var request = new ViewerDispatcherEntry(this.m_oCV);
  10574. var formFieldNames = this.m_lastActionParams.keys();
  10575. for (var index = 0; index < formFieldNames.length; index++) {
  10576. request.addFormField(formFieldNames[index], this.m_lastActionParams.get(formFieldNames[index]));
  10577. }
  10578. request.addFormField("cv.responseFormat", "data");
  10579. request.addFormField("widget.reloadToolbar", "true");
  10580. request.addNonEmptyStringFormField("limitedInteractiveMode", this.m_oCV.envParams["limitedInteractiveMode"]);
  10581. this.m_oCV.dispatchRequest(request);
  10582. this.m_oCV.getViewerWidget().setOriginalFormFields(null);
  10583. }
  10584. };
  10585. /*
  10586. *+------------------------------------------------------------------------+
  10587. *| Licensed Materials - Property of IBM
  10588. *| IBM Cognos Products: Viewer
  10589. *| (C) Copyright IBM Corp. 2001, 2012
  10590. *|
  10591. *| US Government Users Restricted Rights - Use, duplication or
  10592. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10593. *|
  10594. *+------------------------------------------------------------------------+
  10595. */
  10596. /**
  10597. * This is the base class for generating request to re-run the report.
  10598. * Classes derived from this will add to it their specific options.
  10599. */
  10600. function RunReportAction()
  10601. {
  10602. this.m_reuseQuery = false;
  10603. this.m_promptValues = null;
  10604. this.m_sendParameterValues = false;
  10605. this.m_clearCascadeParamsList = null;
  10606. }
  10607. RunReportAction.prototype = new CognosViewerAction();
  10608. RunReportAction.prototype.setRequestParams = function( params ) {
  10609. if( !params ){ return; }
  10610. this.m_promptValues = params.promptValues;
  10611. this.m_clearCascadeParamsList = params.clearCascadeParamsList;
  10612. };
  10613. RunReportAction.prototype.setSendParameterValues = function(sendParameterValues) {
  10614. this.m_sendParameterValues = sendParameterValues;
  10615. };
  10616. RunReportAction.prototype.reuseQuery =function() { return this.m_reuseQuery; };
  10617. RunReportAction.prototype.setReuseQuery = function( value ) { this.m_reuseQuery = value; };
  10618. RunReportAction.prototype.getPromptOption = function() { return "false";};
  10619. RunReportAction.prototype.canBeQueued = function() { return false; };
  10620. RunReportAction.prototype.getAction = function( limitedInteractiveMode ) {
  10621. return limitedInteractiveMode ? 'run' : 'runSpecification';
  10622. }
  10623. /**
  10624. * Overrides base method in CognosViewerAction
  10625. */
  10626. RunReportAction.prototype.addAdditionalOptions = function(cognosViewerRequest)
  10627. {
  10628. this._addCommonOptions(cognosViewerRequest);
  10629. this._addRunOptionsFromProperties(cognosViewerRequest);
  10630. this._addClearCascadeParams( cognosViewerRequest );
  10631. this._addPromptValuesToRequest( cognosViewerRequest );
  10632. };
  10633. RunReportAction.prototype._addClearCascadeParams = function( oReq )
  10634. {
  10635. if( !this.m_clearCascadeParamsList || this.m_clearCascadeParamsList.length == 0){
  10636. return;
  10637. }
  10638. var iCount = this.m_clearCascadeParamsList.length;
  10639. for( var i=0; i <iCount; i++){
  10640. oReq.addFormField('c' + this.m_clearCascadeParamsList[i], '1');//adding bogus value so viewer won't reject the parameter.
  10641. }
  10642. };
  10643. RunReportAction.prototype._addPromptValuesToRequest = function( cognosViewerRequest )
  10644. {
  10645. if ( !this.m_promptValues ){ return; }
  10646. cognosViewerRequest.addFormField("sharedPromptRequest", "true");
  10647. for (var promptValue in this.m_promptValues)
  10648. {
  10649. cognosViewerRequest.addFormField( promptValue, this.m_promptValues[promptValue] );
  10650. }
  10651. };
  10652. RunReportAction.prototype._addCommonOptions = function(oReq)
  10653. {
  10654. var limitedInteractiveMode = this.getCognosViewer().isLimitedInteractiveMode();
  10655. if( typeof this.m_action === "undefined" )
  10656. {
  10657. this.m_action = this.getAction( limitedInteractiveMode );
  10658. }
  10659. oReq.addFormField("run.prompt", this.getPromptOption());
  10660. oReq.addFormField("ui.action", this.m_action);
  10661. if( limitedInteractiveMode )
  10662. {
  10663. oReq.addFormField("run.xslURL", "bux.xsl");
  10664. }
  10665. oReq.addFormField("run.outputFormat", "HTML");
  10666. if( this.reuseQuery() === true )
  10667. {
  10668. oReq.addFormField("reuseResults", "true");
  10669. }
  10670. };
  10671. RunReportAction.prototype._addRunOptionsFromProperties = function(oReq)
  10672. {
  10673. var properties = this.getCognosViewer().getViewerWidget().getProperties();
  10674. if (properties.getRowsPerPage() != null)
  10675. {
  10676. oReq.addFormField("run.verticalElements", properties.getRowsPerPage());
  10677. }
  10678. };
  10679. /**
  10680. * Overrides base method in CognosViewerAction
  10681. */
  10682. RunReportAction.prototype.execute = function()
  10683. {
  10684. var oReq = this.createCognosViewerDispatcherEntry(this.m_action);
  10685. oReq.setCanBeQueued( this.canBeQueued() );
  10686. if( (this.m_action === "forward" || this.m_action === "back") && ( typeof this.m_bAbortAction === "undefined" || this.m_bAbortAction === true ) )
  10687. {
  10688. return false;
  10689. }
  10690. var oCV = this.getCognosViewer();
  10691. if (this.m_sendParameterValues && oCV.envParams["delayedLoadingExecutionParams"]) {
  10692. oReq.addFormField("delayedLoadingExecutionParams", oCV.envParams["delayedLoadingExecutionParams"]);
  10693. delete oCV.envParams["delayedLoadingExecutionParams"];
  10694. }
  10695. this.getCognosViewer().dispatchRequest(oReq);
  10696. return true;
  10697. };
  10698. RunReportAction.prototype.doAddActionContext = function()
  10699. {
  10700. return false;
  10701. };
  10702. RunReportAction.prototype.updateMenu = function(json)
  10703. {
  10704. json.visible = !this.isPromptWidget();
  10705. return json;
  10706. };
  10707. /*
  10708. *+------------------------------------------------------------------------+
  10709. *| Licensed Materials - Property of IBM
  10710. *| IBM Cognos Products: Viewer
  10711. *| (C) Copyright IBM Corp. 2001, 2012
  10712. *|
  10713. *| US Government Users Restricted Rights - Use, duplication or
  10714. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10715. *|
  10716. *+------------------------------------------------------------------------+
  10717. */
  10718. /**
  10719. * This class should only be used in the case where there is delayed loading
  10720. * of report.
  10721. */
  10722. function BuxRunReportAction()
  10723. {
  10724. BuxRunReportAction.baseConstructor.call();
  10725. }
  10726. BuxRunReportAction.prototype = new RunReportAction();
  10727. BuxRunReportAction.baseConstructor = RunReportAction;
  10728. BuxRunReportAction.prototype.canBeQueued = function() { return true; };
  10729. BuxRunReportAction.prototype.getAction = function( limitedInteractiveMode ) {
  10730. return limitedInteractiveMode ? 'runBux' : 'buxRunSpec';
  10731. };
  10732. /*
  10733. *+------------------------------------------------------------------------+
  10734. *| Licensed Materials - Property of IBM
  10735. *| IBM Cognos Products: Viewer
  10736. *| (C) Copyright IBM Corp. 2001, 2011
  10737. *|
  10738. *| US Government Users Restricted Rights - Use, duplication or
  10739. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10740. *|
  10741. *+------------------------------------------------------------------------+
  10742. */
  10743. function RefreshAction()
  10744. {
  10745. this.m_sAction = "Refresh";
  10746. }
  10747. RefreshAction.prototype = new RunReportAction();
  10748. RefreshAction.superclass = RunReportAction.prototype;
  10749. RefreshAction.prototype.execute = function()
  10750. {
  10751. RefreshAction.superclass.execute.call(this);
  10752. };/*
  10753. *+------------------------------------------------------------------------+
  10754. *| Licensed Materials - Property of IBM
  10755. *| IBM Cognos Products: Viewer
  10756. *| (C) Copyright IBM Corp. 2001, 2014
  10757. *|
  10758. *| US Government Users Restricted Rights - Use, duplication or
  10759. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10760. *|
  10761. *+------------------------------------------------------------------------+
  10762. */
  10763. function GetParametersAction()
  10764. {
  10765. this.m_payload = "";
  10766. this.isPrimaryPromptWidget = false;
  10767. this.m_requestParamsCopy = null;
  10768. }
  10769. GetParametersAction.prototype = new RunReportAction();
  10770. GetParametersAction.prototype.setRequestParms = function(payload)
  10771. {
  10772. this.m_payload = payload;
  10773. };
  10774. /*
  10775. * Adds the options to the request that is sent to the server
  10776. */
  10777. GetParametersAction.prototype.addRequestOptions = function(asynchRequest)
  10778. {
  10779. asynchRequest.addFormField("asynch.alwaysIncludePrimaryRequest", "false" );
  10780. asynchRequest.addFormField("ui.action", "getParameters" );
  10781. asynchRequest.addFormField("ui.spec", this.m_oCV.envParams["ui.spec"] );
  10782. asynchRequest.addFormField("ui.object", this.m_oCV.envParams["ui.object"] );
  10783. asynchRequest.addFormField("isPrimaryPromptWidget", this.isPrimaryPromptWidget? "true" : "false" );
  10784. asynchRequest.addFormField("parameterValues", this.m_oCV.getExecutionParameters());
  10785. if (this.m_oCV.envParams["bux"] == "true") {
  10786. asynchRequest.addFormField("bux", "true");
  10787. }
  10788. };
  10789. GetParametersAction.prototype.execute = function()
  10790. {
  10791. var oCV = this.getCognosViewer();
  10792. var asynchRequest = new AsynchJSONDispatcherEntry(oCV);
  10793. asynchRequest.setCallbacks({
  10794. "complete": {"object": this, "method": this.handleGetParametersResponse}
  10795. });
  10796. this.addRequestOptions( asynchRequest );
  10797. // save prompt params
  10798. if (oCV.getActiveRequest()) {
  10799. this.m_requestFormFieldsCopy = oCV.getActiveRequest().getFormFields();
  10800. }
  10801. // special case where we don't want to go through the ViewerDispatcher
  10802. // since we don't want this request to get queue. We need to get the parameter information
  10803. // asap so the other reports on the canvas can start executing with the new prompt information
  10804. asynchRequest.sendRequest();
  10805. };
  10806. GetParametersAction.prototype.handleGetParametersResponse = function (asynchResponse)
  10807. {
  10808. try
  10809. {
  10810. var jsonResponse = asynchResponse.getResult();
  10811. var response = jsonResponse.xml;
  10812. var cognosViewer = this.getCognosViewer();
  10813. var viewerWidget = cognosViewer.getViewerWidget();
  10814. if (typeof response != "undefined" && response != null) {
  10815. var sReportPrompts = xml_decode(response);
  10816. this.m_oCV.envParams["reportPrompts"] = sReportPrompts;
  10817. if (this.isPrimaryPromptWidget) {
  10818. this.m_oCV.raisePromptEvent(sReportPrompts, this.m_requestFormFieldsCopy);
  10819. }
  10820. else {
  10821. viewerWidget.sharePrompts(this.m_payload);
  10822. }
  10823. }
  10824. if (typeof viewerWidget != "undefined") {
  10825. viewerWidget.promptParametersRetrieved = true;
  10826. // do we need to re-add the Reprompt button to the toolbar ?
  10827. var savedRepromptButton = viewerWidget.getButtonFromSavedToolbarButtons("Reprompt");
  10828. if (typeof savedRepromptButton != "undefined" && savedRepromptButton != null) {
  10829. var blueDotMenu = cognosViewer.findBlueDotMenu();
  10830. if (cognosViewer.addedButtonToToolbar(blueDotMenu, savedRepromptButton.button, "Refresh", savedRepromptButton.position)) {
  10831. cognosViewer.resetbHasPromptFlag();
  10832. viewerWidget.updateToolbar();
  10833. }
  10834. viewerWidget.removeFromSavedToolbarButtons("Reprompt");
  10835. }
  10836. }
  10837. }
  10838. catch(e) { }
  10839. };
  10840. /*
  10841. *+------------------------------------------------------------------------+
  10842. *| Licensed Materials - Property of IBM
  10843. *| IBM Cognos Products: Viewer
  10844. *| (C) Copyright IBM Corp. 2001, 2014
  10845. *|
  10846. *| US Government Users Restricted Rights - Use, duplication or
  10847. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10848. *|
  10849. *+------------------------------------------------------------------------+
  10850. */
  10851. function RepromptAction()
  10852. {
  10853. this.m_repromptAction = null;
  10854. }
  10855. RepromptAction.prototype = new CognosViewerAction();
  10856. RepromptAction.superclass = CognosViewerAction.prototype;
  10857. RepromptAction.prototype.updateMenu = function( jsonSpec )
  10858. {
  10859. var oCV = this.getCognosViewer();
  10860. jsonSpec.visible = (!this.isPromptWidget() && oCV.hasPrompt() );
  10861. if (!jsonSpec.visible) {
  10862. jsonSpec.save = true;
  10863. } else {
  10864. delete jsonSpec.save;
  10865. }
  10866. return jsonSpec;
  10867. };
  10868. RepromptAction.prototype.setRequestParms = function(params) {
  10869. RepromptAction.superclass.setRequestParms(params);
  10870. if (params && params["preferencesChanged"]) {
  10871. this["preferencesChanged"] = params["preferencesChanged"];
  10872. }
  10873. };
  10874. RepromptAction.prototype.execute = function()
  10875. {
  10876. var oCV = this.getCognosViewer();
  10877. if( oCV.isLimitedInteractiveMode())
  10878. {
  10879. this.m_repromptAction = new RepromptRunAction();
  10880. }
  10881. else
  10882. {
  10883. this.m_repromptAction = new RepromptRAPAction();
  10884. }
  10885. this.m_repromptAction.setCognosViewer( oCV );
  10886. if (this["preferencesChanged"]) {
  10887. this.m_repromptAction.reuseConversation(false);
  10888. }
  10889. this.m_repromptAction.execute();
  10890. };
  10891. /*
  10892. *+------------------------------------------------------------------------+
  10893. *| Licensed Materials - Property of IBM
  10894. *| IBM Cognos Products: Viewer
  10895. *| (C) Copyright IBM Corp. 2001, 2011
  10896. *|
  10897. *| US Government Users Restricted Rights - Use, duplication or
  10898. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10899. *|
  10900. *+------------------------------------------------------------------------+
  10901. */
  10902. function RepromptRAPAction()
  10903. {
  10904. this.m_sAction = "Reprompt";
  10905. }
  10906. RepromptRAPAction.prototype = new ModifyReportAction();
  10907. RepromptRAPAction.prototype.getPromptOption = function() { return "true"; };
  10908. RepromptRAPAction.prototype.isUndoable = function() { return false; };
  10909. RepromptRAPAction.prototype.reuseQuery =function() { return false; };
  10910. RepromptRAPAction.prototype.reuseGetParameter =function() { return false; };
  10911. RepromptRAPAction.prototype.keepFocusOnWidget = function() { return false; };
  10912. RepromptRAPAction.prototype.preProcess =function()
  10913. {
  10914. var cv = this.getCognosViewer();
  10915. cv.m_raiseSharePromptEvent = true;
  10916. };
  10917. RepromptRAPAction.prototype.addAdditionalOptions = function(cognosViewerRequest)
  10918. {
  10919. cognosViewerRequest.addFormField("run.outputFormat", "HTML");
  10920. cognosViewerRequest.addFormField("bux", "true");
  10921. };
  10922. /*
  10923. *+------------------------------------------------------------------------+
  10924. *| Licensed Materials - Property of IBM
  10925. *| IBM Cognos Products: Viewer
  10926. *| (C) Copyright IBM Corp. 2001, 2011
  10927. *|
  10928. *| US Government Users Restricted Rights - Use, duplication or
  10929. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10930. *|
  10931. *+------------------------------------------------------------------------+
  10932. */
  10933. function RepromptRunAction(){}
  10934. RepromptRunAction.prototype = new RunReportAction();
  10935. RepromptRunAction.prototype.reuseQuery =function() { return false; };
  10936. RepromptRunAction.prototype.reuseGetParameter =function() { return false; };
  10937. RepromptRunAction.prototype.preProcess =function()
  10938. {
  10939. var cv = this.getCognosViewer();
  10940. cv.m_raiseSharePromptEvent = true;
  10941. };
  10942. RepromptRunAction.prototype.getPromptOption = function() { return "true"; };
  10943. /*
  10944. *+------------------------------------------------------------------------+
  10945. *| Licensed Materials - Property of IBM
  10946. *| IBM Cognos Products: Viewer
  10947. *| (C) Copyright IBM Corp. 2001, 2013
  10948. *|
  10949. *| US Government Users Restricted Rights - Use, duplication or
  10950. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10951. *|
  10952. *+------------------------------------------------------------------------+
  10953. */
  10954. function SelectionAction() {}
  10955. SelectionAction.prototype = new CognosViewerAction();
  10956. SelectionAction.prototype.onMouseOver = function(evt)
  10957. {
  10958. if(DragDropAction_isDragging(evt) == false)
  10959. {
  10960. var selectionController = this.getCognosViewer().getSelectionController();
  10961. selectionController.pageHover(evt);
  10962. }
  10963. };
  10964. SelectionAction.prototype.onMouseOut = function(evt)
  10965. {
  10966. if(DragDropAction_isDragging(evt) == false)
  10967. {
  10968. var selectionController = this.getCognosViewer().getSelectionController();
  10969. selectionController.pageHover(evt);
  10970. }
  10971. };
  10972. SelectionAction.prototype.hasPermission = function()
  10973. {
  10974. var oCV = this.getCognosViewer();
  10975. return !( oCV.isLimitedInteractiveMode() || oCV.envParams['cv.objectPermissions'].indexOf( 'read' ) === -1 );
  10976. };
  10977. SelectionAction.prototype.executeDrillUpDown = function(evt)
  10978. {
  10979. var oCV = this.getCognosViewer();
  10980. var oWidget = oCV.getViewerWidget();
  10981. if (oCV.isDrillBlackListed() || (oWidget && oWidget.isSelectionFilterEnabled())) {
  10982. return false;
  10983. }
  10984. if(evt.button == 0 || evt.button == 1 || evt.keyCode == "13")
  10985. {
  10986. // check to see if we're hovering over a drillable item and the cell is selected. If so, invoke the drill action
  10987. var ctxNode = getCtxNodeFromEvent(evt);
  10988. if(ctxNode != null)
  10989. {
  10990. var selectionController = this.m_oCV.getSelectionController();
  10991. var descriptionNode = ctxNode.getAttribute("type") != null ? ctxNode : ctxNode.parentNode;
  10992. var type = descriptionNode.getAttribute("type");
  10993. var ctxValue = ctxNode.getAttribute("ctx");
  10994. ctxValue = ctxValue.split("::")[0].split(":")[0];
  10995. if((descriptionNode.getAttribute("CTNM") != null || type == "datavalue") && selectionController.getMun(ctxValue) != "")
  10996. {
  10997. var selectedObjects = selectionController.getAllSelectedObjects();
  10998. for(var index = 0; index < selectedObjects.length; ++index)
  10999. {
  11000. var selectedObject = selectedObjects[index];
  11001. if(selectedObject.getCellRef() == ctxNode.parentNode)
  11002. {
  11003. if (selectedObjects.length>1) {
  11004. selectionController.clearSelectedObjects();
  11005. selectionController.addSelectionObject(selectedObject);
  11006. }
  11007. var factory = this.m_oCV.getActionFactory();
  11008. var drillAction = factory.load("DrillUpDown");
  11009. drillAction.updateDrillability(this.m_oCV, ctxNode);
  11010. if (drillAction.drillability > 0 && this.hasPermission()) {
  11011. drillAction.execute();
  11012. return true;
  11013. }
  11014. }
  11015. }
  11016. }
  11017. }
  11018. }
  11019. return false;
  11020. };
  11021. SelectionAction.prototype.executeDrillThrough = function(evt)
  11022. {
  11023. var oWidget = this.getCognosViewer().getViewerWidget();
  11024. if (oWidget && oWidget.isSelectionFilterEnabled()) {
  11025. return;
  11026. }
  11027. // try and see if there's a drill through
  11028. var oDrillMgr = this.getCognosViewer().getDrillMgr();
  11029. return oDrillMgr.getDrillThroughParameters('execute', evt);
  11030. };
  11031. SelectionAction.prototype.pageClicked = function(evt) {
  11032. var bDrillThroughExecuted = false;
  11033. var leftMouseButton = evt.which ? evt.which == 1 : evt.button == 1;
  11034. var cvSort = new CognosViewerSort(evt, this.m_oCV);
  11035. var sClass, crossBrowserNode = getCrossBrowserNode(evt);
  11036. try {
  11037. sClass = (crossBrowserNode && crossBrowserNode.className) || "";
  11038. }
  11039. catch (ex) {
  11040. sClass = "";
  11041. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  11042. }
  11043. var oCV = this.getCognosViewer();
  11044. var selectionController = null;
  11045. if(leftMouseButton && cvSort.isSort(evt) && !oCV.isLimitedInteractiveMode() && !oCV.isBlacklisted("Sort") )
  11046. {
  11047. cvSort.execute();
  11048. }
  11049. else if(leftMouseButton && sClass.indexOf("expandButton") > -1 ) {
  11050. var nNode = crossBrowserNode;
  11051. if(sClass.indexOf("expandButtonCaption") > -1) {
  11052. nNode = nNode.parentNode;
  11053. sClass = nNode.className;
  11054. }
  11055. selectionController = getCognosViewerSCObjectRef(this.m_oCV.getId());
  11056. selectionController.selectSingleDomNode(nNode.parentNode);
  11057. var oAction;
  11058. if(sClass.indexOf("collapse") === -1 ) {
  11059. oAction = new ExpandMemberAction();
  11060. } else {
  11061. oAction = new CollapseMemberAction();
  11062. }
  11063. oAction.setCognosViewer(oCV);
  11064. oAction.execute();
  11065. }
  11066. else
  11067. {
  11068. selectionController = this.m_oCV.getSelectionController();
  11069. if(this.executeDrillUpDown(evt) === false)
  11070. {
  11071. var oCVWidget = this.m_oCV.getViewerWidget();
  11072. if( oCVWidget.isSelectionFilterEnabled() ){
  11073. if( leftMouseButton || evt.keyCode === 13 ){
  11074. oCVWidget.preprocessPageClicked( false /*invokingContextMenu*/, evt);
  11075. } else {
  11076. //if we get here, it means that context menu is invoked and previous selections should be saved if it hasn't been yet.
  11077. oCVWidget.preprocessPageClicked( true /*invokingContextMenu*/);
  11078. }
  11079. }
  11080. if (selectionController.pageClicked(evt) != false) {
  11081. this.m_oCV.getViewerWidget().updateToolbar();
  11082. selectionController.resetAllowHorizontalDataValueSelection();
  11083. }
  11084. setNodeFocus(evt);
  11085. }
  11086. if (leftMouseButton || evt.keyCode === 13)
  11087. {
  11088. bDrillThroughExecuted = this.executeDrillThrough(evt);
  11089. }
  11090. if(leftMouseButton && this.m_oCV.getViewerWidget() && this.m_oCV.getViewerWidget().onSelectionChange) {
  11091. this.m_oCV.getViewerWidget().onSelectionChange();
  11092. }
  11093. }
  11094. return bDrillThroughExecuted;
  11095. };
  11096. SelectionAction.prototype.mouseActionInvolvesSelection = function(evt) {
  11097. var leftMouseButton = evt.which ? evt.which == 1 : evt.button == 1;
  11098. var cvSort = new CognosViewerSort(evt, this.m_oCV);
  11099. if (leftMouseButton && cvSort.isSort(evt)) {
  11100. return false;
  11101. }
  11102. if (this.executeDrillUpDown(evt) !== false) {
  11103. return false;
  11104. }
  11105. return true;
  11106. };
  11107. SelectionAction.prototype.onMouseDown = function(evt)
  11108. {
  11109. this.delegateClickToMouseUp = false;
  11110. if (this.mouseActionInvolvesSelection(evt) && !this.m_oCV.getSelectionController().shouldExecutePageClickedOnMouseDown(evt)) {
  11111. this.delegateClickToMouseUp = true;
  11112. return false;
  11113. }
  11114. return this.pageClicked(evt);
  11115. };
  11116. SelectionAction.prototype.onMouseUp = function(evt, consumed)
  11117. {
  11118. var ret = false;
  11119. if(!consumed && this.mouseActionInvolvesSelection(evt) && this.delegateClickToMouseUp) {
  11120. ret = this.pageClicked(evt);
  11121. }
  11122. this.delegateClickToMouseUp = false;
  11123. return ret;
  11124. };
  11125. SelectionAction.prototype.onKeyDown = function(evt)
  11126. {
  11127. this.pageClicked(evt);
  11128. };
  11129. SelectionAction.prototype.onDoubleClick = function(evt)
  11130. {
  11131. // This is called by onDoubleClick from ViewerIWidget.js,
  11132. // because the action we get from ActionFactory_loadActionHandler will be the SelectionAction.
  11133. // Try to determine the drillability and run the drill action if available.
  11134. // This is mostly the case for a chart type.
  11135. // This approach is consistent with what happens when we use the context menu for drill up and down.
  11136. var viewerObject = this.m_oCV;
  11137. var oWidget = viewerObject.getViewerWidget();
  11138. if (viewerObject.isDrillBlackListed() || (oWidget && oWidget.isSelectionFilterEnabled())) {
  11139. return;
  11140. }
  11141. if(viewerObject.getStatus() == "complete")
  11142. {
  11143. var drillManager = viewerObject.getDrillMgr();
  11144. var sDrillAction = "DrillDown";
  11145. var sPayload = "DrillDown";
  11146. var canDrillDown = false;
  11147. var canDrillUp = false;
  11148. if(drillManager != null)
  11149. {
  11150. if( !this.hasPermission() )
  11151. {
  11152. return true;
  11153. }
  11154. var selObj = drillManager.getSelectedObject();
  11155. if (selObj == null ||
  11156. (selObj.m_dataContainerType=="list" && selObj.m_sLayoutType=="columnTitle"))
  11157. {
  11158. //Can't drill up or down with no selections OR on a list column title.
  11159. return true;
  11160. }
  11161. var drillOptions = selObj.getDrillOptions();
  11162. if (typeof drillOptions == "undefined" || drillOptions == null || !drillOptions.length)
  11163. {
  11164. return true;
  11165. }
  11166. canDrillDown = drillManager.canDrillDown();
  11167. if (!canDrillDown)
  11168. {
  11169. // We might be at the leaf level.
  11170. // See if we can drill up and execute the action if this is the case.
  11171. canDrillUp = drillManager.canDrillUp();
  11172. if (canDrillUp)
  11173. {
  11174. sDrillAction = "DrillUp";
  11175. sPayload = "DrillUp";
  11176. }
  11177. }
  11178. // If we can drill down or up execute the action, otherwise do nothing (do not reload).
  11179. if (canDrillDown || canDrillUp)
  11180. {
  11181. viewerObject.executeAction(sDrillAction, sPayload);
  11182. }
  11183. }
  11184. else
  11185. {
  11186. return true;
  11187. }
  11188. }
  11189. };/*
  11190. *+------------------------------------------------------------------------+
  11191. *| Licensed Materials - Property of IBM
  11192. *| IBM Cognos Products: Viewer
  11193. *| (C) Copyright IBM Corp. 2014
  11194. *|
  11195. *| US Government Users Restricted Rights - Use, duplication or
  11196. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11197. *|
  11198. *+------------------------------------------------------------------------+
  11199. */
  11200. function SelectionFilterSwitchAction()
  11201. {
  11202. this.m_sAction = "SelectionFilterSwitch";
  11203. }
  11204. SelectionFilterSwitchAction.prototype = new CognosViewerAction();
  11205. SelectionFilterSwitchAction.prototype.updateMenu = function(jsonSpec)
  11206. {
  11207. //jsonSpec.visible = true;
  11208. if (this.getCognosViewer().getViewerWidget().isSelectionFilterEnabled())
  11209. {
  11210. jsonSpec.disabled = false;
  11211. jsonSpec.checked = true;
  11212. jsonSpec.iconClass = 'selectionFilterEnabled';
  11213. jsonSpec.label = RV_RES.IDS_JS_SELECTION_FILTER_SWITCH_DISABLE;
  11214. }
  11215. else
  11216. {
  11217. jsonSpec.disabled = false;
  11218. jsonSpec.checked = false;
  11219. jsonSpec.iconClass = 'selectionFilter';
  11220. jsonSpec.label = RV_RES.IDS_JS_SELECTION_FILTER_SWITCH;
  11221. }
  11222. return jsonSpec;
  11223. };
  11224. SelectionFilterSwitchAction.prototype.execute = function()
  11225. {
  11226. var oCV = this.getCognosViewer();
  11227. var oVWidget = oCV.getViewerWidget();
  11228. var oldSwitch = oVWidget.isSelectionFilterEnabled();
  11229. // Turning off, so we need to clear the filters before we actually flip the switch in our code
  11230. // since our code checks the boolean before sending the event
  11231. if (oldSwitch) {
  11232. if (oVWidget.selectionFilterSent()) {
  11233. oVWidget.clearSelectionFilter();
  11234. }
  11235. }
  11236. oVWidget.toggleSelectionFilterSwitch();
  11237. oVWidget.updateToolbar();
  11238. oVWidget.onContextMenu({}); //Populates context menu payload with correct state.
  11239. // Turning on
  11240. if (!oldSwitch) {
  11241. if (oVWidget.somethingSelected()) {
  11242. oVWidget.broadcastSelectionFilter();
  11243. }
  11244. }
  11245. oVWidget.updateDrillThroughLinks();
  11246. oVWidget.fireEvent("com.ibm.bux.widget.modified", null, {'modified':true});
  11247. };/*
  11248. *+------------------------------------------------------------------------+
  11249. *| Licensed Materials - Property of IBM
  11250. *| IBM Cognos Products: Viewer
  11251. *| (C) Copyright IBM Corp. 2001, 2013
  11252. *|
  11253. *| US Government Users Restricted Rights - Use, duplication or
  11254. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11255. *|
  11256. *+------------------------------------------------------------------------+
  11257. */
  11258. function SharePromptAction()
  11259. {
  11260. this.m_bAbortAction = true;
  11261. }
  11262. SharePromptAction.prototype = new RunReportAction();
  11263. SharePromptAction.prototype.preProcess = function()
  11264. {
  11265. var cv = this.getCognosViewer();
  11266. cv.disableRaiseSharePromptEvent();
  11267. };
  11268. SharePromptAction.prototype.setRequestParms = function(payload)
  11269. {
  11270. this.m_sharePromptParameters = payload.parameters;
  11271. this.m_action = "forward";
  11272. };
  11273. /**
  11274. * Parse the prompt parameters, and try to match them by parameter name first then model item,
  11275. * if a potential match is found save in an instance member to add later to the request.
  11276. *
  11277. * @param {Object} promptParameters
  11278. * @return (Boolean) True if a potential match is found
  11279. * @author Osmani Gomez
  11280. */
  11281. SharePromptAction.prototype.parsePromptParameters = function()
  11282. {
  11283. var result = false;
  11284. var reportParameterNodes = this.getReportParameterNodes();
  11285. if (reportParameterNodes) {
  11286. var promptParameters = this.m_sharePromptParameters;
  11287. var requestParams = {};
  11288. var usedModelItems = [];
  11289. for (var i in promptParameters) {
  11290. var promptParameterName = promptParameters[i].parmName;
  11291. var promptModelItem = promptParameters[i].modelItem;
  11292. var sName = null;
  11293. var sValue = null;
  11294. var matchedByModelItem = false;
  11295. var modelItemMatchedParams = {};
  11296. for (var j in reportParameterNodes) {
  11297. var targetParameterName = reportParameterNodes[j].getAttribute("parameterName");
  11298. var targetModelItem = reportParameterNodes[j].getAttribute("modelItem");
  11299. if ((typeof targetParameterName !== "undefined" && targetParameterName === promptParameterName) ||
  11300. (typeof targetModelItem !== "undefined" && promptModelItem !== "undefined" && promptModelItem !== "" &&
  11301. targetModelItem === promptModelItem && !this.arrayContains(usedModelItems, targetModelItem)))
  11302. {
  11303. result = true;
  11304. sName = 'p_' + targetParameterName;
  11305. sValue = this.getSharedPromptValue(promptParameters[i], reportParameterNodes[j]);
  11306. if (targetParameterName === promptParameterName) {
  11307. requestParams[sName] = sValue;
  11308. usedModelItems.push(targetModelItem);
  11309. matchedByModelItem = false;
  11310. break;
  11311. } else {
  11312. modelItemMatchedParams[sName] = sValue;
  11313. matchedByModelItem = true;
  11314. }
  11315. }
  11316. }
  11317. if (matchedByModelItem) {
  11318. for (var x in modelItemMatchedParams) {
  11319. requestParams[x] = modelItemMatchedParams[x];
  11320. }
  11321. }
  11322. }
  11323. if (result) {
  11324. this.m_bAbortAction = false;
  11325. this.m_promptValues = requestParams;
  11326. }
  11327. }
  11328. return result;
  11329. };
  11330. SharePromptAction.prototype.getSharedPromptValue = function(promptParameter, reportParameterNode)
  11331. {
  11332. var sValue = null;
  11333. var promptValue = promptParameter.parmValue;
  11334. var multivaluedPrompt = this._isPromptParamMultiValued(promptParameter.multivalued, promptValue);
  11335. var hasSelectOption = new RegExp(/^<selectChoices><selectOption/);
  11336. // if shared prompt param -> many, report param -> one, only one option can be used
  11337. if ( multivaluedPrompt && reportParameterNode.getAttribute( "multivalued" ) == null && promptValue.match(hasSelectOption)) {
  11338. // make sure only one option is used, extract the the first one
  11339. var reOneOption = new RegExp(/^(<selectChoices><selectOption.*?><)/);
  11340. var extractedMatch = reOneOption.exec(promptValue);
  11341. sValue = extractedMatch[1] + '/selectChoices>';
  11342. } else {
  11343. sValue = promptValue;
  11344. }
  11345. return sValue;
  11346. };
  11347. SharePromptAction.prototype.arrayContains = function(array, value)
  11348. {
  11349. var found = false;
  11350. for (var i = 0; i < array.length; i++) {
  11351. if (array[i] === value) {
  11352. found = true;
  11353. break;
  11354. }
  11355. }
  11356. return found;
  11357. };
  11358. SharePromptAction.prototype.getPromptValues = function()
  11359. {
  11360. if( !this.m_promptValues )
  11361. {
  11362. this.parsePromptParameters();
  11363. }
  11364. return this.m_promptValues;
  11365. };
  11366. /*
  11367. * Safer check for multivalue, in certain cases GetParameters won't return multivalued when it should,
  11368. *
  11369. */
  11370. SharePromptAction.prototype._isPromptParamMultiValued = function(multiValuedParamInfo, promptValue)
  11371. {
  11372. var result = false;
  11373. if ( multiValuedParamInfo != "undefined" && multiValuedParamInfo) {
  11374. result = true;
  11375. } else {
  11376. var reIsMulti = new RegExp(/^<selectChoices><selectOption.*?>\s*<selectOption/);
  11377. if (promptValue.match(reIsMulti)) {
  11378. result = true;
  11379. }
  11380. }
  11381. return result;
  11382. };
  11383. SharePromptAction.prototype.getReportParameterNodes = function()
  11384. {
  11385. var cv = this.getCognosViewer();
  11386. var reportParameterNodes = null;
  11387. try {
  11388. if (cv.envParams && cv.envParams.reportPrompts) {
  11389. var reportParameters = cv.envParams.reportPrompts;
  11390. var xmlDom = XMLBuilderLoadXMLFromString(reportParameters);
  11391. if (!(xmlDom && xmlDom.childNodes && xmlDom.childNodes.length > 0 && xmlDom.childNodes[0].nodeName === "parsererror")) {
  11392. var cvTransientSpec = xmlDom.firstChild;
  11393. var reportParametersNode = XMLHelper_FindChildByTagName(cvTransientSpec, "reportParameters", true);
  11394. reportParameterNodes = XMLHelper_FindChildrenByTagName(reportParametersNode, "reportParameter", false);
  11395. }
  11396. }
  11397. }
  11398. catch ( e ) {}
  11399. return reportParameterNodes;
  11400. };
  11401. SharePromptAction.prototype.executePrompt = function ()
  11402. {
  11403. if (this.getPromptValues() !== null )
  11404. {
  11405. this.execute();
  11406. return true;
  11407. }
  11408. return false;
  11409. };
  11410. /*
  11411. *+------------------------------------------------------------------------+
  11412. *| Licensed Materials - Property of IBM
  11413. *| IBM Cognos Products: Viewer
  11414. *| (C) Copyright IBM Corp. 2001, 2011
  11415. *|
  11416. *| US Government Users Restricted Rights - Use, duplication or
  11417. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11418. *|
  11419. *+------------------------------------------------------------------------+
  11420. */
  11421. function SnapshotsAction() {}
  11422. SnapshotsAction.prototype = new CognosViewerAction();
  11423. SnapshotsAction.prototype.updateMenu = function(jsonSpec) {
  11424. var widget = this.m_oCV.getViewerWidget();
  11425. jsonSpec.disabled = (widget.getAttributeValue("reportCreatedInCW") == "true") || (widget.getAttributeValue("fromReportPart") == "true") || (this.m_oCV.envParams["reportpart_id"] && this.m_oCV.envParams["reportpart_id"].length) > 0 ? true : false;
  11426. jsonSpec.visible = !this.isPromptWidget();
  11427. return jsonSpec;
  11428. };
  11429. SnapshotsAction.prototype.execute = function()
  11430. {
  11431. var oCV = this.getCognosViewer();
  11432. var widget = oCV.getViewerWidget();
  11433. if (widget.getSavedOutputsCMResponse() == null) {
  11434. this.queryCMForSavedOutputs({"complete" : {"object" : this, "method" : this.handleQueryResponse}});
  11435. }
  11436. else if (typeof widget.savedOutputMenuUpdated != "undefined" && widget.savedOutputMenuUpdated == false) {
  11437. this.populateMenu(true);
  11438. widget.savedOutputMenuUpdated = true;
  11439. }
  11440. };
  11441. SnapshotsAction.prototype.queryCMForSavedOutputs = function(callback) {
  11442. var oCV = this.getCognosViewer();
  11443. var widget = oCV.getViewerWidget();
  11444. var searchPath = "";
  11445. var formWarpRequest = document.getElementById("formWarpRequest" + oCV.getId());
  11446. if (oCV.envParams["originalReport"])
  11447. {
  11448. searchPath = oCV.envParams["originalReport"];
  11449. }
  11450. else if (formWarpRequest && formWarpRequest["reRunObj"] != null && formWarpRequest["reRunObj"].value.length > 0)
  11451. {
  11452. searchPath = formWarpRequest["reRunObj"].value;
  11453. }
  11454. else
  11455. {
  11456. searchPath = oCV.envParams["ui.object"];
  11457. }
  11458. searchPath += "/reportVersion/*[@format='HTML' or @format='XHTML']/..";
  11459. var cmRequest =
  11460. "<CMRequest>" +
  11461. "<searchPath>" + xml_encode(searchPath) + "</searchPath>" +
  11462. "<properties>" +
  11463. "<property>searchPath</property>" +
  11464. "<property>creationTime</property>" +
  11465. "<property>storeID</property>" +
  11466. "</properties>" +
  11467. "<sortBy>" +
  11468. "<sortItem>" +
  11469. "<property>creationTime</property>" +
  11470. "<order>descending</order>" +
  11471. "</sortItem>" +
  11472. "</sortBy>" +
  11473. "</CMRequest>";
  11474. var request = new DataDispatcherEntry(oCV);
  11475. request.addFormField("ui.action", "CMRequest");
  11476. request.addFormField("cv.responseFormat", "CMRequest");
  11477. request.addFormField("ui.object", searchPath);
  11478. request.addFormField("CMRequest", cmRequest);
  11479. request.setCallbacks(callback);
  11480. oCV.dispatchRequest(request);
  11481. };
  11482. SnapshotsAction.prototype.setSavedOutputsCMResponse = function(response) {
  11483. var oCV = this.getCognosViewer();
  11484. var widget = oCV.getViewerWidget();
  11485. var xmlParsedCMresponse = XMLBuilderLoadXMLFromString(response.getResult());
  11486. widget.setSavedOutputsCMResponse(xmlParsedCMresponse);
  11487. };
  11488. SnapshotsAction.prototype.handleQueryResponse = function(response) {
  11489. this.setSavedOutputsCMResponse(response);
  11490. this.populateMenu(true);
  11491. };
  11492. SnapshotsAction.prototype.canShowLiveMenuItem = function() {
  11493. var oCV = this.getCognosViewer();
  11494. return ( oCV.envParams["cv.responseFormat"] !== "activeReport" && (oCV.isLimitedInteractiveMode() || (oCV.envParams["cv.objectPermissions"] && oCV.envParams["cv.objectPermissions"].indexOf("execute") != -1)) );
  11495. };
  11496. SnapshotsAction.prototype.getMenuItemActionClassHandler = function() {
  11497. var oCV = this.getCognosViewer();
  11498. return oCV.envParams["cv.responseFormat"] === "activeReport" ? "ViewActiveReport" : "ViewSavedOutput";
  11499. };
  11500. SnapshotsAction.prototype.populateMenu = function(bOpen) {
  11501. var oCV = this.getCognosViewer();
  11502. var widget = oCV.getViewerWidget();
  11503. var sAction = oCV.envParams["ui.action"];
  11504. var cmResponse = widget.savedOutputsCMResponse;
  11505. var root = oCV.findBlueDotMenu();
  11506. root.open = bOpen;
  11507. var buttonSpec = oCV.findToolbarItem("Snapshots", root);
  11508. var queryResult = XMLHelper_FindChildByTagName(cmResponse, "result", true);
  11509. var queryItems = XMLHelper_FindChildrenByTagName(queryResult, "item", false);
  11510. var menuItems = [];
  11511. var mostRecentCreationTime = null;
  11512. var mostRecentStoreID = null;
  11513. var oMenuItem = null;
  11514. var bSameAsCurrent;
  11515. if ( this.canShowLiveMenuItem() ) {
  11516. bSameAsCurrent = (sAction != "view" && sAction != "buxView" && oCV.getStatus() !== "fault");
  11517. oMenuItem = { name: "live", label: RV_RES.IDS_JS_SNAPSHOTS_LIVE, action: bSameAsCurrent ? {} : { name: "RunSavedOutputReport", payload: {} }, items: null };
  11518. this.addMenuItemChecked(bSameAsCurrent, oMenuItem);
  11519. menuItems.push(oMenuItem);
  11520. if (queryItems.length > 0) {
  11521. menuItems.push({separator: true});
  11522. }
  11523. }
  11524. if (queryItems.length > 0) {
  11525. var actionClassHanlder = this.getMenuItemActionClassHandler();
  11526. var versions = [];
  11527. for (var iIndex=0; iIndex < queryItems.length; iIndex++) {
  11528. if (iIndex < 5) {
  11529. var queryItem = queryItems[iIndex];
  11530. var sItemLabel = XMLHelper_GetText(XMLHelper_FindChildByTagName(queryItem, "creationTime_localized", true));
  11531. sItemLabel = enforceTextDir(sItemLabel);
  11532. var storeIDNode = XMLHelper_FindChildByTagName(queryItem, "storeID", true);
  11533. var sStoreID = XMLHelper_GetText(XMLHelper_FindChildByTagName(storeIDNode, "value", true));
  11534. var creationTimeNode = XMLHelper_FindChildByTagName(queryItem, "creationTime", true);
  11535. var sCreationTime = XMLHelper_GetText(XMLHelper_FindChildByTagName(creationTimeNode, "value", true));
  11536. if (mostRecentCreationTime == null) {
  11537. mostRecentCreationTime = sCreationTime;
  11538. mostRecentStoreID = sStoreID;
  11539. }
  11540. bSameAsCurrent = (sAction == "view" || sAction == "buxView") && oCV.envParams["creationTime"] == sCreationTime && widget.getSavedOutputSearchPath() != null;
  11541. oMenuItem = { name: "savedOutput", label: sItemLabel, action: bSameAsCurrent ? {} : { name: actionClassHanlder, payload: {obj:sStoreID, creationTime:sCreationTime, mostRecent:false} }, items: null };
  11542. this.addMenuItemChecked(bSameAsCurrent, oMenuItem);
  11543. versions.push(oMenuItem);
  11544. }
  11545. else {
  11546. versions.push({ name: "viewAllSnapshots", label: RV_RES.IDS_JS_VIEW_ALL_SNAPSHOTS, action: { name: "ViewAllSnapshots", payload: {} }, items: null });
  11547. break;
  11548. }
  11549. }
  11550. bSameAsCurrent = false;
  11551. if (widget.getSavedOutputSearchPath() == null && (sAction == "view" || sAction == "buxView")) {
  11552. bSameAsCurrent = true;
  11553. }
  11554. oMenuItem = { name: "savedOutput", label: RV_RES.IDS_JS_MOST_RECENT_SNAPSHOT, action: bSameAsCurrent ? {} : { name: actionClassHanlder, payload: {obj:mostRecentStoreID, creationTime:mostRecentCreationTime, mostRecent:true} }, items: null };
  11555. this.addMenuItemChecked(bSameAsCurrent, oMenuItem);
  11556. menuItems.push(oMenuItem);
  11557. menuItems.push({separator: true});
  11558. menuItems = menuItems.concat(versions);
  11559. }
  11560. buttonSpec.open = bOpen;
  11561. buttonSpec.items = menuItems;
  11562. var updateItems = [];
  11563. updateItems.push(buttonSpec);
  11564. widget.fireEvent("com.ibm.bux.widgetchrome.toolbar.update", null, updateItems);
  11565. };
  11566. SnapshotsAction.prototype.resetMenu = function(bOpen) {
  11567. var oCV = this.getCognosViewer();
  11568. var widget = oCV.getViewerWidget();
  11569. var root = oCV.findBlueDotMenu();
  11570. var buttonSpec = oCV.findToolbarItem("Snapshots", root);
  11571. if (buttonSpec) {
  11572. buttonSpec.open = false;
  11573. var menuItems = [{ name: "loadng", label: RV_RES.GOTO_LOADING, iconClass: "loading"}];
  11574. buttonSpec.items = menuItems;
  11575. var updateItems = [buttonSpec];
  11576. widget.fireEvent("com.ibm.bux.widgetchrome.toolbar.update", null, updateItems);
  11577. }
  11578. };
  11579. /*
  11580. *+------------------------------------------------------------------------+
  11581. *| Licensed Materials - Property of IBM
  11582. *| IBM Cognos Products: Viewer
  11583. *| (C) Copyright IBM Corp. 2001, 2012
  11584. *|
  11585. *| US Government Users Restricted Rights - Use, duplication or
  11586. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11587. *|
  11588. *+------------------------------------------------------------------------+
  11589. */
  11590. function SwapRowsAndColumnsAction()
  11591. {
  11592. this.m_sAction = "SwapRowsAndColumns";
  11593. }
  11594. SwapRowsAndColumnsAction.prototype = new ModifyReportAction();
  11595. SwapRowsAndColumnsAction.prototype.getUndoHint = function()
  11596. {
  11597. return RV_RES.IDS_JS_SWAP_ROWS_AND_COLUMNS;
  11598. };
  11599. /**
  11600. * List of display types that do not support SwapRowsAndColumns
  11601. */
  11602. SwapRowsAndColumnsAction.M_oDisplayTypeIsUnsupported = {
  11603. winLossChart : true,
  11604. progressiveChart : true,
  11605. list : true
  11606. };
  11607. SwapRowsAndColumnsAction.prototype.canSwap = function()
  11608. {
  11609. if( this.reportHasOneObjectOnly())
  11610. {
  11611. return this.isCurrentObject_singlePart_SupportedChartOrCrosstab();
  11612. }
  11613. else
  11614. {
  11615. return this.isSelectedObject_SupportedChartOrCrosstab();
  11616. }
  11617. };
  11618. SwapRowsAndColumnsAction.prototype.reportHasOneObjectOnly = function()
  11619. {
  11620. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  11621. if (oRAPReportInfo) {
  11622. return ( oRAPReportInfo.getContainerCount() == 1 );
  11623. }
  11624. return false;
  11625. };
  11626. SwapRowsAndColumnsAction.prototype.isSelectedObject_SupportedChartOrCrosstab = function()
  11627. {
  11628. var reportInfo = this.getSelectedReportInfo();
  11629. return (reportInfo && !SwapRowsAndColumnsAction.M_oDisplayTypeIsUnsupported[reportInfo.displayTypeId]);
  11630. };
  11631. SwapRowsAndColumnsAction.prototype.isCurrentObject_singlePart_SupportedChartOrCrosstab = function()
  11632. {
  11633. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  11634. if (oRAPReportInfo) {
  11635. if (oRAPReportInfo.getContainerCount() === 1) {
  11636. var displayTypeId = oRAPReportInfo.getContainerFromPos(0).displayTypeId;
  11637. if (displayTypeId && !SwapRowsAndColumnsAction.M_oDisplayTypeIsUnsupported[ displayTypeId ] ) {
  11638. return true;
  11639. }
  11640. }
  11641. }
  11642. return false;
  11643. };
  11644. SwapRowsAndColumnsAction.prototype.keepRAPCache = function()
  11645. {
  11646. return false;
  11647. };
  11648. SwapRowsAndColumnsAction.prototype.updateMenu = function(jsonSpec)
  11649. {
  11650. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  11651. if (! jsonSpec.visible)
  11652. {
  11653. return jsonSpec;
  11654. }
  11655. jsonSpec.disabled = !this.canSwap();
  11656. jsonSpec.iconClass = jsonSpec.disabled ? 'disabledSwap' : 'swap';
  11657. return jsonSpec;
  11658. };
  11659. /*
  11660. *+------------------------------------------------------------------------+
  11661. *| Licensed Materials - Property of IBM
  11662. *| IBM Cognos Products: Viewer
  11663. *| (C) Copyright IBM Corp. 2001, 2011
  11664. *|
  11665. *| US Government Users Restricted Rights - Use, duplication or
  11666. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11667. *|
  11668. *+------------------------------------------------------------------------+
  11669. */
  11670. function UndoRedoAction(){}
  11671. UndoRedoAction.prototype = new CognosViewerAction();
  11672. UndoRedoAction.prototype.dispatchRequest = function(filters, action)
  11673. {
  11674. var cognosViewerRequest = null;
  11675. var undoObj = null;
  11676. var undoRedoQueue = this.getUndoRedoQueue();
  11677. if (action == "Undo")
  11678. {
  11679. undoObj = undoRedoQueue.moveBack();
  11680. }
  11681. else
  11682. {
  11683. undoObj = undoRedoQueue.moveForward();
  11684. }
  11685. if (action == "Undo" && undoObj && undoObj.undoCallback) {
  11686. undoObj.undoCallback();
  11687. this.getCognosViewer().getViewerWidget().updateToolbar();
  11688. }
  11689. else if (action == "Redo" && undoObj && undoObj.redoCallback) {
  11690. undoObj.redoCallback();
  11691. this.getCognosViewer().getViewerWidget().updateToolbar();
  11692. }
  11693. else
  11694. {
  11695. var widgetProperties = this.getCognosViewer().getViewerWidget().getProperties();
  11696. if (widgetProperties && undoObj.widgetProperties)
  11697. {
  11698. widgetProperties.doUndo(undoObj.widgetProperties);
  11699. }
  11700. var cognosViewerRequest = new ViewerDispatcherEntry(this.getCognosViewer());
  11701. if (typeof undoObj.spec != "undefined")
  11702. {
  11703. cognosViewerRequest.addFormField("ui.action", "undoRedo");
  11704. cognosViewerRequest.addFormField("ui.spec", undoObj.spec);
  11705. cognosViewerRequest.addFormField("executionParameters", undoObj.parameters);
  11706. }
  11707. else
  11708. {
  11709. cognosViewerRequest.addFormField("ui.action", "undoRedo");
  11710. cognosViewerRequest.addFormField("ui.conversation", undoObj.conversation);
  11711. }
  11712. if (typeof undoObj.hasAVSChart != "undefined")
  11713. {
  11714. cognosViewerRequest.addFormField("hasAVSChart", undoObj.hasAVSChart);
  11715. }
  11716. if (widgetProperties && widgetProperties.getRowsPerPage() != null) {
  11717. cognosViewerRequest.addFormField( "run.verticalElements", widgetProperties.getRowsPerPage() );
  11718. }
  11719. if(filters != "")
  11720. {
  11721. cognosViewerRequest.addFormField("cv.updateDataFilters", filters);
  11722. }
  11723. if (typeof undoObj.infoBar == "string")
  11724. {
  11725. cognosViewerRequest.addFormField("rap.reportInfo", undoObj.infoBar);
  11726. }
  11727. else
  11728. {
  11729. cognosViewerRequest.addFormField("rap.reportInfo", "{}");
  11730. }
  11731. cognosViewerRequest.addFormField("run.prompt", "false");
  11732. cognosViewerRequest.setCallbacks( {
  11733. "closeErrorDlg" : {"object" : undoRedoQueue, "method" : undoRedoQueue.handleCancel}
  11734. });
  11735. this.getCognosViewer().dispatchRequest(cognosViewerRequest);
  11736. }
  11737. this.fireModifiedReportEvent();
  11738. };
  11739. UndoRedoAction.prototype.execute = function()
  11740. {
  11741. this.gatherFilterInfoBeforeAction(this.m_sAction);
  11742. };
  11743. /*
  11744. *+------------------------------------------------------------------------+
  11745. *| Licensed Materials - Property of IBM
  11746. *| IBM Cognos Products: Viewer
  11747. *| (C) Copyright IBM Corp. 2001, 2011
  11748. *|
  11749. *| US Government Users Restricted Rights - Use, duplication or
  11750. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11751. *|
  11752. *+------------------------------------------------------------------------+
  11753. */
  11754. function UndoAction()
  11755. {
  11756. this.m_sAction = "Undo";
  11757. }
  11758. UndoAction.prototype = new UndoRedoAction();
  11759. UndoAction.prototype.updateMenu = function(jsonSpec)
  11760. {
  11761. jsonSpec.visible = this.getCognosViewer().isLimitedInteractiveMode() ? true : this.ifContainsInteractiveDataContainer();
  11762. if (! jsonSpec.visible)
  11763. {
  11764. return jsonSpec;
  11765. }
  11766. if (this.getUndoRedoQueue().getPosition() > 0)
  11767. {
  11768. jsonSpec.iconClass = "undo";
  11769. jsonSpec.disabled = false;
  11770. }
  11771. else
  11772. {
  11773. jsonSpec.iconClass = "undoDisabled";
  11774. jsonSpec.disabled = true;
  11775. }
  11776. jsonSpec.label = this.getUndoRedoQueue().getUndoTooltip();
  11777. return jsonSpec;
  11778. };
  11779. /*
  11780. *+------------------------------------------------------------------------+
  11781. *| Licensed Materials - Property of IBM
  11782. *| IBM Cognos Products: Viewer
  11783. *| (C) Copyright IBM Corp. 2001, 2011
  11784. *|
  11785. *| US Government Users Restricted Rights - Use, duplication or
  11786. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11787. *|
  11788. *+------------------------------------------------------------------------+
  11789. */
  11790. function RedoAction()
  11791. {
  11792. this.m_sAction = "Redo";
  11793. }
  11794. RedoAction.prototype = new UndoRedoAction();
  11795. RedoAction.prototype.updateMenu = function(jsonSpec)
  11796. {
  11797. jsonSpec.visible = this.getCognosViewer().isLimitedInteractiveMode() ? true : this.ifContainsInteractiveDataContainer();
  11798. if (! jsonSpec.visible)
  11799. {
  11800. return jsonSpec;
  11801. }
  11802. if (this.getUndoRedoQueue().getPosition() < (this.getUndoRedoQueue().getLength()-1))
  11803. {
  11804. jsonSpec.iconClass = "redo";
  11805. jsonSpec.disabled = false;
  11806. }
  11807. else
  11808. {
  11809. jsonSpec.iconClass = "redoDisabled";
  11810. jsonSpec.disabled = true;
  11811. }
  11812. jsonSpec.label = this.getUndoRedoQueue().getRedoTooltip();
  11813. return jsonSpec;
  11814. };
  11815. /*
  11816. *+------------------------------------------------------------------------+
  11817. *| Licensed Materials - Property of IBM
  11818. *| IBM Cognos Products: Viewer
  11819. *| (C) Copyright IBM Corp. 2001, 2011
  11820. *|
  11821. *| US Government Users Restricted Rights - Use, duplication or
  11822. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11823. *|
  11824. *+------------------------------------------------------------------------+
  11825. */
  11826. function ViewAllSnapshotsAction(){}
  11827. ViewAllSnapshotsAction.prototype = new SnapshotsAction();
  11828. ViewAllSnapshotsAction.prototype.updateMenu = function(jsonSpec) {
  11829. var oCV = this.getCognosViewer();
  11830. var widget = oCV.getViewerWidget();
  11831. if (widget.m_bNoSavedOutputs == true) {
  11832. jsonSpec.disabled = true;
  11833. }
  11834. return jsonSpec;
  11835. };
  11836. ViewAllSnapshotsAction.prototype.execute = function() {
  11837. if (!this.getCognosViewer().getViewerWidget().getSavedOutputsCMResponse()) {
  11838. this.queryCMForSavedOutputs({"complete" : {"object" : this, "method" : this.handleQueryResponse}});
  11839. }
  11840. else {
  11841. this.showDialog();
  11842. }
  11843. };
  11844. ViewAllSnapshotsAction.prototype.handleQueryResponse = function(response) {
  11845. this.setSavedOutputsCMResponse(response);
  11846. this.showDialog();
  11847. };
  11848. ViewAllSnapshotsAction.prototype.showDialog = function() {
  11849. var oCV = this.getCognosViewer();
  11850. var widget = oCV.getViewerWidget();
  11851. var cmResponse = widget.getSavedOutputsCMResponse();
  11852. var queryResult = null;
  11853. var queryItems = null;
  11854. if (cmResponse) {
  11855. queryResult = XMLHelper_FindChildByTagName(cmResponse, "result", true);
  11856. if (queryResult) {
  11857. queryItems = XMLHelper_FindChildrenByTagName(queryResult, "item", false);
  11858. }
  11859. }
  11860. if (!cmResponse || !queryItems || queryItems.length == 0) {
  11861. widget.m_bNoSavedOutputs = true;
  11862. var warningDialog = new WarningMessageDialog(oCV, RV_RES.IDS_JS_NO_SAVED_OUTPUTS);
  11863. warningDialog.renderInlineDialog();
  11864. //widget.showErrorMessage(RV_RES.IDS_JS_NO_SAVED_OUTPUTS);
  11865. }
  11866. else {
  11867. var cognosViewerObjectString = getCognosViewerObjectString(this.m_oCV.getId());
  11868. var menuItemString = RV_RES.IDS_JS_SELECT_SNAPSHOT_DIALOG_TITLE;
  11869. var enterNumberLabel = RV_RES.IDS_JS_SELECT_SNAPSHOT_DIALOG_DESC;
  11870. var creationTime = this.getCognosViewer().envParams["creationTime"];
  11871. this.selectSnapshotDialog = new viewer.dialogs.SelectSnapshot({
  11872. sTitle:menuItemString,
  11873. sLabel:enterNumberLabel,
  11874. cmResponse:cmResponse,
  11875. currentSnapshotCreationTime: creationTime,
  11876. okHandler: function(sStoreID, sCreationTime)
  11877. {
  11878. window[cognosViewerObjectString].executeAction("ViewSavedOutput", {obj:sStoreID, creationTime: sCreationTime});
  11879. },
  11880. cancelHandler: function() {}
  11881. });
  11882. this.selectSnapshotDialog.startup();
  11883. this.selectSnapshotDialog.show();
  11884. }
  11885. };/*
  11886. *+------------------------------------------------------------------------+
  11887. *| Licensed Materials - Property of IBM
  11888. *| IBM Cognos Products: Viewer
  11889. *| (C) Copyright IBM Corp. 2001, 2011
  11890. *|
  11891. *| US Government Users Restricted Rights - Use, duplication or
  11892. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11893. *|
  11894. *+------------------------------------------------------------------------+
  11895. */
  11896. function ViewOriginalLabelAction() {}
  11897. ViewOriginalLabelAction.prototype = new CognosViewerAction();
  11898. ViewOriginalLabelAction.prototype.getCellRef = function() {
  11899. return this.m_oCV.getSelectionController().getSelections()[0].getCellRef();
  11900. };
  11901. ViewOriginalLabelAction.prototype.updateMenu = function(jsonSpec) {
  11902. if (this.getNumberOfSelections() == 1)
  11903. {
  11904. var selRef = this.getCellRef();
  11905. if (selRef.getAttribute("rp_name"))
  11906. {
  11907. var menuItems = [];
  11908. menuItems.push({ name: "originalLabel", label: selRef.getAttribute("rp_name"), iconClass: "", action: null, items: null });
  11909. jsonSpec.items = menuItems;
  11910. return jsonSpec;
  11911. }
  11912. }
  11913. return "";
  11914. };
  11915. /*
  11916. *+------------------------------------------------------------------------+
  11917. *| Licensed Materials - Property of IBM
  11918. *| IBM Cognos Products: Viewer
  11919. *| (C) Copyright IBM Corp. 2001, 2011
  11920. *|
  11921. *| US Government Users Restricted Rights - Use, duplication or
  11922. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11923. *|
  11924. *+------------------------------------------------------------------------+
  11925. */
  11926. function ViewSavedOutputAction()
  11927. {
  11928. this.m_obj = "";
  11929. this.creationTime = "";
  11930. this.m_mostRecent = false;
  11931. }
  11932. ViewSavedOutputAction.prototype = new CognosViewerAction();
  11933. ViewSavedOutputAction.prototype.addAdditionalRequestParms = function(cognosViewerRequest) {};
  11934. ViewSavedOutputAction.prototype.setRequestParms = function(payload) {
  11935. this.m_obj = payload.obj;
  11936. this.creationTime = payload.creationTime;
  11937. this.m_mostRecent = payload.mostRecent;
  11938. };
  11939. ViewSavedOutputAction.prototype.updateMenu = function() {
  11940. // update the menu so the saved output that's going to be viewed is shown as selected
  11941. var snapshotsAction = this.getCognosViewer().getAction("Snapshots");
  11942. snapshotsAction.populateMenu(false);
  11943. };
  11944. ViewSavedOutputAction.prototype.execute = function() {
  11945. var cognosViewer = this.getCognosViewer();
  11946. var widget = cognosViewer.getViewerWidget();
  11947. if( cognosViewer.getStatus() === 'fault')
  11948. {
  11949. widget.clearErrorDlg();
  11950. }
  11951. // clear the global prompt information
  11952. cognosViewer.getViewerWidget().setPromptParametersRetrieved(false);
  11953. cognosViewer.envParams["reportPrompts"] = "";
  11954. var sAction = cognosViewer.envParams["ui.action"];
  11955. var formWarpRequest = document.getElementById("formWarpRequest" + cognosViewer.getId());
  11956. if (sAction == "view" && formWarpRequest && formWarpRequest.reRunObj && formWarpRequest.reRunObj.value ) {
  11957. cognosViewer.envParams["ui.reRunObj"] = formWarpRequest["reRunObj"].value;
  11958. } else if (sAction != "view") {
  11959. cognosViewer.envParams["ui.reRunObj"] = cognosViewer.envParams["ui.object"];
  11960. }
  11961. var searchPath = "storeID('" + this.m_obj + "')";
  11962. cognosViewer.envParams["ui.action"] = "buxView";
  11963. cognosViewer.envParams["ui.object"] = cognosViewer.envParams["ui.reRunObj"];
  11964. cognosViewer.envParams["creationTime"] = this.creationTime;
  11965. if (this.m_mostRecent === true) {
  11966. widget.setSavedOutputSearchPath(null);
  11967. }
  11968. else {
  11969. widget.setSavedOutputSearchPath(searchPath);
  11970. }
  11971. // update the menu so the saved output that's going to be viewed is shown as selected
  11972. this.updateMenu();
  11973. // clear the undo queue
  11974. this.getUndoRedoQueue().clearQueue();
  11975. // Clear the properties dialog to it'll get rebuilt. This is needed for the 'View report specification' link
  11976. cognosViewer.getViewerWidget().clearPropertiesDialog();
  11977. if (cognosViewer.getCurrentlySelectedTab() && widget.getSavedOutput()) {
  11978. cognosViewer.setKeepTabSelected(cognosViewer.getCurrentlySelectedTab());
  11979. }
  11980. this.dispatchRequest(searchPath);
  11981. this.fireModifiedReportEvent();
  11982. };
  11983. ViewSavedOutputAction.prototype.dispatchRequest = function(searchPath) {
  11984. this.m_request = new ViewerDispatcherEntry(this.m_oCV);
  11985. this.m_request.addFormField("ui.action", "buxView");
  11986. // we need to include the report name or we'll end up doing 2 CM queries.
  11987. this.m_request.addFormField("ui.name", this.m_oCV.envParams["ui.name"]);
  11988. this.m_request.addFormField("widget.reloadToolbar", "true");
  11989. this.m_request.addFormField("cv.objectPermissions", this.m_oCV.envParams["cv.objectPermissions"]);
  11990. this.m_request.addFormField("ui.savedOutputSearchPath", searchPath);
  11991. this.m_request.setCallbacks( {"complete" : {"object" : this, "method" : this.onComplete}});
  11992. this.addAdditionalRequestParms(this.m_request);
  11993. this.m_oCV.dispatchRequest(this.m_request);
  11994. };
  11995. ViewSavedOutputAction.prototype.onComplete = function(asynchDATAResponse, arg1) {
  11996. this.m_oCV.setTracking("");
  11997. this.m_oCV.setConversation("");
  11998. this.m_request.onComplete(asynchDATAResponse, arg1);
  11999. };
  12000. /*
  12001. *+------------------------------------------------------------------------+
  12002. *| Licensed Materials - Property of IBM
  12003. *| IBM Cognos Products: Viewer
  12004. *| (C) Copyright IBM Corp. 2001, 2011
  12005. *|
  12006. *| US Government Users Restricted Rights - Use, duplication or
  12007. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12008. *|
  12009. *+------------------------------------------------------------------------+
  12010. */
  12011. function WatchNewVersionsAction()
  12012. {
  12013. this.m_requestParms = {subAction:""};
  12014. }
  12015. WatchNewVersionsAction.prototype = new CognosViewerAction();
  12016. WatchNewVersionsAction.prototype.setRequestParms = function(requestParms)
  12017. {
  12018. this.m_requestParms = requestParms;
  12019. };
  12020. WatchNewVersionsAction.prototype.execute = function()
  12021. {
  12022. var subscriptionManager = this.m_oCV.getSubscriptionManager();
  12023. switch(this.m_requestParms.subAction)
  12024. {
  12025. case "loadMenu":
  12026. this.loadMenu(this.m_requestParms.contextMenu);
  12027. break;
  12028. case "close":
  12029. this.closeMenu();
  12030. break;
  12031. case "DeleteNotification":
  12032. subscriptionManager.DeleteNotification();
  12033. break;
  12034. case "AddNotification":
  12035. subscriptionManager.AddNotification();
  12036. break;
  12037. case "NewSubscription":
  12038. subscriptionManager.NewSubscription();
  12039. break;
  12040. case "ModifySubscription":
  12041. subscriptionManager.ModifySubscription(this.m_requestParms.subscriptionId);
  12042. break;
  12043. case "DeleteSubscription":
  12044. subscriptionManager.DeleteSubscription(this.m_requestParms.subscriptionId);
  12045. break;
  12046. }
  12047. };
  12048. WatchNewVersionsAction.prototype.closeMenu = function() {
  12049. var buttonSpec = this.m_oCV.findToolbarItem("WatchNewVersions");
  12050. this.resetMenu(buttonSpec);
  12051. var viewerString = getCognosViewerObjectRefAsString(this.m_oCV.getId());
  12052. // we need to do a set time to let the original menu destroy itself before we go and create a new one
  12053. setTimeout(viewerString + ".getViewerWidget().fireEvent(\"com.ibm.bux.widgetchrome.toolbar.update\", null, [" + viewerString + ".findToolbarItem(\"WatchNewVersions\")]);", 1);
  12054. };
  12055. WatchNewVersionsAction.prototype.resetMenu = function(jsonSpec) {
  12056. jsonSpec.open = false;
  12057. jsonSpec.action = {name: "WatchNewVersions", payload: {subAction:"loadMenu", contextMenu:false}};
  12058. jsonSpec.closeAction = null;
  12059. var menuItems = [];
  12060. menuItems.push({ name: "loadng", label: RV_RES.GOTO_LOADING, iconClass: "loading"});
  12061. jsonSpec.items = menuItems;
  12062. };
  12063. WatchNewVersionsAction.prototype.updateMenu = function(jsonSpec)
  12064. {
  12065. var items = jsonSpec.items;
  12066. var subscriptionManager = this.m_oCV.getSubscriptionManager();
  12067. // context menu won't have any items
  12068. if (!items || items.length === 0){
  12069. jsonSpec.visible = subscriptionManager.CanCreateNewWatchRule();
  12070. jsonSpec.disabled = !(subscriptionManager.IsValidSelectionForNewRule());
  12071. }
  12072. else {
  12073. // we always want to repopulate the toolbar menu, so reset it every time updaetMenu gets called
  12074. this.resetMenu(jsonSpec);
  12075. }
  12076. return jsonSpec;
  12077. };
  12078. WatchNewVersionsAction.prototype.loadMenu = function(contextMenu)
  12079. {
  12080. var subscriptionManager = this.m_oCV.getSubscriptionManager();
  12081. var cvId = this.m_oCV.getId();
  12082. var oCV = this.m_oCV;
  12083. var request = new JSONDispatcherEntry(oCV);
  12084. request.addFormField("ui.action", "getSubscriptionInfo");
  12085. request.addFormField("cv.responseFormat", "subscriptionManager");
  12086. request.addFormField("contextMenu", contextMenu == true ? "true" : "false");
  12087. subscriptionManager.addCommonFormFields(request, "");
  12088. request.setCallbacks({"complete":{"object":this, "method":this.openSubscriptionMenuResponse}});
  12089. oCV.dispatchRequest(request);
  12090. };
  12091. WatchNewVersionsAction.prototype.openSubscriptionMenuResponse = function(response)
  12092. {
  12093. var subscriptionManager = this.m_oCV.getSubscriptionManager();
  12094. subscriptionManager.Initialize(response);
  12095. var menuItems = [];
  12096. // Clear the menu
  12097. subscriptionManager.ClearSubscriptionMenu();
  12098. var bAddSeperator = false;
  12099. if ( subscriptionManager.CanGetNotified() )
  12100. {
  12101. if (subscriptionManager.m_sQueryNotificationResponse == 'on')
  12102. {
  12103. menuItems.push({ name: "DeleteNotification", label: RV_RES.RV_DO_NOT_ALERT_NEW_VERSION, iconClass: "deleteNotification", action: { name: "WatchNewVersions", payload: {subAction:"DeleteNotification"} }, items: null });
  12104. bAddSeperator = true;
  12105. }
  12106. else if (subscriptionManager.m_sQueryNotificationResponse == 'off' && subscriptionManager.m_sEmail != "")
  12107. {
  12108. menuItems.push({ name: "AddNotification", label: RV_RES.RV_ALERT_NEW_VERSION, iconClass: "addNotification", action: { name: "WatchNewVersions", payload: {subAction:"AddNotification"} }, items: null });
  12109. bAddSeperator = true;
  12110. }
  12111. }
  12112. if (subscriptionManager.CanCreateNewWatchRule())
  12113. {
  12114. if (bAddSeperator)
  12115. {
  12116. menuItems.push({separator: true});
  12117. }
  12118. var newSubScriptionMenuItem = { name: "NewSubscription", label: RV_RES.RV_NEW_WATCH_RULE, iconClass: "newSubscription", action: { name: "WatchNewVersions", payload: {subAction:"NewSubscription"} }, items: null };
  12119. if (!subscriptionManager.IsValidSelectionForNewRule())
  12120. {
  12121. newSubScriptionMenuItem.disabled = true;
  12122. }
  12123. menuItems.push(newSubScriptionMenuItem);
  12124. bAddSeperator = true;
  12125. }
  12126. var sBlacklist = "";
  12127. if (typeof this.m_oCV.UIBlacklist != "undefined")
  12128. {
  12129. sBlacklist = this.m_oCV.UIBlacklist;
  12130. }
  12131. //iterate through existing subscriptions
  12132. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES ') == -1)
  12133. {
  12134. if ( subscriptionManager.m_aWatchRules && subscriptionManager.m_aWatchRules.length > 0)
  12135. {
  12136. if (bAddSeperator)
  12137. {
  12138. menuItems.push({separator: true});
  12139. }
  12140. var bCanModifyWatchRules = subscriptionManager.CanModifyWatchRule();
  12141. for(var sub = 0; sub < subscriptionManager.m_aWatchRules.length; ++sub)
  12142. {
  12143. var menu = { name: "WatchRule" + sub, label: subscriptionManager.m_aWatchRules[sub].name, iconClass: "watchRule", action: null, items: [] };
  12144. if (bCanModifyWatchRules && sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES_MODIFY ') == -1)
  12145. {
  12146. menu.items.push({ name: "ModifySubscription" + sub, label: RV_RES.RV_MODIFY_WATCH_RULE, iconClass: "modifySubscription", action: { name: "WatchNewVersions", payload: {subAction:"ModifySubscription", subscriptionId:sub} }, items: null });
  12147. }
  12148. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_RULES_DELETE ') == -1)
  12149. {
  12150. menu.items.push({ name: "DeleteSubscription" + sub, label: RV_RES.RV_DELETE_WATCH_RULE, iconClass: "deleteSubscription", action: { name: "WatchNewVersions", payload: {subAction:"DeleteSubscription", subscriptionId:sub} }, items: null });
  12151. }
  12152. menuItems.push(menu);
  12153. }
  12154. }
  12155. }
  12156. if (menuItems.length === 0)
  12157. {
  12158. menuItems.push({ name: "NoWatchRules", label: RV_RES.RV_NO_WATCH_RULES, iconClass: "", action: null, items: null, disabled:true });
  12159. }
  12160. var buttonSpec = this.m_oCV.findToolbarItem("WatchNewVersions");
  12161. if (buttonSpec) {
  12162. buttonSpec.items = menuItems;
  12163. buttonSpec.action = null;
  12164. buttonSpec.open = true;
  12165. buttonSpec.closeAction = { name: "WatchNewVersions", payload: {subAction:"close"} };
  12166. var updateItems = [];
  12167. updateItems.push(buttonSpec);
  12168. this.m_oCV.getViewerWidget().fireEvent("com.ibm.bux.widgetchrome.toolbar.update", null, updateItems);
  12169. }
  12170. };/*
  12171. *+------------------------------------------------------------------------+
  12172. *| Licensed Materials - Property of IBM
  12173. *| IBM Cognos Products: Viewer
  12174. *| (C) Copyright IBM Corp. 2001, 2011
  12175. *|
  12176. *| US Government Users Restricted Rights - Use, duplication or
  12177. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12178. *|
  12179. *+------------------------------------------------------------------------+
  12180. */
  12181. /**
  12182. * RunSavedOutputReportAction - implements re-run in cognos viewer
  12183. */
  12184. function RunSavedOutputReportAction(){}
  12185. RunSavedOutputReportAction.prototype = new CognosViewerAction();
  12186. RunSavedOutputReportAction.prototype.updateMenu = function(jsonSpec) {
  12187. var sAction = this.m_oCV.envParams["ui.action"];
  12188. var bLiveReport = (sAction != "view" && sAction != "buxView" && this.m_oCV.getStatus() !== "fault");
  12189. this.addMenuItemChecked(bLiveReport, jsonSpec);
  12190. return jsonSpec;
  12191. };
  12192. RunSavedOutputReportAction.prototype.dispatchRequest = function(filters) {
  12193. var cognosViewer = this.getCognosViewer();
  12194. // The savedReportName will only be set if the user opened a saved dashboard, switched to saved output
  12195. // and then reran the report. In this situation we need to clear the savedReportName so that when the user
  12196. // saves the dashboard, a new report is created under the dashboard (bug COGCQ00278882)
  12197. if (cognosViewer.envParams["savedReportName"]) {
  12198. delete cognosViewer.envParams["savedReportName"];
  12199. }
  12200. // clear off the error page if this is invoked after a fault
  12201. if( cognosViewer.getStatus() === 'fault')
  12202. {
  12203. var widget = this.getCognosViewer().getViewerWidget();
  12204. widget.clearErrorDlg();
  12205. }
  12206. var sAction = cognosViewer.envParams["ui.action"];
  12207. var formWarpRequest = document.getElementById("formWarpRequest" + cognosViewer.getId());
  12208. if (cognosViewer.envParams["ui.reRunObj"])
  12209. {
  12210. cognosViewer.envParams["ui.object"] = cognosViewer.envParams["ui.reRunObj"];
  12211. }
  12212. else if (sAction == "view" && formWarpRequest && typeof formWarpRequest["reRunObj"] != "undefined" && formWarpRequest["reRunObj"] != null && formWarpRequest["reRunObj"].value.length > 0)
  12213. {
  12214. cognosViewer.envParams["ui.object"] = formWarpRequest["reRunObj"].value;
  12215. }
  12216. var oReq = new ViewerDispatcherEntry(cognosViewer);
  12217. oReq.addFormField("ui.action", "bux");
  12218. oReq.addFormField("widget.runFromSavedOutput", "true");
  12219. oReq.addFormField("ui.object", cognosViewer.envParams["ui.object"]);
  12220. oReq.addFormField("run.outputFormat", "HTML");
  12221. oReq.addFormField("ui.primaryAction","");
  12222. oReq.addFormField("widget.reloadToolbar", "true");
  12223. oReq.addDefinedNonNullFormField("cv.objectPermissions", cognosViewer.envParams["cv.objectPermissions"]);
  12224. oReq.addDefinedNonNullFormField("run.prompt", cognosViewer.envParams["promptOnRerun"]);
  12225. oReq.addDefinedNonNullFormField("limitedInteractiveMode", cognosViewer.envParams["limitedInteractiveMode"]);
  12226. oReq.addDefinedNonNullFormField("widget.globalPromptInfo", cognosViewer.getViewerWidget().getGlobalPromptsInfo());
  12227. oReq.addDefinedNonNullFormField("baseReportSearchPath", cognosViewer.envParams["baseReportSearchPath"]);
  12228. oReq.addNonEmptyStringFormField("cv.updateDataFilters", filters);
  12229. // Clear the properties dialog to it'll get rebuilt. This is needed for the 'View report specification' link
  12230. cognosViewer.getViewerWidget().clearPropertiesDialog();
  12231. cognosViewer.preparePromptValues(oReq);
  12232. cognosViewer.dispatchRequest(oReq);
  12233. this.fireModifiedReportEvent();
  12234. cognosViewer.envParams["ui.action"] = "run";
  12235. };
  12236. RunSavedOutputReportAction.prototype.execute = function() {
  12237. this.gatherFilterInfoBeforeAction("RunSavedOutputReport");
  12238. };
  12239. /*
  12240. *+------------------------------------------------------------------------+
  12241. *| Licensed Materials - Property of IBM
  12242. *| IBM Cognos Products: Viewer
  12243. *| (C) Copyright IBM Corp. 2001, 2012
  12244. *|
  12245. *| US Government Users Restricted Rights - Use, duplication or
  12246. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12247. *|
  12248. *+------------------------------------------------------------------------+
  12249. */
  12250. function InvokeChangeDisplayTypeDialogAction(){}
  12251. InvokeChangeDisplayTypeDialogAction.prototype = new CognosViewerAction();
  12252. InvokeChangeDisplayTypeDialogAction.prototype.execute = function() {
  12253. var viewer = this.getCognosViewer();
  12254. var selectedObject = this.getSelectedReportInfo();
  12255. if(selectedObject)
  12256. {
  12257. var viewerWidget = viewer.getViewerWidget();
  12258. var bGetInfoOnServer = false;
  12259. if (selectedObject.suggestedDisplayTypesEnabled == true) {
  12260. bGetInfoOnServer = (typeof selectedObject.possibleDisplayTypes == "undefined") || (typeof selectedObject.suggestedDisplayTypes == "undefined")? true : false;
  12261. } else {
  12262. bGetInfoOnServer = (typeof selectedObject.possibleDisplayTypes == "undefined");
  12263. }
  12264. if (bGetInfoOnServer)
  12265. {
  12266. var asynchRequest = new AsynchJSONDispatcherEntry(this.m_oCV);
  12267. asynchRequest.setCallbacks({
  12268. "complete": {"object": this, "method": this.handleResponse}
  12269. });
  12270. asynchRequest.setRequestIndicator(viewer.getRequestIndicator());
  12271. asynchRequest.addFormField("ui.action", "getInfoFromReportSpec");
  12272. asynchRequest.addFormField("bux", "true");
  12273. asynchRequest.addNonEmptyStringFormField("modelPath", this.m_oCV.getModelPath());
  12274. asynchRequest.addFormField("ui.object", this.m_oCV.envParams["ui.object"]);
  12275. asynchRequest.addDefinedFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  12276. asynchRequest.addFormField("cv.actionContext", this.addActionContext());
  12277. asynchRequest.addFormField("ui.conversation", encodeURIComponent(this.m_oCV.getConversation()));
  12278. viewer.dispatchRequest(asynchRequest);
  12279. }
  12280. else
  12281. {
  12282. viewerWidget.invokeDisplayTypeDialog(selectedObject.possibleDisplayTypes,selectedObject.suggestedDisplayTypes );
  12283. }
  12284. }
  12285. };
  12286. InvokeChangeDisplayTypeDialogAction.prototype.handleResponse = function(asynchJSONResponse)
  12287. {
  12288. var viewer = this.getCognosViewer();
  12289. var viewerWidget = viewer.getViewerWidget();
  12290. var reportInfos = asynchJSONResponse.getResult();
  12291. for ( var i in reportInfos.containers)
  12292. {
  12293. var selectedReportInfo = this.getReportInfo(reportInfos.containers[i].container);
  12294. selectedReportInfo.possibleDisplayTypes = reportInfos.containers[i].possibleDisplayTypes;
  12295. selectedReportInfo.suggestedDisplayTypes = reportInfos.containers[i].suggestedDisplayTypes;
  12296. }
  12297. var selectedObject = this.getSelectedReportInfo();
  12298. viewerWidget.invokeDisplayTypeDialog(selectedObject.possibleDisplayTypes,selectedObject.suggestedDisplayTypes);
  12299. };
  12300. InvokeChangeDisplayTypeDialogAction.prototype.addActionContext = function()
  12301. {
  12302. var actionContext = "<getInfoActions>";
  12303. actionContext += "<getInfoAction name=\"GetInfo\">";
  12304. actionContext += "<include><possibleDisplayTypes/></include>";
  12305. actionContext += "<include><suggestedDisplayTypes/></include>";
  12306. actionContext += this.getDataItemInfoMap();;
  12307. actionContext += this.addClientContextData(/*maxValuesPerRDI*/3);
  12308. actionContext += "</getInfoAction>";
  12309. actionContext += "</getInfoActions>";
  12310. return actionContext;
  12311. };
  12312. InvokeChangeDisplayTypeDialogAction.prototype.updateMenu = function(jsonSpec)
  12313. {
  12314. var oRAPReportInfo = this.getCognosViewer().getRAPReportInfo();
  12315. jsonSpec.visible = oRAPReportInfo.containsInteractiveDataContainer();
  12316. if (! jsonSpec.visible)
  12317. {
  12318. return jsonSpec;
  12319. }
  12320. var reportInfo = this.getSelectedReportInfo();
  12321. jsonSpec.disabled = (reportInfo == null || reportInfo.displayTypeId == null || !this.isInteractiveDataContainer(reportInfo.displayTypeId));
  12322. if (jsonSpec.disabled)
  12323. {
  12324. jsonSpec.iconClass = "chartTypesDisabled";
  12325. return jsonSpec;
  12326. }
  12327. jsonSpec.iconClass = "chartTypes";
  12328. return jsonSpec;
  12329. };
  12330. /*
  12331. *+------------------------------------------------------------------------+
  12332. *| Licensed Materials - Property of IBM
  12333. *| IBM Cognos Products: Viewer
  12334. *| (C) Copyright IBM Corp. 2001, 2012
  12335. *|
  12336. *| US Government Users Restricted Rights - Use, duplication or
  12337. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12338. *|
  12339. *+------------------------------------------------------------------------+
  12340. */
  12341. function GotoAction(){}
  12342. GotoAction.prototype = new CognosViewerAction();
  12343. GotoAction.prototype.execute = function()
  12344. {
  12345. var drillManager = this.m_oCV.getDrillMgr();
  12346. drillManager.launchGoToPage();
  12347. };
  12348. GotoAction.prototype.updateMenu = function(jsonSpec)
  12349. {
  12350. var items = [];
  12351. var drillTargetSpecifications = this.m_oCV.getDrillTargets();
  12352. var drillManager = this.m_oCV.getDrillMgr();
  12353. var aAuthoredDrillThroughTargets = drillManager.getAuthoredDrillThroughTargets();
  12354. if(aAuthoredDrillThroughTargets.length > 0)
  12355. {
  12356. var sAuthoredDrillThroughTargets = "<AuthoredDrillTargets>";
  12357. for(var iIndex = 0; iIndex < aAuthoredDrillThroughTargets.length; ++iIndex)
  12358. {
  12359. sAuthoredDrillThroughTargets += eval('"' + aAuthoredDrillThroughTargets[iIndex] + '"');
  12360. }
  12361. sAuthoredDrillThroughTargets += "</AuthoredDrillTargets>";
  12362. var authoredDrillAction = this.m_oCV.getAction("AuthoredDrill");
  12363. var rvDrillTargetsNode = authoredDrillAction.getAuthoredDrillThroughContext(sAuthoredDrillThroughTargets, drillTargetSpecifications);
  12364. var drillTargets = rvDrillTargetsNode.childNodes;
  12365. if(drillTargets.length > 0)
  12366. {
  12367. for(var index = 0; index < drillTargets.length; ++index)
  12368. {
  12369. var drillTarget = drillTargets[index];
  12370. var sIconClass = this.getTargetReportIconClass(drillTarget);
  12371. var sLabel = drillTarget.getAttribute("label");
  12372. items.push({ name: "AuthoredDrill", label: sLabel, iconClass: sIconClass, action: { name: "AuthoredDrill", payload: XMLBuilderSerializeNode(drillTarget) }, items: null });
  12373. }
  12374. }
  12375. }
  12376. if(items.length > 0)
  12377. {
  12378. items.push({separator: true});
  12379. }
  12380. // related links
  12381. var relatedDisabled = false;
  12382. if(this.m_oCV.getSelectionController() == null || this.m_oCV.getSelectionController().getModelDrillThroughEnabled() == false)
  12383. {
  12384. relatedDisabled = true;
  12385. }
  12386. items.push({ name: "Goto", disabled: relatedDisabled, label: RV_RES.RV_MORE, iconClass: "", action: { name: "Goto", payload: "" }, items: null });
  12387. if (this.m_oCV.isIWidgetMobile()) {
  12388. jsonSpec.flatten = "true";
  12389. }
  12390. jsonSpec.items = items;
  12391. return jsonSpec;
  12392. };
  12393. GotoAction.prototype.getTargetReportIconClass = function(drillTarget)
  12394. {
  12395. var sIconClass = "";
  12396. var sMethod = drillTarget.getAttribute("method");
  12397. switch(sMethod)
  12398. {
  12399. case "edit":
  12400. sIconClass = "editContent";
  12401. break;
  12402. case "execute":
  12403. sIconClass = "runReport"; //"/ps/portal/images/action_run.gif";
  12404. break;
  12405. case "view":
  12406. var sOutputFormat = drillTarget.getAttribute("outputFormat");
  12407. switch(sOutputFormat)
  12408. {
  12409. case "HTML":
  12410. case "XHTML":
  12411. case "HTMLFragment":
  12412. sIconClass = "html";
  12413. break;
  12414. case "PDF":
  12415. sIconClass = "pdf";
  12416. break;
  12417. case "XML":
  12418. sIconClass = "xml";
  12419. break;
  12420. case "CSV":
  12421. sIconClass = "csv";
  12422. break;
  12423. case "XLS":
  12424. sIconClass = "excel2000";
  12425. break;
  12426. case "SingleXLS":
  12427. sIconClass = "excelSingleSheet";
  12428. break;
  12429. case "XLWA":
  12430. sIconClass = "excel2002";
  12431. break;
  12432. case "spreadsheetML":
  12433. sIconClass = "excel2007";
  12434. break;
  12435. case "xlsxData":
  12436. sIconClass = "excel2007";
  12437. break;
  12438. }
  12439. break;
  12440. }
  12441. return sIconClass;
  12442. };/*
  12443. *+------------------------------------------------------------------------+
  12444. *| Licensed Materials - Property of IBM
  12445. *| IBM Cognos Products: Viewer
  12446. *| (C) Copyright IBM Corp. 2001, 2011
  12447. *|
  12448. *| US Government Users Restricted Rights - Use, duplication or
  12449. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12450. *|
  12451. *+------------------------------------------------------------------------+
  12452. */
  12453. function AnnotationAction() {}
  12454. AnnotationAction.prototype = new CognosViewerAction();
  12455. AnnotationAction.prototype.updateMenu = function(jsonSpec)
  12456. {
  12457. var viewerWidgetRef = this.m_oCV.getViewerWidget();
  12458. var aAnnotations = this.m_oCV.aBuxAnnotations;
  12459. var annItems = [];
  12460. for (var annIndex=0; annIndex < aAnnotations.length; annIndex++)
  12461. {
  12462. var ann = eval("new " + aAnnotations[annIndex] + "()");
  12463. ann.setCognosViewer(this.m_oCV);
  12464. if (ann && ann.isEnabled(jsonSpec.placeType))
  12465. {
  12466. var newAnnItem = {};
  12467. newAnnItem.name = aAnnotations[annIndex];
  12468. newAnnItem.label = ann.getMenuItemString(viewerWidgetRef.getAttributeValue("itemName"));
  12469. newAnnItem.action = {};
  12470. newAnnItem.action.name = aAnnotations[annIndex];
  12471. newAnnItem.action.payload = "";
  12472. newAnnItem.items = null;
  12473. newAnnItem.iconClass = ann.getMenuItemIconClass();// aAnnotations[annIndex];
  12474. annItems.push(newAnnItem);
  12475. }
  12476. }
  12477. jsonSpec.items = annItems;
  12478. jsonSpec.disabled = !(jsonSpec.items && jsonSpec.items.length);
  12479. if(jsonSpec.disabled) {
  12480. jsonSpec.iconClass = "disabledAnnotation";
  12481. } else {
  12482. jsonSpec.iconClass = "annotation";
  12483. }
  12484. return jsonSpec;
  12485. };
  12486. AnnotationAction.prototype.execute = function()
  12487. {
  12488. var viewer = this.getCognosViewer();
  12489. var selCon = viewer.getSelectionController();
  12490. var selections = selCon.getSelections();
  12491. if (selections && selections.length == 1) {
  12492. var widget = viewer.getViewerWidget();
  12493. if (widget) {
  12494. this.executeAction(viewer, widget, selections[0]);
  12495. }
  12496. }
  12497. };
  12498. AnnotationAction.prototype.executeAction = function(viewer, widget, selection)
  12499. {
  12500. //Do nothing -- derived classes should override this method to perform the necessary action
  12501. };/*
  12502. *+------------------------------------------------------------------------+
  12503. *| Licensed Materials - Property of IBM
  12504. *| IBM Cognos Products: Viewer
  12505. *| (C) Copyright IBM Corp. 2001, 2012
  12506. *|
  12507. *| US Government Users Restricted Rights - Use, duplication or
  12508. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12509. *|
  12510. *+------------------------------------------------------------------------+
  12511. */
  12512. /**
  12513. * DeleteWidgetAnnotationAction - implements deleting existing annotations on the cognos viewer widget
  12514. */
  12515. function DeleteWidgetAnnotationAction() {}
  12516. DeleteWidgetAnnotationAction.prototype = new AnnotationAction();
  12517. DeleteWidgetAnnotationAction.prototype.execute = function()
  12518. {
  12519. var viewer = this.getCognosViewer();
  12520. var widget = viewer.getViewerWidget();
  12521. if (widget) {
  12522. widget.getAnnotationHelper().deleteWidgetComment();
  12523. }
  12524. };/*
  12525. *+------------------------------------------------------------------------+
  12526. *| Licensed Materials - Property of IBM
  12527. *| IBM Cognos Products: Viewer
  12528. *| (C) Copyright IBM Corp. 2001, 2012
  12529. *|
  12530. *| US Government Users Restricted Rights - Use, duplication or
  12531. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12532. *|
  12533. *+------------------------------------------------------------------------+
  12534. */
  12535. /**
  12536. * EditWidgetAnnotationAction - implements editing an existing annotation to the cognos viewer widget
  12537. */
  12538. function EditWidgetAnnotationAction() {}
  12539. EditWidgetAnnotationAction.prototype = new AnnotationAction();
  12540. EditWidgetAnnotationAction.prototype.execute = function()
  12541. {
  12542. var viewer = this.getCognosViewer();
  12543. var widget = viewer.getViewerWidget();
  12544. if (widget) {
  12545. window.setTimeout(function () { widget.getAnnotationHelper().editWidgetComment(); },0);
  12546. }
  12547. };/*
  12548. *+------------------------------------------------------------------------+
  12549. *| Licensed Materials - Property of IBM
  12550. *| IBM Cognos Products: Viewer
  12551. *| (C) Copyright IBM Corp. 2001, 2012
  12552. *|
  12553. *| US Government Users Restricted Rights - Use, duplication or
  12554. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12555. *|
  12556. *+------------------------------------------------------------------------+
  12557. */
  12558. /**
  12559. * NewWidgetAnnotationAction - implements adding new annotations to the cognos viewer widget
  12560. */
  12561. function NewWidgetAnnotationAction() {}
  12562. NewWidgetAnnotationAction.prototype = new AnnotationAction();
  12563. NewWidgetAnnotationAction.prototype.execute = function()
  12564. {
  12565. var viewer = this.getCognosViewer();
  12566. var widget = viewer.getViewerWidget();
  12567. if (widget) {
  12568. widget.getAnnotationHelper().addWidgetComment();
  12569. }
  12570. };/*
  12571. *+------------------------------------------------------------------------+
  12572. *| Licensed Materials - Property of IBM
  12573. *| IBM Cognos Products: Viewer
  12574. *| (C) Copyright IBM Corp. 2001, 2012
  12575. *|
  12576. *| US Government Users Restricted Rights - Use, duplication or
  12577. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12578. *|
  12579. *+------------------------------------------------------------------------+
  12580. */
  12581. /**
  12582. * DeleteAnnotationAction - implements deleting existing annotations in cognos viewer
  12583. */
  12584. function DeleteAnnotationAction() {}
  12585. DeleteAnnotationAction.prototype = new AnnotationAction();
  12586. DeleteAnnotationAction.prototype.executeAction = function(viewer, widget, selection)
  12587. {
  12588. if (viewer && widget && selection) {
  12589. var cellRef = selection.getCellRef();
  12590. var ctxId = viewer.findCtx(cellRef);
  12591. widget.getAnnotationHelper().deleteComment(ctxId);
  12592. }
  12593. };/*
  12594. *+------------------------------------------------------------------------+
  12595. *| Licensed Materials - Property of IBM
  12596. *| IBM Cognos Products: Viewer
  12597. *| (C) Copyright IBM Corp. 2001, 2012
  12598. *|
  12599. *| US Government Users Restricted Rights - Use, duplication or
  12600. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12601. *|
  12602. *+------------------------------------------------------------------------+
  12603. */
  12604. /**
  12605. * EditAnnotationAction - implements editing an existing annotation in cognos viewer
  12606. */
  12607. function EditAnnotationAction() {}
  12608. EditAnnotationAction.prototype = new AnnotationAction();
  12609. EditAnnotationAction.prototype.executeAction = function(viewer, widget, selection)
  12610. {
  12611. if (viewer && widget && selection) {
  12612. var cellRef = selection.getCellRef();
  12613. var ctxId = viewer.findCtx(cellRef);
  12614. window.setTimeout(function () { widget.getAnnotationHelper().editComment(ctxId); },0);
  12615. }
  12616. };/*
  12617. *+------------------------------------------------------------------------+
  12618. *| Licensed Materials - Property of IBM
  12619. *| IBM Cognos Products: Viewer
  12620. *| (C) Copyright IBM Corp. 2001, 2012
  12621. *|
  12622. *| US Government Users Restricted Rights - Use, duplication or
  12623. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12624. *|
  12625. *+------------------------------------------------------------------------+
  12626. */
  12627. /**
  12628. * NewAnnotationAction - implements adding new annotations in cognos viewer
  12629. */
  12630. function NewAnnotationAction() {}
  12631. NewAnnotationAction.prototype = new AnnotationAction();
  12632. NewAnnotationAction.prototype.executeAction = function(viewer, widget, selection)
  12633. {
  12634. if (viewer && widget && selection) {
  12635. var cellRef = selection.getCellRef();
  12636. var ctxId = viewer.findCtx(cellRef);
  12637. var value = selection.getDisplayValues()[0];
  12638. window.setTimeout(function () { widget.getAnnotationHelper().addComment(ctxId, value); },0);
  12639. }
  12640. };/*
  12641. *+------------------------------------------------------------------------+
  12642. *| Licensed Materials - Property of IBM
  12643. *| IBM Cognos Products: Viewer
  12644. *| (C) Copyright IBM Corp. 2001, 2011
  12645. *|
  12646. *| US Government Users Restricted Rights - Use, duplication or
  12647. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12648. *|
  12649. *+------------------------------------------------------------------------+
  12650. */
  12651. function ExploreWithAAFAction() {}
  12652. ExploreWithAAFAction.prototype = new CognosViewerAction();
  12653. ExploreWithAAFAction.prototype.execute = function() {
  12654. window.open(this.m_oCV.getGateway() + this.m_oCV.envParams.aafBaseURL, "_blank");
  12655. };
  12656. /*
  12657. *+------------------------------------------------------------------------+
  12658. *| Licensed Materials - Property of IBM
  12659. *| IBM Cognos Products: Viewer
  12660. *| (C) Copyright IBM Corp. 2001, 2011
  12661. *|
  12662. *| US Government Users Restricted Rights - Use, duplication or
  12663. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12664. *|
  12665. *+------------------------------------------------------------------------+
  12666. */
  12667. function ViewActiveReportAction(){};
  12668. ViewActiveReportAction.prototype = new ViewSavedOutputAction();
  12669. ViewActiveReportAction.prototype.addAdditionalRequestParms = function(request) {
  12670. request.addFormField("cv.responseFormat", "CMRequest");
  12671. request.setCallbacks( {
  12672. "complete" : {"object" : this, "method" : this.handleQueryResponse}
  12673. });
  12674. };
  12675. ViewActiveReportAction.prototype.handleQueryResponse = function(response){
  12676. var viewerWidget = this.m_oCV.getViewerWidget();
  12677. viewerWidget.showLoading();
  12678. var xmlParsedCMresponse = XMLBuilderLoadXMLFromString(response.getResult());
  12679. var storeIDNode = XMLHelper_FindChildByTagName(xmlParsedCMresponse, "storeID", true);
  12680. var sStoreID = XMLHelper_GetText(XMLHelper_FindChildByTagName(storeIDNode, "value", true));
  12681. var activeReportIframe = dojo.byId(this.m_oCV.getViewerWidget().getIFrameId());
  12682. activeReportIframe.src = this.m_oCV.getGateway() + "/output/cm/" + sStoreID + "/";
  12683. };/*
  12684. *+------------------------------------------------------------------------+
  12685. *| Licensed Materials - Property of IBM
  12686. *| IBM Cognos Products: Viewer
  12687. *| (C) Copyright IBM Corp. 2001, 2011
  12688. *|
  12689. *| US Government Users Restricted Rights - Use, duplication or
  12690. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12691. *|
  12692. *+------------------------------------------------------------------------+
  12693. */
  12694. function RefreshActiveReportAction()
  12695. {
  12696. this.m_sAction = "RefreshActiveReport";
  12697. }
  12698. RefreshActiveReportAction.prototype = new CognosViewerAction();
  12699. RefreshActiveReportAction.prototype.execute = function()
  12700. {
  12701. var viewerWidget = this.m_oCV.getViewerWidget();
  12702. var activeReportIframe = dojo.byId(viewerWidget.getIFrameId());
  12703. var srcUrl = activeReportIframe.src;
  12704. activeReportIframe.src = srcUrl;
  12705. viewerWidget.showLoading();
  12706. };/*
  12707. *+------------------------------------------------------------------------+
  12708. *| Licensed Materials - Property of IBM
  12709. *| IBM Cognos Products: Viewer
  12710. *| (C) Copyright IBM Corp. 2001, 2013
  12711. *|
  12712. *| US Government Users Restricted Rights - Use, duplication or
  12713. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12714. *|
  12715. *+------------------------------------------------------------------------+
  12716. */
  12717. function ExportAction() {
  12718. this.m_format = "";
  12719. this.m_responseFormat = "";
  12720. }
  12721. ExportAction.prototype = new CognosViewerAction();
  12722. ExportAction.prototype.getWindowTitle = function() {
  12723. return "";
  12724. };
  12725. ExportAction.prototype.execute = function() {
  12726. if (!this.m_format) {
  12727. return false;
  12728. }
  12729. this.initializeForm();
  12730. this.insertGenericFormElements();
  12731. this.insertSpecializedFormElements();
  12732. return this.sendRequest();
  12733. };
  12734. ExportAction.prototype.addFormField = function(sName, sValue) {
  12735. if(console) {
  12736. console.log("Required method ExportAction.addFormField not implemented");
  12737. }
  12738. };
  12739. ExportAction.prototype.initializeForm = function() {
  12740. if(console) {
  12741. console.log("Required method ExportAction.initializeForm not implemented");
  12742. }
  12743. };
  12744. ExportAction.prototype.sendRequest = function() {
  12745. if(console) {
  12746. console.log("Required method ExportAction.sendRequest not implemented");;
  12747. }
  12748. };
  12749. ExportAction.prototype.insertGenericFormElements = function() {
  12750. var sRunPrompt = "false";
  12751. var bAction = 'cognosViewer';
  12752. this.addFormField("b_action", bAction);
  12753. this.addFormField("cv.toolbar", "false");
  12754. this.addFormField("cv.header", "false");
  12755. this.addFormField("ui.windowtitleformat", 'chromeless_window_action_format');
  12756. this.addFormField("ui.name", this.getObjectDisplayName());
  12757. this.addFormField("cv.responseFormat", this.m_responseFormat);
  12758. this.addFormField("ui.reuseWindow", "true");
  12759. var sUiSpec = this.m_oCV.envParams["ui.spec"]; // TODO: we may not need this when we move to one Tomcat environment
  12760. var sUiConversation = this.m_oCV.getConversation();
  12761. this.addFormField("ui.action", 'export');
  12762. this.addFormField("ui.conversation", sUiConversation);
  12763. this.addFormField("run.prompt", sRunPrompt);
  12764. this.addFormField('asynch.attachmentEncoding', 'base64');
  12765. this.addFormField("run.outputEncapsulation", 'URLQueryString');
  12766. this.addFormField("ui.spec", sUiSpec);
  12767. this.addFormField("rap.reportInfo", this.m_oCV.envParams["rapReportInfo"]);
  12768. if (this.m_oCV.envParams["ui.routingServerGroup"]) {
  12769. this.addFormField("ui.routingServerGroup", this.m_oCV.envParams["ui.routingServerGroup"]);
  12770. }
  12771. var viewerWidget = this.m_oCV.getViewerWidget();
  12772. if(viewerWidget != null) {
  12773. //Technically, this call could be asynchronous, however we assume that if
  12774. //the user is exporting a report, there's already a storeid.
  12775. dojo.when(viewerWidget.getWidgetStoreID(),
  12776. dojo.hitch(this, function(widgetStoreID) {
  12777. if(typeof widgetStoreID != "undefined" && widgetStoreID != null) {
  12778. this.addFormField('widgetStoreID', widgetStoreID);
  12779. }
  12780. })
  12781. );
  12782. var cvGateway = viewerWidget.getAttributeValue("gateway");
  12783. if(cvGateway) {
  12784. this.addFormField('cv.gateway', cvGateway);
  12785. }
  12786. var cvWebcontent = viewerWidget.getAttributeValue("webcontent");
  12787. if(cvWebcontent) {
  12788. this.addFormField('cv.webcontent', cvWebcontent);
  12789. }
  12790. }
  12791. this.addFormField("rap.parametersInfo", CViewerCommon.buildParameterValuesSpec(this.m_oCV));
  12792. };
  12793. ExportAction.prototype.insertSpecializedFormElements = function(request) {
  12794. this.addFormField("run.outputFormat", this.m_format);
  12795. this.addFormField("ui.windowtitleaction", this.getWindowTitle());
  12796. };
  12797. ExportAction.prototype.updateMenu = function(json) {
  12798. json.visible = !this.isPromptWidget();
  12799. if (this.m_oCV.isIWidgetMobile()) {
  12800. json.flatten = true;
  12801. }
  12802. return json;
  12803. };
  12804. function ExportFromIframeAction() {
  12805. this.m_format = "";
  12806. this.m_responseFormat = "downloadObject";
  12807. }
  12808. ExportFromIframeAction.prototype = new ExportAction();
  12809. ExportFromIframeAction.prototype.initializeForm = function() {
  12810. this.oRequest = new HiddenIframeDispatcherEntry(this.getCognosViewer());
  12811. this.addFormField("cv.detachRelease", "true");
  12812. };
  12813. ExportFromIframeAction.prototype.addFormField = function(sName, sValue) {
  12814. this.oRequest.addFormField(sName, sValue);
  12815. };
  12816. ExportFromIframeAction.prototype.sendRequest = function() {
  12817. this.getCognosViewer().dispatchRequest(this.oRequest);
  12818. return true;
  12819. };
  12820. /*
  12821. *+------------------------------------------------------------------------+
  12822. *| Licensed Materials - Property of IBM
  12823. *| IBM Cognos Products: Viewer
  12824. *| (C) Copyright IBM Corp. 2013
  12825. *|
  12826. *| US Government Users Restricted Rights - Use, duplication or
  12827. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12828. *|
  12829. *+------------------------------------------------------------------------+
  12830. */
  12831. function ExportToCSVAction()
  12832. {
  12833. this.m_format = "CSV";
  12834. }
  12835. ExportToCSVAction.prototype = new ExportFromIframeAction();
  12836. ExportToCSVAction.prototype.getWindowTitle = function()
  12837. {
  12838. return RV_RES.RV_CSV;
  12839. };
  12840. /*
  12841. *+------------------------------------------------------------------------+
  12842. *| Licensed Materials - Property of IBM
  12843. *| IBM Cognos Products: Viewer
  12844. *| (C) Copyright IBM Corp. 2013
  12845. *|
  12846. *| US Government Users Restricted Rights - Use, duplication or
  12847. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12848. *|
  12849. *+------------------------------------------------------------------------+
  12850. */
  12851. function ExportToExcel2000Action()
  12852. {
  12853. this.m_format = "XLS";
  12854. }
  12855. ExportToExcel2000Action.prototype = new ExportFromIframeAction();
  12856. ExportToExcel2000Action.prototype.getWindowTitle = function()
  12857. {
  12858. return RV_RES.RV_EXCEL_2000;
  12859. };
  12860. /*
  12861. *+------------------------------------------------------------------------+
  12862. *| Licensed Materials - Property of IBM
  12863. *| IBM Cognos Products: Viewer
  12864. *| (C) Copyright IBM Corp. 2001, 2013
  12865. *|
  12866. *| US Government Users Restricted Rights - Use, duplication or
  12867. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12868. *|
  12869. *+------------------------------------------------------------------------+
  12870. */
  12871. function ExportToExcel2002Action()
  12872. {
  12873. this.m_format = "XLWA";
  12874. }
  12875. ExportToExcel2002Action.prototype = new ExportFromIframeAction();
  12876. ExportToExcel2002Action.prototype.getWindowTitle = function()
  12877. {
  12878. return RV_RES.RV_EXCEL_2002;
  12879. };
  12880. /*
  12881. *+------------------------------------------------------------------------+
  12882. *| Licensed Materials - Property of IBM
  12883. *| IBM Cognos Products: Viewer
  12884. *| (C) Copyright IBM Corp. 2001, 2013
  12885. *|
  12886. *| US Government Users Restricted Rights - Use, duplication or
  12887. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12888. *|
  12889. *+------------------------------------------------------------------------+
  12890. */
  12891. function ExportToExcel2007Action()
  12892. {
  12893. this.m_format = "spreadsheetML";
  12894. }
  12895. ExportToExcel2007Action.prototype = new ExportFromIframeAction();
  12896. ExportToExcel2007Action.prototype.getWindowTitle = function()
  12897. {
  12898. return RV_RES.RV_EXCEL_2007;
  12899. };/*
  12900. *+------------------------------------------------------------------------+
  12901. *| Licensed Materials - Property of IBM
  12902. *| IBM Cognos Products: Viewer
  12903. *| (C) Copyright IBM Corp. 2012, 2013
  12904. *|
  12905. *| US Government Users Restricted Rights - Use, duplication or
  12906. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12907. *|
  12908. *+------------------------------------------------------------------------+
  12909. */
  12910. function ExportToExcel2007DataAction()
  12911. {
  12912. //this.m_format = "spreadsheetML";
  12913. this.m_format = "xlsxData";
  12914. }
  12915. ExportToExcel2007DataAction.prototype = new ExportFromIframeAction();
  12916. ExportToExcel2007DataAction.prototype.getWindowTitle = function()
  12917. {
  12918. return RV_RES.RV_EXCEL_2007_DATA;
  12919. };/*
  12920. *+------------------------------------------------------------------------+
  12921. *| Licensed Materials - Property of IBM
  12922. *| IBM Cognos Products: Viewer
  12923. *| (C) Copyright IBM Corp. 2013
  12924. *|
  12925. *| US Government Users Restricted Rights - Use, duplication or
  12926. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12927. *|
  12928. *+------------------------------------------------------------------------+
  12929. */
  12930. function ExportToExcelSingleSheetAction()
  12931. {
  12932. this.m_format = "singleXLS";
  12933. }
  12934. ExportToExcelSingleSheetAction.prototype = new ExportFromIframeAction();
  12935. ExportToExcelSingleSheetAction.prototype.getWindowTitle = function()
  12936. {
  12937. return RV_RES.RV_EXCEL_2000SF;
  12938. };/*
  12939. *+------------------------------------------------------------------------+
  12940. *| Licensed Materials - Property of IBM
  12941. *| IBM Cognos Products: Viewer
  12942. *| (C) Copyright IBM Corp. 2001, 2013
  12943. *|
  12944. *| US Government Users Restricted Rights - Use, duplication or
  12945. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12946. *|
  12947. *+------------------------------------------------------------------------+
  12948. */
  12949. function ExportToPDFAction()
  12950. {
  12951. this.m_format = "PDF";
  12952. }
  12953. ExportToPDFAction.prototype = new ExportFromIframeAction();
  12954. ExportToPDFAction.prototype.getWindowTitle = function()
  12955. {
  12956. return RV_RES.RV_PDF;
  12957. };
  12958. /*
  12959. *+------------------------------------------------------------------------+
  12960. *| Licensed Materials - Property of IBM
  12961. *| IBM Cognos Products: Viewer
  12962. *| (C) Copyright IBM Corp. 2013
  12963. *|
  12964. *| US Government Users Restricted Rights - Use, duplication or
  12965. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12966. *|
  12967. *+------------------------------------------------------------------------+
  12968. */
  12969. function ExportToXMLAction()
  12970. {
  12971. this.m_format = "XML";
  12972. }
  12973. ExportToXMLAction.prototype = new ExportFromIframeAction();
  12974. ExportToXMLAction.prototype.getWindowTitle = function()
  12975. {
  12976. return RV_RES.RV_XML;
  12977. };/*
  12978. *+------------------------------------------------------------------------+
  12979. *| Licensed Materials - Property of IBM
  12980. *| IBM Cognos Products: Viewer
  12981. *| (C) Copyright IBM Corp. 2001, 2013
  12982. *|
  12983. *| US Government Users Restricted Rights - Use, duplication or
  12984. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12985. *|
  12986. *+------------------------------------------------------------------------+
  12987. */
  12988. function PrintAsPDFAction() {
  12989. this.m_format = "PDF";
  12990. this.m_responseFormat = "page";
  12991. }
  12992. PrintAsPDFAction.prototype = new ExportAction();
  12993. PrintAsPDFAction.prototype.getWindowTitle = function() {
  12994. return RV_RES.IDS_PRINT_AS_PDF;
  12995. };
  12996. PrintAsPDFAction.prototype.initializeForm = function() {
  12997. this.nForm = document.createElement("form");
  12998. this.nForm.setAttribute("method", "post");
  12999. var sDispatcherURI = location.protocol +'//'+ location.host + this.m_oCV.m_sGateway;
  13000. this.nForm.setAttribute("action", sDispatcherURI);
  13001. };
  13002. PrintAsPDFAction.prototype.sendRequest = function() {
  13003. var viewerID = this.m_oCV.getId();
  13004. var sName = 'get' + this.m_format + viewerID;
  13005. this.nForm.setAttribute("id",sName);
  13006. this.nForm.setAttribute("name", sName);
  13007. this.nForm.setAttribute("target", this.m_format + 'Window' + viewerID);
  13008. document.body.appendChild(this.nForm);
  13009. var sWindowId = this.nForm.getAttribute("target");
  13010. window.open("",sWindowId,'resizable=yes,menubar=no,directories=no,location=no,status=no,toolbar=no,titlebar=no');
  13011. this.nForm.submit();
  13012. document.body.removeChild(this.nForm);
  13013. this.nForm = null;
  13014. return true;
  13015. };
  13016. PrintAsPDFAction.prototype.addFormField = function(sName, sValue) {
  13017. this.nForm.appendChild(createHiddenFormField(sName, sValue));
  13018. };/*
  13019. *+------------------------------------------------------------------------+
  13020. *| Licensed Materials - Property of IBM
  13021. *| IBM Cognos Products: Viewer
  13022. *| (C) Copyright IBM Corp. 2001, 2014
  13023. *|
  13024. *| US Government Users Restricted Rights - Use, duplication or
  13025. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13026. *|
  13027. *+------------------------------------------------------------------------+
  13028. */
  13029. function ExpandCollapseMemberAction()
  13030. {
  13031. this.m_sAction = "ExpandCollapseMember";
  13032. this.m_sExpandCollapseType=null;
  13033. this.m_RAPReportInfo = null;
  13034. this.m_itemInfo = null;
  13035. this.m_sPreviousDataItem = null;
  13036. }
  13037. ExpandCollapseMemberAction.prototype = new ModifyReportAction();
  13038. ExpandCollapseMemberAction.baseclass = ModifyReportAction.prototype;
  13039. ExpandCollapseMemberAction.prototype._getCanExpand = function(oSelectionObject)
  13040. {
  13041. var itemInfo = this._getItemInfo( oSelectionObject );
  13042. return ( itemInfo && itemInfo.canExpand );
  13043. };
  13044. ExpandCollapseMemberAction.prototype._isExpanded = function(oSelectionObject)
  13045. {
  13046. var sMUN = this._getSelectedMUN(oSelectionObject);
  13047. if( !sMUN )
  13048. {
  13049. return false;
  13050. }
  13051. var itemInfo = this._getItemInfo( oSelectionObject );
  13052. return ( itemInfo && itemInfo.expandedMembers && itemInfo.expandedMembers[sMUN] === true );
  13053. };
  13054. ExpandCollapseMemberAction.prototype._getSelectedMUN = function( oSelectionObject )
  13055. {
  13056. var sMun = null;
  13057. var aMuns = oSelectionObject.getMuns();
  13058. if (aMuns && aMuns.length>0 && aMuns[0].length>0) {
  13059. sMun = aMuns[0][0];
  13060. }
  13061. return sMun;
  13062. };
  13063. ExpandCollapseMemberAction.prototype._getDataItem = function( oSelectionObject )
  13064. {
  13065. if (!oSelectionObject) {
  13066. return null;
  13067. }
  13068. var sDataItemName = null;
  13069. var aDataItems = oSelectionObject.getDataItems();
  13070. if (aDataItems && aDataItems.length>0 && aDataItems[0].length>0) {
  13071. sDataItemName = aDataItems[0][0];
  13072. }
  13073. return sDataItemName;
  13074. };
  13075. ExpandCollapseMemberAction.prototype._getItemInfo = function(selObj)
  13076. {
  13077. var sDataItem= this._getDataItem(selObj);
  13078. if (!sDataItem ) {
  13079. return null;
  13080. }
  13081. var sContainerLID = this.removeNamespace( selObj.getLayoutElementId() );
  13082. this.m_RAPReportInfo = this.m_oCV.getRAPReportInfo();
  13083. this.m_itemInfo = this.m_RAPReportInfo.getItemInfo( sContainerLID, sDataItem );
  13084. this.m_sPreviousDataItem = sDataItem;
  13085. return this.m_itemInfo;
  13086. };
  13087. ExpandCollapseMemberAction.prototype._alwaysCanExpandCollapse = function(selObj)
  13088. {
  13089. var itemInfo = this._getItemInfo(selObj);
  13090. return ( itemInfo && itemInfo.alwaysCanExpandCollapse );
  13091. };
  13092. ExpandCollapseMemberAction.prototype._canShowMenu = function(oSectionController)
  13093. {
  13094. var selObj = this._getFirstSelectedObject(oSectionController);
  13095. return (selObj && this._hasMUN(selObj) && this._isCrosstab(selObj) && this._isOnEdge(selObj) && !oSectionController.areSelectionsMeasureOrCalculation());
  13096. };
  13097. ExpandCollapseMemberAction.prototype._getCtxId = function(selObj)
  13098. {
  13099. var cellRef = selObj.getCellRef();
  13100. if (cellRef && cellRef.getAttribute) {
  13101. var ctxValue = cellRef.getAttribute("ctx");
  13102. if (ctxValue) {
  13103. ctxValue = ctxValue.split("::")[0].split(":")[0];
  13104. return ctxValue;
  13105. }
  13106. }
  13107. return "";
  13108. };
  13109. ExpandCollapseMemberAction.prototype._hasMUN = function(selObj)
  13110. {
  13111. var aMuns = selObj.getMuns();
  13112. return aMuns.length>0 ? true : false;
  13113. };
  13114. ExpandCollapseMemberAction.prototype._isCrosstab = function(selObj)
  13115. {
  13116. return selObj.getDataContainerType() === 'crosstab' ? true : false;
  13117. };
  13118. ExpandCollapseMemberAction.prototype._isOnEdge = function(selObj)
  13119. {
  13120. return selObj.getLayoutType() === 'columnTitle' ? true : false;
  13121. };
  13122. ExpandCollapseMemberAction.prototype.keepRAPCache = function()
  13123. {
  13124. return false;
  13125. };
  13126. ExpandCollapseMemberAction.prototype.updateMenu = function(jsonSpec)
  13127. {
  13128. var oSectionController = this.m_oCV.getSelectionController();
  13129. jsonSpec.visible = this._canShowMenu(oSectionController);
  13130. if (! jsonSpec.visible)
  13131. {
  13132. return jsonSpec;
  13133. }
  13134. jsonSpec.disabled = !this._canEnableMenu(oSectionController);
  13135. return jsonSpec;
  13136. };
  13137. ExpandCollapseMemberAction.prototype._canEnableMenu = function(oSectionController) {return true;};
  13138. ExpandCollapseMemberAction.prototype._getFirstSelectedObject = function(oSectionController)
  13139. {
  13140. var selectedObjects = oSectionController.getAllSelectedObjects();
  13141. if (selectedObjects.length>0) {
  13142. return selectedObjects[0]; //use the first object
  13143. }
  13144. return null;
  13145. };
  13146. ExpandCollapseMemberAction.prototype._isSingleSelection = function(oSectionController)
  13147. {
  13148. var selectedObjects = oSectionController.getAllSelectedObjects();
  13149. return (selectedObjects.length === 1);
  13150. };
  13151. ExpandCollapseMemberAction.prototype.addActionContextAdditionalParms = function()
  13152. {
  13153. var oSelectionController = this.getCognosViewer().getSelectionController();
  13154. var selObj = this._getFirstSelectedObject(oSelectionController);
  13155. var sPUN = oSelectionController.getPun(this._getCtxId(selObj))
  13156. if( sPUN )
  13157. {
  13158. sPUN = "<PUN>" + sXmlEncode(sPUN) + "</PUN>";
  13159. }
  13160. var sType="";
  13161. if (this.m_sExpandCollapseType) {
  13162. //For now, ExpandMember or CollapseMember
  13163. sType = "<ExpandCollapseType>" + this.m_sExpandCollapseType + "</ExpandCollapseType>";
  13164. }
  13165. return this.getSelectedCellTags() + sPUN + sType;
  13166. };
  13167. /*
  13168. *+------------------------------------------------------------------------+
  13169. *| Licensed Materials - Property of IBM
  13170. *| IBM Cognos Products: Viewer
  13171. *| (C) Copyright IBM Corp. 2001, 2011
  13172. *|
  13173. *| US Government Users Restricted Rights - Use, duplication or
  13174. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13175. *|
  13176. *+------------------------------------------------------------------------+
  13177. */
  13178. function ExpandMemberAction()
  13179. {
  13180. this.m_sAction = "ExpandCollapseMember";
  13181. this.m_sExpandCollapseType="ExpandMember";
  13182. }
  13183. ExpandMemberAction.prototype = new ExpandCollapseMemberAction();
  13184. ExpandMemberAction.baseclass = ExpandCollapseMemberAction.prototype;
  13185. ExpandMemberAction.prototype.getUndoHint = function()
  13186. {
  13187. return RV_RES.IDS_JS_EXPAND_MEMBER;
  13188. };
  13189. ExpandMemberAction.prototype._canEnableMenu = function(oSectionController)
  13190. {
  13191. if (!this._isSingleSelection(oSectionController)) {
  13192. return false;
  13193. }
  13194. var selObj = this._getFirstSelectedObject(oSectionController);
  13195. if (this._alwaysCanExpandCollapse(selObj)) {
  13196. //Always enable both expand/collapse for hierarchy sets.
  13197. return true;
  13198. }
  13199. var ctxId = this._getCtxId(selObj);
  13200. var bCanDrillDown = true;
  13201. /**
  13202. *Use drillabiliy in metadata to safe guard the parent of nested single dimension
  13203. */
  13204. if( oSectionController.getDrillUpDownEnabled() === true){
  13205. bCanDrillDown = oSectionController.canDrillDown(ctxId);
  13206. }
  13207. return (bCanDrillDown && this._getCanExpand( selObj ) && !this._isExpanded(selObj) );
  13208. };
  13209. /*
  13210. *+------------------------------------------------------------------------+
  13211. *| Licensed Materials - Property of IBM
  13212. *| IBM Cognos Products: Viewer
  13213. *| (C) Copyright IBM Corp. 2001, 2011
  13214. *|
  13215. *| US Government Users Restricted Rights - Use, duplication or
  13216. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13217. *|
  13218. *+------------------------------------------------------------------------+
  13219. */
  13220. function CollapseMemberAction()
  13221. {
  13222. this.m_sAction = "ExpandCollapseMember";
  13223. this.m_sExpandCollapseType="CollapseMember";
  13224. }
  13225. CollapseMemberAction.prototype = new ExpandCollapseMemberAction();
  13226. CollapseMemberAction.baseclass = ExpandCollapseMemberAction.prototype;
  13227. CollapseMemberAction.prototype.getUndoHint = function()
  13228. {
  13229. return RV_RES.IDS_JS_COLLAPSE_MEMBER;
  13230. };
  13231. CollapseMemberAction.prototype._canDisableMenu = function(oSectionController)
  13232. {
  13233. if (this._isSingleSelection(oSectionController) && !this._isExpanded() ) {
  13234. return true;
  13235. }
  13236. return false;
  13237. };
  13238. CollapseMemberAction.prototype._canEnableMenu = function(oSectionController)
  13239. {
  13240. var selObj = this._getFirstSelectedObject(oSectionController);
  13241. if (this._alwaysCanExpandCollapse(selObj)) {
  13242. return true; //Expand/collapse cant be determined for complex sets...enable both items
  13243. }
  13244. return (this._isSingleSelection(oSectionController) && this._isExpanded(selObj));
  13245. };
  13246. /*
  13247. *+------------------------------------------------------------------------+
  13248. *| Licensed Materials - Property of IBM
  13249. *| IBM Cognos Products: Viewer
  13250. *| (C) Copyright IBM Corp. 2001, 2012
  13251. *|
  13252. *| US Government Users Restricted Rights - Use, duplication or
  13253. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13254. *|
  13255. *+------------------------------------------------------------------------+
  13256. */
  13257. /**
  13258. * This is the base class for generating request to re-run the report.
  13259. * Classes derived from this will add to it their specific options.
  13260. */
  13261. function OpenReportFromClipboardAction()
  13262. {
  13263. this.m_action = 'bux';
  13264. this.m_cv = this.getCognosViewer();
  13265. }
  13266. OpenReportFromClipboardAction.prototype = new CognosViewerAction();
  13267. OpenReportFromClipboardAction.prototype.reuseQuery =function() { return false; };
  13268. OpenReportFromClipboardAction.prototype.reuseGetParameter =function() { return false; };
  13269. OpenReportFromClipboardAction.prototype.keepRAPCache = function() {return false; };
  13270. OpenReportFromClipboardAction.prototype.reuseConversation = function() {return false; };
  13271. OpenReportFromClipboardAction.prototype.runReport = function() {return true;};
  13272. OpenReportFromClipboardAction.prototype.isUndoable = function() {return true; };
  13273. OpenReportFromClipboardAction.prototype.execute = function()
  13274. {
  13275. if( window.clipboardData )
  13276. {
  13277. this.openReportForIE();
  13278. }
  13279. else
  13280. {
  13281. this.openReportForNonIE();
  13282. }
  13283. };
  13284. OpenReportFromClipboardAction.prototype.openReportForNonIE = function()
  13285. {
  13286. var openReportFromClipboardActionObj = this;
  13287. var clipboardDialog = new viewer.dialogs.ClipboardDialog({
  13288. sTitle: RV_RES.IDS_JS_CLIPBOARD,
  13289. okHandler: function(reportSpec)
  13290. {
  13291. openReportFromClipboardActionObj.executeAction(reportSpec);
  13292. },
  13293. cancelHandler: function() {}
  13294. });
  13295. clipboardDialog.startup();
  13296. window.setTimeout(function () { clipboardDialog.show(); },0);
  13297. };
  13298. OpenReportFromClipboardAction.prototype.openReportForIE = function()
  13299. {
  13300. var reportSpec = window.clipboardData.getData( 'Text' );
  13301. this.executeAction( reportSpec );
  13302. };
  13303. OpenReportFromClipboardAction.prototype.getDeleteEnvParamsList = function()
  13304. {
  13305. var deleteEnvParamsList = [
  13306. 'modelPath',
  13307. 'packageBase',
  13308. 'rapReportInfo',
  13309. 'rap.state'
  13310. ];
  13311. return deleteEnvParamsList;
  13312. };
  13313. OpenReportFromClipboardAction.prototype.deleteEnvParams = function()
  13314. {
  13315. var envParams = this.m_cv.envParams;
  13316. var envParamsToBeDeleted = this.getDeleteEnvParamsList();
  13317. for( var index in envParamsToBeDeleted )
  13318. {
  13319. if( envParams[ envParamsToBeDeleted[index] ] )
  13320. {
  13321. delete envParams[ envParamsToBeDeleted[index] ];
  13322. }
  13323. }
  13324. };
  13325. /**
  13326. * Need to clean up CCognosViewer
  13327. */
  13328. OpenReportFromClipboardAction.prototype.cleanUpCognosViewer = function()
  13329. {
  13330. this.m_cv.setExecutionParameters( "" );
  13331. this.m_cv.setConversation( "" );
  13332. this.deleteEnvParams();
  13333. };
  13334. OpenReportFromClipboardAction.prototype.getRequestParams = function()
  13335. {
  13336. var requestParams = {
  13337. 'run.outputFormat' : 'HTML' ,
  13338. 'cv.id' : this.m_cv.getId(),
  13339. 'widget.reloadToolbar' : 'true',
  13340. 'openReportFromClipboard' : 'true',
  13341. 'ui.reportDrop' : 'true'
  13342. };
  13343. var globalPrompts = this.m_cv.getViewerWidget().getGlobalPromptsInfo();
  13344. if (globalPrompts != null ) {
  13345. requestParams[ 'widget.globalPromptInfo' ] = globalPrompts;
  13346. }
  13347. if( this.m_filters != "" )
  13348. {
  13349. requestParams["cv.updateDataFilters"] = this.m_filters;
  13350. }
  13351. var envParamsNames = [
  13352. 'cv.objectPermissions',
  13353. 'limitedInteractiveMode'
  13354. ];
  13355. for( var index in envParamsNames )
  13356. {
  13357. var envParamName = envParamsNames[index];
  13358. var envParamValue = this.m_cv.envParams[envParamName];
  13359. if( envParamValue )
  13360. {
  13361. requestParams[ envParamName ] = envParamValue;
  13362. }
  13363. }
  13364. return requestParams;
  13365. };
  13366. /**
  13367. * Overrides the base class function
  13368. */
  13369. OpenReportFromClipboardAction.prototype.addAdditionalOptions = function( cognosViewerRequest )
  13370. {
  13371. var options = this.getRequestParams();
  13372. for( var index in options ) {
  13373. cognosViewerRequest.addFormField( index, options[index] );
  13374. }
  13375. };
  13376. OpenReportFromClipboardAction.prototype.executeAction = function( reportSpec )
  13377. {
  13378. this.m_cv = this.getCognosViewer();
  13379. this.m_cv.envParams["ui.spec"] = reportSpec;
  13380. this.gatherFilterInfoBeforeAction("OpenReportFromClipboard");
  13381. ChangePaletteAction.reset(this.getCognosViewer());
  13382. }
  13383. OpenReportFromClipboardAction.prototype.dispatchRequest = function( filters )
  13384. {
  13385. this.m_cv = this.getCognosViewer();
  13386. var widget = this.m_cv.getViewerWidget();
  13387. widget.reset();
  13388. this.m_filters = filters;
  13389. this.cleanUpCognosViewer();
  13390. var cognosViewerRequest = this.createCognosViewerDispatcherEntry( this.m_action );
  13391. this.m_cv.hideReportInfo();
  13392. this.m_cv.dispatchRequest( cognosViewerRequest );
  13393. //fire the modified event
  13394. this.fireModifiedReportEvent();
  13395. };
  13396. OpenReportFromClipboardAction.prototype.doAddActionContext = function()
  13397. {
  13398. return false;
  13399. };
  13400. OpenReportFromClipboardAction.prototype.updateMenu = function(json)
  13401. {
  13402. json.visible = ( window.cognosViewerDebug === true );
  13403. return json;
  13404. };
  13405. /*
  13406. *+------------------------------------------------------------------------+
  13407. *| Licensed Materials - Property of IBM
  13408. *| IBM Cognos Products: Viewer
  13409. *| (C) Copyright IBM Corp. 2013
  13410. *|
  13411. *| US Government Users Restricted Rights - Use, duplication or
  13412. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13413. *|
  13414. *+------------------------------------------------------------------------+
  13415. */
  13416. /**
  13417. * This Action allows end user to save the report inside a report viewer widget
  13418. * to an stand alone Cognos Report Object outside of Cognos workspace
  13419. * */
  13420. function SaveAsReportAction(){
  13421. _progressDisplay = null;
  13422. };
  13423. SaveAsReportAction.prototype = new CognosViewerAction();
  13424. SaveAsReportAction.prototype.onSaveCallback = function(){
  13425. if (!this._progressDisplay) {
  13426. dojo["require"]("bux.dialogs.InformationDialog"); //@lazyload
  13427. this._progressDisplay = new bux.dialogs.Working(BUXMSG.CPN.IDS_CPN_SAVING);
  13428. this._progressDisplay.startup();
  13429. this._progressDisplay.show();
  13430. }
  13431. };
  13432. SaveAsReportAction.prototype.afterSaveCallback = function(){
  13433. if (this._progressDisplay) {
  13434. this._progressDisplay.destroy();
  13435. this._progressDisplay = null;
  13436. }
  13437. };
  13438. SaveAsReportAction.prototype.execute = function( ){
  13439. this.getCognosViewer().executeAction( 'RemoveAllDataFilter', { callback : {method: this.doSaveAs, object: this} } );
  13440. };
  13441. SaveAsReportAction.prototype.updateMenu = function(jsonSpec){
  13442. jsonSpec.visible = this.hasEnvUISpec();
  13443. return jsonSpec;
  13444. };
  13445. SaveAsReportAction.prototype.hasEnvUISpec = function(){
  13446. if(this.m_oCV){
  13447. var sSpec = this.m_oCV.envParams["ui.spec"];
  13448. return (sSpec && sSpec.length >0);
  13449. }
  13450. return false;
  13451. };
  13452. SaveAsReportAction.prototype.doSaveAs = function(strippedReportSpec){
  13453. dojo["require"]("bux.dialogs.FileDialog");
  13454. dojo["require"]("bux.iwidget.canvas.ReportIOHandler");
  13455. this.m_cv = this.getCognosViewer();
  13456. var sReportSpec = strippedReportSpec;
  13457. var sObjectClass = this.m_cv.envParams["ui.objectClass"];
  13458. var onCallback = this.onSaveCallback;
  13459. var afterCallback = this.afterSaveCallback;
  13460. var oSaveAsDlgParams = {
  13461. filter:"content-report", //Only returns report objects in the file dialog
  13462. title: RV_RES.IDS_JS_SAVE_AS_FDG_TITLE,
  13463. sMainActionButtonLabel: RV_RES.IDS_JS_OK,
  13464. "class": "bux-fileDialog"
  13465. };
  13466. var oIOHandler = new bux.iwidget.canvas.ReportIOHandler(sReportSpec, sObjectClass, onCallback, afterCallback, oSaveAsDlgParams);
  13467. oIOHandler._doSaveAs();
  13468. };/*
  13469. *+------------------------------------------------------------------------+
  13470. *| Licensed Materials - Property of IBM
  13471. *| IBM Cognos Products: Viewer
  13472. *| (C) Copyright IBM Corp. 2001, 2012
  13473. *|
  13474. *| US Government Users Restricted Rights - Use, duplication or
  13475. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13476. *|
  13477. *+------------------------------------------------------------------------+
  13478. */
  13479. function BusinessProcessAction() {};
  13480. BusinessProcessAction.prototype = new CognosViewerAction();
  13481. BusinessProcessAction.prototype.updateMenu = function( jsonSpec ) {
  13482. var sBpmRestURI = this.getCognosViewer().envParams['bpmRestURI'];
  13483. jsonSpec.visible = ( sBpmRestURI ? true : false );
  13484. if(jsonSpec.visible) {
  13485. jsonSpec.disabled = !this._hasAnyContextInSelectedObjects();
  13486. }
  13487. return jsonSpec;
  13488. };
  13489. BusinessProcessAction.prototype._initBPMGateway = function() {
  13490. var cognosViewer = this.getCognosViewer();
  13491. this.m_BPMGateway = cognosViewer.envParams['bpmRestURI'];
  13492. var length = this.m_BPMGateway.length;
  13493. if( this.m_BPMGateway[length-1] !== '/') {
  13494. this.m_BPMGateway += '/';
  13495. }
  13496. };
  13497. BusinessProcessAction.prototype.execute = function() {
  13498. this._initBPMGateway();
  13499. var oProcesses = this._getBPMProcesses();
  13500. };
  13501. BusinessProcessAction.prototype._getBPMProcesses = function() {
  13502. var callbacks = {
  13503. complete : { object : this, method : this.handleGetBPMProcessSuccess },
  13504. fault : { object : this, method : this.handleGetBPMProcessFail }
  13505. };
  13506. var url = this.m_BPMGateway + 'exposed/process';
  13507. var request = this._createBPMServerRequest( 'GET', callbacks, url );
  13508. request.sendRequest();
  13509. };
  13510. BusinessProcessAction.prototype._createBPMServerRequest = function( action, callbacks, url, aFormFields ) {
  13511. var xmlHttpObj = new XmlHttpObject();
  13512. xmlHttpObj.init( action, this._rewriteURL(url) );
  13513. xmlHttpObj.setCallbacks( callbacks );
  13514. xmlHttpObj.setHeaders({ Accept : "application/json"} );
  13515. if( aFormFields ) {
  13516. for( var i in aFormFields ){
  13517. xmlHttpObj.addFormField(aFormFields[i].name, aFormFields[i].value);
  13518. }
  13519. }
  13520. return xmlHttpObj;
  13521. };
  13522. BusinessProcessAction.prototype._rewriteURL = function( url ) {
  13523. if( bux && bux.iwidget && bux.iwidget.canvas && bux.iwidget.canvas.Helper && bux.iwidget.canvas.Helper.rewriteUrl )
  13524. {
  13525. return bux.iwidget.canvas.Helper.rewriteUrl( url );
  13526. }
  13527. return url;
  13528. };
  13529. BusinessProcessAction.prototype.handleGetBPMProcessFail = function( serverResponse ) {
  13530. var sErrorMsg = RV_RES.IDS_JS_BUSINESS_PROCESS_GET_PROCESSES_FAIL_MSG;
  13531. var sErrorDetails = serverResponse.getResponseText();
  13532. this._showErrorMessage( sErrorMsg, sErrorDetails );
  13533. };
  13534. BusinessProcessAction.prototype.handleGetBPMProcessSuccess = function( serverResponse ) {
  13535. var response = serverResponse.getResponseText();
  13536. if( !response )
  13537. {
  13538. return;
  13539. }
  13540. var jsonResponse = dojo.fromJson( response );
  13541. var oBusinessProcessesInfo = this._getBusinessProcessesInfo( jsonResponse.data.exposedItemsList );
  13542. this._showDialog( oBusinessProcessesInfo );
  13543. };
  13544. BusinessProcessAction.prototype._getBusinessProcessesInfo = function( exposedItemsList ) {
  13545. if( !exposedItemsList ){
  13546. return;
  13547. }
  13548. var noOfItems = exposedItemsList.length;
  13549. var bpmProcessInfo = new Array();
  13550. var bmpProcessUniqueNamesMap = {};
  13551. for( var i = 0; i < noOfItems; i++ ) {
  13552. var sProcessDisplayName = exposedItemsList[i].display;
  13553. var sProcessItemID = exposedItemsList[i].itemID;
  13554. var sProcessAppID = exposedItemsList[i].processAppID;
  13555. if( sProcessDisplayName && !bmpProcessUniqueNamesMap[sProcessDisplayName] && sProcessItemID && sProcessAppID ) {
  13556. bmpProcessUniqueNamesMap[sProcessDisplayName] = true;
  13557. bpmProcessInfo.push( { sCaption : sProcessDisplayName,
  13558. sBPD_ID : sProcessItemID,
  13559. sProcessAppID : sProcessAppID } );
  13560. }
  13561. };
  13562. return bpmProcessInfo;
  13563. };
  13564. BusinessProcessAction.prototype._showDialog = function( oBPMProcessInfo ) {
  13565. var oBPAction = this;
  13566. var oSelectBusinessProcessDialog = new viewer.dialogs.SelectBusinessProcess( {
  13567. sTitle : RV_RES.IDS_JS_BUSINESS_PROCESS_SELECT_DIALOG_TITLE,
  13568. sLabel : RV_RES.IDS_JS_BUSINESS_PROCESS_SELECT_DIALOG_DESC,
  13569. okHandler : function() {},
  13570. cancelHandler : function() {},
  13571. BPMProcessesInfo : oBPMProcessInfo,
  13572. bpAction : oBPAction
  13573. });
  13574. oSelectBusinessProcessDialog.startup();
  13575. oSelectBusinessProcessDialog.show();
  13576. };
  13577. /**
  13578. * This function gets the selection context and generates the process input parameter
  13579. * (much like the drill thru parameters)
  13580. *
  13581. * Should be in the format:
  13582. * { CognosParameter : { ... } }
  13583. */
  13584. BusinessProcessAction.prototype.getInputParameter = function( bValueAsString ) {
  13585. var obj = null;
  13586. var cognosViewer = this.getCognosViewer();
  13587. var oSectionController = cognosViewer.getSelectionController();
  13588. var aJsonContexts = oSectionController.getSelectedObjectsJsonContext();
  13589. if (aJsonContexts) {
  13590. var value = aJsonContexts;
  13591. if( bValueAsString )
  13592. {
  13593. value = dojo.toJson( value );
  13594. }
  13595. obj = {"cognosParameter": value};
  13596. }
  13597. return obj;
  13598. }
  13599. BusinessProcessAction.prototype.startProcess = function( sBPD_Id, sProcessAppId, sProcessName ) {
  13600. var callbacks = {
  13601. customArguments: [ sProcessName ],
  13602. complete : { object : this, method : this.handleGetStartProcessSuccessResponse },
  13603. fault : { object : this, method : this.handleGetStartProcessFailResponse }
  13604. };
  13605. var url = this.m_BPMGateway + 'process';
  13606. var oFormFields = new Array();
  13607. oFormFields.push( {name : 'action', value : 'start'} );
  13608. oFormFields.push( {name : 'parts', value : 'data'} );
  13609. if( sBPD_Id ) {
  13610. oFormFields.push( {name : 'bpdId', value : sBPD_Id});
  13611. }
  13612. if( sProcessAppId ) {
  13613. oFormFields.push( {name : 'processAppId', value : sProcessAppId} );
  13614. }
  13615. var oParam = this.getInputParameter(true /*value as string */);
  13616. if( oParam ) {
  13617. oFormFields.push( {name : 'params', value : dojo.toJson(oParam) } );
  13618. }
  13619. var request = this._createBPMServerRequest( 'POST', callbacks, url, oFormFields );
  13620. request.sendRequest();
  13621. };
  13622. BusinessProcessAction.prototype.handleGetStartProcessSuccessResponse = function( serverResponse, sProcessName ) {
  13623. var response = serverResponse.getResponseText();
  13624. if( response ) {
  13625. var jsonResponse = dojo.fromJson( response );
  13626. if( jsonResponse.status === "200" ) {
  13627. var sMsg = CViewerCommon.getMessage(RV_RES.IDS_JS_BUSINESS_PROCESS_START_PROCESS_SUCCEED_MSG, sProcessName );
  13628. var oInfoMsgDialog = new ModalInfoMessageDialog({
  13629. sTitle : RV_RES.IDS_JS_BUSINESS_PROCESS_START_PROCESS_SUCCEED_MSG_TITLE,
  13630. sMessage : sMsg,
  13631. sDescription : RV_RES.IDS_JS_BUSINESS_PROCESS_START_PROCESS_SUCCEED_MSG_DETAIL
  13632. });
  13633. oInfoMsgDialog.show();
  13634. }
  13635. }
  13636. };
  13637. BusinessProcessAction.prototype.handleGetStartProcessFailResponse = function( serverResponse, sProcessName ) {
  13638. var response = serverResponse.getResponseXml();
  13639. if( response && response.documentElement )
  13640. {
  13641. this._handleXMLErrorResponse( response, sProcessName );
  13642. return;
  13643. }
  13644. var sErrorMsg = CViewerCommon.getMessage( RV_RES.IDS_JS_BUSINESS_PROCESS_START_PROCESS_FAILED_MSG, sProcessName );
  13645. var sErrorDetails = serverResponse.getResponseText();
  13646. try{
  13647. var jsonResponse = dojo.fromJson( sErrorDetails );
  13648. sErrorDetails = jsonResponse.Data.errorMessage;
  13649. } catch(err) {/*swallow exception*/}
  13650. this._showErrorMessage( sErrorMsg, sErrorDetails );
  13651. };
  13652. BusinessProcessAction.prototype._handleXMLErrorResponse = function( xmlError, sProcessName ) {
  13653. var eError = XMLHelper_FindChildrenByTagName( xmlError, "error" );
  13654. var sErrorMessage = "";
  13655. var sErrorDetails = "";
  13656. if( eError ) {
  13657. sErrorMessage = XMLHelper_FindChildrenByTagName( eError, "message" ).childNodes[0].nodeValue;
  13658. sErrorDetails = XMLHelper_FindChildrenByTagName( eError, "detail" ).childNodes[0].nodeValue;
  13659. }
  13660. else
  13661. {
  13662. sErrorMessage = CViewerCommon.getMessage( RV_RES.IDS_JS_BUSINESS_PROCESS_START_PROCESS_FAILED_MSG, sProcessName);
  13663. }
  13664. this._showErrorMessage( sErrorMessage, sErrorDetails );
  13665. };
  13666. BusinessProcessAction.prototype._showErrorMessage = function( sErrorMsg, sErrorDetails ) {
  13667. var errorDialog = new ModalFaultMessageDialog( sErrorMsg, sErrorDetails );
  13668. errorDialog.show();
  13669. };
  13670. BusinessProcessAction.prototype._hasAnyContextInSelectedObjects = function() {
  13671. var foundCtx = false;
  13672. var oSectionController = this.m_oCV.getSelectionController();
  13673. var aSelectedObjects = oSectionController.getAllSelectedObjects();
  13674. for( var i=0; i<aSelectedObjects.length; i++) {
  13675. var aCtxIds = aSelectedObjects[i].getSelectedContextIds();
  13676. if (aCtxIds && aCtxIds.length>0) {
  13677. foundCtx= true;
  13678. break;
  13679. }
  13680. }
  13681. return foundCtx;
  13682. };/*
  13683. *+------------------------------------------------------------------------+
  13684. *| Licensed Materials - Property of IBM
  13685. *| IBM Cognos Products: Viewer
  13686. *| (C) Copyright IBM Corp. 2001, 2012
  13687. *|
  13688. *| US Government Users Restricted Rights - Use, duplication or
  13689. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13690. *|
  13691. *+------------------------------------------------------------------------+
  13692. */
  13693. function DrillResetAction(){
  13694. this.m_sAction = "DrillDown";
  13695. this.m_sharePromptValues = null;
  13696. this.m_aDrilledResetHUNs = null;
  13697. this.m_updateInfoBar = true;
  13698. };
  13699. DrillResetAction.prototype = new ModifyReportAction();
  13700. DrillResetAction.prototype.setRequestParms = function(params) {
  13701. this.m_aDrilledResetHUNs = params.drilledResetHUNs;
  13702. this.m_sharePromptValues = params.promptValues;
  13703. };
  13704. DrillResetAction.prototype.addAdditionalOptions = function( oReq ) {
  13705. if( !this.m_oCV ) { return; }
  13706. if( !this.m_sharePromptValues ){
  13707. /**
  13708. * The format of prompt values from prompt control is different from that of the
  13709. * share prompt event, therefore, need to prepare it differently
  13710. */
  13711. this.m_oCV.preparePromptValues( oReq );
  13712. oReq.getRequestHandler().setForceRaiseSharePrompt(true);
  13713. }else{
  13714. if( !this.m_sharePromptValues ){
  13715. return;
  13716. }
  13717. for (var promptValue in this.m_sharePromptValues){
  13718. oReq.addFormField( promptValue, this.m_sharePromptValues[promptValue] );
  13719. }
  13720. }
  13721. };
  13722. DrillResetAction.prototype.addActionContextAdditionalParms = function(){
  13723. var additionalContext = '<HUNS>';
  13724. for( var i = 0; i < this.m_aDrilledResetHUNs.length ; i++ ){
  13725. additionalContext += '<HUN>' + xml_encode( this.m_aDrilledResetHUNs[i] ) +'</HUN>';
  13726. }
  13727. additionalContext += '</HUNS>';
  13728. additionalContext += '<action>resetDimension</action>';
  13729. return additionalContext;
  13730. };
  13731. DrillResetAction.prototype.setUpdateInfoBar = function( bUpdate ){
  13732. this.m_updateInfoBar = bUpdate;
  13733. }
  13734. DrillResetAction.prototype.updateInfoBar = function() {
  13735. this.m_updateInfoBar;
  13736. };
  13737. /*
  13738. *+------------------------------------------------------------------------+
  13739. *| Licensed Materials - Property of IBM
  13740. *| IBM Cognos Products: Viewer
  13741. *| (C) Copyright IBM Corp. 2013
  13742. *|
  13743. *| US Government Users Restricted Rights - Use, duplication or
  13744. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13745. *|
  13746. *+------------------------------------------------------------------------+
  13747. */
  13748. /**
  13749. * Removes all the dynamic filters (slider) from the report spec. This is for use with
  13750. * save new report in Cognos Connection. No state information should be updated with this
  13751. * call.
  13752. * @returns
  13753. */
  13754. function RemoveAllDataFilterAction()
  13755. {
  13756. this.m_sAction = "UpdateDataFilter";
  13757. };
  13758. RemoveAllDataFilterAction.prototype.setCognosViewer = function( oCV ){
  13759. this.m_oCV = oCV;
  13760. };
  13761. RemoveAllDataFilterAction.prototype.getCognosViewer = function( oCV ){
  13762. return this.m_oCV;
  13763. };
  13764. /**
  13765. * requestParms = { callback : { method : xxxx},
  13766. * { object : yyyy}
  13767. * }
  13768. */
  13769. RemoveAllDataFilterAction.prototype.setRequestParms= function( requestParms ){
  13770. if( !requestParms || !requestParms.callback){ return;}
  13771. this.m_callbackMethod = requestParms.callback.method;
  13772. this.m_callbackObject = requestParms.callback.object;
  13773. };
  13774. RemoveAllDataFilterAction.prototype.createJSONDispatcherEntry = function( requestType )
  13775. {
  13776. var oReq = new JSONDispatcherEntry(this.getCognosViewer());
  13777. oReq.addFormField("ui.action", requestType);
  13778. //add action context
  13779. var actionContext = this.addActionContext();
  13780. oReq.addFormField("cv.actionContext", actionContext);
  13781. if (window.gViewerLogger)
  13782. {
  13783. window.gViewerLogger.log('Action context', actionContext, "xml");
  13784. }
  13785. if(typeof this.m_oCV.envParams["ui.spec"] != "undefined")
  13786. {
  13787. oReq.addFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  13788. }
  13789. oReq.addFormField("bux", 'true');
  13790. return oReq;
  13791. };
  13792. RemoveAllDataFilterAction.prototype.addActionContext = function(){
  13793. var actionContext = "<reportActions";
  13794. var inlineValues = "";
  13795. actionContext += " run=\"false\"";
  13796. actionContext += ">";
  13797. actionContext += "<reportAction name=\"" + this.m_sAction + "\">";
  13798. var actionParms = "{ \"removeAll\" :\"true\"}";
  13799. actionContext += xml_encode(actionParms);
  13800. actionContext += "</reportAction>";
  13801. actionContext += "</reportActions>";
  13802. return actionContext;
  13803. };
  13804. RemoveAllDataFilterAction.prototype.executeCallback = function(reportSpec) {
  13805. var callbackFunc = GUtil.generateCallback(this.m_callbackMethod, [reportSpec], this.m_callbackObject);
  13806. callbackFunc();
  13807. };
  13808. RemoveAllDataFilterAction.prototype.handleServerResponse = function( serverResponse ) {
  13809. if( serverResponse && serverResponse.getJSONResponseObject() ){
  13810. this.executeCallback( serverResponse.getJSONResponseObject().reportSpec);
  13811. }
  13812. };
  13813. RemoveAllDataFilterAction.prototype.execute = function() {
  13814. var oCV = this.getCognosViewer();
  13815. if( !oCV.getRAPReportInfo().hasSlider() ){
  13816. this.executeCallback(oCV.envParams["ui.spec"]);
  13817. } else {
  13818. var cognosViewerRequest = this.createJSONDispatcherEntry( "modifyReport" );
  13819. cognosViewerRequest.setCallbacks({"complete":{"object":this, "method":this.handleServerResponse}});
  13820. oCV.dispatchRequest(cognosViewerRequest);
  13821. }
  13822. };/*
  13823. *+------------------------------------------------------------------------+
  13824. *| Licensed Materials - Property of IBM
  13825. *| IBM Cognos Products: Viewer
  13826. *| (C) Copyright IBM Corp. 2001, 2012
  13827. *|
  13828. *| US Government Users Restricted Rights - Use, duplication or
  13829. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13830. *|
  13831. *+------------------------------------------------------------------------+
  13832. */
  13833. /**
  13834. * Stub out the loadExtra method since we've just loaded the exta javacript file
  13835. */
  13836. CCognosViewer.prototype.loadExtra = function() {};/*
  13837. *+------------------------------------------------------------------------+
  13838. *| Licensed Materials - Property of IBM
  13839. *| IBM Cognos Products: Viewer
  13840. *| (C) Copyright IBM Corp. 2013
  13841. *|
  13842. *| US Government Users Restricted Rights - Use, duplication or
  13843. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13844. *|
  13845. *+------------------------------------------------------------------------+
  13846. */
  13847. function DrillContextMenuHelper() {}
  13848. /**
  13849. * Visualization support: (also can be used for charts if VIEWER_JS_ENABLE_DRILL_SUBMENU is set to "charts")
  13850. * This function either populates a drill submenu (see needsDrillSubMenu) or ensures jsonSpec is
  13851. * set properly for a simple Drill Down or Drill Up menu item. The submenu contains a "default"
  13852. * and a set of one or more individual pieces that a user can decide to drill on.
  13853. */
  13854. DrillContextMenuHelper.updateDrillMenuItems = function(jsonSpec, oCV, sAction)
  13855. {
  13856. //There will be a submenu only if conditions are met....
  13857. var subMenuItems = [];
  13858. if (DrillContextMenuHelper.needsDrillSubMenu(oCV)) {
  13859. var selectionController = oCV.getSelectionController();
  13860. var selectedObjects = selectionController.getAllSelectedObjects();
  13861. var selObj = selectedObjects[0];
  13862. //For intersections, add the "Default menu item"
  13863. if (selObj.getUseValues().length > 1 && typeof RV_RES != "undefined") {
  13864. var oDrillOnMenuItem = { name: sAction, label: RV_RES.RV_DRILL_DEFAULT, action: { name: sAction, payload: {} } };
  13865. subMenuItems.push(oDrillOnMenuItem);
  13866. }
  13867. //Add the innermost item. For intersections, add the innermost level of dim1 and dim2
  13868. var firstDim=(selObj.getUseValues().length>1) ? 1 : 0;
  13869. var lastDim=selObj.getUseValues().length-1;
  13870. lastDim=(lastDim>2) ? 2 : lastDim; //Never allow the last dim to process more than rows/columns
  13871. for (var iDim=firstDim; iDim<=lastDim; ++iDim) {
  13872. DrillContextMenuHelper.addSubMenuItem(sAction, subMenuItems, selObj, iDim, 0);
  13873. }
  13874. //Do nested levels (either dim0 for edges or dim1 and dim2 for intersections)
  13875. var bRenderedSeparator=false;
  13876. for (var iDim=firstDim; iDim<=lastDim; ++iDim) {
  13877. for (var iLevel=1; iLevel<selObj.getUseValues()[iDim].length; ++iLevel) {
  13878. if (bRenderedSeparator==false) {
  13879. subMenuItems.push({separator: true});
  13880. bRenderedSeparator=true; //If upper levels exist, render a separator.
  13881. }
  13882. DrillContextMenuHelper.addSubMenuItem(sAction, subMenuItems, selObj, iDim, iLevel);
  13883. }
  13884. }
  13885. }
  13886. DrillContextMenuHelper.completeDrillMenu(sAction, subMenuItems, jsonSpec);
  13887. };
  13888. /**
  13889. * Visualization support:
  13890. * Return true if a drill submenu needs to be shown under the Drill Up or Drill Down menu item.
  13891. *
  13892. * Rules: Show the submenu:
  13893. * IF the number of dimensions OR the number of levels in the first dimension are > 1
  13894. * AND its a visualization OR its a chart and the VIEWER_JS_ENABLE_DRILL_SUBMENU advanced server property is set to "charts".
  13895. *
  13896. * NOTE: The Drill Up/Drill Down menu item won't be shown at all if the net drillability is determined to be 0.
  13897. *
  13898. * @return true if this is the case.
  13899. */
  13900. DrillContextMenuHelper.needsDrillSubMenu = function(oCV)
  13901. {
  13902. var selectionController = (oCV && oCV.getSelectionController());
  13903. if (selectionController) {
  13904. var selectedObjects = selectionController.getAllSelectedObjects();
  13905. if(selectedObjects.length == 1 && selectedObjects[0].isHomeCell && selectedObjects[0].isHomeCell() == false) {
  13906. var bDrillSubmenu = selectedObjects[0].isSelectionOnVizChart();
  13907. if (!bDrillSubmenu) {
  13908. var drillSubMenuType = oCV.getAdvancedServerProperty("VIEWER_JS_ENABLE_DRILL_SUBMENU");
  13909. bDrillSubmenu = (drillSubMenuType=="charts" && selectionController.hasSelectedChartNodes());
  13910. }
  13911. if (bDrillSubmenu) {
  13912. var selObj = selectedObjects[0];
  13913. return (bDrillSubmenu && selObj.getUseValues() && (selObj.getUseValues().length > 1 || selObj.getUseValues()[0].length > 1));
  13914. }
  13915. }
  13916. }
  13917. return false;
  13918. };
  13919. /**
  13920. * For the selected object at position iDim and iLevel, if that component of the selection is drillable,
  13921. * add an item to the submenu.
  13922. */
  13923. DrillContextMenuHelper.addSubMenuItem = function(sAction, subMenuItems, selObj, iDim, iLevel)
  13924. {
  13925. var drillOption = selObj.getDrillOptions()[iDim][iLevel];
  13926. if (DrillContextMenuHelper.isOptionDrillable(sAction, drillOption)) {
  13927. var sItemLabel = DrillContextMenuHelper.getItemValue(selObj, iDim, iLevel);
  13928. if (sItemLabel) {
  13929. var sDataItem = selObj.getDataItems()[iDim][iLevel];
  13930. var oDrillOnMenuItem = { name: sAction, label: sItemLabel, action: { name: sAction, payload: { userSelectedDrillItem: sDataItem } } };
  13931. subMenuItems.push(oDrillOnMenuItem);
  13932. }
  13933. }
  13934. };
  13935. /**
  13936. * If a submenu is required, add the items, otherwise ensure the basic action is defined.
  13937. */
  13938. DrillContextMenuHelper.completeDrillMenu = function(sAction, subMenuItems, jsonSpec)
  13939. {
  13940. if (subMenuItems.length > 0) {
  13941. jsonSpec.items = subMenuItems;
  13942. } else {
  13943. jsonSpec.items = null;
  13944. if (jsonSpec.action==null) {
  13945. jsonSpec.action = { name: sAction, action: { name: sAction } };
  13946. }
  13947. }
  13948. };
  13949. /**
  13950. * Return true if the drillFlag value is drillable for the current action (eg: DrillDown and 2,3,4; DrillUp and 1,3,4)
  13951. */
  13952. DrillContextMenuHelper.isOptionDrillable = function(sAction, drillFlag)
  13953. {
  13954. //0=none, 1=up, 2=down, 3=downorup, 4=upordown
  13955. return (drillFlag>=3 || (sAction=="DrillDown" && drillFlag==2) || (sAction=="DrillUp" && drillFlag==1));
  13956. };
  13957. /**
  13958. * Return the item value for the selected object...(usually the useValue of a label like "Camping Equipment")
  13959. */
  13960. DrillContextMenuHelper.getItemValue = function(selObj, iDim, iLevel)
  13961. {
  13962. var itemsLabel = (iLevel==0) ? selObj.getDisplayValues()[iDim] : null;
  13963. return ((itemsLabel) ? itemsLabel : selObj.getUseValues()[iDim][iLevel]);
  13964. };
  13965. /*
  13966. *+------------------------------------------------------------------------+
  13967. *| Licensed Materials - Property of IBM
  13968. *| IBM Cognos Products: Viewer
  13969. *| (C) Copyright IBM Corp. 2001, 2012
  13970. *|
  13971. *| US Government Users Restricted Rights - Use, duplication or
  13972. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13973. *|
  13974. *+------------------------------------------------------------------------+
  13975. */
  13976. dojo.provide("viewer.dialogs.ClipboardDialog");
  13977. dojo.require("bux.dialogs.BaseCustomContentDialog");
  13978. dojo.require("bux.layout.TableContainer");
  13979. dojo.require("dijit.form.Textarea");
  13980. dojo.require("dijit.form.Button");
  13981. dojo.declare("viewer.dialogs.ClipboardDialog", bux.dialogs.BaseCustomContentDialog, {
  13982. sTitle: null,
  13983. okHandler: null, /*Function?*/
  13984. cancelHandler:null, /*Function?*/
  13985. startup: function() {
  13986. this.updateTitle(this.sTitle);
  13987. this.inherited(arguments);
  13988. var tableContainer = new bux.layout.TableContainer({
  13989. // TODO remove this class
  13990. classname: "bux-InformationDialog"
  13991. },this.contentContainer);
  13992. var cell = null, row = null;
  13993. this._textField = new dijit.form.SimpleTextarea({
  13994. required:true,
  13995. rows: 10,
  13996. cols: 50,
  13997. style: 'width:auto'});
  13998. row = new bux.layout.TableContainerRow({
  13999. parentContainer: tableContainer
  14000. });
  14001. cell = new bux.layout.TableContainerCell({
  14002. classname: "bux-dialog-field",
  14003. parentContainer: row
  14004. });
  14005. cell.addContent(this._textField.domNode);
  14006. },
  14007. onOK : function()
  14008. {
  14009. if (this._textField.state != "Error")
  14010. {
  14011. this.inherited(arguments);
  14012. this.okHandler(this._textField.get("value"));
  14013. this.hide();
  14014. }
  14015. }
  14016. });
  14017. /*
  14018. *+------------------------------------------------------------------------+
  14019. *| Licensed Materials - Property of IBM
  14020. *| IBM Cognos Products: Viewer
  14021. *| (C) Copyright IBM Corp. 2001, 2011
  14022. *|
  14023. *| US Government Users Restricted Rights - Use, duplication or
  14024. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  14025. *|
  14026. *+------------------------------------------------------------------------+
  14027. */
  14028. dojo.provide( "bux.reportViewer.chart");
  14029. dojo.declare( "bux.reportViewer.chart", null,
  14030. {
  14031. m_displayTypeDialogDefinition: null,
  14032. constructor: function( )
  14033. {
  14034. this.initialize();
  14035. },
  14036. initialize: function()
  14037. {
  14038. if( this.m_displayTypeDialogDefinition !== null)
  14039. {
  14040. return;
  14041. }
  14042. this.m_displayTypeDialogDefinition = [
  14043. {
  14044. //label: "Table",
  14045. label: RV_RES.IDS_JS_CHART_TABLE,
  14046. image: "images/dialog/displayOptionsDialog/type_icons/table.gif",
  14047. options: [
  14048. {
  14049. label: RV_RES.IDS_JS_CHART_CROSSTAB,
  14050. Description: "",
  14051. image: "images/dialog/displayOptionsDialog/chart_thumbnails/crosstab_48.gif",
  14052. value: "crosstab"
  14053. },
  14054. {
  14055. label: RV_RES.IDS_JS_CHART_LIST_TABLE,
  14056. Description: "",
  14057. image: "images/dialog/displayOptionsDialog/chart_thumbnails/List_48.gif",
  14058. value: "list"
  14059. }
  14060. ]
  14061. },
  14062. {
  14063. label: RV_RES.IDS_JS_CHART_COLUMN,
  14064. image: "images/dialog/displayOptionsDialog/type_icons/column.gif",
  14065. options: [
  14066. {
  14067. label: RV_RES.IDS_JS_CHART_COLUMN,
  14068. Description: "",
  14069. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_clustered_flat.gif",
  14070. value: "column_clustered_flat"
  14071. },
  14072. {
  14073. //label: "Column with 3-D Visual Effect",
  14074. label: RV_RES.IDS_JS_CHART_COLUMN_3D,
  14075. Description: "",
  14076. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_clustered.gif",
  14077. value: "column_clustered"
  14078. },
  14079. {
  14080. //label: "Stacked Column",
  14081. label: RV_RES.IDS_JS_CHART_STACKED_COLUMN,
  14082. Description: "",
  14083. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_stacked_flat.gif",
  14084. value: "column_stacked_flat"
  14085. },
  14086. {
  14087. //label: "Stacked Column with 3-D Visual Effect",
  14088. label: RV_RES.IDS_JS_CHART_STACKED_COLUMN_3D,
  14089. Description: "",
  14090. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_stacked.gif",
  14091. value: "column_stacked"
  14092. },
  14093. {
  14094. //label: "100% Stacked Column",
  14095. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_COLUMN,
  14096. Description: "",
  14097. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_percent_flat.gif",
  14098. value: "column_percent_flat"
  14099. },
  14100. {
  14101. //label: "100% Stacked Column with 3-D Visual Effect",
  14102. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_COLUMN_3D,
  14103. Description: "",
  14104. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_percent.gif",
  14105. value: "column_percent"
  14106. },
  14107. {
  14108. //label: "3-D Axis Column",
  14109. label: RV_RES.IDS_JS_CHART_3D_AXIS_COLUMN,
  14110. Description: "",
  14111. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_column_3daxis.gif",
  14112. value: "column_3daxis"
  14113. },
  14114. {
  14115. label: RV_RES.IDS_JS_CHART_COLUMN,
  14116. Description: "",
  14117. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_column_rectangle_clustered.jpg",
  14118. value: "v2_column_rectangle_clustered"
  14119. },
  14120. {
  14121. //label: "Column with 3-D Visual Effect",
  14122. label: RV_RES.IDS_JS_CHART_COLUMN_3D,
  14123. Description: "",
  14124. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_column_box_clustered_depth.jpg",
  14125. value: "v2_column_box_clustered_depth"
  14126. },
  14127. {
  14128. //label: "Stacked Column",
  14129. label: RV_RES.IDS_JS_CHART_STACKED_COLUMN,
  14130. Description: "",
  14131. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_column_rectangle_stacked.jpg",
  14132. value: "v2_column_rectangle_stacked"
  14133. },
  14134. {
  14135. //label: "Stacked Column with 3-D Visual Effect",
  14136. label: RV_RES.IDS_JS_CHART_STACKED_COLUMN_3D,
  14137. Description: "",
  14138. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_column_box_stacked_depth.jpg",
  14139. value: "v2_column_box_stacked_depth"
  14140. },
  14141. {
  14142. //label: "100% Stacked Column",
  14143. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_COLUMN,
  14144. Description: "",
  14145. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_column_rectangle_percent.jpg",
  14146. value: "v2_column_rectangle_percent"
  14147. },
  14148. {
  14149. //label: "100% Stacked Column with 3-D Visual Effect",
  14150. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_COLUMN_3D,
  14151. Description: "",
  14152. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_column_box_percent_depth.jpg",
  14153. value: "v2_column_box_percent_depth"
  14154. }
  14155. ]
  14156. },
  14157. {
  14158. //label: "Bar",
  14159. label: RV_RES.IDS_JS_CHART_BAR,
  14160. image: "images/dialog/displayOptionsDialog/type_icons/bar.gif",
  14161. options: [
  14162. {
  14163. label: RV_RES.IDS_JS_CHART_BAR,
  14164. Description: "",
  14165. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bar_clustered_flat.gif",
  14166. value: "bar_clustered_flat"
  14167. },
  14168. {
  14169. //label: "Bar with 3-D Visual Effect",
  14170. label: RV_RES.IDS_JS_CHART_BAR_3D,
  14171. Description: "",
  14172. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bar_clustered.gif",
  14173. value: "bar_clustered"
  14174. },
  14175. {
  14176. //label: "Stacked Bar",
  14177. label: RV_RES.IDS_JS_CHART_STACKED_BAR,
  14178. Description: "",
  14179. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bar_stacked_flat.gif",
  14180. value: "bar_stacked_flat"
  14181. },
  14182. {
  14183. //label: "Stacked Bar with 3-D Visual Effect",
  14184. label: RV_RES.IDS_JS_CHART_STACKED_BAR_3D,
  14185. Description: "",
  14186. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bar_stacked.gif",
  14187. value: "bar_stacked"
  14188. },
  14189. {
  14190. //label: "100% Stacked Bar",
  14191. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_BAR,
  14192. Description: "",
  14193. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bar_percent_flat.gif",
  14194. value: "bar_percent_flat"
  14195. },
  14196. {
  14197. //label: "100% Stacked Bar with 3-D Visual Effect",
  14198. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_BAR_3D,
  14199. Description: "",
  14200. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bar_percent.gif",
  14201. value: "bar_percent"
  14202. },
  14203. {
  14204. label: RV_RES.IDS_JS_CHART_BAR,
  14205. Description: "",
  14206. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bar_rectangle_clustered.jpg",
  14207. value: "v2_bar_rectangle_clustered"
  14208. },
  14209. {
  14210. //label: "Bar with 3-D Visual Effect",
  14211. label: RV_RES.IDS_JS_CHART_BAR_3D,
  14212. Description: "",
  14213. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bar_box_clustered_depth.jpg",
  14214. value: "v2_bar_box_clustered_depth"
  14215. },
  14216. {
  14217. //label: "Stacked Bar",
  14218. label: RV_RES.IDS_JS_CHART_STACKED_BAR,
  14219. Description: "",
  14220. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bar_rectangle_stacked.jpg",
  14221. value: "v2_bar_rectangle_stacked"
  14222. },
  14223. {
  14224. //label: "Stacked Bar with 3-D Visual Effect",
  14225. label: RV_RES.IDS_JS_CHART_STACKED_BAR_3D,
  14226. Description: "",
  14227. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bar_box_stacked_depth.jpg",
  14228. value: "v2_bar_box_stacked_depth"
  14229. },
  14230. {
  14231. //label: "100% Stacked Bar",
  14232. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_BAR,
  14233. Description: "",
  14234. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bar_rectangle_percent.jpg",
  14235. value: "v2_bar_rectangle_percent"
  14236. },
  14237. {
  14238. //label: "100% Stacked Bar with 3-D Visual Effect",
  14239. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_BAR_3D,
  14240. Description: "",
  14241. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bar_box_percent_depth.jpg",
  14242. value: "v2_bar_box_percent_depth"
  14243. }
  14244. ]
  14245. },
  14246. {
  14247. //label: "Line",
  14248. label: RV_RES.IDS_JS_CHART_LINE,
  14249. image: "images/dialog/displayOptionsDialog/type_icons/line.gif",
  14250. options: [
  14251. {
  14252. //label: "Line with Markers",
  14253. label: RV_RES.IDS_JS_CHART_LINE_WITH_MARKERS,
  14254. Description: "",
  14255. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_clustered_flat_markers.gif",
  14256. value: "line_clustered_flat_markers"
  14257. },
  14258. {
  14259. //label: "Line",
  14260. label: RV_RES.IDS_JS_CHART_LINE,
  14261. Description: "",
  14262. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_clustered_flat.gif",
  14263. value: "line_clustered_flat"
  14264. },
  14265. {
  14266. //label: "Line with 3-D Visual Effect",
  14267. label: RV_RES.IDS_JS_CHART_LINE_3D,
  14268. Description: "",
  14269. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_clustered.gif",
  14270. value: "line_clustered"
  14271. },
  14272. {
  14273. //label: "Step Line with Markers",
  14274. label: RV_RES.IDS_JS_CHART_STEP_LINE_MARKERS,
  14275. Description: "",
  14276. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_stepAtPoint_clustered_flat_markers.gif",
  14277. value: "line_stepAtPoint_clustered_flat_markers"
  14278. },
  14279. {
  14280. //label: "Step Line",
  14281. label: RV_RES.IDS_JS_CHART_STEP_LINE,
  14282. Description: "",
  14283. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_stepAtPoint_clustered_flat.gif",
  14284. value: "line_stepAtPoint_clustered_flat"
  14285. },
  14286. {
  14287. //label: "Stacked Line with Markers",
  14288. label: RV_RES.IDS_JS_CHART_STACKED_LINE_MARKERS,
  14289. Description: "",
  14290. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_stacked_flat_markers.gif",
  14291. value: "line_stacked_flat_markers"
  14292. },
  14293. {
  14294. //label: "Stacked Line",
  14295. label: RV_RES.IDS_JS_CHART_STACKED_LINE,
  14296. Description: "",
  14297. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_stacked_flat.gif",
  14298. value: "line_stacked_flat"
  14299. },
  14300. {
  14301. //label: "Stacked Line with 3-D Visual Effect",
  14302. label: RV_RES.IDS_JS_CHART_STACKED_LINE_3D,
  14303. Description: "",
  14304. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_stacked.gif",
  14305. value: "line_stacked"
  14306. },
  14307. {
  14308. //label: "100% Stacked Line with Markers",
  14309. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_LINE_MARKERS,
  14310. Description: "",
  14311. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_percent_flat_markers.gif",
  14312. value: "line_percent_flat_markers"
  14313. },
  14314. {
  14315. //label: "100% Stacked Line",
  14316. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_LINE,
  14317. Description: "",
  14318. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_percent_flat.gif",
  14319. value: "line_percent_flat"
  14320. },
  14321. {
  14322. //label: "100% Stacked Line with 3-D Visual Effect",
  14323. label: RV_RES.IDS_JS_CHART_PERCENT_STACKED_LINE__3D,
  14324. Description: "",
  14325. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_percent.gif",
  14326. value: "line_percent"
  14327. },
  14328. {
  14329. //label: "3-D Axis Line",
  14330. label: RV_RES.IDS_JS_CHART_3D_AXIS_LINE,
  14331. Description: "",
  14332. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_line_3daxis.gif",
  14333. value: "line_3daxis"
  14334. },
  14335. {
  14336. //label: "Line",
  14337. label: RV_RES.IDS_JS_CHART_LINE,
  14338. Description: "",
  14339. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_line_clustered.jpg",
  14340. value: "v2_line_clustered"
  14341. },
  14342. {
  14343. //label: "Line with 3-D Visual Effect",
  14344. label: RV_RES.IDS_JS_CHART_LINE_3D,
  14345. Description: "",
  14346. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_line_clustered_depth.jpg",
  14347. value: "v2_line_clustered_depth"
  14348. },
  14349. {
  14350. //label: "Line with Markers",
  14351. label: RV_RES.IDS_JS_CHART_LINE_WITH_MARKERS,
  14352. Description: "",
  14353. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_line_clustered_markers.jpg",
  14354. value: "v2_line_clustered_markers"
  14355. },
  14356. {
  14357. //label: "Line with 3-D Visual Effect Markers",
  14358. label: RV_RES.IDS_JS_CHART_LINE_WITH_3D_MARKERS,
  14359. Description: "",
  14360. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_line_clustered_3dmarkers.jpg",
  14361. value: "v2_line_clustered_3dmarkers"
  14362. },
  14363. {
  14364. //label: "Step Line",
  14365. label: RV_RES.IDS_JS_CHART_STEP_LINE,
  14366. Description: "",
  14367. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_stepped_line_at_points_clustered.jpg",
  14368. value: "v2_stepped_line_at_points_clustered"
  14369. },
  14370. {
  14371. //label: "Step Line with 3-D Visual Effect",
  14372. label: RV_RES.IDS_JS_CHART_STEP_LINE_3D,
  14373. Description: "",
  14374. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_stepped_line_at_points_clustered_depth.jpg",
  14375. value: "v2_stepped_line_at_points_clustered_depth"
  14376. }
  14377. ]
  14378. },
  14379. {
  14380. //label: "Pie, Donut",
  14381. label: RV_RES.IDS_JS_CHART_PIE_DONUT,
  14382. image: "images/dialog/displayOptionsDialog/type_icons/pie.gif",
  14383. options: [
  14384. {
  14385. //label: "Pie",
  14386. label: RV_RES.IDS_JS_CHART_PIE,
  14387. Description: "",
  14388. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_pie_flat.gif",
  14389. value: "pie_flat"
  14390. },
  14391. {
  14392. //label: "Donut",
  14393. label: RV_RES.IDS_JS_CHART_DONUT,
  14394. Description: "",
  14395. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_pie_flat_hole.gif",
  14396. value: "pie_flat_hole"
  14397. },
  14398. {
  14399. //label: "Pie with 3-D Visual Effect",
  14400. label: RV_RES.IDS_JS_CHART_PIE_3D,
  14401. Description: "",
  14402. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_pie.gif",
  14403. value: "pie"
  14404. },
  14405. {
  14406. //label: "Donut with 3-D Visual Effect",
  14407. label: RV_RES.IDS_JS_CHART_DONUT_3D,
  14408. Description: "",
  14409. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_pie_hole.gif",
  14410. value: "pie_hole"
  14411. },
  14412. {
  14413. //label: "Pie",
  14414. label: RV_RES.IDS_JS_CHART_PIE,
  14415. Description: "",
  14416. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_pie_flat.jpg",
  14417. value: "v2_pie"
  14418. },
  14419. {
  14420. //label: "Pie with 3-D Visual Effect",
  14421. label: RV_RES.IDS_JS_CHART_PIE_3D,
  14422. Description: "",
  14423. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_pie.jpg",
  14424. value: "v2_pie_depth_round"
  14425. },
  14426. {
  14427. //label: "Donut",
  14428. label: RV_RES.IDS_JS_CHART_DONUT,
  14429. Description: "",
  14430. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_pie_hole_flat.jpg",
  14431. value: "v2_donut"
  14432. },
  14433. {
  14434. //label: "Donut with 3-D Visual Effect",
  14435. label: RV_RES.IDS_JS_CHART_DONUT_3D,
  14436. Description: "",
  14437. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_pie_hole.jpg",
  14438. value: "v2_donut_depth_round"
  14439. }
  14440. ]
  14441. },
  14442. {
  14443. //label: "Area",
  14444. label: RV_RES.IDS_JS_CHART_AREA,
  14445. image: "images/dialog/displayOptionsDialog/type_icons/area.gif",
  14446. options: [
  14447. {
  14448. //label: "Area",
  14449. label: RV_RES.IDS_JS_CHART_AREA,
  14450. Description: "",
  14451. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_clustered_flat.gif",
  14452. value: "area_clustered_flat"
  14453. },
  14454. {
  14455. //label: "Area with 3-D Visual Effect",
  14456. label: RV_RES.IDS_JS_CHART_AREA_3D,
  14457. Description: "",
  14458. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_clustered.gif",
  14459. value: "area_clustered"
  14460. },
  14461. {
  14462. //label: "Stacked Area",
  14463. label: RV_RES.IDS_JS_CHART_STACKED_AREA,
  14464. Description: "",
  14465. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_stacked_flat.gif",
  14466. value: "area_stacked_flat"
  14467. },
  14468. {
  14469. //label: "Stacked Area with 3-D Visual Effect",
  14470. label: RV_RES.IDS_JS_CHART_STACKED_AREA_3D,
  14471. Description: "",
  14472. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_stacked.gif",
  14473. value: "area_stacked"
  14474. },
  14475. {
  14476. //label: "100% Area",
  14477. label: RV_RES.IDS_JS_CHART_PERCENT_AREA,
  14478. Description: "",
  14479. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_percent_flat.gif",
  14480. value: "area_percent_flat"
  14481. },
  14482. {
  14483. //label: "100% Area with 3-D Visual Effect",
  14484. label: RV_RES.IDS_JS_CHART_PERCENT_AREA_3D,
  14485. Description: "",
  14486. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_percent.gif",
  14487. value: "area_percent"
  14488. },
  14489. {
  14490. //label: "3-D Axis Area",
  14491. label: RV_RES.IDS_JS_CHART_3D_AXIS_AREA,
  14492. Description: "",
  14493. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_area_3daxis.gif",
  14494. value: "area_3daxis"
  14495. },
  14496. {
  14497. //label: "Stacked Area",
  14498. label: RV_RES.IDS_JS_CHART_STACKED_AREA,
  14499. Description: "",
  14500. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_area_flat_point_to_point.gif",
  14501. value: "v2_area_stacked_flat"
  14502. },
  14503. {
  14504. //label: "Stacked Area with 3-D Visual Effect",
  14505. label: RV_RES.IDS_JS_CHART_STACKED_AREA_3D,
  14506. Description: "",
  14507. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_area_depth_point_to_point.gif",
  14508. value: "v2_area_stacked"
  14509. },
  14510. {
  14511. //label: "100% Area",
  14512. label: RV_RES.IDS_JS_CHART_PERCENT_AREA,
  14513. Description: "",
  14514. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_area_flat_percent_point_to_point.gif",
  14515. value: "v2_area_percent_flat"
  14516. },
  14517. {
  14518. //label: "100% Area with 3-D Visual Effect",
  14519. label: RV_RES.IDS_JS_CHART_PERCENT_AREA_3D,
  14520. Description: "",
  14521. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_area_depth_percent_point_to_point.gif",
  14522. value: "v2_area_percent"
  14523. }
  14524. ]
  14525. },
  14526. {
  14527. //label: "Scatter, Bubble, Point",
  14528. label: RV_RES.IDS_JS_CHART_SCATTER_BUBBLE_POINT,
  14529. image: "images/dialog/displayOptionsDialog/type_icons/scatter.gif",
  14530. options: [
  14531. {
  14532. //label: "Scatter",
  14533. label: RV_RES.IDS_JS_CHART_SCATTER,
  14534. Description: "",
  14535. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_scatter.gif",
  14536. value: "scatter"
  14537. },
  14538. {
  14539. //label: "Bubble",
  14540. label: RV_RES.IDS_JS_CHART_BUBBLE,
  14541. Description: "",
  14542. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bubble.gif",
  14543. value: "bubble"
  14544. },
  14545. {
  14546. //label: "Bubble with Excel Bubble Sizing",
  14547. label: RV_RES.IDS_JS_CHART_BUBBLE_WITH_EXCEL_BUBBLE_SIZING,
  14548. Description: "",
  14549. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_bubble_excel.gif",
  14550. value: "bubble_zeroBased"
  14551. },
  14552. {
  14553. //label: "Point",
  14554. label: RV_RES.IDS_JS_CHART_POINT,
  14555. Description: "",
  14556. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_point_clustered.gif",
  14557. value: "point_clustered"
  14558. },
  14559. {
  14560. //label: "3-D Scatter",
  14561. label: RV_RES.IDS_JS_CHART_3D_SCATTER,
  14562. Description: "",
  14563. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_scatter_3daxis.gif",
  14564. value: "scatter_3daxis"
  14565. },
  14566. {
  14567. //label: "Scatter",
  14568. label: RV_RES.IDS_JS_CHART_SCATTER,
  14569. Description: "",
  14570. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_scatter.gif",
  14571. value: "v2_scatter"
  14572. },
  14573. {
  14574. //label: "Bubble",
  14575. label: RV_RES.IDS_JS_CHART_BUBBLE,
  14576. Description: "",
  14577. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bubble.gif",
  14578. value: "v2_bubble"
  14579. },
  14580. {
  14581. //label: "Bubble with 3-D Visual Effect",
  14582. label: RV_RES.IDS_JS_CHART_BUBBLE_3D,
  14583. Description: "",
  14584. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_bubble_3dmarkers.gif",
  14585. value: "v2_bubble_3d"
  14586. },
  14587. {
  14588. //label: "Point",
  14589. label: RV_RES.IDS_JS_CHART_POINT,
  14590. Description: "",
  14591. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_point_clustered_markers.jpg",
  14592. value: "v2_point_clustered_markers"
  14593. },
  14594. {
  14595. //label: "Point with 3-D Markers",
  14596. label: RV_RES.IDS_JS_CHART_POINT_3D,
  14597. Description: "",
  14598. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_point_clustered_3dmarkers.jpg",
  14599. value: "v2_point_clustered_3dmarkers"
  14600. }
  14601. ]
  14602. },
  14603. {
  14604. //label: "Gauge",
  14605. label: RV_RES.IDS_JS_CHART_GAUGE,
  14606. image: "images/dialog/displayOptionsDialog/type_icons/gauge.gif",
  14607. options: [
  14608. {
  14609. //label: "Dial Gauge",
  14610. label: RV_RES.IDS_JS_CHART_DIAL_GAUGE,
  14611. Description: "",
  14612. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_gauge_dial.gif",
  14613. value: "gauge_dial"
  14614. },
  14615. {
  14616. //label: "Dial Gauge",
  14617. label: RV_RES.IDS_JS_CHART_DIAL_GAUGE,
  14618. Description: "",
  14619. image: "images/dialog/displayOptionsDialog/chart_thumbnails/type_v2_gauge.gif",
  14620. value: "v2_gauge"
  14621. }
  14622. ]
  14623. }
  14624. ];
  14625. },
  14626. getDisplayTypeDialogDefinition: function( targetTypes )
  14627. {
  14628. var newDialogDefinition = [];
  14629. for ( var j in this.m_displayTypeDialogDefinition )
  14630. {
  14631. var chartGroup = this.m_displayTypeDialogDefinition[j];
  14632. var newChartGroup = {};
  14633. newChartGroup.image = this.m_displayTypeDialogDefinition[j].image;
  14634. newChartGroup.label = this.m_displayTypeDialogDefinition[j].label;
  14635. newChartGroup.options = [];
  14636. var charts = chartGroup.options;
  14637. for( var k in charts)
  14638. {
  14639. var chart = charts[k];
  14640. for( var i in targetTypes)
  14641. {
  14642. var targetType = targetTypes[i];
  14643. if(chart.value === targetType )
  14644. {
  14645. var chartCopy = {
  14646. label : chart.label,
  14647. Description : chart.Description,
  14648. image : chart.image,
  14649. value : "{targetType:'" + chart.value + "', label:'" + chart.label + "'}"
  14650. };
  14651. newChartGroup.options.push( chartCopy );
  14652. }
  14653. }
  14654. }
  14655. if( newChartGroup.options.length > 0)
  14656. {
  14657. newDialogDefinition.push( newChartGroup );
  14658. }
  14659. }
  14660. return newDialogDefinition;
  14661. }
  14662. });/*
  14663. *+------------------------------------------------------------------------+
  14664. *| Licensed Materials - Property of IBM
  14665. *| IBM Cognos Products: Viewer
  14666. *| (C) Copyright IBM Corp. 2001, 2013
  14667. *|
  14668. *| US Government Users Restricted Rights - Use, duplication or
  14669. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  14670. *|
  14671. *+------------------------------------------------------------------------+
  14672. */
  14673. /**
  14674. * Class which knows what form fields are needed for the Action classes
  14675. * and info requests
  14676. * @param {Object} DispatcherEntry
  14677. */
  14678. function ActionFormFields(dispatcherEntry) {
  14679. this.m_dispatcherEntry = dispatcherEntry;
  14680. this.m_oCV = dispatcherEntry.getViewer();
  14681. }
  14682. ActionFormFields.prototype.addFormFields = function() {
  14683. var dispatcherEntry = this.m_dispatcherEntry;
  14684. var action = dispatcherEntry.getAction();
  14685. action.preProcess();
  14686. dispatcherEntry.addFormField("ui.action", "modifyReport");
  14687. if(this.m_oCV.getModelPath() !== "") {
  14688. dispatcherEntry.addFormField("modelPath", this.m_oCV.getModelPath());
  14689. if(typeof this.m_oCV.envParams["metaDataModelModificationTime"] != "undefined") {
  14690. dispatcherEntry.addFormField("metaDataModelModificationTime", this.m_oCV.envParams["metaDataModelModificationTime"]);
  14691. }
  14692. }
  14693. if( action.doAddActionContext() === true ) {
  14694. var actionContext = action.addActionContext();
  14695. dispatcherEntry.addFormField("cv.actionContext", actionContext);
  14696. if (window.gViewerLogger) {
  14697. window.gViewerLogger.log('Action context', actionContext, "xml");
  14698. }
  14699. }
  14700. var isBux = this.m_oCV.envParams["bux"] == "true";
  14701. if (isBux) {
  14702. dispatcherEntry.addFormField("cv.showFaultPage", "false");
  14703. }
  14704. else {
  14705. dispatcherEntry.addFormField("cv.showFaultPage", "true");
  14706. }
  14707. dispatcherEntry.addFormField("ui.object", this.m_oCV.envParams["ui.object"]);
  14708. dispatcherEntry.addDefinedFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  14709. dispatcherEntry.addDefinedFormField("modelPath", this.m_oCV.envParams["modelPath"]);
  14710. dispatcherEntry.addDefinedFormField("packageBase", this.m_oCV.envParams["packageBase"]);
  14711. dispatcherEntry.addDefinedFormField("rap.state", this.m_oCV.envParams["rap.state"]);
  14712. dispatcherEntry.addDefinedFormField("rap.reportInfo", this.m_oCV.envParams["rapReportInfo"]);
  14713. dispatcherEntry.addDefinedFormField("ui.primaryAction", this.m_oCV.envParams["ui.primaryAction"]);
  14714. dispatcherEntry.addNonNullFormField("cv.debugDirectory", this.m_oCV.envParams["cv.debugDirectory"]);
  14715. dispatcherEntry.addNonNullFormField("ui.objectClass", this.m_oCV.envParams["ui.objectClass"]);
  14716. dispatcherEntry.addNonNullFormField("bux", this.m_oCV.envParams["bux"]);
  14717. dispatcherEntry.addNonNullFormField("baseReportModificationTime", this.m_oCV.envParams["baseReportModificationTime"]);
  14718. dispatcherEntry.addNonNullFormField("originalReport", this.m_oCV.envParams["originalReport"]);
  14719. //Flash chart option
  14720. var flashChartOptionValue = this.m_oCV.getFlashChartOption();
  14721. if( flashChartOptionValue != null)
  14722. {
  14723. dispatcherEntry.addFormField("savedFlashChartOption", flashChartOptionValue);
  14724. if (flashChartOptionValue && action !=null && typeof(action.m_requestParams)!= "undefined" && typeof(action.m_requestParams.targetType)!= "undefined") {
  14725. var hasAVSChart = false;
  14726. var sTarget = null;
  14727. if (typeof(action.m_requestParams.targetType.targetType)!= "undefined") {
  14728. //fix for Defect:COGCQ00676339 Error generated on conversion of crosstab to chart, with chart animation enabled
  14729. //TargetType may be an Object type
  14730. sTarget = action.m_requestParams.targetType.targetType;
  14731. } else {
  14732. sTarget = action.m_requestParams.targetType;
  14733. }
  14734. if (sTarget.match('v2_') != null || sTarget.match('_v2') != null)
  14735. {
  14736. hasAVSChart = true;
  14737. }
  14738. else
  14739. {
  14740. var oRAPReportInfo = this.m_oCV.getRAPReportInfo();
  14741. var selectedReportInfo = action.getSelectedReportInfo();
  14742. if (oRAPReportInfo && selectedReportInfo) {
  14743. // get all the display types except for the currently selected container. We already checked
  14744. // the currently selected container in the about 'if' statement
  14745. var sDisplayTypes = oRAPReportInfo.getDisplayTypes(selectedReportInfo.container);
  14746. if (sDisplayTypes.match('v2_') != null || sDisplayTypes.match('_v2') != null) {
  14747. hasAVSChart = true;
  14748. }
  14749. }
  14750. }
  14751. dispatcherEntry.addFormField("hasAVSChart", hasAVSChart);
  14752. }
  14753. else
  14754. {
  14755. dispatcherEntry.addFormField("hasAVSChart", this.m_oCV.hasAVSChart());
  14756. }
  14757. }
  14758. var sEP = this.m_oCV.getExecutionParameters();
  14759. if (sEP) {
  14760. dispatcherEntry.addFormField("executionParameters", encodeURIComponent(sEP));
  14761. }
  14762. dispatcherEntry.addFormField("ui.conversation", encodeURIComponent(this.m_oCV.getConversation())); //MARK: needed? (its a primary request)
  14763. dispatcherEntry.addFormField("m_tracking", encodeURIComponent(this.m_oCV.getTracking())); //MARK: needed? (its a primary request)
  14764. var sCAF = this.m_oCV.getCAFContext();
  14765. if (sCAF) {
  14766. dispatcherEntry.addFormField("ui.cafcontextid", sCAF);
  14767. }
  14768. if (action.forceRunSpecRequest()) {
  14769. dispatcherEntry.addFormField("widget.forceRunSpec", "true");
  14770. }
  14771. };
  14772. /*
  14773. *+------------------------------------------------------------------------+
  14774. *| Licensed Materials - Property of IBM
  14775. *| IBM Cognos Products: Viewer
  14776. *| (C) Copyright IBM Corp. 2013
  14777. *|
  14778. *| US Government Users Restricted Rights - Use, duplication or
  14779. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  14780. *|
  14781. *+------------------------------------------------------------------------+
  14782. */
  14783. /**
  14784. * This class is used to make requests in a hidden iframe
  14785. */
  14786. HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX = "viewerHiddenRequest";
  14787. HiddenIframeDispatcherEntry.FORM_NAME = "viewerHiddenFormRequest";
  14788. function HiddenIframeDispatcherEntry(oCV) {
  14789. HiddenIframeDispatcherEntry.baseConstructor.call(this, oCV);
  14790. if (oCV) {
  14791. HiddenIframeDispatcherEntry.prototype.setDefaultFormFields.call(this);
  14792. this.setRequestHandler(new RequestHandler(oCV));
  14793. this.setWorkingDialog(oCV.getWorkingDialog());
  14794. this.setRequestIndicator(oCV.getRequestIndicator());
  14795. this.m_httpRequestConfig = oCV.getConfig() && oCV.getConfig().getHttpRequestConfig() ? oCV.getConfig().getHttpRequestConfig() : null;
  14796. this.setIframeId(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX + oCV.getId());
  14797. this.originalGetViewerConfiguration = null;
  14798. }
  14799. }
  14800. HiddenIframeDispatcherEntry.prototype = new DispatcherEntry();
  14801. HiddenIframeDispatcherEntry.baseConstructor = DispatcherEntry;
  14802. HiddenIframeDispatcherEntry.prototype.setDefaultFormFields = function() {
  14803. var oCV = this.getViewer();
  14804. var sCAF = oCV.getCAFContext();
  14805. this.addDefinedNonNullFormField("ui.cafcontextid", sCAF);
  14806. };
  14807. HiddenIframeDispatcherEntry.prototype.sendRequest = function() {
  14808. this._createHiddenIframe();
  14809. var form = this._createForm();
  14810. this._setupCallbacks();
  14811. this.onPreHttpRequest(this.getRequest());
  14812. form.submit();
  14813. };
  14814. /**
  14815. * Do any cleanup or callbacks once the iframe is finished running the request
  14816. */
  14817. HiddenIframeDispatcherEntry.prototype._iframeRequestComplete = function() {
  14818. window.getViewerConfiguration = this.originalGetViewerConfiguration;
  14819. this.onPostHttpRequest();
  14820. this.onEntryComplete();
  14821. };
  14822. /**
  14823. * Using our public callback mechanism setup callbacks for the hidden iframes
  14824. */
  14825. HiddenIframeDispatcherEntry.prototype._setupCallbacks = function() {
  14826. // Save the original getViewerConfiguration method if we have one
  14827. this.originalGetViewerConfiguration = window.getViewerConfiguration;
  14828. // We only need to setup these callbacks if we're using Ajax otherwise
  14829. // the iframes onload callback will be triggered and we'll get the status there
  14830. if (this.getFormField("cv.useAjax") != "false") {
  14831. var hiddenIframeDispatcherEntry = this;
  14832. var requestIndicator = this.getRequestHandler().getRequestIndicator();
  14833. var workingDialog = this.getRequestHandler().getWorkingDialog();
  14834. window.getViewerConfiguration = function() {
  14835. var configObj = {
  14836. "httpRequestCallbacks" : {
  14837. "reportStatus" : {
  14838. "complete" : function() { hiddenIframeDispatcherEntry.onComplete() },
  14839. "working" : function() { hiddenIframeDispatcherEntry.onWorking() },
  14840. "prompting" : function() { hiddenIframeDispatcherEntry.onPrompting() }
  14841. }
  14842. }
  14843. };
  14844. return configObj;
  14845. };
  14846. }
  14847. };
  14848. HiddenIframeDispatcherEntry.prototype.setIframeId = function(id) {
  14849. this._iframeId = id;
  14850. };
  14851. HiddenIframeDispatcherEntry.prototype.getIframeId = function() {
  14852. return this._iframeId;
  14853. };
  14854. /**
  14855. * Creates the form that will POST the request to the hidden iframe
  14856. */
  14857. HiddenIframeDispatcherEntry.prototype._createForm = function(params) {
  14858. var oCV = this.getViewer();
  14859. var formId = HiddenIframeDispatcherEntry.FORM_NAME + oCV.getId();
  14860. var requestForm = document.getElementById(formId);
  14861. if (requestForm) {
  14862. requestForm.parentNode.removeChild(requestForm);
  14863. requestForm = null;
  14864. }
  14865. var sDispatcherURI = location.protocol + '//' + location.host + oCV.m_sGateway;
  14866. requestForm = document.createElement("form");
  14867. requestForm.setAttribute("method","post");
  14868. requestForm.setAttribute("action", sDispatcherURI);
  14869. requestForm.setAttribute("target", this.getIframeId());
  14870. requestForm.setAttribute("id", formId);
  14871. requestForm.style.display = "none";
  14872. var formFields = this.getRequest().getFormFields();
  14873. var formFieldNames = formFields.keys();
  14874. for (var index = 0; index < formFieldNames.length; index++) {
  14875. requestForm.appendChild(createHiddenFormField(formFieldNames[index], formFields.get(formFieldNames[index])));
  14876. }
  14877. document.body.appendChild(requestForm);
  14878. return requestForm;
  14879. };
  14880. /**
  14881. * Creates the hidden iframe that will be used for the request
  14882. */
  14883. HiddenIframeDispatcherEntry.prototype._createHiddenIframe = function() {
  14884. var oCV = this.getViewer();
  14885. var iframeId = this.getIframeId();
  14886. var iframeElem = document.getElementById(iframeId);
  14887. if (iframeElem) {
  14888. iframeElem.parentNode.parentNode.removeChild(iframeElem.parentNode);
  14889. }
  14890. // There's a bug in IE where you can't post to an iframe if it's created dynamically,
  14891. // however if you append an iframe into a div using innerHTML then it work.
  14892. var div = document.createElement("div");
  14893. div.style.position = "absolute";
  14894. div.style.left="0px";
  14895. div.style.top="0px";
  14896. div.style.display = "none";
  14897. document.body.appendChild(div);
  14898. div.innerHTML = "<iframe frameborder=\"0\" id=\"" + iframeId + "\" name=\"" + iframeId + "\"></iframe>";
  14899. iframeElem = document.getElementById(iframeId);
  14900. // only set the onload after it's appended to the DOM or it will get triggered right away in certain browsers
  14901. var thisObj = this;
  14902. var func = function() {HiddenIframeDispatcherEntry.handleIframeLoad(thisObj);};
  14903. if(iframeElem.attachEvent) {
  14904. iframeElem.attachEvent("onload", func);
  14905. }
  14906. else {
  14907. iframeElem.addEventListener("load", func, true);
  14908. }
  14909. };
  14910. /**
  14911. * Hides the iframe. This gets called when we got a fault that we
  14912. * showed to the user and they hit the Ok button in the fault dialog.
  14913. */
  14914. HiddenIframeDispatcherEntry.hideIframe = function(cvId) {
  14915. var iframeElement = document.getElementById(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX + cvId);
  14916. if (iframeElement) {
  14917. iframeElement.parentNode.style.display = "none";
  14918. }
  14919. };
  14920. HiddenIframeDispatcherEntry.showIframeContentsInWindow = function(cvId) {
  14921. var iframeElement = document.getElementById(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX + cvId);
  14922. if (!iframeElement) {
  14923. return;
  14924. }
  14925. var html = iframeElement.contentWindow.document.getElementsByTagName('html')[0].innerHTML;
  14926. var htmlWindow = window.open("","",'height=400,width=500');
  14927. if(htmlWindow) {
  14928. htmlWindow.document.write("<html>" + html + "</html>");
  14929. }
  14930. };
  14931. /**
  14932. * Gets called when the iframe is loaded. Status can be complete, working, fault, ...
  14933. */
  14934. HiddenIframeDispatcherEntry.handleIframeLoad = function(dispatcherEntry) {
  14935. if (!dispatcherEntry) {
  14936. return;
  14937. }
  14938. var iframeElement = document.getElementById(dispatcherEntry.getIframeId());
  14939. if (!iframeElement) {
  14940. return;
  14941. }
  14942. var oCV = iframeElement.contentWindow.window.gaRV_INSTANCES ? iframeElement.contentWindow.window.gaRV_INSTANCES[0] : null;
  14943. var status = oCV ? oCV.getStatus() : null;
  14944. if (status == "complete") {
  14945. dispatcherEntry.onComplete();
  14946. }
  14947. if (status == "working") {
  14948. dispatcherEntry.onWorking();
  14949. }
  14950. if (status == "prompting") {
  14951. dispatcherEntry.onPrompting();
  14952. }
  14953. if (!oCV || status == "fault" || status == "") {
  14954. dispatcherEntry.onFault();
  14955. }
  14956. };
  14957. HiddenIframeDispatcherEntry.prototype.onFault = function() {
  14958. this._iframeRequestComplete();
  14959. HiddenIframeDispatcherEntry.showIframeContentsInWindow(this.getViewer().getId());
  14960. };
  14961. HiddenIframeDispatcherEntry.prototype.onPrompting = function() {
  14962. this._iframeRequestComplete();
  14963. if (this.m_httpRequestConfig) {
  14964. var callback = this.m_httpRequestConfig.getReportStatusCallback("prompting");
  14965. if (typeof callback == "function") {
  14966. callback();
  14967. }
  14968. }
  14969. HiddenIframeDispatcherEntry.showIframeContentsInWindow(this.getViewer().getId());
  14970. };
  14971. HiddenIframeDispatcherEntry.prototype.onComplete = function() {
  14972. this._iframeRequestComplete();
  14973. if (this.m_httpRequestConfig) {
  14974. var callback = this.m_httpRequestConfig.getReportStatusCallback("complete");
  14975. if (typeof callback == "function") {
  14976. callback();
  14977. }
  14978. }
  14979. var iframeElement = document.getElementById(this.getIframeId());
  14980. // We don't want the iframe to ever release the conversation, so unhook the leavingRV method.
  14981. if (typeof iframeElement.contentWindow.detachLeavingRV == "function") {
  14982. iframeElement.contentWindow.detachLeavingRV();
  14983. }
  14984. var divContainer = iframeElement.parentNode;
  14985. divContainer.style.display = "none";
  14986. if (this.getCallbacks() && this.getCallbacks()["complete"]) {
  14987. HiddenIframeDispatcherEntry.executeCallback(this.getCallbacks()["complete"]);
  14988. }
  14989. };
  14990. HiddenIframeDispatcherEntry.prototype.cancelRequest = function(forceSynchronous) {
  14991. this._iframeRequestComplete();
  14992. // guard against sending multiple cancel requests
  14993. if (!this.m_bCancelCalled) {
  14994. this.m_bCancelCalled = true;
  14995. var iframeElement = document.getElementById(this.getIframeId());
  14996. if (!iframeElement) {
  14997. return;
  14998. }
  14999. var oCV = iframeElement.contentWindow[getCognosViewerObjectString(this.getViewer().getId())];
  15000. if (oCV) {
  15001. oCV.cancel();
  15002. }
  15003. }
  15004. };
  15005. HiddenIframeDispatcherEntry.executeCallback = function(callback) {
  15006. if (callback) {
  15007. var callbackFunc = GUtil.generateCallback(callback.method, callback.params, callback.object);
  15008. callbackFunc();
  15009. }
  15010. };
  15011. HiddenIframeDispatcherEntry.getIframe = function(cvId) {
  15012. var iframe = document.getElementById(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX + cvId);
  15013. return iframe;
  15014. };/*
  15015. *+------------------------------------------------------------------------+
  15016. *| Licensed Materials - Property of IBM
  15017. *| IBM Cognos Products: Viewer
  15018. *| (C) Copyright IBM Corp. 2001, 2012
  15019. *|
  15020. *| US Government Users Restricted Rights - Use, duplication or
  15021. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  15022. *|
  15023. *+------------------------------------------------------------------------+
  15024. */
  15025. /*
  15026. *******************************************************************************
  15027. *** View DispatcherEntry.js for information on the dispatcher entry classes ***
  15028. *******************************************************************************
  15029. */
  15030. function ReportInfoDispatcherEntry(oCV)
  15031. {
  15032. ReportInfoDispatcherEntry.baseConstructor.call(this, oCV);
  15033. if (oCV) {
  15034. this.setCallbacks( {
  15035. "complete" : {"object" : this, "method" : this.onComplete },
  15036. "prompting": {"object": this, "method": this.onPrompting}
  15037. });
  15038. this.getRequestHandler().setFaultDialog(new ModalFaultDialog(oCV));
  15039. }
  15040. }
  15041. ReportInfoDispatcherEntry.prototype = new AsynchJSONDispatcherEntry();
  15042. ReportInfoDispatcherEntry.baseConstructor = AsynchJSONDispatcherEntry;
  15043. ReportInfoDispatcherEntry.prototype.initializeAction = function(action)
  15044. {
  15045. this.setKey(action.getActionKey());
  15046. this.setCanBeQueued(action.canBeQueued());
  15047. this.m_action = action;
  15048. };
  15049. ReportInfoDispatcherEntry.prototype.getAction = function() {
  15050. return this.m_action;
  15051. };
  15052. ReportInfoDispatcherEntry.prototype.prepareRequest = function()
  15053. {
  15054. var actionFormFields = new ActionFormFields(this);
  15055. actionFormFields.addFormFields();
  15056. };
  15057. ReportInfoDispatcherEntry.prototype.onComplete = function(asynchJSONResponse, arg1)
  15058. {
  15059. //The request for a single entry has completed...
  15060. if (this.m_oCV.getViewerDispatcher().queueIsEmpty()==true) {
  15061. var callbackFunction = this.m_action.getOnCompleteCallback();
  15062. callbackFunction(asynchJSONResponse);
  15063. }
  15064. };
  15065. ReportInfoDispatcherEntry.prototype.onPrompting = function(asynchJSONResponse, arg1)
  15066. {
  15067. var callbackFunction = this.m_action.getOnPromptingCallback();
  15068. callbackFunction(asynchJSONResponse);
  15069. };
  15070. ReportInfoDispatcherEntry.prototype.onPostEntryComplete = function()
  15071. {
  15072. var oCV = this.getViewer();
  15073. if (oCV && oCV.getViewerWidget()) {
  15074. var cvWidget = oCV.getViewerWidget();
  15075. cvWidget.getLoadManager().processQueue();
  15076. }
  15077. };/*
  15078. *+------------------------------------------------------------------------+
  15079. *| Licensed Materials - Property of IBM
  15080. *| IBM Cognos Products: Viewer
  15081. *| (C) Copyright IBM Corp. 2001, 2014
  15082. *|
  15083. *| US Government Users Restricted Rights - Use, duplication or
  15084. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  15085. *|
  15086. *+------------------------------------------------------------------------+
  15087. */
  15088. /*
  15089. *******************************************************************************
  15090. *** View DispatcherEntry.js for information on the dispatcher entry classes ***
  15091. *******************************************************************************
  15092. */
  15093. function ModifyReportDispatcherEntry(oCV)
  15094. {
  15095. ModifyReportDispatcherEntry.baseConstructor.call(this, oCV);
  15096. this.m_action = null;
  15097. if (oCV) {
  15098. this.m_viewerWidget = oCV.getViewerWidget();
  15099. this.setRequestHandler(new RequestHandler(oCV));
  15100. this.setWorkingDialog(oCV.getWorkingDialog());
  15101. this.setRequestIndicator(oCV.getRequestIndicator());
  15102. this.setCallbacks({
  15103. "complete" : {"object" : this, "method" : this.onComplete},
  15104. "prompting" : {"object" : this, "method" : this.onPrompting}
  15105. });
  15106. }
  15107. }
  15108. ModifyReportDispatcherEntry.prototype = new AsynchDataDispatcherEntry();
  15109. ModifyReportDispatcherEntry.baseConstructor = AsynchDataDispatcherEntry;
  15110. ModifyReportDispatcherEntry.prototype.parent = AsynchDataDispatcherEntry.prototype;
  15111. ModifyReportDispatcherEntry.prototype.initializeAction = function(action)
  15112. {
  15113. this.setKey(action.getActionKey());
  15114. this.setCanBeQueued(action.canBeQueued());
  15115. this.m_action = action;
  15116. };
  15117. ModifyReportDispatcherEntry.prototype.getAction = function() {
  15118. return this.m_action;
  15119. };
  15120. ModifyReportDispatcherEntry.prototype.prepareRequest = function()
  15121. {
  15122. if(this.m_viewerWidget){
  15123. DispatcherEntry.addWidgetInfoToFormFields(this.m_viewerWidget, this);
  15124. }
  15125. var actionFormFields = new ActionFormFields(this);
  15126. actionFormFields.addFormFields();
  15127. if (this.m_viewerWidget) {
  15128. this.addFormField("cv.id", this.m_viewerWidget.getViewerId());
  15129. }
  15130. this.addFormField("keepIterators", "true");
  15131. this.addFormField("run.prompt", this.m_action.getPromptOption());
  15132. if(this.m_action.reuseQuery() === true) {
  15133. this.addFormField("reuseResults", "true");
  15134. }
  15135. else if (this.m_action.reuseGetParameter() === true) {
  15136. this.addFormField("reuseResults", "paramInfo");
  15137. }
  15138. if(this.m_action.keepRAPCache() === false && this.m_viewerWidget) {
  15139. // delete the rap cache
  15140. this.m_viewerWidget.clearRAPCache();
  15141. }
  15142. if (this.m_action.reuseConversation() === true) {
  15143. this.addFormField("cv.reuseConversation", "true");
  15144. }
  15145. if (this.m_action.isUndoable() && this.m_action.getUndoRedoQueue()) {
  15146. this.m_action.getUndoRedoQueue().initUndoObj({"tooltip" : this.m_action.getUndoHint(), "saveSpec" : this.m_action.saveSpecForUndo()});
  15147. }
  15148. // So that we'll end up on the same tab
  15149. if (this.getViewer().getCurrentlySelectedTab() && !this.formFieldExists("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup")) {
  15150. this.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup", this.getViewer().getCurrentlySelectedTab());
  15151. }
  15152. this.getViewer().clearTabs();
  15153. };
  15154. ModifyReportDispatcherEntry.prototype.onComplete = function(asynchDATAResponse, arg1)
  15155. {
  15156. if (this.getRequestHandler()) {
  15157. this.getRequestHandler().onComplete(asynchDATAResponse);
  15158. }
  15159. };
  15160. ModifyReportDispatcherEntry.prototype.onPrompting = function(response) {
  15161. if (this.getRequestHandler()) {
  15162. this.getRequestHandler().onPrompting(response);
  15163. }
  15164. };
  15165. /**
  15166. * Need to update the Viewer state with any information we might have gotten in the working response
  15167. * @param {Object} asynchDATAResponse
  15168. * @param {Object} arg1
  15169. */
  15170. ModifyReportDispatcherEntry.prototype.onWorking = function(asynchDATAResponse, arg1)
  15171. {
  15172. this.parent.onWorking.call(this, asynchDATAResponse, arg1);
  15173. var responseState = asynchDATAResponse.getResponseState();
  15174. if (this.getRequestHandler()) {
  15175. this.getRequestHandler().updateViewerState(responseState);
  15176. }
  15177. };/*
  15178. *+------------------------------------------------------------------------+
  15179. *| Licensed Materials - Property of IBM
  15180. *| IBM Cognos Products: Viewer
  15181. *| (C) Copyright IBM Corp. 2001, 2012
  15182. *|
  15183. *| US Government Users Restricted Rights - Use, duplication or
  15184. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  15185. *|
  15186. *+------------------------------------------------------------------------+
  15187. */
  15188. dojo.provide("ModalInfoMessageDialog");
  15189. dojo.declare("ModalInfoMessageDialog", null, {
  15190. sMessage: "",
  15191. sDescription: "",
  15192. sTitle : "",
  15193. constructor : function( args){
  15194. dojo.safeMixin( this, args );
  15195. },
  15196. getMessage: function() {
  15197. return this.sMessage;
  15198. },
  15199. getDescription: function() {
  15200. return this.sDescription;
  15201. },
  15202. getTitle: function() {
  15203. return this.sTitle;
  15204. },
  15205. show : function() {
  15206. dojo["require"]("bux.dialogs.InformationDialog"); //@lazyload
  15207. var infoDialog = new bux.dialogs.InformationDialog({
  15208. title: this.getTitle(),
  15209. sMainMessage : this.getMessage(),
  15210. sDescription : this.getDescription(),
  15211. sInfoIconClass : 'bux-informationDialog-info-icon'
  15212. });
  15213. infoDialog.show();
  15214. }
  15215. });/*
  15216. *+------------------------------------------------------------------------+
  15217. *| Licensed Materials - Property of IBM
  15218. *| IBM Cognos Products: Viewer
  15219. *| (C) Copyright IBM Corp. 2001, 2011
  15220. *|
  15221. *| US Government Users Restricted Rights - Use, duplication or
  15222. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  15223. *|
  15224. *+------------------------------------------------------------------------+
  15225. */
  15226. function CCognosViewerSaveReport( cognosViewer, payload )
  15227. {
  15228. this.m_cognosViewer = cognosViewer;
  15229. this.m_params = null;
  15230. //chrome always send use the storeid of the dashboard to save report in so we know if it is save-as or save operation
  15231. this.dashboardToSaveIn = payload.cm$storeID;
  15232. this.m_doSaveAsOnFault = false;
  15233. }
  15234. /**
  15235. * Can save if the user has write permission, creating a new dashboard or we're doing a saveAs (also creating a 'new' dashboard)
  15236. * @param {Object} permission
  15237. */
  15238. CCognosViewerSaveReport.prototype.canSave = function( permission )
  15239. {
  15240. return ( this.doSaveAs() || permission && permission.indexOf( "write" ) !== -1 ) ;
  15241. };
  15242. CCognosViewerSaveReport.prototype.isSavedOutput = function()
  15243. {
  15244. //do not save if report is a saved output
  15245. var sAction = this.m_cognosViewer.envParams["ui.action"];
  15246. return ( typeof sAction !== "undefined" && sAction === "view");
  15247. };
  15248. /**
  15249. *
  15250. */
  15251. CCognosViewerSaveReport.prototype.doSaveAs = function()
  15252. {
  15253. //savedReportName is only set when report had been saved in the dashboard
  15254. var result = ( this.m_doSaveAsOnFault || !this.m_cognosViewer.envParams["savedReportName"] || !this.isSameDashboard() );
  15255. return result;
  15256. };
  15257. CCognosViewerSaveReport.prototype.isSameDashboard = function()
  15258. {
  15259. var result = ( this.m_cognosViewer.envParams["ui.object"].indexOf( this.dashboardToSaveIn ) !== -1 );
  15260. return result;
  15261. };
  15262. CCognosViewerSaveReport.prototype.getUIAction = function()
  15263. {
  15264. return ( this.doSaveAs() ? "saveInDashboard" : "updateSavedReport");
  15265. };
  15266. CCognosViewerSaveReport.prototype.populateRequestParams = function(asynchRequest) {
  15267. asynchRequest.addFormField('ui.action', this.getUIAction());
  15268. asynchRequest.addFormField('cv.ignoreState', 'true');
  15269. asynchRequest.addFormField("dashboard-id", this.dashboardToSaveIn);
  15270. asynchRequest.addNonEmptyStringFormField("executionParameters", this.m_cognosViewer.m_sParameters);
  15271. for(var param in this.m_cognosViewer.envParams)
  15272. {
  15273. if( param.indexOf("frag-") == 0 || param == "cv.actionState" ||
  15274. param == "ui.primaryAction" || param == "dashboard" ||
  15275. param == "ui.action" || param == "cv.responseFormat" ||
  15276. param == "b_action") {
  15277. continue;
  15278. }
  15279. asynchRequest.addFormField(param, this.m_cognosViewer.envParams[param]);
  15280. }
  15281. };
  15282. CCognosViewerSaveReport.prototype.getCognosViewer = function()
  15283. {
  15284. return this.m_cognosViewer;
  15285. };
  15286. CCognosViewerSaveReport.prototype.getViewerWidget = function()
  15287. {
  15288. return this.getCognosViewer().getViewerWidget();
  15289. };
  15290. CCognosViewerSaveReport.prototype.dispatchRequest = function()
  15291. {
  15292. var cognosViewer = this.m_cognosViewer;
  15293. var viewerWidget = this.getViewerWidget();
  15294. var callbacks = {
  15295. "complete":{"object":viewerWidget,"method":viewerWidget.handleWidgetSaveDone},
  15296. "fault":{"object":this,"method":this.onFault}
  15297. };
  15298. var asynchRequest = new AsynchJSONDispatcherEntry(cognosViewer);
  15299. asynchRequest.setCallbacks(callbacks);
  15300. this.populateRequestParams(asynchRequest);
  15301. cognosViewer.dispatchRequest(asynchRequest);
  15302. };
  15303. CCognosViewerSaveReport.prototype.onFault = function(asynchJSONResponse, arg1){
  15304. var cognosViewer = this.m_cognosViewer;
  15305. var viewerWidget = this.getViewerWidget();
  15306. var soapFaultEnvelope = asynchJSONResponse.getSoapFault();
  15307. var soapFaultNode = XMLHelper_FindChildByTagName(soapFaultEnvelope, "Fault", true);
  15308. if( this.ifIsEmptySelectionFault( soapFaultNode ) )
  15309. {
  15310. this.handleEmptySelectionFault();
  15311. return;
  15312. }
  15313. // set retry to False - can't retry a save
  15314. var retryNode = soapFaultEnvelope.createElement("allowRetry");
  15315. retryNode.appendChild(soapFaultEnvelope.createTextNode("false"));
  15316. soapFaultNode.appendChild(retryNode);
  15317. var sSoapFault = XMLBuilderSerializeNode(soapFaultNode);
  15318. cognosViewer.setSoapFault(sSoapFault);
  15319. viewerWidget.handleFault();
  15320. var saveDonePayload = {'status':false};
  15321. viewerWidget.iContext.iEvents.fireEvent( "com.ibm.bux.widget.save.done", null, saveDonePayload );
  15322. };
  15323. /**
  15324. * Returns true if the fault is caused by an attempt to update a non-existing report
  15325. */
  15326. CCognosViewerSaveReport.prototype.ifIsEmptySelectionFault = function( soapFault ){
  15327. if(soapFault) {
  15328. var errorCodeElement = XMLHelper_FindChildByTagName(soapFault, 'errorCode', true);
  15329. if( errorCodeElement )
  15330. {
  15331. var errorCode = XMLHelper_GetText(errorCodeElement, false);
  15332. return ( errorCode === 'cmEmptySelection' );
  15333. }
  15334. }
  15335. return false;
  15336. };
  15337. /**
  15338. * Sends a save-as request
  15339. */
  15340. CCognosViewerSaveReport.prototype.handleEmptySelectionFault = function(){
  15341. delete (this.m_cognosViewer.envParams["savedReportName"]);
  15342. this.m_doSaveAsOnFault = true;
  15343. this.dispatchRequest();
  15344. };
  15345. /*
  15346. *+------------------------------------------------------------------------+
  15347. *| Licensed Materials - Property of IBM
  15348. *| IBM Cognos Products: Viewer
  15349. *| (C) Copyright IBM Corp. 2001, 2013
  15350. *|
  15351. *| US Government Users Restricted Rights - Use, duplication or
  15352. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  15353. *|
  15354. *+------------------------------------------------------------------------+
  15355. */
  15356. SAVE_REPORT_TYPE = {
  15357. reportView : 'application/x-ibmcognos_v5reportview+xml',
  15358. report : 'application/x-ibmcognos_v5report+xml'
  15359. };
  15360. function ViewerIWidgetSave( viewerWidget, payload )
  15361. {
  15362. this.m_ViewerWidget = viewerWidget;
  15363. this.m_payload = payload;
  15364. this._setIsSavedDashboard();
  15365. }
  15366. ViewerIWidgetSave.prototype.setDoCWCopy = function(value) {
  15367. this._doCWCopy = value;
  15368. };
  15369. ViewerIWidgetSave.prototype._getSavedReport = function(){
  15370. var sSavedReport = this._getWidgetAttributeValue('savedReportPath') ;
  15371. if( !sSavedReport )
  15372. {
  15373. //for backwards compatibility
  15374. sSavedReport = this._getWidgetAttributeValue( 'savedReportName');
  15375. }
  15376. return sSavedReport;
  15377. };
  15378. /**
  15379. * Check if current dashboard is already saved
  15380. */
  15381. ViewerIWidgetSave.prototype._setIsSavedDashboard = function()
  15382. {
  15383. var sSavedReport = this._getSavedReport();
  15384. this._bIsSavedDashboard = ( sSavedReport !== null && sSavedReport !== undefined && sSavedReport.length !== 0) ;
  15385. };
  15386. ViewerIWidgetSave.prototype._isSavedDashboard = function(){
  15387. return this._bIsSavedDashboard;
  15388. };
  15389. /**
  15390. * Can save if the user has write permission, creating a new dashboard or we're doing a saveAs (also creating a 'new' dashboard)
  15391. * @param {Object} permission
  15392. */
  15393. ViewerIWidgetSave.prototype.canSave = function( permission )
  15394. {
  15395. //user is allowed to save in dashboard if they are doing a save new or save-as without write permission
  15396. return ( this._doSaveNewOrSaveAs() || permission && permission.indexOf( "write" ) !== -1 || this.m_ViewerWidget.isDropped() ) ;
  15397. };
  15398. ViewerIWidgetSave.prototype.isSavedOutput = function()
  15399. {
  15400. //do not save if report is a saved output
  15401. var sAction = this.m_cognosViewer.envParams["ui.action"];
  15402. return ( typeof sAction !== "undefined" && sAction === "view");
  15403. };
  15404. ViewerIWidgetSave.prototype._doSaveNewOrSaveAs = function(){
  15405. var result = ( this.m_payload.operation === 'save' && !this._isSavedDashboard() ) || ( this.m_payload.operation === 'saveAs');
  15406. return result;
  15407. };
  15408. ViewerIWidgetSave.prototype._getWidgetAttributeValue = function( attribName ){
  15409. return this._getViewerWidget().getAttributeValue( attribName );
  15410. };
  15411. ViewerIWidgetSave.prototype._getEnvParam = function( paramName ){
  15412. return this._getViewerWidget().getEnvParam( paramName );
  15413. };
  15414. ViewerIWidgetSave.prototype._getViewerWidget = function(){
  15415. return this.m_ViewerWidget;
  15416. };
  15417. ViewerIWidgetSave.prototype._isLimitedInteractiveMode = function(){
  15418. return this._getViewerWidget().isLimitedInteractiveMode();
  15419. };
  15420. ViewerIWidgetSave.prototype._getDefaultReportName = function(){
  15421. return this._getEnvParam( 'ui.name');
  15422. };
  15423. ViewerIWidgetSave.prototype._getReportSpec = function(){
  15424. return this._getEnvParam( 'ui.spec');
  15425. };
  15426. ViewerIWidgetSave.prototype._getCurrentReportIsReportView = function(){
  15427. return ( this._getEnvParam( 'ui.objectClass') === 'reportView' );
  15428. };
  15429. ViewerIWidgetSave.prototype.doGetSavePropertiesFromServer = function(){
  15430. this.delayedLoadingContext = this._getViewerWidget().getLoadManager().getDelayedLoadingContext();
  15431. if (this._getEnvParam( 'delayedLoadingExecutionParams')) {
  15432. return true;
  15433. }
  15434. return ( this.delayedLoadingContext && this.delayedLoadingContext.getPromptValues() !== null );
  15435. };
  15436. /**
  15437. * This function gets the information that is needed from the server in order to do the save.
  15438. * Currently, it sends the execution parameters to the server to get it in the proper syntax
  15439. * to be saved in CM.
  15440. */
  15441. ViewerIWidgetSave.prototype.getSavePropertiesFromServer = function(){
  15442. var oCV = this._getViewerWidget().getViewerObject();
  15443. var serverRequest = new JSONDispatcherEntry( oCV );
  15444. var widget = this._getViewerWidget();
  15445. //set the callback function
  15446. serverRequest.setCallbacks({
  15447. customArguments: [ this.m_payload ],
  15448. complete: {"object": widget, "method": widget.handleGetSavePropertiesFromServerResponse }
  15449. });
  15450. this._addRequestOptions(serverRequest);
  15451. serverRequest.sendRequest();
  15452. };
  15453. ViewerIWidgetSave.prototype._addRequestOptions = function(serverRequest)
  15454. {
  15455. serverRequest.addFormField("ui.action", "noOp" );
  15456. serverRequest.addFormField("bux", "true");
  15457. serverRequest.addFormField("cv.responseFormat", "IWidgetSavePropertiesJSON");
  15458. // delayedLoadingExecutionParams contains the saved prompt values that was obtained on the initial load of viewer widget but
  15459. // before the report is ran (which means no ui.conversation). This needs to be sent to the server so the saved prompt values can be merged with
  15460. // any new prompt values that is stored in the delayedLoadingContext before being saved. Otherwise, only global prompt values are save and
  15461. // caused the report to prompt next time, the tab is made visible.
  15462. if( this._getEnvParam( 'delayedLoadingExecutionParams') ){
  15463. serverRequest.addFormField("delayedLoadingExecutionParams", this._getEnvParam('delayedLoadingExecutionParams') );
  15464. }
  15465. else
  15466. {
  15467. // if there is no delayedLoadingExecutionParams, it means that the report had ran and there is conversation and it
  15468. // should be sent to the server so that the prompt values contained in it will be merged with the ones in delayedLoadingContext.
  15469. serverRequest.addFormField("ui.conversation", this._getViewerWidget().getViewerObject().getConversation() );
  15470. }
  15471. var promptValues = this.delayedLoadingContext.getPromptValues();
  15472. for( var promptValue in promptValues ){
  15473. serverRequest.addFormField( promptValue, promptValues[promptValue] )
  15474. }
  15475. };
  15476. ViewerIWidgetSave.prototype._getExecutionParameters = function(){
  15477. return this._getViewerWidget().getViewerObject().getExecutionParameters();
  15478. };
  15479. ViewerIWidgetSave.prototype._setExecutionParameters = function( body )
  15480. {
  15481. var sParameters = this._getExecutionParameters();
  15482. var doc = XMLBuilderLoadXMLFromString( sParameters );
  15483. if( !doc.documentElement )
  15484. {
  15485. return;
  15486. }
  15487. var root = XMLBuilderCreateXMLDocument ( 'root');
  15488. var eParameters = root.createElement( 'parameters' );
  15489. XMLBuilderSetAttributeNodeNS(eParameters, "xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
  15490. XMLBuilderSetAttributeNodeNS(eParameters, "xsi:type", "bus:parameterValueArrayProp", "http://www.w3.org/2001/XMLSchema-instance" );
  15491. XMLBuilderSetAttributeNodeNS(eParameters, "xmlns:bus", "http://developer.cognos.com/schemas/bibus/3/" );
  15492. XMLBuilderSetAttributeNodeNS(eParameters, "xmlns:xs", "http://www.w3.org/2001/XMLSchema" );
  15493. root.documentElement.appendChild(eParameters);
  15494. var allItems = XMLHelper_FindChildrenByTagName(doc.documentElement, 'item', false);
  15495. var eValue = root.createElement("value");
  15496. XMLBuilderSetAttributeNodeNS(eValue, "xsi:type", "SOAP-ENC:Array", "http://www.w3.org/2001/XMLSchema-instance");
  15497. eParameters.appendChild( eValue );
  15498. var iNumberOfParms = allItems.length;
  15499. for (var i = 0; i < allItems.length; i++) {
  15500. var eName = XMLHelper_FindChildByTagName(allItems[i], 'name', false);
  15501. if( eName && eName.childNodes[0].nodeValue.indexOf( 'credential:') !== -1 ){
  15502. iNumberOfParms--;
  15503. continue;
  15504. }
  15505. eValue.appendChild( allItems[i] );
  15506. }
  15507. XMLBuilderSetAttributeNodeNS(eValue, "SOAP-ENC:arrayType", "bus:parameterValue[" + iNumberOfParms + "]", "http://schemas.xmlsoap.org/soap/encoding/");
  15508. body.parameters = XMLBuilderSerializeNode( eParameters );
  15509. };
  15510. /**
  15511. * Sets the source report to be copied or base report for the report view
  15512. */
  15513. ViewerIWidgetSave.prototype._setSourceObject = function(resource, bUseCurrentReport) {
  15514. var sOriginalReportValue = (bUseCurrentReport === true)
  15515. ? this._getEnvParam('ui.object')
  15516. : this._getEnvParam('originalReport');
  15517. if (sOriginalReportValue) {
  15518. resource.sourceObject = sOriginalReportValue;
  15519. }
  15520. };
  15521. ViewerIWidgetSave.prototype._setReportTypeToReportView = function(resource) {
  15522. resource.type = SAVE_REPORT_TYPE.reportView;
  15523. };
  15524. ViewerIWidgetSave.prototype._setReportTypeToReport = function(resource) {
  15525. resource.type = SAVE_REPORT_TYPE.report;
  15526. };
  15527. ViewerIWidgetSave.prototype._setReportSpec = function( body ) {
  15528. body.specification = this._getReportSpec();
  15529. };
  15530. ViewerIWidgetSave.prototype._setResourceForSave = function(resource){
  15531. if( !this._getCurrentReportIsReportView() && !this._isLimitedInteractiveMode() ){
  15532. this._setReportSpec( resource.body );
  15533. this._setReportTypeToReport(resource);
  15534. }
  15535. return resource;
  15536. };
  15537. ViewerIWidgetSave.prototype._setResourceForCopy = function(resource){
  15538. this._setReportSpec( resource.body );
  15539. this._setReportTypeToReport(resource);
  15540. return resource;
  15541. };
  15542. ViewerIWidgetSave.prototype._setResourceForSaveNew = function(resource){
  15543. var bUseCurrentReport = false;
  15544. if (this._getEnvParam('originalReport') == null) {
  15545. //this is a special case for copy/pasted ci published widget
  15546. // when originalReport is null we use ui.object env. variable to set SourceObject
  15547. bUseCurrentReport = true;
  15548. }
  15549. this._setSourceObject( resource, bUseCurrentReport );
  15550. if( this._isLimitedInteractiveMode() )
  15551. {
  15552. this._setReportTypeToReportView( resource );
  15553. }else
  15554. {
  15555. this._setReportTypeToReport( resource );
  15556. this._setReportSpec(resource.body );
  15557. }
  15558. return resource;
  15559. };
  15560. ViewerIWidgetSave.prototype._setResourceForSaveAs = function( resource ){
  15561. if( this._getCurrentReportIsReportView() )
  15562. {
  15563. this._setReportTypeToReportView( resource );
  15564. this._setSourceObject( resource );
  15565. }
  15566. else if( this._isLimitedInteractiveMode() )
  15567. {
  15568. this._setReportTypeToReportView( resource );
  15569. this._setSourceObject( resource, true /*bUseCurrentReport*/ );
  15570. }
  15571. else
  15572. {
  15573. this._setReportTypeToReport( resource );
  15574. this._setSourceObject( resource, true /*bUseCurrentReport*/ );
  15575. this._setReportSpec( resource.body );
  15576. }
  15577. return resource;
  15578. };
  15579. ViewerIWidgetSave.prototype._getResource = function(){
  15580. var resource = {};
  15581. if (this._doCWCopy === true) {
  15582. resource.copyOnCreate = true;
  15583. }
  15584. resource.body = {};
  15585. var bDoSave = (this.m_payload.operation === 'save');
  15586. var bIsCopy = (this.m_payload.operation === 'copy');
  15587. if ( bIsCopy )
  15588. {
  15589. this._setResourceForCopy( resource );
  15590. }
  15591. else if( bDoSave)
  15592. {
  15593. this._setResourceForSave( resource );
  15594. }
  15595. else
  15596. {
  15597. if( this._isSavedDashboard() )
  15598. {
  15599. this._setResourceForSaveAs(resource);
  15600. }
  15601. else
  15602. {
  15603. this._setResourceForSaveNew(resource);
  15604. }
  15605. }
  15606. this._setExecutionParameters( resource.body );
  15607. if (!bIsCopy){
  15608. // list of itemSets for chrome to update after a save
  15609. resource.itemSetUpdate = { name: 'savedReportPath',
  15610. type: 'searchPath' };
  15611. }
  15612. return resource;
  15613. };
  15614. ViewerIWidgetSave.prototype._getWidgetId = function(){
  15615. return this._getViewerWidget().getWidgetId();
  15616. };
  15617. /**
  15618. * payload = {
  15619. * widgetId : <widget id>,
  15620. * resource : [
  15621. * {
  15622. * type : <report or report view>
  15623. * sourceObject : <source report to be cloned or saved as report view>
  15624. * body : { <list of cm properties to be updated> }
  15625. * itemSetUpdate : { <list of itemsets to be updated by BUX after a successful save }
  15626. * }
  15627. * ]
  15628. * }
  15629. *
  15630. * body = {
  15631. * specification : <optional - report spec if saving report>,
  15632. * parameters : <execution parameters>
  15633. * }
  15634. *
  15635. * itemSetUpdate = {
  15636. * name : 'savedReportPath',
  15637. * type : 'searchPath'
  15638. * }
  15639. */
  15640. ViewerIWidgetSave.prototype.getPayload = function(){
  15641. var payload = {};
  15642. payload.resource = new Array();
  15643. payload.widgetId = this._getWidgetId();
  15644. payload.resource.push( this._getResource() );
  15645. return payload;
  15646. };
  15647. /*
  15648. *+------------------------------------------------------------------------+
  15649. *| Licensed Materials - Property of IBM
  15650. *| IBM Cognos Products: Viewer
  15651. *| (C) Copyright IBM Corp. 2001, 2012
  15652. *|
  15653. *| US Government Users Restricted Rights - Use, duplication or
  15654. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  15655. *|
  15656. *+------------------------------------------------------------------------+
  15657. */
  15658. dojo.provide("viewer.dialogs.SelectBusinessProcess");
  15659. dojo.require("bux.dialogs.BaseCustomContentDialog");
  15660. dojo.require("bux.layout.TableContainer");
  15661. dojo.require("dijit.form.NumberTextBox");
  15662. dojo.require("dijit.form.Button");
  15663. dojo.declare( 'viewer.dialogs.SelectBusinessProcess', bux.dialogs.BaseCustomContentDialog, {
  15664. sTitle : null,
  15665. sLabel : null,
  15666. okHandler : null, /* function */
  15667. cancelHanlder : null, /* function */
  15668. buildRendering : function() {
  15669. this.aButtonsSpec = [
  15670. {label: RV_RES.IDS_JS_BUSINESS_PROCESS_SELECT_DIALOG_START_BUTTON_LABEL, action: dojo.hitch(this, this.onOK), type: "button"},
  15671. {label: RV_RES.CANCEL, action: dojo.hitch(this, this.onCancel), type: "button"}
  15672. ];
  15673. this.inherited( arguments );
  15674. if( !this.BPMProcessesInfo || this.BPMProcessesInfo.length === 0 ){
  15675. //Disable the start button
  15676. this._buxBaseDialog._aButtonObjects[0].set( 'disabled',true );
  15677. }
  15678. },
  15679. startup : function() {
  15680. this.updateTitle( this.sTitle );
  15681. this.inherited( arguments );
  15682. this.set( 'role', 'group');
  15683. var tableContainer = new bux.layout.TableContainer({
  15684. classname: "bux-InformationDialog buxFilterConfigDiscreteValuesTable"},
  15685. this.contentContainer );
  15686. var row = new bux.layout.TableContainerRow({
  15687. classname : "bux-dialog-label",
  15688. parentContainer : tableContainer
  15689. });
  15690. var cell = new bux.layout.TableContainerCell({
  15691. parentContainer : row
  15692. });
  15693. this.generateSelectProcessSection( cell );
  15694. cell.addContent( document.createElement( 'br' ) );
  15695. this.generateViewInputValuesSection( cell );
  15696. cell.addContent( document.createElement( 'br' ) );
  15697. },
  15698. addDivContainer : function( oParentContainer, sID, sRole ) {
  15699. var div = document.createElement( 'div');
  15700. dojo.attr( div, { 'class' : 'buxFilterConfigFilterValue',
  15701. 'aria-labelledby' : sID,
  15702. role : sRole
  15703. });
  15704. oParentContainer.addContent( div );
  15705. return div;
  15706. },
  15707. generateSelectProcessSection : function( oParentContainer ) {
  15708. var sA11yId = this.id + '_selectProcess_a11ylabel';
  15709. this.addTableDescription(oParentContainer, this.sLabel, sA11yId);
  15710. var div = this.addDivContainer( oParentContainer, sA11yId, 'radiogroup' );
  15711. var tableContainer = new bux.layout.TableContainer({
  15712. classname: 'buxFilterConfigFilterValueTable'
  15713. } );
  15714. dojo.style( tableContainer.domNode, 'width', '325px' );
  15715. this.addSelectProcessTableHeader( tableContainer );
  15716. if( !this.BPMProcessesInfo || this.BPMProcessesInfo.length === 0) {
  15717. this.addEmptySelectProcessTableContent( tableContainer );
  15718. }else{
  15719. this.addSelectProcessTableContent(tableContainer);
  15720. }
  15721. div.appendChild( tableContainer.domNode );
  15722. },
  15723. addSelectProcessTableHeader : function( tableContainer ) {
  15724. var table_header_row = new bux.layout.TableContainerRow({
  15725. classname : "buxFilterConfigFilterValueTableHeaderRow",
  15726. parentContainer : tableContainer
  15727. });
  15728. var table_header_cell_1 = new bux.layout.TableContainerCell({
  15729. classname : "buxListHeader buxFilterConfigFilterValueTableHeaderLeft",
  15730. width : '25px',
  15731. parentContainer : table_header_row
  15732. });
  15733. var table_header_cell_2 = new bux.layout.TableContainerCell({
  15734. classname : "buxListHeader buxFilterConfigFilterValueTableHeader",
  15735. width : '300px',
  15736. parentContainer : table_header_row
  15737. });
  15738. table_header_cell_2.addContent(document.createTextNode(RV_RES.IDS_JS_BUSINESS_PROCESS_SELECT_DIALOG_TABLE_HEADER));
  15739. },
  15740. /**
  15741. * Displays "None" in the table when no process is available to user
  15742. */
  15743. addEmptySelectProcessTableContent: function( tableContainer ) {
  15744. var sA11yLabelId = this.id + '_processItemsRow_label_none';
  15745. var row_process = new bux.layout.TableContainerRow({
  15746. parentContainer : tableContainer
  15747. });
  15748. dojo.attr( row_process.domNode, { id : this.id + '_processItemsRow_none',
  15749. 'aria-labelledby' : sA11yLabelId,
  15750. tabindex : 0
  15751. });
  15752. var a11yLabel = this.createA11yLabel(RV_RES.IDS_JS_BUSINESS_PROCESS_SELECT_DIALOG_NO_PROCESS_A11Y, sA11yLabelId, true /*hidden*/);
  15753. row_process.domNode.appendChild( a11yLabel );
  15754. var cell = new bux.layout.TableContainerCell({
  15755. parentContainer : row_process
  15756. });
  15757. cell.set( 'colspan', 2 );
  15758. cell.addContent( this.createLabelElement( RV_RES.IDS_JS_BUSINESS_PROCESS_SELECT_DIALOG_NO_PROCESS) );
  15759. },
  15760. addSelectProcessTableContent : function( tableContainer ) {
  15761. for( var i=0 ; i < this.BPMProcessesInfo.length; i++) {
  15762. var radioButtonObj = new dijit.form.RadioButton({
  15763. checked: (( i === 0 ) ? true : false),// check the first item by default
  15764. name : this.id + '_processItem',
  15765. disabled: false
  15766. });
  15767. var sCaption = html_encode( this.BPMProcessesInfo[i].sCaption );
  15768. var sBPD_ID = this.BPMProcessesInfo[i].sBPD_ID;
  15769. var sProcessAppID = this.BPMProcessesInfo[i].sProcessAppID;
  15770. radioButtonObj.onChange = dojo.hitch( this, 'getProcessItemRadioChangeFunction', sBPD_ID, sProcessAppID, sCaption, radioButtonObj );
  15771. var row_process = new bux.layout.TableContainerRow({
  15772. parentContainer : tableContainer,
  15773. classname : ((i === 0 ) ? 'buxFilterConfigFilterValueRowSelected' : '')
  15774. });
  15775. row_process.set( 'id', this.id + '_processItemsRow' + radioButtonObj.id );
  15776. var cell_radio = new bux.layout.TableContainerCell({
  15777. align : 'center',
  15778. parentContainer : row_process
  15779. });
  15780. cell_radio.addContent( radioButtonObj.domNode );
  15781. cell_radio.set( 'id', this.id + '_processItemsCell' + i );
  15782. var cell_process = new bux.layout.TableContainerCell({
  15783. classname : 'buxFilterConfigFilterItemName text_overflow_ellipsis_ie',
  15784. width : '300px',
  15785. valign : 'top',
  15786. parentContainer : row_process
  15787. });
  15788. var _label = document.createElement("label");
  15789. _label.appendChild(document.createTextNode( sCaption ));
  15790. _label.setAttribute("for", radioButtonObj.id);
  15791. cell_process.addContent(_label);
  15792. }
  15793. this.setDefaultProcessSelectedInfo();
  15794. },
  15795. setDefaultProcessSelectedInfo : function(){
  15796. this._selectedBPD_ID = this.BPMProcessesInfo[0].sBPD_ID;
  15797. this._selectedProcessAppId = this.BPMProcessesInfo[0].sProcessAppID;
  15798. this._selectedProcessName = html_encode( this.BPMProcessesInfo[0].sCaption );
  15799. },
  15800. getProcessItemRadioChangeFunction : function( sBPD_ID, sProcessAppId, sProcessName, radio) {
  15801. if( radio.get( 'value') === 'on') {
  15802. dojo.byId(this.id + '_processItemsRow' + radio.id).className = 'buxFilterConfigFilterValueRowSelected';
  15803. this._selectedBPD_ID = sBPD_ID;
  15804. this._selectedProcessAppId = sProcessAppId;
  15805. this._selectedProcessName = sProcessName;
  15806. } else {
  15807. dojo.byId(this.id + '_processItemsRow' + radio.id).className = '';
  15808. }
  15809. },
  15810. generateViewInputValuesSection : function( oParentContainer ) {
  15811. var sContainerAllyId = this.id + '_viewInputValues_a11ylabel';
  15812. this.addTableDescription( oParentContainer, RV_RES.IDS_JS_BUSINESS_PROCESS_VIEW_INPUT_VALUES_TABLE_DESCRIPTION, sContainerAllyId);
  15813. this.addViewInputValuesTable( oParentContainer, sContainerAllyId );
  15814. },
  15815. addViewInputValuesTable : function( oParentContainer, sContainerAllyId ) {
  15816. oParentContainer.addContent( this.generateViewInputValuesTable( sContainerAllyId) );
  15817. },
  15818. addTableDescription : function( oParentContainer, sDescription, sID ) {
  15819. var div = document.createElement( 'div');
  15820. dojo.attr( div, { 'class' : 'bux-label',
  15821. id : sID
  15822. });
  15823. div.appendChild( document.createTextNode(html_encode( sDescription ) ) );
  15824. oParentContainer.addContent( div );
  15825. },
  15826. /**
  15827. * Returns div that contains the table
  15828. */
  15829. generateViewInputValuesTable : function(sContainerAllyId) {
  15830. var oInputParameters = this.bpAction.getInputParameter();
  15831. var div = document.createElement( 'div');
  15832. dojo.attr(div, { 'class' : 'buxFilterConfigFilterValue',
  15833. style : 'height:80px',
  15834. role : 'group',
  15835. 'aria-labelledby': sContainerAllyId
  15836. });
  15837. var tableContainer = new bux.layout.TableContainer({
  15838. classname: 'buxFilterConfigFilterValueTable'
  15839. } );
  15840. dojo.style( tableContainer.domNode, 'width', '335px' );
  15841. tableContainer.set( 'role', 'list');
  15842. div.appendChild( tableContainer.domNode );
  15843. var table_header_row = new bux.layout.TableContainerRow({
  15844. classname : "buxFilterConfigFilterValueTableHeaderRow",
  15845. parentContainer : tableContainer
  15846. });
  15847. var table_header_cell_1 = new bux.layout.TableContainerCell({
  15848. classname : "buxListHeader buxFilterConfigFilterValueTableHeaderLeft",
  15849. width : '40%',
  15850. parentContainer : table_header_row
  15851. });
  15852. table_header_cell_1.addContent(document.createTextNode(RV_RES.IDS_JS_BUSINESS_PROCESS_VIEW_INPUT_VALUES_TABLE_COLUMN_HEADER_DATA_ITEM));
  15853. var table_header_cell_2 = new bux.layout.TableContainerCell({
  15854. classname : "buxListHeader buxFilterConfigFilterValueTableHeader",
  15855. width : '60%',
  15856. parentContainer : table_header_row
  15857. });
  15858. table_header_cell_2.addContent(document.createTextNode(RV_RES.IDS_JS_BUSINESS_PROCESS_VIEW_INPUT_VALUES_TABLE_COLUMN_HEADER_DISPLAY_VALUE_HEADER));
  15859. var cognosParm = oInputParameters.cognosParameter;
  15860. var bAlreadySetDefaultFocus = false;
  15861. for( var i=0 ; i < cognosParm.length; i++) {
  15862. var rowIndex = 0;
  15863. var widgetContextValues = this.getWidgetContextValues(cognosParm[i]);
  15864. for( var dataItem in widgetContextValues ) {
  15865. var row = new bux.layout.TableContainerRow({
  15866. parentContainer : tableContainer
  15867. });
  15868. var rowAttributes = { id : this.id + '_inputValueRow_' + rowIndex,
  15869. role : 'listitem' };
  15870. //set focus on first row only
  15871. if( !bAlreadySetDefaultFocus ){
  15872. rowAttributes.tabindex = 0;
  15873. bAlreadySetDefaultFocus = true;
  15874. }
  15875. dojo.attr( row.domNode, rowAttributes);
  15876. this.addRowAccessibility(row, rowIndex, dataItem, widgetContextValues[dataItem]);
  15877. //data item
  15878. var dataItemCell = new bux.layout.TableContainerCell({
  15879. classname : 'buxFilterConfigFilterItemName text_overflow_ellipsis_ie',
  15880. width : '40%',
  15881. valign : 'top',
  15882. parentContainer : row
  15883. });
  15884. dataItemCell.set( 'id', this.id + '_dataItem_' + i );
  15885. dataItemCell.addContent( this.createLabelElement( dataItem ) );
  15886. //display value
  15887. var displayValueCell = new bux.layout.TableContainerCell({
  15888. classname : 'buxFilterConfigFilterItemName text_overflow_ellipsis_ie',
  15889. width : '60%',
  15890. valign : 'top',
  15891. parentContainer : row
  15892. });
  15893. displayValueCell.set( 'id', this.id + '_displayValue_' + i );
  15894. displayValueCell.addContent( this.createLabelElement( widgetContextValues[dataItem][0] ) );
  15895. rowIndex++;
  15896. }
  15897. }
  15898. return div;
  15899. },
  15900. getWidgetContextValues : function( widgetContext ){
  15901. return values = widgetContext['com.ibm.widget.context'].values;
  15902. },
  15903. addRowAccessibility : function( row, rowIndex, sDataItem, sDataValue ) {
  15904. // add aria-labelledby label
  15905. var sA11yLabelId = this.id + '_inputValueRow_label_' + rowIndex;
  15906. dojo.attr( row.domNode, { 'aria-labelledby' : sA11yLabelId } );
  15907. var sA11yLabel = RV_RES.IDS_JS_BUSINESS_PROCESS_VIEW_INPUT_VALUES_TABLE_COLUMN_HEADER_DATA_ITEM + ' ' + sDataItem + ' ' +
  15908. RV_RES.IDS_JS_BUSINESS_PROCESS_START_PROCESS_A11Y_DESC_VALUE + ' ' + sDataValue;
  15909. row.domNode.appendChild( this.createA11yLabel( sA11yLabel, sA11yLabelId, true /*hidden*/ ) );
  15910. //add keyboard navigation
  15911. dojo.connect( row.domNode, "onkeypress", dojo.hitch( this, this._rowOnKeyPress));
  15912. },
  15913. _rowOnKeyPress : function( evt ) {
  15914. switch( evt.keyCode ) {
  15915. case dojo.keys.DOWN_ARROW :
  15916. this.changeNodeFocus( evt, evt.target, evt.target.nextSibling );
  15917. break;
  15918. case dojo.keys.UP_ARROW :
  15919. this.changeNodeFocus( evt, evt.target, evt.target.previousSibling );
  15920. break;
  15921. }
  15922. },
  15923. changeNodeFocus : function( evt, currentNode, targetNode) {
  15924. if( !targetNode || ( targetNode && targetNode.id && targetNode.id.indexOf( '_inputValueRow_' ) === -1 ) ){
  15925. return;
  15926. }
  15927. dojo.attr( currentNode, {tabindex : -1 } );
  15928. dojo.attr( targetNode, { tabindex : 0 } );
  15929. dijit.focus( targetNode );
  15930. if (dojo.isIE || dojo.isTrident) {
  15931. evt.keyCode = 0;
  15932. }
  15933. dojo.stopEvent(evt);
  15934. },
  15935. createA11yLabel : function( sLabelText, sLabelId, hidden ) {
  15936. var _eSpan = this.createLabelElement( sLabelText );
  15937. var attribs = { id :sLabelId };
  15938. if( hidden ){attribs.style = 'visibility:hidden;display:none';}
  15939. dojo.attr( _eSpan, attribs);
  15940. return _eSpan;
  15941. },
  15942. createLabelElement : function( sLabelText ) {
  15943. var _eSpan = document.createElement("span");
  15944. _eSpan.appendChild(document.createTextNode( html_encode( sLabelText ) ));
  15945. return _eSpan;
  15946. },
  15947. onOK : function() {
  15948. this.hide();
  15949. this.bpAction.startProcess( this._selectedBPD_ID, this._selectedProcessAppId, this._selectedProcessName );
  15950. }
  15951. });