StatementSelector.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xDesktop.requireApp("process.Xform", "ViewSelector", null, false);
  3. MWF.xApplication.process.Xform.StatementSelector = MWF.APPStatementSelector = new Class({
  4. Implements: [Events],
  5. Extends: MWF.xApplication.process.Xform.ViewSelector,
  6. selectView: function(callback){
  7. var viewData = this.json.queryStatement;
  8. if (viewData){
  9. var filter = null;
  10. if (this.json.filterList && this.json.filterList.length){
  11. filter = [];
  12. this.json.filterList.each(function(entry){
  13. entry.value = this.form.Macro.exec(entry.code.code, this);
  14. //delete entry.code;
  15. filter.push(entry);
  16. }.bind(this));
  17. }
  18. var viewJson = {
  19. "application": viewData.appName,
  20. "statementName": viewData.name,
  21. "viewId": viewData.id,
  22. "isTitle": this.json.isTitle || "yes",
  23. "select": this.json.select || "single",
  24. "titleStyles": this.json.titleStyles,
  25. "itemStyles": this.json.itemStyles,
  26. "isExpand": this.json.isExpand || "no",
  27. "showActionbar" : this.json.actionbar === "show",
  28. "filter": filter,
  29. "defaultSelectedScript" : this.json.defaultSelectedScript ? this.json.defaultSelectedScript.code : null
  30. };
  31. var options = {};
  32. var width = options.width || "850";
  33. var height = options.height || "700";
  34. if (layout.mobile){
  35. var size = document.body.getSize();
  36. width = size.x;
  37. height = size.y;
  38. options.style = "viewmobile";
  39. }
  40. width = width.toInt();
  41. height = height.toInt();
  42. var size = this.form.app.content.getSize();
  43. var x = (size.x-width)/2;
  44. var y = (size.y-height)/2;
  45. if (x<0) x = 0;
  46. if (y<0) y = 0;
  47. if (layout.mobile){
  48. x = 20;
  49. y = 0;
  50. }
  51. var _self = this;
  52. MWF.require("MWF.xDesktop.Dialog", function(){
  53. var dlg = new MWF.xDesktop.Dialog({
  54. "title": this.json.title || "select view",
  55. "style": options.style || "view",
  56. "top": y,
  57. "left": x-20,
  58. "fromTop":y,
  59. "fromLeft": x-20,
  60. "width": width,
  61. "height": height,
  62. "html": "",
  63. "maskNode": layout.mobile?$(document.body) : this.form.app.content,
  64. "container": layout.mobile?$(document.body) : this.form.app.content,
  65. "buttonList": [
  66. {
  67. "text": MWF.LP.process.button.ok,
  68. "action": function(){
  69. //if (callback) callback(_self.view.selectedItems);
  70. if (callback) callback(_self.view.getData());
  71. this.close();
  72. }
  73. },
  74. {
  75. "text": MWF.LP.process.button.cancel,
  76. "action": function(){this.close();}
  77. }
  78. ],
  79. "onPostShow": function(){
  80. if(layout.mobile){
  81. dlg.node.setStyle("z-index",200);
  82. }
  83. MWF.xDesktop.requireApp("query.Query", "Statement", function(){
  84. this.view = new MWF.xApplication.query.Query.Statement(dlg.content, viewJson, {"style": "select"}, this.form.app, this.form.Macro );
  85. }.bind(this));
  86. }.bind(this)
  87. });
  88. dlg.show();
  89. if (layout.mobile){
  90. var backAction = dlg.node.getElement(".MWF_dialod_Action_back");
  91. var okAction = dlg.node.getElement(".MWF_dialod_Action_ok");
  92. if (backAction) backAction.addEvent("click", function(e){
  93. dlg.close();
  94. }.bind(this));
  95. if (okAction) okAction.addEvent("click", function(e){
  96. //if (callback) callback(this.view.selectedItems);
  97. if (callback) callback(this.view.getData());
  98. dlg.close();
  99. }.bind(this));
  100. }
  101. // MWF.xDesktop.requireApp("process.Xform", "widget.View", function(){
  102. // this.view = new MWF.xApplication.process.Xform.widget.View(dlg.content.getFirst(), viewJson, {"style": "select"});
  103. // }.bind(this));
  104. // MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  105. // this.view = new MWF.xApplication.query.Query.Viewer(dlg.content, viewJson, {"style": "select"});
  106. // }.bind(this));
  107. }.bind(this));
  108. }
  109. }
  110. });