123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/common/ui/permissions/Policy',[],function() {
- 'use strict';
- /**
- * Represents a Policy (account, group or role) that is found in the policy of an item
- */
- function Policy(name, id, type, path) {
- // Ensures that the callee has invoked our Class' constructor function
- // with the `new` keyword
- if (!(this instanceof Policy)) {
- throw new TypeError('Policy constructor cannot be called as a function.');
- }
- this.permissions = [{
- name: 'read',
- access: 'grant'
- }, {
- name: 'traverse',
- access: 'grant'
- }];
- this.securityObject = {
- defaultName: name,
- id: id,
- type: type,
- searchPath: path
- };
- }
- Policy.prototype = {
- constructor: Policy
- };
- return Policy;
- });
- 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}';});
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/common/PolicyPropertyView',[
- 'bacontentnav/common/ContentListPageView',
- 'bi/content_apps/common/ui/permissions/Policy',
- 'text!./policyfacets.json',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/CheckBox',
- 'bacontentnav/utils/ContentStoreObject',
- 'bi/commons/ui/Button',
- 'bacontentnav/utils/PolicyHelper',
- 'bacontentnav/common/ui/BreadcrumbDropDown',
- 'bacontentnav/utils/GlassContextHelper',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'underscore'
- ], function(ContentListPageView, Policy, policyFacets, StringResource, CheckBox, ContentStoreObject, CommonButton, PolicyHelper, DropDownMenu, GlassContextHelper, PropertyUIControl, _) {
- 'use strict';
- var PolicyPropertyView = ContentListPageView.extend({
- init: function(options) {
- this.itemURL = options.itemURL;
- this.showUnavailablePolicies = false;
- PolicyPropertyView.inherited('init', this, arguments);
- _.extend(this, options);
- this.addURLParameters({
- 'schemaInfo': 'true',
- 'fields': 'surname,givenName,userName,defaultName,policies.defaultName,policies.id,policies.ancestors,permissions'
- });
- this.contentListFacets = JSON.parse(policyFacets).facets;
- },
- getPoliciesData: function() {
- return Promise.resolve(this.permissionsData);
- },
- _canModifyPolicies: function(canModify) {
- if (canModify === undefined) {
- this.canModifyPolicies = ContentStoreObject.hasPermissions(this.oData.data[0], ['setPolicy']) && !(ContentStoreObject.isPoliciesAcquired(this.oData.data[0]));
- } else {
- this.canModifyPolicies = canModify;
- }
- },
- _getObject: function() {
- var urlParms = this.getURLParameters();
- var reqUrl = this._getDefaultRequestURL();
- $.each(urlParms, function(name, value) {
- if (reqUrl === this.itemURL) {
- reqUrl += '?';
- } else {
- reqUrl += '&';
- }
- reqUrl += name + '=' + value;
- }.bind(this));
- // Query for the information we need to open the view
- var options = {
- dataType: 'json',
- type: 'GET',
- data: {},
- url: reqUrl,
- cache: false
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .then(function(response) {
- return response && response.data;
- });
- },
- _setOData: function(oData) {
- var updatedPolicies = [];
- this.rejectedPolicies = [];
- if (oData.data[0].policies) {
- oData.data[0].policies.forEach(function(policy) {
- if (policy.securityObject.type === 'nil') {
- this.rejectedPolicies.push(policy);
- } else {
- updatedPolicies.push(policy);
- }
- }.bind(this));
- oData.data[0].policies = updatedPolicies;
- }
- this.oData = oData;
- },
- _showHideAddMemberButton: function(isShown) {
- var buttonTabIndex = '0';
- if ((isShown) && (this.canModifyPolicies)) {
- this.contentBar.itemMap.add.show();
- } else {
- this.contentBar.itemMap.add.hide();
- buttonTabIndex = '-1';
- }
- $(this.contentBar.itemMap.add.el).find('button').attr('tabindex', buttonTabIndex);
- },
- _updateUIForEdit: function() {
- var isRoot = ContentStoreObject.isTeamContent(this.oData.data[0]);
- var listControl = this.getListControl();
- this.applyToChildren = this._oPropertyUIControl.getProperty('applyToAllChildren');
- if (isRoot) {
- if (this.contentBar.itemMap.add) {
- this._showHideAddMemberButton(true);
- }
- } else {
- var overrideParent = this._oPropertyUIControl.getProperty('overrideParent');
- var isChecked = overrideParent.isChecked();
- this._canModifyPolicies(isChecked);
- if (!isChecked) {
- // If we are turning off multi select we should clear selections
- listControl._clearRows();
- this.multiselectBar.hide();
- this.contentBar.show();
- this.applyToChildren.uncheck();
- this.applyToChildren.disable();
- } else {
- this.applyToChildren.enable();
- }
- listControl.multiSelect = isChecked;
- this.$el.removeClass('policyCanNotModify');
- if (!(this.canModifyPolicies && isChecked)) {
- this.$el.addClass('policyCanNotModify');
- }
- if (this.contentBar.itemMap.add) {
- this._showHideAddMemberButton(isChecked);
- }
- }
- },
- render: function() {
- return this._getObject().then(function(oData) {
- this._setOData(oData);
- this.permissionsData = {};
- this.permissionsData.data = oData.data[0].policies ? oData.data[0].policies : [];
- this._canModifyPolicies();
- return PolicyPropertyView.inherited('render', this, arguments).then(function() {
- this._updateUIForEdit();
- return Promise.resolve();
- }.bind(this));
- }.bind(this));
- },
- _overrideParentChanged: function() {
- this._updateUIForEdit();
- this._enableApplyItems();
- },
- renderContent: function() {
- this.$el.addClass('policies');
- // The content bars get rendered first, detach them here so we can re-attach them to the DOM when just above the list control
- this.$contentBars = this.$el.children().detach();
- var aControls = [];
- if ((this.rejectedPolicies) && (this.rejectedPolicies.length > 0)) {
- aControls.push({
- 'type': 'SingleLineLinks',
- 'name': 'hidePolicies',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'class': 'versionStatusText',
- 'value': StringResource.get('missingPolicies'),
- 'svgIcon': 'common-warning'
- }]
- }]
- },{
- 'type': 'CheckBox',
- 'name': 'showUnavailablePolicies',
- 'label': StringResource.get('showUnavailablePolicies'),
- 'controlOnLeft': true,
- 'checked': this.showUnavailablePolicies,
- 'onChange': this._toggleShowUnavailablePolicies.bind(this)
- });
- }
- var isRoot = ContentStoreObject.isTeamContent(this.oData.data[0]);
- if (!isRoot) {
- aControls.push({
- 'type': 'CheckBox',
- 'name': 'overrideParent',
- 'label': StringResource.get('overrideParentPermissions'),
- 'controlOnLeft': true,
- 'checked': !(ContentStoreObject.isPoliciesAcquired(this.oData.data[0])),
- 'onChange': this._overrideParentChanged.bind(this)
- });
- }
- aControls.push({
- 'module': 'bi/content_apps/ui/RenderCallback',
- 'renderCallback': this._renderListControl.bind(this)
- }, {
- 'type': 'CheckBox',
- 'name': 'applyToAllChildren',
- 'label': StringResource.get('applyToAllChildren'),
- 'controlOnLeft': true,
- 'onChange': this._enableApplyItems.bind(this)
- }, {
- 'type': 'Footer',
- 'items': [{
- 'type': 'Button',
- 'label': StringResource.get('applyLabel'),
- 'onSelect': this._onApplyClick.bind(this),
- 'primary': true
- }, {
- 'type': 'Button',
- 'label': StringResource.get('cancel'),
- 'onSelect': this._onCancelClick.bind(this),
- 'primary': false
- }]
- });
- this._oPropertyUIControl = new PropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'items': aControls
- });
- return this._oPropertyUIControl.render().then(function() {
- var footer = this._getFooter();
- var footerProps;
- footerProps = footer._oPropertyUIControl.getProperties();
- this.applyButton = footerProps[0];
- this.applyButton.disable();
- return Promise.resolve();
- }.bind(this));
- },
- _getFooter: function() {
- var propList = this._oPropertyUIControl.getProperties();
- var footer;
- propList.forEach(function(prop) {
- if (prop.type === 'Footer') {
- footer = prop;
- }
- });
- return footer;
- },
- _renderListControl: function(container) {
- var $wrapper = $('<div></div>');
- $(container).append($wrapper);
- $wrapper.append(this.$contentBars);
- return this.renderContentList({
- 'el': $wrapper,
- 'columns': this._getColumnSpecification(),
- '$container': this.$el.closest('.propertiesUIControlPageView'),
- 'minHeight': 50,
- 'url': (this.url || this._getDefaultRequestURL())
- });
- },
- _onCancelClick: function() {
- this.slideout.hide();
- },
- _onApplyClick: function() {
- var data = {};
- data.policies = this.oData.data[0].policies;
- data.type = this.oData.data[0].type;
- var overrideParent = this._oPropertyUIControl.getProperty('overrideParent');
- var overrideChecked = (!overrideParent || overrideParent.isChecked());
- if (overrideChecked) {
- // Add back in the policies the user can not see
- if ((this.rejectedPolicies) && (this.rejectedPolicies.length > 0)) {
- this.rejectedPolicies.forEach(function(policy) {
- data.policies.push(policy);
- });
- }
- // Setup the search path for the security objects
- data.policies.forEach(function(policy) {
- var currentSO = policy.securityObject;
- currentSO.searchPath = 'storeID("' + currentSO.id + '")';
- });
- } else {
- // If the override parent permission is not checked then clear out the permissions
- data.policies = [];
- }
- // Set the apply to all children
- if (this.applyToChildren.isChecked()) {
- data._meta = {
- 'schemaInfo': {
- 'policies': {
- 'applyUpdateToDescendants': true
- }
- }
- };
- }
- var jsonData = JSON.stringify(data);
- var options = {
- 'headers': {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- 'type': 'PUT',
- 'url': ContentStoreObject.getSelfLink(this.oData.data[0]),
- 'data': jsonData
- };
- // Reset the ui after apply
- this.applyButton.disable();
- return this._sendRequest(options).then(function(response) {
- // After updating , refetch policies and render them
- // especially after deselecting override and overrides were previously applied
- // default policies need to be rendered instead
- if (!overrideChecked) {
- this._getObject().then(function(oData) {
- this._setOData(oData);
- this.permissionsData = {};
- this.permissionsData.data = oData.data[0].policies ? oData.data[0].policies : [];
- this._canModifyPolicies();
- this.refresh(this.itemURL);
- this._updateUIForEdit();
- return Promise.resolve(response);
- }.bind(this));
- } else {
- this._updateUIForEdit();
- return Promise.resolve(response);
- }
- }.bind(this));
- },
- _sendRequest: function(options, successHandler) {
- successHandler = successHandler || function() {
- return Promise.resolve();
- };
- return this.glassContext.getCoreSvc('.Ajax').ajax(options)
- .then(successHandler.bind(this))
- .catch(function(err) {
- GlassContextHelper.showAjaxServiceError(this.glassContext, err);
- return Promise.reject(err);
- }.bind(this));
- },
- _getDefaultRequestURL: function() {
- return this.itemURL;
- },
- _getModuleName: function() {
- return 'bi/content_apps/common/ui/PolicyPropertyView';
- },
- getFilterSpec: function() {
- return [{
- 'name': 'allContent',
- 'label': StringResource.get('allGenericItems'),
- 'value': 'allContent'
- }, {
- 'name': 'accounts',
- 'label': StringResource.get('policyFilterAccounts'),
- 'value': 'account'
- }, {
- 'name': 'groups',
- 'label': StringResource.get('policyFilterGroups'),
- 'value': 'group'
- }, {
- 'name': 'roles',
- 'label': StringResource.get('policyFilterRoles'),
- 'value': 'role'
- }];
- },
- _getFilterItems: function(filterSpec, filterMenuPrefix, defaultFilterValue, doFilter) {
- return _.map(filterSpec, function(item) {
- return {
- 'name': filterMenuPrefix + item.name,
- 'icon': 'wft_checkmark',
- 'label': item.label,
- 'checked': item.value === defaultFilterValue,
- 'action': function() {
- doFilter(item.name);
- }
- };
- });
- },
- contentbarItems: function() {
- var filterMenuNamePrefix = 'POLICY_FILTER_';
- var filterString = window.localStorage.getItem('filterString_' + this.stateId) || '';
- var filterSpec = this.getFilterSpec();
- var filterItems = this._getFilterItems(filterSpec, filterMenuNamePrefix, filterString, this._filter.bind(this));
- return [{
- 'name': 'nameLabel',
- 'position': 'leading',
- 'style': 'nameLabel',
- 'module': 'bacontentnav/common/ui/contentbar_components/HiddenLabel',
- 'label': StringResource.get('policiesTableLable')
- }, {
- 'name': filterMenuNamePrefix + 'typeMenu',
- 'label': StringResource.get('type'),
- 'hcLabel': false,
- 'position': 'trailing',
- 'supportCustomCollapse': true,
- 'showTitle': false,
- 'updateLabel': true,
- 'icon': 'common-filter',
- 'bSVG': true,
- 'module': 'bacontentnav/common/ui/contentbar_components/ToggleMenuBar',
- 'items': filterItems
- }, {
- 'name': 'add',
- 'position': 'trailing',
- 'displayLabel': false,
- 'label': StringResource.get('policesAddMemberButtonLabel'),
- 'module': 'bacontentnav/common/ui/contentbar_components/Button',
- 'className': 'addNewFolder',
- 'supportCustomCollapse': true,
- 'icon': 'common-add',
- 'hiddenOnRender': true,
- '_handleClick': function() {
- this._openAddMembersSlideout();
- }.bind(this)
- }];
- },
- getListControlOptions: function() {
- return {
- 'ajaxProp': 'data',
- 'emptyFolderString': StringResource.get('emptyPolicyList'),
- 'showEmptyNewFolderButton': false,
- 'getJSONDataCallback': this.getPoliciesData.bind(this),
- 'url': '',
- 'multiSelect': this.canModifyPolicies,
- 'rightClickContextMenu': false
- };
- },
- getDefaultSort: function() {
- return [1, 'asc'];
- },
- _isDuplicate: function(oData, matchId) {
- var isDuplicate = false;
- oData.forEach(function(arrayElem) {
- var id = arrayElem.securityObject.id;
- if (id === matchId) {
- isDuplicate = true;
- return false;
- }
- });
- return isDuplicate;
- },
- removeSelection: function() {
- setTimeout(function() {
- var overrideParent = this._oPropertyUIControl.getProperty('overrideParent');
- var canOverride = overrideParent === null || overrideParent.isChecked();
- if (canOverride) {
- var selectedPolicies = this.getListControl().getSelectedObjects();
- var updatedPolicies = _.reject(this.oData.data[0].policies, function(policy) {
- return _.find(selectedPolicies, function(selPol) {
- return policy.securityObject.defaultName === selPol.securityObject.defaultName;
- });
- });
- this.getListControl().removeSelectedRows();
- this.oData.data[0].policies = updatedPolicies;
- if (updatedPolicies && updatedPolicies.length > 0) {
- this._enableApplyItems();
- this.setFocus();
- } else {
- this._disableApplyItems();
- }
- }
- }.bind(this), 100);
- },
- addSelection: function(selectedItems) { //NOSONAR
- var itemCount = 0;
- var numberAdded = 0;
- var dataTable = this.getListControl().getDatatable();
- var tableApi = dataTable.api();
- // need to check for duplicates and simply ignore them
- var oData = dataTable.fnGetData();
- selectedItems.forEach(function(item) {
- var itemId = item.id;
- var itemType = item.type;
- var itemName = item.defaultName;
- var foundDuplicate = this._isDuplicate(oData, itemId);
- itemCount = itemCount + 1;
- if ((!foundDuplicate) && (itemType !== 'namespaceFolder')) {
- numberAdded = numberAdded + 1;
- var policy = new Policy(itemName, itemId, itemType);
- tableApi.row.add(policy).draw(true);
- if(this.oData.data[0].policies !== null ) {
- this.oData.data[0].policies.push(policy);
- } else {
- this.oData.data[0].policies = [];
- this.oData.data[0].policies.push(policy);
- }
- }
- }.bind(this));
- var sToastMessage;
- if (numberAdded === 1) {
- sToastMessage = StringResource.get('toastItemsWereAddedSingular', {
- 'noOfItems': numberAdded
- });
- } else if (numberAdded === 0 && itemCount === 1) {
- sToastMessage = StringResource.get('toastItemsAlreadyAddedSingular');
- } else if (numberAdded === 0 && itemCount > 1) {
- sToastMessage = StringResource.get('toastItemsAlreadyAdded');
- } else {
- sToastMessage = StringResource.get('toastItemsWereAdded', {
- 'noOfItems': numberAdded
- });
- }
- this.glassContext.appController.showToast(sToastMessage);
- this._enableApplyItems();
- },
- _openAddMembersSlideout: function(oData) {
- this.glassContext.appController.showSlideOut({
- 'parent': this.slideout,
- 'width': '450', // temporary adjustment for R10 until panel size is unified
- 'content': {
- 'module': 'bi/admin/account/slideout/SecurityObjectSelectorPane',
- 'parentView': this,
- 'objectInfo': oData,
- 'title': StringResource.get('selectAccountGroupOrRole'),
- 'allowedSelectionTypes': ['group', 'role', 'account', 'namespace'],
- 'multiSelectCallback': this.addSelection.bind(this)
- }
- });
- },
- _birdBeakMenuItems: function() {
- return [{
- 'label': StringResource.get('permissionRead'),
- 'icon': '',
- 'onSelect': function() {
- var listCon = this.getListControl();
- if (listCon) {
- this._updatePermission(PolicyHelper.simplePermEnum.read, listCon.getSelectedObjects(), listCon.getSelectedRows());
- }
- }.bind(this)
- }, {
- 'label': StringResource.get('permissionRun'),
- 'icon': '',
- 'onSelect': function() {
- var listCon = this.getListControl();
- if (listCon) {
- this._updatePermission(PolicyHelper.simplePermEnum.run, listCon.getSelectedObjects(), listCon.getSelectedRows());
- }
- }.bind(this)
- }, {
- 'label': StringResource.get('permissionWrite'),
- 'icon': '',
- 'onSelect': function() {
- var listCon = this.getListControl();
- if (listCon) {
- this._updatePermission(PolicyHelper.simplePermEnum.write, listCon.getSelectedObjects(), listCon.getSelectedRows());
- }
- }.bind(this)
- }, {
- 'label': StringResource.get('permissionFull'),
- 'icon': '',
- 'onSelect': function() {
- var listCon = this.getListControl();
- if (listCon) {
- this._updatePermission(PolicyHelper.simplePermEnum.full, listCon.getSelectedObjects(), listCon.getSelectedRows());
- }
- }.bind(this)
- }];
- },
- _updatePermission: function(newPerm, selectedObjects, selectedRows) {
- var pos = 0;
- selectedObjects.forEach(function(policyObj) {
- policyObj.permissions = PolicyHelper.clonePermissionArray(newPerm);
- var currentRow = selectedRows[pos];
- if (currentRow) {
- this.getListControl().updateCell(policyObj, selectedRows[pos], 2);
- }
- pos += 1;
- }.bind(this));
- this.applyButton.enable();
- },
- _getColumnSpecification: function() {
- var columns = [];
- columns.push({
- 'type': 'Icon',
- 'getDataFn': function(oRowData) {
- if (oRowData.securityObject[ContentStoreObject.TYPE] === 'nil') {
- return 'unknown';
- } else {
- return oRowData.securityObject[ContentStoreObject.TYPE];
- }
- }
- });
- var multiPropItems = [];
- multiPropItems.push({
- 'type': 'Text',
- 'scope': 'row',
- 'label': StringResource.get('name'),
- 'getDataFn': function(oRowData) {
- if (oRowData.securityObject[ContentStoreObject.DEFAULT_NAME] === undefined) {
- return StringResource.get('unavailable');
- } else {
- var userData = this.oData.data[0];
- // check if the givenName, surName, and userName are available, otherwise display the defaultName
- return this._getUserName(userData, oRowData);
- }
- }.bind(this)
- });
- multiPropItems.push({
- 'type': 'Text',
- 'getDataFn': function(oRowData) {
- return this._getPath(oRowData);
- }.bind(this)
- });
- columns.push({
- 'type': 'MultipleProperties',
- 'items': multiPropItems
- });
- columns.push({
- 'type': 'MultipleProperties',
- 'orientation': 'horizontal',
- 'weight': 10,
- 'items': [{
- 'type': 'Permission',
- 'clickCallback': this._openPolicyDetailSlideoutView.bind(this)
- }, {
- 'type': 'BirdBeakMenu',
- 'name': StringResource.get('permissionSetAccess'),
- 'menuItems': this._birdBeakMenuItems()
- }]
- });
- columns.push({
- 'type': 'ClickableIcon',
- 'name': StringResource.get('policesRemove'),
- 'icon': 'common-remove-delete',
- 'clickCallback': this.removeSelection.bind(this),
- 'a11yLabel': StringResource.get('removeSelectedItem')
- });
- return columns;
- },
- _adjustWidth: function() {
- this.$el.addClass('pageview-small');
- },
- _refreshTable: function() {
- var selectedRow = this.getListControl().getSelectedRows();
- if (selectedRow.length > 0) {
- var selectedObject = this.getListControl().getSelectedObjects();
- this.getListControl().updateCell(selectedObject[0], selectedRow[0], 2);
- }
- },
- _getUserName: function(userData, oRowData){
- if(userData.userName && (userData.givenName && userData.surname) && (_.escape(userData.defaultName) === _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]))){
- return userData.givenName + ' ' + userData.surname + ' (' + userData.userName + ')';
- } else if(userData.userName && !(userData.givenName && userData.surname) && (_.escape(userData.defaultName) === _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]))){
- return _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]) + ' (' + userData.userName + ')';
- } else{
- return _.escape(oRowData.securityObject[ContentStoreObject.DEFAULT_NAME]);
- }
- },
- _getPath: function(oRowData) {
- var path = '';
- if (oRowData.securityObject[ContentStoreObject.ANCESTORS] && oRowData.securityObject[ContentStoreObject.ANCESTORS].length) {
- var ancestorsArray = oRowData.securityObject[ContentStoreObject.ANCESTORS];
- ancestorsArray.shift(); // remove 'Directory'
- for (var i=0; i< ancestorsArray.length; i++) {
- path += (path === '') ? ('') : (' > ');
- path += ancestorsArray[i].defaultName;
- }
- }
- return path;
- },
- _openPolicyDetailSlideoutView: function(oData) {
- this.slideout.addChild({
- 'width': '400',
- 'onHide': this._refreshTable.bind(this),
- 'enableTabLooping': true,
- 'content': {
- 'module': 'bi/content_apps/common/PolicyDetailsView',
- 'enableParentApplyButton': function() {
- this.applyButton.enable();
- }.bind(this),
- 'objectInformation': oData,
- 'ownerData': this.oData.data[0],
- 'canModify': this.canModifyPolicies
- }
- });
- },
- getListControl: function() {
- return this._listControl;
- },
- _showUnavailablePolicies: function() {
- var dataTable = this.getListControl().getDatatable();
- var tableApi = dataTable.api();
- this.rejectedPolicies.forEach(function(rejPol) {
- this.oData.data[0].policies.push(rejPol);
- tableApi.row.add(rejPol).draw(true);
- }.bind(this));
- this.rejectedPolicies = [];
- },
- _hideUnavailablePolicies: function() {
- var updatedPolicies = [];
- var index = 0;
- var rowsToRemove = [];
- this.oData.data[0].policies.forEach(function(pol) {
- if (pol.securityObject.type === 'nil') {
- this.rejectedPolicies.push(pol);
- rowsToRemove.push(index);
- } else {
- updatedPolicies.push(pol);
- }
- index += 1;
- }.bind(this));
- this.getListControl().removeIndexRows(rowsToRemove);
- this.oData.data[0].policies = updatedPolicies;
- },
- _toggleShowUnavailablePolicies: function() {
- var showUnavailablePolicies = this._oPropertyUIControl.getProperty('showUnavailablePolicies');
- var isChecked = showUnavailablePolicies.isChecked();
- if (isChecked) {
- this._showUnavailablePolicies();
- } else {
- this._hideUnavailablePolicies();
- }
- this.showUnavailablePolicies = !this.showUnavailablePolicies;
- },
- _createMultiSelectBar: function() {
- return (PolicyPropertyView.inherited('_createMultiSelectBar', this, arguments)).then(function() {
- var $actionEl = this.$el.find('.multiselectbar .policyMulSel');
- this.msddMenu = new DropDownMenu({
- dropDownMenuSpec: {
- 'title': StringResource.get('permissionSetAccess'),
- 'id': 'birdBeakIdms',
- 'label': 'BirdBeakMS',
- 'items': this._birdBeakMenuItems(),
- 'actionElement': $actionEl[0],
- 'ddMenuPlacement': 'bottom'
- }
- });
- this.msddMenu.render().then(function(el) {
- $actionEl.append(el);
- });
- return Promise.resolve(this);
- }.bind(this));
- },
- _multiselectbarItems: function() {
- return Promise.resolve([{
- 'name': 'SetLabel',
- 'position': 'leading',
- 'module': '../../lib/gemini/app/ui/toolbar_components/Label',
- 'label': 'Set',
- 'style': 'policyMultiSelectLabel'
- }, {
- 'name': 'birdBeakButton',
- 'position': 'leading',
- 'displayLabel': false,
- 'label': StringResource.get('permissionSetAccess'),
- 'icon': 'common-titan-arrow-down',
- 'module': './contentbar_components/Button',
- 'className': 'policyMulSel'
- }, {
- 'position': 'leading',
- 'type': 'Separator'
- }, {
- 'name': 'removeButton',
- 'position': 'leading',
- 'displayLabel': false,
- 'label': StringResource.get('removeSelectedItem'),
- 'icon': 'common-remove-delete',
- 'module': './contentbar_components/Button',
- 'className': 'policyMulSel',
- 'action': this.removeSelection.bind(this)
- }, {
- 'name': 'selectedLabel',
- 'position': 'center',
- 'label': StringResource.get('selected'),
- 'module': '../../lib/gemini/app/ui/toolbar_components/Label',
- 'style': 'selectedLabel'
- }, {
- 'name': 'cancelButton',
- 'position': 'trailing',
- 'label': StringResource.get('cancel'),
- 'text': StringResource.get('cancel'),
- 'labelOnly': true,
- 'module': './contentbar_components/Button',
- 'className': 'cancelButton',
- '_handleClick': function() {
- this._listControl._clearRows();
- this.multiselectBar.hide();
- this.contentBar.show();
- }.bind(this)
- }]);
- },
- _enableApplyItems: function() {
- this.applyToChildren.enable();
- this.applyButton.enable();
- },
- _disableApplyItems: function() {
- this.applyToChildren.disable();
- this.applyButton.disable();
- }
- });
- return PolicyPropertyView;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+----
- */
- define('bi/content_apps/PropertiesPermissionsTab',['q',
- 'bi/glass/app/ContentView',
- 'bacontentnav/utils/UIHelper',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bi/content_apps/common/PolicyPropertyView',
- 'bacontentnav/utils/ContentStoreObject',
- 'underscore'
- ], function(Q, View, UIHelper, PropertyUIControl, PolicyPropertyView, ContentStoreObject, _) {
- 'use strict';
- var PropertiesPermissionsTab = View.extend({
- /**
- @paran options.el {node} - container dom node
- **/
- init: function(options) {
- PropertiesPermissionsTab.inherited('init', this, arguments);
- _.extend(this, options);
- this.policyView = null;
- },
- render: function() {
- this.policyView = this._getPolicyPropertyView({
- 'el': this.$el,
- 'id': 'policyPropertyView',
- 'slideout': this.slideout,
- 'glassContext': this.glassContext,
- 'itemURL': ContentStoreObject.getSelfLink(this.objectInfo)
- });
- return this.policyView.render();
- },
- _getPolicyPropertyView: function(options) {
- return new PolicyPropertyView(options);
- }
- });
- return PropertiesPermissionsTab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2016, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+----
- */
- define('bi/content_apps/PropertiesTab',['q',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyTabView',
- 'bacontentnav/utils/ContentStoreObject',
- 'underscore'
- ], function(Q, PropertyTabView, ContentStoreObject, _) {
- 'use strict';
- var PropertiesTab = PropertyTabView.extend({
- /**
- * @paran options.el {node} - container dom node
- */
- init: function(options) {
- PropertiesTab.inherited('init', this, arguments);
- _.extend(this, options);
- },
- _setReportOption: function(optionBlob, option, bDefault) {
- for (var i = 0; i < optionBlob.length; i++) {
- //if options exists, either modify or remove it
- if (optionBlob[i].name === option.name) {
- if (bDefault) {
- optionBlob.splice(i, 1);
- } else {
- optionBlob[i].value = option.value;
- }
- return;
- }
- }
- if (!bDefault) {
- optionBlob.push(option);
- }
- },
- _setAdvancedOption: function(optionBlob, optionName, optionType, optionValue, defaultValue) {
- var option = {};
- option.name = optionName;
- option.type = optionType;
- option.value = optionValue;
- this._setReportOption(optionBlob, option, option.value === defaultValue);
- },
- _getRetentionValue: function(objectClass) {
- var retention = null;
- if (objectClass === 'history') {
- retention = ContentStoreObject.getRunHistoryConfig(this.objectInfo);
- } else if (objectClass === 'reportVersion') {
- retention = ContentStoreObject.getReportOutputVersionsConfig(this.objectInfo);
- }
- if (retention) {
- if (retention.maxDuration === undefined || !retention.maxDuration) {
- return retention.maxObjects;
- } else {
- return parseInt(retention.maxDuration.match(/\d+/), 10);
- }
- }
- return 1;
- },
- _getRetentionUnit: function(objectClass) {
- var retention = null;
- if (objectClass === 'history') {
- retention = ContentStoreObject.getRunHistoryConfig(this.objectInfo);
- } else if (objectClass === 'reportVersion') {
- retention = ContentStoreObject.getReportOutputVersionsConfig(this.objectInfo);
- }
- if (retention) {
- if (retention.maxDuration === undefined || !retention.maxDuration) {
- return 'occurrences';
- } else {
- var list = retention.maxDuration.split(/\d+/);
- return list[1] === 'D' ? 'days' : 'months';
- }
- }
- return 'occurrences';
- },
- _getReportRetentions: function() {
- return ContentStoreObject.getReportRetentions(this.objectInfo);
- },
- _setReportRetention: function(retentionBlob, value, unit, ojbectClass) {
- var retention = {
- 'prop': 'creationTime',
- 'objectClass': ojbectClass
- };
- if (retentionBlob) {
- for (var i = 0; i < retentionBlob.length; i++) {
- if (retentionBlob[i].objectClass === ojbectClass) {
- retention = retentionBlob[i];
- break;
- }
- }
- }
- this._setRetentionValue(retention, value, unit);
- },
- _getModifiedRetentions: function(modifiedProperties, modifiedPropertiesUI) {
- var retentionBlob = this._getReportRetentions();
- var retentionModified = false;
- if (modifiedPropertiesUI.hasOwnProperty('runHistory') || modifiedPropertiesUI.hasOwnProperty('runHistoryUnit')) {
- retentionModified = true;
- this._setReportRetention(retentionBlob, modifiedPropertiesUI.runHistory, modifiedPropertiesUI.runHistoryUnit, 'history');
- delete modifiedPropertiesUI.runHistory;
- delete modifiedPropertiesUI.runHistoryUnit;
- }
- if (modifiedPropertiesUI.hasOwnProperty('reportVersion') || modifiedPropertiesUI.hasOwnProperty('reportVersionUnit')) {
- retentionModified = true;
- this._setReportRetention(retentionBlob, modifiedPropertiesUI.reportVersion, modifiedPropertiesUI.reportVersionUnit, 'reportVersion');
- delete modifiedPropertiesUI.reportVersion;
- delete modifiedPropertiesUI.reportVersionUnit;
- }
- if (retentionModified) {
- _.extend(modifiedProperties, {
- 'retentions': retentionBlob
- });
- }
- },
- _setRetentionValue: function(retention, value, unit) {
- if (value >= 0) {
- if (unit) {
- //both modified
- if (unit === 'occurrences') {
- retention.maxObjects = value;
- delete retention.maxDuration;
- } else {
- retention.maxObjects = 0;
- retention.maxDuration = 'P' + value + (unit === 'days' ? 'D' : 'M');
- }
- } else {
- //only value modified
- if (retention.maxDuration) {
- retention.maxDuration = retention.maxDuration.replace(/\d+/, value);
- } else {
- retention.maxObjects = value;
- }
- }
- } else {
- if (unit) {
- //only unit modified
- if (unit === 'occurrences') {
- if (retention.maxDuration) {
- retention.maxObjects = parseInt(retention.maxDuration.match(/\d+/), 10);
- delete retention.maxDuration;
- }
- } else {
- if (retention.maxDuration) {
- retention.maxDuration = retention.maxDuration.replace(/(\w+)(\d+)(\w+)/, '$1$2' + (unit === 'days' ? 'D' : 'M'));
- } else {
- retention.maxDuration = 'P' + retention.maxObjects + (unit === 'days' ? 'D' : 'M');
- retention.maxObjects = 0;
- }
- }
- }
- }
- }
- });
- return PropertiesTab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/PromptValuesView',[
- 'jquery',
- 'bi/glass/app/ContentView',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bi/schedule/views/PromptPickerView',
- 'bacontentnav/utils/UIHelper',
- 'underscore'
- ],
- function($, ContentView, StringResource, ContentStoreObject, PropertyUIControl, PromptPicker, UIHelper, _) {
- 'use strict';
- var PromptValuesView = ContentView.extend({
- init: function(options) {
- PromptValuesView.inherited('init', this, arguments);
- _.extend(this, options);
- this.showClickables = (typeof this.isEditMode === 'undefined') ? true : this.isEditMode;
- },
- render: function() {
- var _clickables = [{}];
- if (this.showClickables) {
- _clickables = [{
- 'type': 'text',
- 'name': 'editPromptValues',
- 'value': this._getBannerEditSetText()
- }, {
- 'type': 'text',
- 'value': StringResource.get('clear'),
- 'name': 'clearPromptValues',
- 'clickCallback': function() {
- this.promptDisplayValues = [];
- this._getPromptValuesSection().refreshProperties([]);
- if (this.clearCallback) {
- this.clearCallback();
- }
- }.bind(this)
- }];
- }
- this._oPropertyUIControl = new PropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'items': [{
- 'type': 'Banner',
- 'name': 'promptValuesBanner',
- 'id': this.viewId,
- 'value': StringResource.get('currentValues'),
- 'centerLabel': true,
- 'backButton': this.slideout.overlay,
- 'editable': false,
- 'readOnly': true,
- 'onClose': function() {
- this.slideout.hide();
- }.bind(this),
- 'clickables': _clickables
- }, {
- 'type': 'CollapsibleSection',
- 'name': 'SectionPromptValues',
- 'styleAsSimpleRow': true,
- 'hideSectionTitle': true,
- 'open': true,
- 'items': this._getPromptItems(this.promptDisplayValues)
- }]
- });
- if (!this._areValueSet()) {
- this._renderEmptyPaneInfoMessage(this.$el);
- }
- return this._oPropertyUIControl.render().then(function() {
- this._renderPromptPicker();
- }.bind(this));
- },
- _areValueSet: function() {
- return (this._getPromptItems(this.promptDisplayValues).length !== 0) ? true : false;
- },
- _getBannerEditSetText: function() {
- var str = (this._areValueSet()) ? 'edit' : 'set';
- return StringResource.get(str);
- },
- _renderEmptyPaneInfoMessage: function($node) {
- UIHelper.renderInfoMessage($node, StringResource.get('noPromptsValuesSet'));
- },
- _removeEmptyPaneInfoMessage: function($node) {
- $node.find('div.contentApps_comingSoon').remove();
- },
- _renderPromptPicker: function() {
- this.promptPicker = new PromptPicker({
- $toggler: this.$el.find('div[class^="editPromptValues' + this.viewId + ' "]'),
- reportId: this.parentView && this.parentView.objectInfo.id,
- values: this.parameters,
- useValues: this.useParameters !== false,
- glassContext: this.glassContext,
- onFinish: function() {
- this._onEditFinish();
- }.bind(this)
- });
- this.promptPicker.render();
- },
- _onEditFinish: function() {
- this.parameters = this.promptPicker.getParameterValues();
- this.promptDisplayValues = ContentStoreObject.getPromptsDisplayValues(this.parameters);
- var items = this._getPromptItems(this.promptDisplayValues);
- this._getPromptValuesSection().refreshProperties(items);
- if (this.editCallback) {
- this.editCallback(this.parameters);
- }
- this._removeEmptyPaneInfoMessage(this.$el);
- },
- _getPromptValuesSection: function() {
- return this._oPropertyUIControl.getProperty('SectionPromptValues');
- },
- _getPromptItems: function(promptDisplayValues) {
- var items = [];
- if (promptDisplayValues) {
- for (var i = 0; i < promptDisplayValues.length; i = i + 1) {
- items.push({
- 'type': 'Separator'
- });
- var label = _.escape(promptDisplayValues[i].name),
- display = promptDisplayValues[i].display;
- var singleLine = {
- 'type': 'SingleLineValue',
- 'name': label,
- 'label': label,
- 'value': display
- };
- items.push(singleLine);
- }
- }
- return items;
- },
- setFocus: function() {
- this._oPropertyUIControl.setFocus('promptValuesBanner');
- }
- });
- return PromptValuesView;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *|
- *| IBM Cognos Products: content-apps
- *|
- *| (C) Copyright IBM Corp. 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/utils/Utils',[], function() {
- 'use strict';
- var reHtmlEncode = /[<>&]/g;
- var htmlEncode = {
- '&': '&',
- '<': '<',
- '>': '>'
- };
- var reXmlEncode = /[<>&'"]/g;
- var xmlEncode = {
- '&': '&',
- '<': '<',
- '>': '>',
- '\'': ''',
- '"': '"'
- };
- return {
- /**
- * Returns the html encoded version of the given text
- * @param {string} text
- * @return {string}
- */
- htmlEncode: function(text) {
- return (text || '').replace(reHtmlEncode, function(m) {
- return htmlEncode[m];
- });
- },
- /**
- * Returns the xml encoded version of the given text
- * ... 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
- * @param {string} text
- * @return {string}
- */
- xmlEncode: function(text) {
- if (text || text === 0) {
- return String(text).replace(reXmlEncode, function(m) {
- return xmlEncode[m];
- });
- } else {
- return '';
- }
- }
- };
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/PdfOptionsView',[
- 'jquery',
- 'underscore',
- 'bi/content_apps/nls/StringResource',
- 'bi/content_apps/utils/Utils',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyPageView',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyUIControl',
- 'bacontentnav/utils/GlassContextHelper'
- ], function($, _, StringResource, Utils, PropertyPageView, PropertyUIControl, GlassContextHelper) {
- 'use strict';
- var PdfOptionsView = PropertyPageView.extend({
- /**
- @param options.el {node} - container dom node
- @param options.pdfOptions {array} - PDF options in format same as Content Rest API
- @param options.glassContext {object} - Glass context
- @param options.closeCallback {function} - callback when the view is closed, pass current option values in format same as Content Rest API.
- [{ name : <option name>
- value : <option value>
- type : <option type>
- },...]
- For userPassword and ownerPassword, the format for the value is: '<credential><password>value</password></credential>'
- @param options.showCancel {boolean} - Default is false. If true, 'Cancel' button will be rendered in the banner
- @param options.overlay {boolean} - Default is false. If true, 'Back' button will be rendered in the banner
- **/
- init: function(options) {
- PdfOptionsView.inherited('init', this, arguments);
- _.extend(this, options);
- },
- _getBannerSpec: function() {
- var spec = {
- 'type': 'Banner',
- 'name': 'pdfOptionsBanner',
- 'value': StringResource.get('pdfOptions'),
- 'centerLabel': true,
- 'backButton': this.slideout.overlay,
- 'editable': false,
- 'readOnly': true,
- 'onClose': function() {
- var modifiedProperties = this.getModifiedProperties();
- var isValid = this._validatePasswords(modifiedProperties);
- if (!isValid) {
- GlassContextHelper.displayToast(this.glassContext, StringResource.get('passwordNotMatched'), {
- 'type': 'warning'
- });
- } else {
- this.slideout.hide();
- if (this.closeCallback) {
- var fullPDFOptions = this._getFullPdfOptions(this._getOptions(), modifiedProperties);
- this.closeCallback(fullPDFOptions);
- }
- }
- }.bind(this)
- };
- if (this.showCancel) {
- spec.clickables = [{
- 'type': 'text',
- 'value': StringResource.get('cancel'),
- 'class': 'cancelPdfOptions',
- 'clickCallback': function() {
- this.cancelled = true;
- this.slideout.hide();
- if (this.cancelCallback) {
- this.cancelCallback();
- }
- }.bind(this)
- }];
- }
- return spec;
- },
- render: function() {
- var optionOO = this._getOption(this._getOptions(), 'outputPageOrientation');
- var optionOD = this._getOption(this._getOptions(), 'outputPageDefinition');
- var optionOwnerPassword = this._getOption(this._getOptions(), 'ownerPassword');
- var ownerPasswordValue = this._getPasswordValue(optionOwnerPassword);
- var optionUserPassword = this._getOption(this._getOptions(), 'userPassword');
- var userPasswordValue = this._getPasswordValue(optionUserPassword);
- return this.renderPropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'items': [
- this._getBannerSpec(), {
- 'type': 'DropDown',
- 'name': 'outputPageOrientation',
- 'label': StringResource.get('Orientation'),
- 'options': [{
- 'label': StringResource.get('default'),
- 'value': 'default',
- 'selected': optionOO === undefined
- }, {
- 'label': StringResource.get('portrait'),
- 'value': 'portrait',
- 'selected': optionOO && optionOO.value === 'portrait'
- }, {
- 'label': StringResource.get('landscape'),
- 'value': 'landscape',
- 'selected': optionOO && optionOO.value === 'landscape'
- }]
- }, {
- 'type': 'Separator'
- }, {
- 'type': 'DropDown',
- 'name': 'outputPageDefinition',
- 'label': StringResource.get('pageSize'),
- 'options': [{
- 'label': StringResource.get('default'),
- 'value': 'default',
- 'selected': optionOD === undefined
- }, {
- 'label': StringResource.get('letter'),
- 'value': '/configuration/pageDefinition[@name=\'Letter\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'Letter\']'
- }, {
- 'label': StringResource.get('legal'),
- 'value': '/configuration/pageDefinition[@name=\'Legal\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'Legal\']'
- }, {
- 'label': StringResource.get('11x17'),
- 'value': '/configuration/pageDefinition[@name=\'11x17\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'11x17\']'
- }, {
- 'label': StringResource.get('A3'),
- 'value': '/configuration/pageDefinition[@name=\'A3\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'A3\']'
- }, {
- 'label': StringResource.get('A4'),
- 'value': '/configuration/pageDefinition[@name=\'A4\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'A4\']'
- }, {
- 'label': StringResource.get('B4JIS'),
- 'value': '/configuration/pageDefinition[@name=\'B4 JIS\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'B4 JIS\']'
- }, {
- 'label': StringResource.get('B5JIS'),
- 'value': '/configuration/pageDefinition[@name=\'B5 JIS\']',
- 'selected': optionOD && optionOD.value === '/configuration/pageDefinition[@name=\'B5 JIS\']'
- }]
- }, {
- 'type': 'Separator'
- }, {
- 'name': 'checkboxUserPassword',
- 'checked': optionUserPassword !== undefined,
- 'label': StringResource.get('requiresPasswordToOpenReport'),
- 'type': 'CheckBox',
- 'onChange': function(propertyName, propertyValue) {
- this._passwordCheckOnChange(propertyValue, 'userPassword', 'userPasswordConfirm');
- }.bind(this)
- }, {
- 'name': 'userPassword',
- 'label': StringResource.get('password'),
- 'ariaLabel': StringResource.get('requiresPasswordToOpenReport'),
- 'value': userPasswordValue,
- 'indent': 2,
- 'editable': true,
- 'disabled': optionUserPassword === undefined,
- 'type': 'SingleLineValue',
- 'multiline': true,
- 'inputType': 'password',
- 'showEmptyBorder': true,
- 'highlightTextOnFocus': true
- }, {
- 'name': 'userPasswordConfirm',
- 'label': StringResource.get('confirmPassword'),
- 'ariaLabel': StringResource.get('requiresPasswordToOpenReport') + ' ' + StringResource.get('confirmPassword'),
- 'value': userPasswordValue,
- 'indent': 2,
- 'editable': true,
- 'disabled': optionUserPassword === undefined,
- 'type': 'SingleLineValue',
- 'multiline': true,
- 'inputType': 'password',
- 'showEmptyBorder': true,
- 'highlightTextOnFocus': true
- }, {
- 'type': 'Separator'
- }, {
- 'name': 'checkboxOwnerPassword',
- 'checked': optionOwnerPassword !== undefined,
- 'label': StringResource.get('requiresPasswordToAccessOptions'),
- 'type': 'CheckBox',
- 'onChange': function(propertyName, propertyValue) {
- this._passwordCheckOnChange(propertyValue, 'ownerPassword', 'ownerPasswordConfirm');
- }.bind(this)
- }, {
- 'name': 'ownerPassword',
- 'label': StringResource.get('password'),
- 'ariaLabel': StringResource.get('requiresPasswordToAccessOptions'),
- 'value': ownerPasswordValue,
- 'indent': 2,
- 'editable': true,
- 'disabled': optionOwnerPassword === undefined,
- 'type': 'SingleLineValue',
- 'multiline': true,
- 'inputType': 'password',
- 'showEmptyBorder': true,
- 'highlightTextOnFocus': true
- }, {
- 'name': 'ownerPasswordConfirm',
- 'label': StringResource.get('confirmPassword'),
- 'ariaLabel': StringResource.get('requiresPasswordToAccessOptions') + ' ' + StringResource.get('confirmPassword'),
- 'value': ownerPasswordValue,
- 'indent': 2,
- 'editable': true,
- 'disabled': optionOwnerPassword === undefined,
- 'type': 'SingleLineValue',
- 'multiline': true,
- 'inputType': 'password',
- 'showEmptyBorder': true,
- 'highlightTextOnFocus': true
- }
- ]
- });
- },
- _getPasswordValue: function(option) {
- var passwordValue = '';
- if (!option) {
- return passwordValue;
- }
- if (!this.isEncrypedPassword(option.value)) {
- var pwd = option.value;
- var optionEncrypted = this._createOption(option.name, option.value);
- option.value = optionEncrypted.value;
- return pwd;
- }
- if (option.value.length > 0) {
- var xmlDoc = $.parseXML(option.value);
- var $pwd = $(xmlDoc).find('password');
- if ($pwd.text().length) {
- passwordValue = $pwd.text();
- } else {
- // If the password is encrypted just use a 8 letter string so the password field looks good
- $pwd = $(xmlDoc).find('encryptedValue');
- if ($pwd.text().length) {
- passwordValue = '********';
- }
- }
- }
- return passwordValue;
- },
- _passwordCheckOnChange: function(check, passwordName, passwordConfirmName) {
- var password = this._oPropertyUIControl.getProperty(passwordName);
- var passwordConfirm = this._oPropertyUIControl.getProperty(passwordConfirmName);
- if (check) {
- password.enable();
- passwordConfirm.enable();
- } else {
- password.disable();
- password.setValue('');
- passwordConfirm.disable();
- passwordConfirm.setValue('');
- }
- },
- onClose: function() {
- if (this._oPropertyUIControl) {
- return this._oPropertyUIControl.onClose();
- }
- },
- getModifiedProperties: function() {
- if (this.cancelled) {
- return null;
- }
- if (this._oPropertyUIControl) {
- return this._oPropertyUIControl.getModifiedProperties();
- }
- return null;
- },
- //this method could be optimized..
- _validatePasswords: function(modifiedProperties) {
- if (!modifiedProperties) {
- return true;
- }
- if (modifiedProperties.userPassword || modifiedProperties.userPasswordConfirm) {
- if (modifiedProperties.userPassword !== modifiedProperties.userPasswordConfirm) {
- this._oPropertyUIControl.getProperty('userPassword').getHTMLControl().focus();
- return false;
- }
- }
- if (modifiedProperties.ownerPassword || modifiedProperties.ownerPasswordConfirm) {
- if (modifiedProperties.ownerPassword !== modifiedProperties.ownerPasswordConfirm) {
- this._oPropertyUIControl.getProperty('ownerPassword').getHTMLControl().focus();
- return false;
- }
- }
- if (modifiedProperties.checkboxUserPassword !== undefined) {
- if (modifiedProperties.checkboxUserPassword) {
- if (!modifiedProperties.userPassword || !modifiedProperties.userPasswordConfirm) {
- return false;
- }
- } else {
- if (modifiedProperties.userPassword || modifiedProperties.userPasswordConfirm) {
- return false;
- }
- }
- } else {
- if (modifiedProperties.userPassword !== undefined && !modifiedProperties.userPassword) {
- return false;
- }
- }
- if (modifiedProperties.checkboxOwnerPassword !== undefined) {
- if (modifiedProperties.checkboxOwnerPassword) {
- if (!modifiedProperties.ownerPassword || !modifiedProperties.ownerPasswordConfirm) {
- return false;
- }
- } else {
- if (modifiedProperties.ownerPassword || modifiedProperties.ownerPasswordConfirm) {
- return false;
- }
- }
- } else {
- if (modifiedProperties.ownerPassword !== undefined && !modifiedProperties.ownerPassword) {
- return false;
- }
- }
- return true;
- },
- _setOption: function(optionBlob, option, bDefault) {
- for (var i = 0; i < optionBlob.length; i = i + 1) {
- //if options exists, either modify or remove it
- if (optionBlob[i].name === option.name) {
- if (bDefault) {
- optionBlob.splice(i, 1);
- } else {
- optionBlob[i].value = option.value;
- }
- return;
- }
- }
- if (!bDefault) {
- optionBlob.push(option);
- }
- },
- //get all the selected PDF options in the UI
- _getFullPdfOptions: function(options, modifiedProperties) {
- var result = [];
- options.forEach(function(item) {
- result.push(item);
- });
- if (modifiedProperties) {
- if (modifiedProperties.outputPageDefinition) {
- var optionOutputPageDefinition = this._createOption('outputPageDefinition', modifiedProperties.outputPageDefinition);
- this._setOption(result, optionOutputPageDefinition, modifiedProperties.outputPageDefinition === 'default');
- }
- if (modifiedProperties.outputPageOrientation) {
- var optionOutputPageOrientation = this._createOption('outputPageOrientation', modifiedProperties.outputPageOrientation);
- this._setOption(result, optionOutputPageOrientation, modifiedProperties.outputPageOrientation === 'default');
- }
- if (modifiedProperties.userPassword !== undefined) {
- var optionUserPassword = this._createOption('userPassword', modifiedProperties.userPassword);
- this._setOption(result, optionUserPassword, modifiedProperties.userPassword.length === 0);
- }
- if (modifiedProperties.ownerPassword !== undefined) {
- var optionOwnerPassword = this._createOption('ownerPassword', modifiedProperties.ownerPassword);
- this._setOption(result, optionOwnerPassword, modifiedProperties.ownerPassword.length === 0);
- }
- if (modifiedProperties.checkboxOwnerPassword !== undefined) {
- var checkOptions = this._getCheckOptions(modifiedProperties.checkboxOwnerPassword);
- for (var i = 0; i < checkOptions.length; i = i + 1) {
- this._setOption(result, checkOptions[i], false);
- }
- }
- }
- return result;
- },
- _getOption: function(options, optionName) {
- var option;
- for (var i = 0; i < options.length; i = i + 1) {
- if (options[i].name === optionName) {
- option = options[i];
- break;
- }
- }
- return option;
- },
- _getOptions: function() {
- if (!this.pdfOptions) {
- this.pdfOptions = [];
- }
- return this.pdfOptions;
- },
- _getCheckOptions: function(checkboxOwnerPassword) {
- return [{
- 'name': 'allowPrintQuality',
- 'type': 'pdfOptionPrintQuality',
- 'value': checkboxOwnerPassword ? 'none' : 'lowOrHigh'
- }, {
- 'name': 'allowModifications',
- 'type': 'pdfOptionBoolean',
- 'value': checkboxOwnerPassword ? false : true
- }, {
- 'name': 'allowAnnotations',
- 'type': 'pdfOptionBoolean',
- 'value': checkboxOwnerPassword ? false : true
- },
- {
- 'name': 'allowFieldCompletion',
- 'type': 'pdfOptionBoolean',
- 'value': checkboxOwnerPassword ? false : true
- }, {
- 'name': 'allowAssembly',
- 'type': 'pdfOptionBoolean',
- 'value': checkboxOwnerPassword ? false : true
- }, {
- 'name': 'allowContentCopy',
- 'type': 'pdfOptionBoolean',
- 'value': checkboxOwnerPassword ? false : true
- }, {
- 'name': 'allowAccessibilitySupport',
- 'type': 'pdfOptionBoolean',
- 'value': true
- }];
- },
- // override base functionality of PropertyPageView which closes the slideout
- _canClose: function() {
- return true;
- },
- _createOption: function(name, value) {
- var option;
- if (name === 'outputPageDefinition') {
- option = {
- 'name': 'outputPageDefinition',
- 'type': 'runOptionString',
- 'value': value
- };
- } else if (name === 'outputPageOrientation') {
- option = {
- 'name': 'outputPageOrientation',
- 'type': 'runOptionString',
- 'value': value
- };
- } else if (name === 'userPassword') {
- option = {
- 'name': 'userPassword',
- 'type': 'pdfOptionXMLEncodedXML',
- 'value': '<credential><password>' + Utils.xmlEncode(value) + '</password></credential>'
- };
- } else if (name === 'ownerPassword') {
- option = {
- 'name': 'ownerPassword',
- 'type': 'pdfOptionXMLEncodedXML',
- 'value': '<credential><password>' + Utils.xmlEncode(value) + '</password></credential>'
- };
- }
- return option;
- },
- remove: function() {
- if (!this.slideout.overlay) {
- this.onClose();
- }
- },
- isEncrypedPassword: function(password) {
- var pattValue = /<credential><encryptedValue>.*<\/encryptedValue><\/credential>/;
- var pattPwd = /<credential><password>.*<\/password><\/credential>/;
- return pattValue.test(password) || pattPwd.test(password);
- },
- setFocus: function() {
- if (this.slideout.overlay) {
- this._oPropertyUIControl.setFocus('pdfOptionsBanner');
- } else {
- this._oPropertyUIControl.setFocus('outputPageOrientation');
- }
- }
- });
- return PdfOptionsView;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/authoring/AuthoringHelper',[
- 'bacontentnav/utils/ContentStoreObject',
- 'bacontentnav/utils/UIHelper'
- ], function(ContentStoreObject, UIHelper) {
- 'use strict';
- var AuthoringHelper = {
- _getFormatIndex: function(objectInfo) {
- var objectFormatType = AuthoringHelper._getObjectType(objectInfo);
- if (AuthoringHelper.SUPPORTED_FORMATS[objectFormatType]) {
- return objectFormatType;
- }
- return 'all';
- },
- _getObjectType: function(objectInfo) {
- var objectType = ContentStoreObject.getType(objectInfo);
- if (objectType === 'powerPlay8ReportView') {
- return 'powerPlay8Report';
- } else {
- var baseTypes = UIHelper.getBaseTypes(objectType);
- if (baseTypes && baseTypes.length > 0) {
- return ContentStoreObject.getBase(objectInfo) && ContentStoreObject.getBase(objectInfo).type || objectType;
- }
- }
- return objectType;
- },
- setReportType: function(requestParams, objectInfo) {
- if (AuthoringHelper._getObjectType(objectInfo) === 'powerPlay8Report') {
- requestParams.reportType = 'powerPlay8Report';
- }
- },
- getSupportedFormats: function(objectInfo) {
- return AuthoringHelper.SUPPORTED_FORMATS[AuthoringHelper._getFormatIndex(objectInfo)];
- },
- userCanGenerateFormat: function(glassContext, format) {
- var capability = AuthoringHelper.FORMAT_CAPABILITY_MAP[format];
- return (capability) ? glassContext.hasCapability(capability) : true;
- }
- };
- AuthoringHelper.SUPPORTED_FORMATS = {
- 'all': ['spreadsheetML', 'xlsxData', 'PDF', 'HTML', 'CSV', 'XML'],
- 'interactiveReport': ['HTML'],
- 'powerPlay8Report': ['PDF']
- };
- AuthoringHelper.FORMAT_CAPABILITY_MAP = {
- 'HTML': null,
- 'PDF': 'canGeneratePDFOutput',
- 'spreadsheetML': 'canGenerateXLSOutput',
- 'xlsxData': 'canGenerateXLSOutput',
- 'CSV': 'canGenerateCSVOutput',
- 'XML': 'canGenerateXMLOutput'
- };
- AuthoringHelper.FORMAT_MESSAGE_KEY_MAP = {
- 'HTML': 'html',
- 'PDF': 'pdf',
- 'spreadsheetML': 'spreadsheetML',
- 'xlsxData': 'xlsxData',
- 'CSV': 'csv',
- 'XML': 'xml'
- };
- return AuthoringHelper;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2016, 2022
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/PropertiesReportTab',[
- 'bi/content_apps/PropertiesTab',
- 'bi/content_apps/utils/C10Utils',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'bacontentnav/utils/GlassContextHelper',
- 'bi/content_apps/PromptValuesView',
- 'bi/content_apps/PdfOptionsView',
- 'underscore',
- 'bi/content_apps/authoring/AuthoringHelper'
- ], function(PropertiesTab, C10Utils, StringResource, ContentStoreObject, GlassContextHelper, PromptValuesView, PdfOptionsView, _, AuthoringHelper) {
- 'use strict';
- var PropertiesReportTab = PropertiesTab.extend({
- ACTION_VIEW: 'viewOutput',
- ACTION_RUN: 'run',
- ACTION_EDIT: 'edit',
- RUNASOWNER: 'runAsOwnerRadio',
- pdfOptionNames: ['outputPageDefinition', 'outputPageOrientation', 'userPassword', 'ownerPassword', 'allowPrintQuality',
- 'allowModifications', 'allowAnnotations', 'allowFieldCompletion', 'allowAssembly', 'allowContentCopy', 'allowAccessibilitySupport'
- ],
- /**
- @param options.el {node} - container dom node
- **/
- init: function(options) {
- PropertiesReportTab.inherited('init', this, arguments);
- _.extend(this, options);
- this._getPdfOptions();
- },
- render: function() {
- return new Promise(function(resolve /*, reject*/ ) {
- this._id = _.uniqueId('prop_');
- var items = [];
- var reportOptionItems = [this._getFormatSpec(), {
- 'type': 'Separator',
- 'indent': 2
- }];
- if (this.objectInfo.type.indexOf('powerPlay8Report') === -1) {
- reportOptionItems.push({
- 'name': 'setPdfOptions',
- 'label': StringResource.get('pdfOptions'),
- 'value': StringResource.get('set'),
- 'indent': 2,
- 'type': 'SingleLineValue',
- 'ellipses': true,
- 'editCallback': function() {
- this._openPdfOptionsView();
- }.bind(this)
- }, {
- 'type': 'Separator',
- 'indent': 2
- });
- }
- return this._getLanguages()
- .then(function(languages) {
- reportOptionItems.push({
- 'type': 'DropDown',
- 'name': ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES,
- 'label': StringResource.get('enableAccessibilitySupport'),
- 'indent': 2,
- 'options': [{
- 'label': StringResource.get('default'),
- 'value': null,
- 'selected': this._getEnableAccessibilitySupport() === null
- }, {
- 'label': StringResource.get('True'),
- 'value': true,
- 'selected': this._getEnableAccessibilitySupport() === true
- }, {
- 'label': StringResource.get('False'),
- 'value': false,
- 'selected': this._getEnableAccessibilitySupport() === false
- }]
- }, {
- 'type': 'Separator',
- 'indent': 2
- }, {
- 'type': 'DropDown',
- 'name': ContentStoreObject.OPTION_OUTPUT_LOCALE,
- 'label': StringResource.get('language'),
- 'indent': 2,
- 'options': languages,
- 'position': 'left',
- 'parentEl': this.slideout.$el
- }, {
- 'type': 'Separator',
- 'indent': 2
- });
- items.push({
- 'name': 'package',
- 'label': StringResource.get('source'),
- 'value': this._getPackageOrModule(),
- 'type': 'SingleLineValue'
- });
- items.push({
- 'name': 'promptValues',
- 'label': StringResource.get('promptValues'),
- 'type': 'SectionLabel'
- });
- items.push({
- 'name': 'executionPrompt',
- 'checked': this._getPromptValue(),
- 'label': StringResource.get('executionPrompt'),
- 'type': 'CheckBox'
- });
- items.push({
- 'type': 'Separator'
- });
- items.push({
- 'name': 'currentPromptValues',
- 'label': StringResource.get('currentValues'),
- 'value': this._getPromptValueLabel(),
- 'type': 'SingleLineValue',
- 'ellipses': true,
- 'editCallback': function() {
- this._openPromptsValuesView();
- }.bind(this)
- });
- items.push({
- 'type': 'Separator'
- });
- items.push({
- 'type': 'CollapsibleSection',
- 'label': StringResource.get('reportOptions'),
- 'open': false,
- 'name': 'reportOptions',
- 'items': reportOptionItems
- });
- return this._getAdvancedItems()
- .then(function(advancedItems) {
- items.push({
- 'type': 'CollapsibleSection',
- 'name': 'advancedReportProperties',
- 'label': StringResource.get('advancedProperties'),
- 'items': advancedItems
- });
- this.renderPropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'readOnly': !ContentStoreObject.hasPermissions(this.objectInfo, ['write']),
- 'items': items
- }).then(function() {
- resolve(this);
- }.bind(this));
- }.bind(this));
- }.bind(this));
- }.bind(this));
- },
- onClose: function() {
- this._closePdfOptionView();
- if(this.getPropertyUIControl() === undefined){
- return this.renderPropertyUIControl().then(function() {
- return this.getPropertyUIControl().onClose();
- }.bind(this));
- }
- return this.getPropertyUIControl().onClose();
- },
- getModifiedProperties: function() {
- var modifiedProperties = {};
- var modifiedPropertiesUI = this.getPropertyUIControl().getModifiedProperties();
- //deal with run as owner property
- this._getModifiedRunAsOwner(modifiedProperties, modifiedPropertiesUI);
- //deal with report options
- this._getModifiedOptions(modifiedProperties, modifiedPropertiesUI);
- //deal with history/output version settings
- this._getModifiedRetentions(modifiedProperties, modifiedPropertiesUI);
- _.extend(modifiedProperties, modifiedPropertiesUI);
- this.logger.debug('PropertiesReportTab.getModifiedProperties', modifiedProperties);
- return modifiedProperties;
- },
- _getFormatSpec: function() {
- var formatSpec;
- if (this.objectInfo.type === 'interactiveReport') {
- formatSpec = {
- 'type': 'SingleLineLinks',
- 'indent': 2,
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('format')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('html')
- }]
- }]
- };
- } else if (C10Utils.isPowerPlay(this.objectInfo.type)) {
- formatSpec = {
- 'type': 'SingleLineLinks',
- 'indent': 2,
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('format')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('pdf')
- }]
- }]
- };
- } else {
- formatSpec = {
- 'type': 'DropDown',
- 'name': ContentStoreObject.OPTION_OUTPUT_FORMAT,
- 'label': StringResource.get('format'),
- 'indent': 2,
- 'options': [{
- 'label': StringResource.get('default'),
- 'value': '',
- 'selected': this._getOutputFormat() === null
- }]
- };
- var supportedFormats = AuthoringHelper.getSupportedFormats(this.objectInfo);
- supportedFormats.forEach(function(format) {
- formatSpec.options.push({
- 'label': StringResource.get(AuthoringHelper.FORMAT_MESSAGE_KEY_MAP[format]),
- 'value': format,
- 'selected': this._getOutputFormat() === format
- });
- }.bind(this));
- }
- return formatSpec;
- },
- _getAdvancedItems: function() {
- return new Promise(function(resolve /*, reject*/ ) {
- var advancedItems = [{
- 'type': 'SingleLineLinks',
- 'name': 'sectionRunHistory',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'labelFor': 'runHistory',
- 'type': 'text',
- 'value': StringResource.get('runHistory')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'Input',
- 'name': 'runHistory',
- 'ellipses': false,
- 'inputClass': 'narrowInput',
- 'value': this._getRetentionValue('history'),
- 'validator': {
- 'isNumber': true
- }
- }, {
- 'type': 'DropDown',
- 'name': 'runHistoryUnit',
- 'ariaLabel': StringResource.get('runHistoryUnits'),
- 'options': [{
- 'label': StringResource.get('occurrences'),
- 'value': 'occurrences',
- 'selected': 'occurrences' === this._getRetentionUnit('history')
- }, {
- 'label': StringResource.get('days'),
- 'value': 'days',
- 'selected': 'days' === this._getRetentionUnit('history')
- }, {
- 'label': StringResource.get('months'),
- 'value': 'months',
- 'selected': 'months' === this._getRetentionUnit('history')
- }]
- }]
- }]
- }, {
- 'type': 'Separator'
- }, {
- 'type': 'SingleLineLinks',
- 'name': 'sectionReportVersion',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'labelFor': 'reportVersion',
- 'type': 'text',
- 'value': StringResource.get('reportOutputVersions')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'Input',
- 'name': 'reportVersion',
- 'ellipses': false,
- 'inputClass': 'narrowInput',
- 'value': this._getRetentionValue('reportVersion'),
- 'validator': {
- 'isNumber': true
- }
- }, {
- 'type': 'DropDown',
- 'name': 'reportVersionUnit',
- 'ariaLabel': StringResource.get('reportOutputVersionsUnits'),
- 'options': [{
- 'label': StringResource.get('occurrences'),
- 'value': 'occurrences',
- 'selected': 'occurrences' === this._getRetentionUnit('reportVersion')
- }, {
- 'label': StringResource.get('days'),
- 'value': 'days',
- 'selected': 'days' === this._getRetentionUnit('reportVersion')
- }, {
- 'label': StringResource.get('months'),
- 'value': 'months',
- 'selected': 'months' === this._getRetentionUnit('reportVersion')
- }]
- }]
- }]
- }];
- if (this.objectInfo.type) {
- advancedItems.push({
- 'type': 'Separator'
- });
- advancedItems.push(this._getDefaultActionSpec());
- }
- if (ContentStoreObject.getType(this.objectInfo).indexOf('powerPlay8Report') === -1) {
- advancedItems.push({
- 'type': 'Separator'
- }, {
- 'type': 'DropDown',
- 'name': 'verticalElements', // name must match cm's option name for update to work
- 'label': StringResource.get('rowsPerPageHtmlReport'),
- 'options': [{
- 'label': StringResource.get('default'),
- 'value': 'null',
- 'selected': this._getRowsPerPageHtmlReport() === 'null'
- }, {
- 'label': '4',
- 'value': '4',
- 'selected': this._getRowsPerPageHtmlReport() === 4
- }, {
- 'label': '5',
- 'value': '5',
- 'selected': this._getRowsPerPageHtmlReport() === 5
- }, {
- 'label': '8',
- 'value': '8',
- 'selected': this._getRowsPerPageHtmlReport() === 8
- }, {
- 'label': '10',
- 'value': '10',
- 'selected': this._getRowsPerPageHtmlReport() === 10
- }, {
- 'label': '12',
- 'value': '12',
- 'selected': this._getRowsPerPageHtmlReport() === 12
- }, {
- 'label': '16',
- 'value': '16',
- 'selected': this._getRowsPerPageHtmlReport() === 16
- }, {
- 'label': '20',
- 'value': '20',
- 'selected': this._getRowsPerPageHtmlReport() === 20
- }, {
- 'label': '50',
- 'value': '50',
- 'selected': this._getRowsPerPageHtmlReport() === 50
- }, {
- 'label': '100',
- 'value': '100',
- 'selected': this._getRowsPerPageHtmlReport() === 100
- }, {
- 'label': '200',
- 'value': '200',
- 'selected': this._getRowsPerPageHtmlReport() === 200
- }, {
- 'label': '500',
- 'value': '500',
- 'selected': this._getRowsPerPageHtmlReport() === 500
- }, {
- 'label': '1000',
- 'value': '1000',
- 'selected': this._getRowsPerPageHtmlReport() === 1000
- }]
- });
- advancedItems.push({
- 'name': 'selectionBasedFeatures',
- 'label': StringResource.get('selectionBasedFeatures'),
- 'checked': ContentStoreObject.getOptionValue(this.objectInfo, ContentStoreObject.OPTION_SELECTION_BASED_FEATURES, true),
- 'type': 'CheckBox'
- }, {
- 'name': 'allowNotification',
- 'label': StringResource.get('allowNotifications'),
- 'checked': ContentStoreObject.getAllowNotification(this.objectInfo),
- 'type': 'CheckBox'
- }, {
- 'name': 'advancedOutput',
- 'label': StringResource.get('advancedOutput'),
- 'checked': ContentStoreObject.getOptionValue(this.objectInfo, ContentStoreObject.OPTION_ENABLE_USER_FEATURE_SAVED_OUTPUT, false),
- 'type': 'CheckBox'
- });
- }
- //if the type is any of the powerplay types
- //then need to add the pp options...
- if (ContentStoreObject.getType(this.objectInfo) === 'powerPlay8Report') {
- advancedItems.push({
- 'type': 'Separator'
- }, {
- 'name': 'powerPlay8ReportTab',
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('powerPlay8Report')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('SetExternalRespostoryLabel'),
- 'clickCallback': this._setPowerPlay8ReportOptions.bind(this)
- }]
- }]
- });
- }
- /*
- * If current user does not have permissions to view
- * this property, we don't show runAs options
- */
- return this._getRunAsOwnerInfo()
- .then(function(runAsOwnerValue) {
- if (runAsOwnerValue) {
- advancedItems.push({
- 'type': 'Separator'
- },{
- 'name': 'runAsOwnerLabel',
- 'label': StringResource.get('run'),
- 'type': 'SectionLabel'
- });
- advancedItems.push({
- 'type': 'RadioButtonGroup',
- 'name': this.RUNASOWNER,
- 'value': runAsOwnerValue,
- 'ariaLabel': StringResource.get('run'),
- 'items': [{
- 'label': StringResource.get('runAsUser'),
- 'value': ContentStoreObject.RUN_AS_USER
- }, {
- 'label': StringResource.get('runWithOwnerCapabilities'),
- 'value': ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES
- }, {
- 'label': StringResource.get('runAsOwner', {
- 'ownerName': ContentStoreObject.getOwnerName(this.objectInfo)
- }),
- 'value': ContentStoreObject.RUN_AS_OWNER
- }]
- });
- }
- }.bind(this), function() {})
- .finally(function() {
- resolve(advancedItems);
- });
- }.bind(this));
- },
- _setPowerPlay8ReportOptions: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.propPP8, this.objectInfo.type, this.objectInfo.id);
- },
- _getRunAsOwnerInfo: function() {
- return new Promise(function(resolve, reject) {
- var owner = ContentStoreObject.getOwnerSelfLink(this.objectInfo);
- if (owner) {
- this.glassContext.services.ajax.ajax({
- 'dataType': 'json',
- 'type': 'GET',
- 'url': owner + '/items?fields=permissions&types=credential'
- }).then(function(response) {
- if (response.data.length > 0 && (ContentStoreObject.hasPermissions(response.data[0], ['execute']) ||
- ContentStoreObject.hasPermissions(response.data[0], ['read']))) {
- resolve(ContentStoreObject.getRunAsOwnerValue(this.objectInfo));
- } else {
- reject(new Error());
- }
- }.bind(this));
- } else {
- // no owner info
- reject(new Error());
- }
- }.bind(this));
- },
- _getOutputFormat: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_FORMAT);
- },
- _getOutputLocale: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_LOCALE);
- },
- _getEnableAccessibilitySupport: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES);
- },
- _getReportOptions: function() {
- return ContentStoreObject.getOptions(this.objectInfo);
- },
- _getLanguages: function() {
- return new Promise(function(resolve /*, reject*/ ) {
- var outputLocale = this._getOutputLocale() ? this._getOutputLocale() : '';
- var languages = [{
- 'value': '',
- 'label': StringResource.get('default'),
- 'selected': '' === outputLocale
- }];
- if (this.glassContext) {
- return GlassContextHelper.getContentLocales(this.glassContext)
- .then(function(items) {
- for (var item in items) {
- if (items.hasOwnProperty(item)) {
- languages.push({
- value: item,
- label: items[item],
- selected: item === outputLocale
- });
- }
- }
- resolve(languages);
- });
- } else {
- resolve(languages);
- }
- }.bind(this));
- },
- _getPackageOrModule: function() {
- // a report can be built on either a data module or a package, for a report view, you need to go into the base
- var source = ContentStoreObject.getMetadataModelPackage(this.objectInfo) ||
- ContentStoreObject.getModule(this.objectInfo) ||
- ContentStoreObject.getBaseMetadataModelPackage(this.objectInfo) ||
- ContentStoreObject.getBaseModule(this.objectInfo);
- return source && ContentStoreObject.getName(source) || StringResource.get('unavailable');
- },
- _getModifiedRunAsOwner: function(modifiedProperties, modifiedPropertiesUI) {
- var runAsOwnerBlob = {};
- var optionModified = false;
- if (modifiedPropertiesUI.hasOwnProperty(this.RUNASOWNER)) {
- runAsOwnerBlob[ContentStoreObject.RUN_AS_OWNER] = false;
- runAsOwnerBlob[ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES] = false;
- switch (modifiedPropertiesUI[this.RUNASOWNER]) {
- case ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES:
- runAsOwnerBlob[ContentStoreObject.RUN_WITH_OWNER_CAPABILITIES] = true;
- break;
- case ContentStoreObject.RUN_AS_OWNER:
- runAsOwnerBlob[ContentStoreObject.RUN_AS_OWNER] = true;
- break;
- }
- delete modifiedPropertiesUI[this.RUNASOWNER];
- optionModified = true;
- }
- if (optionModified) {
- _.extend(modifiedProperties, runAsOwnerBlob);
- }
- },
- _getModifiedOptions: function(modifiedProperties, modifiedPropertiesUI) {
- var optionBlob = this._getReportOptions();
- var optionModified = false;
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_FORMAT)) {
- var modifiedValue = modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
- modifiedProperties.executionFormat = modifiedValue;
- var optionFormat = {};
- //convert property to option
- optionFormat.name = ContentStoreObject.OPTION_OUTPUT_FORMAT;
- optionFormat.type = 'runOptionStringArray';
- optionFormat.value = [modifiedValue];
- this._setReportOption(optionBlob, optionFormat, optionFormat.value[0] === '');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.EXECUTION_PROMPT)) {
- var isPowerPlay = C10Utils.isPowerPlay(this.objectInfo.type);
- var optionPrompt = {};
- optionPrompt.name = ContentStoreObject.OPTION_PROMPT;
- optionPrompt.type = isPowerPlay ? 'powerPlay8OptionBoolean' : 'runOptionBoolean';
- optionPrompt.value = !!modifiedPropertiesUI.executionPrompt;
- this._setReportOption(optionBlob, optionPrompt);
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_SELECTION_BASED_FEATURES)) {
- this._setAdvancedOption(optionBlob, ContentStoreObject.OPTION_SELECTION_BASED_FEATURES, 'runOptionBoolean', !!modifiedPropertiesUI.selectionBasedFeatures, true);
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_SELECTION_BASED_FEATURES];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ENABLE_ALLOW_NOTIFICATION)) {
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ENABLE_USER_FEATURE_SAVED_OUTPUT)) {
- this._setAdvancedOption(optionBlob, ContentStoreObject.OPTION_ENABLE_USER_FEATURE_SAVED_OUTPUT, 'runOptionBoolean', !!modifiedPropertiesUI.advancedOutput, false);
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_LOCALE)) {
- var optionLocale = {};
- var value = modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
- modifiedProperties.executionLocale = value;
- optionLocale.name = ContentStoreObject.OPTION_OUTPUT_LOCALE;
- optionLocale.type = 'runOptionLanguageArray';
- optionLocale.value = [value];
- this._setReportOption(optionBlob, optionLocale, optionLocale.value[0] === '');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES)) {
- var optionAF = {};
- optionAF.name = ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES;
- optionAF.type = 'genericOptionBoolean';
- optionAF.value = modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
- this._setReportOption(optionBlob, optionAF, optionAF.value === 'null' || optionAF.value === '');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE)) {
- var optionRowsPerPageInHtml = {};
- //convert property to option
- optionRowsPerPageInHtml.name = ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE;
- optionRowsPerPageInHtml.type = 'runOptionInt';
- optionRowsPerPageInHtml.value = modifiedPropertiesUI[ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE];
- this._setReportOption(optionBlob, optionRowsPerPageInHtml, optionRowsPerPageInHtml.value === 'null');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE];
- optionModified = true;
- }
- // PDF options
- if (this._isPdfOptionsModified(optionBlob, this.pdfOptions)) {
- optionModified = true;
- optionBlob = this._getModifiedPdfOptions(optionBlob, this.pdfOptions);
- }
- //option blob
- if (optionModified) {
- _.extend(modifiedProperties, {
- 'options': optionBlob
- });
- }
- },
- _getParameters: function() {
- return ContentStoreObject.getParameters(this.objectInfo);
- },
- _getPromptValueLabel: function() {
- var parameters = this._getParameters();
- if (parameters && parameters.length > 0) {
- return parameters.length + ' ' + StringResource.get('numOfPromptValues');
- }
- return StringResource.get('setValues');
- },
- _openPromptsValuesView: function() {
- if (C10Utils.isPowerPlay(this.objectInfo.type)) {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.runOptsPP8, this.objectInfo.type, this.objectInfo.id, [{
- setPrompts: 'true'
- }]);
- } else {
- this.glassContext.appController.showSlideOut({
- 'label': StringResource.get('promptValues'),
- 'position': this.slideout ? null : 'left',
- 'overlay': true,
- 'parent': this.slideout,
- 'width': '400',
- 'content': {
- 'module': PromptValuesView,
- 'parentView': this,
- 'glassContext': this.glassContext,
- 'promptDisplayValues': ContentStoreObject.getPromptsDisplayValues(this._getParameters()),
- 'parameters': [],
- 'useParameters': false,
- 'clearCallback': function() {
- if (this._getParameters().length > 0) {
- this._setPrompts();
- }
- }.bind(this),
- 'editCallback': function(parameters) {
- this._setPrompts(parameters);
- }.bind(this)
- }
- });
- }
- },
- _setPrompts: function(prompts) {
- var data;
- if (prompts === undefined || prompts === null || prompts.length === 0) {
- this.objectInfo.parameters = [];
- data = {
- 'parameters': [],
- 'type': 'report'
- };
- } else {
- this.objectInfo.parameters = prompts;
- data = {
- 'parameters': prompts,
- 'type': 'report'
- };
- }
- this.slideout.contentView._directSave(data);
- //update number of prompts
- var numOfPromptsLabel = this.getPropertyUIControl().getProperty('currentPromptValues');
- numOfPromptsLabel.setValue(this._getPromptValueLabel());
- },
- _getRowsPerPageHtmlReport: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_HTML_ROWS_PER_PAGE);
- },
- _getPdfOptions: function() {
- if (this.pdfOptions) {
- return this.pdfOptions;
- }
- this.pdfOptions = [];
- var reportOptions = this._getReportOptions();
- reportOptions.forEach(function(option) {
- if (this._isPdfOption(option)) {
- var clonedObj = {
- 'name': option.name,
- 'type': option.type,
- 'value': option.value
- };
- this.pdfOptions.push(clonedObj);
- }
- }.bind(this));
- return this.pdfOptions;
- },
- _getOption: function(options, name) {
- if (options) {
- for (var i = 0; i < options.length; i = i + 1) {
- if (options[i].name === name) {
- return options[i];
- }
- }
- }
- return null;
- },
- _isPdfOptionsModified: function(optionBlob, pdfOptions) {
- if (pdfOptions) {
- for (var i = 0; i < pdfOptions.length; i = i + 1) {
- var optionFromBlob = this._getOption(optionBlob, pdfOptions[i].name);
- if (!optionFromBlob || optionFromBlob.value !== pdfOptions[i].value) {
- return true;
- }
- }
- }
- if (optionBlob) {
- for (var j = 0; j < optionBlob.length; j = j + 1) {
- var option = optionBlob[j];
- if (this._isPdfOption(option)) {
- var optionPdf = this._getOption(pdfOptions, option.name);
- if (!optionPdf || optionPdf.value !== option.value) {
- return true;
- }
- }
- }
- }
- return false;
- },
- _getModifiedPdfOptions: function(optionBlob, pdfOptions) {
- var newBlob = [];
- for (var i = 0; i < optionBlob.length; i = i + 1) {
- if (!this._isPdfOption(optionBlob[i]) && this.pdfOptionNames.indexOf(optionBlob[i].name) === -1) {
- newBlob.push(optionBlob[i]);
- }
- }
- return newBlob.concat(pdfOptions);
- },
- _closePdfOptionView: function() {
- if (this.pdfOptionView && this.pdfOptionView.contentView) {
- this.pdfOptionView.contentView.onClose();
- this.pdfOptionView.hide();
- this.pdfOptionView = null;
- }
- },
- _openPdfOptionsView: function() {
- this.pdfOptionView = this.glassContext.appController.showSlideOut({
- 'label': StringResource.get('pdfOptions'),
- 'position': 'left',
- 'width': '400',
- 'parent': this.slideout,
- 'overlay': true,
- 'content': {
- 'module': PdfOptionsView,
- 'parentView': this,
- 'pdfOptions': this._getPdfOptions(),
- 'glassContext': this.glassContext,
- 'showCancel': false,
- 'closeCallback': function(data) {
- if (data) {
- this.pdfOptions = [];
- _.extend(this.pdfOptions, data);
- }
- }.bind(this)
- }
- });
- },
- _isPdfOption: function(option) {
- if (option && this.pdfOptionNames.indexOf(option.name) !== -1) {
- //For report imported without upgrade, option allowAnnotations may has legacy type
- if (option.name.indexOf('allow') === 0 && option.type.indexOf('pdfOption') !== 0) {
- return false;
- }
- return true;
- }
- return false;
- },
- _getPowerPlay8OptionPrompt: function() {
- return ContentStoreObject.getOption(this.objectInfo, 'prompt');
- },
- _getExecutionPrompt: function() {
- if (C10Utils.isPowerPlay(this.objectInfo.type)) {
- return this._getPowerPlay8OptionPrompt();
- }
- return ContentStoreObject.getExecutionPrompt(this.objectInfo);
- },
- _getPromptValue: function() {
- if (C10Utils.isPowerPlay(this.objectInfo.type)) {
- return this._getPowerPlay8OptionPrompt();
- }
- return ContentStoreObject.getOptionValue(this.objectInfo, 'prompt', true);
- },
- _getDefaultPortalAction: function() {
- return this.objectInfo.defaultPortalAction;
- },
- _getDefaultActionSpec: function() {
- var options = [{
- 'label': StringResource.get('viewMostRecentReport'),
- 'value': this.ACTION_VIEW,
- 'selected': this._getDefaultPortalAction() === this.ACTION_VIEW
- }, {
- 'label': StringResource.get('runTheReport'),
- 'value': this.ACTION_RUN,
- 'selected': this._getDefaultPortalAction() === this.ACTION_RUN
- }];
- if (this.objectInfo.type.indexOf('View') === -1) {
- var capitalizedType = this.objectInfo.type.charAt(0).toUpperCase() + this.objectInfo.type.slice(1);
- options.push({
- 'label': StringResource.get('open' + capitalizedType),
- 'value': this.ACTION_EDIT,
- 'selected': this._getDefaultPortalAction() === this.ACTION_EDIT
- });
- }
- return {
- 'type': 'DropDown',
- 'name': 'defaultPortalAction', // name must match cm's option name for update to work
- 'label': StringResource.get('defaultPortalAction'),
- 'options': options
- };
- }
- });
- return PropertiesReportTab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2016, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+----
- */
- define('bi/content_apps/PropertiesC10Tab',['q',
- 'bi/content_apps/PropertiesTab',
- 'bi/content_apps/utils/C10Utils',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'underscore'
- ], function(Q, PropertiesTab, C10Utils, StringResource, ContentStoreObject, _) {
- 'use strict';
- var PropertiesC10Tab = PropertiesTab.extend({
- /**
- @param options.el {node} - container dom node
- **/
- init: function(options) {
- PropertiesC10Tab.inherited('init', this, arguments);
- _.extend(this, options);
- },
- _setPowerPlayReport: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.proppowerplay, this.objectInfo.type, this.objectInfo.id);
- },
- _setDocumentRetention: function() {
- C10Utils.openC10General(C10Utils.propGeneralTitanActionEnum.document, this.objectInfo.type, this.objectInfo.id);
- },
- _viewArchivedVersion: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.archive, this.objectInfo.type, this.objectInfo.id, [{
- 'output_tab': 'arch'
- }, {
- 'm_name': this.objectInfo.defaultName
- }]);
- },
- _viewCurrentVersion: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.archive, this.objectInfo.type, this.objectInfo.id, [{
- 'output_tab': 'current'
- }, {
- 'm_name': this.objectInfo.defaultName
- }]);
- },
- _getReportOptions: function() {
- return ContentStoreObject.getOptions(this.objectInfo);
- },
- _setAgentDefinition: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.agent, this.objectInfo.type, this.objectInfo.id);
- },
- _setMetricsExportTask: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.metricsExport, this.objectInfo.type, this.objectInfo.id);
- },
- _setMetricsDatasourceETLTask: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.metricsImport, this.objectInfo.type, this.objectInfo.id);
- },
- _setMetricsMainteanceTask: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.metricsMainTask, this.objectInfo.type, this.objectInfo.id);
- },
- _genUILinkToC10: function(name, label, callbackLabel, callback) {
- return {
- 'name': name,
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': label,
- 'name': 'text' + name
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': callbackLabel,
- 'clickCallback': callback,
- 'name': 'value' + name,
- 'ariaLabelledby': 'text' + name + ' value' + name
- }]
- }]
- };
- },
- _genRunHistoryUI: function() {
- return {
- 'type': 'SingleLineLinks',
- 'name': 'sectionRunHistory',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('runHistory'),
- 'labelFor': 'runHistory'
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'Input',
- 'name': 'runHistory',
- 'ellipses': false,
- 'inputClass': 'narrowInput',
- 'value': this._getRetentionValue('history'),
- 'validator': {
- 'isNumber': true
- }
- }, {
- 'type': 'DropDown',
- 'name': 'runHistoryUnit',
- 'ariaLabel': StringResource.get('runHistoryUnits'),
- 'options': [{
- 'label': StringResource.get('occurrences'),
- 'value': 'occurrences',
- 'selected': 'occurrences' === this._getRetentionUnit('history')
- }, {
- 'label': StringResource.get('days'),
- 'value': 'days',
- 'selected': 'days' === this._getRetentionUnit('history')
- }, {
- 'label': StringResource.get('months'),
- 'value': 'months',
- 'selected': 'months' === this._getRetentionUnit('history')
- }]
- }]
- }]
- };
- },
- _getItems: function() {
- var items = [];
- switch (this.objectInfo.type) {
- case 'metricsMaintenanceTask':
- items.push(this._genRunHistoryUI());
- items.push({
- 'type': 'Separator'
- });
- items.push(this._genUILinkToC10('metricsMaintenanceTaskProp', StringResource.get('metricsMaintenanceTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsMainteanceTask.bind(this)));
- break;
- case 'metricsFileImportTask':
- items.push(this._genRunHistoryUI());
- items.push({
- 'type': 'Separator'
- });
- items.push(this._genUILinkToC10('metricsDataSourceETLTask', StringResource.get('metricsFileImportTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsDatasourceETLTask.bind(this)));
- break;
- case 'metricsDataSourceETLTask':
- items.push(this._genRunHistoryUI());
- items.push({
- 'type': 'Separator'
- });
- items.push(this._genUILinkToC10('metricsDataSourceETLTaskProp', StringResource.get('metricsDataSourceETLTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsDatasourceETLTask.bind(this)));
- break;
- case 'metricsExportTask':
- items.push(this._genRunHistoryUI());
- items.push({
- 'type': 'Separator'
- });
- items.push(this._genUILinkToC10('metricsExportTaskProp', StringResource.get('metricsExportTask'), StringResource.get('SetExternalRespostoryLabel'), this._setMetricsExportTask.bind(this)));
- break;
- case 'planningTask':
- items.push(this._genRunHistoryUI());
- break;
- case 'agentDefinition':
- case 'agentDefinitionView':
- items.push(this._genRunHistoryUI());
- items.push({
- 'type': 'Separator'
- });
- items.push(this._genUILinkToC10('agentDefinitionProp', StringResource.get('agentDefinition'), StringResource.get('SetExternalRespostoryLabel'), this._setAgentDefinition.bind(this)));
- break;
- case 'powerPlayReport':
- items.push(this._genUILinkToC10('powerPlay8ReportTab', StringResource.get('powerPlayReport'), StringResource.get('SetExternalRespostoryLabel'), this._setPowerPlayReport.bind(this)));
- break;
- case 'document':
- items.push(this._genUILinkToC10('layoutProperty', StringResource.get('DocumentRetention'), StringResource.get('SetExternalRespostoryLabel'), this._setDocumentRetention.bind(this)));
- items.push(this._genUILinkToC10('viewArchivedVersions', StringResource.get('viewCurrentVersions'), StringResource.get('viewRunHistory'), this._viewCurrentVersion.bind(this)));
- items.push(this._genUILinkToC10('viewArchivedVersions', StringResource.get('viewArchivedVersions'), StringResource.get('viewRunHistory'), this._viewArchivedVersion.bind(this)));
- break;
- }
- return items;
- },
- render: function() {
- this._id = _.uniqueId('prop_');
- return this.renderPropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'readOnly': this.objectInfo.type === 'document' ? false : !ContentStoreObject.hasPermissions(this.objectInfo, ['write']),
- 'items': this._getItems()
- });
- },
- _getModifiedOptions: function(modifiedProperties, modifiedPropertiesUI) {
- var optionBlob = this._getReportOptions();
- var optionModified = false;
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_FORMAT)) {
- var optionFormat = {};
- //convert property to option
- optionFormat.name = ContentStoreObject.OPTION_OUTPUT_FORMAT;
- optionFormat.type = 'runOptionStringArray';
- optionFormat.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT]];
- this._setReportOption(optionBlob, optionFormat, optionFormat.value[0] === 'Default');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_LOCALE)) {
- var optionLocale = {};
- optionLocale.name = ContentStoreObject.OPTION_OUTPUT_LOCALE;
- optionLocale.type = 'runOptionLanguageArray';
- optionLocale.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE]];
- this._setReportOption(optionBlob, optionLocale, optionLocale.value[0] === 'Default');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES)) {
- var optionAF = {};
- optionAF.name = ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES;
- optionAF.type = 'genericOptionBoolean';
- optionAF.value = modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
- this._setReportOption(optionBlob, optionAF, optionAF.value === 'null');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
- optionModified = true;
- }
- if (optionModified) {
- _.extend(modifiedProperties, {
- 'options': optionBlob
- });
- }
- },
- getModifiedProperties: function() {
- var modifiedProperties = {};
- var modifiedPropertiesUI = this.getPropertyUIControl().getModifiedProperties();
- //deal with report options
- this._getModifiedOptions(modifiedProperties, modifiedPropertiesUI);
- //deal with history/output version settings
- this._getModifiedRetentions(modifiedProperties, modifiedPropertiesUI);
- _.extend(modifiedProperties, modifiedPropertiesUI);
- return modifiedProperties;
- }
- });
- return PropertiesC10Tab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+----
- */
- define('bi/content_apps/PropertiesCapabilitiesTab',['q',
- 'bacontentnav/lib/@waca/core-client/js/core-client/ui/properties/PropertyTabView',
- 'bacontentnav/utils/UIHelper',
- 'bi/content_apps/utils/C10Utils',
- 'bi/content_apps/nls/StringResource',
- 'underscore'
- ], function(Q, PropertyTabView, UIHelper, C10Utils, StringResource, _) {
- 'use strict';
- var PropertiesCapabilitiesTab = PropertyTabView.extend({
- /**
- @paran options.el {node} - container dom node
- **/
- init: function(options) {
- PropertiesCapabilitiesTab.inherited('init', this, arguments);
- _.extend(this, options);
- },
- _setCapabilities: function() {
- C10Utils.openC10Morphlet(C10Utils.morphletMap.capabilities, this.objectInfo.type, this.objectInfo.id);
- },
- render: function() {
- this._id = _.uniqueId('prop_');
- return this.renderPropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'items': [{
- 'name': 'setCapabilities',
- 'type': 'SingleLineLinks',
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'name': 'setCapabilitiesText',
- 'value': StringResource.get('capabilities')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'name': 'setCapabilitiesLink',
- 'value': StringResource.get('SetCapabilitiesLabel'),
- 'clickCallback': this._setCapabilities.bind(this),
- 'ariaLabelledby': 'setCapabilitiesText setCapabilitiesLink'
- }]
- }]
- }]
- });
- }
- });
- return PropertiesCapabilitiesTab;
- });
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *|
- *| IBM Cognos Products: content-apps
- *|
- *| (C) Copyright IBM Corp. 2016, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/PropertiesJobTab',[
- 'bi/content_apps/PropertiesTab',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/ContentStoreObject',
- 'underscore'
- ], function(PropertiesTab, StringResource, ContentStoreObject, _) {
- 'use strict';
- var PropertiesJobTab = PropertiesTab.extend({
- /**
- @param options.el {node} - container dom node
- **/
- init: function(options) {
- PropertiesJobTab.inherited('init', this, arguments);
- _.extend(this, options);
- },
- render: function() {
- this._id = _.uniqueId('prop_');
- var hasNoWritePermission = !ContentStoreObject.hasPermissions(this.objectInfo, ['write']);
- var hasNoTraversePermission = !ContentStoreObject.hasPermissions(this.objectInfo, ['traverse']);
- return this.renderPropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'items': [{
- 'type': 'SingleLineLinks',
- 'name': 'sectionRunHistory',
- 'readOnly': hasNoWritePermission,
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('runHistory'),
- 'labelFor': 'runHistory'
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'Input',
- 'name': 'runHistory',
- 'ellipses': false,
- 'inputClass': 'narrowInput',
- 'value': this._getRetentionValue('history'),
- 'validator': {
- 'isNumber': true
- }
- }, {
- 'type': 'DropDown',
- 'name': 'runHistoryUnit',
- 'ariaLabel': StringResource.get('runHistoryUnits'),
- 'options': [{
- 'label': StringResource.get('occurrences'),
- 'value': 'occurrences',
- 'selected': 'occurrences' === this._getRetentionUnit('history')
- }, {
- 'label': StringResource.get('days'),
- 'value': 'days',
- 'selected': 'days' === this._getRetentionUnit('history')
- }, {
- 'label': StringResource.get('months'),
- 'value': 'months',
- 'selected': 'months' === this._getRetentionUnit('history')
- }]
- }]
- }]
- }, {
- 'type': 'CollapsibleSection',
- 'label': StringResource.get('advancedProperties'),
- 'name': 'Advanced',
- 'items': [{
- 'name': 'advancedProperties',
- 'type': 'SingleLineLinks',
- 'readOnly': hasNoWritePermission || hasNoTraversePermission,
- 'items': [{
- 'align': 'left',
- 'items': [{
- 'type': 'text',
- 'name': 'advancedPropertiesText',
- 'value': StringResource.get('jobAdvancedProperties')
- }]
- }, {
- 'align': 'right',
- 'items': [{
- 'type': 'text',
- 'value': StringResource.get('JobAdvancedSettings'),
- 'name': 'advancedPropertiesLink',
- 'ariaLabelledby': 'advancedPropertiesText advancedPropertiesLink',
- 'clickCallback': this._setAdvancedProperties.bind(this)
- }]
- }]
- }]
- }]
- });
- },
- _setAdvancedProperties: function() {
- var context = {
- id: PropertiesJobTab.JOB_MGT,
- content: {
- objectInfo: this.objectInfo
- }
- };
- this.glassContext.appController.openAppView(PropertiesJobTab.JOB_MGT, context);
- },
- getModifiedProperties: function() {
- var modifiedProperties = {};
- var modifiedPropertiesUI = this.getPropertyUIControl().getModifiedProperties();
- //deal with report options
- this._getModifiedOptions(modifiedProperties, modifiedPropertiesUI);
- //deal with history/output version settings
- this._getModifiedRetentions(modifiedProperties, modifiedPropertiesUI);
- _.extend(modifiedProperties, modifiedPropertiesUI);
- return modifiedProperties;
- },
- _getOutputFormat: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_FORMAT);
- },
- _getOutputLocale: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_OUTPUT_LOCALE);
- },
- _getEnableAccessibilitySupport: function() {
- return ContentStoreObject.getOption(this.objectInfo, ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES);
- },
- _getReportOptions: function() {
- return ContentStoreObject.getOptions(this.objectInfo);
- },
- _getModifiedOptions: function(modifiedProperties, modifiedPropertiesUI) {
- var optionBlob = this._getReportOptions();
- var optionModified = false;
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_FORMAT)) {
- var optionFormat = {};
- //convert property to option
- optionFormat.name = ContentStoreObject.OPTION_OUTPUT_FORMAT;
- optionFormat.type = 'runOptionStringArray';
- optionFormat.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT]];
- this._setReportOption(optionBlob, optionFormat, optionFormat.value[0] === 'Default');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_FORMAT];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_OUTPUT_LOCALE)) {
- var optionLocale = {};
- optionLocale.name = ContentStoreObject.OPTION_OUTPUT_LOCALE;
- optionLocale.type = 'runOptionLanguageArray';
- optionLocale.value = [modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE]];
- this._setReportOption(optionBlob, optionLocale, optionLocale.value[0] === 'Default');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_OUTPUT_LOCALE];
- optionModified = true;
- }
- if (modifiedPropertiesUI.hasOwnProperty(ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES)) {
- var optionAF = {};
- optionAF.name = ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES;
- optionAF.type = 'genericOptionBoolean';
- optionAF.value = modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
- this._setReportOption(optionBlob, optionAF, optionAF.value === 'null');
- delete modifiedPropertiesUI[ContentStoreObject.OPTION_ACCESSIBILITY_FEATURES];
- optionModified = true;
- }
- if (optionModified) {
- _.extend(modifiedProperties, {
- 'options': optionBlob
- });
- }
- }
- });
- PropertiesJobTab.JOB_MGT = 'job_mgt';
- return PropertiesJobTab;
- });
- 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';});
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Content Explorer
- *| (C) Copyright IBM Corp. 2015, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define('bi/content_apps/common/PolicyDetailsView',[
- 'bi/commons/ui/AccessibleView',
- 'doT',
- 'bacontentnav/common/ui/BreadcrumbDropDown',
- 'text!bi/content_apps/common/templates/PolicyDetail.html',
- 'bi/content_apps/nls/StringResource',
- 'bacontentnav/utils/PolicyHelper',
- 'bi/commons/ui/KeyCodes',
- 'bi/commons/utils/ContentFormatter',
- 'underscore'
- ], function(AccessibleView, dot, DropDownMenu, pdTemplate, StringResource, PolicyHelper, KeyCodes, ContentFormatter, _) {
- 'use strict';
- var PolicyDetailsView = AccessibleView.extend({
- init: function(options) {
- this.events = {};
- this.events['keydown #policyDetailsDropDown'] = '_handleKeyDown';
- PolicyDetailsView.inherited('init', this, arguments);
- _.extend(this, options);
- },
- _refreshPermissionUI: function(permission) {
- var permissionEl = this.$el.find('.permission_' + permission);
- var simplifiedPermissionEl = this.$el.find('.simplifiedPermission');
- var selectedBirdBeak = this.$el.find('#' + permission + '_id');
- simplifiedPermissionEl.text(PolicyHelper.getSimplifiedPermissions(this.objectInformation.permissions));
- permissionEl.empty();
- var permObj = _.find(this.objectInformation.permissions, function(obj) {
- return obj.name === permission;
- });
- var newValue = permObj ? permObj.access : 'default';
- 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>');
- permissionEl.append(updatedPerm);
- selectedBirdBeak.children('div').focus();
- },
- _updatePermission: function(permission, value) {
- if (value === 'default') {
- var newPerms = _.reject(this.objectInformation.permissions, function(obj) {
- return obj.name === permission;
- });
- this.objectInformation.permissions = newPerms;
- } else {
- var permObj = _.find(this.objectInformation.permissions, function(obj) {
- return obj.name === permission;
- });
- if (!permObj) {
- permObj = {
- 'name': permission
- };
- this.objectInformation.permissions.push(permObj);
- }
- permObj.access = value;
- }
- this._refreshPermissionUI(permission);
- if (typeof (this.enableParentApplyButton) === 'function') {
- this.enableParentApplyButton();
- }
- },
- _onMenuSelect: function(value, $row) {
- var permission = $row.children('div').attr('name');
- this._updatePermission(permission, value);
- },
- updateRead: function(newValue) {
- this._updatePermission(PolicyHelper.permissionEnum.r, newValue);
- },
- updateWrite: function(newValue) {
- this._updatePermission(PolicyHelper.permissionEnum.w, newValue);
- },
- updateExecute: function(newValue) {
- this._updatePermission(PolicyHelper.permissionEnum.x, newValue);
- },
- updateSetPolicy: function(newValue) {
- this._updatePermission(PolicyHelper.permissionEnum.sp, newValue);
- },
- updateTraverse: function(newValue) {
- this._updatePermission(PolicyHelper.permissionEnum.t, newValue);
- },
- getOwnerName: function() {
- // 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
- if((this.ownerData.givenName && this.ownerData.surname) && (this.objectInformation.securityObject.defaultName === this.ownerData.defaultName)){
- return this.ownerData.givenName + ' ' + this.ownerData.surname;
- } else {
- return this.objectInformation.securityObject.defaultName;
- }
- },
- render: function() {
- var owner = this.getOwnerName();
- var perm = ['read', 'write', 'execute', 'traverse', 'setPolicy'];
- var permObj = PolicyHelper.getIconsForPermissionValues(this.objectInformation.permissions);
- var sHtml = dot.template(pdTemplate)({
- oData: this.objectInformation,
- 'simpliedPolicy': PolicyHelper.getSimplifiedPermissions(this.objectInformation.permissions),
- 'permIcons': permObj,
- 'canModify': this.canModify,
- 'owner': owner,
- 'strings': {
- 'title': StringResource.get('permissionDetails'),
- 'grant': StringResource.get('grant'),
- 'deny': StringResource.get('deny'),
- 'default': StringResource.get('default'),
- 'columnLabelAccess': StringResource.get('permissionDetailsColumnAccess'),
- 'columnLabelPermission': StringResource.get('permissionDetailsColumnPermission'),
- 'columnLabelAction': StringResource.get('permissionDetailsColumnAction'),
- 'setAccess': StringResource.get('permissionSetAccess')
- }
- });
- this.$el.append(sHtml);
- var $ellipses = this.$el.find('.ellipses');
- $.each($ellipses, function(index, node) {
- ContentFormatter.middleShortenString(node);
- });
- // add drop down menus to table
- for (var i = 0; i < perm.length; i = i + 1) {
- var theID = perm[i] + '_id';
- var $td = this.$el.find('#' + theID);
- this._createDropDown($td);
- }
- /* JAWS reader support */
- var flyoutPane = this.$el.closest('.flyoutPane');
- flyoutPane.attr({
- 'aria-label': StringResource.get('permissionDetails'),
- role: 'region'
- });
- var permissionGrid = this.$el.find('.propertyRow');
- permissionGrid.focus();
- return Promise.resolve();
- },
- setFocus: function() {
- var firstDropdown = this.$el.find('#policyDetailsDropDown');
- if (firstDropdown) {
- firstDropdown.focus();
- }
- },
- _createDropDown: function($row) {
- var menuItems = [{
- 'label': StringResource.get('grant'),
- 'icon': 'common-grant_perm',
- 'onSelect': this._onMenuSelect.bind(this, 'grant', $row)
- }, {
- 'label': StringResource.get('deny'),
- 'icon': 'common-deny_perm',
- 'onSelect': this._onMenuSelect.bind(this, 'deny', $row)
- }, {
- 'label': StringResource.get('default'),
- 'icon': 'common-default_perm',
- 'onSelect': this._onMenuSelect.bind(this, 'default', $row)
- }];
- this.ddMenu = new DropDownMenu({
- dropDownMenuSpec: {
- 'title': StringResource.get('permissionSetAccess'),
- 'id': 'myId',
- 'label': 'mylabel',
- 'icon': '',
- 'items': menuItems,
- 'actionElement': $row,
- 'ddMenuPlacement': 'bottom'
- }
- });
- this.ddMenu.render();
- },
- // open dropdown popup
- _handleKeyDown: function(evt) {
- if (evt.keyCode === KeyCodes.DOWN_ARROW) {
- $(evt.currentTarget).closest('td').click();
- }
- }
- });
- return PolicyDetailsView;
- });
- define("js/content_apps/propertiesBundle", function(){});
|