NewProject.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. MWF.xApplication.TeamWork = MWF.xApplication.TeamWork || {};
  2. MWF.xApplication.TeamWork.NewProject = new Class({
  3. Extends: MWF.xApplication.TeamWork.Common.Popup,
  4. options:{
  5. "closeByClickMask" : false
  6. },
  7. open: function (e) {
  8. //设置css 和 lp等
  9. var css = this.css;
  10. this.cssPath = "/x_component_TeamWork/$NewProject/"+this.options.style+"/css.wcss";
  11. this._loadCss();
  12. if(css) this.css = Object.merge( css, this.css );
  13. this.lp = this.app.lp.newProject;
  14. this.fireEvent("queryOpen");
  15. this.isNew = false;
  16. this.isEdited = false;
  17. this._open();
  18. this.fireEvent("postOpen");
  19. },
  20. _createTableContent: function () {
  21. //var a = new Element("div.aaa",{styles:{"width":"100px","height":"100px","background-color":"#f00"},text:"f分分分f分分f分分分f分分分"}).inject(this.formTableArea);
  22. // alert(JSON.stringify(this.css.projectAdd))
  23. // alert(JSON.stringify(this.lp))
  24. this.newProjectTop = new Element("div.newProjectTop",{styles:this.css.newProjectTop}).inject(this.formTableArea);
  25. this.newProjectTopText = new Element("div.newProjectTopText",{styles:this.css.newProjectTopText,text:this.lp.title}).inject(this.newProjectTop);
  26. this.newProjectTopClose = new Element("div.newProjectTopClose",{styles:this.css.newProjectTopClose}).inject(this.newProjectTop);
  27. this.newProjectTopClose.addEvents({
  28. click:function(){this.close()}.bind(this)
  29. });
  30. this.newProjectContainer = new Element("div.newProjectInContainer",{styles:this.css.newProjectContainer}).inject(this.formTableArea);
  31. this.newProjectIn = new Element("input.newProjectIn",{styles:this.css.newProjectIn,type:"text",placeholder:this.lp.name}).inject(this.newProjectContainer);
  32. this.newProjectIn.addEvents({
  33. keyup:function(){
  34. var v = this.newProjectIn.get("value");
  35. if(v.trim()==""){
  36. this.newProjectAdd.setStyles({
  37. "cursor":"",
  38. "background-color":"#F0F0F0",
  39. "color":"#666666"
  40. })
  41. }else{
  42. this.newProjectAdd.setStyles({
  43. "cursor":"pointer",
  44. "background-color":"#4A90E2",
  45. "color":"#FFFFFF"
  46. })
  47. }
  48. }.bind(this)
  49. });
  50. this.newProjectDesContainer = new Element("div.newProjectDesContainer",{styles:this.css.newProjectDesContainer}).inject(this.formTableArea);
  51. this.newProjectDesIn = new Element("textarea.newProjectDesIn",{styles:this.css.newProjectDesIn,placeholder:this.lp.description}).inject(this.newProjectDesContainer);
  52. this.newProjectDesIn.addEvents({
  53. focus:function(){ //32px
  54. var v = this.newProjectDesIn.get("value");
  55. if(v.trim()==""){
  56. this.newProjectDesIn.setStyle("line-height","");
  57. var _h = 36;
  58. this.newProjectDesContainer.setStyles({"height":(this.newProjectDesContainer.getHeight()+_h)+"px"});
  59. this.newProjectDesIn.setStyles({"height":(this.newProjectDesIn.getHeight()+_h-2)+"px"});
  60. this.formAreaNode.setStyles({"height":(this.formAreaNode.getHeight()+_h)+"px"});
  61. this.formNode.setStyles({"height":(this.formNode.getHeight()+_h)+"px"});
  62. this.formTableContainer.setStyles({"height":(this.formTableContainer.getHeight()+_h)+"px"});
  63. this.formTableArea.setStyles({"height":(this.formTableArea.getHeight()+_h)+"px"});
  64. this.formContentNode.setStyles({"height":(this.formContentNode.getHeight()+_h)+"px"});
  65. var pre = this.formTableContainer.getPrevious();
  66. if(pre){
  67. pre.destroy();
  68. }
  69. }
  70. }.bind(this),
  71. blur:function(){
  72. var v = this.newProjectDesIn.get("value");
  73. if(v.trim()==""){
  74. this.newProjectDesIn.setStyle("line-height","32px");
  75. var _h = 36;
  76. this.newProjectDesContainer.setStyles({"height":(this.newProjectDesContainer.getHeight()-_h)+"px"});
  77. this.newProjectDesIn.setStyles({"height":(this.newProjectDesIn.getHeight()-_h-2)+"px"});
  78. this.formAreaNode.setStyles({"height":(this.formAreaNode.getHeight()-_h)+"px"});
  79. this.formNode.setStyles({"height":(this.formNode.getHeight()-_h)+"px"});
  80. this.formTableContainer.setStyles({"height":(this.formTableContainer.getHeight()-_h)+"px"});
  81. this.formTableArea.setStyles({"height":(this.formTableArea.getHeight()-_h)+"px"});
  82. this.formContentNode.setStyles({"height":(this.formContentNode.getHeight()-_h)+"px"});
  83. var pre = this.formTableContainer.getPrevious();
  84. if(pre){
  85. pre.destroy();
  86. }
  87. }
  88. }.bind(this)
  89. });
  90. this.newProjectGroupText = new Element("div.newProjectGroupText",{styles:this.css.newProjectGroupText,text:this.lp.group}).inject(this.formTableArea);
  91. this.newProjectGroupContainer = new Element("div.newProjectGroupContainer",{styles:this.css.newProjectGroupContainer}).inject(this.formTableArea);
  92. this.newProjectGroupValue = new Element("div.newProjectGroupValue",{styles:this.css.newProjectGroupValue,text:""}).inject(this.newProjectGroupContainer);
  93. this.newProjectGroupArrow = new Element("div.newProjectGroupArrow",{styles:this.css.newProjectGroupArrow}).inject(this.newProjectGroupContainer);
  94. this.newProjectGroupContainer.addEvents({
  95. click:function(){
  96. var node = this.newProjectGroupContainer;
  97. var data = {groups:this.selectGroup};
  98. //alert(JSON.stringify(this.selectGroup))
  99. MWF.xDesktop.requireApp("TeamWork", "GroupSelect", function(){
  100. var gs = new MWF.xApplication.TeamWork.GroupSelect(this.container, node, this.app, data, {
  101. axis : "y",
  102. nodeStyles : {
  103. "z-index" : "102"
  104. },
  105. onClose:function(d){
  106. if(!d) return;
  107. this.refreshGroup(function(){
  108. var res = [];
  109. d.each(function(dd){
  110. this.groupSearch(dd,function(json){
  111. if(json) res.push(json);
  112. }.bind(this))
  113. }.bind(this));
  114. this.selectGroup = res;
  115. var resVal = [];
  116. res.each(function(dd){
  117. resVal.push(dd.name)
  118. }.bind(this));
  119. this.newProjectGroupValue.set("text",resVal.join(","))
  120. }.bind(this));
  121. }.bind(this)
  122. });
  123. gs.load()
  124. }.bind(this));
  125. }.bind(this)
  126. });
  127. this.newProjectAdd = new Element("div.newProjectAdd",{styles:this.css.newProjectAdd,text:this.lp.add}).inject(this.formTableArea);
  128. this.newProjectAdd.addEvents({
  129. click:function(){
  130. var v = this.newProjectIn.get("value").trim();
  131. var des = this.newProjectDesIn.get("value");
  132. if(v=="") return;
  133. var groups = [];
  134. if(this.selectGroup){
  135. this.selectGroup.each(function(d){
  136. groups.push(d.id);
  137. });
  138. }
  139. var data = {
  140. "title":v,
  141. "description":des,
  142. "groups":groups
  143. };
  144. this.actions.projectSave(data,function(json){
  145. this.close(json);
  146. }.bind(this));
  147. }.bind(this)
  148. });
  149. },
  150. groupSearch:function(id,callback){
  151. var res = null;
  152. this.allGroupList.each(function(d){
  153. if(d.id == id) res = d;
  154. }.bind(this));
  155. if(callback)callback(res);
  156. },
  157. refreshGroup:function(callback){
  158. this.actions.groupList(function(json){
  159. this.allGroupList = json.data;
  160. if(callback)callback();
  161. }.bind(this))
  162. }
  163. });