propertiesBundle.debug.js 114 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Content Explorer
  5. *| (C) Copyright IBM Corp. 2015, 2018
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or disclosure
  8. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *+------------------------------------------------------------------------+
  10. */
  11. define('bi/content_apps/common/ui/permissions/Policy',[],function() {
  12. 'use strict';
  13. /**
  14. * Represents a Policy (account, group or role) that is found in the policy of an item
  15. */
  16. function Policy(name, id, type, path) {
  17. // Ensures that the callee has invoked our Class' constructor function
  18. // with the `new` keyword
  19. if (!(this instanceof Policy)) {
  20. throw new TypeError('Policy constructor cannot be called as a function.');
  21. }
  22. this.permissions = [{
  23. name: 'read',
  24. access: 'grant'
  25. }, {
  26. name: 'traverse',
  27. access: 'grant'
  28. }];
  29. this.securityObject = {
  30. defaultName: name,
  31. id: id,
  32. type: type,
  33. searchPath: path
  34. };
  35. }
  36. Policy.prototype = {
  37. constructor: Policy
  38. };
  39. return Policy;
  40. });
  41. define('text!bi/content_apps/common/policyfacets.json',[],function () { return '{\n\t"copyright": "Licensed Materials - Property of IBM. IBM Cognos Products: BI Cloud(C) Copyright IBM Corp.2014, 2017. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.",\n\t"facets": {\n "accounts": "account",\n "groups": "group",\n "roles": "role"\n\t},\n\t"columns": []\n}';});
  42. /*
  43. *+------------------------------------------------------------------------+
  44. *| Licensed Materials - Property of IBM
  45. *| IBM Cognos Products: BI Content Explorer
  46. *| (C) Copyright IBM Corp. 2015, 2020
  47. *|
  48. *| US Government Users Restricted Rights - Use, duplication or disclosure
  49. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  50. *+------------------------------------------------------------------------+
  51. */
  52. define('bi/content_apps/common/PolicyPropertyView',[
  53. 'bacontentnav/common/ContentListPageView',
  54. 'bi/content_apps/common/ui/permissions/Policy',
  55. 'text!./policyfacets.json',
  56. 'bi/content_apps/nls/StringResource',
  57. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/CheckBox',
  58. 'bacontentnav/utils/ContentStoreObject',
  59. 'bi/commons/ui/Button',
  60. 'bacontentnav/utils/PolicyHelper',
  61. 'bacontentnav/common/ui/BreadcrumbDropDown',
  62. 'bacontentnav/utils/GlassContextHelper',
  63. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  64. 'underscore'
  65. ], function(ContentListPageView, Policy, policyFacets, StringResource, CheckBox, ContentStoreObject, CommonButton, PolicyHelper, DropDownMenu, GlassContextHelper, PropertyUIControl, _) {
  66. 'use strict';
  67. var PolicyPropertyView = ContentListPageView.extend({
  68. init: function(options) {
  69. this.itemURL = options.itemURL;
  70. this.showUnavailablePolicies = false;
  71. PolicyPropertyView.inherited('init', this, arguments);
  72. _.extend(this, options);
  73. this.addURLParameters({
  74. 'schemaInfo': 'true',
  75. 'fields': 'surname,givenName,userName,defaultName,policies.defaultName,policies.id,policies.ancestors,permissions'
  76. });
  77. this.contentListFacets = JSON.parse(policyFacets).facets;
  78. },
  79. getPoliciesData: function() {
  80. return Promise.resolve(this.permissionsData);
  81. },
  82. _canModifyPolicies: function(canModify) {
  83. if (canModify === undefined) {
  84. this.canModifyPolicies = ContentStoreObject.hasPermissions(this.oData.data[0], ['setPolicy']) && !(ContentStoreObject.isPoliciesAcquired(this.oData.data[0]));
  85. } else {
  86. this.canModifyPolicies = canModify;
  87. }
  88. },
  89. _getObject: function() {
  90. var urlParms = this.getURLParameters();
  91. var reqUrl = this._getDefaultRequestURL();
  92. $.each(urlParms, function(name, value) {
  93. if (reqUrl === this.itemURL) {
  94. reqUrl += '?';
  95. } else {
  96. reqUrl += '&';
  97. }
  98. reqUrl += name + '=' + value;
  99. }.bind(this));
  100. // Query for the information we need to open the view
  101. var options = {
  102. dataType: 'json',
  103. type: 'GET',
  104. data: {},
  105. url: reqUrl,
  106. cache: false
  107. };
  108. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  109. .then(function(response) {
  110. return response && response.data;
  111. });
  112. },
  113. _setOData: function(oData) {
  114. var updatedPolicies = [];
  115. this.rejectedPolicies = [];
  116. if (oData.data[0].policies) {
  117. oData.data[0].policies.forEach(function(policy) {
  118. if (policy.securityObject.type === 'nil') {
  119. this.rejectedPolicies.push(policy);
  120. } else {
  121. updatedPolicies.push(policy);
  122. }
  123. }.bind(this));
  124. oData.data[0].policies = updatedPolicies;
  125. }
  126. this.oData = oData;
  127. },
  128. _showHideAddMemberButton: function(isShown) {
  129. var buttonTabIndex = '0';
  130. if ((isShown) && (this.canModifyPolicies)) {
  131. this.contentBar.itemMap.add.show();
  132. } else {
  133. this.contentBar.itemMap.add.hide();
  134. buttonTabIndex = '-1';
  135. }
  136. $(this.contentBar.itemMap.add.el).find('button').attr('tabindex', buttonTabIndex);
  137. },
  138. _updateUIForEdit: function() {
  139. var isRoot = ContentStoreObject.isTeamContent(this.oData.data[0]);
  140. var listControl = this.getListControl();
  141. this.applyToChildren = this._oPropertyUIControl.getProperty('applyToAllChildren');
  142. if (isRoot) {
  143. if (this.contentBar.itemMap.add) {
  144. this._showHideAddMemberButton(true);
  145. }
  146. } else {
  147. var overrideParent = this._oPropertyUIControl.getProperty('overrideParent');
  148. var isChecked = overrideParent.isChecked();
  149. this._canModifyPolicies(isChecked);
  150. if (!isChecked) {
  151. // If we are turning off multi select we should clear selections
  152. listControl._clearRows();
  153. this.multiselectBar.hide();
  154. this.contentBar.show();
  155. this.applyToChildren.uncheck();
  156. this.applyToChildren.disable();
  157. } else {
  158. this.applyToChildren.enable();
  159. }
  160. listControl.multiSelect = isChecked;
  161. this.$el.removeClass('policyCanNotModify');
  162. if (!(this.canModifyPolicies && isChecked)) {
  163. this.$el.addClass('policyCanNotModify');
  164. }
  165. if (this.contentBar.itemMap.add) {
  166. this._showHideAddMemberButton(isChecked);
  167. }
  168. }
  169. },
  170. render: function() {
  171. return this._getObject().then(function(oData) {
  172. this._setOData(oData);
  173. this.permissionsData = {};
  174. this.permissionsData.data = oData.data[0].policies ? oData.data[0].policies : [];
  175. this._canModifyPolicies();
  176. return PolicyPropertyView.inherited('render', this, arguments).then(function() {
  177. this._updateUIForEdit();
  178. return Promise.resolve();
  179. }.bind(this));
  180. }.bind(this));
  181. },
  182. _overrideParentChanged: function() {
  183. this._updateUIForEdit();
  184. this._enableApplyItems();
  185. },
  186. renderContent: function() {
  187. this.$el.addClass('policies');
  188. // The content bars get rendered first, detach them here so we can re-attach them to the DOM when just above the list control
  189. this.$contentBars = this.$el.children().detach();
  190. var aControls = [];
  191. if ((this.rejectedPolicies) && (this.rejectedPolicies.length > 0)) {
  192. aControls.push({
  193. 'type': 'SingleLineLinks',
  194. 'name': 'hidePolicies',
  195. 'items': [{
  196. 'align': 'left',
  197. 'items': [{
  198. 'type': 'text',
  199. 'class': 'versionStatusText',
  200. 'value': StringResource.get('missingPolicies'),
  201. 'svgIcon': 'common-warning'
  202. }]
  203. }]
  204. },{
  205. 'type': 'CheckBox',
  206. 'name': 'showUnavailablePolicies',
  207. 'label': StringResource.get('showUnavailablePolicies'),
  208. 'controlOnLeft': true,
  209. 'checked': this.showUnavailablePolicies,
  210. 'onChange': this._toggleShowUnavailablePolicies.bind(this)
  211. });
  212. }
  213. var isRoot = ContentStoreObject.isTeamContent(this.oData.data[0]);
  214. if (!isRoot) {
  215. aControls.push({
  216. 'type': 'CheckBox',
  217. 'name': 'overrideParent',
  218. 'label': StringResource.get('overrideParentPermissions'),
  219. 'controlOnLeft': true,
  220. 'checked': !(ContentStoreObject.isPoliciesAcquired(this.oData.data[0])),
  221. 'onChange': this._overrideParentChanged.bind(this)
  222. });
  223. }
  224. aControls.push({
  225. 'module': 'bi/content_apps/ui/RenderCallback',
  226. 'renderCallback': this._renderListControl.bind(this)
  227. }, {
  228. 'type': 'CheckBox',
  229. 'name': 'applyToAllChildren',
  230. 'label': StringResource.get('applyToAllChildren'),
  231. 'controlOnLeft': true,
  232. 'onChange': this._enableApplyItems.bind(this)
  233. }, {
  234. 'type': 'Footer',
  235. 'items': [{
  236. 'type': 'Button',
  237. 'label': StringResource.get('applyLabel'),
  238. 'onSelect': this._onApplyClick.bind(this),
  239. 'primary': true
  240. }, {
  241. 'type': 'Button',
  242. 'label': StringResource.get('cancel'),
  243. 'onSelect': this._onCancelClick.bind(this),
  244. 'primary': false
  245. }]
  246. });
  247. this._oPropertyUIControl = new PropertyUIControl({
  248. 'el': this.$el,
  249. 'glassContext': this.glassContext,
  250. 'items': aControls
  251. });
  252. return this._oPropertyUIControl.render().then(function() {
  253. var footer = this._getFooter();
  254. var footerProps;
  255. footerProps = footer._oPropertyUIControl.getProperties();
  256. this.applyButton = footerProps[0];
  257. this.applyButton.disable();
  258. return Promise.resolve();
  259. }.bind(this));
  260. },
  261. _getFooter: function() {
  262. var propList = this._oPropertyUIControl.getProperties();
  263. var footer;
  264. propList.forEach(function(prop) {
  265. if (prop.type === 'Footer') {
  266. footer = prop;
  267. }
  268. });
  269. return footer;
  270. },
  271. _renderListControl: function(container) {
  272. var $wrapper = $('<div></div>');
  273. $(container).append($wrapper);
  274. $wrapper.append(this.$contentBars);
  275. return this.renderContentList({
  276. 'el': $wrapper,
  277. 'columns': this._getColumnSpecification(),
  278. '$container': this.$el.closest('.propertiesUIControlPageView'),
  279. 'minHeight': 50,
  280. 'url': (this.url || this._getDefaultRequestURL())
  281. });
  282. },
  283. _onCancelClick: function() {
  284. this.slideout.hide();
  285. },
  286. _onApplyClick: function() {
  287. var data = {};
  288. data.policies = this.oData.data[0].policies;
  289. data.type = this.oData.data[0].type;
  290. var overrideParent = this._oPropertyUIControl.getProperty('overrideParent');
  291. var overrideChecked = (!overrideParent || overrideParent.isChecked());
  292. if (overrideChecked) {
  293. // Add back in the policies the user can not see
  294. if ((this.rejectedPolicies) && (this.rejectedPolicies.length > 0)) {
  295. this.rejectedPolicies.forEach(function(policy) {
  296. data.policies.push(policy);
  297. });
  298. }
  299. // Setup the search path for the security objects
  300. data.policies.forEach(function(policy) {
  301. var currentSO = policy.securityObject;
  302. currentSO.searchPath = 'storeID("' + currentSO.id + '")';
  303. });
  304. } else {
  305. // If the override parent permission is not checked then clear out the permissions
  306. data.policies = [];
  307. }
  308. // Set the apply to all children
  309. if (this.applyToChildren.isChecked()) {
  310. data._meta = {
  311. 'schemaInfo': {
  312. 'policies': {
  313. 'applyUpdateToDescendants': true
  314. }
  315. }
  316. };
  317. }
  318. var jsonData = JSON.stringify(data);
  319. var options = {
  320. 'headers': {
  321. 'Accept': 'application/json',
  322. 'Content-Type': 'application/json'
  323. },
  324. 'type': 'PUT',
  325. 'url': ContentStoreObject.getSelfLink(this.oData.data[0]),
  326. 'data': jsonData
  327. };
  328. // Reset the ui after apply
  329. this.applyButton.disable();
  330. return this._sendRequest(options).then(function(response) {
  331. // After updating , refetch policies and render them
  332. // especially after deselecting override and overrides were previously applied
  333. // default policies need to be rendered instead
  334. if (!overrideChecked) {
  335. this._getObject().then(function(oData) {
  336. this._setOData(oData);
  337. this.permissionsData = {};
  338. this.permissionsData.data = oData.data[0].policies ? oData.data[0].policies : [];
  339. this._canModifyPolicies();
  340. this.refresh(this.itemURL);
  341. this._updateUIForEdit();
  342. return Promise.resolve(response);
  343. }.bind(this));
  344. } else {
  345. this._updateUIForEdit();
  346. return Promise.resolve(response);
  347. }
  348. }.bind(this));
  349. },
  350. _sendRequest: function(options, successHandler) {
  351. successHandler = successHandler || function() {
  352. return Promise.resolve();
  353. };
  354. return this.glassContext.getCoreSvc('.Ajax').ajax(options)
  355. .then(successHandler.bind(this))
  356. .catch(function(err) {
  357. GlassContextHelper.showAjaxServiceError(this.glassContext, err);
  358. return Promise.reject(err);
  359. }.bind(this));
  360. },
  361. _getDefaultRequestURL: function() {
  362. return this.itemURL;
  363. },
  364. _getModuleName: function() {
  365. return 'bi/content_apps/common/ui/PolicyPropertyView';
  366. },
  367. getFilterSpec: function() {
  368. return [{
  369. 'name': 'allContent',
  370. 'label': StringResource.get('allGenericItems'),
  371. 'value': 'allContent'
  372. }, {
  373. 'name': 'accounts',
  374. 'label': StringResource.get('policyFilterAccounts'),
  375. 'value': 'account'
  376. }, {
  377. 'name': 'groups',
  378. 'label': StringResource.get('policyFilterGroups'),
  379. 'value': 'group'
  380. }, {
  381. 'name': 'roles',
  382. 'label': StringResource.get('policyFilterRoles'),
  383. 'value': 'role'
  384. }];
  385. },
  386. _getFilterItems: function(filterSpec, filterMenuPrefix, defaultFilterValue, doFilter) {
  387. return _.map(filterSpec, function(item) {
  388. return {
  389. 'name': filterMenuPrefix + item.name,
  390. 'icon': 'wft_checkmark',
  391. 'label': item.label,
  392. 'checked': item.value === defaultFilterValue,
  393. 'action': function() {
  394. doFilter(item.name);
  395. }
  396. };
  397. });
  398. },
  399. contentbarItems: function() {
  400. var filterMenuNamePrefix = 'POLICY_FILTER_';
  401. var filterString = window.localStorage.getItem('filterString_' + this.stateId) || '';
  402. var filterSpec = this.getFilterSpec();
  403. var filterItems = this._getFilterItems(filterSpec, filterMenuNamePrefix, filterString, this._filter.bind(this));
  404. return [{
  405. 'name': 'nameLabel',
  406. 'position': 'leading',
  407. 'style': 'nameLabel',
  408. 'module': 'bacontentnav/common/ui/contentbar_components/HiddenLabel',
  409. 'label': StringResource.get('policiesTableLable')
  410. }, {
  411. 'name': filterMenuNamePrefix + 'typeMenu',
  412. 'label': StringResource.get('type'),
  413. 'hcLabel': false,
  414. 'position': 'trailing',
  415. 'supportCustomCollapse': true,
  416. 'showTitle': false,
  417. 'updateLabel': true,
  418. 'icon': 'common-filter',
  419. 'bSVG': true,
  420. 'module': 'bacontentnav/common/ui/contentbar_components/ToggleMenuBar',
  421. 'items': filterItems
  422. }, {
  423. 'name': 'add',
  424. 'position': 'trailing',
  425. 'displayLabel': false,
  426. 'label': StringResource.get('policesAddMemberButtonLabel'),
  427. 'module': 'bacontentnav/common/ui/contentbar_components/Button',
  428. 'className': 'addNewFolder',
  429. 'supportCustomCollapse': true,
  430. 'icon': 'common-add',
  431. 'hiddenOnRender': true,
  432. '_handleClick': function() {
  433. this._openAddMembersSlideout();
  434. }.bind(this)
  435. }];
  436. },
  437. getListControlOptions: function() {
  438. return {
  439. 'ajaxProp': 'data',
  440. 'emptyFolderString': StringResource.get('emptyPolicyList'),
  441. 'showEmptyNewFolderButton': false,
  442. 'getJSONDataCallback': this.getPoliciesData.bind(this),
  443. 'url': '',
  444. 'multiSelect': this.canModifyPolicies,
  445. 'rightClickContextMenu': false
  446. };
  447. },
  448. getDefaultSort: function() {
  449. return [1, 'asc'];
  450. },
  451. _isDuplicate: function(oData, matchId) {
  452. var isDuplicate = false;
  453. oData.forEach(function(arrayElem) {
  454. var id = arrayElem.securityObject.id;
  455. if (id === matchId) {
  456. isDuplicate = true;
  457. return false;
  458. }
  459. });
  460. return isDuplicate;
  461. },
  462. removeSelection: function() {
  463. setTimeout(function() {
  464. var overrideParent = this._oPropertyUIControl.getProperty('overrideParent');
  465. var canOverride = overrideParent === null || overrideParent.isChecked();
  466. if (canOverride) {
  467. var selectedPolicies = this.getListControl().getSelectedObjects();
  468. var updatedPolicies = _.reject(this.oData.data[0].policies, function(policy) {
  469. return _.find(selectedPolicies, function(selPol) {
  470. return policy.securityObject.defaultName === selPol.securityObject.defaultName;
  471. });
  472. });
  473. this.getListControl().removeSelectedRows();
  474. this.oData.data[0].policies = updatedPolicies;
  475. if (updatedPolicies && updatedPolicies.length > 0) {
  476. this._enableApplyItems();
  477. this.setFocus();
  478. } else {
  479. this._disableApplyItems();
  480. }
  481. }
  482. }.bind(this), 100);
  483. },
  484. addSelection: function(selectedItems) { //NOSONAR
  485. var itemCount = 0;
  486. var numberAdded = 0;
  487. var dataTable = this.getListControl().getDatatable();
  488. var tableApi = dataTable.api();
  489. // need to check for duplicates and simply ignore them
  490. var oData = dataTable.fnGetData();
  491. selectedItems.forEach(function(item) {
  492. var itemId = item.id;
  493. var itemType = item.type;
  494. var itemName = item.defaultName;
  495. var foundDuplicate = this._isDuplicate(oData, itemId);
  496. itemCount = itemCount + 1;
  497. if ((!foundDuplicate) && (itemType !== 'namespaceFolder')) {
  498. numberAdded = numberAdded + 1;
  499. var policy = new Policy(itemName, itemId, itemType);
  500. tableApi.row.add(policy).draw(true);
  501. if(this.oData.data[0].policies !== null ) {
  502. this.oData.data[0].policies.push(policy);
  503. } else {
  504. this.oData.data[0].policies = [];
  505. this.oData.data[0].policies.push(policy);
  506. }
  507. }
  508. }.bind(this));
  509. var sToastMessage;
  510. if (numberAdded === 1) {
  511. sToastMessage = StringResource.get('toastItemsWereAddedSingular', {
  512. 'noOfItems': numberAdded
  513. });
  514. } else if (numberAdded === 0 && itemCount === 1) {
  515. sToastMessage = StringResource.get('toastItemsAlreadyAddedSingular');
  516. } else if (numberAdded === 0 && itemCount > 1) {
  517. sToastMessage = StringResource.get('toastItemsAlreadyAdded');
  518. } else {
  519. sToastMessage = StringResource.get('toastItemsWereAdded', {
  520. 'noOfItems': numberAdded
  521. });
  522. }
  523. this.glassContext.appController.showToast(sToastMessage);
  524. this._enableApplyItems();
  525. },
  526. _openAddMembersSlideout: function(oData) {
  527. this.glassContext.appController.showSlideOut({
  528. 'parent': this.slideout,
  529. 'width': '450', // temporary adjustment for R10 until panel size is unified
  530. 'content': {
  531. 'module': 'bi/admin/account/slideout/SecurityObjectSelectorPane',
  532. 'parentView': this,
  533. 'objectInfo': oData,
  534. 'title': StringResource.get('selectAccountGroupOrRole'),
  535. 'allowedSelectionTypes': ['group', 'role', 'account', 'namespace'],
  536. 'multiSelectCallback': this.addSelection.bind(this)
  537. }
  538. });
  539. },
  540. _birdBeakMenuItems: function() {
  541. return [{
  542. 'label': StringResource.get('permissionRead'),
  543. 'icon': '',
  544. 'onSelect': function() {
  545. var listCon = this.getListControl();
  546. if (listCon) {
  547. this._updatePermission(PolicyHelper.simplePermEnum.read, listCon.getSelectedObjects(), listCon.getSelectedRows());
  548. }
  549. }.bind(this)
  550. }, {
  551. 'label': StringResource.get('permissionRun'),
  552. 'icon': '',
  553. 'onSelect': function() {
  554. var listCon = this.getListControl();
  555. if (listCon) {
  556. this._updatePermission(PolicyHelper.simplePermEnum.run, listCon.getSelectedObjects(), listCon.getSelectedRows());
  557. }
  558. }.bind(this)
  559. }, {
  560. 'label': StringResource.get('permissionWrite'),
  561. 'icon': '',
  562. 'onSelect': function() {
  563. var listCon = this.getListControl();
  564. if (listCon) {
  565. this._updatePermission(PolicyHelper.simplePermEnum.write, listCon.getSelectedObjects(), listCon.getSelectedRows());
  566. }
  567. }.bind(this)
  568. }, {
  569. 'label': StringResource.get('permissionFull'),
  570. 'icon': '',
  571. 'onSelect': function() {
  572. var listCon = this.getListControl();
  573. if (listCon) {
  574. this._updatePermission(PolicyHelper.simplePermEnum.full, listCon.getSelectedObjects(), listCon.getSelectedRows());
  575. }
  576. }.bind(this)
  577. }];
  578. },
  579. _updatePermission: function(newPerm, selectedObjects, selectedRows) {
  580. var pos = 0;
  581. selectedObjects.forEach(function(policyObj) {
  582. policyObj.permissions = PolicyHelper.clonePermissionArray(newPerm);
  583. var currentRow = selectedRows[pos];
  584. if (currentRow) {
  585. this.getListControl().updateCell(policyObj, selectedRows[pos], 2);
  586. }
  587. pos += 1;
  588. }.bind(this));
  589. this.applyButton.enable();
  590. },
  591. _getColumnSpecification: function() {
  592. var columns = [];
  593. columns.push({
  594. 'type': 'Icon',
  595. 'getDataFn': function(oRowData) {
  596. if (oRowData.securityObject[ContentStoreObject.TYPE] === 'nil') {
  597. return 'unknown';
  598. } else {
  599. return oRowData.securityObject[ContentStoreObject.TYPE];
  600. }
  601. }
  602. });
  603. var multiPropItems = [];
  604. multiPropItems.push({
  605. 'type': 'Text',
  606. 'scope': 'row',
  607. 'label': StringResource.get('name'),
  608. 'getDataFn': function(oRowData) {
  609. if (oRowData.securityObject[ContentStoreObject.DEFAULT_NAME] === undefined) {
  610. return StringResource.get('unavailable');
  611. } else {
  612. var userData = this.oData.data[0];
  613. // check if the givenName, surName, and userName are available, otherwise display the defaultName
  614. return this._getUserName(userData, oRowData);
  615. }
  616. }.bind(this)
  617. });
  618. multiPropItems.push({
  619. 'type': 'Text',
  620. 'getDataFn': function(oRowData) {
  621. return this._getPath(oRowData);
  622. }.bind(this)
  623. });
  624. columns.push({
  625. 'type': 'MultipleProperties',
  626. 'items': multiPropItems
  627. });
  628. columns.push({
  629. 'type': 'MultipleProperties',
  630. 'orientation': 'horizontal',
  631. 'weight': 10,
  632. 'items': [{
  633. 'type': 'Permission',
  634. 'clickCallback': this._openPolicyDetailSlideoutView.bind(this)
  635. }, {
  636. 'type': 'BirdBeakMenu',
  637. 'name': StringResource.get('permissionSetAccess'),
  638. 'menuItems': this._birdBeakMenuItems()
  639. }]
  640. });
  641. columns.push({
  642. 'type': 'ClickableIcon',
  643. 'name': StringResource.get('policesRemove'),
  644. 'icon': 'common-remove-delete',
  645. 'clickCallback': this.removeSelection.bind(this),
  646. 'a11yLabel': StringResource.get('removeSelectedItem')
  647. });
  648. return columns;
  649. },
  650. _adjustWidth: function() {
  651. this.$el.addClass('pageview-small');
  652. },
  653. _refreshTable: function() {
  654. var selectedRow = this.getListControl().getSelectedRows();
  655. if (selectedRow.length > 0) {
  656. var selectedObject = this.getListControl().getSelectedObjects();
  657. this.getListControl().updateCell(selectedObject[0], selectedRow[0], 2);
  658. }
  659. },
  660. _getUserName: function(userData, oRowData){
  661. if(userData.userName && (userData.givenName && userData.surname) && (_.escape(userData.defaultName) === _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]))){
  662. return userData.givenName + ' ' + userData.surname + ' (' + userData.userName + ')';
  663. } else if(userData.userName && !(userData.givenName && userData.surname) && (_.escape(userData.defaultName) === _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]))){
  664. return _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]) + ' (' + userData.userName + ')';
  665. } else{
  666. return _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]);
  667. }
  668. },
  669. _getPath: function(oRowData) {
  670. var path = '';
  671. if (oRowData.securityObject[ContentStoreObject.ANCESTORS] && oRowData.securityObject[ContentStoreObject.ANCESTORS].length) {
  672. var ancestorsArray = oRowData.securityObject[ContentStoreObject.ANCESTORS];
  673. ancestorsArray.shift(); // remove 'Directory'
  674. for (var i=0; i< ancestorsArray.length; i++) {
  675. path += (path === '') ? ('') : (' > ');
  676. path += ancestorsArray[i].defaultName;
  677. }
  678. }
  679. return path;
  680. },
  681. _openPolicyDetailSlideoutView: function(oData) {
  682. this.slideout.addChild({
  683. 'width': '400',
  684. 'onHide': this._refreshTable.bind(this),
  685. 'enableTabLooping': true,
  686. 'content': {
  687. 'module': 'bi/content_apps/common/PolicyDetailsView',
  688. 'enableParentApplyButton': function() {
  689. this.applyButton.enable();
  690. }.bind(this),
  691. 'objectInformation': oData,
  692. 'ownerData': this.oData.data[0],
  693. 'canModify': this.canModifyPolicies
  694. }
  695. });
  696. },
  697. getListControl: function() {
  698. return this._listControl;
  699. },
  700. _showUnavailablePolicies: function() {
  701. var dataTable = this.getListControl().getDatatable();
  702. var tableApi = dataTable.api();
  703. this.rejectedPolicies.forEach(function(rejPol) {
  704. this.oData.data[0].policies.push(rejPol);
  705. tableApi.row.add(rejPol).draw(true);
  706. }.bind(this));
  707. this.rejectedPolicies = [];
  708. },
  709. _hideUnavailablePolicies: function() {
  710. var updatedPolicies = [];
  711. var index = 0;
  712. var rowsToRemove = [];
  713. this.oData.data[0].policies.forEach(function(pol) {
  714. if (pol.securityObject.type === 'nil') {
  715. this.rejectedPolicies.push(pol);
  716. rowsToRemove.push(index);
  717. } else {
  718. updatedPolicies.push(pol);
  719. }
  720. index += 1;
  721. }.bind(this));
  722. this.getListControl().removeIndexRows(rowsToRemove);
  723. this.oData.data[0].policies = updatedPolicies;
  724. },
  725. _toggleShowUnavailablePolicies: function() {
  726. var showUnavailablePolicies = this._oPropertyUIControl.getProperty('showUnavailablePolicies');
  727. var isChecked = showUnavailablePolicies.isChecked();
  728. if (isChecked) {
  729. this._showUnavailablePolicies();
  730. } else {
  731. this._hideUnavailablePolicies();
  732. }
  733. this.showUnavailablePolicies = !this.showUnavailablePolicies;
  734. },
  735. _createMultiSelectBar: function() {
  736. return (PolicyPropertyView.inherited('_createMultiSelectBar', this, arguments)).then(function() {
  737. var $actionEl = this.$el.find('.multiselectbar .policyMulSel');
  738. this.msddMenu = new DropDownMenu({
  739. dropDownMenuSpec: {
  740. 'title': StringResource.get('permissionSetAccess'),
  741. 'id': 'birdBeakIdms',
  742. 'label': 'BirdBeakMS',
  743. 'items': this._birdBeakMenuItems(),
  744. 'actionElement': $actionEl[0],
  745. 'ddMenuPlacement': 'bottom'
  746. }
  747. });
  748. this.msddMenu.render().then(function(el) {
  749. $actionEl.append(el);
  750. });
  751. return Promise.resolve(this);
  752. }.bind(this));
  753. },
  754. _multiselectbarItems: function() {
  755. return Promise.resolve([{
  756. 'name': 'SetLabel',
  757. 'position': 'leading',
  758. 'module': '../../lib/gemini/app/ui/toolbar_components/Label',
  759. 'label': 'Set',
  760. 'style': 'policyMultiSelectLabel'
  761. }, {
  762. 'name': 'birdBeakButton',
  763. 'position': 'leading',
  764. 'displayLabel': false,
  765. 'label': StringResource.get('permissionSetAccess'),
  766. 'icon': 'common-titan-arrow-down',
  767. 'module': './contentbar_components/Button',
  768. 'className': 'policyMulSel'
  769. }, {
  770. 'position': 'leading',
  771. 'type': 'Separator'
  772. }, {
  773. 'name': 'removeButton',
  774. 'position': 'leading',
  775. 'displayLabel': false,
  776. 'label': StringResource.get('removeSelectedItem'),
  777. 'icon': 'common-remove-delete',
  778. 'module': './contentbar_components/Button',
  779. 'className': 'policyMulSel',
  780. 'action': this.removeSelection.bind(this)
  781. }, {
  782. 'name': 'selectedLabel',
  783. 'position': 'center',
  784. 'label': StringResource.get('selected'),
  785. 'module': '../../lib/gemini/app/ui/toolbar_components/Label',
  786. 'style': 'selectedLabel'
  787. }, {
  788. 'name': 'cancelButton',
  789. 'position': 'trailing',
  790. 'label': StringResource.get('cancel'),
  791. 'text': StringResource.get('cancel'),
  792. 'labelOnly': true,
  793. 'module': './contentbar_components/Button',
  794. 'className': 'cancelButton',
  795. '_handleClick': function() {
  796. this._listControl._clearRows();
  797. this.multiselectBar.hide();
  798. this.contentBar.show();
  799. }.bind(this)
  800. }]);
  801. },
  802. _enableApplyItems: function() {
  803. this.applyToChildren.enable();
  804. this.applyButton.enable();
  805. },
  806. _disableApplyItems: function() {
  807. this.applyToChildren.disable();
  808. this.applyButton.disable();
  809. }
  810. });
  811. return PolicyPropertyView;
  812. });
  813. /*
  814. *+------------------------------------------------------------------------+
  815. *| Licensed Materials - Property of IBM
  816. *| IBM Cognos Products: Content Explorer
  817. *| (C) Copyright IBM Corp. 2015, 2018
  818. *|
  819. *| US Government Users Restricted Rights - Use, duplication or disclosure
  820. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  821. *+----
  822. */
  823. define('bi/content_apps/PropertiesPermissionsTab',['q',
  824. 'bi/glass/app/ContentView',
  825. 'bacontentnav/utils/UIHelper',
  826. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  827. 'bi/content_apps/common/PolicyPropertyView',
  828. 'bacontentnav/utils/ContentStoreObject',
  829. 'underscore'
  830. ], function(Q, View, UIHelper, PropertyUIControl, PolicyPropertyView, ContentStoreObject, _) {
  831. 'use strict';
  832. var PropertiesPermissionsTab = View.extend({
  833. /**
  834. @paran options.el {node} - container dom node
  835. **/
  836. init: function(options) {
  837. PropertiesPermissionsTab.inherited('init', this, arguments);
  838. _.extend(this, options);
  839. this.policyView = null;
  840. },
  841. render: function() {
  842. this.policyView = this._getPolicyPropertyView({
  843. 'el': this.$el,
  844. 'id': 'policyPropertyView',
  845. 'slideout': this.slideout,
  846. 'glassContext': this.glassContext,
  847. 'itemURL': ContentStoreObject.getSelfLink(this.objectInfo)
  848. });
  849. return this.policyView.render();
  850. },
  851. _getPolicyPropertyView: function(options) {
  852. return new PolicyPropertyView(options);
  853. }
  854. });
  855. return PropertiesPermissionsTab;
  856. });
  857. /*
  858. *+------------------------------------------------------------------------+
  859. *| Licensed Materials - Property of IBM
  860. *| IBM Cognos Products: Content Explorer
  861. *| (C) Copyright IBM Corp. 2016, 2018
  862. *|
  863. *| US Government Users Restricted Rights - Use, duplication or disclosure
  864. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  865. *+----
  866. */
  867. define('bi/content_apps/PropertiesTab',['q',
  868. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyTabView',
  869. 'bacontentnav/utils/ContentStoreObject',
  870. 'underscore'
  871. ], function(Q, PropertyTabView, ContentStoreObject, _) {
  872. 'use strict';
  873. var PropertiesTab = PropertyTabView.extend({
  874. /**
  875. * @paran options.el {node} - container dom node
  876. */
  877. init: function(options) {
  878. PropertiesTab.inherited('init', this, arguments);
  879. _.extend(this, options);
  880. },
  881. _setReportOption: function(optionBlob, option, bDefault) {
  882. for (var i = 0; i < optionBlob.length; i++) {
  883. //if options exists, either modify or remove it
  884. if (optionBlob[i].name === option.name) {
  885. if (bDefault) {
  886. optionBlob.splice(i, 1);
  887. } else {
  888. optionBlob[i].value = option.value;
  889. }
  890. return;
  891. }
  892. }
  893. if (!bDefault) {
  894. optionBlob.push(option);
  895. }
  896. },
  897. _setAdvancedOption: function(optionBlob, optionName, optionType, optionValue, defaultValue) {
  898. var option = {};
  899. option.name = optionName;
  900. option.type = optionType;
  901. option.value = optionValue;
  902. this._setReportOption(optionBlob, option, option.value === defaultValue);
  903. },
  904. _getRetentionValue: function(objectClass) {
  905. var retention = null;
  906. if (objectClass === 'history') {
  907. retention = ContentStoreObject.getRunHistoryConfig(this.objectInfo);
  908. } else if (objectClass === 'reportVersion') {
  909. retention = ContentStoreObject.getReportOutputVersionsConfig(this.objectInfo);
  910. }
  911. if (retention) {
  912. if (retention.maxDuration === undefined || !retention.maxDuration) {
  913. return retention.maxObjects;
  914. } else {
  915. return parseInt(retention.maxDuration.match(/\d+/), 10);
  916. }
  917. }
  918. return 1;
  919. },
  920. _getRetentionUnit: function(objectClass) {
  921. var retention = null;
  922. if (objectClass === 'history') {
  923. retention = ContentStoreObject.getRunHistoryConfig(this.objectInfo);
  924. } else if (objectClass === 'reportVersion') {
  925. retention = ContentStoreObject.getReportOutputVersionsConfig(this.objectInfo);
  926. }
  927. if (retention) {
  928. if (retention.maxDuration === undefined || !retention.maxDuration) {
  929. return 'occurrences';
  930. } else {
  931. var list = retention.maxDuration.split(/\d+/);
  932. return list[1] === 'D' ? 'days' : 'months';
  933. }
  934. }
  935. return 'occurrences';
  936. },
  937. _getReportRetentions: function() {
  938. return ContentStoreObject.getReportRetentions(this.objectInfo);
  939. },
  940. _setReportRetention: function(retentionBlob, value, unit, ojbectClass) {
  941. var retention = {
  942. 'prop': 'creationTime',
  943. 'objectClass': ojbectClass
  944. };
  945. if (retentionBlob) {
  946. for (var i = 0; i < retentionBlob.length; i++) {
  947. if (retentionBlob[i].objectClass === ojbectClass) {
  948. retention = retentionBlob[i];
  949. break;
  950. }
  951. }
  952. }
  953. this._setRetentionValue(retention, value, unit);
  954. },
  955. _getModifiedRetentions: function(modifiedProperties, modifiedPropertiesUI) {
  956. var retentionBlob = this._getReportRetentions();
  957. var retentionModified = false;
  958. if (modifiedPropertiesUI.hasOwnProperty('runHistory') || modifiedPropertiesUI.hasOwnProperty('runHistoryUnit')) {
  959. retentionModified = true;
  960. this._setReportRetention(retentionBlob, modifiedPropertiesUI.runHistory, modifiedPropertiesUI.runHistoryUnit, 'history');
  961. delete modifiedPropertiesUI.runHistory;
  962. delete modifiedPropertiesUI.runHistoryUnit;
  963. }
  964. if (modifiedPropertiesUI.hasOwnProperty('reportVersion') || modifiedPropertiesUI.hasOwnProperty('reportVersionUnit')) {
  965. retentionModified = true;
  966. this._setReportRetention(retentionBlob, modifiedPropertiesUI.reportVersion, modifiedPropertiesUI.reportVersionUnit, 'reportVersion');
  967. delete modifiedPropertiesUI.reportVersion;
  968. delete modifiedPropertiesUI.reportVersionUnit;
  969. }
  970. if (retentionModified) {
  971. _.extend(modifiedProperties, {
  972. 'retentions': retentionBlob
  973. });
  974. }
  975. },
  976. _setRetentionValue: function(retention, value, unit) {
  977. if (value >= 0) {
  978. if (unit) {
  979. //both modified
  980. if (unit === 'occurrences') {
  981. retention.maxObjects = value;
  982. delete retention.maxDuration;
  983. } else {
  984. retention.maxObjects = 0;
  985. retention.maxDuration = 'P' + value + (unit === 'days' ? 'D' : 'M');
  986. }
  987. } else {
  988. //only value modified
  989. if (retention.maxDuration) {
  990. retention.maxDuration = retention.maxDuration.replace(/\d+/, value);
  991. } else {
  992. retention.maxObjects = value;
  993. }
  994. }
  995. } else {
  996. if (unit) {
  997. //only unit modified
  998. if (unit === 'occurrences') {
  999. if (retention.maxDuration) {
  1000. retention.maxObjects = parseInt(retention.maxDuration.match(/\d+/), 10);
  1001. delete retention.maxDuration;
  1002. }
  1003. } else {
  1004. if (retention.maxDuration) {
  1005. retention.maxDuration = retention.maxDuration.replace(/(\w+)(\d+)(\w+)/, '$1$2' + (unit === 'days' ? 'D' : 'M'));
  1006. } else {
  1007. retention.maxDuration = 'P' + retention.maxObjects + (unit === 'days' ? 'D' : 'M');
  1008. retention.maxObjects = 0;
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. });
  1015. return PropertiesTab;
  1016. });
  1017. /*
  1018. *+------------------------------------------------------------------------+
  1019. *| Licensed Materials - Property of IBM
  1020. *| IBM Cognos Products: Content Explorer
  1021. *| (C) Copyright IBM Corp. 2015, 2018
  1022. *|
  1023. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1024. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1025. *+------------------------------------------------------------------------+
  1026. */
  1027. define('bi/content_apps/PromptValuesView',[
  1028. 'jquery',
  1029. 'bi/glass/app/ContentView',
  1030. 'bi/content_apps/nls/StringResource',
  1031. 'bacontentnav/utils/ContentStoreObject',
  1032. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  1033. 'bi/schedule/views/PromptPickerView',
  1034. 'bacontentnav/utils/UIHelper',
  1035. 'underscore'
  1036. ],
  1037. function($, ContentView, StringResource, ContentStoreObject, PropertyUIControl, PromptPicker, UIHelper, _) {
  1038. 'use strict';
  1039. var PromptValuesView = ContentView.extend({
  1040. init: function(options) {
  1041. PromptValuesView.inherited('init', this, arguments);
  1042. _.extend(this, options);
  1043. this.showClickables = (typeof this.isEditMode === 'undefined') ? true : this.isEditMode;
  1044. },
  1045. render: function() {
  1046. var _clickables = [{}];
  1047. if (this.showClickables) {
  1048. _clickables = [{
  1049. 'type': 'text',
  1050. 'name': 'editPromptValues',
  1051. 'value': this._getBannerEditSetText()
  1052. }, {
  1053. 'type': 'text',
  1054. 'value': StringResource.get('clear'),
  1055. 'name': 'clearPromptValues',
  1056. 'clickCallback': function() {
  1057. this.promptDisplayValues = [];
  1058. this._getPromptValuesSection().refreshProperties([]);
  1059. if (this.clearCallback) {
  1060. this.clearCallback();
  1061. }
  1062. }.bind(this)
  1063. }];
  1064. }
  1065. this._oPropertyUIControl = new PropertyUIControl({
  1066. 'el': this.$el,
  1067. 'glassContext': this.glassContext,
  1068. 'slideout': this.slideout,
  1069. 'items': [{
  1070. 'type': 'Banner',
  1071. 'name': 'promptValuesBanner',
  1072. 'id': this.viewId,
  1073. 'value': StringResource.get('currentValues'),
  1074. 'centerLabel': true,
  1075. 'backButton': this.slideout.overlay,
  1076. 'editable': false,
  1077. 'readOnly': true,
  1078. 'onClose': function() {
  1079. this.slideout.hide();
  1080. }.bind(this),
  1081. 'clickables': _clickables
  1082. }, {
  1083. 'type': 'CollapsibleSection',
  1084. 'name': 'SectionPromptValues',
  1085. 'styleAsSimpleRow': true,
  1086. 'hideSectionTitle': true,
  1087. 'open': true,
  1088. 'items': this._getPromptItems(this.promptDisplayValues)
  1089. }]
  1090. });
  1091. if (!this._areValueSet()) {
  1092. this._renderEmptyPaneInfoMessage(this.$el);
  1093. }
  1094. return this._oPropertyUIControl.render().then(function() {
  1095. this._renderPromptPicker();
  1096. }.bind(this));
  1097. },
  1098. _areValueSet: function() {
  1099. return (this._getPromptItems(this.promptDisplayValues).length !== 0) ? true : false;
  1100. },
  1101. _getBannerEditSetText: function() {
  1102. var str = (this._areValueSet()) ? 'edit' : 'set';
  1103. return StringResource.get(str);
  1104. },
  1105. _renderEmptyPaneInfoMessage: function($node) {
  1106. UIHelper.renderInfoMessage($node, StringResource.get('noPromptsValuesSet'));
  1107. },
  1108. _removeEmptyPaneInfoMessage: function($node) {
  1109. $node.find('div.contentApps_comingSoon').remove();
  1110. },
  1111. _renderPromptPicker: function() {
  1112. this.promptPicker = new PromptPicker({
  1113. $toggler: this.$el.find('div[class^="editPromptValues' + this.viewId + ' "]'),
  1114. reportId: this.parentView && this.parentView.objectInfo.id,
  1115. values: this.parameters,
  1116. useValues: this.useParameters !== false,
  1117. glassContext: this.glassContext,
  1118. onFinish: function() {
  1119. this._onEditFinish();
  1120. }.bind(this)
  1121. });
  1122. this.promptPicker.render();
  1123. },
  1124. _onEditFinish: function() {
  1125. this.parameters = this.promptPicker.getParameterValues();
  1126. this.promptDisplayValues = ContentStoreObject.getPromptsDisplayValues(this.parameters);
  1127. var items = this._getPromptItems(this.promptDisplayValues);
  1128. this._getPromptValuesSection().refreshProperties(items);
  1129. if (this.editCallback) {
  1130. this.editCallback(this.parameters);
  1131. }
  1132. this._removeEmptyPaneInfoMessage(this.$el);
  1133. },
  1134. _getPromptValuesSection: function() {
  1135. return this._oPropertyUIControl.getProperty('SectionPromptValues');
  1136. },
  1137. _getPromptItems: function(promptDisplayValues) {
  1138. var items = [];
  1139. if (promptDisplayValues) {
  1140. for (var i = 0; i < promptDisplayValues.length; i = i + 1) {
  1141. items.push({
  1142. 'type': 'Separator'
  1143. });
  1144. var label = _.escape(promptDisplayValues[i].name),
  1145. display = promptDisplayValues[i].display;
  1146. var singleLine = {
  1147. 'type': 'SingleLineValue',
  1148. 'name': label,
  1149. 'label': label,
  1150. 'value': display
  1151. };
  1152. items.push(singleLine);
  1153. }
  1154. }
  1155. return items;
  1156. },
  1157. setFocus: function() {
  1158. this._oPropertyUIControl.setFocus('promptValuesBanner');
  1159. }
  1160. });
  1161. return PromptValuesView;
  1162. });
  1163. /*
  1164. *+------------------------------------------------------------------------+
  1165. *| Licensed Materials - Property of IBM
  1166. *|
  1167. *| IBM Cognos Products: content-apps
  1168. *|
  1169. *| (C) Copyright IBM Corp. 2018
  1170. *|
  1171. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1172. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1173. *+------------------------------------------------------------------------+
  1174. */
  1175. define('bi/content_apps/utils/Utils',[], function() {
  1176. 'use strict';
  1177. var reHtmlEncode = /[<>&]/g;
  1178. var htmlEncode = {
  1179. '&': '&amp;',
  1180. '<': '&lt;',
  1181. '>': '&gt;'
  1182. };
  1183. var reXmlEncode = /[<>&'"]/g;
  1184. var xmlEncode = {
  1185. '&': '&amp;',
  1186. '<': '&lt;',
  1187. '>': '&gt;',
  1188. '\'': '&apos;',
  1189. '"': '&quot;'
  1190. };
  1191. return {
  1192. /**
  1193. * Returns the html encoded version of the given text
  1194. * @param {string} text
  1195. * @return {string}
  1196. */
  1197. htmlEncode: function(text) {
  1198. return (text || '').replace(reHtmlEncode, function(m) {
  1199. return htmlEncode[m];
  1200. });
  1201. },
  1202. /**
  1203. * Returns the xml encoded version of the given text
  1204. * ... according to https://www.ibm.com/support/knowledgecenter/en/SSEP7J_10.2.2/com.ibm.swg.ba.cognos.dg_sdk.10.2.2.doc/r_d15e1241850.html#bibus_xmlEncodedXML
  1205. * @param {string} text
  1206. * @return {string}
  1207. */
  1208. xmlEncode: function(text) {
  1209. if (text || text === 0) {
  1210. return String(text).replace(reXmlEncode, function(m) {
  1211. return xmlEncode[m];
  1212. });
  1213. } else {
  1214. return '';
  1215. }
  1216. }
  1217. };
  1218. });
  1219. /*
  1220. *+------------------------------------------------------------------------+
  1221. *| Licensed Materials - Property of IBM
  1222. *| IBM Cognos Products: Content Explorer
  1223. *| (C) Copyright IBM Corp. 2015, 2018
  1224. *|
  1225. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1226. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1227. *+------------------------------------------------------------------------+
  1228. */
  1229. define('bi/content_apps/PdfOptionsView',[
  1230. 'jquery',
  1231. 'underscore',
  1232. 'bi/content_apps/nls/StringResource',
  1233. 'bi/content_apps/utils/Utils',
  1234. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyPageView',
  1235. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
  1236. 'bacontentnav/utils/GlassContextHelper'
  1237. ], function($, _, StringResource, Utils, PropertyPageView, PropertyUIControl, GlassContextHelper) {
  1238. 'use strict';
  1239. var PdfOptionsView = PropertyPageView.extend({
  1240. /**
  1241. @param options.el {node} - container dom node
  1242. @param options.pdfOptions {array} - PDF options in format same as Content Rest API
  1243. @param options.glassContext {object} - Glass context
  1244. @param options.closeCallback {function} - callback when the view is closed, pass current option values in format same as Content Rest API.
  1245. [{ name : <option name>
  1246. value : <option value>
  1247. type : <option type>
  1248. },...]
  1249. For userPassword and ownerPassword, the format for the value is: '<credential><password>value</password></credential>'
  1250. @param options.showCancel {boolean} - Default is false. If true, 'Cancel' button will be rendered in the banner
  1251. @param options.overlay {boolean} - Default is false. If true, 'Back' button will be rendered in the banner
  1252. **/
  1253. init: function(options) {
  1254. PdfOptionsView.inherited('init', this, arguments);
  1255. _.extend(this, options);
  1256. },
  1257. _getBannerSpec: function() {
  1258. var spec = {
  1259. 'type': 'Banner',
  1260. 'name': 'pdfOptionsBanner',
  1261. 'value': StringResource.get('pdfOptions'),
  1262. 'centerLabel': true,
  1263. 'backButton': this.slideout.overlay,
  1264. 'editable': false,
  1265. 'readOnly': true,
  1266. 'onClose': function() {
  1267. var modifiedProperties = this.getModifiedProperties();
  1268. var isValid = this._validatePasswords(modifiedProperties);
  1269. if (!isValid) {
  1270. GlassContextHelper.displayToast(this.glassContext, StringResource.get('passwordNotMatched'), {
  1271. 'type': 'warning'
  1272. });
  1273. } else {
  1274. this.slideout.hide();
  1275. if (this.closeCallback) {
  1276. var fullPDFOptions = this._getFullPdfOptions(this._getOptions(), modifiedProperties);
  1277. this.closeCallback(fullPDFOptions);
  1278. }
  1279. }
  1280. }.bind(this)
  1281. };
  1282. if (this.showCancel) {
  1283. spec.clickables = [{
  1284. 'type': 'text',
  1285. 'value': StringResource.get('cancel'),
  1286. 'class': 'cancelPdfOptions',
  1287. 'clickCallback': function() {
  1288. this.cancelled = true;
  1289. this.slideout.hide();
  1290. if (this.cancelCallback) {
  1291. this.cancelCallback();
  1292. }
  1293. }.bind(this)
  1294. }];
  1295. }
  1296. return spec;
  1297. },
  1298. render: function() {
  1299. var optionOO = this._getOption(this._getOptions(), 'outputPageOrientation');
  1300. var optionOD = this._getOption(this._getOptions(), 'outputPageDefinition');
  1301. var optionOwnerPassword = this._getOption(this._getOptions(), 'ownerPassword');
  1302. var ownerPasswordValue = this._getPasswordValue(optionOwnerPassword);
  1303. var optionUserPassword = this._getOption(this._getOptions(), 'userPassword');
  1304. var userPasswordValue = this._getPasswordValue(optionUserPassword);
  1305. return this.renderPropertyUIControl({
  1306. 'el': this.$el,
  1307. 'glassContext': this.glassContext,
  1308. 'slideout': this.slideout,
  1309. 'items': [
  1310. this._getBannerSpec(), {
  1311. 'type': 'DropDown',
  1312. 'name': 'outputPageOrientation',
  1313. 'label': StringResource.get('Orientation'),
  1314. 'options': [{
  1315. 'label': StringResource.get('default'),
  1316. 'value': 'default',
  1317. 'selected': optionOO === undefined
  1318. }, {
  1319. 'label': StringResource.get('portrait'),
  1320. 'value': 'portrait',
  1321. 'selected': optionOO && optionOO.value === 'portrait'
  1322. }, {
  1323. 'label': StringResource.get('landscape'),
  1324. 'value': 'landscape',
  1325. 'selected': optionOO && optionOO.value === 'landscape'
  1326. }]
  1327. }, {
  1328. 'type': 'Separator'
  1329. }, {
  1330. 'type': 'DropDown',
  1331. 'name': 'outputPageDefinition',
  1332. 'label': StringResource.get('pageSize'),
  1333. 'options': [{
  1334. 'label': StringResource.get('default'),
  1335. 'value': 'default',
  1336. 'selected': optionOD === undefined
  1337. }, {
  1338. 'label': StringResource.get('letter'),
  1339. 'value': '/configuration/pageDefinition[@name=\'Letter\']',
  1340. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'Letter\']'
  1341. }, {
  1342. 'label': StringResource.get('legal'),
  1343. 'value': '/configuration/pageDefinition[@name=\'Legal\']',
  1344. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'Legal\']'
  1345. }, {
  1346. 'label': StringResource.get('11x17'),
  1347. 'value': '/configuration/pageDefinition[@name=\'11x17\']',
  1348. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'11x17\']'
  1349. }, {
  1350. 'label': StringResource.get('A3'),
  1351. 'value': '/configuration/pageDefinition[@name=\'A3\']',
  1352. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'A3\']'
  1353. }, {
  1354. 'label': StringResource.get('A4'),
  1355. 'value': '/configuration/pageDefinition[@name=\'A4\']',
  1356. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'A4\']'
  1357. }, {
  1358. 'label': StringResource.get('B4JIS'),
  1359. 'value': '/configuration/pageDefinition[@name=\'B4 JIS\']',
  1360. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'B4 JIS\']'
  1361. }, {
  1362. 'label': StringResource.get('B5JIS'),
  1363. 'value': '/configuration/pageDefinition[@name=\'B5 JIS\']',
  1364. 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'B5 JIS\']'
  1365. }]
  1366. }, {
  1367. 'type': 'Separator'
  1368. }, {
  1369. 'name': 'checkboxUserPassword',
  1370. 'checked': optionUserPassword !== undefined,
  1371. 'label': StringResource.get('requiresPasswordToOpenReport'),
  1372. 'type': 'CheckBox',
  1373. 'onChange': function(propertyName, propertyValue) {
  1374. this._passwordCheckOnChange(propertyValue, 'userPassword', 'userPasswordConfirm');
  1375. }.bind(this)
  1376. }, {
  1377. 'name': 'userPassword',
  1378. 'label': StringResource.get('password'),
  1379. 'ariaLabel': StringResource.get('requiresPasswordToOpenReport'),
  1380. 'value': userPasswordValue,
  1381. 'indent': 2,
  1382. 'editable': true,
  1383. 'disabled': optionUserPassword === undefined,
  1384. 'type': 'SingleLineValue',
  1385. 'multiline': true,
  1386. 'inputType': 'password',
  1387. 'showEmptyBorder': true,
  1388. 'highlightTextOnFocus': true
  1389. }, {
  1390. 'name': 'userPasswordConfirm',
  1391. 'label': StringResource.get('confirmPassword'),
  1392. 'ariaLabel': StringResource.get('requiresPasswordToOpenReport') + ' ' + StringResource.get('confirmPassword'),
  1393. 'value': userPasswordValue,
  1394. 'indent': 2,
  1395. 'editable': true,
  1396. 'disabled': optionUserPassword === undefined,
  1397. 'type': 'SingleLineValue',
  1398. 'multiline': true,
  1399. 'inputType': 'password',
  1400. 'showEmptyBorder': true,
  1401. 'highlightTextOnFocus': true
  1402. }, {
  1403. 'type': 'Separator'
  1404. }, {
  1405. 'name': 'checkboxOwnerPassword',
  1406. 'checked': optionOwnerPassword !== undefined,
  1407. 'label': StringResource.get('requiresPasswordToAccessOptions'),
  1408. 'type': 'CheckBox',
  1409. 'onChange': function(propertyName, propertyValue) {
  1410. this._passwordCheckOnChange(propertyValue, 'ownerPassword', 'ownerPasswordConfirm');
  1411. }.bind(this)
  1412. }, {
  1413. 'name': 'ownerPassword',
  1414. 'label': StringResource.get('password'),
  1415. 'ariaLabel': StringResource.get('requiresPasswordToAccessOptions'),
  1416. 'value': ownerPasswordValue,
  1417. 'indent': 2,
  1418. 'editable': true,
  1419. 'disabled': optionOwnerPassword === undefined,
  1420. 'type': 'SingleLineValue',
  1421. 'multiline': true,
  1422. 'inputType': 'password',
  1423. 'showEmptyBorder': true,
  1424. 'highlightTextOnFocus': true
  1425. }, {
  1426. 'name': 'ownerPasswordConfirm',
  1427. 'label': StringResource.get('confirmPassword'),
  1428. 'ariaLabel': StringResource.get('requiresPasswordToAccessOptions') + ' ' + StringResource.get('confirmPassword'),
  1429. 'value': ownerPasswordValue,
  1430. 'indent': 2,
  1431. 'editable': true,
  1432. 'disabled': optionOwnerPassword === undefined,
  1433. 'type': 'SingleLineValue',
  1434. 'multiline': true,
  1435. 'inputType': 'password',
  1436. 'showEmptyBorder': true,
  1437. 'highlightTextOnFocus': true
  1438. }
  1439. ]
  1440. });
  1441. },
  1442. _getPasswordValue: function(option) {
  1443. var passwordValue = '';
  1444. if (!option) {
  1445. return passwordValue;
  1446. }
  1447. if (!this.isEncrypedPassword(option.value)) {
  1448. var pwd = option.value;
  1449. var optionEncrypted = this._createOption(option.name, option.value);
  1450. option.value = optionEncrypted.value;
  1451. return pwd;
  1452. }
  1453. if (option.value.length > 0) {
  1454. var xmlDoc = $.parseXML(option.value);
  1455. var $pwd = $(xmlDoc).find('password');
  1456. if ($pwd.text().length) {
  1457. passwordValue = $pwd.text();
  1458. } else {
  1459. // If the password is encrypted just use a 8 letter string so the password field looks good
  1460. $pwd = $(xmlDoc).find('encryptedValue');
  1461. if ($pwd.text().length) {
  1462. passwordValue = '********';
  1463. }
  1464. }
  1465. }
  1466. return passwordValue;
  1467. },
  1468. _passwordCheckOnChange: function(check, passwordName, passwordConfirmName) {
  1469. var password = this._oPropertyUIControl.getProperty(passwordName);
  1470. var passwordConfirm = this._oPropertyUIControl.getProperty(passwordConfirmName);
  1471. if (check) {
  1472. password.enable();
  1473. passwordConfirm.enable();
  1474. } else {
  1475. password.disable();
  1476. password.setValue('');
  1477. passwordConfirm.disable();
  1478. passwordConfirm.setValue('');
  1479. }
  1480. },
  1481. onClose: function() {
  1482. if (this._oPropertyUIControl) {
  1483. return this._oPropertyUIControl.onClose();
  1484. }
  1485. },
  1486. getModifiedProperties: function() {
  1487. if (this.cancelled) {
  1488. return null;
  1489. }
  1490. if (this._oPropertyUIControl) {
  1491. return this._oPropertyUIControl.getModifiedProperties();
  1492. }
  1493. return null;
  1494. },
  1495. //this method could be optimized..
  1496. _validatePasswords: function(modifiedProperties) {
  1497. if (!modifiedProperties) {
  1498. return true;
  1499. }
  1500. if (modifiedProperties.userPassword || modifiedProperties.userPasswordConfirm) {
  1501. if (modifiedProperties.userPassword !== modifiedProperties.userPasswordConfirm) {
  1502. this._oPropertyUIControl.getProperty('userPassword').getHTMLControl().focus();
  1503. return false;
  1504. }
  1505. }
  1506. if (modifiedProperties.ownerPassword || modifiedProperties.ownerPasswordConfirm) {
  1507. if (modifiedProperties.ownerPassword !== modifiedProperties.ownerPasswordConfirm) {
  1508. this._oPropertyUIControl.getProperty('ownerPassword').getHTMLControl().focus();
  1509. return false;
  1510. }
  1511. }
  1512. if (modifiedProperties.checkboxUserPassword !== undefined) {
  1513. if (modifiedProperties.checkboxUserPassword) {
  1514. if (!modifiedProperties.userPassword || !modifiedProperties.userPasswordConfirm) {
  1515. return false;
  1516. }
  1517. } else {
  1518. if (modifiedProperties.userPassword || modifiedProperties.userPasswordConfirm) {
  1519. return false;
  1520. }
  1521. }
  1522. } else {
  1523. if (modifiedProperties.userPassword !== undefined && !modifiedProperties.userPassword) {
  1524. return false;
  1525. }
  1526. }
  1527. if (modifiedProperties.checkboxOwnerPassword !== undefined) {
  1528. if (modifiedProperties.checkboxOwnerPassword) {
  1529. if (!modifiedProperties.ownerPassword || !modifiedProperties.ownerPasswordConfirm) {
  1530. return false;
  1531. }
  1532. } else {
  1533. if (modifiedProperties.ownerPassword || modifiedProperties.ownerPasswordConfirm) {
  1534. return false;
  1535. }
  1536. }
  1537. } else {
  1538. if (modifiedProperties.ownerPassword !== undefined && !modifiedProperties.ownerPassword) {
  1539. return false;
  1540. }
  1541. }
  1542. return true;
  1543. },
  1544. _setOption: function(optionBlob, option, bDefault) {
  1545. for (var i = 0; i < optionBlob.length; i = i + 1) {
  1546. //if options exists, either modify or remove it
  1547. if (optionBlob[i].name === option.name) {
  1548. if (bDefault) {
  1549. optionBlob.splice(i, 1);
  1550. } else {
  1551. optionBlob[i].value = option.value;
  1552. }
  1553. return;
  1554. }
  1555. }
  1556. if (!bDefault) {
  1557. optionBlob.push(option);
  1558. }
  1559. },
  1560. //get all the selected PDF options in the UI
  1561. _getFullPdfOptions: function(options, modifiedProperties) {
  1562. var result = [];
  1563. options.forEach(function(item) {
  1564. result.push(item);
  1565. });
  1566. if (modifiedProperties) {
  1567. if (modifiedProperties.outputPageDefinition) {
  1568. var optionOutputPageDefinition = this._createOption('outputPageDefinition', modifiedProperties.outputPageDefinition);
  1569. this._setOption(result, optionOutputPageDefinition, modifiedProperties.outputPageDefinition === 'default');
  1570. }
  1571. if (modifiedProperties.outputPageOrientation) {
  1572. var optionOutputPageOrientation = this._createOption('outputPageOrientation', modifiedProperties.outputPageOrientation);
  1573. this._setOption(result, optionOutputPageOrientation, modifiedProperties.outputPageOrientation === 'default');
  1574. }
  1575. if (modifiedProperties.userPassword !== undefined) {
  1576. var optionUserPassword = this._createOption('userPassword', modifiedProperties.userPassword);
  1577. this._setOption(result, optionUserPassword, modifiedProperties.userPassword.length === 0);
  1578. }
  1579. if (modifiedProperties.ownerPassword !== undefined) {
  1580. var optionOwnerPassword = this._createOption('ownerPassword', modifiedProperties.ownerPassword);
  1581. this._setOption(result, optionOwnerPassword, modifiedProperties.ownerPassword.length === 0);
  1582. }
  1583. if (modifiedProperties.checkboxOwnerPassword !== undefined) {
  1584. var checkOptions = this._getCheckOptions(modifiedProperties.checkboxOwnerPassword);
  1585. for (var i = 0; i < checkOptions.length; i = i + 1) {
  1586. this._setOption(result, checkOptions[i], false);
  1587. }
  1588. }
  1589. }
  1590. return result;
  1591. },
  1592. _getOption: function(options, optionName) {
  1593. var option;
  1594. for (var i = 0; i < options.length; i = i + 1) {
  1595. if (options[i].name === optionName) {
  1596. option = options[i];
  1597. break;
  1598. }
  1599. }
  1600. return option;
  1601. },
  1602. _getOptions: function() {
  1603. if (!this.pdfOptions) {
  1604. this.pdfOptions = [];
  1605. }
  1606. return this.pdfOptions;
  1607. },
  1608. _getCheckOptions: function(checkboxOwnerPassword) {
  1609. return [{
  1610. 'name': 'allowPrintQuality',
  1611. 'type': 'pdfOptionPrintQuality',
  1612. 'value': checkboxOwnerPassword ? 'none' : 'lowOrHigh'
  1613. }, {
  1614. 'name': 'allowModifications',
  1615. 'type': 'pdfOptionBoolean',
  1616. 'value': checkboxOwnerPassword ? false : true
  1617. }, {
  1618. 'name': 'allowAnnotations',
  1619. 'type': 'pdfOptionBoolean',
  1620. 'value': checkboxOwnerPassword ? false : true
  1621. },
  1622. {
  1623. 'name': 'allowFieldCompletion',
  1624. 'type': 'pdfOptionBoolean',
  1625. 'value': checkboxOwnerPassword ? false : true
  1626. }, {
  1627. 'name': 'allowAssembly',
  1628. 'type': 'pdfOptionBoolean',
  1629. 'value': checkboxOwnerPassword ? false : true
  1630. }, {
  1631. 'name': 'allowContentCopy',
  1632. 'type': 'pdfOptionBoolean',
  1633. 'value': checkboxOwnerPassword ? false : true
  1634. }, {
  1635. 'name': 'allowAccessibilitySupport',
  1636. 'type': 'pdfOptionBoolean',
  1637. 'value': true
  1638. }];
  1639. },
  1640. // override base functionality of PropertyPageView which closes the slideout
  1641. _canClose: function() {
  1642. return true;
  1643. },
  1644. _createOption: function(name, value) {
  1645. var option;
  1646. if (name === 'outputPageDefinition') {
  1647. option = {
  1648. 'name': 'outputPageDefinition',
  1649. 'type': 'runOptionString',
  1650. 'value': value
  1651. };
  1652. } else if (name === 'outputPageOrientation') {
  1653. option = {
  1654. 'name': 'outputPageOrientation',
  1655. 'type': 'runOptionString',
  1656. 'value': value
  1657. };
  1658. } else if (name === 'userPassword') {
  1659. option = {
  1660. 'name': 'userPassword',
  1661. 'type': 'pdfOptionXMLEncodedXML',
  1662. 'value': '<credential><password>' + Utils.xmlEncode(value) + '</password></credential>'
  1663. };
  1664. } else if (name === 'ownerPassword') {
  1665. option = {
  1666. 'name': 'ownerPassword',
  1667. 'type': 'pdfOptionXMLEncodedXML',
  1668. 'value': '<credential><password>' + Utils.xmlEncode(value) + '</password></credential>'
  1669. };
  1670. }
  1671. return option;
  1672. },
  1673. remove: function() {
  1674. if (!this.slideout.overlay) {
  1675. this.onClose();
  1676. }
  1677. },
  1678. isEncrypedPassword: function(password) {
  1679. var pattValue = /<credential><encryptedValue>.*<\/encryptedValue><\/credential>/;
  1680. var pattPwd = /<credential><password>.*<\/password><\/credential>/;
  1681. return pattValue.test(password) || pattPwd.test(password);
  1682. },
  1683. setFocus: function() {
  1684. if (this.slideout.overlay) {
  1685. this._oPropertyUIControl.setFocus('pdfOptionsBanner');
  1686. } else {
  1687. this._oPropertyUIControl.setFocus('outputPageOrientation');
  1688. }
  1689. }
  1690. });
  1691. return PdfOptionsView;
  1692. });
  1693. /*
  1694. *+------------------------------------------------------------------------+
  1695. *| Licensed Materials - Property of IBM
  1696. *| IBM Cognos Products: Content Explorer
  1697. *| (C) Copyright IBM Corp. 2018
  1698. *|
  1699. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1700. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1701. *+------------------------------------------------------------------------+
  1702. */
  1703. define('bi/content_apps/authoring/AuthoringHelper',[
  1704. 'bacontentnav/utils/ContentStoreObject',
  1705. 'bacontentnav/utils/UIHelper'
  1706. ], function(ContentStoreObject, UIHelper) {
  1707. 'use strict';
  1708. var AuthoringHelper = {
  1709. _getFormatIndex: function(objectInfo) {
  1710. var objectFormatType = AuthoringHelper._getObjectType(objectInfo);
  1711. if (AuthoringHelper.SUPPORTED_FORMATS[objectFormatType]) {
  1712. return objectFormatType;
  1713. }
  1714. return 'all';
  1715. },
  1716. _getObjectType: function(objectInfo) {
  1717. var objectType = ContentStoreObject.getType(objectInfo);
  1718. if (objectType === 'powerPlay8ReportView') {
  1719. return 'powerPlay8Report';
  1720. } else {
  1721. var baseTypes = UIHelper.getBaseTypes(objectType);
  1722. if (baseTypes && baseTypes.length > 0) {
  1723. return ContentStoreObject.getBase(objectInfo) && ContentStoreObject.getBase(objectInfo).type || objectType;
  1724. }
  1725. }
  1726. return objectType;
  1727. },
  1728. setReportType: function(requestParams, objectInfo) {
  1729. if (AuthoringHelper._getObjectType(objectInfo) === 'powerPlay8Report') {
  1730. requestParams.reportType = 'powerPlay8Report';
  1731. }
  1732. },
  1733. getSupportedFormats: function(objectInfo) {
  1734. return AuthoringHelper.SUPPORTED_FORMATS[AuthoringHelper._getFormatIndex(objectInfo)];
  1735. },
  1736. userCanGenerateFormat: function(glassContext, format) {
  1737. var capability = AuthoringHelper.FORMAT_CAPABILITY_MAP[format];
  1738. return (capability) ? glassContext.hasCapability(capability) : true;
  1739. }
  1740. };
  1741. AuthoringHelper.SUPPORTED_FORMATS = {
  1742. 'all': ['spreadsheetML', 'xlsxData', 'PDF', 'HTML', 'CSV', 'XML'],
  1743. 'interactiveReport': ['HTML'],
  1744. 'powerPlay8Report': ['PDF']
  1745. };
  1746. AuthoringHelper.FORMAT_CAPABILITY_MAP = {
  1747. 'HTML': null,
  1748. 'PDF': 'canGeneratePDFOutput',
  1749. 'spreadsheetML': 'canGenerateXLSOutput',
  1750. 'xlsxData': 'canGenerateXLSOutput',
  1751. 'CSV': 'canGenerateCSVOutput',
  1752. 'XML': 'canGenerateXMLOutput'
  1753. };
  1754. AuthoringHelper.FORMAT_MESSAGE_KEY_MAP = {
  1755. 'HTML': 'html',
  1756. 'PDF': 'pdf',
  1757. 'spreadsheetML': 'spreadsheetML',
  1758. 'xlsxData': 'xlsxData',
  1759. 'CSV': 'csv',
  1760. 'XML': 'xml'
  1761. };
  1762. return AuthoringHelper;
  1763. });
  1764. /*
  1765. *+------------------------------------------------------------------------+
  1766. *| Licensed Materials - Property of IBM
  1767. *| IBM Cognos Products: Content Explorer
  1768. *| (C) Copyright IBM Corp. 2016, 2022
  1769. *|
  1770. *| US Government Users Restricted Rights - Use, duplication or disclosure
  1771. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  1772. *+------------------------------------------------------------------------+
  1773. */
  1774. define('bi/content_apps/PropertiesReportTab',[
  1775. 'bi/content_apps/PropertiesTab',
  1776. 'bi/content_apps/utils/C10Utils',
  1777. 'bi/content_apps/nls/StringResource',
  1778. 'bacontentnav/utils/ContentStoreObject',
  1779. 'bacontentnav/utils/GlassContextHelper',
  1780. 'bi/content_apps/PromptValuesView',
  1781. 'bi/content_apps/PdfOptionsView',
  1782. 'underscore',
  1783. 'bi/content_apps/authoring/AuthoringHelper'
  1784. ], function(PropertiesTab, C10Utils, StringResource, ContentStoreObject, GlassContextHelper, PromptValuesView, PdfOptionsView, _, AuthoringHelper) {
  1785. 'use strict';
  1786. var PropertiesReportTab = PropertiesTab.extend({
  1787. ACTION_VIEW: 'viewOutput',
  1788. ACTION_RUN: 'run',
  1789. ACTION_EDIT: 'edit',
  1790. RUNASOWNER: 'runAsOwnerRadio',
  1791. pdfOptionNames: ['outputPageDefinition', 'outputPageOrientation', 'userPassword', 'ownerPassword', 'allowPrintQuality',
  1792. 'allowModifications', 'allowAnnotations', 'allowFieldCompletion', 'allowAssembly', 'allowContentCopy', 'allowAccessibilitySupport'
  1793. ],
  1794. /**
  1795. @param options.el {node} - container dom node
  1796. **/
  1797. init: function(options) {
  1798. PropertiesReportTab.inherited('init', this, arguments);
  1799. _.extend(this, options);
  1800. this._getPdfOptions();
  1801. },
  1802. render: function() {
  1803. return new Promise(function(resolve /*, reject*/ ) {
  1804. this._id = _.uniqueId('prop_');
  1805. var items = [];
  1806. var reportOptionItems = [this._getFormatSpec(), {
  1807. 'type': 'Separator',
  1808. 'indent': 2
  1809. }];
  1810. if (this.objectInfo.type.indexOf('powerPlay8Report') === -1) {
  1811. reportOptionItems.push({
  1812. 'name': 'setPdfOptions',
  1813. 'label': StringResource.get('pdfOptions'),
  1814. 'value': StringResource.get('set'),
  1815. 'indent': 2,
  1816. 'type': 'SingleLineValue',
  1817. 'ellipses': true,
  1818. 'editCallback': function() {
  1819. this._openPdfOptionsView();
  1820. }.bind(this)
  1821. }, {
  1822. 'type': 'Separator',
  1823. 'indent': 2
  1824. });
  1825. }
  1826. return this._getLanguages()
  1827. .then(function(languages) {
  1828. reportOptionItems.push({
  1829. 'type': 'DropDown',
  1830. 'name': ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES,
  1831. 'label': StringResource.get('enableAccessibilitySupport'),
  1832. 'indent': 2,
  1833. 'options': [{
  1834. 'label': StringResource.get('default'),
  1835. 'value': null,
  1836. 'selected': this._getEnableAccessibilitySupport() === null
  1837. }, {
  1838. 'label': StringResource.get('True'),
  1839. 'value': true,
  1840. 'selected': this._getEnableAccessibilitySupport() === true
  1841. }, {
  1842. 'label': StringResource.get('False'),
  1843. 'value': false,
  1844. 'selected': this._getEnableAccessibilitySupport() === false
  1845. }]
  1846. }, {
  1847. 'type': 'Separator',
  1848. 'indent': 2
  1849. }, {
  1850. 'type': 'DropDown',
  1851. 'name': ContentStoreObject.OPTION_OUTPUT_LOCALE,
  1852. 'label': StringResource.get('language'),
  1853. 'indent': 2,
  1854. 'options': languages,
  1855. 'position': 'left',
  1856. 'parentEl': this.slideout.$el
  1857. }, {
  1858. 'type': 'Separator',
  1859. 'indent': 2
  1860. });
  1861. items.push({
  1862. 'name': 'package',
  1863. 'label': StringResource.get('source'),
  1864. 'value': this._getPackageOrModule(),
  1865. 'type': 'SingleLineValue'
  1866. });
  1867. items.push({
  1868. 'name': 'promptValues',
  1869. 'label': StringResource.get('promptValues'),
  1870. 'type': 'SectionLabel'
  1871. });
  1872. items.push({
  1873. 'name': 'executionPrompt',
  1874. 'checked': this._getPromptValue(),
  1875. 'label': StringResource.get('executionPrompt'),
  1876. 'type': 'CheckBox'
  1877. });
  1878. items.push({
  1879. 'type': 'Separator'
  1880. });
  1881. items.push({
  1882. 'name': 'currentPromptValues',
  1883. 'label': StringResource.get('currentValues'),
  1884. 'value': this._getPromptValueLabel(),
  1885. 'type': 'SingleLineValue',
  1886. 'ellipses': true,
  1887. 'editCallback': function() {
  1888. this._openPromptsValuesView();
  1889. }.bind(this)
  1890. });
  1891. items.push({
  1892. 'type': 'Separator'
  1893. });
  1894. items.push({
  1895. 'type': 'CollapsibleSection',
  1896. 'label': StringResource.get('reportOptions'),
  1897. 'open': false,
  1898. 'name': 'reportOptions',
  1899. 'items': reportOptionItems
  1900. });
  1901. return this._getAdvancedItems()
  1902. .then(function(advancedItems) {
  1903. items.push({
  1904. 'type': 'CollapsibleSection',
  1905. 'name': 'advancedReportProperties',
  1906. 'label': StringResource.get('advancedProperties'),
  1907. 'items': advancedItems
  1908. });
  1909. this.renderPropertyUIControl({
  1910. 'el': this.$el,
  1911. 'glassContext': this.glassContext,
  1912. 'readOnly': !ContentStoreObject.hasPermissions(this.objectInfo, ['write']),
  1913. 'items': items
  1914. }).then(function() {
  1915. resolve(this);
  1916. }.bind(this));
  1917. }.bind(this));
  1918. }.bind(this));
  1919. }.bind(this));
  1920. },
  1921. onClose: function() {
  1922. this._closePdfOptionView();
  1923. if(this.getPropertyUIControl() === undefined){
  1924. return this.renderPropertyUIControl().then(function() {
  1925. return this.getPropertyUIControl().onClose();
  1926. }.bind(this));
  1927. }
  1928. return this.getPropertyUIControl().onClose();
  1929. },
  1930. getModifiedProperties: function() {
  1931. var modifiedProperties = {};
  1932. var modifiedPropertiesUI = this.getPropertyUIControl().getModifiedProperties();
  1933. //deal with run as owner property
  1934. this._getModifiedRunAsOwner(modifiedProperties, modifiedPropertiesUI);
  1935. //deal with report options
  1936. this._getModifiedOptions(modifiedProperties, modifiedPropertiesUI);
  1937. //deal with history/output version settings
  1938. this._getModifiedRetentions(modifiedProperties, modifiedPropertiesUI);
  1939. _.extend(modifiedProperties, modifiedPropertiesUI);
  1940. this.logger.debug('PropertiesReportTab.getModifiedProperties', modifiedProperties);
  1941. return modifiedProperties;
  1942. },
  1943. _getFormatSpec: function() {
  1944. var formatSpec;
  1945. if (this.objectInfo.type === 'interactiveReport') {
  1946. formatSpec = {
  1947. 'type': 'SingleLineLinks',
  1948. 'indent': 2,
  1949. 'items': [{
  1950. 'align': 'left',
  1951. 'items': [{
  1952. 'type': 'text',
  1953. 'value': StringResource.get('format')
  1954. }]
  1955. }, {
  1956. 'align': 'right',
  1957. 'items': [{
  1958. 'type': 'text',
  1959. 'value': StringResource.get('html')
  1960. }]
  1961. }]
  1962. };
  1963. } else if (C10Utils.isPowerPlay(this.objectInfo.type)) {
  1964. formatSpec = {
  1965. 'type': 'SingleLineLinks',
  1966. 'indent': 2,
  1967. 'items': [{
  1968. 'align': 'left',
  1969. 'items': [{
  1970. 'type': 'text',
  1971. 'value': StringResource.get('format')
  1972. }]
  1973. }, {
  1974. 'align': 'right',
  1975. 'items': [{
  1976. 'type': 'text',
  1977. 'value': StringResource.get('pdf')
  1978. }]
  1979. }]
  1980. };
  1981. } else {
  1982. formatSpec = {
  1983. 'type': 'DropDown',
  1984. 'name': ContentStoreObject.OPTION_OUTPUT_FORMAT,
  1985. 'label': StringResource.get('format'),
  1986. 'indent': 2,
  1987. 'options': [{
  1988. 'label': StringResource.get('default'),
  1989. 'value': '',
  1990. 'selected': this._getOutputFormat() === null
  1991. }]
  1992. };
  1993. var supportedFormats = AuthoringHelper.getSupportedFormats(this.objectInfo);
  1994. supportedFormats.forEach(function(format) {
  1995. formatSpec.options.push({
  1996. 'label': StringResource.get(AuthoringHelper.FORMAT_MESSAGE_KEY_MAP[format]),
  1997. 'value': format,
  1998. 'selected': this._getOutputFormat() === format
  1999. });
  2000. }.bind(this));
  2001. }
  2002. return formatSpec;
  2003. },
  2004. _getAdvancedItems: function() {
  2005. return new Promise(function(resolve /*, reject*/ ) {
  2006. var advancedItems = [{
  2007. 'type': 'SingleLineLinks',
  2008. 'name': 'sectionRunHistory',
  2009. 'items': [{
  2010. 'align': 'left',
  2011. 'items': [{
  2012. 'labelFor': 'runHistory',
  2013. 'type': 'text',
  2014. 'value': StringResource.get('runHistory')
  2015. }]
  2016. }, {
  2017. 'align': 'right',
  2018. 'items': [{
  2019. 'type': 'Input',
  2020. 'name': 'runHistory',
  2021. 'ellipses': false,
  2022. 'inputClass': 'narrowInput',
  2023. 'value': this._getRetentionValue('history'),
  2024. 'validator': {
  2025. 'isNumber': true
  2026. }
  2027. }, {
  2028. 'type': 'DropDown',
  2029. 'name': 'runHistoryUnit',
  2030. 'ariaLabel': StringResource.get('runHistoryUnits'),
  2031. 'options': [{
  2032. 'label': StringResource.get('occurrences'),
  2033. 'value': 'occurrences',
  2034. 'selected': 'occurrences' === this._getRetentionUnit('history')
  2035. }, {
  2036. 'label': StringResource.get('days'),
  2037. 'value': 'days',
  2038. 'selected': 'days' === this._getRetentionUnit('history')
  2039. }, {
  2040. 'label': StringResource.get('months'),
  2041. 'value': 'months',
  2042. 'selected': 'months' === this._getRetentionUnit('history')
  2043. }]
  2044. }]
  2045. }]
  2046. }, {
  2047. 'type': 'Separator'
  2048. }, {
  2049. 'type': 'SingleLineLinks',
  2050. 'name': 'sectionReportVersion',
  2051. 'items': [{
  2052. 'align': 'left',
  2053. 'items': [{
  2054. 'labelFor': 'reportVersion',
  2055. 'type': 'text',
  2056. 'value': StringResource.get('reportOutputVersions')
  2057. }]
  2058. }, {
  2059. 'align': 'right',
  2060. 'items': [{
  2061. 'type': 'Input',
  2062. 'name': 'reportVersion',
  2063. 'ellipses': false,
  2064. 'inputClass': 'narrowInput',
  2065. 'value': this._getRetentionValue('reportVersion'),
  2066. 'validator': {
  2067. 'isNumber': true
  2068. }
  2069. }, {
  2070. 'type': 'DropDown',
  2071. 'name': 'reportVersionUnit',
  2072. 'ariaLabel': StringResource.get('reportOutputVersionsUnits'),
  2073. 'options': [{
  2074. 'label': StringResource.get('occurrences'),
  2075. 'value': 'occurrences',
  2076. 'selected': 'occurrences' === this._getRetentionUnit('reportVersion')
  2077. }, {
  2078. 'label': StringResource.get('days'),
  2079. 'value': 'days',
  2080. 'selected': 'days' === this._getRetentionUnit('reportVersion')
  2081. }, {
  2082. 'label': StringResource.get('months'),
  2083. 'value': 'months',
  2084. 'selected': 'months' === this._getRetentionUnit('reportVersion')
  2085. }]
  2086. }]
  2087. }]
  2088. }];
  2089. if (this.objectInfo.type) {
  2090. advancedItems.push({
  2091. 'type': 'Separator'
  2092. });
  2093. advancedItems.push(this._getDefaultActionSpec());
  2094. }
  2095. if (ContentStoreObject.getType(this.objectInfo).indexOf('powerPlay8Report') === -1) {
  2096. advancedItems.push({
  2097. 'type': 'Separator'
  2098. }, {
  2099. 'type': 'DropDown',
  2100. 'name': 'verticalElements', // name must match cm's option name for update to work
  2101. 'label': StringResource.get('rowsPerPageHtmlReport'),
  2102. 'options': [{
  2103. 'label': StringResource.get('default'),
  2104. 'value': 'null',
  2105. 'selected': this._getRowsPerPageHtmlReport() === 'null'
  2106. }, {
  2107. 'label': '4',
  2108. 'value': '4',
  2109. 'selected': this._getRowsPerPageHtmlReport() === 4
  2110. }, {
  2111. 'label': '5',
  2112. 'value': '5',
  2113. 'selected': this._getRowsPerPageHtmlReport() === 5
  2114. }, {
  2115. 'label': '8',
  2116. 'value': '8',
  2117. 'selected': this._getRowsPerPageHtmlReport() === 8
  2118. }, {
  2119. 'label': '10',
  2120. 'value': '10',
  2121. 'selected': this._getRowsPerPageHtmlReport() === 10
  2122. }, {
  2123. 'label': '12',
  2124. 'value': '12',
  2125. 'selected': this._getRowsPerPageHtmlReport() === 12
  2126. }, {
  2127. 'label': '16',
  2128. 'value': '16',
  2129. 'selected': this._getRowsPerPageHtmlReport() === 16
  2130. }, {
  2131. 'label': '20',
  2132. 'value': '20',
  2133. 'selected': this._getRowsPerPageHtmlReport() === 20
  2134. }, {
  2135. 'label': '50',
  2136. 'value': '50',
  2137. 'selected': this._getRowsPerPageHtmlReport() === 50
  2138. }, {
  2139. 'label': '100',
  2140. 'value': '100',
  2141. 'selected': this._getRowsPerPageHtmlReport() === 100
  2142. }, {
  2143. 'label': '200',
  2144. 'value': '200',
  2145. 'selected': this._getRowsPerPageHtmlReport() === 200
  2146. }, {
  2147. 'label': '500',
  2148. 'value': '500',
  2149. 'selected': this._getRowsPerPageHtmlReport() === 500
  2150. }, {
  2151. 'label': '1000',
  2152. 'value': '1000',
  2153. 'selected': this._getRowsPerPageHtmlReport() === 1000
  2154. }]
  2155. });
  2156. advancedItems.push({
  2157. 'name': 'selectionBasedFeatures',
  2158. 'label': StringResource.get('selectionBasedFeatures'),
  2159. 'checked': ContentStoreObject.getOptionValue(this.objectInfo, ContentStoreObject.OPTION_SELECTION_BASED_FEATURES, true),
  2160. 'type': 'CheckBox'
  2161. }, {
  2162. 'name': 'allowNotification',
  2163. 'label': StringResource.get('allowNotifications'),
  2164. 'checked': ContentStoreObject.getAllowNotification(this.objectInfo),
  2165. 'type': 'CheckBox'
  2166. }, {
  2167. 'name': 'advancedOutput',
  2168. 'label': StringResource.get('advancedOutput'),
  2169. 'checked': ContentStoreObject.getOptionValue(this.objectInfo, ContentStoreObject.OPTION_ENABLE_USER_FEATURE_SAVED_OUTPUT, false),
  2170. 'type': 'CheckBox'
  2171. });
  2172. }
  2173. //if the type is any of the powerplay types
  2174. //then need to add the pp options...
  2175. if (ContentStoreObject.getType(this.objectInfo) === 'powerPlay8Report') {
  2176. advancedItems.push({
  2177. 'type': 'Separator'
  2178. }, {
  2179. 'name': 'powerPlay8ReportTab',
  2180. 'type': 'SingleLineLinks',
  2181. 'items': [{
  2182. 'align': 'left',
  2183. 'items': [{
  2184. 'type': 'text',
  2185. 'value': StringResource.get('powerPlay8Report')
  2186. }]
  2187. }, {
  2188. 'align': 'right',
  2189. 'items': [{
  2190. 'type': 'text',
  2191. 'value': StringResource.get('SetExternalRespostoryLabel'),
  2192. 'clickCallback': this._setPowerPlay8ReportOptions.bind(this)
  2193. }]
  2194. }]
  2195. });
  2196. }
  2197. /*
  2198. * If current user does not have permissions to view
  2199. * this property, we don't show runAs options
  2200. */
  2201. return this._getRunAsOwnerInfo()
  2202. .then(function(runAsOwnerValue) {
  2203. if (runAsOwnerValue) {
  2204. advancedItems.push({
  2205. 'type': 'Separator'
  2206. },{
  2207. 'name': 'runAsOwnerLabel',
  2208. 'label': StringResource.get('run'),
  2209. 'type': 'SectionLabel'
  2210. });
  2211. advancedItems.push({
  2212. 'type': 'RadioButtonGroup',
  2213. 'name': this.RUNASOWNER,
  2214. 'value': runAsOwnerValue,
  2215. 'ariaLabel': StringResource.get('run'),
  2216. 'items': [{
  2217. 'label': StringResource.get('runAsUser'),
  2218. 'value': ContentStoreObject.RUN_AS_USER
  2219. }, {
  2220. 'label': StringResource.get('runWithOwnerCapabilities'),
  2221. 'value': ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES
  2222. }, {
  2223. 'label': StringResource.get('runAsOwner', {
  2224. 'ownerName': ContentStoreObject.getOwnerName(this.objectInfo)
  2225. }),
  2226. 'value': ContentStoreObject.RUN_AS_OWNER
  2227. }]
  2228. });
  2229. }
  2230. }.bind(this), function() {})
  2231. .finally(function() {
  2232. resolve(advancedItems);
  2233. });
  2234. }.bind(this));
  2235. },
  2236. _setPowerPlay8ReportOptions: function() {
  2237. C10Utils.openC10Morphlet(C10Utils.morphletMap.propPP8, this.objectInfo.type, this.objectInfo.id);
  2238. },
  2239. _getRunAsOwnerInfo: function() {
  2240. return new Promise(function(resolve, reject) {
  2241. var owner = ContentStoreObject.getOwnerSelfLink(this.objectInfo);
  2242. if (owner) {
  2243. this.glassContext.services.ajax.ajax({
  2244. 'dataType': 'json',
  2245. 'type': 'GET',
  2246. 'url': owner + '/items?fields=permissions&types=credential'
  2247. }).then(function(response) {
  2248. if (response.data.length > 0 && (ContentStoreObject.hasPermissions(response.data[0], ['execute']) ||
  2249. ContentStoreObject.hasPermissions(response.data[0], ['read']))) {
  2250. resolve(ContentStoreObject.getRunAsOwnerValue(this.objectInfo));
  2251. } else {
  2252. reject(new Error());
  2253. }
  2254. }.bind(this));
  2255. } else {
  2256. // no owner info
  2257. reject(new Error());
  2258. }
  2259. }.bind(this));
  2260. },
  2261. _getOutputFormat: function() {
  2262. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_FORMAT);
  2263. },
  2264. _getOutputLocale: function() {
  2265. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_LOCALE);
  2266. },
  2267. _getEnableAccessibilitySupport: function() {
  2268. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES);
  2269. },
  2270. _getReportOptions: function() {
  2271. return ContentStoreObject.getOptions(this.objectInfo);
  2272. },
  2273. _getLanguages: function() {
  2274. return new Promise(function(resolve /*, reject*/ ) {
  2275. var outputLocale = this._getOutputLocale() ? this._getOutputLocale() : '';
  2276. var languages = [{
  2277. 'value': '',
  2278. 'label': StringResource.get('default'),
  2279. 'selected': '' === outputLocale
  2280. }];
  2281. if (this.glassContext) {
  2282. return GlassContextHelper.getContentLocales(this.glassContext)
  2283. .then(function(items) {
  2284. for (var item in items) {
  2285. if (items.hasOwnProperty(item)) {
  2286. languages.push({
  2287. value: item,
  2288. label: items[item],
  2289. selected: item === outputLocale
  2290. });
  2291. }
  2292. }
  2293. resolve(languages);
  2294. });
  2295. } else {
  2296. resolve(languages);
  2297. }
  2298. }.bind(this));
  2299. },
  2300. _getPackageOrModule: function() {
  2301. // a report can be built on either a data module or a package, for a report view, you need to go into the base
  2302. var source = ContentStoreObject.getMetadataModelPackage(this.objectInfo) ||
  2303. ContentStoreObject.getModule(this.objectInfo) ||
  2304. ContentStoreObject.getBaseMetadataModelPackage(this.objectInfo) ||
  2305. ContentStoreObject.getBaseModule(this.objectInfo);
  2306. return source && ContentStoreObject.getName(source) || StringResource.get('unavailable');
  2307. },
  2308. _getModifiedRunAsOwner: function(modifiedProperties, modifiedPropertiesUI) {
  2309. var runAsOwnerBlob = {};
  2310. var optionModified = false;
  2311. if (modifiedPropertiesUI.hasOwnProperty(this.RUNASOWNER)) {
  2312. runAsOwnerBlob[ContentStoreObject.RUN_AS_OWNER] = false;
  2313. runAsOwnerBlob[ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES] = false;
  2314. switch (modifiedPropertiesUI[this.RUNASOWNER]) {
  2315. case ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES:
  2316. runAsOwnerBlob[ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES] = true;
  2317. break;
  2318. case ContentStoreObject.RUN_AS_OWNER:
  2319. runAsOwnerBlob[ContentStoreObject.RUN_AS_OWNER] = true;
  2320. break;
  2321. }
  2322. delete modifiedPropertiesUI[this.RUNASOWNER];
  2323. optionModified = true;
  2324. }
  2325. if (optionModified) {
  2326. _.extend(modifiedProperties, runAsOwnerBlob);
  2327. }
  2328. },
  2329. _getModifiedOptions: function(modifiedProperties, modifiedPropertiesUI) {
  2330. var optionBlob = this._getReportOptions();
  2331. var optionModified = false;
  2332. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_FORMAT)) {
  2333. var modifiedValue = modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
  2334. modifiedProperties.executionFormat = modifiedValue;
  2335. var optionFormat = {};
  2336. //convert property to option
  2337. optionFormat.name = ContentStoreObject.OPTION_OUTPUT_FORMAT;
  2338. optionFormat.type = 'runOptionStringArray';
  2339. optionFormat.value = [modifiedValue];
  2340. this._setReportOption(optionBlob, optionFormat, optionFormat.value[0] === '');
  2341. delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
  2342. optionModified = true;
  2343. }
  2344. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.EXECUTION_PROMPT)) {
  2345. var isPowerPlay = C10Utils.isPowerPlay(this.objectInfo.type);
  2346. var optionPrompt = {};
  2347. optionPrompt.name = ContentStoreObject.OPTION_PROMPT;
  2348. optionPrompt.type = isPowerPlay ? 'powerPlay8OptionBoolean' : 'runOptionBoolean';
  2349. optionPrompt.value = !!modifiedPropertiesUI.executionPrompt;
  2350. this._setReportOption(optionBlob, optionPrompt);
  2351. optionModified = true;
  2352. }
  2353. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_SELECTION_BASED_FEATURES)) {
  2354. this._setAdvancedOption(optionBlob, ContentStoreObject.OPTION_SELECTION_BASED_FEATURES, 'runOptionBoolean', !!modifiedPropertiesUI.selectionBasedFeatures, true);
  2355. delete modifiedPropertiesUI[ContentStoreObject.OPTION_SELECTION_BASED_FEATURES];
  2356. optionModified = true;
  2357. }
  2358. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ENABLE_ALLOW_NOTIFICATION)) {
  2359. optionModified = true;
  2360. }
  2361. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ENABLE_USER_FEATURE_SAVED_OUTPUT)) {
  2362. this._setAdvancedOption(optionBlob, ContentStoreObject.OPTION_ENABLE_USER_FEATURE_SAVED_OUTPUT, 'runOptionBoolean', !!modifiedPropertiesUI.advancedOutput, false);
  2363. optionModified = true;
  2364. }
  2365. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_LOCALE)) {
  2366. var optionLocale = {};
  2367. var value = modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
  2368. modifiedProperties.executionLocale = value;
  2369. optionLocale.name = ContentStoreObject.OPTION_OUTPUT_LOCALE;
  2370. optionLocale.type = 'runOptionLanguageArray';
  2371. optionLocale.value = [value];
  2372. this._setReportOption(optionBlob, optionLocale, optionLocale.value[0] === '');
  2373. delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
  2374. optionModified = true;
  2375. }
  2376. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES)) {
  2377. var optionAF = {};
  2378. optionAF.name = ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES;
  2379. optionAF.type = 'genericOptionBoolean';
  2380. optionAF.value = modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
  2381. this._setReportOption(optionBlob, optionAF, optionAF.value === 'null' || optionAF.value === '');
  2382. delete modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
  2383. optionModified = true;
  2384. }
  2385. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE)) {
  2386. var optionRowsPerPageInHtml = {};
  2387. //convert property to option
  2388. optionRowsPerPageInHtml.name = ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE;
  2389. optionRowsPerPageInHtml.type = 'runOptionInt';
  2390. optionRowsPerPageInHtml.value = modifiedPropertiesUI[ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE];
  2391. this._setReportOption(optionBlob, optionRowsPerPageInHtml, optionRowsPerPageInHtml.value === 'null');
  2392. delete modifiedPropertiesUI[ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE];
  2393. optionModified = true;
  2394. }
  2395. // PDF options
  2396. if (this._isPdfOptionsModified(optionBlob, this.pdfOptions)) {
  2397. optionModified = true;
  2398. optionBlob = this._getModifiedPdfOptions(optionBlob, this.pdfOptions);
  2399. }
  2400. //option blob
  2401. if (optionModified) {
  2402. _.extend(modifiedProperties, {
  2403. 'options': optionBlob
  2404. });
  2405. }
  2406. },
  2407. _getParameters: function() {
  2408. return ContentStoreObject.getParameters(this.objectInfo);
  2409. },
  2410. _getPromptValueLabel: function() {
  2411. var parameters = this._getParameters();
  2412. if (parameters && parameters.length > 0) {
  2413. return parameters.length + ' ' + StringResource.get('numOfPromptValues');
  2414. }
  2415. return StringResource.get('setValues');
  2416. },
  2417. _openPromptsValuesView: function() {
  2418. if (C10Utils.isPowerPlay(this.objectInfo.type)) {
  2419. C10Utils.openC10Morphlet(C10Utils.morphletMap.runOptsPP8, this.objectInfo.type, this.objectInfo.id, [{
  2420. setPrompts: 'true'
  2421. }]);
  2422. } else {
  2423. this.glassContext.appController.showSlideOut({
  2424. 'label': StringResource.get('promptValues'),
  2425. 'position': this.slideout ? null : 'left',
  2426. 'overlay': true,
  2427. 'parent': this.slideout,
  2428. 'width': '400',
  2429. 'content': {
  2430. 'module': PromptValuesView,
  2431. 'parentView': this,
  2432. 'glassContext': this.glassContext,
  2433. 'promptDisplayValues': ContentStoreObject.getPromptsDisplayValues(this._getParameters()),
  2434. 'parameters': [],
  2435. 'useParameters': false,
  2436. 'clearCallback': function() {
  2437. if (this._getParameters().length > 0) {
  2438. this._setPrompts();
  2439. }
  2440. }.bind(this),
  2441. 'editCallback': function(parameters) {
  2442. this._setPrompts(parameters);
  2443. }.bind(this)
  2444. }
  2445. });
  2446. }
  2447. },
  2448. _setPrompts: function(prompts) {
  2449. var data;
  2450. if (prompts === undefined || prompts === null || prompts.length === 0) {
  2451. this.objectInfo.parameters = [];
  2452. data = {
  2453. 'parameters': [],
  2454. 'type': 'report'
  2455. };
  2456. } else {
  2457. this.objectInfo.parameters = prompts;
  2458. data = {
  2459. 'parameters': prompts,
  2460. 'type': 'report'
  2461. };
  2462. }
  2463. this.slideout.contentView._directSave(data);
  2464. //update number of prompts
  2465. var numOfPromptsLabel = this.getPropertyUIControl().getProperty('currentPromptValues');
  2466. numOfPromptsLabel.setValue(this._getPromptValueLabel());
  2467. },
  2468. _getRowsPerPageHtmlReport: function() {
  2469. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE);
  2470. },
  2471. _getPdfOptions: function() {
  2472. if (this.pdfOptions) {
  2473. return this.pdfOptions;
  2474. }
  2475. this.pdfOptions = [];
  2476. var reportOptions = this._getReportOptions();
  2477. reportOptions.forEach(function(option) {
  2478. if (this._isPdfOption(option)) {
  2479. var clonedObj = {
  2480. 'name': option.name,
  2481. 'type': option.type,
  2482. 'value': option.value
  2483. };
  2484. this.pdfOptions.push(clonedObj);
  2485. }
  2486. }.bind(this));
  2487. return this.pdfOptions;
  2488. },
  2489. _getOption: function(options, name) {
  2490. if (options) {
  2491. for (var i = 0; i < options.length; i = i + 1) {
  2492. if (options[i].name === name) {
  2493. return options[i];
  2494. }
  2495. }
  2496. }
  2497. return null;
  2498. },
  2499. _isPdfOptionsModified: function(optionBlob, pdfOptions) {
  2500. if (pdfOptions) {
  2501. for (var i = 0; i < pdfOptions.length; i = i + 1) {
  2502. var optionFromBlob = this._getOption(optionBlob, pdfOptions[i].name);
  2503. if (!optionFromBlob || optionFromBlob.value !== pdfOptions[i].value) {
  2504. return true;
  2505. }
  2506. }
  2507. }
  2508. if (optionBlob) {
  2509. for (var j = 0; j < optionBlob.length; j = j + 1) {
  2510. var option = optionBlob[j];
  2511. if (this._isPdfOption(option)) {
  2512. var optionPdf = this._getOption(pdfOptions, option.name);
  2513. if (!optionPdf || optionPdf.value !== option.value) {
  2514. return true;
  2515. }
  2516. }
  2517. }
  2518. }
  2519. return false;
  2520. },
  2521. _getModifiedPdfOptions: function(optionBlob, pdfOptions) {
  2522. var newBlob = [];
  2523. for (var i = 0; i < optionBlob.length; i = i + 1) {
  2524. if (!this._isPdfOption(optionBlob[i]) && this.pdfOptionNames.indexOf(optionBlob[i].name) === -1) {
  2525. newBlob.push(optionBlob[i]);
  2526. }
  2527. }
  2528. return newBlob.concat(pdfOptions);
  2529. },
  2530. _closePdfOptionView: function() {
  2531. if (this.pdfOptionView && this.pdfOptionView.contentView) {
  2532. this.pdfOptionView.contentView.onClose();
  2533. this.pdfOptionView.hide();
  2534. this.pdfOptionView = null;
  2535. }
  2536. },
  2537. _openPdfOptionsView: function() {
  2538. this.pdfOptionView = this.glassContext.appController.showSlideOut({
  2539. 'label': StringResource.get('pdfOptions'),
  2540. 'position': 'left',
  2541. 'width': '400',
  2542. 'parent': this.slideout,
  2543. 'overlay': true,
  2544. 'content': {
  2545. 'module': PdfOptionsView,
  2546. 'parentView': this,
  2547. 'pdfOptions': this._getPdfOptions(),
  2548. 'glassContext': this.glassContext,
  2549. 'showCancel': false,
  2550. 'closeCallback': function(data) {
  2551. if (data) {
  2552. this.pdfOptions = [];
  2553. _.extend(this.pdfOptions, data);
  2554. }
  2555. }.bind(this)
  2556. }
  2557. });
  2558. },
  2559. _isPdfOption: function(option) {
  2560. if (option && this.pdfOptionNames.indexOf(option.name) !== -1) {
  2561. //For report imported without upgrade, option allowAnnotations may has legacy type
  2562. if (option.name.indexOf('allow') === 0 && option.type.indexOf('pdfOption') !== 0) {
  2563. return false;
  2564. }
  2565. return true;
  2566. }
  2567. return false;
  2568. },
  2569. _getPowerPlay8OptionPrompt: function() {
  2570. return ContentStoreObject.getOption(this.objectInfo, 'prompt');
  2571. },
  2572. _getExecutionPrompt: function() {
  2573. if (C10Utils.isPowerPlay(this.objectInfo.type)) {
  2574. return this._getPowerPlay8OptionPrompt();
  2575. }
  2576. return ContentStoreObject.getExecutionPrompt(this.objectInfo);
  2577. },
  2578. _getPromptValue: function() {
  2579. if (C10Utils.isPowerPlay(this.objectInfo.type)) {
  2580. return this._getPowerPlay8OptionPrompt();
  2581. }
  2582. return ContentStoreObject.getOptionValue(this.objectInfo, 'prompt', true);
  2583. },
  2584. _getDefaultPortalAction: function() {
  2585. return this.objectInfo.defaultPortalAction;
  2586. },
  2587. _getDefaultActionSpec: function() {
  2588. var options = [{
  2589. 'label': StringResource.get('viewMostRecentReport'),
  2590. 'value': this.ACTION_VIEW,
  2591. 'selected': this._getDefaultPortalAction() === this.ACTION_VIEW
  2592. }, {
  2593. 'label': StringResource.get('runTheReport'),
  2594. 'value': this.ACTION_RUN,
  2595. 'selected': this._getDefaultPortalAction() === this.ACTION_RUN
  2596. }];
  2597. if (this.objectInfo.type.indexOf('View') === -1) {
  2598. var capitalizedType = this.objectInfo.type.charAt(0).toUpperCase() + this.objectInfo.type.slice(1);
  2599. options.push({
  2600. 'label': StringResource.get('open' + capitalizedType),
  2601. 'value': this.ACTION_EDIT,
  2602. 'selected': this._getDefaultPortalAction() === this.ACTION_EDIT
  2603. });
  2604. }
  2605. return {
  2606. 'type': 'DropDown',
  2607. 'name': 'defaultPortalAction', // name must match cm's option name for update to work
  2608. 'label': StringResource.get('defaultPortalAction'),
  2609. 'options': options
  2610. };
  2611. }
  2612. });
  2613. return PropertiesReportTab;
  2614. });
  2615. /*
  2616. *+------------------------------------------------------------------------+
  2617. *| Licensed Materials - Property of IBM
  2618. *| IBM Cognos Products: Content Explorer
  2619. *| (C) Copyright IBM Corp. 2016, 2020
  2620. *|
  2621. *| US Government Users Restricted Rights - Use, duplication or disclosure
  2622. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  2623. *+----
  2624. */
  2625. define('bi/content_apps/PropertiesC10Tab',['q',
  2626. 'bi/content_apps/PropertiesTab',
  2627. 'bi/content_apps/utils/C10Utils',
  2628. 'bi/content_apps/nls/StringResource',
  2629. 'bacontentnav/utils/ContentStoreObject',
  2630. 'underscore'
  2631. ], function(Q, PropertiesTab, C10Utils, StringResource, ContentStoreObject, _) {
  2632. 'use strict';
  2633. var PropertiesC10Tab = PropertiesTab.extend({
  2634. /**
  2635. @param options.el {node} - container dom node
  2636. **/
  2637. init: function(options) {
  2638. PropertiesC10Tab.inherited('init', this, arguments);
  2639. _.extend(this, options);
  2640. },
  2641. _setPowerPlayReport: function() {
  2642. C10Utils.openC10Morphlet(C10Utils.morphletMap.proppowerplay, this.objectInfo.type, this.objectInfo.id);
  2643. },
  2644. _setDocumentRetention: function() {
  2645. C10Utils.openC10General(C10Utils.propGeneralTitanActionEnum.document, this.objectInfo.type, this.objectInfo.id);
  2646. },
  2647. _viewArchivedVersion: function() {
  2648. C10Utils.openC10Morphlet(C10Utils.morphletMap.archive, this.objectInfo.type, this.objectInfo.id, [{
  2649. 'output_tab': 'arch'
  2650. }, {
  2651. 'm_name': this.objectInfo.defaultName
  2652. }]);
  2653. },
  2654. _viewCurrentVersion: function() {
  2655. C10Utils.openC10Morphlet(C10Utils.morphletMap.archive, this.objectInfo.type, this.objectInfo.id, [{
  2656. 'output_tab': 'current'
  2657. }, {
  2658. 'm_name': this.objectInfo.defaultName
  2659. }]);
  2660. },
  2661. _getReportOptions: function() {
  2662. return ContentStoreObject.getOptions(this.objectInfo);
  2663. },
  2664. _setAgentDefinition: function() {
  2665. C10Utils.openC10Morphlet(C10Utils.morphletMap.agent, this.objectInfo.type, this.objectInfo.id);
  2666. },
  2667. _setMetricsExportTask: function() {
  2668. C10Utils.openC10Morphlet(C10Utils.morphletMap.metricsExport, this.objectInfo.type, this.objectInfo.id);
  2669. },
  2670. _setMetricsDatasourceETLTask: function() {
  2671. C10Utils.openC10Morphlet(C10Utils.morphletMap.metricsImport, this.objectInfo.type, this.objectInfo.id);
  2672. },
  2673. _setMetricsMainteanceTask: function() {
  2674. C10Utils.openC10Morphlet(C10Utils.morphletMap.metricsMainTask, this.objectInfo.type, this.objectInfo.id);
  2675. },
  2676. _genUILinkToC10: function(name, label, callbackLabel, callback) {
  2677. return {
  2678. 'name': name,
  2679. 'type': 'SingleLineLinks',
  2680. 'items': [{
  2681. 'align': 'left',
  2682. 'items': [{
  2683. 'type': 'text',
  2684. 'value': label,
  2685. 'name': 'text' + name
  2686. }]
  2687. }, {
  2688. 'align': 'right',
  2689. 'items': [{
  2690. 'type': 'text',
  2691. 'value': callbackLabel,
  2692. 'clickCallback': callback,
  2693. 'name': 'value' + name,
  2694. 'ariaLabelledby': 'text' + name + ' value' + name
  2695. }]
  2696. }]
  2697. };
  2698. },
  2699. _genRunHistoryUI: function() {
  2700. return {
  2701. 'type': 'SingleLineLinks',
  2702. 'name': 'sectionRunHistory',
  2703. 'items': [{
  2704. 'align': 'left',
  2705. 'items': [{
  2706. 'type': 'text',
  2707. 'value': StringResource.get('runHistory'),
  2708. 'labelFor': 'runHistory'
  2709. }]
  2710. }, {
  2711. 'align': 'right',
  2712. 'items': [{
  2713. 'type': 'Input',
  2714. 'name': 'runHistory',
  2715. 'ellipses': false,
  2716. 'inputClass': 'narrowInput',
  2717. 'value': this._getRetentionValue('history'),
  2718. 'validator': {
  2719. 'isNumber': true
  2720. }
  2721. }, {
  2722. 'type': 'DropDown',
  2723. 'name': 'runHistoryUnit',
  2724. 'ariaLabel': StringResource.get('runHistoryUnits'),
  2725. 'options': [{
  2726. 'label': StringResource.get('occurrences'),
  2727. 'value': 'occurrences',
  2728. 'selected': 'occurrences' === this._getRetentionUnit('history')
  2729. }, {
  2730. 'label': StringResource.get('days'),
  2731. 'value': 'days',
  2732. 'selected': 'days' === this._getRetentionUnit('history')
  2733. }, {
  2734. 'label': StringResource.get('months'),
  2735. 'value': 'months',
  2736. 'selected': 'months' === this._getRetentionUnit('history')
  2737. }]
  2738. }]
  2739. }]
  2740. };
  2741. },
  2742. _getItems: function() {
  2743. var items = [];
  2744. switch (this.objectInfo.type) {
  2745. case 'metricsMaintenanceTask':
  2746. items.push(this._genRunHistoryUI());
  2747. items.push({
  2748. 'type': 'Separator'
  2749. });
  2750. items.push(this._genUILinkToC10('metricsMaintenanceTaskProp', StringResource.get('metricsMaintenanceTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsMainteanceTask.bind(this)));
  2751. break;
  2752. case 'metricsFileImportTask':
  2753. items.push(this._genRunHistoryUI());
  2754. items.push({
  2755. 'type': 'Separator'
  2756. });
  2757. items.push(this._genUILinkToC10('metricsDataSourceETLTask', StringResource.get('metricsFileImportTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsDatasourceETLTask.bind(this)));
  2758. break;
  2759. case 'metricsDataSourceETLTask':
  2760. items.push(this._genRunHistoryUI());
  2761. items.push({
  2762. 'type': 'Separator'
  2763. });
  2764. items.push(this._genUILinkToC10('metricsDataSourceETLTaskProp', StringResource.get('metricsDataSourceETLTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsDatasourceETLTask.bind(this)));
  2765. break;
  2766. case 'metricsExportTask':
  2767. items.push(this._genRunHistoryUI());
  2768. items.push({
  2769. 'type': 'Separator'
  2770. });
  2771. items.push(this._genUILinkToC10('metricsExportTaskProp', StringResource.get('metricsExportTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsExportTask.bind(this)));
  2772. break;
  2773. case 'planningTask':
  2774. items.push(this._genRunHistoryUI());
  2775. break;
  2776. case 'agentDefinition':
  2777. case 'agentDefinitionView':
  2778. items.push(this._genRunHistoryUI());
  2779. items.push({
  2780. 'type': 'Separator'
  2781. });
  2782. items.push(this._genUILinkToC10('agentDefinitionProp', StringResource.get('agentDefinition'), StringResource.get('SetExternalRespostoryLabel'), this._setAgentDefinition.bind(this)));
  2783. break;
  2784. case 'powerPlayReport':
  2785. items.push(this._genUILinkToC10('powerPlay8ReportTab', StringResource.get('powerPlayReport'), StringResource.get('SetExternalRespostoryLabel'), this._setPowerPlayReport.bind(this)));
  2786. break;
  2787. case 'document':
  2788. items.push(this._genUILinkToC10('layoutProperty', StringResource.get('DocumentRetention'), StringResource.get('SetExternalRespostoryLabel'), this._setDocumentRetention.bind(this)));
  2789. items.push(this._genUILinkToC10('viewArchivedVersions', StringResource.get('viewCurrentVersions'), StringResource.get('viewRunHistory'), this._viewCurrentVersion.bind(this)));
  2790. items.push(this._genUILinkToC10('viewArchivedVersions', StringResource.get('viewArchivedVersions'), StringResource.get('viewRunHistory'), this._viewArchivedVersion.bind(this)));
  2791. break;
  2792. }
  2793. return items;
  2794. },
  2795. render: function() {
  2796. this._id = _.uniqueId('prop_');
  2797. return this.renderPropertyUIControl({
  2798. 'el': this.$el,
  2799. 'glassContext': this.glassContext,
  2800. 'readOnly': this.objectInfo.type === 'document' ? false : !ContentStoreObject.hasPermissions(this.objectInfo, ['write']),
  2801. 'items': this._getItems()
  2802. });
  2803. },
  2804. _getModifiedOptions: function(modifiedProperties, modifiedPropertiesUI) {
  2805. var optionBlob = this._getReportOptions();
  2806. var optionModified = false;
  2807. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_FORMAT)) {
  2808. var optionFormat = {};
  2809. //convert property to option
  2810. optionFormat.name = ContentStoreObject.OPTION_OUTPUT_FORMAT;
  2811. optionFormat.type = 'runOptionStringArray';
  2812. optionFormat.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT]];
  2813. this._setReportOption(optionBlob, optionFormat, optionFormat.value[0] === 'Default');
  2814. delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
  2815. optionModified = true;
  2816. }
  2817. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_LOCALE)) {
  2818. var optionLocale = {};
  2819. optionLocale.name = ContentStoreObject.OPTION_OUTPUT_LOCALE;
  2820. optionLocale.type = 'runOptionLanguageArray';
  2821. optionLocale.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE]];
  2822. this._setReportOption(optionBlob, optionLocale, optionLocale.value[0] === 'Default');
  2823. delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
  2824. optionModified = true;
  2825. }
  2826. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES)) {
  2827. var optionAF = {};
  2828. optionAF.name = ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES;
  2829. optionAF.type = 'genericOptionBoolean';
  2830. optionAF.value = modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
  2831. this._setReportOption(optionBlob, optionAF, optionAF.value === 'null');
  2832. delete modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
  2833. optionModified = true;
  2834. }
  2835. if (optionModified) {
  2836. _.extend(modifiedProperties, {
  2837. 'options': optionBlob
  2838. });
  2839. }
  2840. },
  2841. getModifiedProperties: function() {
  2842. var modifiedProperties = {};
  2843. var modifiedPropertiesUI = this.getPropertyUIControl().getModifiedProperties();
  2844. //deal with report options
  2845. this._getModifiedOptions(modifiedProperties, modifiedPropertiesUI);
  2846. //deal with history/output version settings
  2847. this._getModifiedRetentions(modifiedProperties, modifiedPropertiesUI);
  2848. _.extend(modifiedProperties, modifiedPropertiesUI);
  2849. return modifiedProperties;
  2850. }
  2851. });
  2852. return PropertiesC10Tab;
  2853. });
  2854. /*
  2855. *+------------------------------------------------------------------------+
  2856. *| Licensed Materials - Property of IBM
  2857. *| IBM Cognos Products: Content Explorer
  2858. *| (C) Copyright IBM Corp. 2015, 2018
  2859. *|
  2860. *| US Government Users Restricted Rights - Use, duplication or disclosure
  2861. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  2862. *+----
  2863. */
  2864. define('bi/content_apps/PropertiesCapabilitiesTab',['q',
  2865. 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyTabView',
  2866. 'bacontentnav/utils/UIHelper',
  2867. 'bi/content_apps/utils/C10Utils',
  2868. 'bi/content_apps/nls/StringResource',
  2869. 'underscore'
  2870. ], function(Q, PropertyTabView, UIHelper, C10Utils, StringResource, _) {
  2871. 'use strict';
  2872. var PropertiesCapabilitiesTab = PropertyTabView.extend({
  2873. /**
  2874. @paran options.el {node} - container dom node
  2875. **/
  2876. init: function(options) {
  2877. PropertiesCapabilitiesTab.inherited('init', this, arguments);
  2878. _.extend(this, options);
  2879. },
  2880. _setCapabilities: function() {
  2881. C10Utils.openC10Morphlet(C10Utils.morphletMap.capabilities, this.objectInfo.type, this.objectInfo.id);
  2882. },
  2883. render: function() {
  2884. this._id = _.uniqueId('prop_');
  2885. return this.renderPropertyUIControl({
  2886. 'el': this.$el,
  2887. 'glassContext': this.glassContext,
  2888. 'items': [{
  2889. 'name': 'setCapabilities',
  2890. 'type': 'SingleLineLinks',
  2891. 'items': [{
  2892. 'align': 'left',
  2893. 'items': [{
  2894. 'type': 'text',
  2895. 'name': 'setCapabilitiesText',
  2896. 'value': StringResource.get('capabilities')
  2897. }]
  2898. }, {
  2899. 'align': 'right',
  2900. 'items': [{
  2901. 'type': 'text',
  2902. 'name': 'setCapabilitiesLink',
  2903. 'value': StringResource.get('SetCapabilitiesLabel'),
  2904. 'clickCallback': this._setCapabilities.bind(this),
  2905. 'ariaLabelledby': 'setCapabilitiesText setCapabilitiesLink'
  2906. }]
  2907. }]
  2908. }]
  2909. });
  2910. }
  2911. });
  2912. return PropertiesCapabilitiesTab;
  2913. });
  2914. /*
  2915. *+------------------------------------------------------------------------+
  2916. *| Licensed Materials - Property of IBM
  2917. *|
  2918. *| IBM Cognos Products: content-apps
  2919. *|
  2920. *| (C) Copyright IBM Corp. 2016, 2018
  2921. *|
  2922. *| US Government Users Restricted Rights - Use, duplication or disclosure
  2923. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  2924. *+------------------------------------------------------------------------+
  2925. */
  2926. define('bi/content_apps/PropertiesJobTab',[
  2927. 'bi/content_apps/PropertiesTab',
  2928. 'bi/content_apps/nls/StringResource',
  2929. 'bacontentnav/utils/ContentStoreObject',
  2930. 'underscore'
  2931. ], function(PropertiesTab, StringResource, ContentStoreObject, _) {
  2932. 'use strict';
  2933. var PropertiesJobTab = PropertiesTab.extend({
  2934. /**
  2935. @param options.el {node} - container dom node
  2936. **/
  2937. init: function(options) {
  2938. PropertiesJobTab.inherited('init', this, arguments);
  2939. _.extend(this, options);
  2940. },
  2941. render: function() {
  2942. this._id = _.uniqueId('prop_');
  2943. var hasNoWritePermission = !ContentStoreObject.hasPermissions(this.objectInfo, ['write']);
  2944. var hasNoTraversePermission = !ContentStoreObject.hasPermissions(this.objectInfo, ['traverse']);
  2945. return this.renderPropertyUIControl({
  2946. 'el': this.$el,
  2947. 'glassContext': this.glassContext,
  2948. 'items': [{
  2949. 'type': 'SingleLineLinks',
  2950. 'name': 'sectionRunHistory',
  2951. 'readOnly': hasNoWritePermission,
  2952. 'items': [{
  2953. 'align': 'left',
  2954. 'items': [{
  2955. 'type': 'text',
  2956. 'value': StringResource.get('runHistory'),
  2957. 'labelFor': 'runHistory'
  2958. }]
  2959. }, {
  2960. 'align': 'right',
  2961. 'items': [{
  2962. 'type': 'Input',
  2963. 'name': 'runHistory',
  2964. 'ellipses': false,
  2965. 'inputClass': 'narrowInput',
  2966. 'value': this._getRetentionValue('history'),
  2967. 'validator': {
  2968. 'isNumber': true
  2969. }
  2970. }, {
  2971. 'type': 'DropDown',
  2972. 'name': 'runHistoryUnit',
  2973. 'ariaLabel': StringResource.get('runHistoryUnits'),
  2974. 'options': [{
  2975. 'label': StringResource.get('occurrences'),
  2976. 'value': 'occurrences',
  2977. 'selected': 'occurrences' === this._getRetentionUnit('history')
  2978. }, {
  2979. 'label': StringResource.get('days'),
  2980. 'value': 'days',
  2981. 'selected': 'days' === this._getRetentionUnit('history')
  2982. }, {
  2983. 'label': StringResource.get('months'),
  2984. 'value': 'months',
  2985. 'selected': 'months' === this._getRetentionUnit('history')
  2986. }]
  2987. }]
  2988. }]
  2989. }, {
  2990. 'type': 'CollapsibleSection',
  2991. 'label': StringResource.get('advancedProperties'),
  2992. 'name': 'Advanced',
  2993. 'items': [{
  2994. 'name': 'advancedProperties',
  2995. 'type': 'SingleLineLinks',
  2996. 'readOnly': hasNoWritePermission || hasNoTraversePermission,
  2997. 'items': [{
  2998. 'align': 'left',
  2999. 'items': [{
  3000. 'type': 'text',
  3001. 'name': 'advancedPropertiesText',
  3002. 'value': StringResource.get('jobAdvancedProperties')
  3003. }]
  3004. }, {
  3005. 'align': 'right',
  3006. 'items': [{
  3007. 'type': 'text',
  3008. 'value': StringResource.get('JobAdvancedSettings'),
  3009. 'name': 'advancedPropertiesLink',
  3010. 'ariaLabelledby': 'advancedPropertiesText advancedPropertiesLink',
  3011. 'clickCallback': this._setAdvancedProperties.bind(this)
  3012. }]
  3013. }]
  3014. }]
  3015. }]
  3016. });
  3017. },
  3018. _setAdvancedProperties: function() {
  3019. var context = {
  3020. id: PropertiesJobTab.JOB_MGT,
  3021. content: {
  3022. objectInfo: this.objectInfo
  3023. }
  3024. };
  3025. this.glassContext.appController.openAppView(PropertiesJobTab.JOB_MGT, context);
  3026. },
  3027. getModifiedProperties: function() {
  3028. var modifiedProperties = {};
  3029. var modifiedPropertiesUI = this.getPropertyUIControl().getModifiedProperties();
  3030. //deal with report options
  3031. this._getModifiedOptions(modifiedProperties, modifiedPropertiesUI);
  3032. //deal with history/output version settings
  3033. this._getModifiedRetentions(modifiedProperties, modifiedPropertiesUI);
  3034. _.extend(modifiedProperties, modifiedPropertiesUI);
  3035. return modifiedProperties;
  3036. },
  3037. _getOutputFormat: function() {
  3038. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_FORMAT);
  3039. },
  3040. _getOutputLocale: function() {
  3041. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_LOCALE);
  3042. },
  3043. _getEnableAccessibilitySupport: function() {
  3044. return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES);
  3045. },
  3046. _getReportOptions: function() {
  3047. return ContentStoreObject.getOptions(this.objectInfo);
  3048. },
  3049. _getModifiedOptions: function(modifiedProperties, modifiedPropertiesUI) {
  3050. var optionBlob = this._getReportOptions();
  3051. var optionModified = false;
  3052. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_FORMAT)) {
  3053. var optionFormat = {};
  3054. //convert property to option
  3055. optionFormat.name = ContentStoreObject.OPTION_OUTPUT_FORMAT;
  3056. optionFormat.type = 'runOptionStringArray';
  3057. optionFormat.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT]];
  3058. this._setReportOption(optionBlob, optionFormat, optionFormat.value[0] === 'Default');
  3059. delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
  3060. optionModified = true;
  3061. }
  3062. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_LOCALE)) {
  3063. var optionLocale = {};
  3064. optionLocale.name = ContentStoreObject.OPTION_OUTPUT_LOCALE;
  3065. optionLocale.type = 'runOptionLanguageArray';
  3066. optionLocale.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE]];
  3067. this._setReportOption(optionBlob, optionLocale, optionLocale.value[0] === 'Default');
  3068. delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
  3069. optionModified = true;
  3070. }
  3071. if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES)) {
  3072. var optionAF = {};
  3073. optionAF.name = ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES;
  3074. optionAF.type = 'genericOptionBoolean';
  3075. optionAF.value = modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
  3076. this._setReportOption(optionBlob, optionAF, optionAF.value === 'null');
  3077. delete modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
  3078. optionModified = true;
  3079. }
  3080. if (optionModified) {
  3081. _.extend(modifiedProperties, {
  3082. 'options': optionBlob
  3083. });
  3084. }
  3085. }
  3086. });
  3087. PropertiesJobTab.JOB_MGT = 'job_mgt';
  3088. return PropertiesJobTab;
  3089. });
  3090. define('text!bi/content_apps/common/templates/PolicyDetail.html',[],function () { return '<div style="padding: 10px">\n\t<div class="policyDetailTitle">{{=it.strings.title}}</div>\n\t<div class="policyHeaderRow">\n\t\t<div class="policyHeaderLeft ellipses">{{=_.escape(it.owner)}}</div>\n\t\t<div class="policyHeaderRight">\n\t\t\t<div class="policyHeaderSeparator" ></div>\n\t\t\t<div class="simplifiedPermission">{{=it.simpliedPolicy}}</div>\n\t\t</div>\n\t</div>\n\t<div class="propertyUIControl policyDetail"> \n\t\t<table class="propertyRow" summary="{{=it.strings.title}}" role="grid" tabindex="0">\n\t\t\t<thead>\n\t\t\t\t<tr style=" position:absolute; left:-9999px">\n\t\t\t\t\t<th scope="col">{{=it.strings.columnLabelAccess}}</th> \n\t\t\t\t\t<th scope="col">{{=it.strings.columnLabelPermission}}</th>\n\t\t\t\t\t<th scope="col">{{=it.strings.columnLabelAction}}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\n\t\t\t{{ for(var prop in it.permIcons) { }}\n\t\t\t\t<tr>\n\t\t\t\t\t<td class="permission_{{=prop}}">\n\t\t\t\t\t\t<div title="{{=it.permIcons[prop].tooltip}}" alt="{{=it.permIcons[prop].tooltip}}" role="img" aria-label="{{=it.permIcons[prop].tooltip}}" tabindex="0">\n\t\t\t\t\t\t\t<svg role="presentation" class="svgIcon">\n\t\t\t\t\t\t\t\t<text>{{=it.permIcons[prop].tooltip}}</text>\n\t\t\t\t\t\t\t\t<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{{=it.permIcons[prop].icon}}"></use>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td scope="row" class="policyDetailLabel" role="gridcell" aria-label="{{=it.permIcons[prop].label}}" tabindex="0">{{=it.permIcons[prop].label}}</td>\n\t\t\t\t\t<td id="{{=prop}}_id">\n\t\t\t\t\t\t{{?it.canModify}}\n\t\t\t\t\t\t<div role="button" class="clickable" aria-haspopup="true" name="{{=prop}}" tabindex="0" id="policyDetailsDropDown" aria-label="{{=it.strings.setAccess}}">\n\t\t\t\t\t\t\t<svg class="svgIcon">\n\t\t\t\t\t\t\t\t<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#common-titan-arrow-down"></use>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{{?}}\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t{{ } }}\n\t\t\t</tbody>\n\t\t</table>\n\t\t</div>\n</div>\n';});
  3091. /*
  3092. *+------------------------------------------------------------------------+
  3093. *| Licensed Materials - Property of IBM
  3094. *| IBM Cognos Products: BI Content Explorer
  3095. *| (C) Copyright IBM Corp. 2015, 2018
  3096. *|
  3097. *| US Government Users Restricted Rights - Use, duplication or disclosure
  3098. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  3099. *+------------------------------------------------------------------------+
  3100. */
  3101. define('bi/content_apps/common/PolicyDetailsView',[
  3102. 'bi/commons/ui/AccessibleView',
  3103. 'doT',
  3104. 'bacontentnav/common/ui/BreadcrumbDropDown',
  3105. 'text!bi/content_apps/common/templates/PolicyDetail.html',
  3106. 'bi/content_apps/nls/StringResource',
  3107. 'bacontentnav/utils/PolicyHelper',
  3108. 'bi/commons/ui/KeyCodes',
  3109. 'bi/commons/utils/ContentFormatter',
  3110. 'underscore'
  3111. ], function(AccessibleView, dot, DropDownMenu, pdTemplate, StringResource, PolicyHelper, KeyCodes, ContentFormatter, _) {
  3112. 'use strict';
  3113. var PolicyDetailsView = AccessibleView.extend({
  3114. init: function(options) {
  3115. this.events = {};
  3116. this.events['keydown #policyDetailsDropDown'] = '_handleKeyDown';
  3117. PolicyDetailsView.inherited('init', this, arguments);
  3118. _.extend(this, options);
  3119. },
  3120. _refreshPermissionUI: function(permission) {
  3121. var permissionEl = this.$el.find('.permission_' + permission);
  3122. var simplifiedPermissionEl = this.$el.find('.simplifiedPermission');
  3123. var selectedBirdBeak = this.$el.find('#' + permission + '_id');
  3124. simplifiedPermissionEl.text(PolicyHelper.getSimplifiedPermissions(this.objectInformation.permissions));
  3125. permissionEl.empty();
  3126. var permObj = _.find(this.objectInformation.permissions, function(obj) {
  3127. return obj.name === permission;
  3128. });
  3129. var newValue = permObj ? permObj.access : 'default';
  3130. var updatedPerm = $('<div title="' + StringResource.get(newValue) + '"><svg class="svgIcon"><text>' + newValue + '</text><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#common-' + newValue + '_perm"></use></svg></div>');
  3131. permissionEl.append(updatedPerm);
  3132. selectedBirdBeak.children('div').focus();
  3133. },
  3134. _updatePermission: function(permission, value) {
  3135. if (value === 'default') {
  3136. var newPerms = _.reject(this.objectInformation.permissions, function(obj) {
  3137. return obj.name === permission;
  3138. });
  3139. this.objectInformation.permissions = newPerms;
  3140. } else {
  3141. var permObj = _.find(this.objectInformation.permissions, function(obj) {
  3142. return obj.name === permission;
  3143. });
  3144. if (!permObj) {
  3145. permObj = {
  3146. 'name': permission
  3147. };
  3148. this.objectInformation.permissions.push(permObj);
  3149. }
  3150. permObj.access = value;
  3151. }
  3152. this._refreshPermissionUI(permission);
  3153. if (typeof (this.enableParentApplyButton) === 'function') {
  3154. this.enableParentApplyButton();
  3155. }
  3156. },
  3157. _onMenuSelect: function(value, $row) {
  3158. var permission = $row.children('div').attr('name');
  3159. this._updatePermission(permission, value);
  3160. },
  3161. updateRead: function(newValue) {
  3162. this._updatePermission(PolicyHelper.permissionEnum.r, newValue);
  3163. },
  3164. updateWrite: function(newValue) {
  3165. this._updatePermission(PolicyHelper.permissionEnum.w, newValue);
  3166. },
  3167. updateExecute: function(newValue) {
  3168. this._updatePermission(PolicyHelper.permissionEnum.x, newValue);
  3169. },
  3170. updateSetPolicy: function(newValue) {
  3171. this._updatePermission(PolicyHelper.permissionEnum.sp, newValue);
  3172. },
  3173. updateTraverse: function(newValue) {
  3174. this._updatePermission(PolicyHelper.permissionEnum.t, newValue);
  3175. },
  3176. getOwnerName: function() {
  3177. // check if the givenName and surname are available, if so, display them, otherwise, display the defaultName. Check if the owner default name is the same as the user in the permissions table
  3178. if((this.ownerData.givenName && this.ownerData.surname) && (this.objectInformation.securityObject.defaultName === this.ownerData.defaultName)){
  3179. return this.ownerData.givenName + ' ' + this.ownerData.surname;
  3180. } else {
  3181. return this.objectInformation.securityObject.defaultName;
  3182. }
  3183. },
  3184. render: function() {
  3185. var owner = this.getOwnerName();
  3186. var perm = ['read', 'write', 'execute', 'traverse', 'setPolicy'];
  3187. var permObj = PolicyHelper.getIconsForPermissionValues(this.objectInformation.permissions);
  3188. var sHtml = dot.template(pdTemplate)({
  3189. oData: this.objectInformation,
  3190. 'simpliedPolicy': PolicyHelper.getSimplifiedPermissions(this.objectInformation.permissions),
  3191. 'permIcons': permObj,
  3192. 'canModify': this.canModify,
  3193. 'owner': owner,
  3194. 'strings': {
  3195. 'title': StringResource.get('permissionDetails'),
  3196. 'grant': StringResource.get('grant'),
  3197. 'deny': StringResource.get('deny'),
  3198. 'default': StringResource.get('default'),
  3199. 'columnLabelAccess': StringResource.get('permissionDetailsColumnAccess'),
  3200. 'columnLabelPermission': StringResource.get('permissionDetailsColumnPermission'),
  3201. 'columnLabelAction': StringResource.get('permissionDetailsColumnAction'),
  3202. 'setAccess': StringResource.get('permissionSetAccess')
  3203. }
  3204. });
  3205. this.$el.append(sHtml);
  3206. var $ellipses = this.$el.find('.ellipses');
  3207. $.each($ellipses, function(index, node) {
  3208. ContentFormatter.middleShortenString(node);
  3209. });
  3210. // add drop down menus to table
  3211. for (var i = 0; i < perm.length; i = i + 1) {
  3212. var theID = perm[i] + '_id';
  3213. var $td = this.$el.find('#' + theID);
  3214. this._createDropDown($td);
  3215. }
  3216. /* JAWS reader support */
  3217. var flyoutPane = this.$el.closest('.flyoutPane');
  3218. flyoutPane.attr({
  3219. 'aria-label': StringResource.get('permissionDetails'),
  3220. role: 'region'
  3221. });
  3222. var permissionGrid = this.$el.find('.propertyRow');
  3223. permissionGrid.focus();
  3224. return Promise.resolve();
  3225. },
  3226. setFocus: function() {
  3227. var firstDropdown = this.$el.find('#policyDetailsDropDown');
  3228. if (firstDropdown) {
  3229. firstDropdown.focus();
  3230. }
  3231. },
  3232. _createDropDown: function($row) {
  3233. var menuItems = [{
  3234. 'label': StringResource.get('grant'),
  3235. 'icon': 'common-grant_perm',
  3236. 'onSelect': this._onMenuSelect.bind(this, 'grant', $row)
  3237. }, {
  3238. 'label': StringResource.get('deny'),
  3239. 'icon': 'common-deny_perm',
  3240. 'onSelect': this._onMenuSelect.bind(this, 'deny', $row)
  3241. }, {
  3242. 'label': StringResource.get('default'),
  3243. 'icon': 'common-default_perm',
  3244. 'onSelect': this._onMenuSelect.bind(this, 'default', $row)
  3245. }];
  3246. this.ddMenu = new DropDownMenu({
  3247. dropDownMenuSpec: {
  3248. 'title': StringResource.get('permissionSetAccess'),
  3249. 'id': 'myId',
  3250. 'label': 'mylabel',
  3251. 'icon': '',
  3252. 'items': menuItems,
  3253. 'actionElement': $row,
  3254. 'ddMenuPlacement': 'bottom'
  3255. }
  3256. });
  3257. this.ddMenu.render();
  3258. },
  3259. // open dropdown popup
  3260. _handleKeyDown: function(evt) {
  3261. if (evt.keyCode === KeyCodes.DOWN_ARROW) {
  3262. $(evt.currentTarget).closest('td').click();
  3263. }
  3264. }
  3265. });
  3266. return PolicyDetailsView;
  3267. });
  3268. define("js/content_apps/propertiesBundle", function(){});