Common.js 128 KB

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