ProcessSelector.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  31. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  32. this.applicationIds.each(function(id){
  33. this.restActions.listProcess(id, function(json){
  34. json.data.each(function(data){
  35. var process = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector.Process(this.app, this, data);
  36. process.load();
  37. this.processes.push(process);
  38. }.bind(this));
  39. }.bind(this));
  40. }.bind(this));
  41. //}.bind(this));
  42. },
  43. clearSelected: function(){
  44. this.processes.each(function(pro){
  45. if (pro.selected) pro.unSelectedItem();
  46. }.bind(this));
  47. },
  48. close: function(){
  49. //if (this.callback) this.callback();
  50. this.selectedItems = [];
  51. this.windowNode.destroy();
  52. this.options.maskNode.unmask();
  53. }
  54. });
  55. MWF.xApplication.process.ProcessManager.widget.ProcessSelector.Process = new Class({
  56. Extends: MWF.xApplication.process.ProcessManager.ProcessExplorer.Process,
  57. Implements: [Options, Events],
  58. initialize: function(app, selector, data, options){
  59. this.explorer = selector;
  60. this.data = data;
  61. this.container = selector.windowContentNode;
  62. this.css = selector.css;
  63. this.icon = this._getIcon();
  64. },
  65. load: function(){
  66. this.createNode();
  67. this.createIconNode();
  68. this.loadSelectIcon();
  69. this.createTextNodes();
  70. },
  71. createNode: function(){
  72. this.node = new Element("div", {
  73. "styles": this.css.itemNode,
  74. "events": {
  75. "click": function(e){
  76. this.selected();
  77. e.stopPropagation();
  78. }.bind(this)
  79. }
  80. }).inject(this.container);
  81. },
  82. createIconNode: function(){
  83. if (this.data.name.icon) this.icon = this.data.name.icon;
  84. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  85. var itemIconNode = new Element("div", {
  86. "styles": this.css.itemIconNode
  87. }).inject(this.node);
  88. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  89. },
  90. loadSelectIcon: function(){
  91. this.selectIconNode = new Element("div", {
  92. "styles": this.css.processItemSelectIcon
  93. }).inject(this.node);
  94. },
  95. _open: function(e){},
  96. selected: function(){
  97. if (!this.isSelected){
  98. if (!this.explorer.options.multi) this.explorer.clearSelected();
  99. this.selectedItem();
  100. }else{
  101. this.unSelectedItem();
  102. }
  103. },
  104. selectedItem: function(){
  105. this.selectIconNode.setStyles(this.css.processItemSelectIcon_selected);
  106. this.node.setStyles(this.css.itemNode_select);
  107. this.explorer.selectedItems.push(this.data);
  108. this.isSelected = true;
  109. },
  110. unSelectedItem: function(){
  111. this.selectIconNode.setStyles(this.css.processItemSelectIcon);
  112. this.node.setStyles(this.css.itemNode);
  113. this.explorer.selectedItems.erase(this.data);
  114. this.isSelected = false;
  115. }
  116. });