UserGroupSelectorPane.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2016, 2017
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['bi/glass/app/ContentView', 'underscore', 'bi/admin/nls/StringResource', 'q', 'require', 'bi/commons/ui/properties/PropertyUIControl'], function (View, _, StringResource, Q, require, PropertyUIControl) {
  9. 'use strict'; //NOSONAR
  10. var UserGroupSelectorPane = View.extend({
  11. init: function init(options) {
  12. UserGroupSelectorPane.inherited('init', this, arguments);
  13. _.extend(this, options);
  14. },
  15. render: function render() {
  16. var deferred = Q.defer();
  17. this._renderFacets().then(function () {
  18. deferred.resolve();
  19. });
  20. return deferred.promise;
  21. },
  22. _onClear: function _onClear() {
  23. this._oPropertyUIControl.getProperty('users').uncheck(false);
  24. this._oPropertyUIControl.getProperty('groups').uncheck(false);
  25. this._oPropertyUIControl.getProperty('roles').uncheck(false);
  26. this.callback.filterStringValue.account = false;
  27. this.callback.filterStringValue.group = false;
  28. this.callback.filterStringValue.role = false;
  29. this.callback._filter(this.callback.filterStringValue);
  30. },
  31. _renderPropertyControl: function _renderPropertyControl(checkBoxItems) {
  32. var deferred = Q.defer();
  33. this._oPropertyUIControl = new PropertyUIControl({
  34. 'el': this.$el,
  35. 'glassContext': this.glassContext,
  36. 'slideout': this.slideout,
  37. 'items': checkBoxItems
  38. });
  39. this._oPropertyUIControl.render().then(function () {
  40. deferred.resolve(this);
  41. }.bind(this));
  42. return deferred.promise;
  43. },
  44. _initCheckBoxItems: function _initCheckBoxItems() {
  45. //NOSONAR
  46. var checkBoxItems = [{
  47. type: 'SingleLineLinks',
  48. name: 'clearAll',
  49. items: [{
  50. align: 'right',
  51. items: [{
  52. type: 'text',
  53. value: StringResource.get('clearAll'),
  54. clickCallback: function () {
  55. this._onClear();
  56. }.bind(this)
  57. }]
  58. }]
  59. }, {
  60. 'type': 'CheckBox',
  61. 'name': 'users',
  62. 'icon': 'wft_checkmark',
  63. 'disabled': this.callback.listAdaptor.allowedSelectionTypes && !_.include(this.callback.listAdaptor.allowedSelectionTypes, "account") ? true : false,
  64. 'label': StringResource.get('account'),
  65. 'checked': this.callback.filterStringValue.account ? true : false,
  66. 'onChange': function (name, value) {
  67. if (value === true) {
  68. this.callback.filterStringValue.account = true;
  69. } else {
  70. this.callback.filterStringValue.account = false;
  71. }
  72. this.callback._filter(this.callback.filterStringValue);
  73. }.bind(this)
  74. }, {
  75. 'type': 'CheckBox',
  76. 'name': 'groups',
  77. 'icon': 'wft_checkmark',
  78. 'disabled': this.callback.listAdaptor.allowedSelectionTypes && !_.include(this.callback.listAdaptor.allowedSelectionTypes, "group") ? true : false,
  79. 'label': StringResource.get('group'),
  80. 'checked': this.callback.filterStringValue.group ? true : false,
  81. 'onChange': function (name, value) {
  82. if (value === true) {
  83. this.callback.filterStringValue.group = true;
  84. } else {
  85. this.callback.filterStringValue.group = false;
  86. }
  87. this.callback._filter(this.callback.filterStringValue);
  88. }.bind(this)
  89. }, {
  90. 'type': 'CheckBox',
  91. 'name': 'roles',
  92. 'icon': 'wft_checkmark',
  93. 'disabled': false,
  94. 'label': StringResource.get('role'),
  95. 'checked': this.callback.filterStringValue.role ? true : false,
  96. 'onChange': function (name, value) {
  97. if (value === true) {
  98. this.callback.filterStringValue.role = true;
  99. } else {
  100. this.callback.filterStringValue.role = false;
  101. }
  102. this.callback._filter(this.callback.filterStringValue);
  103. }.bind(this)
  104. }];
  105. return checkBoxItems;
  106. },
  107. _renderFacets: function _renderFacets() {
  108. //NOSONAR
  109. var deferred = Q.defer();
  110. var checkBoxItems = this._initCheckBoxItems();
  111. this._renderPropertyControl(checkBoxItems).then(function () {
  112. deferred.resolve();
  113. });
  114. return deferred.promise;
  115. }
  116. });
  117. return UserGroupSelectorPane;
  118. });