Common.js 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138
  1. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  2. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  3. MWF.require("MWF.widget.O2Identity", null, false);
  4. MWF.xDesktop.requireApp("Selector", "package", null, false);
  5. MWF.require("MWF.widget.AttachmentController",null,false);
  6. MWF.xApplication.Meeting = MWF.xApplication.Meeting || {};
  7. MWF.xApplication.Meeting.BuildingForm = new Class({
  8. Extends: MPopupForm,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "meeting",
  12. "width": "800",
  13. "height": "300",
  14. "hasTop": true,
  15. "hasIcon": false,
  16. "hasTopIcon" : false,
  17. "hasTopContent" : false,
  18. "hasBottom": false,
  19. "draggable": true,
  20. "closeAction": true
  21. },
  22. _createTableContent: function () {
  23. this.formTopTextNode.set( "text", this.lp.editBuilding );
  24. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  25. "<tr><td styles='formTableTitle' lable='name'></td>" +
  26. " <td styles='formTableValue' item='name' colspan='3' ></td></tr>" +
  27. "<tr><td styles='formTableTitle' lable='address'></td>" +
  28. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  29. "<tr><td styles='formTableTitle'></td>" +
  30. " <td styles='formTableValue' colspan='3' style='padding-top: 30px;'>"+
  31. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  32. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  33. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew ) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  34. " </td></tr>" +
  35. "</table>";
  36. this.formTableArea.set("html", html);
  37. MWF.xDesktop.requireApp("Template", "MForm", function () {
  38. this.form = new MForm(this.formTableArea, this.data, {
  39. isEdited: this.isEdited || this.isNew,
  40. style : "meeting",
  41. itemTemplate: {
  42. name: { text : this.lp.name, notEmpty : true },
  43. address: { text : this.lp.address },
  44. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  45. click : function(){ this.save();}.bind(this)
  46. } },
  47. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.delete , event : {
  48. click : function( item, ev ){ this.removeBuilding(ev); }.bind(this)
  49. } },
  50. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  51. click : function(){ this.close(); }.bind(this)
  52. } }
  53. }
  54. }, this.app);
  55. this.form.load();
  56. }.bind(this), true);
  57. },
  58. save: function(){
  59. var data = this.form.getResult(true,null,true,false,true);
  60. this.actions.saveBuilding( data, function(json){
  61. this.app.notice(this.lp.save_success, "success");
  62. var view = this.view;
  63. this.close();
  64. view.reload();
  65. }.bind(this));
  66. },
  67. removeBuilding: function(e) {
  68. var info = this.app.lp.delete_building;
  69. info = info.replace(/{name}/g, this.data.name);
  70. var _self = this;
  71. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  72. _self.remove();
  73. this.close();
  74. }, function(){
  75. this.close();
  76. });
  77. },
  78. remove: function(){
  79. var view = this.view;
  80. this.app.actions.deleteBuilding(this.data.id, function(){
  81. view.reload();
  82. }.bind(this));
  83. }
  84. });
  85. MWF.xApplication.Meeting.BuildingTooltip = new Class({
  86. Extends: MTooltips,
  87. _loadCustom : function( callback ){
  88. this.loadActionBar();
  89. if(callback)callback();
  90. },
  91. _getHtml : function(){
  92. var data = this.data;
  93. var html =
  94. "<div item='containr' style='height:16px;line-height:16px;'><div style='font-size: 14px;color:#666;float:left; '>"+ (data.address ? data.address : this.lp.noAddress) +"</div></div>";
  95. return html;
  96. },
  97. loadActionBar : function(){
  98. if( MWF.AC.isMeetingAdministrator() ){
  99. //this.actionBar = new Element("div", {
  100. // "styles": this.css.actionBar
  101. //}).inject(this.node);
  102. var container = this.node.getElement("[item='containr']");
  103. this.editAction = new Element("div", {
  104. styles: this.css.action_edit,
  105. title : this.lp.editAddress,
  106. events : {
  107. mouseover : function(){
  108. this.editAction.setStyles( this.css.action_edit_over );
  109. }.bind(this),
  110. mouseout : function(){
  111. this.editAction.setStyles( this.css.action_edit );
  112. }.bind(this),
  113. click : function(){
  114. this.editBuilding()
  115. }.bind(this)
  116. }
  117. }).inject(container);
  118. this.removeAction = new Element("div", {
  119. styles: this.css.action_remove,
  120. title: this.lp.removeBuilding,
  121. events : {
  122. mouseover : function(){
  123. this.removeAction.setStyles( this.css.action_remove_over );
  124. }.bind(this),
  125. mouseout : function(){
  126. this.removeAction.setStyles( this.css.action_remove );
  127. }.bind(this),
  128. click : function( e ){
  129. this.removeBuilding(e);
  130. }.bind(this)
  131. }
  132. }).inject(container);
  133. }
  134. },
  135. editBuilding : function(){
  136. var form = new MWF.xApplication.Meeting.BuildingForm(this,this.data, {}, {app:this.app});
  137. form.edit();
  138. },
  139. removeBuilding: function(e) {
  140. this.app.actions.getBuilding( this.data.id, function( json ){
  141. if( json.data.roomList && json.data.roomList.length > 0 ){
  142. this.app.notice( this.app.lp.delete_building_hasRoom.replace(/{name}/g, this.data.name),"error", e.target );
  143. }else{
  144. var info = this.app.lp.delete_building;
  145. info = info.replace(/{name}/g, this.data.name);
  146. var _self = this;
  147. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  148. _self.remove();
  149. this.close();
  150. }, function(){
  151. this.close();
  152. });
  153. }
  154. }.bind(this));
  155. },
  156. remove: function(){
  157. var view = this.view;
  158. this.app.actions.deleteBuilding(this.data.id, function(){
  159. view.reload();
  160. }.bind(this));
  161. },
  162. reload : function(){
  163. this.view.reload();
  164. }
  165. });
  166. MWF.xApplication.Meeting.RoomForm = new Class({
  167. Extends: MPopupForm,
  168. Implements: [Options, Events],
  169. options: {
  170. "style": "meeting",
  171. "width": "900",
  172. "height": "500",
  173. "hasTop": true,
  174. "hasIcon": false,
  175. "hasTopIcon" : false,
  176. "hasTopContent" : false,
  177. "hasBottom": false,
  178. "draggable": true,
  179. "closeAction": true
  180. },
  181. _createTableContent: function () {
  182. if( this.isNew ){
  183. this.formTopTextNode.set( "text", this.lp.addRoom );
  184. }else if( this.isEdited ){
  185. this.formTopTextNode.set( "text", this.lp.editRoom );
  186. //this.options.height = "550";
  187. }else{
  188. this.formTopTextNode.set( "text", this.lp.room );
  189. //this.options.height = "460";
  190. }
  191. var lp = this.lp.roomForm;
  192. var editEnable = ( !this.isEdited && !this.isNew && MWF.AC.isMeetingAdministrator() );
  193. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  194. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  195. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  196. "<tr><td styles='formTableTitle'>"+ lp.name+":</td>" +
  197. " <td styles='formTableValue' item='name' colspan='3' ></td></tr>" +
  198. "<tr><td styles='formTableTitle'>"+ lp.building +":</td>" +
  199. " <td styles='formTableValue' item='buildingName' colspan='3'></td></tr>" +
  200. "<tr><td styles='formTableTitle'>"+ lp.floor +":</td>" +
  201. " <td styles='formTableValue' item='floor'></td>"+
  202. " <td styles='formTableTitle2'>"+ lp.capacity +":</td>" +
  203. " <td styles='formTableValue' item='capacity'></td></tr>" +
  204. "<tr><td styles='formTableTitle'>"+lp.roomNumber+":</td>" +
  205. " <td styles='formTableValue' item='roomNumber'></td>" +
  206. " <td styles='formTableTitle2'>"+lp.phone+":</td>" +
  207. " <td styles='formTableValue' item='phoneNumber'></td></tr>" +
  208. "<tr><td styles='formTableTitle'>"+lp.device+":</td>" +
  209. " <td styles='formTableValue' colspan='3'>" +
  210. " <div item='deviceList' style='"+ boxStyle +"'></div>" +
  211. "</td></tr>" +
  212. "<tr><td styles='formTableTitle'>"+lp.available+":</td>" +
  213. " <td styles='formTableValue' colspan='3'>" +
  214. " <div item='available' style='"+ boxStyle +"'></div>" +
  215. "</td></tr>" +
  216. "<tr><td styles='formTableTitle'></td>" +
  217. " <td styles='formTableValue' colspan='3' style='padding-top: 30px;'>"+
  218. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  219. " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  220. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  221. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  222. " </td></tr>" +
  223. "</table>";
  224. this.formTableArea.set("html", html);
  225. var data = this.data || {};
  226. this.buildingId = data.building;
  227. if( this.buildingId ){
  228. this.getBuliding()
  229. }
  230. MWF.xDesktop.requireApp("Template", "MForm", function () {
  231. this.form = new MForm(this.formTableArea, data, {
  232. isEdited: this.isEdited || this.isNew,
  233. style : "meeting",
  234. itemTemplate: {
  235. name: { text : lp.name, notEmpty : true },
  236. buildingName: {
  237. text : lp.building, notEmpty : true,
  238. value : this.buildingName || "",
  239. event : {
  240. "click": function(){this.listBuilding();}.bind(this),
  241. //"blur": function(){}.bind(this),
  242. "change": function(){ this.buildingId = null; }.bind(this),
  243. "keydown": function(e){
  244. //if ([13,40,38].indexOf(e.code)!=-1){
  245. // if (!this.selectBuildingNode){
  246. // this.listBuilding();
  247. // }
  248. //}
  249. if (e.code==13){
  250. this.listBuildingHide();
  251. this.listBuilding();
  252. }
  253. if (e.code==40) this.selectBuildingNext();
  254. if (e.code==38) this.selectBuildingPrev();
  255. if (e.code==32) this.selectBuildingConfirm(e);
  256. }.bind(this)
  257. }
  258. },
  259. floor: { type: "select", defaultValue: "1", notEmpty : true, text : lp.floor,
  260. selectText : function(){
  261. var floors = [];
  262. for (var i=-2; i<=50; i++){
  263. if( i != 0 )floors.push(i+ this.lp.floor )
  264. }
  265. return floors;
  266. }.bind(this), selectValue : function(){
  267. var floors = [];
  268. for (var i=-2; i<=50; i++){
  269. if( i != 0 )floors.push(i)
  270. }
  271. return floors;
  272. }.bind(this)
  273. },
  274. capacity: { notEmpty : true, tType: "number", text : lp.capacity },
  275. roomNumber: {},
  276. phoneNumber: {},
  277. deviceList: { type : "checkbox",
  278. value : this.data.device ? this.data.device.split("#") : "",
  279. selectValue : function(){ return Object.keys(this.lp.device); }.bind(this),
  280. selectText : function(){ return Object.values(this.lp.device); }.bind(this)
  281. },
  282. available: { type : "radio", defaultValue : "true",
  283. selectValue : [ "true", "false" ],
  284. selectText : [ this.lp.enable, this.lp.disable ]
  285. },
  286. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  287. click : function(){ this.save();}.bind(this)
  288. } },
  289. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.delete , event : {
  290. click : function( item, ev ){ this.removeRoom(ev); }.bind(this)
  291. } },
  292. editAction : { type : "button", className : "inputOkButton", value : this.lp.editRoom , event : {
  293. click : function(){ this.editRoom(); }.bind(this)
  294. } },
  295. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  296. click : function(){ this.close(); }.bind(this)
  297. } }
  298. }
  299. }, this.app);
  300. this.form.load();
  301. }.bind(this), true);
  302. },
  303. editRoom : function(){
  304. this.formTopNode = null;
  305. if(this.setFormNodeSizeFun && this.app ){
  306. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  307. }
  308. if( this.formMaskNode )this.formMaskNode.destroy();
  309. this.formAreaNode.destroy();
  310. this.edit();
  311. },
  312. getBuliding : function(){
  313. this.actions.getBuilding( this.buildingId, function(json){
  314. this.buildingName = json.data.name
  315. }.bind(this), null, false )
  316. },
  317. reset: function(){
  318. this.formTableArea.empty();
  319. this._createTableContent();
  320. },
  321. removeRoom: function(e) {
  322. var info = this.app.lp.delete_room;
  323. info = info.replace(/{name}/g, this.data.name);
  324. var _self = this;
  325. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  326. _self.remove();
  327. this.close();
  328. }, function(){
  329. this.close();
  330. });
  331. },
  332. remove: function(){
  333. var view = this.view;
  334. this.app.actions.deleteRoom(this.data.id, function(){
  335. view.reload();
  336. }.bind(this));
  337. },
  338. selectBuildingNext: function(){
  339. if (this.selectBuildingNode){
  340. var node=null;
  341. if (this.selectBuildingNode.selectedNode){
  342. var node = this.selectBuildingNode.selectedNode.getNext();
  343. if (!node) node = this.selectBuildingNode.getFirst();
  344. this.selectBuildingNode.selectedNode.setStyle("background-color", this.selectBuildingNode.selectedNode.retrieve("bg"));
  345. }else{
  346. node = this.selectBuildingNode.getFirst();
  347. }
  348. if (node){
  349. var color = node.getStyle("background-color");
  350. node.store("bg", color);
  351. node.setStyles(this.css.createRoomBuildingSelectItem_over);
  352. this.selectBuildingNode.selectedNode = node;
  353. }
  354. }
  355. },
  356. selectBuildingPrev: function(){
  357. if (this.selectBuildingNode){
  358. var node = null;
  359. if (this.selectBuildingNode.selectedNode){
  360. var node = this.selectBuildingNode.selectedNode.getPrevious();
  361. if (!node) node = this.selectBuildingNode.getLast();
  362. this.selectBuildingNode.selectedNode.setStyle("background-color", this.selectBuildingNode.selectedNode.retrieve("bg"));
  363. }else{
  364. node = this.selectBuildingNode.getLast();
  365. }
  366. if (node){
  367. var color = node.getStyle("background-color");
  368. node.store("bg", color);
  369. node.setStyles(this.css.createRoomBuildingSelectItem_over);
  370. this.selectBuildingNode.selectedNode = node;
  371. }
  372. }
  373. },
  374. selectBuildingConfirm: function(e){
  375. if (this.selectBuildingNode.selectedNode){
  376. this.selectBuilding(this.selectBuildingNode.selectedNode);
  377. e.preventDefault();
  378. }
  379. },
  380. //cancelCreateRoom: function(){
  381. // this.createRoomNode.destroy();
  382. //},
  383. listBuilding: function(){
  384. var item = this.form.getItem("buildingName");
  385. var key = item.getValue();
  386. this.actions.listBuildingByKey(key, function(json){
  387. if (json.data && json.data.length){
  388. this.selectBuildingNode = new Element("div", {"styles": this.css.createRoomSelectBuildingNode}).inject(item.container);
  389. this.setSelectBuildingNodeSize();
  390. this.listBuildingHideFun = this.listBuildingHide.bind(this);
  391. this.formMaskNode.addEvent("mousedown", this.listBuildingHideFun);
  392. this.formNode.addEvent("mousedown", this.listBuildingHideFun);
  393. var _self = this;
  394. json.data.each(function(building, idx){
  395. var node = new Element("div", {"styles": this.css.createRoomBuildingSelectItem}).inject(this.selectBuildingNode);
  396. var nameNode = new Element("div", {"styles": this.css.createRoomBuildingSelectItemName, "text": building.name}).inject(node);
  397. var addrNode = new Element("div", {"styles": this.css.createRoomBuildingSelectItemAddr, "text": building.address}).inject(node);
  398. if ((idx % 2)==1) node.setStyle("background-color", "#f1f6ff");
  399. node.store("building", building.id);
  400. node.addEvents({
  401. "mouseover": function(e){
  402. var color = this.getStyle("background-color");
  403. this.store("bg", color);
  404. this.setStyles(_self.css.createRoomBuildingSelectItem_over);
  405. },
  406. "mouseout": function(e){
  407. this.setStyle("background-color", this.retrieve("bg"));
  408. },
  409. "mousedown": function(e){e.stopPropagation();},
  410. "click": function(e){
  411. _self.selectBuilding(this);
  412. }
  413. });
  414. }.bind(this));
  415. }
  416. }.bind(this));
  417. },
  418. selectBuilding: function(node){
  419. var id = node.retrieve("building");
  420. var text = node.getFirst().get("text");
  421. this.form.getItem("buildingName").setValue(text);
  422. this.buildingId = id;
  423. this.listBuildingHide();
  424. },
  425. setSelectBuildingNodeSize: function(){
  426. var buildingInput = this.form.getItem("buildingName").getElements()[0];
  427. //var p = buildingInput.getPosition(buildingInput.getOffsetParent());
  428. this.selectBuildingNode.position({
  429. relativeTo: buildingInput,
  430. position: 'bottomLeft',
  431. edge: 'upperCenter',
  432. offset: {x: 4, y: 0}
  433. });
  434. //this.selectBuildingNode.setStyle("left", p.x);
  435. var size = buildingInput.getSize();
  436. var w = size.x-8;
  437. this.selectBuildingNode.setStyle("width", ""+w+"px");
  438. },
  439. listBuildingHide: function(){
  440. if (this.selectBuildingNode){
  441. //this.removeEvent("resize", this.setSelectBuildingNodeSizeFun);
  442. this.selectBuildingNode.destroy();
  443. this.selectBuildingNode = null;
  444. this.formMaskNode.removeEvent("mousedown", this.listBuildingHideFun);
  445. this.formNode.removeEvent("mousedown", this.listBuildingHideFun);
  446. }
  447. },
  448. save: function(){
  449. this.getData(function(data){
  450. this.actions.saveRoom(data, function(json){
  451. this.app.notice(this.lp.roomForm.save_success, "success");
  452. var view = this.view;
  453. this.close();
  454. view.reload();
  455. }.bind(this));
  456. }.bind(this));
  457. },
  458. getData: function(callback){
  459. var data = this.form.getResult(true,null,true,false,true);
  460. if( !data )return;
  461. data.device = data.deviceList.join("#");
  462. data.available = data.available == "true";
  463. if (!this.buildingId){
  464. this.actions.saveBuilding({"name": data.buildingName, "address": ""}, function(json){
  465. data.building = json.data.id;
  466. if (callback) callback(data);
  467. }.bind(this));
  468. }else{
  469. data.building = this.buildingId;
  470. if (callback) callback(data);
  471. }
  472. }
  473. });
  474. MWF.xApplication.Meeting.RoomTooltip = new Class({
  475. Extends: MTooltips,
  476. _loadCustom : function( callback ){
  477. this.loadBuilding( function(){
  478. if(callback)callback();
  479. }.bind(this) );
  480. },
  481. _getHtml : function(){
  482. var data = this.data;
  483. var lp = this.lp.device;
  484. var titleStyle = "font-size:14px;color:#333";
  485. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  486. var device = [];
  487. data.device.split("#").each( function( d ){
  488. device.push( lp[d] );
  489. }.bind(this));
  490. lp = this.lp.roomForm;
  491. var html =
  492. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  493. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.room +"</div>"+
  494. "</div>"+
  495. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;'>"+ data.name +"</div>"+
  496. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  497. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  498. "<tr><td style='"+titleStyle+"' width='100'>"+ lp.building+":</td>" +
  499. " <td style='"+valueStyle+"' item='building'></td></tr>" +
  500. "<tr><td style='"+titleStyle+"'>" + lp.floor+":</td>" +
  501. " <td style='"+valueStyle+"'>" + data.floor + "</td></tr>" +
  502. "<tr><td style='"+titleStyle+"'>"+ lp.capacity +":</td>" +
  503. " <td style='"+valueStyle+"'>"+ data.capacity+"</td></tr>" +
  504. "<tr><td style='"+titleStyle+"'>"+ lp.roomNumber +":</td>" +
  505. " <td style='"+valueStyle+"'>"+ data.roomNumber+"</td></tr>" +
  506. "<tr><td style='"+titleStyle+"'>"+ lp.phone+":</td>" +
  507. " <td style='"+valueStyle+"'>"+ data.phoneNumber +"</td></tr>" +
  508. "<tr><td style='"+titleStyle+"'>"+ lp.device +":</td>" +
  509. " <td style='"+valueStyle+"'>"+ device.join( "," ) +"</td></tr>"+
  510. "<tr><td style='"+titleStyle+"'>"+ lp.available +":</td>" +
  511. " <td style='"+valueStyle+"'>" + ( !data.available ? this.lp.disable : this.lp.enable ) + "</td></tr>"+
  512. "</table>";
  513. return html;
  514. },
  515. loadBuilding: function( callback ){
  516. var area = this.node.getElement("[item='building']");
  517. if (this.data.building){
  518. this.app.actions.getBuilding(this.data.building, function(bjson){
  519. area.set("text", bjson.data.name );
  520. if( callback )callback();
  521. }.bind(this));
  522. }
  523. }
  524. });
  525. MWF.xApplication.Meeting.MeetingForm = new Class({
  526. Extends: MPopupForm,
  527. Implements: [Options, Events],
  528. options: {
  529. "style": "meeting",
  530. "width": "900",
  531. "height": "640",
  532. "hasTop": true,
  533. "hasIcon": false,
  534. "hasTopIcon" : false,
  535. "hasTopContent" : false,
  536. "hasBottom": false,
  537. "draggable": true,
  538. "closeAction": true
  539. },
  540. open: function (e) {
  541. this.fireEvent("queryOpen");
  542. this.isNew = false;
  543. this.isEdited = false;
  544. this.getMeetingData( function(){
  545. this._open();
  546. }.bind(this));
  547. this.fireEvent("postOpen");
  548. },
  549. create: function () {
  550. this.fireEvent("queryCreate");
  551. this.isNew = true;
  552. this._open();
  553. this.fireEvent("postCreate");
  554. },
  555. edit: function () {
  556. this.fireEvent("queryEdit");
  557. this.isEdited = true;
  558. this.getMeetingData( function(){
  559. this._open();
  560. }.bind(this));
  561. this.fireEvent("postEdit");
  562. },
  563. _createTableContent: function () {
  564. this.userName = layout.desktop.session.user.distinguishedName;
  565. this.userId = layout.desktop.session.user.id;
  566. if( this.isNew ){
  567. this.formTopTextNode.set( "text", this.lp.addMeeting );
  568. }else if( this.isEdited ){
  569. this.formTopTextNode.set( "text", this.lp.editMeeting );
  570. this.options.height = "590";
  571. }else{
  572. this.formTopTextNode.set( "text", this.lp.metting );
  573. this.options.height = "500";
  574. }
  575. var defaultDate, defaultBeginTime, date1, defaultEndTime;
  576. if( this.options.date || this.options.minute ){
  577. this.date = typeOf( this.options.date )=="string" ? Date.parse( this.options.date ) : this.options.date;
  578. defaultDate = this.date.clone().format("%Y-%m-%d");
  579. if( this.date.getHours() ){
  580. defaultBeginTime = this.getString( this.date.getHours() )+":"+ this.getString( this.date.getMinutes() );
  581. date1 = this.date.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  582. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  583. defaultEndTime = this.getString( date1.getHours() )+":"+ this.getString( date1.getMinutes() );
  584. }else{
  585. var now = new Date();
  586. defaultBeginTime = (now.getHours()+1)+":"+"00";
  587. date1 = now.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  588. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  589. defaultEndTime = (date1.getHours()+1)+":"+"00";
  590. }
  591. }else{
  592. this.date = new Date();
  593. defaultDate = this.date.clone().format("%Y-%m-%d");
  594. defaultBeginTime = (this.date.getHours()+1)+":"+"00";
  595. date1 = this.date.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  596. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  597. defaultEndTime = (date1.getHours()+1)+":"+"00";
  598. }
  599. var data = this.data;
  600. var editEnable = ( !this.isEdited && !this.isNew && this.data.status == "wait" && ( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() ) );
  601. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  602. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  603. "<tr>"+
  604. " <td styles='formTableTitle' width='70'>"+this.lp.applyPerson+":</td>" +
  605. " <td styles='formTableValue' item='applicant'></td>" +
  606. "</tr>"+
  607. "<tr><td styles='formTableTitle' width='100'>"+this.lp.beginDate+":</td>" +
  608. " <td styles='formTableValue' item='dateInput'></td>" +
  609. "</tr>" +
  610. "<tr><td styles='formTableTitle'>"+ this.lp.time +":</td>" +
  611. " <td styles='formTableValue'>" +
  612. " <div item='beginTimeInput' style='float:left'></div>"+
  613. " <div style='float:left; "+ ( this.isNew ? "margin:5px;" : "margin:0px 5px;") + "'>"+ this.lp.to+ "</div>"+
  614. " <div item='endTimeInput' style='float:left'></div>"+
  615. " </td></tr>" +
  616. "<tr><td styles='formTableTitle'>"+ this.lp.selectRoom +":</td>" +
  617. " <td styles='formTableValue' item='meetingRoom'></td></tr>" +
  618. "<tr><td styles='formTableTitle'>"+this.lp.invitePerson2+":</td>" +
  619. " <td styles='formTableValue'>" +
  620. " <div item='invitePersonList'></div>" +
  621. " <div style='display:"+ ( this.isEdited ? "" : "none") +";' item='selectinvitePerson'></div>" +
  622. (( !this.isNew && this.data.myWaitAccept ) ?
  623. " <tr><td></td><td styles='formTableValue'><div item='acceptAction'></div><div item='rejectAction'></div></td></tr>" : ""
  624. ) +
  625. " </td>" +
  626. "</tr>" +
  627. "<tr><td styles='formTableTitle'>"+this.lp.meetingSubject+":</td>" +
  628. " <td styles='formTableValue' item='subject'></td></tr>" +
  629. "<tr><td styles='formTableTitle'>"+this.lp.meetingDescription+":</td>" +
  630. " <td styles='formTableValue' item='description'></td></tr>" +
  631. "<tr style='display:none ;' item='attachmentTr'><td styles='formTableTitle'>"+this.lp.meetingAttachment+":</td>" +
  632. " <td styles='formTableValue' item='attachment'></td></tr>" +
  633. "<tr><td styles='formTableTitle'></td>" +
  634. " <td styles='formTableValue' style='padding-top: 10px;'>"+
  635. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  636. " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  637. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  638. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  639. " </td></tr>" +
  640. "</table>";
  641. this.formTableArea.set("html", html);
  642. if( data.startTime ){
  643. var beignDate = Date.parse( data.startTime );
  644. data.dateInput = beignDate.format("%Y-%m-%d");
  645. data.beginTimeInput = this.getString( beignDate.getHours() ) + ":" + this.getString( beignDate.getMinutes() );
  646. }
  647. if( data.completedTime ){
  648. var endDate = Date.parse( data.completedTime );
  649. data.endTimeInput = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  650. }
  651. this.meetingRoomArea = this.formTableArea.getElement("[item='meetingRoom']");
  652. this.attachmentTr = this.formTableArea.getElement("[item='attachmentTr']");
  653. this.attachmentArea = this.formTableArea.getElement("[item='attachment']");
  654. MWF.xDesktop.requireApp("Template", "MForm", function () {
  655. this.form = new MForm(this.formTableArea, data, {
  656. isEdited: this.isEdited || this.isNew,
  657. style : "meeting",
  658. itemTemplate: {
  659. applicant : { type : "org", orgType : "person", isEdited : false,
  660. defaultValue : this.userName
  661. },
  662. dateInput: {tType: "date", isEdited : this.isNew, defaultValue: defaultDate,
  663. event : {
  664. change : function( item, ev ){
  665. this.clearRoom();
  666. }.bind(this)
  667. }
  668. },
  669. beginTimeInput: { tType: "time", isEdited : this.isNew,
  670. defaultValue: defaultBeginTime, className : ( this.isNew ? "inputTimeUnformatWidth" : "" ),
  671. event : {
  672. change : function( item, ev ){
  673. this.clearRoom();
  674. }.bind(this)
  675. }
  676. },
  677. endTimeInput: { tType: "time", isEdited : this.isNew,
  678. defaultValue: defaultEndTime, className : ( this.isNew ? "inputTimeUnformatWidth" : "" ),
  679. event : {
  680. change : function( item, ev ){
  681. this.clearRoom();
  682. }.bind(this)
  683. }
  684. },
  685. invitePersonList: { type: "org", isEdited : this.isNew, orgType: ["identity","person"], count : 0, orgWidgetOptions : {
  686. "onLoadedInfor": function(item){
  687. this.loadAcceptAndReject( item );
  688. }.bind(this)
  689. }},
  690. selectinvitePerson : { type : "button", value : this.lp.addInvitePerson1, style : {"margin-left": "20px"}, event : {
  691. click : function( it ){
  692. var options = {
  693. "type" : "",
  694. "types": ["identity","person"],
  695. "values": [],
  696. "count": 0,
  697. "onComplete": function(items){
  698. MWF.require("MWF.widget.O2Identity", function(){
  699. var invitePersonList = [];
  700. items.each(function(item){
  701. var _self = this;
  702. if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  703. var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  704. invitePersonList.push( item.data.distinguishedName );
  705. }else{
  706. var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  707. invitePersonList.push(item.data.distinguishedName);
  708. }
  709. }.bind(this));
  710. this.app.actions.addMeetingInvite(this.data.id, {"invitePersonList": invitePersonList, "id": this.data.id}, function(json){
  711. this.app.actions.getMeeting(json.data.id, function(meeting){
  712. this.invitePersonList = meeting.data.invitePersonList;
  713. this.app.notice(this.app.lp.addedInvitePerson1, "success", this.node );
  714. }.bind(this));
  715. }.bind(this));
  716. }.bind(this));
  717. }.bind(this)
  718. };
  719. var selector = new MWF.O2Selector(this.app.content, options);
  720. }.bind(this)
  721. } },
  722. subject: {},
  723. description: {type: "textarea"},
  724. acceptAction : { type : "button", value : this.lp.accept, className : "inputAcceptButton",
  725. event : { click : function( it, ev ){ this.accept(ev); }.bind(this) }
  726. },
  727. rejectAction : { type : "button", value : this.lp.reject, style : {"margin-left": "20px"}, className : "inputDenyButton",
  728. event : { click : function( it, ev ){ this.reject(ev) }.bind(this) }
  729. },
  730. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  731. click : function(){ this.save();}.bind(this)
  732. } },
  733. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.cancelMeeting , event : {
  734. click : function( item, ev ){ this.cancelMeeting(ev); }.bind(this)
  735. } },
  736. editAction : { type : "button", className : "inputOkButton", value : this.lp.editMeeting , event : {
  737. click : function(){ this.editMeeting(); }.bind(this)
  738. } },
  739. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  740. click : function(){ this.close(); }.bind(this)
  741. } }
  742. }
  743. }, this.app);
  744. this.form.load();
  745. this.loadSelectRoom();
  746. if( this.data.id )this.loadAttachment();
  747. }.bind(this), true);
  748. },
  749. getString : function( str ){
  750. var s = "00" + str;
  751. return s.substr(s.length - 2, 2 );
  752. },
  753. loadAcceptAndReject : function( item ){
  754. var personName = item.data.distinguishedName;
  755. if(this.data.acceptPersonList){
  756. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  757. var acceptNode = new Element("div", {"styles": this.css.acceptIconNode}).inject(item.node, "top");
  758. new Element("div", {
  759. "styles": this.css.acceptTextNode,
  760. "text": this.app.lp.accepted
  761. }).inject(item.inforNode);
  762. }
  763. }
  764. if(this.data.rejectPersonList){
  765. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  766. var rejectNode = new Element("div", {"styles": this.css.rejectIconNode}).inject(item.node, "top");
  767. new Element("div", {
  768. "styles": this.css.rejectTextNode,
  769. "text": this.app.lp.rejected
  770. }).inject(item.inforNode);
  771. }
  772. }
  773. },
  774. getMeetingData : function( callback ){
  775. if( this.data && this.data.id ){
  776. ( this.app.actions || this.actions ).getMeeting( this.data.id, function( json ){
  777. this.data = json.data;
  778. if(callback)callback();
  779. }.bind(this))
  780. }else{
  781. if(callback)callback();
  782. }
  783. },
  784. editMeeting : function(){
  785. this.formTopNode = null;
  786. if(this.setFormNodeSizeFun && this.app ){
  787. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  788. }
  789. if( this.formMaskNode )this.formMaskNode.destroy();
  790. this.formAreaNode.destroy();
  791. this.edit();
  792. },
  793. cancelMeeting: function(e){
  794. var _self = this;
  795. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  796. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 200, function(){
  797. _self._cancelMeeting();
  798. this.close();
  799. _self.close();
  800. }, function(){
  801. this.close();
  802. });
  803. },
  804. _cancelMeeting: function(){
  805. var view = this.view;
  806. this.app.actions.deleteMeeting(this.data.id, function(){
  807. view.reload();
  808. }.bind(this))
  809. },
  810. reset: function(){
  811. this.formTableArea.empty();
  812. this._createTableContent();
  813. },
  814. clearRoom : function(){
  815. this.roomId = "";
  816. if(this.roomInput)this.roomInput.set("text", "");
  817. },
  818. loadSelectRoom: function(){
  819. var lineNode = new Element("div", {"styles": this.css.createMeetingInfoLineNode}).inject(this.meetingRoomArea);
  820. var editNode = new Element("div", {
  821. "styles": this.css.createMeetingInfoItemEditNode,
  822. "html": "<div></div>"
  823. }).inject(lineNode);
  824. this.roomInput = editNode.getFirst();
  825. this.roomInput.setStyles(this.css.createMeetingInfoItemDivNode);
  826. //var downNode = new Element("div", {"styles": this.css.createMeetingInfoItemDownNode}).inject(editNode);
  827. if( this.isNew ){
  828. this.roomInput.addEvents({
  829. "click": function(e){this.selectRooms();}.bind(this)
  830. });
  831. }
  832. var roomId = this.data.room || this.options.room;
  833. if (roomId){
  834. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  835. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  836. this.roomId = roomId;
  837. this.roomInput.set("text", json.data.name+" ("+bjson.data.name+")");
  838. }.bind(this));
  839. }.bind(this));
  840. }
  841. },
  842. selectRooms: function(){
  843. this.createRoomNode(function(){
  844. this.loadSelectRooms();
  845. this.selectRoomNode.setStyle("display", "block");
  846. this.hideRoomNodeFun = this.hideRoomNode.bind(this);
  847. document.body.addEvent("mousedown", this.hideRoomNodeFun);
  848. //var p = this.selectRoomNode.getPosition(this.selectRoomNode.getOffsetParent());
  849. this.selectRoomNode.position({
  850. relativeTo: this.roomInput,
  851. position: 'bottomLeft',
  852. edge: 'upperLeft',
  853. offset: {x: 0, y: 0}
  854. });
  855. var size = this.roomInput.getSize();
  856. var w = size.x-2;
  857. this.selectRoomNode.setStyle("width", ""+w+"px");
  858. }.bind(this));
  859. },
  860. createRoomNode: function(callback){
  861. if (!this.selectRoomNode){
  862. this.selectRoomNode = new Element("div", {"styles": this.css.createMeetingInfoSelectRoomNode}).inject(this.formNode);
  863. this.selectRoomNode.addEvent("mousedown", function(e){e.stopPropagation();});
  864. if (callback) callback();
  865. }else{
  866. if (callback) callback();
  867. }
  868. },
  869. loadSelectRooms: function(){
  870. var result = this.form.getResult(false,null,false,false,true);
  871. var d = result.dateInput;
  872. var bt = result.beginTimeInput;
  873. var et = result.endTimeInput;
  874. var start = d+" "+bt;
  875. var completed = d+" "+et;
  876. this.app.actions.listBuildingByRange(start, completed, function(json){
  877. json.data.each(function(building){
  878. var node = new Element("div", {"styles": this.css.createMeetingInfoSelectRoomItem1Node}).inject(this.selectRoomNode);
  879. var nodeName = new Element("div", {"styles": this.css.createMeetingInfoSelectRoomItem1NameNode, "text": building.name}).inject(node);
  880. var nodeAddr = new Element("div", {"styles": this.css.createMeetingInfoSelectRoomItem1AddrNode, "text": building.address}).inject(node);
  881. building.roomList.each(function(room, i){
  882. if (room.available && room.idle) this.createRoomSelectNode(room, i, building);
  883. }.bind(this));
  884. }.bind(this));
  885. }.bind(this));
  886. },
  887. createRoomSelectNode: function(room, i, building){
  888. var roomNode = new Element("div", {"styles": this.css.roomTitleNode}).inject(this.selectRoomNode);
  889. var capacityNode = new Element("div", {"styles": this.css.roomTitleCapacityNode, "text": room.capacity+this.lp.person}).inject(roomNode);
  890. var inforNode = new Element("div", {"styles": this.css.roomTitleInforNode}).inject(roomNode);
  891. var node = new Element("div", {"styles": {"height": "20px"}}).inject(inforNode);
  892. var numberNode = new Element("div", {"styles": this.css.roomTitleNumberNode, "text": (room.roomNumber) ? "#"+room.roomNumber : ""}).inject(node);
  893. var nameNode = new Element("div", {"styles": this.css.roomTitleNameNode, "text": room.name}).inject(node);
  894. var iconsNode = new Element("div", {"styles": this.css.roomTitleIconsNode}).inject(inforNode);
  895. var deviceList = room.device.split("#");
  896. deviceList.each(function(name){
  897. var node = new Element("div", {"styles": this.css.roomTitleIconNode, "title": this.lp.device[name]}).inject(iconsNode);
  898. node.setStyle("background-image", "url(/x_component_Meeting/$RoomView/default/icon/device/"+name+"_disable.png)");
  899. }.bind(this));
  900. if ((i % 2)!=0) roomNode.setStyle("background-color", "#f4f8ff");
  901. roomNode.store("room", room);
  902. var _self = this;
  903. if (room.idle){
  904. roomNode.addEvents({
  905. "mouseover": function(e){
  906. var color = roomNode.getStyle("background-color");
  907. this.store("bgcolor", color);
  908. this.setStyle("background-color", "#e4edfc");
  909. },
  910. "mouseout": function(){
  911. var color = this.retrieve("bgcolor", "#FFF");
  912. this.setStyle("background-color", color);
  913. },
  914. "click": function(){
  915. var roomData = this.retrieve("room");
  916. _self.roomId = roomData.id;
  917. //roomNode.inject(_self.roomInput);
  918. _self.roomInput.set("text", roomData.name+" ("+building.name+")");
  919. _self.hideRoomNode();
  920. }
  921. });
  922. }else{
  923. roomNode.setStyle("background-color", "#fff6f6");
  924. var disabledNode = new Element("div", {"styles": this.css.roomTitleDisabledIconNode}).inject(roomNode);
  925. }
  926. },
  927. hideRoomNode: function(){
  928. this.selectRoomNode.empty();
  929. this.selectRoomNode.setStyle("display", "none");
  930. document.body.removeEvent("mousedown", this.hideRoomNodeFun);
  931. },
  932. setCreateRoomSelectBuildingNodeSize: function(){
  933. var p = this.createRoomBuildingInput.getPosition(this.createRoomBuildingInput.getOffsetParent());
  934. this.createRoomSelectBuildingNode.position({
  935. relativeTo: this.createRoomBuildingInput,
  936. position: 'bottomCenter',
  937. edge: 'upperCenter',
  938. offset: {x: 0, y: 0}
  939. });
  940. this.createRoomSelectBuildingNode.setStyle("left", p.x);
  941. var size = this.createRoomBuildingInput.getSize();
  942. var w = size.x-2;
  943. this.createRoomSelectBuildingNode.setStyle("width", ""+w+"px");
  944. },
  945. loadAttachment: function(){
  946. this.attachmentTr.setStyle("display","");
  947. this.attachmentNode = new Element("div", {"styles": this.css.createMeetingAttachmentNode}).inject(this.attachmentArea);
  948. var attachmentContentNode = new Element("div", {"styles": this.css.createMeetingAttachmentContentNode}).inject(this.attachmentNode);
  949. MWF.require("MWF.widget.AttachmentController", function(){
  950. this.attachmentController = new MWF.widget.AttachmentController(attachmentContentNode, this, {
  951. "size": "min",
  952. "isSizeChange": false,
  953. "isReplace": false,
  954. "isUpload": this.isNew || this.isEdited,
  955. "isDelete": this.isNew || this.isEdited,
  956. "isDownload": true,
  957. "readonly": !this.isNew && !this.isEdited
  958. });
  959. this.attachmentController.load();
  960. if( this.data.attachmentList ){
  961. this.data.attachmentList.each(function (att) {
  962. att.person = att.lastUpdatePerson.split("@")[0];
  963. var at = this.attachmentController.addAttachment(att);
  964. }.bind(this));
  965. }
  966. }.bind(this));
  967. },
  968. uploadAttachment: function(e, node){
  969. if (!this.uploadFileAreaNode){
  970. this.createUploadFileNode();
  971. }
  972. this.fileUploadNode.click();
  973. },
  974. createUploadFileNode: function(){
  975. this.uploadFileAreaNode = new Element("div");
  976. var html = "<input name=\"file\" type=\"file\" multiple/>";
  977. this.uploadFileAreaNode.set("html", html);
  978. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  979. this.fileUploadNode.addEvent("change", function(){
  980. var files = this.fileUploadNode.files;
  981. if (files.length){
  982. for (var i = 0; i < files.length; i++) {
  983. var file = files.item(i);
  984. var formData = new FormData();
  985. formData.append('file', file);
  986. //formData.append('folder', folderId);
  987. this.app.actions.addAttachment(this.data.id, formData, file, function(o, text){
  988. if (o.id){
  989. this.app.actions.getAttachment(o.id, function(json){
  990. if (json.data) this.attachmentController.addAttachment(json.data);
  991. this.attachmentController.checkActions();
  992. }.bind(this))
  993. }
  994. this.attachmentController.checkActions();
  995. }.bind(this));
  996. }
  997. }
  998. }.bind(this));
  999. },
  1000. deleteAttachments: function(e, node, attachments){
  1001. var names = [];
  1002. attachments.each(function(attachment){
  1003. names.push(attachment.data.name);
  1004. }.bind(this));
  1005. var _self = this;
  1006. this.app.confirm("warn", e, this.lp.deleteAttachmentTitle, this.lp.deleteAttachment+"( "+names.join(", ")+" )", 300, 120, function(){
  1007. while (attachments.length){
  1008. attachment = attachments.shift();
  1009. _self.deleteAttachment(attachment);
  1010. }
  1011. this.close();
  1012. }, function(){
  1013. this.close();
  1014. }, null);
  1015. },
  1016. deleteAttachment: function(attachment){
  1017. this.app.actions.deleteFile(attachment.data.id, function(josn){
  1018. this.attachmentController.removeAttachment(attachment);
  1019. this.attachmentController.checkActions();
  1020. }.bind(this));
  1021. },
  1022. downloadAttachment: function(e, node, attachments){
  1023. attachments.each(function(att){
  1024. this.app.actions.getFileDownload(att.data.id);
  1025. }.bind(this));
  1026. },
  1027. openAttachment: function(e, node, attachments){
  1028. attachments.each(function(att){
  1029. this.app.actions.getFile(att.data.id);
  1030. }.bind(this));
  1031. },
  1032. getAttachmentUrl: function(attachment, callback){
  1033. this.app.actions.getFileUrl(attachment.data.id, callback);
  1034. },
  1035. save: function(){
  1036. this._save(function(){
  1037. this.app.notice(this.lp.meeting_saveSuccess, "success");
  1038. if (!this.attachmentNode){
  1039. this.loadAttachment();
  1040. }
  1041. }.bind(this));
  1042. },
  1043. _save: function(callback){
  1044. this.getSaveData();
  1045. var now = new Date();
  1046. var errorText = "";
  1047. if (!this.data.subject) errorText +=this.lp.meeting_input_subject_error;
  1048. if (!this.data.room) errorText +=this.lp.meeting_input_room_error;
  1049. if (!this.data.invitePersonList.length) errorText +=this.lp.meeting_input_person_error;
  1050. if( this.data.startTimeDate ){
  1051. if (this.data.startTimeDate.diff(this.data.completedTimeDate, "minute")<1) errorText +=this.lp.meeting_input_time_error;
  1052. if (now.diff(this.data.startTimeDate, "minute")<0) errorText +=this.lp.meeting_input_date_error;
  1053. delete this.data.startTimeDate;
  1054. delete this.data.completedTimeDate;
  1055. }
  1056. if (errorText){
  1057. this.app.notice(this.lp.meeting_input_error+errorText, "error");
  1058. return false;
  1059. }
  1060. this.app.actions.saveMeeting(this.data, function(json){
  1061. this.data.id = json.data.id;
  1062. this.waitReload = true;
  1063. if (callback) callback();
  1064. }.bind(this));
  1065. },
  1066. getSaveData: function(){
  1067. this.data = this.form.getResult(false,null,false,false,true);
  1068. this.data.room = this.roomId;
  1069. if( this.invitePersonList ){
  1070. this.data.invitePersonList = this.invitePersonList;
  1071. }
  1072. var d = this.data.dateInput;
  1073. if( this.isNew ) {
  1074. var startTime = d + " " + this.data.beginTimeInput + ":0";
  1075. var completedTime = d + " " + this.data.endTimeInput + ":0";
  1076. var startTimeDate = Date.parse(startTime);
  1077. var completedTimeDate = Date.parse(completedTime);
  1078. this.data.startTime = startTime;
  1079. this.data.completedTime = completedTime;
  1080. this.data.startTimeDate = startTimeDate;
  1081. this.data.completedTimeDate = completedTimeDate;
  1082. }
  1083. if( this.isNew ){
  1084. delete this.data.applicant;
  1085. }else{
  1086. this.data.applicant = this.data.applicant.join(",")
  1087. }
  1088. },
  1089. getPersonByIdentity : function( identity ){
  1090. },
  1091. getPerson : function( source ){
  1092. if( typeOf(source) != "array" )source = [source];
  1093. var target = [];
  1094. source.each( function( s ){
  1095. if( s.split("@").getLast().toLowerCase() == "i" ){
  1096. target.push( this.getPersonByIdentity( s ) )
  1097. }else{
  1098. target.push( s )
  1099. }
  1100. }.bind(this));
  1101. return target;
  1102. },
  1103. reject: function(e){
  1104. var _self = this;
  1105. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1106. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1107. _self.rejectMeeting();
  1108. this.close();
  1109. _self.close();
  1110. }, function(){
  1111. this.close();
  1112. });
  1113. },
  1114. rejectMeeting: function(){
  1115. var view = this.view;
  1116. this.app.actions.rejectMeeting(this.data.id, function(){
  1117. view.reload();
  1118. }.bind(this))
  1119. },
  1120. accept: function(e){
  1121. var _self = this;
  1122. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1123. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1124. _self.acceptMeeting();
  1125. this.close();
  1126. _self.close();
  1127. }, function(){
  1128. this.close();
  1129. });
  1130. },
  1131. acceptMeeting: function(){
  1132. var view = this.view;
  1133. this.app.actions.acceptMeeting(this.data.id, function(){
  1134. view.reload();
  1135. }.bind(this))
  1136. },
  1137. close: function (e) {
  1138. this.fireEvent("queryClose");
  1139. this._close();
  1140. //if( this.form ){
  1141. // this.form.destroy();
  1142. //}
  1143. if(this.setFormNodeSizeFun && this.app ){
  1144. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1145. }
  1146. if( this.formMaskNode )this.formMaskNode.destroy();
  1147. this.formAreaNode.destroy();
  1148. this.fireEvent("postClose");
  1149. if( this.waitReload )this.view.reload();
  1150. delete this;
  1151. }
  1152. });
  1153. MWF.xApplication.Meeting.MeetingTooltip = new Class({
  1154. Extends: MTooltips,
  1155. _loadCustom : function( callback ){
  1156. this.loadRoom( function(){
  1157. this.loadInvite();
  1158. this.loadAttachment();
  1159. if(callback)callback();
  1160. }.bind(this) );
  1161. },
  1162. _getHtml : function(){
  1163. var data = this.data;
  1164. var titleStyle = "font-size:14px;color:#333";
  1165. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1166. var persons = [];
  1167. data.invitePersonList.each( function( p ){
  1168. persons.push(p.split("@")[0] )
  1169. }.bind(this));
  1170. var color = "#ccc";
  1171. switch (data.status){
  1172. case "wait":
  1173. color = "#4990E2";
  1174. break;
  1175. case "processing":
  1176. color = "#66CC7F";
  1177. break;
  1178. case "completed":
  1179. color = "#666";
  1180. break;
  1181. }
  1182. if (data.myWaitAccept){
  1183. color = "#F6A623";
  1184. }
  1185. if (data.confilct){
  1186. color = "#FF7F7F";
  1187. }
  1188. var beginDate = Date.parse(data.startTime);
  1189. var endDate = Date.parse(data.completedTime);
  1190. var dateStr = beginDate.format(this.app.lp.dateFormatDay);
  1191. var beginTime = this.getString( beginDate.getHours() ) + ":" + this.getString( beginDate.getMinutes() );
  1192. var endTime = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  1193. var meetingTime = dateStr + " " + beginTime + "-" + endTime;
  1194. var html =
  1195. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1196. " <div style='font-size: 12px;color:#666; float: right'>"+ this.lp.applyPerson +":" + data.applicant.split("@")[0] +"</div>" +
  1197. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.meetingDetail +"</div>"+
  1198. "</div>"+
  1199. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;'>"+ data.subject +"</div>"+
  1200. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1201. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1202. "<tr><td style='"+titleStyle+";' width='70'>"+this.lp.meetingTime+":</td>" +
  1203. " <td style='"+valueStyle+";color:"+ color +"'>" + meetingTime + "</td></tr>" +
  1204. //"<tr><td style='"+titleStyle+"' width='70'>"+this.lp.beginTime+":</td>" +
  1205. //" <td style='"+valueStyle+"'>" + data.startTime + "</td></tr>" +
  1206. //"<tr><td style='"+titleStyle+"'>"+this.lp.endTime+":</td>" +
  1207. //" <td style='"+valueStyle+"'>" + data.completedTime + "</td></tr>" +
  1208. "<tr><td style='"+titleStyle+"'>"+this.lp.selectRoom +":</td>" +
  1209. " <td style='"+valueStyle+"' item='meetingRoom'></td></tr>" +
  1210. "<tr><td style='"+titleStyle+"'>"+this.lp.invitePerson2+":</td>" +
  1211. " <td style='"+valueStyle+"' item='invitePerson'>"+persons.join(",")+"</td></tr>" +
  1212. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingDescription+":</td>" +
  1213. " <td style='"+valueStyle+"'>"+ data.description +"</td></tr>" +
  1214. ( this.options.isHideAttachment ? "" :
  1215. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingAttachment+":</td>" +
  1216. " <td style='"+valueStyle+"' item='attachment'></td></tr>"
  1217. )+
  1218. "</table>";
  1219. return html;
  1220. },
  1221. getString : function( str ){
  1222. var s = "00" + str;
  1223. return s.substr(s.length - 2, 2 );
  1224. },
  1225. loadRoom: function( callback ){
  1226. var area = this.node.getElement("[item='meetingRoom']");
  1227. if (this.data.room){
  1228. this.app.actions.getRoom(this.data.room, function(json){
  1229. this.app.actions.getBuilding(json.data.building, function(bjson){
  1230. area.set("text", json.data.name+" ("+bjson.data.name+")");
  1231. if( callback )callback();
  1232. }.bind(this));
  1233. }.bind(this));
  1234. }
  1235. },
  1236. loadInvite : function(){
  1237. this.O2PersonList = [];
  1238. var area = this.node.getElement("[item='invitePerson']");
  1239. MWF.require("MWF.widget.O2Identity", function(){
  1240. area.empty();
  1241. this.data.invitePersonList.each(function( person ){
  1242. var O2person = new MWF.widget.O2Person({name : person}, area, {"style": "room", "onLoadedInfor": function(item){
  1243. this.loadAcceptAndReject( item );
  1244. }.bind(this) });
  1245. this.O2PersonList.push( O2person );
  1246. }.bind(this));
  1247. }.bind(this));
  1248. },
  1249. loadAcceptAndReject : function( item ){
  1250. var personName = item.data.distinguishedName;
  1251. if( this.data.acceptPersonList ){
  1252. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  1253. var acceptNode = new Element("div", {"styles": {
  1254. "height": "20px",
  1255. "width": "14px",
  1256. "margin-right": "3px",
  1257. "float": "left",
  1258. "background": "url(/x_component_Template/$MPopupForm/meeting/icon/accept.png) no-repeat center center"
  1259. }}).inject(item.node, "top");
  1260. new Element("div", {
  1261. "styles" : {"color": "#1fbf04", "clear":"both","text-align":"center"},
  1262. "text": this.app.lp.accepted
  1263. }).inject(item.inforNode);
  1264. }
  1265. }
  1266. if(this.data.rejectPersonList){
  1267. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  1268. var rejectNode = new Element("div", {"styles": {
  1269. "height": "20px",
  1270. "width": "14px",
  1271. "margin-right": "3px",
  1272. "float": "left",
  1273. "background": "url(/x_component_Template/$MPopupForm/meeting/icon/reject.png) no-repeat center center"
  1274. }}).inject(item.node, "top");
  1275. new Element("div", {
  1276. "styles" : {"color": "#FF0000", "clear":"both","text-align":"center"},
  1277. "text": this.app.lp.rejected
  1278. }).inject(item.inforNode);
  1279. }
  1280. }
  1281. },
  1282. destroy: function(){
  1283. if( this.O2PersonList ){
  1284. this.O2PersonList.each(function(p){
  1285. p.destroy();
  1286. })
  1287. }
  1288. if( this.node ){
  1289. this.node.destroy();
  1290. this.node = null;
  1291. }
  1292. },
  1293. loadAttachment: function(){
  1294. if( this.options.isHideAttachment )return;
  1295. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1296. var area = this.node.getElement("[item='attachment']");
  1297. this.attachmentNode = new Element("div"
  1298. //{"styles": this.css.createMeetingAttachmentNode}
  1299. ).inject(area);
  1300. var attachmentContentNode = new Element("div", {
  1301. //"styles": this.css.createMeetingAttachmentContentNode
  1302. }).inject(this.attachmentNode);
  1303. this.attachmentController = new MWF.xApplication.Meeting.MeetingTooltip.AttachmentController(attachmentContentNode, this, {
  1304. "size": "min",
  1305. "isSizeChange": false,
  1306. "isReplace": false,
  1307. "isUpload": false,
  1308. "isDelete": false,
  1309. "isDownload": true,
  1310. "readonly": true
  1311. });
  1312. this.attachmentController.load();
  1313. this.data.attachmentList.each(function (att) {
  1314. att.person = att.lastUpdatePerson.split("@")[0];
  1315. var at = this.attachmentController.addAttachment(att);
  1316. }.bind(this));
  1317. }
  1318. },
  1319. downloadAttachment: function(e, node, attachments){
  1320. attachments.each(function(att){
  1321. this.app.actions.getFileDownload(att.data.id);
  1322. }.bind(this));
  1323. },
  1324. openAttachment: function(e, node, attachments){
  1325. attachments.each(function(att){
  1326. this.app.actions.getFile(att.data.id);
  1327. }.bind(this));
  1328. },
  1329. getAttachmentUrl: function(attachment, callback){
  1330. this.app.actions.getFileUrl(attachment.data.id, callback);
  1331. }
  1332. });
  1333. MWF.xApplication.Meeting.MeetingTooltip.AttachmentController = new Class({
  1334. Extends : MWF.widget.AttachmentController,
  1335. loadMin: function(){
  1336. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1337. if (!this.minActionAreaNode){
  1338. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1339. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1340. this.minContent.setStyles({
  1341. "margin-right" : "0px"
  1342. });
  1343. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1344. // this.downloadAttachment(e, node);
  1345. //}.bind(this));
  1346. this.node.inject(this.container);
  1347. //if (this.options.readonly) this.setReadonly();
  1348. this.checkActions();
  1349. this.setEvent();
  1350. }else{
  1351. //this.minActionAreaNode.setStyle("display", "block");
  1352. this.minContent.setStyle("display", "block");
  1353. this.minContent.empty();
  1354. }
  1355. var atts = [];
  1356. while (this.attachments.length){
  1357. var att = this.attachments.shift();
  1358. atts.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(att.data, this));
  1359. }
  1360. this.attachments = atts;
  1361. },
  1362. addAttachment: function(data){
  1363. if (this.options.size=="min"){
  1364. this.attachments.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(data, this));
  1365. }else{
  1366. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1367. }
  1368. }
  1369. });
  1370. MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin = new Class({
  1371. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1372. setEvent: function(){
  1373. this.node.addEvents({
  1374. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1375. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1376. "mousedown": function(e){this.selected(e);}.bind(this),
  1377. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1378. });
  1379. },
  1380. downloadAttachment: function(e){
  1381. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1382. }
  1383. });
  1384. MWF.xApplication.Meeting.MeetingArea = new Class({
  1385. initialize: function(container, view, data){
  1386. this.container = container;
  1387. this.view = view;
  1388. this.css = this.view.css;
  1389. this.app = this.view.app;
  1390. this.data = data;
  1391. this.beginDate = Date.parse(this.data.startTime);
  1392. this.endDate = Date.parse(this.data.completedTime);
  1393. this.userName = layout.desktop.session.user.distinguishedName;
  1394. this.userId = layout.desktop.session.user.id;
  1395. this.parseData();
  1396. this.path = "/x_component_Meeting/$Common/default/meetingarea/";
  1397. this.cssPath = "/x_component_Meeting/$Common/default/meetingarea/css.wcss";
  1398. this._loadCss();
  1399. this.load();
  1400. },
  1401. load: function(){
  1402. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  1403. this.node.addEvents({
  1404. mouseenter : function(){
  1405. this.node.setStyles( this.css.meetingNode_over );
  1406. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  1407. }.bind(this),
  1408. mouseleave : function(){
  1409. this.node.setStyles( this.css.meetingNode );
  1410. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  1411. }.bind(this),
  1412. click : function(){
  1413. this.openMeeting()
  1414. }.bind(this)
  1415. });
  1416. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  1417. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  1418. var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  1419. var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  1420. this.timeNode = new Element("div", {
  1421. "styles": this.css.meetingTimeNode,
  1422. "text" : beginTime + "-" + endTime
  1423. }).inject(this.contentNode);
  1424. this.subjectNode = new Element("div", {
  1425. "styles": this.css.meetingSubjectNode,
  1426. "text": this.data.subject
  1427. }).inject(this.contentNode);
  1428. this.descriptionNode = new Element("div", {
  1429. "styles": this.css.meetingDescriptionNode,
  1430. "text" : this.data.description
  1431. }).inject(this.contentNode);
  1432. this.loadActionBar();
  1433. switch (this.data.status){
  1434. case "wait":
  1435. this.colorNode.setStyles({"background-color": "#4990E2"});
  1436. this.timeNode.setStyles({"color": "#4990E2"});
  1437. break;
  1438. case "processing":
  1439. this.colorNode.setStyles({"background-color": "#66CC7F"});
  1440. this.timeNode.setStyles({"color": "#66CC7F"});
  1441. break;
  1442. case "completed":
  1443. //add attachment
  1444. this.colorNode.setStyles({"background-color": "#ccc"});
  1445. this.timeNode.setStyles({"color": "#ccc"});
  1446. break;
  1447. }
  1448. if (this.data.myWaitAccept){
  1449. this.colorNode.setStyles({"background-color": "#F6A623"});
  1450. this.timeNode.setStyles({"color": "#F6A623"});
  1451. }
  1452. this.resetNodeSize();
  1453. this.loadTooltip();
  1454. },
  1455. parseData : function(){
  1456. if( !this.data.status ){
  1457. var now = new Date();
  1458. var status;
  1459. if( this.beginDate > now ){
  1460. status = "wait";
  1461. }else if( this.endDate < now ){
  1462. status = "completed";
  1463. }else{
  1464. status = "processing";
  1465. }
  1466. this.data.status = status;
  1467. }
  1468. if( typeOf( this.data.myWaitAccept ) != "boolean" ){
  1469. if( this.data.invitePersonList.contains( this.userName ) || this.data.invitePersonList.contains( this.userId ) ){
  1470. this.data.myWaitAccept = ( !this.data.acceptPersonList.contains( this.userName ) || this.data.acceptPersonList.contains( this.userId ) ) &&
  1471. ( !this.data.rejectPersonList.contains( this.userName ) || !this.data.rejectPersonList.contains( this.userId ) )
  1472. }
  1473. }
  1474. },
  1475. loadActionBar : function(){
  1476. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() || this.data.myWaitAccept ){
  1477. }else{
  1478. return;
  1479. }
  1480. this.actionBar = new Element("div", {
  1481. "styles": this.css.actionBar
  1482. }).inject(this.contentNode);
  1483. //this.viewAction = new Element("div", {
  1484. // styles: this.css.action_view,
  1485. // events : {
  1486. // mouseenter : function(){
  1487. // this.viewAction.setStyles( this.css.action_view_over );
  1488. // }.bind(this),
  1489. // mouseleave : function(){
  1490. // this.viewAction.setStyles( this.css.action_view );
  1491. // }.bind(this),
  1492. // click : function(){
  1493. // this.openMeeting()
  1494. // }.bind(this)
  1495. // }
  1496. //}).inject(this.actionBar);
  1497. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() ){
  1498. if( this.data.status=="wait" ){
  1499. this.editAction = new Element("div", {
  1500. styles: this.css.action_edit,
  1501. events : {
  1502. mouseover : function(){
  1503. this.editAction.setStyles( this.css.action_edit_over );
  1504. }.bind(this),
  1505. mouseout : function(){
  1506. this.editAction.setStyles( this.css.action_edit );
  1507. }.bind(this),
  1508. click : function(e){
  1509. this.editMeeting();
  1510. e.stopPropagation();
  1511. }.bind(this)
  1512. }
  1513. }).inject(this.actionBar);
  1514. //if (this.data.myWaitConfirm) this.createConfirmActions();
  1515. //if (this.data.myWaitAccept) this.createAcceptActions();
  1516. //if (this.data.status=="wait" && this.isEdit) this.createCancelActions();
  1517. this.removeAction = new Element("div", {
  1518. styles: this.css.action_remove,
  1519. events : {
  1520. mouseover : function(){
  1521. this.removeAction.setStyles( this.css.action_remove_over );
  1522. }.bind(this),
  1523. mouseout : function(){
  1524. this.removeAction.setStyles( this.css.action_remove );
  1525. }.bind(this),
  1526. click : function( e ){
  1527. this.cancel(e);
  1528. e.stopPropagation();
  1529. }.bind(this)
  1530. }
  1531. }).inject(this.actionBar);
  1532. }
  1533. }
  1534. if (this.data.myWaitAccept){
  1535. this.acceptAction = new Element("div", {
  1536. styles: this.css.action_accept,
  1537. title : this.app.lp.accept,
  1538. events : {
  1539. mouseover : function(){
  1540. this.acceptAction.setStyles( this.css.action_accept_over );
  1541. }.bind(this),
  1542. mouseout : function(){
  1543. this.acceptAction.setStyles( this.css.action_accept );
  1544. }.bind(this),
  1545. click : function( e ){
  1546. this.accept(e);
  1547. e.stopPropagation();
  1548. }.bind(this)
  1549. }
  1550. }).inject(this.actionBar);
  1551. this.rejectAction = new Element("div", {
  1552. styles: this.css.action_reject,
  1553. title : this.app.lp.reject,
  1554. events : {
  1555. mouseover : function(){
  1556. this.rejectAction.setStyles( this.css.action_reject_over );
  1557. }.bind(this),
  1558. mouseout : function(){
  1559. this.rejectAction.setStyles( this.css.action_reject );
  1560. }.bind(this),
  1561. click : function( e ){
  1562. this.reject(e);
  1563. e.stopPropagation();
  1564. }.bind(this)
  1565. }
  1566. }).inject(this.actionBar);
  1567. }
  1568. },
  1569. getString : function( str ){
  1570. var s = "00" + str;
  1571. return s.substr(s.length - 2, 2 );
  1572. },
  1573. _loadCss: function(){
  1574. var key = encodeURIComponent(this.cssPath);
  1575. if (MWF.widget.css[key]){
  1576. this.css = MWF.widget.css[key];
  1577. }else{
  1578. var r = new Request.JSON({
  1579. url: this.cssPath,
  1580. secure: false,
  1581. async: false,
  1582. method: "get",
  1583. noCache: false,
  1584. onSuccess: function(responseJSON, responseText){
  1585. this.css = responseJSON;
  1586. MWF.widget.css[key] = responseJSON;
  1587. }.bind(this),
  1588. onError: function(text, error){
  1589. alert(error + text);
  1590. }
  1591. });
  1592. r.send();
  1593. }
  1594. },
  1595. loadTooltip : function( isHideAttachment ){
  1596. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  1597. axis : "x",
  1598. hiddenDelay : 300,
  1599. displayDelay : 300,
  1600. isHideAttachment : isHideAttachment
  1601. });
  1602. },
  1603. showTooltip: function( ){
  1604. if( this.tooltip ){
  1605. this.tooltip.load();
  1606. }else{
  1607. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.viewAction, this.app, this.data);
  1608. this.tooltip.load();
  1609. }
  1610. },
  1611. openMeeting: function(){
  1612. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1613. form.view = this.view;
  1614. form.open();
  1615. },
  1616. resetNodeSize: function(){
  1617. var contentSize = this.contentNode.getSize();
  1618. this.colorNode.setStyle("height", contentSize.y );
  1619. },
  1620. destroy: function(){
  1621. if(this.tooltip)this.tooltip.destroy();
  1622. this.node.destroy();
  1623. MWF.release(this);
  1624. },
  1625. editMeeting : function(){
  1626. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1627. form.view = this.view;
  1628. form.edit();
  1629. },
  1630. cancel: function(e){
  1631. var _self = this;
  1632. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  1633. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 150, function(){
  1634. _self.cancelMeeting();
  1635. this.close();
  1636. }, function(){
  1637. this.close();
  1638. });
  1639. },
  1640. cancelMeeting: function(){
  1641. var view = this.view;
  1642. this.app.actions.deleteMeeting(this.data.id, function(){
  1643. view.reload();
  1644. }.bind(this))
  1645. },
  1646. reject: function(e){
  1647. var _self = this;
  1648. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1649. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1650. _self.rejectMeeting();
  1651. this.close();
  1652. }, function(){
  1653. this.close();
  1654. });
  1655. },
  1656. rejectMeeting: function(){
  1657. var view = this.view;
  1658. this.app.actions.rejectMeeting(this.data.id, function(){
  1659. view.reload();
  1660. }.bind(this))
  1661. },
  1662. accept: function(e){
  1663. var _self = this;
  1664. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1665. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1666. _self.acceptMeeting();
  1667. this.close();
  1668. }, function(){
  1669. this.close();
  1670. });
  1671. },
  1672. acceptMeeting: function(){
  1673. var view = this.view;
  1674. this.app.actions.acceptMeeting(this.data.id, function(){
  1675. view.reload();
  1676. }.bind(this))
  1677. },
  1678. disagree: function(e){
  1679. var _self = this;
  1680. var text = this.app.lp.disagree_confirm.replace(/{name}/g, this.data.subject);
  1681. this.app.confirm("infor", e, this.app.lp.disagree_confirm_title, text, 300, 120, function(){
  1682. _self.disagreeMeeting();
  1683. this.close();
  1684. }, function(){
  1685. this.close();
  1686. });
  1687. },
  1688. disagreeMeeting: function(){
  1689. var view = this.view;
  1690. this.app.actions.denyMeeting(this.data.id, function(){
  1691. view.reload();
  1692. }.bind(this))
  1693. },
  1694. agree: function(e){
  1695. var _self = this;
  1696. var text = this.app.lp.agree_confirm.replace(/{name}/g, this.data.subject);
  1697. this.app.confirm("infor", e, this.app.lp.agree_confirm_title, text, 300, 120, function(){
  1698. _self.agreeMeeting();
  1699. this.close();
  1700. }, function(){
  1701. this.close();
  1702. });
  1703. },
  1704. agreeMeeting: function(){
  1705. var view = this.view;
  1706. this.app.actions.allowMeeting(this.data.id, function(){
  1707. view.reload();
  1708. }.bind(this))
  1709. }
  1710. });
  1711. MWF.xApplication.Meeting.SideBar = new Class({
  1712. Extends: MWF.widget.Common,
  1713. Implements: [Options, Events],
  1714. options: {
  1715. "style": "default"
  1716. },
  1717. initialize : function( container, app, options){
  1718. this.setOptions( options );
  1719. this.container = container;
  1720. this.app = app;
  1721. //this.css = this.app.css;
  1722. this.lp = this.app.lp;
  1723. this.isHidden = false;
  1724. this.cssPath = "/x_component_Meeting/$Common/"+this.options.style+"/sidebar/css.wcss";
  1725. this._loadCss();
  1726. this.load();
  1727. },
  1728. load : function(){
  1729. this.node = new Element("div.sideBar", {
  1730. "styles": this.css.node,
  1731. events : {
  1732. mousedown : function( ev ){
  1733. ev.stopPropagation();
  1734. }
  1735. }
  1736. }).inject(this.container);
  1737. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  1738. this.loadStatusArea();
  1739. new Element("div.contentLine", {
  1740. "styles" : this.css.contentLine
  1741. }).inject( this.contentNode );
  1742. this.loadTodayMeetingNode();
  1743. this.trapezoid = new Element("div.trapezoid",{
  1744. "styles":this.css.trapezoid_toRight,
  1745. events : {
  1746. click : function(){
  1747. this.trigger();
  1748. }.bind(this)
  1749. }
  1750. }).inject(this.node);
  1751. //this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  1752. this.loadTodayMeeting( function(){
  1753. var x = this.node.getSize().x - 8;
  1754. this.node.setStyle( "right", "-"+x+"px" );
  1755. this.resetNodeSize();
  1756. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  1757. this.app.addEvent("resize", this.resetNodeSizeFun );
  1758. this.hideFun = this.hide.bind(this);
  1759. this.app.node.addEvent("mousedown", this.hideFun);
  1760. }.bind(this));
  1761. },
  1762. loadStatusArea : function(){
  1763. var area = new Element("div", {
  1764. "styles" : this.css.statusArea
  1765. }).inject( this.contentNode );
  1766. var html = "<div class='titleDiv'>"+this.lp.config.meetingStatus+"</div>" +
  1767. "<div class = 'statusStyle'>"+
  1768. " <div class='statusIconStyle' style='background-color:#4990E2'></div>" +
  1769. " <div class = 'statusTextStyle'>"+this.lp.config.wait+"</div></div>" +
  1770. "</div>"+
  1771. "<div class = 'statusStyle'>"+
  1772. " <div class='statusIconStyle' style='background-color:#66CC7F'></div>" +
  1773. " <div class = 'statusTextStyle'>"+this.lp.config.progress+"</div></div>" +
  1774. "</div>"+
  1775. "<div class = 'statusStyle'>"+
  1776. " <div class='statusIconStyle' style='background-color:#F6A623'></div>" +
  1777. " <div class = 'statusTextStyle'>"+this.lp.config.invite+"</div></div>" +
  1778. "</div>"+
  1779. "<div class = 'statusStyle'>"+
  1780. " <div class='statusIconStyle' style='background-color:#ccc'></div>" +
  1781. " <div class = 'statusTextStyle'>"+this.lp.config.completed+"</div></div>" +
  1782. "</div>"+
  1783. "<div class = 'statusStyle'>"+
  1784. " <div class='statusIconStyle2' style='border:2px solid #FF7F7F;'></div>" +
  1785. " <div class = 'statusTextStyle'>"+this.lp.config.conflict+"</div></div>" +
  1786. "</div>";
  1787. area.set("html", html);
  1788. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  1789. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  1790. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  1791. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  1792. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  1793. },
  1794. loadTodayMeetingNode: function(){
  1795. var area = new Element("div.meetingArea", {
  1796. "styles" : this.css.meetingArea
  1797. }).inject( this.contentNode );
  1798. new Element("div.titleDiv", {
  1799. "styles" : this.css.titleDiv,
  1800. "text" : this.lp.meetingNotice
  1801. }).inject( area );
  1802. this.meetingNode = Element("div", {
  1803. "styles" : this.css.meetingNode
  1804. }).inject( area );
  1805. },
  1806. loadTodayMeeting : function( callback ){
  1807. var today = new Date();
  1808. var user = layout.desktop.session.user;
  1809. var dn = user.distinguishedName;
  1810. var y = today.getFullYear();
  1811. var m = today.getMonth()+1;
  1812. var d = today.getDate();
  1813. this.app.actions.listMeetingDay(y, m, d, function(json) {
  1814. var data = [];
  1815. json.data.each( function( d ){
  1816. if( d.invitePersonList.contains( dn ) || d.applicant == dn ){
  1817. if( !d.rejectPersonList.contains( dn ) ){
  1818. data.push( d );
  1819. }
  1820. }
  1821. }.bind(this));
  1822. if( user.distinguishedName ){
  1823. var userName = user.distinguishedName.split("@")[0]
  1824. }else{
  1825. var userName = user.name
  1826. }
  1827. var lp = data.length ? this.lp.meetingTopInfor : this.lp.noMeetingTopInfor ;
  1828. this.meetingTopNode = new Element("div", {
  1829. "styles" : this.css.meetingTopNode,
  1830. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  1831. }).inject( this.meetingNode );
  1832. this.scrollNode = new Element("div.scrollNode", {
  1833. "styles" : this.css.scrollNode
  1834. }).inject( this.meetingNode );
  1835. this.meetingItemContainer = new Element("div.meetingItemContainer", {
  1836. "styles" : this.css.meetingItemContainer
  1837. }).inject( this.scrollNode );
  1838. data.each( function( d, i ){
  1839. var itemNode = new Element("div.meetingItemNode", {
  1840. "styles" : this.css.meetingItemNode,
  1841. "events" : {
  1842. click : function(){
  1843. this.obj.openMeeting( this.data );
  1844. }.bind({ obj : this, data : d })
  1845. }
  1846. }).inject( this.meetingItemContainer );
  1847. this.tooltipList = this.tooltipList || [];
  1848. this.tooltipList.push( new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, itemNode, this.app, d, {
  1849. axis : "x",
  1850. hiddenDelay : 300,
  1851. displayDelay : 300
  1852. })
  1853. );
  1854. var colorNode = new Element("div.meetingItemColorNode", {
  1855. "styles" : this.css.meetingItemColorNode,
  1856. "text" : i+1
  1857. }).inject( itemNode );
  1858. var textNode = new Element("div.meetingItemTextNode", {
  1859. "styles" : this.css.meetingItemTextNode,
  1860. "text" : d.subject
  1861. }).inject( itemNode );
  1862. switch (d.status){
  1863. case "wait":
  1864. colorNode.setStyles({"background-color": "#4990E2"});
  1865. break;
  1866. case "processing":
  1867. colorNode.setStyles({"background-color": "#66CC7F"});
  1868. break;
  1869. case "completed":
  1870. //add attachment
  1871. colorNode.setStyles({"background-color": "#ccc"});
  1872. break;
  1873. }
  1874. if (d.myWaitAccept){
  1875. colorNode.setStyles({"background-color": "#F6A623"});
  1876. }
  1877. var y = itemNode.getSize().y ;
  1878. colorNode.setStyle("margin-top", ( y - 20)/2 );
  1879. }.bind(this));
  1880. this.setScrollBar( this.scrollNode );
  1881. if( callback )callback();
  1882. }.bind(this));
  1883. },
  1884. trigger : function(){
  1885. this.isHidden ? this.show( true ) : this.hide( true )
  1886. },
  1887. hide: function( isFireEvent ){
  1888. var x = this.node.getSize().x - 9;
  1889. var fx = new Fx.Morph(this.node, {
  1890. "duration": "300",
  1891. "transition": Fx.Transitions.Expo.easeOut
  1892. });
  1893. fx.start({
  1894. //"opacity": 0
  1895. }).chain(function(){
  1896. this.isHidden = true;
  1897. //this.node.setStyle("display", "none");
  1898. this.node.setStyles({
  1899. "right": "-"+x+"px"
  1900. });
  1901. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  1902. //if(isFireEvent)this.app.fireEvent("resize");
  1903. }.bind(this));
  1904. },
  1905. show: function( isFireEvent ){
  1906. this.node.setStyles(this.css.node);
  1907. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  1908. //var x = this.node.getSize().x - 8;
  1909. //this.node.setStyles( "right", "-"+x+"px" );
  1910. var fx = new Fx.Morph(this.node, {
  1911. "duration": "500",
  1912. "transition": Fx.Transitions.Expo.easeOut
  1913. });
  1914. this.app.fireAppEvent("resize");
  1915. fx.start({
  1916. "opacity": 1
  1917. }).chain(function(){
  1918. this.node.setStyles({
  1919. //"position": "static",
  1920. //"width": "auto"
  1921. "right": "0px"
  1922. });
  1923. this.isHidden = false;
  1924. //if(isFireEvent)this.app.fireEvent("resize");
  1925. }.bind(this))
  1926. },
  1927. //show: function(){
  1928. // this.node.setStyles(this.css.configNode);
  1929. // var fx = new Fx.Morph(this.node, {
  1930. // "duration": "500",
  1931. // "transition": Fx.Transitions.Expo.easeOut
  1932. // });
  1933. // fx.start({
  1934. // "opacity": 1
  1935. // }).chain(function(){
  1936. // this.hideFun = this.hide.bind(this);
  1937. // this.app.content.addEvent("mousedown", this.hideFun);
  1938. // }.bind(this));
  1939. //},
  1940. //hide: function(){
  1941. // this.node.destroy();
  1942. // this.app.content.removeEvent("mousedown", this.hideFun);
  1943. // MWF.release(this);
  1944. //},
  1945. resetNodeSize: function(){
  1946. var size = this.container.getSize();
  1947. this.node.setStyle("height", size.y - 50 );
  1948. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  1949. var y = size.y - 395;
  1950. var meetContainerY = this.meetingItemContainer.getSize().y + 12;
  1951. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  1952. },
  1953. getSize : function(){
  1954. //var size = this.node.getSize();
  1955. //return {
  1956. // x : this.isHidden ? 9 : size.x,
  1957. // y : size.y
  1958. //}
  1959. return { x : 9, y : 0 }
  1960. },
  1961. showByType : function( type ){
  1962. },
  1963. reload : function(){
  1964. this.destory();
  1965. this.app.reload();
  1966. },
  1967. openMeeting : function( data ){
  1968. var form = new MWF.xApplication.Meeting.MeetingForm(this, data, {}, {app:this.app});
  1969. form.view = this.app;
  1970. form.open();
  1971. },
  1972. destory : function(){
  1973. this.tooltipList.each( function( t ){
  1974. t.destory();
  1975. });
  1976. this.app.removeEvent("resize", this.resetNodeSizeFun );
  1977. this.app.node.removeEvent("mousedown", this.hideFun);
  1978. this.node.destory();
  1979. }
  1980. });