LoginPerspectiveListView.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2016
  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/commons/ui/content/SingleSelectListControl', 'ba-react-admin/ba-react-admin.min'], function (Q, StringResource, ListView, ListControl, AdminReact) {
  10. var LoginPerspectiveListView = ListView.extend({
  11. init: function init() {
  12. LoginPerspectiveListView.inherited('init', this, arguments);
  13. var spec = this._getListSpec();
  14. spec.$el = this._contentView.$standardBody;
  15. spec.selectedRow = ['name', this.currentValue];
  16. this._body = this._getNewListControl(spec);
  17. this._contentView.bodyView = this._body;
  18. this.$el = this._contentView.$el;
  19. },
  20. _getNewListControl: function _getNewListControl(options) {
  21. return new ListControl(options);
  22. },
  23. render: function render() {
  24. return LoginPerspectiveListView.inherited('render', this, arguments).then(function (result) {
  25. $(result).addClass('login-perspective-view');
  26. });
  27. },
  28. _getPerspectives: function _getPerspectives() {
  29. return AdminReact.AdminSvc.getPerspectives(this.glassContext.getCoreSvc('.Ajax'), {
  30. type: 'login',
  31. extension: true
  32. }).then(function (list) {
  33. var defaultLogin = {
  34. name: 'login'
  35. };
  36. if (list === undefined) {
  37. list = [];
  38. }
  39. list.push(defaultLogin);
  40. return list;
  41. }, function (err) {
  42. this.glassContext.appController.showToast(StringResource.get('failedToRetrievePerspectivesList'), {
  43. type: 'error'
  44. });
  45. this.glassContext.getCoreSvc('.Logger').error('failed to get the perspective list from glass service.', err);
  46. }.bind(this));
  47. }
  48. });
  49. return LoginPerspectiveListView;
  50. });