JobCreateButtonView.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. /*
  3. * Licensed Materials - Property of IBM
  4. *
  5. * IBM Cognos Products: ADMIN
  6. *
  7. * (C) Copyright IBM Corp. 2017
  8. *
  9. * US Government Users Restricted Rights - Use, duplication or disclosure
  10. * restricted by GSA ADP Schedule Contract with IBM Corp.
  11. */
  12. define(['bi/glass/app/plugins/MenuActionInterface', 'bi/glass/utils/ClassFactory', 'ba-react-admin/ba-react-admin.min'], function (view, ClassFactory, AdminReact) {
  13. 'use strict';
  14. var JOB_PANE_MODULE = 'bi/admin/job/JobPane';
  15. var JobCreateButtonView = view.extend({
  16. SUBSCRIPTION_SLIDEOUT_PANE_WIDTH: '400px',
  17. onSelectItem: function onSelectItem(context) {
  18. var id = context.target.itemId;
  19. var idTokens = id.split('.');
  20. var key = idTokens[idTokens.length - 1];
  21. if (key === "new_job") {
  22. AdminReact.JobUIStore.setCreateButtonPressed(true);
  23. return this._showNewJobPane(context.glassContext).catch(function (err) {
  24. context.glassContext.getCoreSvc('.Logger').error(err);
  25. });
  26. }
  27. },
  28. _showNewJobPane: function _showNewJobPane(glassContext) {
  29. return ClassFactory.loadModule(JOB_PANE_MODULE).then(function (JobPane) {
  30. return JobPane.openJobPane(glassContext, {});
  31. });
  32. },
  33. isItemVisible: function isItemVisible(context) {
  34. var id = context.target.itemId;
  35. var idTokens = id.split('.');
  36. var key = idTokens[idTokens.length - 1];
  37. if (key === "new_job") {
  38. return true;
  39. } else {
  40. return false;
  41. }
  42. }
  43. });
  44. return JobCreateButtonView;
  45. });