Main.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. MWF.xApplication.query = MWF.xApplication.query || {};
  2. MWF.xApplication.query.QueryExplorer = MWF.xApplication.query.QueryExplorer || {};
  3. MWF.xDesktop.requireApp("process.ApplicationExplorer", "", null, false);
  4. MWF.xApplication.query.QueryExplorer.Main = new Class({
  5. Extends: MWF.xApplication.process.ApplicationExplorer.Main,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "name": "query.QueryExplorer",
  10. "mvcStyle": "style.css",
  11. "icon": "icon.png",
  12. "width": "1500",
  13. "height": "760",
  14. "isResize": true,
  15. "isMax": true,
  16. "title": MWF.xApplication.query.QueryExplorer.LP.title,
  17. "maxWidth": 840,
  18. "minWidth": 720
  19. },
  20. onQueryLoad: function(){
  21. this.lp = MWF.QueryLP;
  22. this.viewPath = this.path+this.options.style+"/view.html";
  23. this.restActions = MWF.Actions.get("x_query_assemble_designer");
  24. this.deleteElements = [];
  25. },
  26. loadControl: function(){
  27. this.control = {};
  28. this.control.canCreate = MWF.AC.isQueryPlatformCreator();
  29. this.control.canManage = !!(MWF.AC.isAdministrator() || MWF.AC.isQueryManager());
  30. },
  31. createApplicationItem: function(appData, where){
  32. var application = new MWF.xApplication.query.QueryExplorer.Query(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. "queryCategory": 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.viewList = [];
  52. json.data.statList = [];
  53. this.createApplicationItem(json.data, "top");
  54. }.bind(this));
  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("query.QueryExplorer", "Importer", function(){
  65. (new MWF.xApplication.query.QueryExplorer.Importer(this, e)).load();
  66. }.bind(this));
  67. }
  68. });
  69. MWF.xApplication.query.QueryExplorer.Query = new Class({
  70. Extends: MWF.xApplication.process.ApplicationExplorer.Application,
  71. Implements: [Events],
  72. loadElements: function(){
  73. this.loadElementList("viewList", this.viewListNode, this.openView.bind(this), this.lp.noView, this.createNewView.bind(this));
  74. this.loadElementList("statList", this.statListNode, this.openStat.bind(this), this.lp.noStat, this.createNewStat.bind(this));
  75. },
  76. createNewView: function(e){
  77. this.openApplication(e, 0);
  78. },
  79. createNewStat: function(e){
  80. this.openApplication(e, 1);
  81. },
  82. openApplication: function(e, navi){
  83. var appId = "query.QueryManager"+this.data.id;
  84. if (this.app.desktop.apps[appId]){
  85. this.app.desktop.apps[appId].setCurrent();
  86. }else {
  87. this.app.desktop.openApplication(e, "query.QueryManager", {
  88. "application": this.data,
  89. "appId": appId,
  90. "onQueryLoad": function(){
  91. this.status = {"navi": navi || null};
  92. }
  93. });
  94. }
  95. },
  96. openView: function(id, e){
  97. if (id){
  98. var _self = this;
  99. var options = {
  100. "appId": "query.ViewDesigner"+id,
  101. "onQueryLoad": function(){
  102. this.actions = _self.app.actions;
  103. //this.category = _self;
  104. this.options.id = id;
  105. this.application = _self.data;
  106. }
  107. };
  108. this.app.desktop.openApplication(e, "query.ViewDesigner", options);
  109. }
  110. },
  111. openStat: function(id, e){
  112. if (id){
  113. var _self = this;
  114. var options = {
  115. "appId": "query.StatDesigner"+id,
  116. "onQueryLoad": function(){
  117. this.actions = _self.app.actions;
  118. //this.category = _self;
  119. this.options.id = id;
  120. this.application = _self.data;
  121. }
  122. };
  123. this.app.desktop.openApplication(e, "query.StatDesigner", options);
  124. }
  125. },
  126. setIconNode: function(){
  127. if (this.data.icon){
  128. this.iconNode.setStyle("background-image", "url(data:image/png;base64,"+this.data.icon+")");
  129. }else{
  130. this.iconNode.setStyle("background-image", "url("+"/x_component_query_QueryExplorer/$Main/default/icon/application.png)")
  131. }
  132. this.iconNode.makeLnk({
  133. "par": this._getLnkPar()
  134. });
  135. },
  136. _getLnkPar: function(){
  137. var lnkIcon = "/x_component_query_QueryExplorer/$Main/default/lnk.png";
  138. if (this.data.icon) lnkIcon = "data:image/png;base64,"+this.data.icon;
  139. var appId = "query.QueryManager"+this.data.id;
  140. return {
  141. "icon": lnkIcon,
  142. "title": this.data.name,
  143. "par": "query.QueryManager#{\"application\": \""+this.data.id+"\", \"appId\": \""+appId+"\"}"
  144. };
  145. },
  146. exportApplication: function(){
  147. MWF.xDesktop.requireApp("query.QueryExplorer", "Exporter", function(){
  148. (new MWF.xApplication.query.QueryExplorer.Exporter(this.app, this.data)).load();
  149. }.bind(this));
  150. },
  151. _deleteElement: function(id, onlyRemoveNotCompleted, success, failure){
  152. this.app.restActions.deleteApplication(id, success, failure);
  153. }
  154. });