Main.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.reloadApplicationCategoryList(true);
  55. this.notice(this.lp.application.createApplicationSuccess, "success");
  56. }.bind(this));
  57. }else{
  58. nameNode.setStyle("border-color", "red");
  59. nameNode.focus();
  60. this.notice(this.lp.application.inputApplicationName, "error");
  61. }
  62. },
  63. importApplication: function(e){
  64. MWF.xDesktop.requireApp("portal.PortalExplorer", "Importer", function(){
  65. (new MWF.xApplication.portal.PortalExplorer.Importer(this, e)).load();
  66. }.bind(this));
  67. }
  68. });
  69. MWF.xApplication.portal.PortalExplorer.Portal = new Class({
  70. Extends: MWF.xApplication.process.ApplicationExplorer.Application,
  71. Implements: [Events],
  72. checkManage: function(){
  73. if (this.app.control.canManage) return true;
  74. if (this.app.control.canCreate && (this.data.creatorPerson==layout.desktop.session.user.name)) return true;
  75. //if (this.data.controllerList.indexOf(layout.desktop.session.user.distinguishedName)!==-1) return true;
  76. return false;
  77. },
  78. loadElements: function(){
  79. this.loadElementList("pageList", this.pageListNode, this.openPage.bind(this), this.lp.noPage, this.createNewPage.bind(this));
  80. },
  81. createNewPage: function(e){
  82. this.openApplication(e, 0);
  83. },
  84. openPage: function(id, e){
  85. if (id){
  86. var _self = this;
  87. var options = {
  88. "appId": "portal.PageDesigner"+id,
  89. "onQueryLoad": function(){
  90. this.actions = _self.app.actions;
  91. //this.category = _self;
  92. this.options.id = id;
  93. this.application = _self.data;
  94. }
  95. };
  96. this.app.desktop.openApplication(e, "portal.PageDesigner", options);
  97. }
  98. },
  99. openApplication: function(e, navi){
  100. var appId = "portal.PortalManager"+this.data.id;
  101. if (this.app.desktop.apps[appId]){
  102. this.app.desktop.apps[appId].setCurrent();
  103. }else {
  104. this.app.desktop.openApplication(e, "portal.PortalManager", {
  105. "application": this.data,
  106. "appId": appId,
  107. "onQueryLoad": function(){
  108. this.status = {"navi": navi || null};
  109. }
  110. });
  111. }
  112. },
  113. setIconNode: function(){
  114. if (this.data.icon){
  115. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.icon+")");
  116. }else{
  117. this.iconNode.setStyle("background-image", "url("+"../x_component_portal_PortalExplorer/$Main/default/icon/application.png)")
  118. }
  119. this.iconNode.makeLnk({
  120. "par": this._getLnkPar()
  121. });
  122. },
  123. _getLnkPar: function(){
  124. var lnkIcon = "../x_component_portal_PortalExplorer/$Main/default/lnk.png";
  125. if (this.data.icon) lnkIcon = "data:image/png;base64,"+this.data.icon;
  126. var appId = "portal.PortalManager"+this.data.id;
  127. return {
  128. "icon": lnkIcon,
  129. "title": this.data.name,
  130. "par": "portal.PortalManager#{\"application\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  131. };
  132. },
  133. exportApplication: function(){
  134. MWF.xDesktop.requireApp("portal.PortalExplorer", "Exporter", function(){
  135. (new MWF.xApplication.portal.PortalExplorer.Exporter(this.app, this.data)).load();
  136. }.bind(this));
  137. },
  138. _deleteElement: function(id, onlyRemoveNotCompleted, success, failure){
  139. this.app.restActions.deleteApplication(id, success, failure);
  140. }
  141. });