GlobalParametersProperties.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2015, 2019
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['q', 'underscore', 'bi/admin/nls/StringResource', 'bacontentnav/common/ContentListPageView', 'bi/commons/ui/properties/PropertyUIControl'], function (Q, _, StringResource, ContentView, PropertyUIControl) {
  9. 'use strict'; //NOSONAR
  10. var GlobalParameterPropertiesView = ContentView.extend({
  11. init: function init(options) {
  12. GlobalParameterPropertiesView.inherited('init', this, arguments);
  13. _.extend(this, options);
  14. this.modified = false;
  15. },
  16. render: function render() {
  17. this.$el.empty();
  18. this._propertyControlItems = this._getNewPropertyUIControl({
  19. 'el': this.$el,
  20. 'glassContext': this.glassContext,
  21. 'slideout': this.slideout,
  22. 'items': this._getPropertyControlItems()
  23. });
  24. return this._propertyControlItems.render();
  25. },
  26. _getNewPropertyUIControl: function _getNewPropertyUIControl(spec) {
  27. return new PropertyUIControl(spec);
  28. },
  29. _getPropertyControlItems: function _getPropertyControlItems() {
  30. var items = [{
  31. 'name': 'parameterName',
  32. 'label': '',
  33. 'value': this.parameter.name,
  34. 'type': 'Banner',
  35. 'editable': this.parameter.source === 'user' ? true : false,
  36. 'onChange': function (name, value) {
  37. this.parameter.name = value;
  38. this.modified = true;
  39. }.bind(this)
  40. }, {
  41. 'type': 'Separator'
  42. }, {
  43. 'name': 'parameterDescription',
  44. 'label': StringResource.get('description'),
  45. 'value': this.parameter.description,
  46. 'type': 'TextArea',
  47. 'multiline': true,
  48. 'editable': true,
  49. 'onChange': function (name, value) {
  50. this.parameter.description = value;
  51. this.modified = true;
  52. }.bind(this)
  53. }, {
  54. 'type': 'Separator'
  55. }, {
  56. 'name': 'accessibleAtSystemOrTenantLevelParameter',
  57. 'label': StringResource.get('accessibleAtSystemOrTenantLevel'),
  58. 'checked': this.parameter.accessibleAtSystemOrTenantLevel,
  59. 'type': 'CheckBox',
  60. 'disabled': false,
  61. 'onChange': function (name, value) {
  62. this.parameter.accessibleAtSystemOrTenantLevel = value;
  63. this.modified = true;
  64. }.bind(this)
  65. }, {
  66. 'type': 'Separator'
  67. }, {
  68. 'name': 'disableParameter',
  69. 'label': StringResource.get('disabled'),
  70. 'checked': this.parameter.disabled,
  71. 'type': 'CheckBox',
  72. 'disabled': false,
  73. 'onChange': function (name, value) {
  74. this.parameter.disabled = value;
  75. this.modified = true;
  76. }.bind(this)
  77. }, {
  78. 'type': 'Separator'
  79. }, {
  80. 'name': 'parameterSource',
  81. 'label': StringResource.get('source'),
  82. 'value': this.parameter.source === 'report' ? StringResource.get('report') : StringResource.get('userParameter'),
  83. 'type': 'SingleLineValue',
  84. 'disabled': false,
  85. 'readyOnly': true,
  86. 'ellipses': false
  87. }, {
  88. 'type': 'Separator'
  89. }];
  90. if (this.parameter.name === '_as_of_date') {
  91. // Remove extra separator
  92. items.pop();
  93. } else if (this.parameter.source === 'report') {
  94. items.push({
  95. 'name': 'parameterReport',
  96. 'label': StringResource.get('report'),
  97. 'value': this.parameter.report,
  98. 'type': 'SingleLineValue',
  99. 'disabled': false,
  100. 'readyOnly': true,
  101. 'ellipses': false
  102. });
  103. } else {
  104. items.push({
  105. 'name': 'defineValues',
  106. 'label': StringResource.get('customValues'),
  107. 'value': this.parameter.values && this.parameter.values.length !== 0 ? StringResource.get('customized') : StringResource.get('setValues'),
  108. 'type': 'SingleLineValue',
  109. 'disabled': false,
  110. 'ellipses': true,
  111. 'editCallback': function () {
  112. this._openSetValuesPanel();
  113. }.bind(this)
  114. });
  115. }
  116. items.push({
  117. 'type': 'Separator'
  118. });
  119. items.push({
  120. 'name': 'setLanguages',
  121. 'label': StringResource.get('languages'),
  122. 'value': StringResource.get('set'),
  123. 'type': 'SingleLineValue',
  124. 'disabled': false,
  125. 'ellipses': true,
  126. 'editCallback': function () {
  127. this._openSetLanguagesPanel();
  128. }.bind(this)
  129. });
  130. return items;
  131. },
  132. _openSetLanguagesPanel: function _openSetLanguagesPanel() {
  133. this._propertyPropertiesSlideout = this.glassContext.appController.showSlideOut({
  134. parent: this.slideout,
  135. width: '525px',
  136. label: StringResource.get('setLanguages'),
  137. content: {
  138. 'module': 'bi/admin/common/slideout/SetLanguages',
  139. 'glassContext': this.glassContext,
  140. 'values': this.parameter.multilingualDisplay,
  141. 'saveCallback': function (values) {
  142. this.parameter.multilingualDisplay = values;
  143. this.save();
  144. }.bind(this)
  145. }
  146. });
  147. },
  148. _openSetValuesPanel: function _openSetValuesPanel() {
  149. this.glassContext.appController.showSlideOut({
  150. parent: this.slideout,
  151. width: '400px',
  152. label: StringResource.get('setLanguages'),
  153. content: {
  154. 'module': 'bi/admin/common/slideout/SetCustomParameterValues',
  155. 'glassContext': this.glassContext,
  156. 'values': this.parameter.values ? this.parameter.values : [],
  157. 'updateCallback': function (values) {
  158. this.parameter.values = values;
  159. this.modified = true;
  160. this._propertyControlItems.getProperty('defineValues').setValue(this.parameter.values && this.parameter.values.length !== 0 ? StringResource.get('customized') : StringResource.get('setValues'));
  161. }.bind(this)
  162. }
  163. });
  164. }
  165. });
  166. return GlobalParameterPropertiesView;
  167. });