HomePerspectiveListView.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2016, 2017
  6. * US Government Users Restricted Rights - Use, duplication or disclosure
  7. * restricted by GSA ADP Schedule Contract with IBM Corp.
  8. */
  9. define(['q', 'bi/admin/nls/StringResource', 'bi/admin/common/ui/BasePerspectiveListView', 'bi/admin/system/SetHomePageView', 'ba-react-admin/ba-react-admin.min'], function (Q, StringResource, ListView, SetHomePageView, AdminReact) {
  10. var HomePerspectiveListView = ListView.extend({
  11. init: function init() {
  12. HomePerspectiveListView.inherited('init', this, arguments);
  13. var spec = this._getListSpec();
  14. spec.$el = this._contentView.$standardBody;
  15. spec.selectedRow = ['name', this.currentValue.perspective];
  16. var options = {
  17. currentValue: this.currentValue,
  18. $el: this._contentView.$standardBody,
  19. glassContext: this.glassContext,
  20. listSpec: spec,
  21. _selectionChanged: this._selectionChanged
  22. };
  23. this._body = new SetHomePageView(options);
  24. this._contentView.bodyView = this._body;
  25. this.$el = this._contentView.$el;
  26. },
  27. render: function render() {
  28. return HomePerspectiveListView.inherited('render', this, arguments).then(function (result) {
  29. $(result).addClass('home-perspective-page');
  30. });
  31. },
  32. _getPerspectives: function _getPerspectives() {
  33. return AdminReact.AdminSvc.getPerspectives(this.glassContext.getCoreSvc('.Ajax'), {
  34. type: 'home',
  35. extension: true
  36. }).then(function (list) {
  37. var defaultHome = {
  38. name: this._getDefaultHome()
  39. };
  40. if (list === undefined) {
  41. list = [];
  42. }
  43. list.push(defaultHome);
  44. return list;
  45. }.bind(this), function (err) {
  46. this.glassContext.appController.showToast(StringResource.get('failedToRetrievePerspectivesList'), {
  47. type: 'error'
  48. });
  49. this.glassContext.services.logger.error('failed to get the perspective list from glass service.', err);
  50. }.bind(this));
  51. },
  52. _getDefaultHome: function _getDefaultHome() {
  53. return this.global ? 'home' : StringResource.get('default');
  54. }
  55. });
  56. return HomePerspectiveListView;
  57. });