Statement.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. "statementId": (this.json.queryStatement) ? this.json.queryStatement.id : this.json.statementId,
  49. "isTitle": this.json.isTitle || "yes",
  50. "select": this.json.select || "none",
  51. "titleStyles": this.json.titleStyles,
  52. "itemStyles": this.json.itemStyles,
  53. "isExpand": this.json.isExpand || "no",
  54. "showActionbar" : this.json.actionbar === "show",
  55. "filter": filter,
  56. "defaultSelectedScript" : this.json.defaultSelectedScript ? this.json.defaultSelectedScript.code : null
  57. };
  58. //MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  59. this.view = new MWF.xApplication.query.Query.Statement(this.node, viewJson, {
  60. "isload": (this.json.loadView!=="no"),
  61. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  62. "onLoadView": function(){
  63. this.fireEvent("loadView");
  64. }.bind(this),
  65. "onSelect": function(){
  66. this.fireEvent("select");
  67. }.bind(this),
  68. "onOpenDocument": function(options, item){
  69. this.openOptions = {
  70. "options": options,
  71. "item": item
  72. };
  73. this.fireEvent("openDocument");
  74. this.openOptions = null;
  75. }.bind(this)
  76. }, this.form.app, this.form.Macro);
  77. //}.bind(this));
  78. },
  79. getData: function(){
  80. if (this.view.selectedItems.length){
  81. var arr = [];
  82. this.view.selectedItems.each(function(item){
  83. arr.push(item.data);
  84. });
  85. return arr;
  86. }else{
  87. return [];
  88. }
  89. }
  90. });