GenericViewDialog.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2018
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../../../lib/@waca/core-client/js/core-client/ui/dialogs/BaseDialog'], function (BaseDialog) {
  8. var Dialog = null;
  9. Dialog = BaseDialog.extend({
  10. _buttons: ['ok', 'cancel'],
  11. _okCallback: null,
  12. _cancelCallback: null,
  13. init: function init(options) {
  14. this.title = options.title;
  15. this.view = new options.viewClass(options.viewOptions);
  16. this._okCallback = options.okCallback;
  17. this._cancelCallback = options.cancelCallback;
  18. Dialog.inherited('init', this, arguments);
  19. },
  20. destroy: function destroy() {
  21. if (this.view) {
  22. this.view.remove();
  23. }
  24. Dialog.inherited('destroy', this, arguments);
  25. },
  26. renderContent: function renderContent(n) {
  27. this.view.render();
  28. n.append(this.view.$el);
  29. return n;
  30. },
  31. renderTitle: function renderTitle(n) {
  32. n.text(this.title);
  33. return n;
  34. },
  35. ok: function ok() {
  36. Dialog.inherited('ok', this, arguments);
  37. if (this._okCallback) {
  38. return this._okCallback();
  39. }
  40. },
  41. cancel: function cancel() {
  42. Dialog.inherited('cancel', this, arguments);
  43. if (this._cancelCallback) {
  44. return this._cancelCallback();
  45. }
  46. },
  47. open: function open() {
  48. Dialog.inherited('open', this, arguments);
  49. if (this.view.onOpen) {
  50. this.view.onOpen();
  51. }
  52. }
  53. });
  54. return Dialog;
  55. });
  56. //# sourceMappingURL=GenericViewDialog.js.map