FileExplorer.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. MWF.xDesktop.requireApp("process.ProcessManager", "FileExplorer", null, false);
  2. MWF.xApplication.portal.PortalManager.FileExplorer = new Class({
  3. Extends: MWF.xApplication.process.ProcessManager.FileExplorer,
  4. Implements: [Options, Events],
  5. options: {
  6. "create": MWF.APPPM.LP.file.create,
  7. "search": MWF.APPPM.LP.file.search,
  8. "searchText": MWF.APPPM.LP.file.searchText,
  9. "noElement": MWF.APPPM.LP.file.noDictionaryNoticeText
  10. },
  11. _createElement: function(e){
  12. // var _self = this;
  13. // var options = {
  14. // "onQueryLoad": function(){
  15. // this.actions = _self.app.restActions;
  16. // this.application = _self.app.options.application || _self.app.application;
  17. // this.explorer = _self;
  18. // }
  19. // };
  20. // this.app.desktop.openApplication(e, "process.FileDesigner", options);
  21. new MWF.xApplication.portal.PortalManager.FileDesigner(this);
  22. },
  23. _getItemObject: function(item){
  24. return new MWF.xApplication.portal.PortalManager.FileExplorer.File(this, item)
  25. }
  26. });
  27. MWF.xApplication.portal.PortalManager.FileExplorer.File = new Class({
  28. Extends: MWF.xApplication.process.ProcessManager.FileExplorer.File,
  29. _open: function(e){
  30. var _self = this;
  31. MWF.Actions.get("x_portal_assemble_designer").getFile(this.data.id, function(json){
  32. this.data = json.data;
  33. new MWF.xApplication.portal.PortalManager.FileDesigner(this.explorer, this.data);
  34. }.bind(this));
  35. },
  36. _getIcon: function(){
  37. return "file.png";
  38. },
  39. _getLnkPar: function(){
  40. return {
  41. "icon": this.explorer.path+this.explorer.options.style+"/fileIcon/lnk.png",
  42. "title": this.data.name,
  43. "par": "portal.FileDesigner#{\"id\": \""+this.data.id+"\", \"applicationId\": \""+this.explorer.app.options.application.id+"\"}"
  44. };
  45. },
  46. deleteFile: function(callback){
  47. this.explorer.app.restActions.deleteFile(this.data.id, function(){
  48. this.node.destroy();
  49. if (callback) callback();
  50. }.bind(this));
  51. }
  52. });
  53. MWF.xApplication.portal.PortalManager.FileDesigner = new Class({
  54. Extends: MWF.xApplication.process.ProcessManager.FileDesigner,
  55. getNewData: function(){
  56. return {
  57. "id": "",
  58. "name": "",
  59. "alias": "",
  60. "description": "",
  61. "portal": (this.explorer.app.options.application || this.explorer.app.application).id,
  62. "fileName": ""
  63. }
  64. },
  65. createContentFileUrl: function(){
  66. if (this.data.fileName){
  67. var div = new Element("div", {"styles": this.css.fileDesignerContentLineNode}).inject(this.contentAreaNode);
  68. var lineTitleNode = new Element("div", {"styles": this.css.fileDesignerContentLineTitleNode, "text": "URL"}).inject(div);
  69. this.fileUrlNode = new Element("div", {"styles": this.css.fileDesignerContentLineContentNode}).inject(div);
  70. div.setStyle("height", "80px");
  71. var url = MWF.Actions.get("x_portal_assemble_surface").action.actions.readFile.uri;
  72. url = url.replace(/{flag}/, this.data.id);
  73. url = url.replace(/{applicationFlag}/, this.data.portal);
  74. url = "/x_portal_assemble_surface"+url;
  75. this.fileUrlNode.setStyle("line-height", "18px");
  76. var href = MWF.Actions.getHost("x_portal_assemble_surface")+url;
  77. //this.fileUrlNode.set("html", "<a target='_blank' href='"+href+"'>"+url+"</a>");
  78. this.fileUrlNode.set("text", url);
  79. var a = new Element("div", {
  80. "styles": {"height": "30px"},
  81. "html": "<a target='_blank' href='"+href+"'>open</a>"
  82. }).inject(this.fileUrlNode, "bottom");
  83. }
  84. },
  85. modifyContentFileUrl: function(){
  86. if (!this.fileUrlNode){
  87. this.createContentFileUrl();
  88. }else{
  89. var url = MWF.Actions.get("x_portal_assemble_surface").action.actions.readFile.uri;
  90. url = url.replace(/{flag}/, this.data.id);
  91. url = url.replace(/{applicationFlag}/, this.data.portal);
  92. //this.fileUrlNode.set("text", "/x_processplatform_assemble_surface"+url);
  93. url = "/x_portal_assemble_surface"+url;
  94. this.fileUrlNode.setStyle("line-height", "18px");
  95. var href = MWF.Actions.getHost("x_portal_assemble_surface")+url;
  96. //this.fileUrlNode.set("html", "<a target='_blank' href='"+href+"'>"+url+"</a>");
  97. this.fileUrlNode.set("text", url);
  98. var a = new Element("div", {
  99. "styles": {"height": "30px"},
  100. "html": "<a target='_blank' href='"+href+"'>open</a>"
  101. }).inject(this.fileUrlNode, "bottom")
  102. }
  103. },
  104. upload: function(){
  105. if (!this.data.id){
  106. var data = this.getData();
  107. this.data = Object.merge(this.data, data);
  108. MWF.Actions.get("x_portal_assemble_designer").saveFile(this.data, function(){
  109. this.explorer.reload();
  110. this.uploadFile(function(){
  111. this.app.notice(this.lp.file.uploadSuccess, "success");
  112. }.bind(this));
  113. }.bind(this));
  114. }else{
  115. this.uploadFile(function(){
  116. this.app.notice(this.lp.file.uploadSuccess, "success");
  117. }.bind(this));
  118. }
  119. },
  120. uploadFile: function(callback){
  121. MWF.require("MWF.widget.Upload", function(){
  122. new MWF.widget.Upload(this.app.content, {
  123. "action": MWF.Actions.get("x_portal_assemble_designer").action,
  124. "method": "uploadFile",
  125. "parameter": {"id": this.data.id},
  126. "onCompleted": function(){
  127. this.loadFileIcon();
  128. this.modifyContentFileUrl();
  129. if (callback) callback();
  130. }.bind(this),
  131. "onEvery": function(json, current, count, file){
  132. //this.data.description = file.name+" "+this.getSizeText(file.size);
  133. this.data.fileName = file.name;
  134. this.data.description = file.name+" "+this.getSizeText(file.size);
  135. this.descriptionInput.set("value", this.data.description);
  136. MWF.Actions.get("x_portal_assemble_designer").saveFile(this.data);
  137. }.bind(this)
  138. }).load();
  139. }.bind(this));
  140. },
  141. save: function(){
  142. var data = this.getData();
  143. this.data = Object.merge(this.data, data);
  144. MWF.Actions.get("x_portal_assemble_designer").saveFile(this.data, function(){
  145. this.explorer.reload();
  146. this.app.notice(this.lp.file.saveSuccess, "success");
  147. this.destroy();
  148. }.bind(this));
  149. }
  150. });