ContactPreferencesTab.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2018, 2018
  6. * US Government Users Restricted Rights - Use, duplication or disclosure
  7. * restricted by GSA ADP Schedule Contract with IBM Corp.
  8. */
  9. define(['react', 'react-dom', 'ba-react-admin/ba-react-admin.min', 'underscore', 'bi/glass/app/ContentView', 'bi/admin/nls/StringResource'], function (React, ReactDOM, AdminReact, _, ContentView, StringResource) {
  10. 'use strict'; //NOSONAR: meant to be strict
  11. var ContactPreferencesTab = ContentView.extend({
  12. init: function init(options) {
  13. ContactPreferencesTab.inherited('init', this, arguments);
  14. _.extend(this, options);
  15. },
  16. render: function render() {
  17. AdminReact.ContactStore.update(this.objectInfo);
  18. ReactDOM.unmountComponentAtNode(this.$el[0]);
  19. var pane = React.createElement(AdminReact.ContactPreferencesPanel, {
  20. glassContext: this.glassContext,
  21. StringResource: StringResource,
  22. parent: this,
  23. title: this.title
  24. });
  25. ReactDOM.render(pane, this.$el[0]);
  26. return Promise.resolve();
  27. },
  28. onClose: function onClose() {
  29. ReactDOM.unmountComponentAtNode(this.$el[0]);
  30. var dirty = AdminReact.ContactStore.isDirty({
  31. format: this.objectInfo.format,
  32. locale: this.objectInfo.locale,
  33. timeZoneID: this.objectInfo.timeZoneID
  34. });
  35. if (dirty) {
  36. this.objectInfo.contactUpdate = {
  37. format: AdminReact.ContactStore.reportFormatId,
  38. locale: AdminReact.ContactStore.modifiedContentLocale,
  39. timeZoneID: AdminReact.ContactStore.modifiedTimeZone
  40. };
  41. }
  42. AdminReact.ContactStore.clear();
  43. }
  44. });
  45. return ContactPreferencesTab;
  46. });