NewProject.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. focus:function(){
  50. this.newProjectContainer.setStyles({"border":"1px solid #4A90E2"});
  51. }.bind(this),
  52. blur:function(){
  53. this.newProjectContainer.setStyles({"border":"1px solid #A6A6A6"});
  54. }.bind(this)
  55. });
  56. this.newProjectDesContainer = new Element("div.newProjectDesContainer",{styles:this.css.newProjectDesContainer}).inject(this.formTableArea);
  57. this.newProjectDesIn = new Element("textarea.newProjectDesIn",{styles:this.css.newProjectDesIn,placeholder:this.lp.description}).inject(this.newProjectDesContainer);
  58. this.newProjectDesIn.addEvents({
  59. focus:function(){ //32px
  60. var v = this.newProjectDesIn.get("value");
  61. if(v.trim()==""){
  62. this.newProjectDesIn.setStyle("line-height","");
  63. var _h = 36;
  64. this.newProjectDesContainer.setStyles({"height":(this.newProjectDesContainer.getHeight()+_h)+"px"});
  65. this.newProjectDesIn.setStyles({"height":(this.newProjectDesIn.getHeight()+_h-2)+"px"});
  66. this.formAreaNode.setStyles({"height":(this.formAreaNode.getHeight()+_h)+"px"});
  67. this.formNode.setStyles({"height":(this.formNode.getHeight()+_h)+"px"});
  68. this.formTableContainer.setStyles({"height":(this.formTableContainer.getHeight()+_h)+"px"});
  69. this.formTableArea.setStyles({"height":(this.formTableArea.getHeight()+_h)+"px"});
  70. this.formContentNode.setStyles({"height":(this.formContentNode.getHeight()+_h)+"px"});
  71. var pre = this.formTableContainer.getPrevious();
  72. if(pre){
  73. pre.destroy();
  74. }
  75. }
  76. this.newProjectDesContainer.setStyles({"border":"1px solid #4A90E2"});
  77. }.bind(this),
  78. blur:function(){
  79. var v = this.newProjectDesIn.get("value");
  80. if(v.trim()==""){
  81. this.newProjectDesIn.setStyle("line-height","32px");
  82. var _h = 36;
  83. this.newProjectDesContainer.setStyles({"height":(this.newProjectDesContainer.getHeight()-_h)+"px"});
  84. this.newProjectDesIn.setStyles({"height":(this.newProjectDesIn.getHeight()-_h-2)+"px"});
  85. this.formAreaNode.setStyles({"height":(this.formAreaNode.getHeight()-_h)+"px"});
  86. this.formNode.setStyles({"height":(this.formNode.getHeight()-_h)+"px"});
  87. this.formTableContainer.setStyles({"height":(this.formTableContainer.getHeight()-_h)+"px"});
  88. this.formTableArea.setStyles({"height":(this.formTableArea.getHeight()-_h)+"px"});
  89. this.formContentNode.setStyles({"height":(this.formContentNode.getHeight()-_h)+"px"});
  90. var pre = this.formTableContainer.getPrevious();
  91. if(pre){
  92. pre.destroy();
  93. }
  94. }
  95. this.newProjectDesContainer.setStyles({"border":"1px solid #A6A6A6"});
  96. }.bind(this)
  97. });
  98. this.newProjectGroupText = new Element("div.newProjectGroupText",{styles:this.css.newProjectGroupText,text:this.lp.group}).inject(this.formTableArea);
  99. this.newProjectGroupContainer = new Element("div.newProjectGroupContainer",{styles:this.css.newProjectGroupContainer}).inject(this.formTableArea);
  100. this.newProjectGroupValue = new Element("div.newProjectGroupValue",{styles:this.css.newProjectGroupValue,text:""}).inject(this.newProjectGroupContainer);
  101. this.newProjectGroupArrow = new Element("div.newProjectGroupArrow",{styles:this.css.newProjectGroupArrow}).inject(this.newProjectGroupContainer);
  102. this.newProjectGroupContainer.addEvents({
  103. click:function(){
  104. var node = this.newProjectGroupContainer;
  105. var data = {groups:this.selectGroup};
  106. //alert(JSON.stringify(this.selectGroup))
  107. MWF.xDesktop.requireApp("TeamWork", "GroupSelect", function(){
  108. var gs = new MWF.xApplication.TeamWork.GroupSelect(this.container, node, this.app, data, {
  109. axis : "y",
  110. nodeStyles : {
  111. "z-index" : "102"
  112. },
  113. onClose:function(d){
  114. this.newProjectGroupContainer.setStyles({"border":"1px solid #A6A6A6"});
  115. if(!d) return;
  116. this.refreshGroup(function(){
  117. var res = [];
  118. d.each(function(dd){
  119. this.groupSearch(dd,function(json){
  120. if(json) res.push(json);
  121. }.bind(this));
  122. }.bind(this));
  123. this.selectGroup = res;
  124. var resVal = [];
  125. res.each(function(dd){
  126. resVal.push(dd.name);
  127. }.bind(this));
  128. this.newProjectGroupValue.set("text",resVal.join(","));
  129. }.bind(this));
  130. }.bind(this)
  131. });
  132. gs.load()
  133. }.bind(this));
  134. this.newProjectGroupContainer.setStyles({"border":"1px solid #4A90E2"});
  135. }.bind(this)
  136. });
  137. this.newProjectAdd = new Element("div.newProjectAdd",{styles:this.css.newProjectAdd,text:this.lp.add}).inject(this.formTableArea);
  138. this.newProjectAdd.addEvents({
  139. click:function(){
  140. var v = this.newProjectIn.get("value").trim();
  141. var des = this.newProjectDesIn.get("value");
  142. if(v=="") return;
  143. var groups = [];
  144. if(this.selectGroup){
  145. this.selectGroup.each(function(d){
  146. groups.push(d.id);
  147. });
  148. }
  149. var data = {
  150. "title":v,
  151. "description":des,
  152. "groups":groups
  153. };
  154. //this.actions.projectSave(data,function(json){
  155. this.rootActions.ProjectAction.save(data,function(json){
  156. this.close(json);
  157. }.bind(this));
  158. }.bind(this)
  159. });
  160. },
  161. groupSearch:function(id,callback){
  162. var res = null;
  163. this.allGroupList.each(function(d){
  164. if(d.id == id) res = d;
  165. }.bind(this));
  166. if(callback)callback(res);
  167. },
  168. refreshGroup:function(callback){
  169. //this.actions.groupList(function(json){
  170. this.rootActions.ProjectGroupAction.listGroups(function(json){
  171. this.allGroupList = json.data;
  172. if(callback)callback();
  173. }.bind(this))
  174. }
  175. });