Statement.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 && this.view.loadViewRes.res) if (this.view.loadViewRes.res.isRunning()) this.view.loadViewRes.res.cancel();
  20. if (this.view.getViewRes && this.view.getViewRes.res) if (this.view.getViewRes.res.isRunning()) this.view.getViewRes.res.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. //var data = JSON.parse(this.json.data);
  44. var viewJson = {
  45. "application": (this.json.queryStatement) ? this.json.queryStatement.appName : this.json.application,
  46. "statementName": (this.json.queryStatement) ? this.json.queryStatement.name : this.json.statementName,
  47. "statementId": (this.json.queryStatement) ? this.json.queryStatement.id : this.json.statementId,
  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. "selectedAbleScript" : this.json.selectedAbleScript ? this.json.selectedAbleScript.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. });