CapabilitiesListPane.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2018, 2018
  6. * US Government Users Restricted Rights - Use, duplication or disclosure
  7. * restricted by GSA ADP Schedule Contract with IBM Corp.
  8. */
  9. define(['doT', 'react', 'react-dom', 'ba-react-admin/ba-react-admin.min', 'underscore', 'bi/admin/common/slideout/BasePane', 'bi/content_apps/PropertiesTab', 'bi/admin/nls/StringResource'], function (dot, React, ReactDOM, AdminReact, _, BasePane, PropertiesTab, StringResource) {
  10. 'use strict'; //NOSONAR: meant to be strict
  11. var CapabilitiesListPane = BasePane.extend({
  12. init: function init(options) {
  13. CapabilitiesListPane.inherited('init', this, arguments);
  14. $.extend(this, options);
  15. this.title = StringResource.get('capabilities');
  16. },
  17. setFocus: function setFocus() {
  18. this.$el.find('.bi-admin-base-pane').focus();
  19. var elem = this.$el.find('.bi-admin-base-pane')[0];
  20. if (elem) {
  21. elem.focus();
  22. }
  23. },
  24. refresh: function refresh() {
  25. this.renderBody(this.$body);
  26. },
  27. renderBody: function renderBody($body) {
  28. var sHtml = '<div class="bi-admin-base-pane bi-admin-vflex bi-admin-fullheight" tabindex="0">' + '<div id=capabilitiesListReactElement style="height:100%"></div>' + '</div>';
  29. $body.html(sHtml);
  30. this.bodyEl = $body;
  31. ReactDOM.unmountComponentAtNode(this.bodyEl.find('#capabilitiesListReactElement')[0]);
  32. var capabilitiesListPane = React.createElement(AdminReact.CapabilitiesListPanel, {
  33. glassContext: this.glassContext,
  34. StringResource: StringResource,
  35. parent: this,
  36. objectInfo: this.objectInfo
  37. });
  38. ReactDOM.render(capabilitiesListPane, $body.find('#capabilitiesListReactElement')[0]);
  39. return Promise.resolve();
  40. },
  41. reactPropSelectCallback: function reactPropSelectCallback(index, selectedItem) {
  42. var capabilityItem = {
  43. defaultName: selectedItem.label,
  44. type: selectedItem.type,
  45. id: selectedItem.id,
  46. children: selectedItem.children && selectedItem.children.length > 0 ? true : false,
  47. isParent: selectedItem.depth === 0 ? true : false,
  48. hasParent: selectedItem.depth === 1 ? true : false
  49. };
  50. var selectedTab = "bi/admin/account/ui/CapabilitiesTab";
  51. if (index === 0) {
  52. selectedTab = "bi/admin/common/GeneralPropertiesTab";
  53. }
  54. var slideout = this.glassContext.appController.showSlideOut({
  55. 'parent': this.slideout,
  56. 'launchPoint': this.slideout.$el.find('span.goback-icon'),
  57. 'width': "400px",
  58. 'content': {
  59. 'module': 'bi/admin/common/PropertiesPageView',
  60. 'parentView': this,
  61. 'listPane': this,
  62. 'objectInfo': capabilityItem,
  63. 'type': capabilityItem.type,
  64. 'glassContext': this.glassContext,
  65. 'selectedTabModule': selectedTab
  66. },
  67. 'onHide': function () {
  68. if (slideout && slideout.contentView && slideout.contentView.onHide) {
  69. slideout.contentView.onHide().then(function () {
  70. slideout.hide();
  71. });
  72. }
  73. }.bind(this)
  74. });
  75. },
  76. remove: function remove() {
  77. CapabilitiesListPane.inherited('remove', this, arguments);
  78. ReactDOM.unmountComponentAtNode(this.bodyEl.find('#capabilitiesListReactElement')[0]);
  79. }
  80. });
  81. return CapabilitiesListPane;
  82. });