Statement.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. //MWF.xDesktop.requireApp("process.Xform", "widget.View", null, false);
  3. MWF.xApplication.process.Xform.Statement = MWF.APPStatement = new Class({
  4. Extends: MWF.APP$Module,
  5. options: {
  6. "moduleEvents": ["load", "loadView", "queryLoad", "postLoad", "select", "openDocument"]
  7. },
  8. _loadUserInterface: function(){
  9. MWF.xDesktop.requireApp("query.Query", "Statement", null, false);
  10. this.node.empty();
  11. },
  12. _afterLoaded: function(){
  13. if (this.json.queryStatement){
  14. this.loadView();
  15. }
  16. },
  17. reload: function(){
  18. if (this.view){
  19. if (this.view.loadViewRes) if (this.view.loadViewRes.isRunning()) this.view.loadViewRes.cancel();
  20. if (this.view.getViewRes) if (this.view.getViewRes.isRunning()) this.view.getViewRes.cancel();
  21. }
  22. this.node.empty();
  23. this.loadView();
  24. },
  25. active: function(){
  26. if (this.view){
  27. if (!this.view.loadingAreaNode) this.view.loadView();
  28. }else{
  29. this.loadView();
  30. }
  31. },
  32. loadView: function(){
  33. if (!this.json.queryStatement) return "";
  34. var filter = null;
  35. if (this.json.filterList && this.json.filterList.length){
  36. filter = [];
  37. this.json.filterList.each(function(entry){
  38. entry.value = this.form.Macro.exec(entry.code.code, this);
  39. //delete entry.code;
  40. filter.push(entry);
  41. }.bind(this));
  42. }
  43. debugger;
  44. //var data = JSON.parse(this.json.data);
  45. var viewJson = {
  46. "application": (this.json.queryStatement) ? this.json.queryStatement.appName : this.json.application,
  47. "statementName": (this.json.queryStatement) ? this.json.queryStatement.name : this.json.statementName,
  48. "isTitle": this.json.isTitle || "yes",
  49. "select": this.json.select || "none",
  50. "titleStyles": this.json.titleStyles,
  51. "itemStyles": this.json.itemStyles,
  52. "isExpand": this.json.isExpand || "no",
  53. "showActionbar" : this.json.actionbar === "show",
  54. "filter": filter,
  55. "defaultSelectedScript" : this.json.defaultSelectedScript ? this.json.defaultSelectedScript.code : null
  56. };
  57. //MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  58. this.view = new MWF.xApplication.query.Query.Statement(this.node, viewJson, {
  59. "isload": (this.json.loadView!=="no"),
  60. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  61. "onLoadView": function(){
  62. this.fireEvent("loadView");
  63. }.bind(this),
  64. "onSelect": function(){
  65. this.fireEvent("select");
  66. }.bind(this),
  67. "onOpenDocument": function(options, item){
  68. this.openOptions = {
  69. "options": options,
  70. "item": item
  71. };
  72. this.fireEvent("openDocument");
  73. this.openOptions = null;
  74. }.bind(this)
  75. }, this.form.app, this.form.Macro);
  76. //}.bind(this));
  77. },
  78. getData: function(){
  79. if (this.view.selectedItems.length){
  80. var arr = [];
  81. this.view.selectedItems.each(function(item){
  82. arr.push(item.data);
  83. });
  84. return arr;
  85. }else{
  86. return [];
  87. }
  88. }
  89. });