Common.js 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906
  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", clazz: "mainColor_bg", 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.fireEvent("postSave", [data]);
  64. this.close();
  65. if(view)view.reload();
  66. }.bind(this));
  67. },
  68. removeBuilding: function(e) {
  69. var info = this.app.lp.delete_building;
  70. info = info.replace(/{name}/g, this.data.name);
  71. var _self = this;
  72. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  73. _self.remove();
  74. this.close();
  75. }, function(){
  76. this.close();
  77. });
  78. },
  79. remove: function(){
  80. var view = this.view;
  81. this.app.actions.deleteBuilding(this.data.id, function(){
  82. view.reload();
  83. }.bind(this));
  84. }
  85. });
  86. MWF.xApplication.Meeting.BuildingTooltip = new Class({
  87. Extends: MTooltips,
  88. _loadCustom : function( callback ){
  89. this.loadActionBar();
  90. if(callback)callback();
  91. },
  92. _getHtml : function(){
  93. var data = this.data;
  94. var html =
  95. "<div item='containr' style='height:16px;line-height:16px;'><div style='font-size: 14px;color:#666;float:left; ' item='address'></div></div>";
  96. return html;
  97. },
  98. _customNode : function( node, contentNode ){
  99. var data = this.data;
  100. contentNode.getElement("[item='address']").set("text", (data.address ? data.address : this.lp.noAddress) );
  101. this.fireEvent("customContent", [contentNode, node])
  102. },
  103. loadActionBar : function(){
  104. if( MWF.AC.isMeetingAdministrator() ){
  105. //this.actionBar = new Element("div", {
  106. // "styles": this.css.actionBar
  107. //}).inject(this.node);
  108. var container = this.node.getElement("[item='containr']");
  109. this.editAction = new Element("div.o2icon-edit2", {
  110. styles: this.css.action_edit,
  111. title : this.lp.editAddress,
  112. events : {
  113. mouseover : function(){
  114. this.editAction.setStyles( this.css.action_edit_over );
  115. this.editAction.addClass("mainColor_color");
  116. }.bind(this),
  117. mouseout : function(){
  118. this.editAction.setStyles( this.css.action_edit );
  119. this.editAction.removeClass("mainColor_color");
  120. }.bind(this),
  121. click : function(){
  122. this.editBuilding( function(data){
  123. this.node.getElement("[item='containr']").getFirst().set("text", (data.address ? data.address : this.lp.noAddress))
  124. }.bind(this))
  125. }.bind(this)
  126. }
  127. }).inject(container);
  128. this.removeAction = new Element("div.o2icon-delete", {
  129. styles: this.css.action_remove,
  130. title: this.lp.removeBuilding,
  131. events : {
  132. mouseover : function(){
  133. this.removeAction.setStyles( this.css.action_remove_over );
  134. this.removeAction.addClass("mainColor_color");
  135. }.bind(this),
  136. mouseout : function(){
  137. this.removeAction.setStyles( this.css.action_remove );
  138. this.removeAction.removeClass("mainColor_color");
  139. }.bind(this),
  140. click : function( e ){
  141. this.removeBuilding(e);
  142. }.bind(this)
  143. }
  144. }).inject(container);
  145. }
  146. },
  147. editBuilding : function( save_callback ){
  148. var options = save_callback ? {
  149. "onPostSave" : save_callback
  150. } : {};
  151. var form = new MWF.xApplication.Meeting.BuildingForm(this,this.data, options, {app:this.app});
  152. form.edit();
  153. },
  154. removeBuilding: function(e) {
  155. this.app.actions.getBuilding( this.data.id, function( json ){
  156. if( json.data.roomList && json.data.roomList.length > 0 ){
  157. this.app.notice( this.app.lp.delete_building_hasRoom.replace(/{name}/g, this.data.name),"error", e.target );
  158. }else{
  159. var info = this.app.lp.delete_building;
  160. info = info.replace(/{name}/g, this.data.name);
  161. var _self = this;
  162. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  163. _self.remove();
  164. this.close();
  165. }, function(){
  166. this.close();
  167. });
  168. }
  169. }.bind(this));
  170. },
  171. remove: function(){
  172. var view = this.view;
  173. this.app.actions.deleteBuilding(this.data.id, function(){
  174. view.reload();
  175. }.bind(this));
  176. },
  177. reload : function(){
  178. this.view.reload();
  179. }
  180. });
  181. MWF.xApplication.Meeting.RoomForm = new Class({
  182. Extends: MPopupForm,
  183. Implements: [Options, Events],
  184. options: {
  185. "style": "meeting",
  186. "width": "900",
  187. "height": "500",
  188. "hasTop": true,
  189. "hasIcon": false,
  190. "hasTopIcon" : false,
  191. "hasTopContent" : false,
  192. "hasBottom": false,
  193. "draggable": true,
  194. "closeAction": true
  195. },
  196. _createTableContent: function () {
  197. if( this.isNew ){
  198. this.formTopTextNode.set( "text", this.lp.addRoom );
  199. }else if( this.isEdited ){
  200. this.formTopTextNode.set( "text", this.lp.editRoom );
  201. //this.options.height = "550";
  202. }else{
  203. this.formTopTextNode.set( "text", this.lp.room );
  204. //this.options.height = "460";
  205. }
  206. var lp = this.lp.roomForm;
  207. var editEnable = ( !this.isEdited && !this.isNew && MWF.AC.isMeetingAdministrator() );
  208. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  209. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  210. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  211. "<tr><td styles='formTableTitle'>"+ lp.name+":</td>" +
  212. " <td styles='formTableValue' item='name' colspan='3' ></td></tr>" +
  213. "<tr><td styles='formTableTitle'>"+ lp.building +":</td>" +
  214. " <td styles='formTableValue' item='buildingName' colspan='3'></td></tr>" +
  215. "<tr><td styles='formTableTitle'>"+ lp.floor +":</td>" +
  216. " <td styles='formTableValue' item='floor'></td>"+
  217. " <td styles='formTableTitle2'>"+ lp.capacity +":</td>" +
  218. " <td styles='formTableValue' item='capacity'></td></tr>" +
  219. "<tr><td styles='formTableTitle'>"+lp.roomNumber+":</td>" +
  220. " <td styles='formTableValue' item='roomNumber'></td>" +
  221. " <td styles='formTableTitle2'>"+lp.phone+":</td>" +
  222. " <td styles='formTableValue' item='phoneNumber'></td></tr>" +
  223. "<tr><td styles='formTableTitle'>"+lp.device+":</td>" +
  224. " <td styles='formTableValue' colspan='3'>" +
  225. " <div item='deviceList' style='"+ boxStyle +"'></div>" +
  226. "</td></tr>" +
  227. "<tr><td styles='formTableTitle'>"+lp.available+":</td>" +
  228. " <td styles='formTableValue' colspan='3'>" +
  229. " <div item='available' style='"+ boxStyle +"'></div>" +
  230. "</td></tr>" +
  231. "<tr><td styles='formTableTitle'></td>" +
  232. " <td styles='formTableValue' colspan='3' style='padding-top: 30px;'>"+
  233. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  234. " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  235. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  236. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  237. " </td></tr>" +
  238. "</table>";
  239. this.formTableArea.set("html", html);
  240. var data = this.data || {};
  241. this.buildingId = data.building;
  242. if( this.buildingId ){
  243. this.getBuliding()
  244. }
  245. MWF.xDesktop.requireApp("Template", "MForm", function () {
  246. this.form = new MForm(this.formTableArea, data, {
  247. isEdited: this.isEdited || this.isNew,
  248. style : "meeting",
  249. itemTemplate: {
  250. name: { text : lp.name, notEmpty : true },
  251. buildingName: {
  252. text : lp.building, notEmpty : true,
  253. value : this.buildingName || "",
  254. event : {
  255. "click": function(){this.listBuilding();}.bind(this),
  256. //"blur": function(){}.bind(this),
  257. "change": function(){ this.buildingId = null; }.bind(this),
  258. "focus": function(){
  259. this.listBuildingHide();
  260. this.listBuilding();
  261. }.bind(this),
  262. "keydown": function(e){
  263. //if ([13,40,38].indexOf(e.code)!=-1){
  264. // if (!this.selectBuildingNode){
  265. // this.listBuilding();
  266. // }
  267. //}
  268. switch (e.code){
  269. case 13:
  270. this.listBuildingHide();
  271. this.listBuilding();
  272. break;
  273. case 40:
  274. this.selectBuildingNext();
  275. break;
  276. case 38:
  277. this.selectBuildingPrev();
  278. break;
  279. case 38:
  280. this.selectBuildingConfirm();
  281. break;
  282. default:
  283. // this.listBuildingHide();
  284. // this.listBuilding();
  285. }
  286. // if (e.code==13){
  287. // this.listBuildingHide();
  288. // this.listBuilding();
  289. // }
  290. // if (e.code==40) this.selectBuildingNext();
  291. // if (e.code==38) this.selectBuildingPrev();
  292. // if (e.code==32) this.selectBuildingConfirm(e);
  293. }.bind(this)
  294. }
  295. },
  296. floor: { type: "select", defaultValue: "1", notEmpty : true, text : lp.floor,
  297. selectText : function(){
  298. var floors = [];
  299. for (var i=-2; i<=50; i++){
  300. if( i != 0 )floors.push(i) //this.lp.floor
  301. }
  302. return floors;
  303. }.bind(this), selectValue : function(){
  304. var floors = [];
  305. for (var i=-2; i<=50; i++){
  306. if( i != 0 )floors.push(i)
  307. }
  308. return floors;
  309. }.bind(this)
  310. },
  311. capacity: { notEmpty : true, tType: "number", text : lp.capacity },
  312. roomNumber: {},
  313. phoneNumber: {},
  314. deviceList: { type : "checkbox",
  315. value : this.data.device ? this.data.device.split("#") : "",
  316. selectValue : function(){ return Object.keys(this.lp.device); }.bind(this),
  317. selectText : function(){ return Object.values(this.lp.device); }.bind(this)
  318. },
  319. available: { type : "radio", defaultValue : "true",
  320. selectValue : [ "true", "false" ],
  321. selectText : [ this.lp.enable, this.lp.disable ]
  322. },
  323. saveAction : { type : "button", className : "inputOkButton", clazz: "mainColor_bg", value : this.lp.save, event : {
  324. click : function(){ this.save();}.bind(this)
  325. } },
  326. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.delete , event : {
  327. click : function( item, ev ){ this.removeRoom(ev); }.bind(this)
  328. } },
  329. editAction : { type : "button", className : "inputOkButton", clazz: "mainColor_bg", value : this.lp.editRoom , event : {
  330. click : function(){ this.editRoom(); }.bind(this)
  331. } },
  332. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  333. click : function(){ this.close(); }.bind(this)
  334. } }
  335. }
  336. }, this.app);
  337. this.form.load();
  338. }.bind(this), true);
  339. },
  340. editRoom : function(){
  341. this.formTopNode = null;
  342. if(this.setFormNodeSizeFun && this.app ){
  343. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  344. }
  345. if( this.formMaskNode )this.formMaskNode.destroy();
  346. this.formAreaNode.destroy();
  347. this.edit();
  348. },
  349. getBuliding : function(){
  350. this.actions.getBuilding( this.buildingId, function(json){
  351. this.buildingName = json.data.name
  352. }.bind(this), null, false )
  353. },
  354. reset: function(){
  355. this.formTableArea.empty();
  356. this._createTableContent();
  357. },
  358. removeRoom: function(e) {
  359. var info = this.app.lp.delete_room;
  360. info = info.replace(/{name}/g, this.data.name);
  361. var _self = this;
  362. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  363. _self.remove();
  364. this.close();
  365. }, function(){
  366. this.close();
  367. });
  368. },
  369. remove: function(){
  370. var view = this.view;
  371. this.app.actions.deleteRoom(this.data.id, function(){
  372. this.close();
  373. view.reload();
  374. }.bind(this));
  375. },
  376. selectBuildingNext: function(){
  377. if (this.selectBuildingNode){
  378. var node=null;
  379. if (this.selectBuildingNode.selectedNode){
  380. node = this.selectBuildingNode.selectedNode.getNext();
  381. if (!node) node = this.selectBuildingNode.getFirst();
  382. this.selectBuildingNode.selectedNode.setStyle("background-color", this.selectBuildingNode.selectedNode.retrieve("bg"));
  383. }else{
  384. node = this.selectBuildingNode.getFirst();
  385. }
  386. if (node){
  387. var color = node.getStyle("background-color");
  388. node.store("bg", color);
  389. node.setStyles(this.css.createRoomBuildingSelectItem_over);
  390. this.selectBuildingNode.selectedNode = node;
  391. }
  392. }
  393. },
  394. selectBuildingPrev: function(){
  395. if (this.selectBuildingNode){
  396. var node = null;
  397. if (this.selectBuildingNode.selectedNode){
  398. var node = this.selectBuildingNode.selectedNode.getPrevious();
  399. if (!node) node = this.selectBuildingNode.getLast();
  400. this.selectBuildingNode.selectedNode.setStyle("background-color", this.selectBuildingNode.selectedNode.retrieve("bg"));
  401. }else{
  402. node = this.selectBuildingNode.getLast();
  403. }
  404. if (node){
  405. var color = node.getStyle("background-color");
  406. node.store("bg", color);
  407. node.setStyles(this.css.createRoomBuildingSelectItem_over);
  408. this.selectBuildingNode.selectedNode = node;
  409. }
  410. }
  411. },
  412. selectBuildingConfirm: function(e){
  413. if (this.selectBuildingNode.selectedNode){
  414. this.selectBuilding(this.selectBuildingNode.selectedNode);
  415. e.preventDefault();
  416. }
  417. },
  418. //cancelCreateRoom: function(){
  419. // this.createRoomNode.destroy();
  420. //},
  421. listBuildingData: function(key, callback){
  422. if (key){
  423. this.actions.listBuildingByKey(key, function(json){
  424. if (callback) callback(json);
  425. });
  426. }else{
  427. this.actions.listBuilding(function(json){
  428. if (callback) callback(json);
  429. });
  430. }
  431. },
  432. listBuilding: function(){
  433. debugger;
  434. if( this.selectBuildingNode )return;
  435. if( this.listing )return;
  436. this.listing = true;
  437. var item = this.form.getItem("buildingName");
  438. var key = item.getValue();
  439. this.listBuildingData(key, function(json){
  440. if (json.data && json.data.length){
  441. this.selectBuildingNode = new Element("div", {"styles": this.css.createRoomSelectBuildingNode}).inject(item.container);
  442. this.setSelectBuildingNodeSize();
  443. this.listBuildingHideFun = this.listBuildingHide.bind(this);
  444. this.formMaskNode.addEvent("mousedown", this.listBuildingHideFun);
  445. this.formNode.addEvent("mousedown", this.listBuildingHideFun);
  446. var _self = this;
  447. json.data.each(function(building, idx){
  448. var node = new Element("div", {"styles": this.css.createRoomBuildingSelectItem}).inject(this.selectBuildingNode);
  449. var nameNode = new Element("div", {"styles": this.css.createRoomBuildingSelectItemName, "text": building.name}).inject(node);
  450. var addrNode = new Element("div", {"styles": this.css.createRoomBuildingSelectItemAddr, "text": building.address}).inject(node);
  451. if ((idx % 2)==1) node.setStyle("background-color", "#f1f6ff");
  452. node.store("building", building.id);
  453. node.addEvents({
  454. "mouseover": function(e){
  455. var color = this.getStyle("background-color");
  456. this.store("bg", color);
  457. this.setStyles(_self.css.createRoomBuildingSelectItem_over);
  458. },
  459. "mouseout": function(e){
  460. this.setStyle("background-color", this.retrieve("bg"));
  461. },
  462. "mousedown": function(e){e.stopPropagation();},
  463. "click": function(e){
  464. _self.selectBuilding(this);
  465. }
  466. });
  467. }.bind(this));
  468. }
  469. this.listing = false;
  470. }.bind(this));
  471. // if( !key ){
  472. // listBuilding
  473. // }else{
  474. //
  475. // }
  476. // this.actions.listBuildingByKey(key, function(json){
  477. //
  478. // }.bind(this));
  479. },
  480. selectBuilding: function(node){
  481. var id = node.retrieve("building");
  482. var text = node.getFirst().get("text");
  483. this.form.getItem("buildingName").setValue(text);
  484. this.buildingId = id;
  485. this.listBuildingHide();
  486. },
  487. setSelectBuildingNodeSize: function(){
  488. var buildingInput = this.form.getItem("buildingName").getElements()[0];
  489. //var p = buildingInput.getPosition(buildingInput.getOffsetParent());
  490. this.selectBuildingNode.position({
  491. relativeTo: buildingInput,
  492. position: 'bottomLeft',
  493. edge: 'upperCenter',
  494. offset: {x: 4, y: 0}
  495. });
  496. //this.selectBuildingNode.setStyle("left", p.x);
  497. var size = buildingInput.getSize();
  498. var w = size.x-8;
  499. this.selectBuildingNode.setStyle("width", ""+w+"px");
  500. },
  501. listBuildingHide: function(){
  502. if (this.selectBuildingNode){
  503. //this.removeEvent("resize", this.setSelectBuildingNodeSizeFun);
  504. this.selectBuildingNode.destroy();
  505. this.selectBuildingNode = null;
  506. this.formMaskNode.removeEvent("mousedown", this.listBuildingHideFun);
  507. this.formNode.removeEvent("mousedown", this.listBuildingHideFun);
  508. }
  509. },
  510. save: function(){
  511. this.getData(function(data){
  512. this.actions.saveRoom(data, function(json){
  513. this.app.notice(this.lp.roomForm.save_success, "success");
  514. var view = this.view;
  515. this.close();
  516. view.reload();
  517. }.bind(this));
  518. }.bind(this));
  519. },
  520. getData: function(callback){
  521. var data = this.form.getResult(true,null,true,false,true);
  522. if( !data )return;
  523. data.device = data.deviceList.join("#");
  524. data.available = data.available == "true";
  525. if (!this.buildingId){
  526. this.actions.saveBuilding({"name": data.buildingName, "address": ""}, function(json){
  527. data.building = json.data.id;
  528. if (callback) callback(data);
  529. }.bind(this));
  530. }else{
  531. data.building = this.buildingId;
  532. if (callback) callback(data);
  533. }
  534. }
  535. });
  536. MWF.xApplication.Meeting.RoomTooltip = new Class({
  537. Extends: MTooltips,
  538. _loadCustom : function( callback ){
  539. this.loadBuilding( function(){
  540. if(callback)callback();
  541. }.bind(this) );
  542. },
  543. _getHtml : function(){
  544. var data = this.data;
  545. var lp = this.lp.device;
  546. var titleStyle = "font-size:14px;color:#333";
  547. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  548. lp = this.lp.roomForm;
  549. var html =
  550. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  551. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.room +"</div>"+
  552. "</div>"+
  553. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;' item='name'></div>"+
  554. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  555. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  556. "<tr><td style='"+titleStyle+"' width='100'>"+ lp.building+":</td>" +
  557. " <td style='"+valueStyle+"' item='building'></td></tr>" +
  558. "<tr><td style='"+titleStyle+"'>" + lp.floor+":</td>" +
  559. " <td style='"+valueStyle+"' item='floor'></td></tr>" +
  560. "<tr><td style='"+titleStyle+"'>"+ lp.capacity +":</td>" +
  561. " <td style='"+valueStyle+"' item='capacity'></td></tr>" +
  562. "<tr><td style='"+titleStyle+"'>"+ lp.roomNumber +":</td>" +
  563. " <td style='"+valueStyle+"' item='roomNumber'></td></tr>" +
  564. "<tr><td style='"+titleStyle+"'>"+ lp.phone+":</td>" +
  565. " <td style='"+valueStyle+"' item='phoneNumber'></td></tr>" +
  566. "<tr><td style='"+titleStyle+"'>"+ lp.device +":</td>" +
  567. " <td style='"+valueStyle+"' item='device'></td></tr>"+
  568. "<tr><td style='"+titleStyle+"'>"+ lp.available +":</td>" +
  569. " <td style='"+valueStyle+"' item='available'></td></tr>"+
  570. "</table>";
  571. return html;
  572. },
  573. _customNode : function( node, contentNode ){
  574. var data = this.data;
  575. var lp = this.lp.roomForm;
  576. var device = [];
  577. ( data.device || "" ).split("#").each( function( d ){
  578. device.push( lp[d] );
  579. }.bind(this));
  580. contentNode.getElement("[item='name']").set("text", data.name );
  581. // contentNode.getElement("[item='building']").set("text", end );
  582. contentNode.getElement("[item='floor']").set("text", data.floor );
  583. contentNode.getElement("[item='capacity']").set("text", data.capacity );
  584. contentNode.getElement("[item='roomNumber']").set("text", data.roomNumber );
  585. contentNode.getElement("[item='phoneNumber']").set("text", data.phoneNumber );
  586. contentNode.getElement("[item='device']").set("text", device.join( "," ) );
  587. contentNode.getElement("[item='available']").set("text", ( !data.available ? this.lp.disable : this.lp.enable ) );
  588. this.fireEvent("customContent", [contentNode, node]);
  589. },
  590. loadBuilding: function( callback ){
  591. var area = this.node.getElement("[item='building']");
  592. if (this.data.building){
  593. this.app.actions.getBuilding(this.data.building, function(bjson){
  594. area.set("text", bjson.data.name );
  595. if( callback )callback();
  596. }.bind(this));
  597. }
  598. }
  599. });
  600. MWF.xApplication.Meeting.MeetingForm = new Class({
  601. Extends: MPopupForm,
  602. Implements: [Options, Events],
  603. options: {
  604. "style": "meeting",
  605. "width": 900,
  606. "height": 780,
  607. "hasTop": true,
  608. "hasIcon": false,
  609. "hasTopIcon" : false,
  610. "hasTopContent" : false,
  611. "hasBottom": true,
  612. "draggable": true,
  613. "closeAction": true,
  614. "maxAction" : true,
  615. "buttonList": []
  616. },
  617. open: function (e) {
  618. this.fireEvent("queryOpen");
  619. this.isNew = false;
  620. this.isEdited = false;
  621. this.getMeetingData( function(){
  622. this._open();
  623. }.bind(this));
  624. this.fireEvent("postOpen");
  625. },
  626. create: function () {
  627. this.fireEvent("queryCreate");
  628. this.isNew = true;
  629. this._open();
  630. this.fireEvent("postCreate");
  631. },
  632. edit: function () {
  633. this.fireEvent("queryEdit");
  634. this.isEdited = true;
  635. this.getMeetingData( function(){
  636. this._open();
  637. }.bind(this));
  638. this.fireEvent("postEdit");
  639. },
  640. getIdentity: function(){
  641. var user = layout.desktop.session.user;
  642. var list = (user.identityList || []).filter(function(i){ return i.major; });
  643. if( list.length )return list[0].distinguishedName;
  644. if( user.identityList && user.identityList.length ){
  645. return user.identityList[0].distinguishedName;
  646. }else{
  647. return "";
  648. }
  649. },
  650. _createTableContent: function () {
  651. var _self = this;
  652. this.formTableContainer.setStyle("padding-top", "20px");
  653. var user = layout.desktop.session.user;
  654. this.userName = user.distinguishedName;
  655. this.userId = user.id;
  656. if( this.isNew ){
  657. this.formTopTextNode.set( "text", this.lp.addMeeting );
  658. }else if( this.isEdited ){
  659. this.formTopTextNode.set( "text", this.lp.editMeeting );
  660. this.options.height = this.isShowInviteDelPersonList() ? 900 : 810;
  661. if( this.data.inviteDelPersonList && this.data.inviteDelPersonList.length )this.options.height += 40;
  662. }else{
  663. this.formTopTextNode.set( "text", this.lp.metting );
  664. this.options.height = 730;
  665. }
  666. if( this.data.acceptPersonList && this.data.acceptPersonList.length )this.options.height += 40;
  667. if( this.data.rejectPersonList && this.data.rejectPersonList.length )this.options.height += 40;
  668. if( this.isNew && !this.data.mode){
  669. this.data.mode = this.app.isAutoCreateOnlineRoom() ? "online" : "offline";
  670. }
  671. debugger;
  672. if(this.isEdited || this.isNew){
  673. if( this.data.mode === "online" )this.options.height += 80;
  674. }else{
  675. if( this.data.mode === "online" )this.options.height += 40;
  676. }
  677. this.options.height = ""+this.options.height;
  678. var defaultDate, defaultBeginTime, date1, defaultEndTime;
  679. if( this.options.date || this.options.minute ){
  680. this.date = typeOf( this.options.date )=="string" ? Date.parse( this.options.date ) : this.options.date;
  681. defaultDate = this.date.clone().format("%Y-%m-%d");
  682. if( this.date.getHours() ){
  683. defaultBeginTime = this.getString( this.date.getHours() )+":"+ this.getString( this.date.getMinutes() );
  684. date1 = this.date.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  685. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  686. defaultEndTime = this.getString( date1.getHours() )+":"+ this.getString( date1.getMinutes() );
  687. }else{
  688. var now = new Date();
  689. defaultBeginTime = (now.getHours()+1)+":"+"00";
  690. date1 = now.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  691. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  692. defaultEndTime = (date1.getHours()+1)+":"+"00";
  693. }
  694. }else{
  695. this.date = new Date();
  696. defaultDate = this.date.clone().format("%Y-%m-%d");
  697. defaultBeginTime = (this.date.getHours()+1)+":"+"00";
  698. date1 = this.date.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  699. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  700. defaultEndTime = (date1.getHours()+1)+":"+"00";
  701. }
  702. this.formTableArea.setStyle("position","relative");
  703. var data = this.data;
  704. var isEditer = this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator();
  705. var editEnable = ( !this.isEdited && !this.isNew && this.data.status == "wait" && isEditer );
  706. var isEditing = this.isNew || (this.isEdited && this.data.status == "wait" && isEditer);
  707. var startImmediatelyEnable = false;
  708. if( editEnable && this.data.room){ //&& this.data.mode !== "online"
  709. if( MWF.AC.isMeetingAdministrator() ){
  710. startImmediatelyEnable = true;
  711. }else{
  712. if( this.userName == this.data.applicant || this.userId == this.data.applicant ){
  713. if( !this.app.meetingConfig.process )startImmediatelyEnable = true;
  714. }
  715. }
  716. }
  717. var finishImmediatelyEnable = false;
  718. if( isEditer && !this.isEdited && !this.isNew && this.data.status == "processing" && this.data.room){
  719. finishImmediatelyEnable = true;
  720. //if( this.data.mode === "online" )finishImmediatelyEnable = false;
  721. }
  722. this.isEditer = isEditer;
  723. this.editEnable = editEnable;
  724. this.isEditing = isEditing;
  725. this.startImmediatelyEnable = startImmediatelyEnable;
  726. this.finishImmediatelyEnable = finishImmediatelyEnable;
  727. var html = "<div item='qrCode' style='position: absolute;right:0px;top:-20px;width:150px;height:180px;'></div>" +
  728. (( this.isShowCurrentUserDelPersonInfor() ) ?
  729. "<div style='position: absolute;left:0px;top:-25px;height:20px;min-width:200px;color: rgb(246, 166, 35);'>"+this.lp.userDeleteInvitePerson+"</div>" : ""
  730. ) +
  731. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  732. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  733. "<tr>"+
  734. " <td styles='formTableTitle' width='70'>"+this.lp.applyPerson+":</td>" +
  735. " <td styles='formTableValue' item='applicant'></td>" +
  736. "</tr>"+
  737. "<tr><td styles='formTableTitle'>"+this.lp.meetingType+":</td>" +
  738. " <td styles='formTableValue'><div item='type'></div></td></tr>";
  739. if( this.app.isOnlineAvailable() ) {
  740. html += "<tr><td styles='formTableTitle'>" + this.lp.meetingMode + ":</td>" +
  741. " <td styles='formTableValue'><div item='mode'></div></td></tr>";
  742. }
  743. if( this.app.isOnlineAvailable() ){
  744. html += "<tr style='display:"+(data.mode === "online" ? "" : "none" )+";'><td styles='formTableTitle'>"+ this.lp.meetingUrl +":</td>" +
  745. " <td styles='formTableValue' item='roomLink'></td></tr>" +
  746. "<tr style='display:"+(data.mode === "online" ? "" : "none" )+";'><td styles='formTableTitle'>"+ this.lp.meetingNumber +":</td>" +
  747. " <td styles='formTableValue' item='roomId'></td></tr>";
  748. }
  749. html += "<tr><td styles='formTableTitle' width='100'>"+this.lp.beginDate+":</td>" +
  750. " <td styles='formTableValue' item='dateInput'></td>" +
  751. "</tr>" +
  752. "<tr><td styles='formTableTitle'>"+ this.lp.time +":</td>" +
  753. " <td styles='formTableValue'>" +
  754. " <div item='beginTimeInput' style='float:left'></div>"+
  755. " <div style='float:left; "+ ( isEditing ? "margin:5px;" : "margin:0px 5px;") + "'>"+ this.lp.to+ "</div>"+
  756. " <div item='endTimeInput' style='float:left'></div>"+
  757. " </td></tr>";
  758. html += "<tr style='display:"+(data.mode !== "online" ? "" : "" )+";'><td styles='formTableTitle'>"+ this.lp.selectRoom +":</td>" +
  759. " <td styles='formTableValue' item='meetingRoom'></td></tr>" +
  760. "<tr><td styles='formTableTitle'>"+this.lp.hostPerson+":</td>" +
  761. " <td styles='formTableValue'><div item='hostPerson'></div></td></tr>"+
  762. "<tr><td styles='formTableTitle'>"+this.lp.hostUnit+":</td>" +
  763. " <td styles='formTableValue'><div item='hostUnit'></div></td></tr>"+
  764. (this.isOnlyPerson() ? this.getHtmlOnlyPerson() : this.getHtmlWithGroup()) +
  765. "<tr style='display:"+ ( this.isNew ? "none" : "") +" ;' item='checkPersonTr'><td styles='formTableTitle'>"+this.lp.needSignInPerson+":</td>" +
  766. " <td styles='formTableValue' item='checkinPersonList'></td></tr>" +
  767. "<tr><td styles='formTableTitle'>"+this.lp.meetingSubject+":</td>" +
  768. " <td styles='formTableValue' item='subject'></td></tr>" +
  769. "<tr><td styles='formTableTitle'>"+this.lp.meetingDescription+":</td>" +
  770. " <td styles='formTableValue' item='summary'></td></tr>" +
  771. "<tr style='display:none ;' item='attachmentTr'><td styles='formTableTitle'>"+this.lp.meetingAttachment+":</td>" +
  772. " <td styles='formTableValue' item='attachment'></td></tr>" +
  773. // "<tr><td styles='formTableTitle'></td>" +
  774. // " <td styles='formTableValue' style='padding-top: 10px;'>"+
  775. // " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  776. // " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  777. // " <div item='startImmediatelyAction' style='float:left;display:"+ ( startImmediatelyEnable ? "" : "none") +";'></div>"+
  778. // " <div item='finishImmediatelyAction' style='float:left;display:"+ ( finishImmediatelyEnable ? "" : "none") +";'></div>"+
  779. // " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  780. // " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable || startImmediatelyEnable || finishImmediatelyEnable ) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  781. // " </td></tr>" +
  782. "</table>";
  783. this.formTableArea.set("html", html);
  784. if( data.startTime ){
  785. var beignDate = Date.parse( data.startTime );
  786. data.dateInput = beignDate.format("%Y-%m-%d");
  787. data.beginTimeInput = this.getString( beignDate.getHours() ) + ":" + this.getString( beignDate.getMinutes() );
  788. }
  789. if( data.completedTime ){
  790. var endDate = Date.parse( data.completedTime );
  791. data.endTimeInput = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  792. }
  793. this.meetingRoomArea = this.formTableArea.getElement("[item='meetingRoom']");
  794. this.attachmentTr = this.formTableArea.getElement("[item='attachmentTr']");
  795. this.attachmentArea = this.formTableArea.getElement("[item='attachment']");
  796. this.qrCodeArea = this.formTableArea.getElement("[item='qrCode']");
  797. MWF.xDesktop.requireApp("Template", "MForm", function () {
  798. this.form = new MForm(this.formTableArea, data, {
  799. isEdited: this.isEdited || this.isNew,
  800. style : "meeting",
  801. itemTemplate: {
  802. applicant : { type : "org", orgType : "person", isEdited : false,
  803. defaultValue : this.userName
  804. },
  805. mode: {type: "select", isEdited : isEditing,
  806. selectValue : this.lp.meetingModeSelectValue || [],
  807. selectText : this.lp.meetingModeSelectText || [],
  808. event : {
  809. change : function( item, ev ){
  810. this.changeMode();
  811. }.bind(this)
  812. }
  813. },
  814. dateInput: {tType: "date", isEdited : isEditing, defaultValue: defaultDate,
  815. event : {
  816. change : function( item, ev ){
  817. this.clearRoom();
  818. }.bind(this)
  819. }
  820. },
  821. beginTimeInput: { tType: "time", isEdited : isEditing,
  822. defaultValue: defaultBeginTime, className : ( isEditing ? "inputTimeUnformatWidth" : "" ),
  823. event : {
  824. change : function( item, ev ){
  825. this.clearRoom();
  826. }.bind(this)
  827. }
  828. },
  829. endTimeInput: { tType: "time", isEdited : isEditing,
  830. defaultValue: defaultEndTime, className : ( isEditing ? "inputTimeUnformatWidth" : "" ),
  831. event : {
  832. change : function( item, ev ){
  833. this.clearRoom();
  834. }.bind(this)
  835. }
  836. },
  837. invitePersonList: { type: "org", isEdited : this.isNew, orgType: ["identity","person"], count : 0, orgWidgetOptions : {
  838. "onLoadedInfor": function(item){
  839. // this.loadAcceptAndReject( item );
  840. }.bind(this)
  841. }},
  842. inviteMemberList: { type: "org", isEdited : isEditing, orgType: ["identity","person","group","unit"], count : 0, orgWidgetOptions : {
  843. "onLoadedInfor": function(item){
  844. // this.loadAcceptAndReject( item );
  845. }.bind(this)
  846. }},
  847. acceptPersonList: { type: "org", isEdited : false, orgType: ["identity","person","group","unit"], count : 0, orgWidgetOptions : {}},
  848. rejectPersonList: { type: "org", isEdited : false, orgType: ["identity","person","group","unit"], count : 0, orgWidgetOptions : {}},
  849. inviteDelPersonList: { type: "org", isEdited : false, orgType: ["identity","person"], count : 0},
  850. checkinPersonList : { type: "org", isEdited : false, orgType: ["identity","person"], count : 0},
  851. selectinvitePerson : { type : "button", value : this.lp.addInvitePerson1, style : {"float": "left"}, event : {
  852. click : function( it ){
  853. var options = {
  854. "type" : "identity",
  855. "resultType": "person",
  856. "exclude" : this.getInvitePersonExclude(),
  857. "values": [],
  858. "count": 0,
  859. "onComplete": function(items){
  860. MWF.require("MWF.widget.O2Identity", function(){
  861. var invitePersonList = items.map(function(item){
  862. return item.data.distinguishedName;
  863. }.bind(this));
  864. // items.each(function(item){
  865. // var _self = this;
  866. // if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  867. // var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  868. // invitePersonList.push( item.data.distinguishedName );
  869. // }else{
  870. // var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  871. // invitePersonList.push(item.data.distinguishedName);
  872. // }
  873. // }.bind(this));
  874. this.app.actions.addMeetingInvite(this.data.id, {"invitePersonList": invitePersonList, "id": this.data.id}, function(json){
  875. this.app.actions.getMeeting(json.data.id, function(meeting){
  876. this.data.invitePersonList = meeting.data.invitePersonList;
  877. this.reloadInvitePerson();
  878. this.checkShowDisInviateButton();
  879. this.app.notice(this.app.lp.addedInvitePerson1, "success", this.node );
  880. }.bind(this));
  881. }.bind(this));
  882. }.bind(this));
  883. }.bind(this)
  884. };
  885. var selector = new MWF.O2Selector(this.app.content, options);
  886. }.bind(this)
  887. } },
  888. selectDisinvitePerson : { type : "button", value : this.lp.deleteInvitePerson1, className : "inputButtonGrey", event : {
  889. click : function( it ){
  890. var options = {
  891. "title": this.lp.deleteInvitePerson1,
  892. "type": "identity",
  893. "include" : this.data.invitePersonList,
  894. "noUnit": true,
  895. "onlyMajorIdentity": true,
  896. "onComplete": function(items){
  897. MWF.require("MWF.widget.O2Identity", function(){
  898. var removeList = items.map(function(item){
  899. return item.data.distinguishedName;
  900. }.bind(this));
  901. o2.Actions.load("x_meeting_assemble_control").MeetingAction.deleteInvite(this.data.id, {"InvitePersonList": removeList}, function(json){
  902. this.app.actions.getMeeting(json.data.id, function(meeting){
  903. this.data.invitePersonList = meeting.data.invitePersonList;
  904. this.data.inviteDelPersonList = meeting.data.inviteDelPersonList;
  905. this.reloadInvitePerson();
  906. this.reloadinviteDelPerson();
  907. this.checkShowInviteDelPersonList();
  908. this.checkShowDisInviateButton();
  909. this.app.notice(this.app.lp.deleteInvitePerson, "success", this.node );
  910. }.bind(this));
  911. }.bind(this));
  912. }.bind(this));
  913. }.bind(this)
  914. };
  915. var selector = new MWF.O2Selector(this.app.content, options);
  916. }.bind(this)
  917. } },
  918. subject: {},
  919. roomLink: {
  920. type: this.app.isAutoCreateOnlineRoom() ? ( this.isNew ? "text" : "innerText" ) : "text",
  921. attr: {
  922. readonly: this.app.isAutoCreateOnlineRoom(),
  923. placeholder: this.app.isAutoCreateOnlineRoom() ? this.lp.createOnSave: ""
  924. }
  925. },
  926. roomId: {
  927. type: this.app.isAutoCreateOnlineRoom() ? ( this.isNew ? "text" : "innerText" ) : "text",
  928. attr: {
  929. readonly: this.app.isAutoCreateOnlineRoom(),
  930. placeholder: this.app.isAutoCreateOnlineRoom() ? this.lp.createOnSave: ""
  931. }
  932. },
  933. summary: {type: "textarea"},
  934. hostPerson: { type : "org", orgType : "identity", count: 1, "defaultValue": this.getIdentity(), orgOptions: {"resultType": "person"} },
  935. hostUnit: { type : "org", orgType : "unit", count: 1 },
  936. type: {
  937. type : (this.app.meetingConfig.typeList && this.app.meetingConfig.typeList.length) ? "select" : "text",
  938. selectValue : this.app.meetingConfig.typeList || [],
  939. selectText : this.app.meetingConfig.typeList || [],
  940. notEmpty: true
  941. },
  942. acceptAction : { type : "button", value : this.lp.accept, className : "inputAcceptButton", clazz: "mainColor_bg",
  943. event : { click : function( it, ev ){ this.accept(ev); }.bind(this) }
  944. },
  945. rejectAction : { type : "button", value : this.lp.reject, style : {"margin-left": "20px"}, className : "inputDenyButton",
  946. event : { click : function( it, ev ){ this.reject(ev) }.bind(this) }
  947. }
  948. }
  949. }, this.app);
  950. this.form.load();
  951. if( isEditing ){
  952. this.loadSelectRoom();
  953. }else{
  954. this.loadSelectRoom_read();
  955. }
  956. if( this.data.id )this.loadAttachment();
  957. if( isEditer && !this.isNew && !this.isEdited && data.mode !== "online"){
  958. this.loadQrCode();
  959. }else{
  960. this.qrCodeArea.destroy();
  961. }
  962. if( this.data.mode === "online" ){
  963. if( !isEditing ){
  964. this.loadRoomUrl_read();
  965. }else if( this.app.isAutoCreateOnlineRoom() ){
  966. if( this.data.roomLink || this.data.roomId ){
  967. this.loadRoomUrl_read();
  968. }
  969. }
  970. }
  971. }.bind(this), true);
  972. },
  973. _createBottomContent: function(){
  974. var editEnable = this.editEnable;
  975. var startImmediatelyEnable = this.startImmediatelyEnable;
  976. var finishImmediatelyEnable = this.finishImmediatelyEnable;
  977. var html = "<div style='width: 700px;margin:0px auto;'><table><tr><td styles='formTableTitle' width='80'></td>" +
  978. " <td styles='formTableValue' style='padding-top: 10px;'>"+
  979. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  980. " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  981. " <div item='startImmediatelyAction' style='float:left;display:"+ ( startImmediatelyEnable ? "" : "none") +";'></div>"+
  982. " <div item='finishImmediatelyAction' style='float:left;display:"+ ( finishImmediatelyEnable ? "" : "none") +";'></div>"+
  983. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  984. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable || startImmediatelyEnable || finishImmediatelyEnable ) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  985. " </td></tr></table></div>";
  986. this.formBottomNode.set("html", html);
  987. MWF.xDesktop.requireApp("Template", "MForm", function () {
  988. this.actionForm = new MForm(this.formBottomNode, {}, {
  989. isEdited: this.isEdited || this.isNew,
  990. style: "meeting",
  991. itemTemplate: {
  992. saveAction: {
  993. type: "button", className: "inputOkButton", clazz: "mainColor_bg", value: this.lp.save, event: {
  994. click: function () {
  995. this.save();
  996. }.bind(this)
  997. }
  998. },
  999. removeAction: {
  1000. type: "button", className: "inputCancelButton", value: this.lp.cancelMeeting, event: {
  1001. click: function (item, ev) {
  1002. this.cancelMeeting(ev);
  1003. }.bind(this)
  1004. }
  1005. },
  1006. editAction: {
  1007. type: "button", className: "inputOkButton", clazz: "mainColor_bg", value: this.lp.editMeeting, event: {
  1008. click: function () {
  1009. this.editMeeting();
  1010. }.bind(this)
  1011. }
  1012. },
  1013. startImmediatelyAction: {
  1014. type: "button", className: "inputCancelButton", value: this.lp.startMeetingImmediately, event: {
  1015. click: function () {
  1016. this.startImmediately();
  1017. }.bind(this)
  1018. }
  1019. },
  1020. finishImmediatelyAction: {
  1021. type: "button", className: "inputCancelButton", value: this.lp.endMeetingImmediately, event: {
  1022. click: function () {
  1023. this.finishImmediately();
  1024. }.bind(this)
  1025. }
  1026. },
  1027. cancelAction: {
  1028. type: "button", className: "inputCancelButton", value: this.lp.close, event: {
  1029. click: function () {
  1030. this.close();
  1031. }.bind(this)
  1032. }
  1033. }
  1034. }
  1035. }, this.app);
  1036. this.actionForm.load();
  1037. }.bind(this))
  1038. },
  1039. isOnlyPerson: function(){
  1040. return (!this.data.inviteMemberList || this.data.inviteMemberList.length === 0 ) &&
  1041. (this.data.invitePersonList && this.data.invitePersonList.length > 0 )
  1042. },
  1043. getHtmlWithGroup: function(){
  1044. return "<tr><td styles='formTableTitle'>"+this.lp.invitePerson2+":</td>" +
  1045. " <td styles='formTableValue' style='overflow: hidden;'>" +
  1046. " <div item='inviteMemberList'></div>" +
  1047. " </td>" +
  1048. "</tr>"+
  1049. (( !this.isNew && this.data.myWaitAccept ) ?
  1050. "<tr><td></td><td styles='formTableValue'><div item='acceptAction'></div><div item='rejectAction'></div></td></tr>" : ""
  1051. ) +
  1052. "<tr style='display:"+((this.data.acceptPersonList && this.data.acceptPersonList.length)?'':'none')+"'>" +
  1053. " <td styles='formTableTitle'>"+this.lp.acceptPerson+":</td>" +
  1054. " <td styles='formTableValue'><div item='acceptPersonList'></div></td></tr>"+
  1055. "<tr style='display:"+((this.data.rejectPersonList && this.data.rejectPersonList.length)?'':'none')+"'>" +
  1056. " <td styles='formTableTitle'>"+this.lp.rejectPerson+":</td>" +
  1057. " <td styles='formTableValue'><div item='rejectPersonList'></div></td></tr>"+
  1058. "<tr style='display:"+(this.isShowInviteDelPersonList()?'':'none')+"' class='inviteDelPersonListTr'>" +
  1059. " <td styles='formTableTitle'>"+this.lp.deleteInvitePerson2+":</td>" +
  1060. " <td styles='formTableValue'><div item='inviteDelPersonList'></div></td></tr>";
  1061. },
  1062. getHtmlOnlyPerson: function(){
  1063. return "<tr><td styles='formTableTitle'>"+this.lp.invitePerson2+":</td>" +
  1064. " <td styles='formTableValue' style='overflow: hidden;'>" +
  1065. " <div item='invitePersonList'></div>" +
  1066. " <div style='display:"+ ( this.isEdited ? "" : "none") +";float:left; margin-left:20px;' item='selectinvitePerson'></div>" +
  1067. " <div style='display:"+ ( this.isShowDisInviateButton() ? "" : "none") +";float:left; margin-left:20px;' item='selectDisinvitePerson'></div>" +
  1068. " </td>" +
  1069. "</tr>" +
  1070. (( !this.isNew && this.data.myWaitAccept ) ?
  1071. "<tr><td></td><td styles='formTableValue'><div item='acceptAction'></div><div item='rejectAction'></div></td></tr>" : ""
  1072. ) +
  1073. "<tr style='display:"+((this.data.acceptPersonList && this.data.acceptPersonList.length)?'':'none')+"'>" +
  1074. " <td styles='formTableTitle'>"+this.lp.acceptPerson+":</td>" +
  1075. " <td styles='formTableValue'><div item='acceptPersonList'></div></td></tr>"+
  1076. "<tr style='display:"+((this.data.rejectPersonList && this.data.rejectPersonList.length)?'':'none')+"'>" +
  1077. " <td styles='formTableTitle'>"+this.lp.rejectPerson+":</td>" +
  1078. " <td styles='formTableValue'><div item='rejectPersonList'></div></td></tr>"+
  1079. "<tr style='display:"+(this.isShowInviteDelPersonList()?'':'none')+"' class='inviteDelPersonListTr'>" +
  1080. " <td styles='formTableTitle'>"+this.lp.deleteInvitePerson2+":</td>" +
  1081. " <td styles='formTableValue'><div item='inviteDelPersonList'></div></td></tr>";
  1082. },
  1083. reloadInvitePerson: function(){
  1084. if(!this.form)return;
  1085. this.form.getItem("invitePersonList").setValue(this.data.invitePersonList);
  1086. // var container = this.form.getItem("invitePersonList").container;
  1087. // container.empty();
  1088. // this.data.invitePersonList.each(function(item){
  1089. // var _self = this;
  1090. // if( item.split("@").getLast().toLowerCase() === "i" ){
  1091. // new MWF.widget.O2Identity(item, container, {"style": "room"});
  1092. // }else{
  1093. // new MWF.widget.O2Person(item, container, {"style": "room"});
  1094. // }
  1095. // }.bind(this));
  1096. },
  1097. isShowDisInviateButton : function (){
  1098. return this.isEdited && this.data.invitePersonList && this.data.invitePersonList.length > 0;
  1099. },
  1100. checkShowDisInviateButton: function(){
  1101. var node = this.formTableArea.getElement("[item='selectDisinvitePerson']");
  1102. node.setStyle( "display", this.isShowDisInviateButton() ? "" : "none" );
  1103. },
  1104. isShowInviteDelPersonList : function () {
  1105. return this.isEdited && this.data.inviteDelPersonList && this.data.inviteDelPersonList.length > 0;
  1106. },
  1107. checkShowInviteDelPersonList: function(){
  1108. var node = this.formTableArea.getElement('.inviteDelPersonListTr');
  1109. node.setStyle( "display", this.isShowInviteDelPersonList() ? "" : "none" );
  1110. },
  1111. isShowCurrentUserDelPersonInfor : function () {
  1112. return (!this.isEdited) && (this.data.inviteDelPersonList||[]).contains(this.userName) && !(this.data.invitePersonList||[]).contains(this.userName);
  1113. },
  1114. loadRoomUrl_read: function(){
  1115. var node;
  1116. if( this.data.roomLink ){
  1117. this.onlineRoomLink = this.data.roomLink;
  1118. node = this.formTableArea.getElement("[item='roomLink']");
  1119. node.empty();
  1120. new Element("span", { text: this.data.roomLink, name: "roomLink", style: "display:none;" }).inject( node );
  1121. new Element("a", {
  1122. style: "font-size:14px;",
  1123. href: this.data.roomLink,
  1124. text: this.lp.openMeetingUrl,
  1125. target: "_blank"
  1126. }).inject( node );
  1127. }
  1128. if( this.data.roomId ){
  1129. this.onlineRoomId = this.data.roomId;
  1130. node = this.formTableArea.getElement("[item='roomId']");
  1131. node.empty();
  1132. new Element("span", { text: this.data.roomId, name: "roomId" }).inject( node );
  1133. // this.app.isCopyEnable().then(function(flag){
  1134. // if( flag ){
  1135. // new Element("div", {
  1136. // "text": this.lp.copy,
  1137. // "styles": this.app.css.inputDenyButton,
  1138. // "events": {
  1139. // "click": function (){ this.app.copyTextToClipboard(this.data.roomId) }.bind(this)
  1140. // }
  1141. // }).inject( node );
  1142. // }
  1143. // }.bind(this))
  1144. }
  1145. },
  1146. reloadinviteDelPerson: function(){
  1147. if(!this.form)return;
  1148. this.form.getItem("inviteDelPersonList").setValue(this.data.inviteDelPersonList);
  1149. // var container = this.form.getItem("inviteDelPersonList").container;
  1150. // container.empty();
  1151. // this.data.inviteDelPersonList.each(function(item){
  1152. // var _self = this;
  1153. // if( item.split("@").getLast().toLowerCase() === "i" ){
  1154. // new MWF.widget.O2Identity(item, container, {"style": "room"});
  1155. // }else{
  1156. // new MWF.widget.O2Person(item, container, {"style": "room"});
  1157. // }
  1158. // }.bind(this));
  1159. },
  1160. startImmediately : function(){
  1161. o2.Actions.load("x_meeting_assemble_control").MeetingAction.editStartTime( this.data.id, {
  1162. room : this.roomId || this.data.room,
  1163. startTime : ( new Date() ).format("db")
  1164. }, function () {
  1165. this.app.notice( this.lp.startMeetingSucccess, "success");
  1166. this.waitReload = true;
  1167. this.reload()
  1168. }.bind(this))
  1169. },
  1170. finishImmediately : function(){
  1171. o2.Actions.load("x_meeting_assemble_control").MeetingAction.editCompletedTime( this.data.id, {
  1172. room : this.roomId || this.data.room,
  1173. completedTime : ( new Date() ).format("db")
  1174. }, function () {
  1175. this.app.notice( this.lp.endMeetingSucccess, "success");
  1176. this.waitReload = true;
  1177. this.reload()
  1178. }.bind(this))
  1179. },
  1180. getInvitePersonExclude : function(){
  1181. var invitePersonList = this.invitePersonList || this.data.invitePersonList;
  1182. var identityList = [];
  1183. if( invitePersonList.length > 0 ){
  1184. o2.Actions.load("x_organization_assemble_express").IdentityAction.listWithPerson({
  1185. personList : invitePersonList
  1186. }, function( json ){
  1187. identityList = json.data ? json.data.identityList : [];
  1188. }, null ,false );
  1189. return ( identityList || [] ).concat(invitePersonList);
  1190. }else{
  1191. return [];
  1192. }
  1193. },
  1194. getString : function( str ){
  1195. var s = "00" + str;
  1196. return s.substr(s.length - 2, 2 );
  1197. },
  1198. loadQrCode : function(){
  1199. this.actions.getCheckinQrCode( this.data.id, function(json){
  1200. var img = new Element("img",{
  1201. src : "data:image/png;base64,"+json.data.image,
  1202. styles : {
  1203. width : "150px",
  1204. height : "150px"
  1205. }
  1206. }).inject( this.qrCodeArea );
  1207. var div = new Element("div",{
  1208. text : this.app.lp.printQrcode,
  1209. styles : {
  1210. "color" : "#3c75b7",
  1211. "cursor" : "pointer",
  1212. "text-align": "center"
  1213. },
  1214. events : {
  1215. click : function(){
  1216. window.open(o2.filterUrl("../x_desktop/meetingQrPrint.html?meeting="+this.data.id), "_blank" );
  1217. }.bind(this)
  1218. }
  1219. }).inject( this.qrCodeArea );
  1220. }.bind(this));
  1221. },
  1222. loadAcceptAndReject : function( item ){
  1223. var personName = item.data.distinguishedName;
  1224. if(this.data.acceptPersonList){
  1225. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  1226. var acceptNode = new Element("div", {"styles": this.css.acceptIconNode}).inject(item.node, "top");
  1227. new Element("div", {
  1228. "styles": this.css.acceptTextNode,
  1229. "text": this.app.lp.accepted
  1230. }).inject(item.inforNode);
  1231. }
  1232. }
  1233. if(this.data.rejectPersonList){
  1234. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  1235. var rejectNode = new Element("div", {"styles": this.css.rejectIconNode}).inject(item.node, "top");
  1236. new Element("div", {
  1237. "styles": this.css.rejectTextNode,
  1238. "text": this.app.lp.rejected
  1239. }).inject(item.inforNode);
  1240. }
  1241. }
  1242. },
  1243. getMeetingData : function( callback ){
  1244. if( this.data && this.data.id ){
  1245. ( this.app.actions || this.actions ).getMeeting( this.data.id, function( json ){
  1246. this.data = json.data;
  1247. if(callback)callback();
  1248. }.bind(this))
  1249. }else{
  1250. if(callback)callback();
  1251. }
  1252. },
  1253. editMeeting : function(){
  1254. this.formTopNode = null;
  1255. if(this.setFormNodeSizeFun && this.app ){
  1256. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1257. }
  1258. if( this.formMaskNode )this.formMaskNode.destroy();
  1259. this.formAreaNode.destroy();
  1260. this.edit();
  1261. },
  1262. cancelMeeting: function(e){
  1263. var _self = this;
  1264. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  1265. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 400, 200, function(){
  1266. _self._cancelMeeting();
  1267. this.close();
  1268. _self.close();
  1269. }, function(){
  1270. this.close();
  1271. });
  1272. },
  1273. _cancelMeeting: function(){
  1274. var view = this.view;
  1275. this.app.actions.deleteMeeting(this.data.id, function(){
  1276. view.reload();
  1277. }.bind(this))
  1278. },
  1279. reset: function(){
  1280. this.formTableArea.empty();
  1281. this._createTableContent();
  1282. },
  1283. changeMode: function(){
  1284. var mode = this.form.getItem("mode").getValue();
  1285. if( mode === "online" ){
  1286. this.form.getItem("roomLink").node.getParent("tr").setStyle("display", "");
  1287. this.form.getItem("roomId").node.getParent("tr").setStyle("display", "");
  1288. // this.meetingRoomArea.getParent("tr").setStyle("display", "none");
  1289. }else{
  1290. this.form.getItem("roomLink").node.getParent("tr").setStyle("display", "none");
  1291. this.form.getItem("roomId").node.getParent("tr").setStyle("display", "none");
  1292. // this.meetingRoomArea.getParent("tr").setStyle("display", "");
  1293. }
  1294. //this.resetHeight("auto");
  1295. },
  1296. clearRoom : function(){
  1297. this.roomId = "";
  1298. if(this.roomInput)this.roomInput.set("text", "");
  1299. },
  1300. loadSelectRoom_read : function(){
  1301. var roomId = this.data.room || this.options.room;
  1302. if (roomId){
  1303. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  1304. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  1305. this.roomId = roomId;
  1306. this.meetingRoomArea.set("text", json.data.name+" ("+bjson.data.name+")");
  1307. }.bind(this));
  1308. }.bind(this));
  1309. }
  1310. },
  1311. loadSelectRoom: function(){
  1312. var css = this.app.css;
  1313. var lineNode = new Element("div", {"styles": css.createMeetingInfoLineNode}).inject(this.meetingRoomArea);
  1314. var editNode = new Element("div", {
  1315. "styles": css.createMeetingInfoItemEditNode,
  1316. "html": "<div></div>"
  1317. }).inject(lineNode);
  1318. this.roomInput = editNode.getFirst();
  1319. this.roomInput.setStyles( css.createMeetingInfoItemDivNode);
  1320. //var downNode = new Element("div", {"styles": this.css.createMeetingInfoItemDownNode}).inject(editNode);
  1321. this.roomInput.addEvents({
  1322. "click": function(e){this.selectRooms();}.bind(this)
  1323. });
  1324. var roomId = this.data.room || this.options.room;
  1325. if (roomId){
  1326. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  1327. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  1328. this.roomId = roomId;
  1329. this.roomInput.set("text", json.data.name+" ("+bjson.data.name+")");
  1330. }.bind(this));
  1331. }.bind(this));
  1332. }
  1333. },
  1334. selectRooms: function(){
  1335. this.createRoomNode(function(){
  1336. this.loadSelectRooms();
  1337. this.selectRoomNode.setStyle("display", "block");
  1338. this.hideRoomNodeFun = this.hideRoomNode.bind(this);
  1339. document.body.addEvent("mousedown", this.hideRoomNodeFun);
  1340. //var p = this.selectRoomNode.getPosition(this.selectRoomNode.getOffsetParent());
  1341. this.selectRoomNode.position({
  1342. relativeTo: this.roomInput,
  1343. position: 'bottomLeft',
  1344. edge: 'upperLeft',
  1345. offset: {x: 0, y: 0}
  1346. });
  1347. var size = this.roomInput.getSize();
  1348. var w = size.x-2;
  1349. this.selectRoomNode.setStyle("width", ""+w+"px");
  1350. }.bind(this));
  1351. },
  1352. createRoomNode: function(callback){
  1353. var css = this.app.css;
  1354. if (!this.selectRoomNode){
  1355. this.selectRoomNode = new Element("div", {"styles": css.createMeetingInfoSelectRoomNode}).inject(this.formNode);
  1356. this.selectRoomNode.addEvent("mousedown", function(e){e.stopPropagation();});
  1357. if (callback) callback();
  1358. }else{
  1359. if (callback) callback();
  1360. }
  1361. },
  1362. loadSelectRooms: function(){
  1363. var css = this.app.css;
  1364. var result = this.form.getResult(false,null,false,false,true);
  1365. var d = result.dateInput;
  1366. var bt = result.beginTimeInput;
  1367. var et = result.endTimeInput;
  1368. var start = d+" "+bt;
  1369. var completed = d+" "+et;
  1370. var success = function(json){
  1371. json.data.each(function(building){
  1372. var node = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1Node}).inject(this.selectRoomNode);
  1373. var nodeName = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1NameNode, "text": building.name}).inject(node);
  1374. var nodeAddr = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1AddrNode, "text": building.address}).inject(node);
  1375. building.roomList.each(function(room, i){
  1376. if (room.available && room.idle) this.createRoomSelectNode(room, i, building);
  1377. }.bind(this));
  1378. }.bind(this));
  1379. }.bind(this);
  1380. if( this.isEdited && this.data.room ){
  1381. o2.Actions.load("x_meeting_assemble_control").BuildingAction.listWithStartCompletedRoom( start, completed, this.data.room, this.data.id, function ( json ) {
  1382. success( json );
  1383. }
  1384. )
  1385. }else{
  1386. this.app.actions.listBuildingByRange(start, completed, function(json){
  1387. success( json )
  1388. }.bind(this));
  1389. }
  1390. },
  1391. createRoomSelectNode: function(room, i, building){
  1392. var css = this.app.css;
  1393. var roomNode = new Element("div", {"styles": css.roomTitleNode}).inject(this.selectRoomNode);
  1394. var capacityNode = new Element("div", {"styles": css.roomTitleCapacityNode, "text": room.capacity+this.lp.person}).inject(roomNode);
  1395. var inforNode = new Element("div", {"styles": css.roomTitleInforNode}).inject(roomNode);
  1396. var node = new Element("div", {"styles": {"height": "20px"}}).inject(inforNode);
  1397. var numberNode = new Element("div", {"styles": css.roomTitleNumberNode, "text": (room.roomNumber) ? "#"+room.roomNumber : ""}).inject(node);
  1398. var nameNode = new Element("div", {"styles": css.roomTitleNameNode, "text": room.name}).inject(node);
  1399. var iconsNode = new Element("div", {"styles": css.roomTitleIconsNode}).inject(inforNode);
  1400. var deviceList = ( room.device || "" ).split("#");
  1401. deviceList.each(function(name){
  1402. if( name ){
  1403. var node = new Element("div", {"styles": css.roomTitleIconNode, "title": this.lp.device[name]}).inject(iconsNode);
  1404. node.setStyle("background-image", "url(../x_component_Meeting/$RoomView/default/icon/device/"+name+"_disable.png)");
  1405. }
  1406. }.bind(this));
  1407. if ((i % 2)!=0) roomNode.setStyle("background-color", "#f4f8ff");
  1408. roomNode.store("room", room);
  1409. var _self = this;
  1410. if (room.idle){
  1411. roomNode.addEvents({
  1412. "mouseover": function(e){
  1413. var color = roomNode.getStyle("background-color");
  1414. this.store("bgcolor", color);
  1415. this.setStyle("background-color", "#e4edfc");
  1416. },
  1417. "mouseout": function(){
  1418. var color = this.retrieve("bgcolor", "#FFF");
  1419. this.setStyle("background-color", color);
  1420. },
  1421. "click": function(){
  1422. var roomData = this.retrieve("room");
  1423. _self.roomId = roomData.id;
  1424. //roomNode.inject(_self.roomInput);
  1425. _self.roomInput.set("text", roomData.name+" ("+building.name+")");
  1426. _self.hideRoomNode();
  1427. }
  1428. });
  1429. }else{
  1430. roomNode.setStyle("background-color", "#fff6f6");
  1431. var disabledNode = new Element("div", {"styles": css.roomTitleDisabledIconNode}).inject(roomNode);
  1432. }
  1433. },
  1434. hideRoomNode: function(){
  1435. this.selectRoomNode.empty();
  1436. this.selectRoomNode.setStyle("display", "none");
  1437. document.body.removeEvent("mousedown", this.hideRoomNodeFun);
  1438. },
  1439. setCreateRoomSelectBuildingNodeSize: function(){
  1440. var p = this.createRoomBuildingInput.getPosition(this.createRoomBuildingInput.getOffsetParent());
  1441. this.createRoomSelectBuildingNode.position({
  1442. relativeTo: this.createRoomBuildingInput,
  1443. position: 'bottomCenter',
  1444. edge: 'upperCenter',
  1445. offset: {x: 0, y: 0}
  1446. });
  1447. this.createRoomSelectBuildingNode.setStyle("left", p.x);
  1448. var size = this.createRoomBuildingInput.getSize();
  1449. var w = size.x-2;
  1450. this.createRoomSelectBuildingNode.setStyle("width", ""+w+"px");
  1451. },
  1452. loadAttachment: function(){
  1453. this.attachmentTr.setStyle("display","");
  1454. this.attachmentNode = new Element("div", {"styles": this.css.createMeetingAttachmentNode}).inject(this.attachmentArea);
  1455. var attachmentContentNode = new Element("div", {"styles": this.css.createMeetingAttachmentContentNode}).inject(this.attachmentNode);
  1456. MWF.require("MWF.widget.AttachmentController", function(){
  1457. this.attachmentController = new MWF.widget.AttachmentController(attachmentContentNode, this, {
  1458. "size": "min",
  1459. "isSizeChange": false,
  1460. "isReplace": false,
  1461. "isUpload": this.isNew || this.isEdited,
  1462. "isDelete": this.isNew || this.isEdited,
  1463. "isDownload": true,
  1464. "readonly": !this.isNew && !this.isEdited
  1465. });
  1466. this.attachmentController.load();
  1467. if( this.data.attachmentList ){
  1468. this.data.attachmentList.each(function (att) {
  1469. att.person = att.lastUpdatePerson.split("@")[0];
  1470. var at = this.attachmentController.addAttachment(att);
  1471. }.bind(this));
  1472. }
  1473. }.bind(this));
  1474. },
  1475. uploadAttachment: function(e, node){
  1476. if (!this.uploadFileAreaNode){
  1477. this.createUploadFileNode();
  1478. }
  1479. this.fileUploadNode.click();
  1480. },
  1481. createUploadFileNode: function(){
  1482. this.uploadFileAreaNode = new Element("div");
  1483. var html = "<input name=\"file\" type=\"file\" multiple/>";
  1484. this.uploadFileAreaNode.set("html", html);
  1485. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1486. this.fileUploadNode.addEvent("change", function(){
  1487. var files = this.fileUploadNode.files;
  1488. if (files.length){
  1489. for (var i = 0; i < files.length; i++) {
  1490. var file = files.item(i);
  1491. var formData = new FormData();
  1492. formData.append('file', file);
  1493. //formData.append('folder', folderId);
  1494. this.app.actions.addAttachment(this.data.id, formData, file, function(o, text){
  1495. if (o.id){
  1496. this.app.actions.getAttachment(o.id, function(json){
  1497. if (json.data) this.attachmentController.addAttachment(json.data);
  1498. this.attachmentController.checkActions();
  1499. }.bind(this))
  1500. }
  1501. this.attachmentController.checkActions();
  1502. }.bind(this));
  1503. }
  1504. }
  1505. }.bind(this));
  1506. },
  1507. deleteAttachments: function(e, node, attachments){
  1508. var names = [];
  1509. attachments.each(function(attachment){
  1510. names.push(attachment.data.name);
  1511. }.bind(this));
  1512. var _self = this;
  1513. this.app.confirm("warn", e, this.lp.deleteAttachmentTitle, this.lp.deleteAttachment+"( "+names.join(", ")+" )", 300, 120, function(){
  1514. while (attachments.length){
  1515. attachment = attachments.shift();
  1516. _self.deleteAttachment(attachment);
  1517. }
  1518. this.close();
  1519. }, function(){
  1520. this.close();
  1521. }, null);
  1522. },
  1523. deleteAttachment: function(attachment){
  1524. this.app.actions.deleteFile(attachment.data.id, function(josn){
  1525. this.attachmentController.removeAttachment(attachment);
  1526. this.attachmentController.checkActions();
  1527. }.bind(this));
  1528. },
  1529. downloadAttachment: function(e, node, attachments){
  1530. attachments.each(function(att){
  1531. this.app.actions.getFileDownload(att.data.id);
  1532. }.bind(this));
  1533. },
  1534. openAttachment: function(e, node, attachments){
  1535. attachments.each(function(att){
  1536. this.app.actions.getFile(att.data.id);
  1537. }.bind(this));
  1538. },
  1539. getAttachmentUrl: function(attachment, callback){
  1540. this.app.actions.getFileUrl(attachment.data.id, callback);
  1541. },
  1542. save: function(){
  1543. this._save(function(){
  1544. this.app.notice(this.lp.meeting_saveSuccess, "success");
  1545. if (!this.attachmentNode){
  1546. this.loadAttachment();
  1547. if( this.data.mode === "online" ){
  1548. o2.Actions.load("x_meeting_assemble_control").MeetingAction.get( this.data.id, function (json) {
  1549. this.data.roomLink = json.data.roomLink;
  1550. this.data.roomId = json.data.roomId;
  1551. if( this.data.mode === "online" && this.app.isAutoCreateOnlineRoom() ){
  1552. this.loadRoomUrl_read();
  1553. }
  1554. }.bind(this))
  1555. }
  1556. //this.resetHeight("auto", 30);
  1557. }
  1558. }.bind(this));
  1559. },
  1560. _save: function(callback){
  1561. this.getSaveData();
  1562. var now = new Date();
  1563. var errorText = "";
  1564. if (!this.data.subject) {
  1565. if( !errorText )this.formTableArea.getElement("[item='subject']").scrollIntoView(false);
  1566. errorText +=this.lp.meeting_input_subject_error;
  1567. }
  1568. if( this.data.mode === "online" ){
  1569. if ( !this.app.isAutoCreateOnlineRoom() && !this.data.roomLink && !this.data.roomId ) {
  1570. if( !errorText )this.formTableArea.getElement("[item='roomLink']").scrollIntoView(false);
  1571. errorText +=this.lp.meeting_input_url_number_error;
  1572. }
  1573. }else{
  1574. if (!this.data.room) {
  1575. if( !errorText )this.formTableArea.getElement("[item='meetingRoom']").scrollIntoView(false);
  1576. errorText +=this.lp.meeting_input_room_error;
  1577. }
  1578. }
  1579. if ((!this.data.invitePersonList || !this.data.invitePersonList.length) && (!this.data.inviteMemberList || !this.data.inviteMemberList.length)){
  1580. if( !errorText && this.formTableArea.getElement("[item='inviteMemberList']")){
  1581. this.formTableArea.getElement("[item='inviteMemberList']").scrollIntoView(false);
  1582. }
  1583. errorText +=this.lp.meeting_input_person_error;
  1584. }
  1585. if( this.data.startTimeDate ){
  1586. if (this.data.startTimeDate.diff(this.data.completedTimeDate, "minute")<1) errorText +=this.lp.meeting_input_time_error;
  1587. if (now.diff(this.data.startTimeDate, "minute")<0) errorText +=this.lp.meeting_input_date_error;
  1588. delete this.data.startTimeDate;
  1589. delete this.data.completedTimeDate;
  1590. }
  1591. if (errorText){
  1592. this.app.notice(this.lp.meeting_input_error+errorText, "error");
  1593. return false;
  1594. }
  1595. this.app.actions.saveMeeting(this.data, function(json){
  1596. this.data.id = json.data.id;
  1597. this.waitReload = true;
  1598. if (callback) callback();
  1599. }.bind(this));
  1600. },
  1601. getSaveData: function(){
  1602. debugger;
  1603. this.data = this.form.getResult(false,null,false,false,true);
  1604. if( this.onlineRoomLink )this.data.roomLink = this.onlineRoomLink;
  1605. if( this.onlineRoomId )this.data.roomId = this.onlineRoomId; //在线会议室ID
  1606. this.data.room = this.roomId;
  1607. if( this.invitePersonList ){
  1608. this.data.invitePersonList = this.invitePersonList;
  1609. }
  1610. if( o2.typeOf( this.data.hostPerson ) === "array" ){
  1611. this.data.hostPerson = this.data.hostPerson[0];
  1612. }
  1613. if( o2.typeOf( this.data.hostUnit ) === "array" ){
  1614. this.data.hostUnit = this.data.hostUnit[0];
  1615. }
  1616. var d = this.data.dateInput;
  1617. // if( this.isNew ) {
  1618. var startTime = d + " " + this.data.beginTimeInput + ":0";
  1619. var completedTime = d + " " + this.data.endTimeInput + ":0";
  1620. var startTimeDate = Date.parse(startTime);
  1621. var completedTimeDate = Date.parse(completedTime);
  1622. this.data.startTime = startTime;
  1623. this.data.completedTime = completedTime;
  1624. this.data.startTimeDate = startTimeDate;
  1625. this.data.completedTimeDate = completedTimeDate;
  1626. // }
  1627. if( this.isNew ){
  1628. delete this.data.applicant;
  1629. }else{
  1630. this.data.applicant = this.data.applicant.join(",")
  1631. }
  1632. },
  1633. getPersonByIdentity : function( identity ){
  1634. },
  1635. getPerson : function( source ){
  1636. if( typeOf(source) != "array" )source = [source];
  1637. var target = [];
  1638. source.each( function( s ){
  1639. if( s.split("@").getLast().toLowerCase() == "i" ){
  1640. target.push( this.getPersonByIdentity( s ) )
  1641. }else{
  1642. target.push( s )
  1643. }
  1644. }.bind(this));
  1645. return target;
  1646. },
  1647. reject: function(e){
  1648. var _self = this;
  1649. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1650. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1651. _self.rejectMeeting();
  1652. this.close();
  1653. _self.close();
  1654. }, function(){
  1655. this.close();
  1656. });
  1657. },
  1658. rejectMeeting: function(){
  1659. var view = this.view;
  1660. this.app.actions.rejectMeeting(this.data.id, function(){
  1661. view.reload();
  1662. }.bind(this))
  1663. },
  1664. accept: function(e){
  1665. var _self = this;
  1666. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1667. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1668. _self.acceptMeeting();
  1669. this.close();
  1670. _self.close();
  1671. }, function(){
  1672. this.close();
  1673. });
  1674. },
  1675. acceptMeeting: function(){
  1676. var view = this.view;
  1677. this.app.actions.acceptMeeting(this.data.id, function(){
  1678. view.reload();
  1679. }.bind(this))
  1680. },
  1681. close: function (e) {
  1682. this.fireEvent("queryClose");
  1683. this._close();
  1684. //if( this.form ){
  1685. // this.form.destroy();
  1686. //}
  1687. if(this.setFormNodeSizeFun && this.app ){
  1688. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1689. }
  1690. if( this.formMaskNode )this.formMaskNode.destroy();
  1691. this.formAreaNode.destroy();
  1692. this.fireEvent("postClose");
  1693. if( this.waitReload )this.view.reload();
  1694. delete this;
  1695. }
  1696. });
  1697. MWF.xApplication.Meeting.MeetingTooltip = new Class({
  1698. Extends: MTooltips,
  1699. _loadCustom : function( callback ){
  1700. var fun = function () {
  1701. this.loadRoom( function(){
  1702. this.loadInvite();
  1703. this.loadAttachment();
  1704. if(callback)callback();
  1705. }.bind(this) );
  1706. }.bind(this)
  1707. if( this.options.isResetData ){
  1708. if( this.data && this.data.id ){
  1709. ( this.app.actions || this.actions ).getMeeting( this.data.id, function( json ){
  1710. this.data = json.data;
  1711. fun();
  1712. }.bind(this))
  1713. }else{
  1714. fun();
  1715. }
  1716. }else{
  1717. fun();
  1718. }
  1719. },
  1720. _getHtml : function(){
  1721. var data = this.data;
  1722. var titleStyle = "font-size:14px;color:#333";
  1723. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1724. var color = "#ccc";
  1725. switch (data.status){
  1726. case "wait":
  1727. color = "#4990E2";
  1728. break;
  1729. case "processing":
  1730. color = "#66CC7F";
  1731. break;
  1732. case "completed":
  1733. color = "#666";
  1734. break;
  1735. }
  1736. if (data.myWaitAccept){
  1737. color = "#F6A623";
  1738. }
  1739. if (data.confilct){
  1740. color = "#FF7F7F";
  1741. }
  1742. debugger;
  1743. var deletedInfor = "";
  1744. this.userName = layout.desktop.session.user.distinguishedName;
  1745. if((this.data.inviteDelPersonList||[]).contains(this.userName) && !(this.data.invitePersonList||[]).contains(this.userName)){
  1746. deletedInfor = "<div style='position: absolute;left:20px;top:5px;height:20px;min-width:200px;color: rgb(246, 166, 35);'>"+this.lp.userDeleteInvitePerson+"</div>";
  1747. }
  1748. var html = deletedInfor +
  1749. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1750. " <div style='font-size: 12px;color:#666; float: right' item='applicant'></div>" +
  1751. " <div style='float: left' item='meetingFlag'></div>"+
  1752. " <div style='font-size: 16px;color:#333;float: left' item='type'></div>"+
  1753. "</div>"+
  1754. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;overflow:hidden;' item='subject'></div>"+
  1755. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1756. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1757. "<tr><td style='"+titleStyle+";' width='70'>"+this.lp.meetingTime+":</td>" +
  1758. " <td style='"+valueStyle+";color:"+ color +"' item='meetingTime'></td></tr>";
  1759. if( this.data.mode === "online" ){
  1760. html += "<tr><td style='"+titleStyle+"'>"+this.lp.meetingUrl +":</td>" +
  1761. " <td style='"+valueStyle+"' item='roomLink'></td></tr>" +
  1762. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingNumber +":</td>" +
  1763. " <td style='"+valueStyle+"' item='roomId'></td></tr>";
  1764. }
  1765. if( this.data.room && this.data.room !== "noRoom" ){ //this.data.mode !== "online"
  1766. html += "<tr><td style='"+titleStyle+"'>"+this.lp.selectRoom +":</td>" +
  1767. " <td style='"+valueStyle+"' item='meetingRoom'></td></tr>";
  1768. }
  1769. html += "<tr><td style='"+titleStyle+"'>"+this.lp.invitePerson2+":</td>" +
  1770. " <td style='"+valueStyle+"' item='invitePerson'></td></tr>" +
  1771. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingDescription+":</td>" +
  1772. " <td style='"+valueStyle+"' item='description'></td></tr>";
  1773. if( this.data.hostPerson ){
  1774. html += "<tr><td style='"+titleStyle+"'>"+this.lp.hostPerson+":</td>" +
  1775. " <td style='"+valueStyle+"' item='hostPerson'></td></tr>";
  1776. }
  1777. if( this.data.hostUnit ){
  1778. html += "<tr><td style='"+titleStyle+"'>"+this.lp.hostUnit+":</td>" +
  1779. " <td style='"+valueStyle+"' item='hostUnit'></td></tr>";
  1780. }
  1781. if( !this.options.isHideAttachment ){
  1782. html += "<tr><td style='"+titleStyle+"'>"+this.lp.meetingAttachment+":</td>" +
  1783. " <td style='"+valueStyle+"' item='attachment'></td></tr>";
  1784. }
  1785. html += "</table>";
  1786. return html;
  1787. },
  1788. setItemValue: function( contentNode, name, value ){
  1789. var itemNode = contentNode.getElement("[item='"+name+"']");
  1790. if(itemNode)itemNode.set("text", value );
  1791. },
  1792. _customNode : function( node, contentNode ){
  1793. var data = this.data;
  1794. var persons = [];
  1795. data.invitePersonList.each( function( p ){
  1796. persons.push(p.split("@")[0] )
  1797. }.bind(this));
  1798. var beginDate = Date.parse(data.startTime);
  1799. var endDate = Date.parse(data.completedTime);
  1800. var dateStr = beginDate.format(this.app.lp.dateFormatDay);
  1801. var beginTime = this.getString( beginDate.getHours() ) + ":" + this.getString( beginDate.getMinutes() );
  1802. var endTime = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  1803. var meetingTime = dateStr + " " + beginTime + "-" + endTime;
  1804. var description = (data.description || "")+(data.summary || "");
  1805. this.setItemValue(contentNode, "roomLink", data.roomLink );
  1806. this.setItemValue(contentNode, "roomId", data.roomId );
  1807. this.setItemValue(contentNode, "type", (this.data.type || this.lp.meetingDetail));
  1808. this.setItemValue(contentNode, "applicant", this.lp.applyPerson +":" + data.applicant.split("@")[0] );
  1809. this.setItemValue(contentNode, "subject", data.subject );
  1810. this.setItemValue(contentNode, "meetingTime", meetingTime );
  1811. this.setItemValue(contentNode, "subject", data.subject );
  1812. this.setItemValue(contentNode, "invitePerson", persons.join(",") );
  1813. this.setItemValue(contentNode, "description", description );
  1814. if(this.data.hostPerson)this.setItemValue(contentNode, "hostPerson", this.data.hostPerson.split("@")[0] );
  1815. if(this.data.hostUnit)this.setItemValue(contentNode, "hostUnit", this.data.hostUnit.split("@")[0] );
  1816. var meetingFlagArea = contentNode.getElement("[item='meetingFlag']");
  1817. if(meetingFlagArea){
  1818. if( data.mode === "online" ){
  1819. new Element("div.mainColor_bg", {
  1820. style: "font-size:12px; line-height:22px; text-align:center; height:22px; width:22px;border-radius:22px; background:#4A90E2; color:#fff;margin-right:5px;margin-top:-4px;",
  1821. text: this.lp.netMeetingAbb
  1822. }).inject( meetingFlagArea )
  1823. }
  1824. }
  1825. if( this.data.mode === "online" )this.loadRoomLink();
  1826. this.fireEvent("customContent", [contentNode, node]);
  1827. },
  1828. getString : function( str ){
  1829. var s = "00" + str;
  1830. return s.substr(s.length - 2, 2 );
  1831. },
  1832. loadRoomLink: function(){
  1833. var node;
  1834. if( this.data.roomLink ){
  1835. node = this.node.getElement("[item='roomLink']");
  1836. node.empty();
  1837. new Element("a", {
  1838. style: "font-size:13px;",
  1839. href: this.data.roomLink,
  1840. text: this.lp.openMeetingUrl,
  1841. target: "_blank"
  1842. }).inject( node );
  1843. }
  1844. // if( this.data.roomId ){
  1845. // this.app.isCopyEnable().then(function(flag){
  1846. // if( flag ){
  1847. // node = this.node.getElement("[item='roomId']");
  1848. // node.empty();
  1849. // new Element("span", { text: this.data.roomId, name: "roomId" }).inject( node );
  1850. // new Element("div", {
  1851. // "text": this.lp.copy,
  1852. // "styles": this.app.css.inputDenyButton,
  1853. // "events": {
  1854. // "click": function (){ this.app.copyTextToClipboard(this.data.roomId) }.bind(this)
  1855. // }
  1856. // }).inject( node );
  1857. // }
  1858. // }.bind(this))
  1859. //}
  1860. },
  1861. loadRoom: function( callback ){
  1862. var area = this.node.getElement("[item='meetingRoom']");
  1863. if (area && this.data.room && this.data.room !== "noRoom"){
  1864. this.app.actions.getRoom(this.data.room, function(json){
  1865. this.app.actions.getBuilding(json.data.building, function(bjson){
  1866. area.set("text", json.data.name+" ("+bjson.data.name+")");
  1867. if( callback )callback();
  1868. }.bind(this));
  1869. }.bind(this));
  1870. }else{
  1871. if( callback )callback();
  1872. }
  1873. },
  1874. loadInvite : function(){
  1875. this.O2PersonList = [];
  1876. var area = this.node.getElement("[item='invitePerson']");
  1877. area.empty();
  1878. var inviteList;
  1879. if( this.data.inviteMemberList && this.data.inviteMemberList.length ){
  1880. inviteList = this.data.inviteMemberList;
  1881. }else{
  1882. inviteList = this.data.invitePersonList || [];
  1883. }
  1884. this.loadOrgWidget(inviteList, area, {"onLoadedInfor": function(item){
  1885. // this.loadAcceptAndReject( item );
  1886. }.bind(this)})
  1887. },
  1888. loadOrgWidget: function(value, node, opt){
  1889. this.O2PersonList = [];
  1890. var options = Object.merge({"lazy":true, "style": "room"}, opt);
  1891. MWF.require("MWF.widget.O2Identity", null, false);
  1892. value.each(function( v ){
  1893. var data;
  1894. var distinguishedName;
  1895. if( typeOf(v) === "string" ){
  1896. distinguishedName = v;
  1897. if( distinguishedName.indexOf("@") > 0 ){
  1898. data = {
  1899. "distinguishedName" : distinguishedName,
  1900. "name": distinguishedName.split("@")[0]
  1901. }
  1902. }else{
  1903. data = {
  1904. "id" : distinguishedName,
  1905. "name": distinguishedName.split("@")[0]
  1906. }
  1907. }
  1908. }else{
  1909. distinguishedName = v.distinguishedName || v.name || "";
  1910. if( !v.name )v.name = distinguishedName.split("@")[0];
  1911. data = v;
  1912. }
  1913. var flag = distinguishedName.substr(distinguishedName.length-1, 1);
  1914. switch (flag.toLowerCase()){
  1915. case "i":
  1916. var widget = new MWF.widget.O2Identity( data, node, options );
  1917. break;
  1918. case "p":
  1919. var widget = new MWF.widget.O2Person(data, node, options);
  1920. break;
  1921. case "u":
  1922. var widget = new MWF.widget.O2Unit(data, node, options);
  1923. break;
  1924. case "g":
  1925. var widget = new MWF.widget.O2Group(data, node, options);
  1926. break;
  1927. default:
  1928. var orgType = this.options.orgType;
  1929. var t = ( typeOf( orgType ) == "array" && orgType.length == 1 ) ? orgType[0] : orgType;
  1930. t = typeOf( t ) == "string" ? t.toLowerCase() : "";
  1931. if( t == "identity" ){
  1932. var widget = new MWF.widget.O2Identity( data, node, options );
  1933. }else if( t == "person" ){
  1934. var widget = new MWF.widget.O2Person(data, node, options);
  1935. }else if( t == "unit" ){
  1936. var widget = new MWF.widget.O2Unit(data, node, options);
  1937. }else if( t == "group" ){
  1938. var widget = new MWF.widget.O2Group(data, node, options);
  1939. }
  1940. }
  1941. widget.field = this;
  1942. this.O2PersonList.push( widget );
  1943. }.bind(this));
  1944. },
  1945. loadAcceptAndReject : function( item ){
  1946. var personName = item.data.distinguishedName;
  1947. if( this.data.acceptPersonList ){
  1948. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  1949. var acceptNode = new Element("div", {"styles": {
  1950. "height": "20px",
  1951. "width": "14px",
  1952. "margin-right": "3px",
  1953. "float": "left",
  1954. "background": "url(../x_component_Template/$MPopupForm/meeting/icon/accept.png) no-repeat center center"
  1955. }}).inject(item.node, "top");
  1956. if(item.inforNode)new Element("div", {
  1957. "styles" : {"color": "#1fbf04", "clear":"both","text-align":"center"},
  1958. "text": this.app.lp.accepted
  1959. }).inject(item.inforNode);
  1960. }
  1961. }
  1962. if(this.data.rejectPersonList){
  1963. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  1964. var rejectNode = new Element("div", {"styles": {
  1965. "height": "20px",
  1966. "width": "14px",
  1967. "margin-right": "3px",
  1968. "float": "left",
  1969. "background": "url(../x_component_Template/$MPopupForm/meeting/icon/reject.png) no-repeat center center"
  1970. }}).inject(item.node, "top");
  1971. if(item.inforNode)new Element("div", {
  1972. "styles" : {"color": "#FF0000", "clear":"both","text-align":"center"},
  1973. "text": this.app.lp.rejected
  1974. }).inject(item.inforNode);
  1975. }
  1976. }
  1977. },
  1978. destroy: function(){
  1979. if( this.O2PersonList ){
  1980. this.O2PersonList.each(function(p){
  1981. p.destroy();
  1982. })
  1983. }
  1984. if( this.node ){
  1985. this.node.destroy();
  1986. this.node = null;
  1987. }
  1988. },
  1989. loadAttachment: function(){
  1990. if( this.options.isHideAttachment )return;
  1991. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1992. var area = this.node.getElement("[item='attachment']");
  1993. this.attachmentNode = new Element("div"
  1994. //{"styles": this.css.createMeetingAttachmentNode}
  1995. ).inject(area);
  1996. var attachmentContentNode = new Element("div", {
  1997. //"styles": this.css.createMeetingAttachmentContentNode
  1998. }).inject(this.attachmentNode);
  1999. this.attachmentController = new MWF.xApplication.Meeting.MeetingTooltip.AttachmentController(attachmentContentNode, this, {
  2000. "size": "min",
  2001. "isSizeChange": false,
  2002. "isReplace": false,
  2003. "isUpload": false,
  2004. "isDelete": false,
  2005. "isDownload": true,
  2006. "readonly": true
  2007. });
  2008. this.attachmentController.load();
  2009. this.data.attachmentList.each(function (att) {
  2010. att.person = att.lastUpdatePerson.split("@")[0];
  2011. var at = this.attachmentController.addAttachment(att);
  2012. }.bind(this));
  2013. }
  2014. },
  2015. downloadAttachment: function(e, node, attachments){
  2016. attachments.each(function(att){
  2017. this.app.actions.getFileDownload(att.data.id);
  2018. }.bind(this));
  2019. },
  2020. openAttachment: function(e, node, attachments){
  2021. attachments.each(function(att){
  2022. this.app.actions.getFile(att.data.id);
  2023. }.bind(this));
  2024. },
  2025. getAttachmentUrl: function(attachment, callback){
  2026. this.app.actions.getFileUrl(attachment.data.id, callback);
  2027. }
  2028. });
  2029. MWF.xApplication.Meeting.MeetingTooltip.AttachmentController = new Class({
  2030. Extends : MWF.widget.AttachmentController,
  2031. loadMin: function(){
  2032. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  2033. if (!this.minActionAreaNode){
  2034. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  2035. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  2036. this.minContent.setStyles({
  2037. "margin-right" : "0px"
  2038. });
  2039. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  2040. // this.downloadAttachment(e, node);
  2041. //}.bind(this));
  2042. this.node.inject(this.container);
  2043. //if (this.options.readonly) this.setReadonly();
  2044. this.checkActions();
  2045. this.setEvent();
  2046. }else{
  2047. //this.minActionAreaNode.setStyle("display", "block");
  2048. this.minContent.setStyle("display", "block");
  2049. this.minContent.empty();
  2050. }
  2051. var atts = [];
  2052. while (this.attachments.length){
  2053. var att = this.attachments.shift();
  2054. atts.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(att.data, this));
  2055. }
  2056. this.attachments = atts;
  2057. },
  2058. addAttachment: function(data){
  2059. if (this.options.size=="min"){
  2060. this.attachments.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(data, this));
  2061. }else{
  2062. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  2063. }
  2064. }
  2065. });
  2066. MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin = new Class({
  2067. Extends : MWF.widget.AttachmentController.AttachmentMin,
  2068. setEvent: function(){
  2069. this.node.addEvents({
  2070. "mouseover": function(){
  2071. var styleName = "attachmentNode_"+this.controller.options.listStyle+"_over";
  2072. if (!this.isSelected) this.node.setStyles(this.css[styleName])
  2073. }.bind(this),
  2074. "mouseout": function(){
  2075. var styleName = "attachmentNode_"+this.controller.options.listStyle;
  2076. if (!this.isSelected) this.node.setStyles(this.css[styleName])
  2077. }.bind(this),
  2078. "mousedown": function(e){this.selected(e);}.bind(this),
  2079. "click": function(e){this.downloadAttachment(e);}.bind(this)
  2080. });
  2081. },
  2082. downloadAttachment: function(e){
  2083. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  2084. }
  2085. });
  2086. MWF.xApplication.Meeting.MeetingArea = new Class({
  2087. initialize: function(container, view, data){
  2088. this.container = container;
  2089. this.view = view;
  2090. this.css = this.view.css;
  2091. this.app = this.view.app;
  2092. this.data = data;
  2093. this.beginDate = Date.parse(this.data.startTime);
  2094. this.endDate = Date.parse(this.data.completedTime);
  2095. this.userName = layout.desktop.session.user.distinguishedName;
  2096. this.userId = layout.desktop.session.user.id;
  2097. this.parseData();
  2098. this.path = "../x_component_Meeting/$Common/default/meetingarea/";
  2099. this.cssPath = "../x_component_Meeting/$Common/default/meetingarea/css.wcss";
  2100. this._loadCss();
  2101. this.load();
  2102. },
  2103. load: function(){
  2104. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  2105. this.node.addEvents({
  2106. mouseenter : function(){
  2107. this.node.setStyles( this.css.meetingNode_over );
  2108. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  2109. this.subjectNode.addClass("mainColor_color");
  2110. }.bind(this),
  2111. mouseleave : function(){
  2112. this.node.setStyles( this.css.meetingNode );
  2113. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  2114. this.subjectNode.removeClass("mainColor_color");
  2115. }.bind(this),
  2116. click : function(){
  2117. this.openMeeting()
  2118. }.bind(this)
  2119. });
  2120. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  2121. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  2122. var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  2123. var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  2124. this.timeNode = new Element("div", {
  2125. "styles": this.css.meetingTimeNode,
  2126. "text" : beginTime + "-" + endTime
  2127. }).inject(this.contentNode);
  2128. this.subjectNode = new Element("div", {
  2129. "styles": this.css.meetingSubjectNode,
  2130. "text": this.data.subject
  2131. }).inject(this.contentNode);
  2132. var description = (this.data.description || "")+(this.data.summary || "");
  2133. this.descriptionNode = new Element("div", {
  2134. "styles": this.css.meetingDescriptionNode,
  2135. "text" : description
  2136. }).inject(this.contentNode);
  2137. this.loadActionBar();
  2138. switch (this.data.status){
  2139. case "wait":
  2140. this.colorNode.setStyles({"background-color": "#4990E2"});
  2141. this.timeNode.setStyles({"color": "#4990E2"});
  2142. break;
  2143. case "processing":
  2144. this.colorNode.setStyles({"background-color": "#66CC7F"});
  2145. this.timeNode.setStyles({"color": "#66CC7F"});
  2146. break;
  2147. case "completed":
  2148. //add attachment
  2149. this.colorNode.setStyles({"background-color": "#ccc"});
  2150. this.timeNode.setStyles({"color": "#ccc"});
  2151. break;
  2152. }
  2153. if (this.data.myWaitAccept){
  2154. this.colorNode.setStyles({"background-color": "#F6A623"});
  2155. this.timeNode.setStyles({"color": "#F6A623"});
  2156. }
  2157. this.resetNodeSize();
  2158. this.loadTooltip();
  2159. },
  2160. parseData : function(){
  2161. if( !this.data.status ){
  2162. var now = new Date();
  2163. var status;
  2164. if( this.beginDate > now ){
  2165. status = "wait";
  2166. }else if( this.endDate < now ){
  2167. status = "completed";
  2168. }else{
  2169. status = "processing";
  2170. }
  2171. this.data.status = status;
  2172. }
  2173. if( typeOf( this.data.myWaitAccept ) != "boolean" ){
  2174. if( this.data.invitePersonList.contains( this.userName ) || this.data.invitePersonList.contains( this.userId ) ){
  2175. this.data.myWaitAccept = ( !this.data.acceptPersonList.contains( this.userName ) || this.data.acceptPersonList.contains( this.userId ) ) &&
  2176. ( !this.data.rejectPersonList.contains( this.userName ) || !this.data.rejectPersonList.contains( this.userId ) )
  2177. }
  2178. }
  2179. },
  2180. loadActionBar : function(){
  2181. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() || this.data.myWaitAccept ){
  2182. }else{
  2183. return;
  2184. }
  2185. this.actionBar = new Element("div", {
  2186. "styles": this.css.actionBar
  2187. }).inject(this.contentNode);
  2188. //this.viewAction = new Element("div", {
  2189. // styles: this.css.action_view,
  2190. // events : {
  2191. // mouseenter : function(){
  2192. // this.viewAction.setStyles( this.css.action_view_over );
  2193. // }.bind(this),
  2194. // mouseleave : function(){
  2195. // this.viewAction.setStyles( this.css.action_view );
  2196. // }.bind(this),
  2197. // click : function(){
  2198. // this.openMeeting()
  2199. // }.bind(this)
  2200. // }
  2201. //}).inject(this.actionBar);
  2202. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() ){
  2203. if( this.data.status=="wait" ){
  2204. this.editAction = new Element("div.o2icon-edit2", {
  2205. styles: this.css.action_edit,
  2206. events : {
  2207. mouseover : function(){
  2208. this.editAction.setStyles( this.css.action_edit_over );
  2209. this.editAction.addClass("mainColor_color");
  2210. }.bind(this),
  2211. mouseout : function(){
  2212. this.editAction.setStyles( this.css.action_edit );
  2213. this.editAction.removeClass("mainColor_color");
  2214. }.bind(this),
  2215. click : function(e){
  2216. this.editMeeting();
  2217. e.stopPropagation();
  2218. }.bind(this)
  2219. }
  2220. }).inject(this.actionBar);
  2221. //if (this.data.myWaitConfirm) this.createConfirmActions();
  2222. //if (this.data.myWaitAccept) this.createAcceptActions();
  2223. //if (this.data.status=="wait" && this.isEdit) this.createCancelActions();
  2224. this.removeAction = new Element("div.o2icon-delete", {
  2225. styles: this.css.action_remove,
  2226. events : {
  2227. mouseover : function(){
  2228. this.removeAction.setStyles( this.css.action_remove_over );
  2229. this.removeAction.addClass("mainColor_color");
  2230. }.bind(this),
  2231. mouseout : function(){
  2232. this.removeAction.setStyles( this.css.action_remove );
  2233. this.removeAction.removeClass("mainColor_color");
  2234. }.bind(this),
  2235. click : function( e ){
  2236. this.cancel(e);
  2237. e.stopPropagation();
  2238. }.bind(this)
  2239. }
  2240. }).inject(this.actionBar);
  2241. }
  2242. }
  2243. if (this.data.myWaitAccept){
  2244. this.acceptAction = new Element("div.o2icon-checkbox", {
  2245. styles: this.css.action_accept,
  2246. title : this.app.lp.accept,
  2247. events : {
  2248. mouseover : function(){
  2249. this.acceptAction.setStyles( this.css.action_accept_over );
  2250. this.acceptAction.addClass("mainColor_color");
  2251. }.bind(this),
  2252. mouseout : function(){
  2253. this.acceptAction.setStyles( this.css.action_accept );
  2254. this.acceptAction.removeClass("mainColor_color");
  2255. }.bind(this),
  2256. click : function( e ){
  2257. this.accept(e);
  2258. e.stopPropagation();
  2259. }.bind(this)
  2260. }
  2261. }).inject(this.actionBar);
  2262. this.rejectAction = new Element("div.o2icon-off", {
  2263. styles: this.css.action_reject,
  2264. title : this.app.lp.reject,
  2265. events : {
  2266. mouseover : function(){
  2267. this.rejectAction.setStyles( this.css.action_reject_over );
  2268. this.rejectAction.addClass("mainColor_color");
  2269. }.bind(this),
  2270. mouseout : function(){
  2271. this.rejectAction.setStyles( this.css.action_reject );
  2272. this.rejectAction.removeClass("mainColor_color");
  2273. }.bind(this),
  2274. click : function( e ){
  2275. this.reject(e);
  2276. e.stopPropagation();
  2277. }.bind(this)
  2278. }
  2279. }).inject(this.actionBar);
  2280. }
  2281. },
  2282. getString : function( str ){
  2283. var s = "00" + str;
  2284. return s.substr(s.length - 2, 2 );
  2285. },
  2286. _loadCss: function(){
  2287. var key = encodeURIComponent(this.cssPath);
  2288. if (MWF.widget.css[key]){
  2289. this.css = MWF.widget.css[key];
  2290. }else{
  2291. var r = new Request.JSON({
  2292. url: this.cssPath,
  2293. secure: false,
  2294. async: false,
  2295. method: "get",
  2296. noCache: false,
  2297. onSuccess: function(responseJSON, responseText){
  2298. this.css = responseJSON;
  2299. MWF.widget.css[key] = responseJSON;
  2300. }.bind(this),
  2301. onError: function(text, error){
  2302. alert(error + text);
  2303. }
  2304. });
  2305. r.send();
  2306. }
  2307. },
  2308. loadTooltip : function( isHideAttachment, isResetData ){
  2309. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  2310. axis : "x",
  2311. hiddenDelay : 300,
  2312. displayDelay : 300,
  2313. isHideAttachment : isHideAttachment,
  2314. isResetData : isResetData
  2315. });
  2316. },
  2317. showTooltip: function( ){
  2318. if( this.tooltip ){
  2319. this.tooltip.load();
  2320. }else{
  2321. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.viewAction, this.app, this.data);
  2322. this.tooltip.load();
  2323. }
  2324. },
  2325. openMeeting: function(){
  2326. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  2327. form.view = this.view;
  2328. form.open();
  2329. },
  2330. resetNodeSize: function(){
  2331. var contentSize = this.contentNode.getSize();
  2332. this.colorNode.setStyle("height", contentSize.y );
  2333. },
  2334. destroy: function(){
  2335. if(this.tooltip)this.tooltip.destroy();
  2336. this.node.destroy();
  2337. MWF.release(this);
  2338. },
  2339. editMeeting : function(){
  2340. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  2341. form.view = this.view;
  2342. form.edit();
  2343. },
  2344. cancel: function(e){
  2345. var _self = this;
  2346. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  2347. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 400, 200, function(){
  2348. _self.cancelMeeting();
  2349. this.close();
  2350. }, function(){
  2351. this.close();
  2352. });
  2353. },
  2354. cancelMeeting: function(){
  2355. var view = this.view;
  2356. this.app.actions.deleteMeeting(this.data.id, function(){
  2357. view.reload();
  2358. }.bind(this))
  2359. },
  2360. reject: function(e){
  2361. var _self = this;
  2362. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  2363. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  2364. _self.rejectMeeting();
  2365. this.close();
  2366. }, function(){
  2367. this.close();
  2368. });
  2369. },
  2370. rejectMeeting: function(){
  2371. var view = this.view;
  2372. this.app.actions.rejectMeeting(this.data.id, function(){
  2373. view.reload();
  2374. }.bind(this))
  2375. },
  2376. accept: function(e){
  2377. var _self = this;
  2378. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  2379. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  2380. _self.acceptMeeting();
  2381. this.close();
  2382. }, function(){
  2383. this.close();
  2384. });
  2385. },
  2386. acceptMeeting: function(){
  2387. var view = this.view;
  2388. this.app.actions.acceptMeeting(this.data.id, function(){
  2389. view.reload();
  2390. }.bind(this))
  2391. },
  2392. disagree: function(e){
  2393. var _self = this;
  2394. var text = this.app.lp.disagree_confirm.replace(/{name}/g, this.data.subject);
  2395. this.app.confirm("infor", e, this.app.lp.disagree_confirm_title, text, 300, 120, function(){
  2396. _self.disagreeMeeting();
  2397. this.close();
  2398. }, function(){
  2399. this.close();
  2400. });
  2401. },
  2402. disagreeMeeting: function(){
  2403. var view = this.view;
  2404. this.app.actions.denyMeeting(this.data.id, function(){
  2405. view.reload();
  2406. }.bind(this))
  2407. },
  2408. agree: function(e){
  2409. var _self = this;
  2410. var text = this.app.lp.agree_confirm.replace(/{name}/g, this.data.subject);
  2411. this.app.confirm("infor", e, this.app.lp.agree_confirm_title, text, 300, 120, function(){
  2412. _self.agreeMeeting();
  2413. this.close();
  2414. }, function(){
  2415. this.close();
  2416. });
  2417. },
  2418. agreeMeeting: function(){
  2419. var view = this.view;
  2420. this.app.actions.allowMeeting(this.data.id, function(){
  2421. view.reload();
  2422. }.bind(this))
  2423. }
  2424. });
  2425. MWF.xApplication.Meeting.SideBar = new Class({
  2426. Extends: MWF.widget.Common,
  2427. Implements: [Options, Events],
  2428. options: {
  2429. "style": "default"
  2430. },
  2431. initialize : function( container, app, options){
  2432. this.setOptions( options );
  2433. this.container = container;
  2434. this.app = app;
  2435. //this.css = this.app.css;
  2436. this.lp = this.app.lp;
  2437. this.isHidden = false;
  2438. this.cssPath = "../x_component_Meeting/$Common/"+this.options.style+"/sidebar/css.wcss";
  2439. this._loadCss();
  2440. this.load();
  2441. },
  2442. load : function(){
  2443. this.node = new Element("div.sideBar", {
  2444. "styles": this.css.node,
  2445. events : {
  2446. mousedown : function( ev ){
  2447. ev.stopPropagation();
  2448. }
  2449. }
  2450. }).inject(this.container);
  2451. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  2452. this.loadStatusArea();
  2453. new Element("div.contentLine", {
  2454. "styles" : this.css.contentLine
  2455. }).inject( this.contentNode );
  2456. this.loadTodayMeetingNode();
  2457. this.trapezoid = new Element("div.trapezoid",{
  2458. "styles":this.css.trapezoid_toRight,
  2459. events : {
  2460. click : function(){
  2461. this.trigger();
  2462. }.bind(this)
  2463. }
  2464. }).inject(this.node);
  2465. //this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  2466. this.loadTodayMeeting( function(){
  2467. var x = this.node.getSize().x - 8;
  2468. this.node.setStyle( "right", "-"+x+"px" );
  2469. this.resetNodeSize();
  2470. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  2471. this.app.addEvent("resize", this.resetNodeSizeFun );
  2472. this.hideFun = this.hide.bind(this);
  2473. this.app.node.addEvent("mousedown", this.hideFun);
  2474. }.bind(this));
  2475. },
  2476. loadStatusArea : function(){
  2477. var area = new Element("div", {
  2478. "styles" : this.css.statusArea
  2479. }).inject( this.contentNode );
  2480. var html = "<div class='titleDiv'>"+this.lp.config.meetingStatus+"</div>" +
  2481. "<div class = 'statusStyle'>"+
  2482. " <div class='statusIconStyle' style='background-color:#4990E2'></div>" +
  2483. " <div class = 'statusTextStyle'>"+this.lp.config.wait+"</div></div>" +
  2484. "</div>"+
  2485. "<div class = 'statusStyle'>"+
  2486. " <div class='statusIconStyle' style='background-color:#66CC7F'></div>" +
  2487. " <div class = 'statusTextStyle'>"+this.lp.config.progress+"</div></div>" +
  2488. "</div>"+
  2489. "<div class = 'statusStyle'>"+
  2490. " <div class='statusIconStyle' style='background-color:#F6A623'></div>" +
  2491. " <div class = 'statusTextStyle'>"+this.lp.config.invite+"</div></div>" +
  2492. "</div>"+
  2493. "<div class = 'statusStyle'>"+
  2494. " <div class='statusIconStyle' style='background-color:#ccc'></div>" +
  2495. " <div class = 'statusTextStyle'>"+this.lp.config.completed+"</div></div>" +
  2496. "</div>"+
  2497. "<div class = 'statusStyle'>"+
  2498. " <div class='statusIconStyle2' style='border:2px solid #FF7F7F;'></div>" +
  2499. " <div class = 'statusTextStyle'>"+this.lp.config.conflict+"</div></div>" +
  2500. "</div>";
  2501. area.set("html", html);
  2502. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  2503. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  2504. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  2505. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  2506. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  2507. },
  2508. loadTodayMeetingNode: function(){
  2509. var area = new Element("div.meetingArea", {
  2510. "styles" : this.css.meetingArea
  2511. }).inject( this.contentNode );
  2512. new Element("div.titleDiv", {
  2513. "styles" : this.css.titleDiv,
  2514. "text" : this.lp.meetingNotice
  2515. }).inject( area );
  2516. this.meetingNode = Element("div", {
  2517. "styles" : this.css.meetingNode
  2518. }).inject( area );
  2519. },
  2520. loadTodayMeeting : function( callback ){
  2521. var today = new Date();
  2522. var user = layout.desktop.session.user;
  2523. var dn = user.distinguishedName;
  2524. var y = today.getFullYear();
  2525. var m = today.getMonth()+1;
  2526. var d = today.getDate();
  2527. this.app.actions.listMeetingDay(y, m, d, function(json) {
  2528. var data = [];
  2529. json.data.each( function( d ){
  2530. if( d.invitePersonList.contains( dn ) || d.applicant == dn ){
  2531. if( !d.rejectPersonList.contains( dn ) ){
  2532. data.push( d );
  2533. }
  2534. }
  2535. }.bind(this));
  2536. if( user.distinguishedName ){
  2537. var userName = user.distinguishedName.split("@")[0]
  2538. }else{
  2539. var userName = user.name
  2540. }
  2541. var lp = data.length ? this.lp.meetingTopInfor : this.lp.noMeetingTopInfor ;
  2542. this.meetingTopNode = new Element("div", {
  2543. "styles" : this.css.meetingTopNode,
  2544. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  2545. }).inject( this.meetingNode );
  2546. this.scrollNode = new Element("div.scrollNode", {
  2547. "styles" : this.css.scrollNode
  2548. }).inject( this.meetingNode );
  2549. this.meetingItemContainer = new Element("div.meetingItemContainer", {
  2550. "styles" : this.css.meetingItemContainer
  2551. }).inject( this.scrollNode );
  2552. data.each( function( d, i ){
  2553. var itemNode = new Element("div.meetingItemNode", {
  2554. "styles" : this.css.meetingItemNode,
  2555. "events" : {
  2556. click : function(){
  2557. this.obj.openMeeting( this.data );
  2558. }.bind({ obj : this, data : d })
  2559. }
  2560. }).inject( this.meetingItemContainer );
  2561. this.tooltipList = this.tooltipList || [];
  2562. this.tooltipList.push( new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, itemNode, this.app, d, {
  2563. axis : "x",
  2564. hiddenDelay : 300,
  2565. displayDelay : 300
  2566. })
  2567. );
  2568. var colorNode = new Element("div.meetingItemColorNode", {
  2569. "styles" : this.css.meetingItemColorNode,
  2570. "text" : i+1
  2571. }).inject( itemNode );
  2572. var textNode = new Element("div.meetingItemTextNode", {
  2573. "styles" : this.css.meetingItemTextNode,
  2574. "text" : d.subject
  2575. }).inject( itemNode );
  2576. switch (d.status){
  2577. case "wait":
  2578. colorNode.setStyles({"background-color": "#4990E2"});
  2579. break;
  2580. case "processing":
  2581. colorNode.setStyles({"background-color": "#66CC7F"});
  2582. break;
  2583. case "completed":
  2584. //add attachment
  2585. colorNode.setStyles({"background-color": "#ccc"});
  2586. break;
  2587. }
  2588. if (d.myWaitAccept){
  2589. colorNode.setStyles({"background-color": "#F6A623"});
  2590. }
  2591. var y = itemNode.getSize().y ;
  2592. colorNode.setStyle("margin-top", ( y - 20)/2 );
  2593. }.bind(this));
  2594. this.setScrollBar( this.scrollNode );
  2595. if( callback )callback();
  2596. }.bind(this));
  2597. },
  2598. trigger : function(){
  2599. this.isHidden ? this.show( true ) : this.hide( true )
  2600. },
  2601. hide: function( isFireEvent ){
  2602. var x = this.node.getSize().x - 9;
  2603. var fx = new Fx.Morph(this.node, {
  2604. "duration": "300",
  2605. "transition": Fx.Transitions.Expo.easeOut
  2606. });
  2607. fx.start({
  2608. //"opacity": 0
  2609. }).chain(function(){
  2610. this.isHidden = true;
  2611. //this.node.setStyle("display", "none");
  2612. this.node.setStyles({
  2613. "right": "-"+x+"px"
  2614. });
  2615. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  2616. //if(isFireEvent)this.app.fireEvent("resize");
  2617. }.bind(this));
  2618. },
  2619. show: function( isFireEvent ){
  2620. this.node.setStyles(this.css.node);
  2621. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  2622. //var x = this.node.getSize().x - 8;
  2623. //this.node.setStyles( "right", "-"+x+"px" );
  2624. var fx = new Fx.Morph(this.node, {
  2625. "duration": "500",
  2626. "transition": Fx.Transitions.Expo.easeOut
  2627. });
  2628. this.app.fireAppEvent("resize");
  2629. fx.start({
  2630. "opacity": 1
  2631. }).chain(function(){
  2632. this.node.setStyles({
  2633. //"position": "static",
  2634. //"width": "auto"
  2635. "right": "0px"
  2636. });
  2637. this.isHidden = false;
  2638. //if(isFireEvent)this.app.fireEvent("resize");
  2639. }.bind(this))
  2640. },
  2641. //show: function(){
  2642. // this.node.setStyles(this.css.configNode);
  2643. // var fx = new Fx.Morph(this.node, {
  2644. // "duration": "500",
  2645. // "transition": Fx.Transitions.Expo.easeOut
  2646. // });
  2647. // fx.start({
  2648. // "opacity": 1
  2649. // }).chain(function(){
  2650. // this.hideFun = this.hide.bind(this);
  2651. // this.app.content.addEvent("mousedown", this.hideFun);
  2652. // }.bind(this));
  2653. //},
  2654. //hide: function(){
  2655. // this.node.destroy();
  2656. // this.app.content.removeEvent("mousedown", this.hideFun);
  2657. // MWF.release(this);
  2658. //},
  2659. resetNodeSize: function(){
  2660. var size = this.container.getSize();
  2661. this.node.setStyle("height", size.y - 50 );
  2662. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  2663. var y = size.y - 395;
  2664. var meetContainerY = this.meetingItemContainer.getSize().y + 12;
  2665. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  2666. },
  2667. getSize : function(){
  2668. //var size = this.node.getSize();
  2669. //return {
  2670. // x : this.isHidden ? 9 : size.x,
  2671. // y : size.y
  2672. //}
  2673. return { x : 9, y : 0 }
  2674. },
  2675. showByType : function( type ){
  2676. },
  2677. reload : function(){
  2678. this.destory();
  2679. this.app.reload();
  2680. },
  2681. openMeeting : function( data ){
  2682. var form = new MWF.xApplication.Meeting.MeetingForm(this, data, {}, {app:this.app});
  2683. form.view = this.app;
  2684. form.open();
  2685. },
  2686. destory : function(){
  2687. this.tooltipList.each( function( t ){
  2688. t.destory();
  2689. });
  2690. this.app.removeEvent("resize", this.resetNodeSizeFun );
  2691. this.app.node.removeEvent("mousedown", this.hideFun);
  2692. this.node.destory();
  2693. }
  2694. });