ScheduleDeliveryPickerView.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: SHARE
  5. *
  6. * (C) Copyright IBM Corp. 2015, 2016
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  9. * IBM Corp.
  10. */
  11. define([
  12. 'jquery',
  13. 'bi/sharecommon/utils/simpledoT',
  14. 'q',
  15. 'bi/schedule/views/DeliveryPickerView',
  16. 'bi/sharecommon/utils/translator',
  17. 'bi/commons/utils/Utils',
  18. 'bootstrap'
  19. ], function($, dot, Q, DeliveryPickerView, t, Utils) {
  20. 'use strict';
  21. /* deliveryOptions look like:
  22. * {
  23. * "save": {
  24. * "notify": false
  25. * },
  26. * "email": {
  27. * "emailAsAttachment": false,
  28. * "emailAsURL": false,
  29. * "subject": "blah",
  30. * "memoPart": "this is the body",
  31. * "to": [],
  32. * "cc": [],
  33. * "bcc": []
  34. * }
  35. * mobile: {
  36. * to: []
  37. * }
  38. * print: {
  39. * printer: ""
  40. * }
  41. * }
  42. */
  43. var __SLIDEOUT_PRESET_WIDTH = '350px';
  44. var scheduleDeliveryPickerView = DeliveryPickerView.extend({
  45. init: function(options) {
  46. $.extend(this, options);
  47. scheduleDeliveryPickerView.inherited('init', this, arguments);
  48. if(options.slideoutparent == undefined) {
  49. throw "Error: slideoutparent parameter must be provided.";
  50. }
  51. this.isVisible = false;
  52. this.slideout = null;
  53. },
  54. render: function() {
  55. // in update mode the permissions are passed
  56. if ( this.hasPermission && !this.hasPermission.write && this.hasPermission.read ) {
  57. this.$toggler.prop('disabled', true);
  58. }
  59. this._setEvents();
  60. // Initially update the "delivery" area in the main pane
  61. if(this.$activeOptionsContainer) {
  62. this.updateActiveDeliveryList(this.$activeOptionsContainer);
  63. }
  64. },
  65. _setEvents: function() {
  66. this.$toggler.on('primaryaction', function(event) {
  67. this._showDeliveryOptions();
  68. }.bind(this));
  69. },
  70. _setpanelContent: function() {
  71. var allowRecipients = typeof this.allowRecipients === "function" ? this.allowRecipients() : true;
  72. var deliveryContent = this.getDeliveryContent(allowRecipients);
  73. this.$panelContent = $(deliveryContent);
  74. },
  75. _showDeliveryOptions: function(){
  76. this.isVisible = true;
  77. this._setpanelContent();
  78. this.slideout = this.glassContext.appController.showSlideOut({
  79. 'parent': this.slideoutparent,
  80. 'overlay': this.overlay,
  81. 'width': __SLIDEOUT_PRESET_WIDTH,
  82. 'enableTabLooping': true,
  83. 'label': t.translate('schedule_delivery_picker_name'),
  84. 'content': {
  85. 'module': 'bi/schedule/views/OptionsSlideoutView',
  86. 'content': this.$panelContent,
  87. 'title': t.translate("schedule_delivery_label"),
  88. 'closeCallback': function() {
  89. this._close();
  90. }.bind(this),
  91. 'setUpCallback': function(content) {
  92. this.setDeliveryOptions(content, this.$activeOptionsContainer);
  93. }.bind(this)
  94. }
  95. });
  96. },
  97. _close: function() {
  98. this.isVisible = false;
  99. // clear event handler for editor dialogs and remove editor dialogs
  100. if($('body').hasClass('editorHideHandlerSet')) {
  101. $('body').removeClass('editorHideHandlerSet');
  102. $('body').off( ".ckeditorDialog" );
  103. var editorDialogs = $('body').find('.cke_reset_all');
  104. var editorDialogBg = $('body').find('.cke_dialog_background_cover');
  105. editorDialogs.remove();
  106. editorDialogBg.remove();
  107. }
  108. this.close();
  109. }
  110. });
  111. return scheduleDeliveryPickerView;
  112. });