Main.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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. if (this.tableConfigurator){
  31. this.tableConfigurator.keyCopy(e);
  32. }
  33. if (this.statementConfigurator){
  34. this.statementConfigurator.keyCopy(e);
  35. }
  36. if (this.importerConfigurator){
  37. this.importerConfigurator.keyCopy(e);
  38. }
  39. },
  40. keyPasteItems: function(e) {
  41. var app = layout.desktop.currentApp || layout.desktop.app;
  42. if (app && app.appId === this.appId){
  43. if (this.viewConfigurator) {
  44. this.viewConfigurator.keyPaste(e);
  45. }
  46. if (this.statConfigurator) {
  47. this.statConfigurator.keyPaste(e);
  48. }
  49. if (this.tableConfigurator) {
  50. this.tableConfigurator.keyPaste(e);
  51. }
  52. if (this.statementConfigurator) {
  53. this.statementConfigurator.keyPaste(e);
  54. }
  55. if (this.importerConfigurator) {
  56. this.importerConfigurator.keyPaste(e);
  57. }
  58. }
  59. },
  60. loadStartMenu: function(callback){
  61. this.startMenuNode = new Element("div", {
  62. "styles": this.css.startMenuNode
  63. }).inject(this.node);
  64. this.menu = new MWF.xApplication.query.QueryManager.Menu(this, this.startMenuNode, {
  65. "onPostLoad": function(){
  66. if (this.status){
  67. if (this.status.navi!=null){
  68. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  69. }else{
  70. this.menu.doAction(this.menu.startNavis[0]);
  71. }
  72. }else{
  73. this.menu.doAction(this.menu.startNavis[0]);
  74. }
  75. }.bind(this)
  76. });
  77. this.addEvent("resize", function(){
  78. if (this.menu) this.menu.onResize();
  79. }.bind(this));
  80. },
  81. clearContent: function(){
  82. //暂时没有启用---------------------
  83. if (this.selectConfiguratorContent){
  84. if (this.selectConfigurator) delete this.selectConfigurator;
  85. this.selectConfiguratorContent.destroy();
  86. this.selectConfiguratorContent = null;
  87. }
  88. if (this.revealConfiguratorContent){
  89. if (this.revealConfigurator) delete this.revealConfigurator;
  90. this.revealConfiguratorContent.destroy();
  91. this.revealConfiguratorContent = null;
  92. }
  93. //-------------------------------
  94. if (this.viewConfiguratorContent){
  95. if (this.viewConfigurator) delete this.viewConfigurator;
  96. this.viewConfiguratorContent.destroy();
  97. this.viewConfiguratorContent = null;
  98. }
  99. if (this.propertyConfiguratorContent){
  100. if (this.property) delete this.property;
  101. this.propertyConfiguratorContent.destroy();
  102. this.propertyConfiguratorContent = null;
  103. }
  104. if (this.statConfiguratorContent){
  105. if (this.statConfigurator) delete this.statConfigurator;
  106. this.statConfiguratorContent.destroy();
  107. this.statConfiguratorContent = null;
  108. }
  109. if (this.tableConfiguratorContent){
  110. if (this.tableConfigurator) delete this.tableConfigurator;
  111. this.tableConfiguratorContent.destroy();
  112. this.tableConfiguratorContent = null;
  113. }
  114. if (this.statementConfiguratorContent){
  115. if (this.statementConfigurator) delete this.statementConfigurator;
  116. this.statementConfiguratorContent.destroy();
  117. this.statementConfiguratorContent = null;
  118. }
  119. if (this.importerConfiguratorContent){
  120. if (this.importerConfigurator) delete this.importerConfigurator;
  121. this.importerConfiguratorContent.destroy();
  122. this.importerConfiguratorContent = null;
  123. }
  124. },
  125. queryProperty: function(){
  126. this.clearContent();
  127. this.propertyConfiguratorContent = new Element("div", {
  128. "styles": this.css.rightContentNode
  129. }).inject(this.node);
  130. this.property = new MWF.xApplication.query.QueryManager.QueryProperty(this, this.propertyConfiguratorContent);
  131. this.property.load();
  132. },
  133. selectConfig: function(){
  134. this.clearContent();
  135. this.selectConfiguratorContent = new Element("div", {
  136. "styles": this.css.rightContentNode
  137. }).inject(this.node);
  138. this.loadSelectConfig();
  139. },
  140. loadSelectConfig: function(){
  141. MWF.xDesktop.requireApp("query.QueryManager", "SelectExplorer", function(){
  142. this.selectConfigurator = new MWF.xApplication.query.QueryManager.SelectExplorer(this.selectConfiguratorContent, this.restActions);
  143. this.selectConfigurator.app = this;
  144. this.selectConfigurator.load();
  145. }.bind(this));
  146. },
  147. viewConfig: function(){
  148. this.clearContent();
  149. this.viewConfiguratorContent = new Element("div", {
  150. "styles": this.css.rightContentNode
  151. }).inject(this.node);
  152. this.loadViewConfig();
  153. },
  154. loadViewConfig: function(){
  155. MWF.xDesktop.requireApp("query.QueryManager", "ViewExplorer", function(){
  156. this.viewConfigurator = new MWF.xApplication.query.QueryManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  157. this.viewConfigurator.app = this;
  158. this.viewConfigurator.load();
  159. }.bind(this));
  160. },
  161. statConfig: function(){
  162. this.clearContent();
  163. this.statConfiguratorContent = new Element("div", {
  164. "styles": this.css.rightContentNode
  165. }).inject(this.node);
  166. this.loadStatConfig();
  167. },
  168. loadStatConfig: function(){
  169. MWF.xDesktop.requireApp("query.QueryManager", "StatExplorer", function(){
  170. this.statConfigurator = new MWF.xApplication.query.QueryManager.StatExplorer(this.statConfiguratorContent, this.restActions);
  171. this.statConfigurator.app = this;
  172. this.statConfigurator.load();
  173. }.bind(this));
  174. },
  175. revealConfig: function(){
  176. this.clearContent();
  177. this.revealConfiguratorContent = new Element("div", {
  178. "styles": this.css.rightContentNode
  179. }).inject(this.node);
  180. this.loadRevealConfig();
  181. },
  182. loadRevealConfig: function(){
  183. MWF.xDesktop.requireApp("query.QueryManager", "RevealExplorer", function(){
  184. this.revealConfigurator = new MWF.xApplication.query.QueryManager.RevealExplorer(this.revealConfiguratorContent, this.restActions);
  185. this.revealConfigurator.app = this;
  186. this.revealConfigurator.load();
  187. }.bind(this));
  188. },
  189. tableConfig: function(){
  190. this.clearContent();
  191. this.tableConfiguratorContent = new Element("div", {
  192. "styles": this.css.rightContentNode
  193. }).inject(this.node);
  194. this.loadTableConfig();
  195. },
  196. loadTableConfig: function(){
  197. MWF.xDesktop.requireApp("query.QueryManager", "TableExplorer", function(){
  198. this.tableConfigurator = new MWF.xApplication.query.QueryManager.TableExplorer(this.tableConfiguratorContent, this.restActions);
  199. this.tableConfigurator.app = this;
  200. this.tableConfigurator.load();
  201. }.bind(this));
  202. },
  203. statementConfig: function(){
  204. this.clearContent();
  205. this.statementConfiguratorContent = new Element("div", {
  206. "styles": this.css.rightContentNode
  207. }).inject(this.node);
  208. this.loadStatementConfig();
  209. },
  210. loadStatementConfig: function(){
  211. MWF.xDesktop.requireApp("query.QueryManager", "StatementExplorer", function(){
  212. this.statementConfigurator = new MWF.xApplication.query.QueryManager.StatementExplorer(this.statementConfiguratorContent, this.restActions);
  213. this.statementConfigurator.app = this;
  214. this.statementConfigurator.load();
  215. }.bind(this));
  216. },
  217. importerConfig: function(){
  218. this.clearContent();
  219. this.importerConfiguratorContent = new Element("div", {
  220. "styles": this.css.rightContentNode
  221. }).inject(this.node);
  222. this.loadImporterConfig();
  223. },
  224. loadImporterConfig: function(){
  225. MWF.xDesktop.requireApp("query.QueryManager", "ImporterExplorer", function(){
  226. this.importerConfigurator = new MWF.xApplication.query.QueryManager.ImporterExplorer(this.importerConfiguratorContent, this.restActions);
  227. this.importerConfigurator.app = this;
  228. this.importerConfigurator.load();
  229. }.bind(this));
  230. }
  231. });
  232. MWF.xApplication.query.QueryManager.Menu = new Class({
  233. Extends: MWF.xApplication.process.ProcessManager.Menu,
  234. Implements: [Options, Events]
  235. });
  236. MWF.xApplication.query.QueryManager.QueryProperty = new Class({
  237. Extends: MWF.xApplication.process.ProcessManager.ApplicationProperty,
  238. load: function(){
  239. this.app.restActions.getApplication(this.app.options.application.id, function(json){
  240. this.data = json.data;
  241. this.propertyTitleBar = new Element("div", {
  242. "styles": this.app.css.propertyTitleBar,
  243. "text": this.data.name
  244. }).inject(this.node);
  245. this.contentNode = new Element("div", {
  246. "styles": this.app.css.propertyContentNode
  247. }).inject(this.node);
  248. this.contentAreaNode = new Element("div", {
  249. "styles": this.app.css.propertyContentAreaNode
  250. }).inject(this.contentNode);
  251. this.setContentHeight();
  252. this.setContentHeightFun = this.setContentHeight.bind(this);
  253. this.app.addEvent("resize", this.setContentHeightFun);
  254. MWF.require("MWF.widget.ScrollBar", function(){
  255. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  256. }.bind(this));
  257. this.baseActionAreaNode = new Element("div", {
  258. "styles": this.app.css.baseActionAreaNode
  259. }).inject(this.contentAreaNode);
  260. this.baseActionNode = new Element("div", {
  261. "styles": this.app.css.propertyInforActionNode
  262. }).inject(this.baseActionAreaNode);
  263. this.baseTextNode = new Element("div", {
  264. "styles": this.app.css.baseTextNode,
  265. "text": this.app.lp.application.property
  266. }).inject(this.baseActionAreaNode);
  267. this.createEditBaseNode();
  268. this.createPropertyContentNode();
  269. this.createInterfaceNode();
  270. this.createIconContentNode();
  271. this.createAvailableNode();
  272. this.createControllerListNode();
  273. }.bind(this));
  274. },
  275. createInterfaceNode: function(){
  276. this.interfaceAreaNode = new Element("div", {
  277. "styles": this.app.css.baseActionAreaNode
  278. }).inject(this.contentAreaNode);
  279. this.interfaceAreaNode.setStyle("clear","both");
  280. this.interfaceActionNode = new Element("div", {
  281. "styles": this.app.css.propertyInforActionNode
  282. }).inject(this.interfaceAreaNode);
  283. this.interfaceTextNode = new Element("div", {
  284. "styles": this.app.css.baseTextNode,
  285. "text": this.app.lp.interfaceConfig
  286. }).inject(this.interfaceAreaNode);
  287. this.interfaceContentNode = new Element("div", {"styles": {
  288. "overflow": "hidden",
  289. "-webkit-user-select": "text",
  290. "-moz-user-select": "text"
  291. }}).inject(this.contentAreaNode);
  292. var lp = this.app.lp;
  293. this.interfaceData = this.data.data ? JSON.parse(this.data.data) : "";
  294. var data = this.interfaceData || {
  295. viewShow: "true",
  296. viewNumber: 1,
  297. viewName: lp.viewName,
  298. statShow: "true",
  299. statNumber: 2,
  300. statName: lp.statName,
  301. statementShow: "true",
  302. statementNumber: 3,
  303. statementName: lp.statementName,
  304. importerShow: "true",
  305. importerNumber: 4,
  306. importerName: lp.importerName
  307. };
  308. // var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  309. // var inputTextStyle = "float:right; width:120px; border:1px solid #ccc";
  310. var html = "<table cellspacing='0' cellpadding='0' border='0' align='left' style='margin-top: 20px;padding-left: 15%;width: 72%;'>";
  311. html += "<tr class='title'>" +
  312. "<td class='formTitle' style='width:150px'>"+lp.naviCategory+"</td>" +
  313. "<td class='formTitle' style='width:200px'>"+lp.isShow+"</td> " +
  314. "<td class='formTitle' style='width: calc( 100% - 360px )'>"+lp.showText+"</td></tr>";
  315. var view = { index : data.viewNumber };
  316. view.html = "<tr class='view'>" +
  317. "<td class='formContent'><div class='sort'>↑</div>"+lp.viewName+"</td> " +
  318. "<td item='viewShow' class='formContent'></td> " +
  319. "<td item='viewName' class='formContent' style='padding:3px 0px;'></td></tr>";
  320. var stat = { index : data.statNumber };
  321. stat.html = "<tr class='stat'><td class='formContent'><div class='sort'>↑</div>"+lp.statName+"</td>" +
  322. "<td item='statShow' class='formContent'></td>" +
  323. "<td item='statName' class='formContent' style='padding:3px 0px;'></td></tr>";
  324. var statement = { index : data.statementNumber };
  325. statement.html = "<tr class='statement'>" +
  326. "<td class='formContent'><div class='sort'>↑</div>"+lp.statementName+"</td>" +
  327. "<td item='statementShow' class='formContent'></td> " +
  328. "<td item='statementName' class='formContent' style='padding:3px 0px;'></td></tr>";
  329. var importer = {index : data.importerNumber};
  330. importer.html = "<tr class='importer'>" +
  331. "<td class='formContent'><div class='sort'>↑</div>"+lp.importerName+"</td> " +
  332. "<td item='importerShow' class='formContent'></td> " +
  333. "<td item='importerName' class='formContent' style='padding:3px 0px;'></td></tr>";
  334. var array = [view,stat,statement,importer];
  335. array.sort(function(a, b){
  336. return a.index - b.index;
  337. });
  338. array.each(function(a){
  339. html += a.html;
  340. });
  341. html += "</table>";
  342. this.interfaceContentNode.set("html", html);
  343. this.interfaceSortActions = this.interfaceContentNode.getElements("div.sort");
  344. this.interfaceSortActions.setStyles({
  345. "cursor":"pointer", "width":"20px", "font-size": "16px", "text-align":"center", "display": "none"
  346. }).set("title", lp.moveUp).addEvent("click", function(ev){
  347. var tr = ev.target.getParent("tr");
  348. var trBefore = tr.getPrevious("tr");
  349. if( !trBefore.hasClass("title") ){
  350. tr.inject(trBefore, "before");
  351. }
  352. var trs = tr.getParent("table").getElements("tr[class!='title']");
  353. trs.each(function(tr, i){
  354. this.interfaceForm.data[0][tr.get("class")+"Number"] = i+1;
  355. }.bind(this))
  356. }.bind(this));
  357. this.interfaceContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyInterfaceTdTitle);
  358. this.interfaceContentNode.getElements("td.formContent").setStyles(this.app.css.propertyInterfaceTdContent);
  359. MWF.xDesktop.requireApp("Template", "MForm", function () {
  360. this.interfaceForm = new MForm(this.interfaceContentNode, data, {
  361. isEdited: false,
  362. style : "appproperty",
  363. itemTemplate: {
  364. viewShow: { type:"radio", selectValue : ["true","false"], selectText: [lp.show, lp.hide], style: {"display":"inline"} },
  365. statShow: { type:"radio", selectValue : ["true","false"], selectText: [lp.show, lp.hide], style: {"display":"inline"} },
  366. statementShow: { type:"radio", selectValue : ["true","false"], selectText: [lp.show, lp.hide], style: {"display":"inline"} },
  367. importerShow: { type:"radio", selectValue : ["true","false"], selectText: [lp.show, lp.hide], style: {"display":"inline"} },
  368. statName: { event: {
  369. focus: function(node){ node.setStyles(this.app.css.input_focus) }.bind(this),
  370. blur: function(node){ node.setStyles(this.app.css.input) }.bind(this)
  371. }
  372. },
  373. viewName: { event: {
  374. focus: function(node){ node.setStyles(this.app.css.input_focus) }.bind(this),
  375. blur: function(node){ node.setStyles(this.app.css.input) }.bind(this)
  376. }
  377. },
  378. statementName: { event: {
  379. focus: function(node){ node.setStyles(this.app.css.input_focus) }.bind(this),
  380. blur: function(node){ node.setStyles(this.app.css.input) }.bind(this)
  381. }
  382. },
  383. importerName: { event: {
  384. focus: function(node){ node.setStyles(this.app.css.input_focus) }.bind(this),
  385. blur: function(node){ node.setStyles(this.app.css.input) }.bind(this)
  386. }
  387. }
  388. }
  389. }, this);
  390. debugger;
  391. this.interfaceForm.load();
  392. }.bind(this), true);
  393. },
  394. createPropertyContentNode: function(){
  395. this.propertyContentNode = new Element("div", {"styles": {
  396. "overflow": "hidden",
  397. "-webkit-user-select": "text",
  398. "-moz-user-select": "text"
  399. }}).inject(this.contentAreaNode);
  400. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  401. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  402. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  403. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  404. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  405. // html += "<tr><td class='formTitle'>"+this.app.lp.application.firstPage+"</td><td id='formApplicationFirstPage'></td></tr>";
  406. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  407. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  408. html += "</table>";
  409. this.propertyContentNode.set("html", html);
  410. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  411. this.nameInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  412. this.aliasInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  413. this.descriptionInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  414. //2019年11月15日--ji 接口是queryCategory字段
  415. //this.typeInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  416. this.typeInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.queryCategory, this.app.css.formInput);
  417. // this.firstPageInput = new MWF.xApplication.query.QueryManager.Select(this.propertyContentNode.getElement("#formApplicationFirstPage"), this.data.firstPage, this.app.css.formInput, function(){
  418. // var pages = {};
  419. // debugger;
  420. // this.app.restActions.listPage(this.app.options.application.id, function(json){
  421. // json.data.each(function(page) {
  422. // pages[page.id] = page.name;
  423. // }.bind(this));
  424. // }.bind(this), null, false);
  425. // return pages;
  426. // }.bind(this));
  427. this.idInput = new MWF.xApplication.query.QueryManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  428. },
  429. editMode: function(){
  430. this.nameInput.editMode();
  431. this.aliasInput.editMode();
  432. this.descriptionInput.editMode();
  433. this.typeInput.editMode();
  434. //this.firstPageInput.editMode();
  435. if(this.interfaceForm)this.interfaceForm.changeMode();
  436. if(this.interfaceSortActions)this.interfaceSortActions.setStyle("display","inline-block");
  437. this.isEdit = true;
  438. },
  439. readMode: function(){
  440. this.nameInput.readMode();
  441. this.aliasInput.readMode();
  442. this.descriptionInput.readMode();
  443. this.typeInput.readMode();
  444. //this.firstPageInput.readMode();
  445. if(this.interfaceForm)this.interfaceForm.changeMode( this.interfaceSaved );
  446. if(this.interfaceSortActions)this.interfaceSortActions.setStyle("display","none");
  447. this.interfaceSaved = false;
  448. this.isEdit = false;
  449. },
  450. save: function(callback, cancel) {
  451. this.data.name = this.nameInput.input.get("value");
  452. this.data.alias = this.aliasInput.input.get("value");
  453. this.data.description = this.descriptionInput.input.get("value");
  454. //2019年11月15日--ji 接口是queryCategory字段
  455. //this.data.applicationCategory = this.typeInput.input.get("value");
  456. this.data.queryCategory = this.typeInput.input.get("value");
  457. //this.data.firstPage = this.firstPageInput.input.get("value");
  458. if(this.interfaceForm){
  459. this.interfaceData = this.interfaceForm.getResult(true, ",", true, false, true );
  460. this.data.data = JSON.stringify(this.interfaceData);
  461. }
  462. this.interfaceSaved = true;
  463. this.app.restActions.saveApplication(this.data, function (json) {
  464. this.propertyTitleBar.set("text", this.data.name);
  465. this.data.id = json.data.id;
  466. this.nameInput.save();
  467. this.aliasInput.save();
  468. this.descriptionInput.save();
  469. this.typeInput.save();
  470. //this.firstPageInput.save();
  471. if (callback) callback();
  472. }.bind(this), function (xhr, text, error) {
  473. if (cancel) cancel(xhr, text, error);
  474. }.bind(this));
  475. }
  476. });
  477. MWF.xApplication.query.QueryManager.Input = new Class({
  478. Extends: MWF.xApplication.process.ProcessManager.Input,
  479. Implements: [Events]
  480. });
  481. MWF.xApplication.query.QueryManager.Select = new Class({
  482. Extends: MWF.xApplication.process.ProcessManager.Input,
  483. Implements: [Events],
  484. initialize: function(node, value, style, select){
  485. this.node = $(node);
  486. this.value = (value) ? value: "";
  487. this.style = style;
  488. this.select = select;
  489. this.selectList = null;;
  490. this.load();
  491. },
  492. getSelectList: function(){
  493. if (this.select){
  494. return this.select();
  495. }
  496. return [];
  497. },
  498. getText: function(value){
  499. if (value){
  500. if (this.selectList){
  501. return this.selectList[value] || "";
  502. }
  503. }
  504. return "";
  505. },
  506. load: function(){
  507. this.selectList = this.getSelectList();
  508. this.content = new Element("div", {
  509. "styles": this.style.content,
  510. "text": this.getText(this.value)
  511. }).inject(this.node);
  512. },
  513. editMode: function(){
  514. this.content.empty();
  515. this.input = new Element("select",{
  516. //"styles": this.style.input,
  517. //"value": this.value
  518. }).inject(this.content);
  519. Object.each(this.selectList, function(v, k){
  520. new Element("option", {
  521. "value": k,
  522. "text": v,
  523. "selected": (this.value==v)
  524. }).inject(this.input);
  525. }.bind(this));
  526. //this.input.addEvents({
  527. // //"focus": function(){
  528. // // this.input.setStyles(this.style.input_focus);
  529. // //}.bind(this),
  530. // //"blur": function(){
  531. // // this.input.setStyles(this.style.input);
  532. // //}.bind(this),
  533. // //"change": function(){
  534. // // this.input.setStyles(this.style.input);
  535. // //}.bind(this)
  536. //});
  537. },
  538. readMode: function(){
  539. this.content.empty();
  540. this.input = null;
  541. this.content.set("text", this.getText(this.value));
  542. },
  543. save: function(){
  544. if (this.input) this.value = this.input.options[this.input.selectedIndex].get("value");
  545. return this.value;
  546. }
  547. });