TaskList.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. MWF.xDesktop.requireApp("process.TaskCenter", "List", null, false);
  2. MWF.xApplication.process.TaskCenter.TaskList = new Class({
  3. Extends: MWF.xApplication.process.TaskCenter.List,
  4. _getFilterCount: function(callback){
  5. this.app.action.listTaskFilterCount(function(json){
  6. if (callback) callback(json);
  7. });
  8. },
  9. createAppFilterNodes: function(){
  10. var allApp = {"name": this.app.lp.all, "application": "", "count": 0};
  11. this.allAppFilterNode = this.createAppFilterNode(allApp, "appFilterNode_current");
  12. this.currentFilterNode = this.allAppFilterNode;
  13. this.filterListNode = new Element("div", {"styles": this.css.filterListNode}).inject(this.applicationFilterAreaNode);
  14. },
  15. createFilterItemNode: function(key, v){
  16. var _self = this;
  17. var node = new Element("div", {"styles": this.css.filterListItemNode}).inject(this.filterListNode);
  18. var actionNode = new Element("div", {"styles": this.css.filterListItemActionNode}).inject(node);
  19. var textNode = new Element("div", {"styles": this.css.filterListItemTextNode}).inject(node);
  20. textNode.set("text", this.app.lp[key]+": "+ v.name);
  21. actionNode.store("key", key);
  22. node.addEvents({
  23. "mouseover": function(){
  24. this.setStyles(_self.css.filterListItemNode_over);
  25. this.getLast().setStyles(_self.css.filterListItemTextNode_over);
  26. this.getFirst().setStyles(_self.css.filterListItemActionNode_over);
  27. },
  28. "mouseout": function(){
  29. this.setStyles(_self.css.filterListItemNode);
  30. this.getLast().setStyles(_self.css.filterListItemTextNode);
  31. this.getFirst().setStyles(_self.css.filterListItemActionNode);
  32. }
  33. });
  34. actionNode.addEvent("click", function(){
  35. var key = this.retrieve("key");
  36. if (_self.filterData[key]) _self.filterData[key] = null;
  37. delete _self.filterData[key];
  38. this.destroy();
  39. _self.refilter();
  40. });
  41. },
  42. _getCurrentPageData: function(callback, count){
  43. this.app.getAction(function(){
  44. if (this.filterData){
  45. this.filterListNode.empty();
  46. var data = {};
  47. Object.each(this.filterData, function(v, key){
  48. if (key!=="key"){
  49. if (v) {
  50. //data[this.app.options.filterMap[key]] = v.value;
  51. if (!data[this.app.options.filterMap[key]]) data[this.app.options.filterMap[key]] = [];
  52. data[this.app.options.filterMap[key]].push(v.value);
  53. this.createFilterItemNode(key, v);
  54. }
  55. }else{
  56. data.key = v;
  57. }
  58. }.bind(this));
  59. if (this.filterData.key){
  60. this.createFilterItemNode("key", {"name": this.filterData.key});
  61. }
  62. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  63. this.app.action.listTaskFilter(function(json){
  64. if (callback) callback(json);
  65. }, null, id, count || this.pageCount, data);
  66. }else{
  67. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  68. this.app.action.listTaskNext(function(json){
  69. if (callback) callback(json);
  70. }, null, id, count || this.pageCount);
  71. }
  72. }.bind(this));
  73. }
  74. });
  75. MWF.xApplication.process.TaskCenter.TaskList.Item = new Class({
  76. Extends: MWF.xApplication.process.TaskCenter.List.Item
  77. });