PinView.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2020
  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/core/View', './PinsPanel', 'text!./templates/PinPanel.html', '../app/nls/StringResources', 'doT'], function (View, PinsPanel, ViewTemplate, StringResources, dot) {
  8. var PinView = View.extend({
  9. init: function init() {
  10. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11. PinView.inherited('init', this, arguments);
  12. var params = options.params ? options.params : window.location.search;
  13. this.viewMode = this.isViewMode(params);
  14. this.glassContext = options.glassContext;
  15. this.canvasController = options.canvasController;
  16. this.dashboardApi = this.canvasController.dashboardApi;
  17. this.slideout = options.slideout;
  18. this.template = dot.template(ViewTemplate);
  19. },
  20. isViewMode: function isViewMode(params) {
  21. var viewMode = false;
  22. var getParam = function getParam(param) {
  23. return decodeURIComponent((new RegExp('[?|&]' + param + '=' + '([^&;]+?)(&|#|;|$)').exec(params) || ['', ''])[1].replace(/\+/g, '%20')) || null;
  24. };
  25. var key = getParam('mode');
  26. if (key && key === 'view') {
  27. viewMode = true;
  28. }
  29. return viewMode;
  30. },
  31. getUrl: function getUrl() {
  32. return '/pins';
  33. },
  34. render: function render() {
  35. var _this = this;
  36. this.$el.html(this.template({
  37. lbl_alternateTitle: StringResources.get('pinsOld')
  38. }));
  39. var $listEl = this.$el.find('.pinListView');
  40. return Promise.all([this.dashboardApi.getGlassSvc('.DashboardPinning'), this._getDndManager()]).then(function (results) {
  41. var dashboardPinningService = results[0];
  42. var PinsPanelClass = _this._getPinsPanelClass();
  43. _this._pinListView = new PinsPanelClass({
  44. el: $listEl,
  45. appController: _this.appController,
  46. viewMode: _this.viewMode,
  47. glassContext: _this.glassContext,
  48. canvasController: _this.canvasController,
  49. dndManager: _this.dndManager,
  50. dashboardPinningService: dashboardPinningService,
  51. smartNamingSvc: _this.dashboardApi.getDashboardCoreSvc('.SmartNamingSvc')
  52. });
  53. _this._pinListView.render();
  54. });
  55. },
  56. _getPinsPanelClass: function _getPinsPanelClass() {
  57. return PinsPanel;
  58. },
  59. remove: function remove() {
  60. this._pinListView.remove();
  61. return PinView.inherited('remove', this, arguments);
  62. },
  63. shouldUpdateGlass: function shouldUpdateGlass() {
  64. return false;
  65. },
  66. _getDndManager: function _getDndManager() {
  67. if (this.dndManager) {
  68. return Promise.resolve();
  69. } else {
  70. return this.dndManager = this.dashboardApi.getFeature('DashboardDnd.internal');
  71. }
  72. }
  73. });
  74. return PinView;
  75. });
  76. //# sourceMappingURL=PinView.js.map