ProcessSelector.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. MWF.xDesktop.requireApp("process.ProcessManager", "ProcessExplorer",null,false);
  2. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector",null,false);
  3. MWF.xApplication.process.ProcessManager.widget = MWF.xApplication.process.ProcessManager.widget || {};
  4. MWF.xApplication.process.ProcessManager.widget.ProcessSelector = new Class({
  5. Implements: [Options, Events],
  6. Extends: MWF.xApplication.process.ProcessManager.widget.ApplicationSelector,
  7. options: {
  8. "style": "default",
  9. "multi": true,
  10. "maskNode": $(document.body)
  11. },
  12. initialize: function(app, options){
  13. this.setOptions(options);
  14. //this.node = $(node);
  15. this.app = app;
  16. this.processes = [];
  17. this.path = "../x_component_process_ProcessManager/widget/$ProcessSelector/";
  18. this.cssPath = "../x_component_process_ProcessManager/widget/$ProcessSelector/"+this.options.style+"/css.wcss";
  19. this._loadCss();
  20. this.selectedItems = [];
  21. },
  22. load: function(ids, callback){
  23. this.applicationIds = ids;
  24. this.callback = callback || null;
  25. this.loadWindow();
  26. this.loadContent();
  27. },
  28. loadContent: function(){
  29. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  30. if (!this.restActions) this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  31. this.applicationIds.each(function(id){
  32. this.restActions.listProcess(id, function(json){
  33. json.data.each(function(data){
  34. var process = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector.Process(this.app, this, data);
  35. process.load();
  36. this.processes.push(process);
  37. }.bind(this));
  38. }.bind(this));
  39. }.bind(this));
  40. //}.bind(this));
  41. },
  42. clearSelected: function(){
  43. this.processes.each(function(pro){
  44. if (pro.selected) pro.unSelectedItem();
  45. }.bind(this));
  46. },
  47. close: function(){
  48. //if (this.callback) this.callback();
  49. this.selectedItems = [];
  50. this.windowNode.destroy();
  51. this.options.maskNode.unmask();
  52. }
  53. });
  54. MWF.xApplication.process.ProcessManager.widget.ProcessSelector.Process = new Class({
  55. Extends: MWF.xApplication.process.ProcessManager.ProcessExplorer.Process,
  56. Implements: [Options, Events],
  57. initialize: function(app, selector, data, options){
  58. this.explorer = selector;
  59. this.data = data;
  60. this.container = selector.windowContentNode;
  61. this.css = selector.css;
  62. this.icon = this._getIcon();
  63. },
  64. load: function(){
  65. this.createNode();
  66. this.createIconNode();
  67. this.loadSelectIcon();
  68. this.createTextNodes();
  69. },
  70. createNode: function(){
  71. this.node = new Element("div", {
  72. "styles": this.css.itemNode,
  73. "events": {
  74. "click": function(e){
  75. this.selected();
  76. e.stopPropagation();
  77. }.bind(this)
  78. }
  79. }).inject(this.container);
  80. },
  81. createIconNode: function(){
  82. if (this.data.name.icon) this.icon = this.data.name.icon;
  83. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  84. var itemIconNode = new Element("div", {
  85. "styles": this.css.itemIconNode
  86. }).inject(this.node);
  87. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  88. },
  89. loadSelectIcon: function(){
  90. this.selectIconNode = new Element("div", {
  91. "styles": this.css.processItemSelectIcon
  92. }).inject(this.node);
  93. },
  94. _open: function(e){},
  95. selected: function(){
  96. if (!this.isSelected){
  97. if (!this.explorer.options.multi) this.explorer.clearSelected();
  98. this.selectedItem();
  99. }else{
  100. this.unSelectedItem();
  101. }
  102. },
  103. selectedItem: function(){
  104. this.selectIconNode.setStyles(this.css.processItemSelectIcon_selected);
  105. this.node.setStyles(this.css.itemNode_select);
  106. this.explorer.selectedItems.push(this.data);
  107. this.isSelected = true;
  108. },
  109. unSelectedItem: function(){
  110. this.selectIconNode.setStyles(this.css.processItemSelectIcon);
  111. this.node.setStyles(this.css.itemNode);
  112. this.explorer.selectedItems.erase(this.data);
  113. this.isSelected = false;
  114. }
  115. });