SimpleDialog.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. *
  5. * IBM Cognos Products: admin
  6. *
  7. * Copyright IBM Corp. 2016
  8. *
  9. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['bi/commons/ui/dialogs/GenericViewDialog', 'bi/admin/nls/StringResource'], function (BaseDialog, StringResource) {
  12. /**
  13. * Create a error dialog that will display a list of errors.
  14. *
  15. * @param - options
  16. * {
  17. * errorList: Array of errors to display
  18. * }
  19. *
  20. */
  21. var SimpleDialog = BaseDialog.extend({
  22. init: function init(options) {
  23. this.options = options;
  24. var dialogOptions = {
  25. 'buttons': ['ok'],
  26. 'viewClass': options.viewObject,
  27. 'id': 'SimpleDialog',
  28. 'title': options.title,
  29. 'viewOptions': {
  30. 'displayMsgList': this.options.displayMsgList,
  31. 'onOpen': this.onOpen.bind(this),
  32. 'glassContext': this.options.glassContext
  33. }
  34. };
  35. SimpleDialog.inherited('init', this, [dialogOptions]);
  36. },
  37. /**
  38. * Called when the dialog is opened
  39. */
  40. onOpen: function onOpen() {
  41. var container = this._container();
  42. container.addClass('openDialog');
  43. container.find('.dialogHeader');
  44. container.find('.modalDialog').addClass('contentListDialog');
  45. container.find('footer').attr('role', 'contentinfo').attr('aria-label', StringResource.get('ok'));
  46. },
  47. /**
  48. * Called when the OK button is clicked
  49. */
  50. ok: function ok() {
  51. this.hide();
  52. },
  53. setFocus: function setFocus() {
  54. this._container().find('.dialogButton.primary')[0].focus();
  55. }
  56. });
  57. return SimpleDialog;
  58. });