FeaturesFooter.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2015, 2017
  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/commons/ui/View', 'bi/admin/nls/StringResource', 'bi/commons/ui/ButtonBar'], function (Q, _, View, StringResource, ButtonBar) {
  9. 'use strict'; //NOSONAR
  10. var FeaturesFooter = View.extend({
  11. init: function init(options) {
  12. FeaturesFooter.inherited('init', this, arguments);
  13. _.extend(this, options);
  14. this._buttonBar = null;
  15. },
  16. render: function render() {
  17. var deferred = Q.defer();
  18. this._buttonBar = new ButtonBar({
  19. buttons: [{
  20. 'id': 'applyID',
  21. 'label': StringResource.get('apply'),
  22. 'onSelect': this.onApply.bind(this),
  23. 'disabled': true
  24. }, {
  25. 'id': 'admin-features-resetToDefaultsID',
  26. 'label': StringResource.get('reset'),
  27. 'onSelect': this.onReset.bind(this),
  28. 'disabled': this.isCustomized ? false : true
  29. }]
  30. });
  31. this._buttonBar.render().then(function (el) {
  32. _.each(this._buttonBar.getButtonList(), function (button) {
  33. button.disabled ? button.disable() : button.enable();
  34. }.bind(this));
  35. deferred.resolve(el);
  36. }.bind(this));
  37. return deferred.promise;
  38. },
  39. remove: function remove() {
  40. if (this._buttonBar) {
  41. this._buttonBar.remove();
  42. }
  43. },
  44. setModified: function setModified(modified) {
  45. _.each(this._buttonBar.getButtonList(), function (button) {
  46. if (modified) {
  47. if (button.id === 'applyID') {
  48. button.enable();
  49. }
  50. } else {
  51. button.disable();
  52. }
  53. });
  54. }
  55. });
  56. return FeaturesFooter;
  57. });