Main.js 6.3 KB

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