Main.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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": 720
  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. loadElements: function(){
  72. this.loadElementList("pageList", this.pageListNode, this.openPage.bind(this), this.lp.noPage, this.createNewPage.bind(this));
  73. },
  74. createNewPage: function(e){
  75. this.openApplication(e, 0);
  76. },
  77. openPage: function(id, e){
  78. if (id){
  79. var _self = this;
  80. var options = {
  81. "appId": "portal.PageDesigner"+id,
  82. "onQueryLoad": function(){
  83. this.actions = _self.app.actions;
  84. //this.category = _self;
  85. this.options.id = id;
  86. this.application = _self.data;
  87. }
  88. };
  89. this.app.desktop.openApplication(e, "portal.PageDesigner", options);
  90. }
  91. },
  92. openApplication: function(e, navi){
  93. var appId = "portal.PortalManager"+this.data.id;
  94. if (this.app.desktop.apps[appId]){
  95. this.app.desktop.apps[appId].setCurrent();
  96. }else {
  97. this.app.desktop.openApplication(e, "portal.PortalManager", {
  98. "application": this.data,
  99. "appId": appId,
  100. "onQueryLoad": function(){
  101. this.status = {"navi": navi || null};
  102. }
  103. });
  104. }
  105. },
  106. setIconNode: function(){
  107. if (this.data.icon){
  108. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.icon+")");
  109. }else{
  110. this.iconNode.setStyle("background-image", "url("+"/x_component_portal_PortalExplorer/$Main/default/icon/application.png)")
  111. }
  112. this.iconNode.makeLnk({
  113. "par": this._getLnkPar()
  114. });
  115. },
  116. _getLnkPar: function(){
  117. var lnkIcon = "/x_component_portal_PortalExplorer/$Main/default/lnk.png";
  118. if (this.data.icon) lnkIcon = "data:image/png;base64,"+this.data.icon;
  119. var appId = "portal.PortalManager"+this.data.id;
  120. return {
  121. "icon": lnkIcon,
  122. "title": this.data.name,
  123. "par": "portal.PortalManager#{\"application\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  124. };
  125. },
  126. exportApplication: function(){
  127. MWF.xDesktop.requireApp("portal.PortalExplorer", "Exporter", function(){
  128. (new MWF.xApplication.portal.PortalExplorer.Exporter(this.app, this.data)).load();
  129. }.bind(this));
  130. },
  131. _deleteElement: function(id, onlyRemoveNotCompleted, success, failure){
  132. this.app.restActions.deleteApplication(id, success, failure);
  133. }
  134. });