Stat.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. //MWF.xDesktop.requireApp("process.Xform", "widget.View", null, false);
  3. MWF.xApplication.process.Xform.Stat = MWF.APPStat = new Class({
  4. Extends: MWF.APP$Module,
  5. options: {
  6. "moduleEvents": ["load", "queryLoad", "postLoad", "loadStat"]
  7. },
  8. _loadUserInterface: function(){
  9. this.node.empty();
  10. },
  11. _afterLoaded: function(){
  12. this.node.setStyle("min-height", "100px");
  13. this.loadStat();
  14. },
  15. active: function(){
  16. if (this.stat) this.stat.loadStatData();
  17. },
  18. reload: function(){
  19. this.active();
  20. },
  21. loadStat: function(){
  22. if (this.json.queryStat){
  23. var viewJson = {
  24. "application": this.json.queryStat.appName,
  25. "statName": this.json.queryStat.name,
  26. "isChart": (this.json.isChart!="no"),
  27. "isLegend": (this.json.isLegend!="no"),
  28. "isTable": (this.json.isTable!="no")
  29. };
  30. MWF.xDesktop.requireApp("query.Query", "Statistician", function(){
  31. this.stat = new MWF.xApplication.query.Query.Statistician(this.form.app, this.node, viewJson, {
  32. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  33. "onLoaded": function(){
  34. this.fireEvent("loadStat");
  35. }.bind(this)
  36. });
  37. }.bind(this));
  38. }
  39. },
  40. getData: function(){
  41. if (!this.stat) return null;
  42. if (!this.stat.stat) return null;
  43. return this.stat.stat.data;
  44. }
  45. });