Main.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. MWF.xDesktop.requireApp("query.QueryManager", "package", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xDesktop.requireApp("process.ProcessManager", "", null, false);
  5. MWF.xApplication.query = MWF.xApplication.query || {};
  6. MWF.xApplication.query.QueryManager.Main = new Class({
  7. Extends: MWF.xApplication.process.ProcessManager.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "application": null,
  11. "style": "default",
  12. "name": "query.QueryManager",
  13. "icon": "icon.png",
  14. "width": "1100",
  15. "height": "700",
  16. "title": MWF.xApplication.query.QueryManager.LP.title
  17. },
  18. onQueryLoad: function(){
  19. this.lp = MWF.xApplication.query.QueryManager.LP;
  20. this.currentContentNode = null;
  21. this.restActions = MWF.Actions.get("x_query_assemble_designer");
  22. },
  23. keyCopyItems: function(e){
  24. debugger;
  25. if (this.viewConfigurator){
  26. this.viewConfigurator.keyCopy(e);
  27. }
  28. if (this.statConfigurator){
  29. this.statConfigurator.keyCopy(e);
  30. }
  31. },
  32. keyPasteItems: function(e){
  33. if (this.viewConfigurator){
  34. this.viewConfigurator.keyPaste(e);
  35. }
  36. if (this.statConfigurator) {
  37. this.statConfigurator.keyPaste(e);
  38. }
  39. },
  40. loadStartMenu: function(callback){
  41. this.startMenuNode = new Element("div", {
  42. "styles": this.css.startMenuNode
  43. }).inject(this.node);
  44. this.menu = new MWF.xApplication.query.QueryManager.Menu(this, this.startMenuNode, {
  45. "onPostLoad": function(){
  46. if (this.status){
  47. if (this.status.navi!=null){
  48. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  49. }else{
  50. this.menu.doAction(this.menu.startNavis[0]);
  51. }
  52. }else{
  53. this.menu.doAction(this.menu.startNavis[0]);
  54. }
  55. }.bind(this)
  56. });
  57. this.addEvent("resize", function(){
  58. if (this.menu) this.menu.onResize();
  59. }.bind(this));
  60. },
  61. clearContent: function(){
  62. if (this.selectConfiguratorContent){
  63. if (this.selectConfigurator) delete this.selectConfigurator;
  64. this.selectConfiguratorContent.destroy();
  65. this.selectConfiguratorContent = null;
  66. }
  67. if (this.viewConfiguratorContent){
  68. if (this.viewConfigurator) delete this.viewConfigurator;
  69. this.viewConfiguratorContent.destroy();
  70. this.viewConfiguratorContent = null;
  71. }
  72. if (this.propertyConfiguratorContent){
  73. if (this.property) delete this.property;
  74. this.propertyConfiguratorContent.destroy();
  75. this.propertyConfiguratorContent = null;
  76. }
  77. if (this.statConfiguratorContent){
  78. if (this.statConfigurator) delete this.statConfigurator;
  79. this.statConfiguratorContent.destroy();
  80. this.statConfiguratorContent = null;
  81. }
  82. if (this.revealConfiguratorContent){
  83. if (this.revealConfigurator) delete this.revealConfigurator;
  84. this.revealConfiguratorContent.destroy();
  85. this.revealConfiguratorContent = null;
  86. }
  87. },
  88. queryProperty: function(){
  89. this.clearContent();
  90. this.propertyConfiguratorContent = new Element("div", {
  91. "styles": this.css.rightContentNode
  92. }).inject(this.node);
  93. this.property = new MWF.xApplication.query.QueryManager.QueryProperty(this, this.propertyConfiguratorContent);
  94. this.property.load();
  95. },
  96. selectConfig: function(){
  97. this.clearContent();
  98. this.selectConfiguratorContent = new Element("div", {
  99. "styles": this.css.rightContentNode
  100. }).inject(this.node);
  101. this.loadSelectConfig();
  102. },
  103. loadSelectConfig: function(){
  104. MWF.xDesktop.requireApp("query.QueryManager", "SelectExplorer", function(){
  105. this.selectConfigurator = new MWF.xApplication.query.QueryManager.SelectExplorer(this.selectConfiguratorContent, this.restActions);
  106. this.selectConfigurator.app = this;
  107. this.selectConfigurator.load();
  108. }.bind(this));
  109. },
  110. viewConfig: function(){
  111. this.clearContent();
  112. this.viewConfiguratorContent = new Element("div", {
  113. "styles": this.css.rightContentNode
  114. }).inject(this.node);
  115. this.loadViewConfig();
  116. },
  117. loadViewConfig: function(){
  118. MWF.xDesktop.requireApp("query.QueryManager", "ViewExplorer", function(){
  119. this.viewConfigurator = new MWF.xApplication.query.QueryManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  120. this.viewConfigurator.app = this;
  121. this.viewConfigurator.load();
  122. }.bind(this));
  123. },
  124. statConfig: function(){
  125. this.clearContent();
  126. this.statConfiguratorContent = new Element("div", {
  127. "styles": this.css.rightContentNode
  128. }).inject(this.node);
  129. this.loadStatConfig();
  130. },
  131. loadStatConfig: function(){
  132. MWF.xDesktop.requireApp("query.QueryManager", "StatExplorer", function(){
  133. this.statConfigurator = new MWF.xApplication.query.QueryManager.StatExplorer(this.statConfiguratorContent, this.restActions);
  134. this.statConfigurator.app = this;
  135. this.statConfigurator.load();
  136. }.bind(this));
  137. },
  138. revealConfig: function(){
  139. this.clearContent();
  140. this.revealConfiguratorContent = new Element("div", {
  141. "styles": this.css.rightContentNode
  142. }).inject(this.node);
  143. this.loadRevealConfig();
  144. },
  145. loadRevealConfig: function(){
  146. MWF.xDesktop.requireApp("query.QueryManager", "RevealExplorer", function(){
  147. this.revealConfigurator = new MWF.xApplication.query.QueryManager.RevealExplorer(this.revealConfiguratorContent, this.restActions);
  148. this.revealConfigurator.app = this;
  149. this.revealConfigurator.load();
  150. }.bind(this));
  151. }
  152. });
  153. MWF.xApplication.query.QueryManager.Menu = new Class({
  154. Extends: MWF.xApplication.process.ProcessManager.Menu,
  155. Implements: [Options, Events]
  156. });
  157. MWF.xApplication.query.QueryManager.QueryProperty = new Class({
  158. Extends: MWF.xApplication.process.ProcessManager.ApplicationProperty,
  159. createPropertyContentNode: function(){
  160. this.propertyContentNode = new Element("div", {"styles": {
  161. "overflow": "hidden",
  162. "-webkit-user-select": "text",
  163. "-moz-user-select": "text"
  164. }}).inject(this.contentAreaNode);
  165. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  166. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  167. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  168. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  169. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  170. // html += "<tr><td class='formTitle'>"+this.app.lp.application.firstPage+"</td><td id='formApplicationFirstPage'></td></tr>";
  171. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  172. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  173. html += "</table>";
  174. this.propertyContentNode.set("html", html);
  175. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  176. this.nameInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  177. this.aliasInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  178. this.descriptionInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  179. this.typeInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  180. // this.firstPageInput = new MWF.xApplication.query.QueryManager.Select(this.propertyContentNode.getElement("#formApplicationFirstPage"), this.data.firstPage, this.app.css.formInput, function(){
  181. // var pages = {};
  182. // debugger;
  183. // this.app.restActions.listPage(this.app.options.application.id, function(json){
  184. // json.data.each(function(page) {
  185. // pages[page.id] = page.name;
  186. // }.bind(this));
  187. // }.bind(this), null, false);
  188. // return pages;
  189. // }.bind(this));
  190. this.idInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  191. },
  192. editMode: function(){
  193. this.nameInput.editMode();
  194. this.aliasInput.editMode();
  195. this.descriptionInput.editMode();
  196. this.typeInput.editMode();
  197. //this.firstPageInput.editMode();
  198. this.isEdit = true;
  199. },
  200. readMode: function(){
  201. this.nameInput.readMode();
  202. this.aliasInput.readMode();
  203. this.descriptionInput.readMode();
  204. this.typeInput.readMode();
  205. //this.firstPageInput.readMode();
  206. this.isEdit = false;
  207. },
  208. save: function(callback, cancel) {
  209. debugger;
  210. this.data.name = this.nameInput.input.get("value");
  211. this.data.alias = this.aliasInput.input.get("value");
  212. this.data.description = this.descriptionInput.input.get("value");
  213. this.data.applicationCategory = this.typeInput.input.get("value");
  214. //this.data.firstPage = this.firstPageInput.input.get("value");
  215. this.app.restActions.saveApplication(this.data, function (json) {
  216. this.propertyTitleBar.set("text", this.data.name);
  217. this.data.id = json.data.id;
  218. this.nameInput.save();
  219. this.aliasInput.save();
  220. this.descriptionInput.save();
  221. this.typeInput.save();
  222. //this.firstPageInput.save();
  223. if (callback) callback();
  224. }.bind(this), function (xhr, text, error) {
  225. if (cancel) cancel(xhr, text, error);
  226. }.bind(this));
  227. }
  228. });
  229. MWF.xApplication.query.QueryManager.Input = new Class({
  230. Extends: MWF.xApplication.process.ProcessManager.Input,
  231. Implements: [Events]
  232. });
  233. MWF.xApplication.query.QueryManager.Select = new Class({
  234. Extends: MWF.xApplication.process.ProcessManager.Input,
  235. Implements: [Events],
  236. initialize: function(node, value, style, select){
  237. this.node = $(node);
  238. this.value = (value) ? value: "";
  239. this.style = style;
  240. this.select = select;
  241. this.selectList = null;;
  242. this.load();
  243. },
  244. getSelectList: function(){
  245. if (this.select){
  246. return this.select();
  247. }
  248. return [];
  249. },
  250. getText: function(value){
  251. if (value){
  252. if (this.selectList){
  253. return this.selectList[value] || "";
  254. }
  255. }
  256. return "";
  257. },
  258. load: function(){
  259. this.selectList = this.getSelectList();
  260. this.content = new Element("div", {
  261. "styles": this.style.content,
  262. "text": this.getText(this.value)
  263. }).inject(this.node);
  264. },
  265. editMode: function(){
  266. this.content.empty();
  267. this.input = new Element("select",{
  268. //"styles": this.style.input,
  269. //"value": this.value
  270. }).inject(this.content);
  271. Object.each(this.selectList, function(v, k){
  272. new Element("option", {
  273. "value": k,
  274. "text": v,
  275. "selected": (this.value==v)
  276. }).inject(this.input);
  277. }.bind(this));
  278. //this.input.addEvents({
  279. // //"focus": function(){
  280. // // this.input.setStyles(this.style.input_focus);
  281. // //}.bind(this),
  282. // //"blur": function(){
  283. // // this.input.setStyles(this.style.input);
  284. // //}.bind(this),
  285. // //"change": function(){
  286. // // this.input.setStyles(this.style.input);
  287. // //}.bind(this)
  288. //});
  289. },
  290. readMode: function(){
  291. this.content.empty();
  292. this.input = null;
  293. this.content.set("text", this.getText(this.value));
  294. },
  295. save: function(){
  296. if (this.input) this.value = this.input.options[this.input.selectedIndex].get("value");
  297. return this.value;
  298. }
  299. });