SourceModel.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: Dashboard
  6. *| (C) Copyright IBM Corp. 2017 - 2019
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['../../../lib/@waca/dashboard-common/dist/core/Model', './shaping/ShapingModel', 'underscore'], function (Model, ShapingModel, _) {
  13. 'use strict';
  14. var SourceModel = Model.extend({
  15. nestedModels: {
  16. shaping: ShapingModel
  17. },
  18. whitelistAttrs: ['id', 'assetId', 'type', 'clientId', 'module', 'name', 'pinSourceName', 'shaping', 'customGroupColumns'],
  19. init: function init(model) {
  20. if (model) {
  21. _.defaults(model, {
  22. shaping: {},
  23. assetId: this._generateUniqueId('assetId')
  24. });
  25. }
  26. SourceModel.inherited('init', this, arguments);
  27. },
  28. destroy: function destroy() {
  29. if (this.getTempModuleUrl() && this.ajaxSvc) {
  30. this.ajaxSvc.ajax({
  31. contentType: 'application/json; charset=utf-8',
  32. url: this.getTempModuleUrl(),
  33. type: 'DELETE'
  34. });
  35. }
  36. this.get('shaping').destroy();
  37. },
  38. setAjaxSvc: function setAjaxSvc(ajaxSvc) {
  39. this.ajaxSvc = ajaxSvc;
  40. },
  41. setUserProfileSvc: function setUserProfileSvc(userProfileSvc) {
  42. this.userProfileSvc = userProfileSvc;
  43. },
  44. getDeploymentReference: function getDeploymentReference(deploymentReferences, processedAssetIds, isSaveAs) {
  45. if (this.state !== 'error' && this.errorCode !== '404' && !processedAssetIds[this.assetId]) {
  46. var _name;
  47. var userPreferences = this.userProfileSvc && this.userProfileSvc.preferences;
  48. var contentLocale = userPreferences && userPreferences.contentLocale || 'en-us';
  49. processedAssetIds[this.assetId] = true;
  50. deploymentReferences.push({
  51. objects: [{
  52. type: this.type,
  53. searchPath: 'storeID("' + this.assetId + '")'
  54. }],
  55. name: (_name = {}, _name[contentLocale] = this.assetId, _name)
  56. });
  57. if (this.shaping) {
  58. this.shaping.getDeploymentReference(deploymentReferences, processedAssetIds, isSaveAs, contentLocale);
  59. }
  60. }
  61. },
  62. getIsOlapPackage: function getIsOlapPackage() {
  63. return this.get('isOlapPackage');
  64. },
  65. hasInlineModule: function hasInlineModule() {
  66. return typeof this.module !== 'undefined';
  67. },
  68. setTempModuleUrl: function setTempModuleUrl(url) {
  69. this._tempModuleUrl = url;
  70. },
  71. getTempModuleUrl: function getTempModuleUrl() {
  72. return this._tempModuleUrl;
  73. }
  74. });
  75. return SourceModel;
  76. });
  77. //# sourceMappingURL=SourceModel.js.map