Stat.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. isEmpty: function(){
  39. var data = this.getData();
  40. debugger;
  41. if( typeOf(data) !== "array" )return true;
  42. if( data.length === 0 )return true;
  43. return false;
  44. },
  45. getData: function(){
  46. if (!this.stat) return null;
  47. if (!this.stat.stat) return null;
  48. return this.stat.stat.data;
  49. }
  50. });