Stat.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. var viewJson = {
  23. "application": this.json.queryStat.appName,
  24. "statName": this.json.queryStat.name,
  25. "isChart": (this.json.isChart!="no"),
  26. "isLegend": (this.json.isLegend!="no"),
  27. "isTable": (this.json.isTable!="no")
  28. };
  29. MWF.xDesktop.requireApp("query.Query", "Statistician", function(){
  30. this.stat = new MWF.xApplication.query.Query.Statistician(this.form.app, this.node, viewJson, {
  31. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  32. "onLoaded": function(){
  33. this.fireEvent("loadStat");
  34. }.bind(this)
  35. });
  36. }.bind(this));
  37. },
  38. getData: function(){
  39. if (!this.stat) return null;
  40. if (!this.stat.stat) return null;
  41. return this.stat.stat.data;
  42. }
  43. });