Main.js 12 KB

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