Main.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. MWF.xApplication.portal = MWF.xApplication.portal || {};
  2. MWF.xApplication.portal.PortalExplorer = MWF.xApplication.portal.PortalExplorer || {};
  3. MWF.xDesktop.requireApp("process.ApplicationExplorer", "", null, false);
  4. MWF.xApplication.portal.PortalExplorer.Main = new Class({
  5. Extends: MWF.xApplication.process.ApplicationExplorer.Main,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "name": "portal.PortalExplorer",
  10. "mvcStyle": "style.css",
  11. "icon": "icon.png",
  12. "width": "1500",
  13. "height": "760",
  14. "isResize": true,
  15. "isMax": true,
  16. "title": MWF.xApplication.portal.PortalExplorer.LP.title,
  17. "maxWidth": 840,
  18. "minWidth": 540
  19. },
  20. onQueryLoad: function(){
  21. this.lp = MWF.xApplication.portal.PortalExplorer.LP;
  22. this.viewPath = this.path+this.options.style+"/view.html";
  23. this.restActions = MWF.Actions.get("x_portal_assemble_designer");
  24. this.deleteElements = [];
  25. },
  26. loadControl: function(){
  27. this.control = {};
  28. this.control.canCreate = MWF.AC.isPortalPlatformCreator();
  29. this.control.canManage = !!(MWF.AC.isAdministrator() || MWF.AC.isPortalManager());
  30. },
  31. createApplicationItem: function(appData, where){
  32. var application = new MWF.xApplication.portal.PortalExplorer.Portal(this, appData, where);
  33. application.load();
  34. },
  35. okCreateApplication: function(e){
  36. var nameNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationName");
  37. var aliasNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationAlias");
  38. var descriptionNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationDescription");
  39. var typeNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationType");
  40. var data = {
  41. "name": nameNode.get("value"),
  42. "alias": aliasNode.get("value"),
  43. "description": descriptionNode.get("value"),
  44. "portalCategory": typeNode.get("value")
  45. };
  46. if (data.name){
  47. this.restActions.saveApplication(data, function(json){
  48. this.applicationCreateMarkNode.destroy();
  49. this.applicationCreateAreaNode.destroy();
  50. this.restActions.getApplication(json.data.id, function(json){
  51. json.data.pageList = [];
  52. this.createApplicationItem(json.data, "top");
  53. }.bind(this));
  54. this.notice(this.lp.application.createApplicationSuccess, "success");
  55. }.bind(this));
  56. }else{
  57. nameNode.setStyle("border-color", "red");
  58. nameNode.focus();
  59. this.notice(this.lp.application.inputApplicationName, "error");
  60. }
  61. },
  62. importApplication: function(e){
  63. MWF.xDesktop.requireApp("portal.PortalExplorer", "Importer", function(){
  64. (new MWF.xApplication.portal.PortalExplorer.Importer(this, e)).load();
  65. }.bind(this));
  66. }
  67. });
  68. MWF.xApplication.portal.PortalExplorer.Portal = new Class({
  69. Extends: MWF.xApplication.process.ApplicationExplorer.Application,
  70. Implements: [Events],
  71. checkManage: function(){
  72. if (this.app.control.canManage) return true;
  73. if (this.app.control.canCreate && (this.data.creatorPerson==layout.desktop.session.user.name)) return true;
  74. //if (this.data.controllerList.indexOf(layout.desktop.session.user.distinguishedName)!==-1) return true;
  75. return false;
  76. },
  77. loadElements: function(){
  78. this.loadElementList("pageList", this.pageListNode, this.openPage.bind(this), this.lp.noPage, this.createNewPage.bind(this));
  79. },
  80. createNewPage: function(e){
  81. this.openApplication(e, 0);
  82. },
  83. openPage: function(id, e){
  84. if (id){
  85. var _self = this;
  86. var options = {
  87. "appId": "portal.PageDesigner"+id,
  88. "onQueryLoad": function(){
  89. this.actions = _self.app.actions;
  90. //this.category = _self;
  91. this.options.id = id;
  92. this.application = _self.data;
  93. }
  94. };
  95. this.app.desktop.openApplication(e, "portal.PageDesigner", options);
  96. }
  97. },
  98. openApplication: function(e, navi){
  99. var appId = "portal.PortalManager"+this.data.id;
  100. if (this.app.desktop.apps[appId]){
  101. this.app.desktop.apps[appId].setCurrent();
  102. }else {
  103. this.app.desktop.openApplication(e, "portal.PortalManager", {
  104. "application": this.data,
  105. "appId": appId,
  106. "onQueryLoad": function(){
  107. this.status = {"navi": navi || null};
  108. }
  109. });
  110. }
  111. },
  112. setIconNode: function(){
  113. if (this.data.icon){
  114. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.icon+")");
  115. }else{
  116. this.iconNode.setStyle("background-image", "url("+"/x_component_portal_PortalExplorer/$Main/default/icon/application.png)")
  117. }
  118. this.iconNode.makeLnk({
  119. "par": this._getLnkPar()
  120. });
  121. },
  122. _getLnkPar: function(){
  123. var lnkIcon = "/x_component_portal_PortalExplorer/$Main/default/lnk.png";
  124. if (this.data.icon) lnkIcon = "data:image/png;base64,"+this.data.icon;
  125. var appId = "portal.PortalManager"+this.data.id;
  126. return {
  127. "icon": lnkIcon,
  128. "title": this.data.name,
  129. "par": "portal.PortalManager#{\"application\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  130. };
  131. },
  132. exportApplication: function(){
  133. MWF.xDesktop.requireApp("portal.PortalExplorer", "Exporter", function(){
  134. (new MWF.xApplication.portal.PortalExplorer.Exporter(this.app, this.data)).load();
  135. }.bind(this));
  136. },
  137. _deleteElement: function(id, onlyRemoveNotCompleted, success, failure){
  138. this.app.restActions.deleteApplication(id, success, failure);
  139. }
  140. });