GeneralPropertiesTab.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. "use strict";
  2. /**
  3.  * Licensed Materials - Property of IBM
  4.  * IBM Cognos Products: admin
  5.  * Copyright IBM Corp. 2015, 2018
  6.  * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7.  */
  8. define(['underscore', 'q', 'bi/admin/nls/StringResource', 'bi/content_apps/PropertiesGeneralTab'], function (_, Q, StringResource, BaseGeneralTab) {
  9. 'use strict'; //NOSONAR: meant to be strict
  10. var GeneralPropertiesTab = BaseGeneralTab.extend({
  11. /**
  12. @paran options.el {node} - container dom node
  13. **/
  14. init: function init(options) {
  15. GeneralPropertiesTab.inherited('init', this, arguments);
  16. _.extend(this, options);
  17. if (this.objectInfo.searchPath !== undefined) {
  18. this.isEditable = !(this.objectInfo.searchPath.indexOf('CAMID(":') === -1 && this.objectInfo.searchPath.indexOf('CAMID("CognosEx:') === -1);
  19. } else {
  20. this.isEditable = false;
  21. }
  22. this.writable = this.objectInfo.permissions && this.objectInfo.permissions.indexOf('write') > -1 ? true : false;
  23. },
  24. _getLocation: function _getLocation() {
  25. var ancestors = [];
  26. if (!this.objectInfo.ancestors) {
  27. return null;
  28. }
  29. this.objectInfo.ancestors.forEach(function (ancestor) {
  30. ancestors.push(ancestor.defaultName);
  31. });
  32. return ancestors.join(' > ');
  33. },
  34. _checkForCapability: function _checkForCapability() {
  35. if (!this.objectInfo.ancestors || this.objectInfo.ancestors.length === 0) {
  36. return false;
  37. }
  38. if (this.objectInfo.ancestors[0].type === 'capability') {
  39. this._advancedProperties.splice(2, 0, {
  40. 'name': 'hidden',
  41. 'label': StringResource.get('hideThisEntry'),
  42. 'checked': this.objectInfo.hidden,
  43. 'type': 'CheckBox',
  44. 'disabled': !this.writable
  45. }, {
  46. 'type': 'Separator'
  47. });
  48. }
  49. return true;
  50. },
  51. _getAdvancedPropertyItems: function _getAdvancedPropertyItems() {
  52. //NOSONAR
  53. this._advancedProperties = [{
  54. 'name': 'disabled',
  55. 'label': StringResource.get('disableThisEntry'),
  56. 'checked': this.objectInfo.disabled,
  57. 'type': 'CheckBox',
  58. 'disabled': !this.writable
  59. }, {
  60. 'type': 'Separator'
  61. }, {
  62. 'name': 'location',
  63. 'label': StringResource.get('location'),
  64. 'value': this._getLocation(),
  65. 'type': 'SingleLineValue'
  66. }, {
  67. 'type': 'Separator'
  68. }, {
  69. 'name': 'searchPath',
  70. 'label': StringResource.get('searchPath'),
  71. 'newLook': true,
  72. 'value': this.objectInfo.searchPath,
  73. 'type': 'InputLabel',
  74. 'inputStyles': 'width: 210px',
  75. 'readOnly': true
  76. }, {
  77. 'type': 'Separator'
  78. }, {
  79. 'name': 'ID',
  80. 'label': StringResource.get('id'),
  81. 'newLook': true,
  82. 'value': this.objectInfo.id,
  83. 'type': 'InputLabel',
  84. 'inputStyles': 'width: 210px',
  85. 'readOnly': true
  86. }];
  87. if (this._canSeeTenant()) {
  88. this.currentTenantID = this.objectInfo.tenantID;
  89. this._advancedProperties.splice(0, 0, {
  90. 'type': 'SingleLineValue',
  91. 'name': 'changeTenant',
  92. 'label': StringResource.get('type_tenant'),
  93. 'value': this._getTenantNameByID(this.objectInfo.tenantID),
  94. 'disabled': !this._canSetTenant,
  95. 'editCallback': function () {
  96. this.changeTenantSlideout = this.glassContext.appController.showSlideOut({
  97. 'parent': this.slideout,
  98. 'position': 'left',
  99. 'width': '400px',
  100. 'overlay': true,
  101. 'label': StringResource.get('tenantSettings'),
  102. 'content': {
  103. 'module': 'bi/content_apps/TenantSlideoutView',
  104. 'glassContext': this.glassContext,
  105. 'title': StringResource.get('Tenants'),
  106. 'objectInfo': this.objectInfo,
  107. 'currentTenantID': this.currentTenantID,
  108. 'onChangeCallback': this.updateTenant.bind(this)
  109. }
  110. });
  111. }.bind(this)
  112. }, {
  113. 'type': 'Separator'
  114. });
  115. }
  116. switch (this.objectInfo.type) {
  117. case 'role':
  118. case 'group':
  119. break;
  120. case 'contact':
  121. this._advancedProperties.splice(2, 0, {
  122. 'name': 'hidden',
  123. 'label': StringResource.get('hideThisEntry'),
  124. 'checked': this.objectInfo.hidden,
  125. 'type': 'CheckBox',
  126. 'disabled': !this.writable
  127. }, {
  128. 'type': 'Separator'
  129. });
  130. this._advancedProperties = this._advancedProperties.concat([{
  131. 'type': 'Separator'
  132. }, {
  133. 'name': 'givenName',
  134. 'label': StringResource.get('givenName'),
  135. 'value': this.objectInfo.givenName,
  136. 'type': 'TextArea',
  137. 'multiline': false,
  138. 'editable': this.isEditable && this.writable
  139. }, {
  140. 'type': 'Separator'
  141. }, {
  142. 'name': 'surname',
  143. 'label': StringResource.get('surname'),
  144. 'value': this.objectInfo.surname,
  145. 'type': 'TextArea',
  146. 'multiline': false,
  147. 'editable': this.isEditable && this.writable
  148. }, {
  149. 'type': 'Separator'
  150. }, {
  151. 'name': 'email',
  152. 'label': StringResource.get('email'),
  153. 'value': this.objectInfo.email,
  154. 'type': 'TextArea',
  155. 'multiline': false,
  156. 'editable': this.isEditable && this.writable
  157. }]);
  158. break;
  159. // Defect 294283, visualization
  160. case 'visualization':
  161. case 'namespaceFolder':
  162. case 'namespace':
  163. case 'dataSource':
  164. case 'dataSourceSignon':
  165. case 'dataSourceConnection':
  166. case 'distributionList':
  167. case 'capability':
  168. case 'productCapability':
  169. this._advancedProperties.splice(2, 0, {
  170. 'name': 'hidden',
  171. 'label': StringResource.get('hideThisEntry'),
  172. 'checked': this.objectInfo.hidden,
  173. 'type': 'CheckBox',
  174. 'disabled': !this.writable
  175. }, {
  176. 'type': 'Separator'
  177. });
  178. break;
  179. case 'account':
  180. var isAnonymous = this.objectInfo.searchPath.indexOf('CAMID("::Anonymous') >= 0;
  181. if (!isAnonymous) {
  182. this._advancedProperties = this._advancedProperties.concat([{
  183. 'type': 'Separator'
  184. }, {
  185. 'name': 'userName',
  186. 'label': StringResource.get('userId'),
  187. 'value': this.objectInfo.userName,
  188. 'type': 'SingleLineValue',
  189. 'editable': false
  190. }, {
  191. 'type': 'Separator'
  192. }, {
  193. 'name': 'givenName',
  194. 'label': StringResource.get('givenName'),
  195. 'value': this.objectInfo.givenName,
  196. 'type': 'TextArea',
  197. 'multiline': false,
  198. 'editable': this.isEditable && this.writable
  199. }, {
  200. 'type': 'Separator'
  201. }, {
  202. 'name': 'surname',
  203. 'label': StringResource.get('surname'),
  204. 'value': this.objectInfo.surname,
  205. 'type': 'TextArea',
  206. 'multiline': false,
  207. 'editable': this.isEditable && this.writable
  208. }, {
  209. 'type': 'Separator'
  210. }, {
  211. 'name': 'email',
  212. 'label': StringResource.get('email'),
  213. 'value': this.objectInfo.email,
  214. 'type': 'TextArea',
  215. 'multiline': false,
  216. 'editable': this.isEditable && this.writable
  217. }, {
  218. 'type': 'Separator'
  219. }, {
  220. 'name': 'password',
  221. 'label': StringResource.get('password'),
  222. 'value': 'secret',
  223. 'type': 'SingleLineValue',
  224. 'multiline': false,
  225. 'editable': this.isEditable && this.writable,
  226. 'inputType': 'password'
  227. }]);
  228. }
  229. break;
  230. case 'tenant':
  231. this._advancedProperties.splice(2, 0, {
  232. 'name': 'tenantID',
  233. 'label': StringResource.get('tenantId'),
  234. 'value': this.objectInfo.tenantID,
  235. 'type': 'SingleLineValue',
  236. 'editable': false
  237. });
  238. break;
  239. default:
  240. if (this._checkForCapability()) {
  241. break;
  242. }
  243. this.logger.error('get advanced properies of unknown type: ' + this.objectInfo.type);
  244. }
  245. return this._advancedProperties;
  246. }
  247. });
  248. return GeneralPropertiesTab;
  249. });