Main.js 13 KB

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