Main.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. openFindDesigner: function(){
  32. var options = {
  33. "filter": {
  34. "moduleList": ["portal"]
  35. }
  36. };
  37. layout.openApplication(null, "FindDesigner", options);
  38. },
  39. createApplicationItem: function(appData, where){
  40. var application = new MWF.xApplication.portal.PortalExplorer.Portal(this, appData, where);
  41. application.load();
  42. this.applicationList.push(application);
  43. },
  44. okCreateApplication: function(e){
  45. var nameNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationName");
  46. var aliasNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationAlias");
  47. var descriptionNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationDescription");
  48. var typeNode = this.applicationCreateFormNode.getElement(".o2_process_AppExp_createApplicationType");
  49. var data = {
  50. "name": nameNode.get("value"),
  51. "alias": aliasNode.get("value"),
  52. "description": descriptionNode.get("value"),
  53. "portalCategory": typeNode.get("value") || ""
  54. };
  55. if (data.name){
  56. this.restActions.saveApplication(data, function(json){
  57. this.applicationCreateMarkNode.destroy();
  58. this.applicationCreateAreaNode.destroy();
  59. this.restActions.getApplication(json.data.id, function(json){
  60. json.data.pageList = [];
  61. this.createApplicationItem(json.data, "top");
  62. }.bind(this));
  63. this.reloadApplicationCategoryList(true);
  64. this.notice(this.lp.application.createApplicationSuccess, "success");
  65. }.bind(this));
  66. }else{
  67. nameNode.setStyle("border-color", "red");
  68. nameNode.focus();
  69. this.notice(this.lp.application.inputApplicationName, "error");
  70. }
  71. },
  72. importApplication: function(e){
  73. MWF.xDesktop.requireApp("portal.PortalExplorer", "Importer", function(){
  74. (new MWF.xApplication.portal.PortalExplorer.Importer(this, e)).load();
  75. }.bind(this));
  76. }
  77. });
  78. MWF.xApplication.portal.PortalExplorer.Portal = new Class({
  79. Extends: MWF.xApplication.process.ApplicationExplorer.Application,
  80. Implements: [Events],
  81. checkManage: function(){
  82. if (this.app.control.canManage) return true;
  83. if (this.app.control.canCreate && (this.data.creatorPerson==layout.desktop.session.user.name)) return true;
  84. //if (this.data.controllerList.indexOf(layout.desktop.session.user.distinguishedName)!==-1) return true;
  85. return false;
  86. },
  87. loadElements: function(){
  88. this.loadElementList("pageList", this.pageListNode, this.openPage.bind(this), this.lp.noPage, this.createNewPage.bind(this));
  89. },
  90. createNewPage: function(e){
  91. this.openApplication(e, 0);
  92. },
  93. openPage: function(id, e){
  94. if (id){
  95. var _self = this;
  96. var options = {
  97. "appId": "portal.PageDesigner"+id,
  98. "onQueryLoad": function(){
  99. this.actions = _self.app.actions;
  100. //this.category = _self;
  101. this.options.id = id;
  102. this.application = _self.data;
  103. }
  104. };
  105. this.app.desktop.openApplication(e, "portal.PageDesigner", options);
  106. }
  107. },
  108. openApplication: function(e, navi){
  109. var appId = "portal.PortalManager"+this.data.id;
  110. if (this.app.desktop.apps[appId]){
  111. this.app.desktop.apps[appId].setCurrent();
  112. }else {
  113. this.app.desktop.openApplication(e, "portal.PortalManager", {
  114. "application": {"id": this.data.id, "name": this.data.name},
  115. "appId": appId,
  116. "onQueryLoad": function(){
  117. this.status = {"navi": navi || null};
  118. }
  119. });
  120. }
  121. },
  122. setIconNode: function(){
  123. if (this.data.icon){
  124. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.icon+")");
  125. }else{
  126. this.iconNode.setStyle("background-image", "url("+"../x_component_portal_PortalExplorer/$Main/default/icon/application.png)")
  127. }
  128. this.iconNode.makeLnk({
  129. "par": this._getLnkPar()
  130. });
  131. },
  132. _getLnkPar: function(){
  133. var lnkIcon = "../x_component_portal_PortalExplorer/$Main/default/lnk.png";
  134. if (this.data.icon) lnkIcon = "data:image/png;base64,"+this.data.icon;
  135. var appId = "portal.PortalManager"+this.data.id;
  136. return {
  137. "icon": lnkIcon,
  138. "title": this.data.name,
  139. "par": "portal.PortalManager#{\"application\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  140. };
  141. },
  142. exportApplication: function(){
  143. MWF.xDesktop.requireApp("portal.PortalExplorer", "Exporter", function(){
  144. (new MWF.xApplication.portal.PortalExplorer.Exporter(this.app, this.data)).load();
  145. }.bind(this));
  146. },
  147. _deleteElement: function(id, onlyRemoveNotCompleted, success, failure){
  148. this.app.restActions.deleteApplication(id, success, failure);
  149. }
  150. });