Main.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. MWF.xApplication.Meeting = MWF.xApplication.Meeting || {};
  2. MWF.require("MWF.xDesktop.UserData", null, false);
  3. MWF.xDesktop.requireApp("Meeting", "MeetingView", null, false);
  4. MWF.xDesktop.requireApp("Meeting", "Common", null, false);
  5. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  6. MWF.xApplication.Meeting.options.multitask = false;
  7. MWF.xApplication.Meeting.Main = new Class({
  8. Extends: MWF.xApplication.Common.Main,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default",
  12. "name": "Meeting",
  13. "icon": "icon.png",
  14. "width": "1000",
  15. "height": "600",
  16. "isResize": true,
  17. "isMax": true,
  18. "sideBarEnable" : true,
  19. "settingEnable" : true,
  20. "title": MWF.xApplication.Meeting.LP.title
  21. },
  22. onQueryLoad: function(){
  23. this.lp = MWF.xApplication.Meeting.LP;
  24. this.menuMode="show";
  25. this.isManager = MWF.AC.isMeetingAdministrator();
  26. this.actions = MWF.Actions.get("x_meeting_assemble_control");
  27. this.personActions = MWF.Actions.get("x_organization_assemble_express");
  28. //if (!this.actions) this.actions = new MWF.xApplication.Meeting.Actions.RestActions();
  29. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  30. },
  31. loadApplication: function(callback) {
  32. MWF.UD.getDataJson("meetingConfig", function(json){
  33. this.meetingConfig = json || {};
  34. MWF.UD.getPublicData("meetingConfig", function(json){
  35. var jsonData = json || {};
  36. if (jsonData.process){
  37. this.meetingConfig.process = jsonData.process;
  38. }else{
  39. this.meetingConfig.process = null;
  40. }
  41. if( jsonData.weekBegin ){
  42. this.meetingConfig.weekBegin = jsonData.weekBegin;
  43. }
  44. if( jsonData.meetingViewer ){
  45. this.meetingConfig.meetingViewer = jsonData.meetingViewer;
  46. }
  47. for( var key in jsonData ){
  48. if( key != "process" && key != "weekBegin" && key != "meetingViewer" ){
  49. this.meetingConfig[ key ] = jsonData[key];
  50. }
  51. }
  52. if( !this.meetingConfig.disableViewList ) this.meetingConfig.disableViewList = [];
  53. this.createNode();
  54. if (!this.options.isRefresh) {
  55. this.maxSize(function () {
  56. this.loadLayout();
  57. }.bind(this));
  58. } else {
  59. this.loadLayout();
  60. }
  61. if (callback) callback();
  62. }.bind(this));
  63. }.bind(this));
  64. },
  65. createNode: function(){
  66. this.content.setStyle("overflow", "hidden");
  67. this.node = new Element("div", {
  68. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  69. }).inject(this.content);
  70. },
  71. loadLayout: function(){
  72. if( this.status && this.status.action ){
  73. this.defaultAction = this.status.action;
  74. }else if (this.meetingConfig.defaultView){
  75. this.defaultAction = this.meetingConfig.defaultView;
  76. }else{
  77. this.defaultAction = "toMyMeeting";
  78. }
  79. if( this.meetingConfig.disableViewList.contains( this.defaultAction ) ){
  80. this.defaultAction = "";
  81. }
  82. this.topMenu = new Element("div", {"styles": this.css.topMenu}).inject(this.node);
  83. this.contentNode = new Element("div.contentNode", {"styles": this.inContainer ? this.css.contentNode_inContainer : this.css.contentNode}).inject(this.node);
  84. //this.bottomMenu = new Element("div", {"styles": this.css.bottomMenu}).inject(this.node);
  85. this.loadTopMenus();
  86. if( this.options.sideBarEnable ){
  87. this.loadSideBar();
  88. }
  89. //this.loadBottomMenus();
  90. //this.hideMenu();
  91. //
  92. //this.node.addEvent("contextmenu", function(e){
  93. // if (this.menuMode=="show"){
  94. // this.hideMenu();
  95. // }else{
  96. // this.showMenu();
  97. // }
  98. // e.preventDefault();
  99. //}.bind(this));
  100. this.setEvent();
  101. },
  102. setEvent: function(){
  103. //this.topMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this));
  104. //this.topMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this));
  105. //this.bottomMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this));
  106. //this.bottomMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this));
  107. //this.contentNode.addEvent("click", function(){this.hideMenu();}.bind(this));
  108. },
  109. loadTopMenus_right: function(){
  110. this.topMenuRight = new Element("div", {"styles": this.css.topMenuRight }).inject(this.topMenu);
  111. this.createTopMenu_right(this.lp.addMeeting, "icon_newapply", "addMeeting");
  112. if (this.isManager)this.createTopMenu_right(this.lp.addRoom, "icon_newhuiyishi", "addRoom");
  113. //var refreshNode = this.createTopMenu_right(this.lp.refresh, "refresh", "refresh");
  114. //refreshNode.setStyle("float", "right");
  115. if( this.options.settingEnable ){
  116. var configNode = this.createTopMenu_right(this.lp.setting, "icon_shezhi", "config");
  117. configNode.setStyle("float", "right");
  118. }
  119. },
  120. createTopMenu_right : function(text, icon, action){
  121. var actionNode = new Element("div", {"styles": this.css.topMenuNode_right, "title" : text}).inject(this.topMenuRight);
  122. var actionIconNode = new Element("div", {"styles": this.css.topMenuIconNode}).inject(actionNode);
  123. var actionTextNode = new Element("div",{styles: this.css.topMenuTextNode, "text":text}).inject(actionNode);
  124. actionIconNode.setStyle("background", "url(../x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center");
  125. actionNode.store("icon",icon);
  126. actionNode.store("iconNode",actionIconNode);
  127. var _self = this;
  128. actionNode.addEvents({
  129. "mouseover": function(){
  130. this.node.setStyles(_self.css.topMenuNode_over);
  131. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  132. }.bind( { node : actionNode } ),
  133. "mouseout": function(){
  134. this.node.setStyles(_self.css.topMenuNode_right);
  135. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  136. }.bind({ node:actionNode }),
  137. "click": function(){
  138. this.node.setStyles(_self.css.topMenuNode_down);
  139. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  140. if (_self[action]) _self[action].apply(_self);
  141. }.bind({ node : actionNode })
  142. });
  143. return actionNode;
  144. },
  145. loadTopMenus: function(){
  146. this.createTopMenu(this.lp.myMeeting, "icon_huiyi", "toMyMeeting");
  147. this.createTopMenu(this.lp.month, "icon_yue", "toMonth");
  148. this.createTopMenu(this.lp.week, "icon_zhou", "toWeek");
  149. this.createTopMenu(this.lp.day, "icon_ri", "toDay");
  150. this.createTopMenu(this.lp.list, "icon_liebiao", "toList");
  151. this.createTopMenu(this.lp.room, "icon_huiyishi", "toRoom");
  152. this.loadTopMenus_right();
  153. },
  154. isViewAvailable : function( action ){
  155. return !this.meetingConfig.disableViewList.contains( action );
  156. },
  157. createTopMenu: function(text, icon, action){
  158. if( this.meetingConfig.disableViewList.contains( action ) )return;
  159. if( this.meetingConfig[ action + "ViewName" ] ){
  160. text = this.meetingConfig[ action + "ViewName" ];
  161. }
  162. var actionNode = new Element("div", {"styles": this.css.topMenuNode}).inject(this.topMenu);
  163. var actionIconNode = new Element("div", {"styles": this.css.topMenuIconNode}).inject(actionNode);
  164. actionIconNode.setStyle("background", "url(../x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center");
  165. var actionTextNode = new Element("div", {"styles": this.css.topMenuTextNode, "text": text}).inject(actionNode);
  166. actionNode.store("icon",icon);
  167. actionNode.store("iconNode",actionIconNode);
  168. actionNode.store("action",action);
  169. var _self = this;
  170. actionNode.addEvents({
  171. "mouseover": function(){
  172. if( this.node != _self.currentTopMenuNode ){
  173. this.node.setStyles(_self.css.topMenuNode_over);
  174. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  175. }
  176. }.bind( { node : actionNode } ),
  177. "mouseout": function(){
  178. if(this.node != _self.currentTopMenuNode){
  179. this.node.setStyles(_self.css.topMenuNode);
  180. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  181. }
  182. }.bind({ node:actionNode }),
  183. //"mousedown": function(){this.setStyles(_self.css.topMenuNode_down);},
  184. //"mouseup": function(){this.setStyles(_self.css.topMenuNode_over);},
  185. "click": function(){
  186. if( this.node != _self.currentTopMenuNode ){
  187. this.node.setStyles( _self.css.topMenuNode_down );
  188. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  189. }
  190. if( _self.currentTopMenuNode && this.node != _self.currentTopMenuNode){
  191. _self.currentTopMenuNode.setStyles( _self.css.topMenuNode );
  192. _self.currentTopMenuNode.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+_self.currentTopMenuNode.retrieve("icon")+".png) no-repeat center center" );
  193. }
  194. _self.currentTopMenuNode = this.node;
  195. if (_self[action]) _self[action].apply(_self);
  196. }.bind({ node : actionNode })
  197. });
  198. if( this.defaultAction ){
  199. if( this.defaultAction == action ){
  200. actionNode.click();
  201. }
  202. }else if( !this.loaded ){
  203. actionNode.click();
  204. this.loaded = true;
  205. }
  206. return actionNode;
  207. },
  208. hideMenu: function(){
  209. },
  210. showMenu: function(){
  211. if (this.menuMode!="show") {
  212. this.topMenu.set("tween", {duration: 100, transition: "bounce:out"});
  213. //this.bottomMenu.set("tween", {duration: 100, transition: "bounce:out"});
  214. this.topMenu.tween("top", "-50px", "0px");
  215. //this.bottomMenu.tween("bottom", "-50px", "0px");
  216. this.menuMode = "show";
  217. if (this.topMenuPoint) this.topMenuPoint.setStyle("display", "none");
  218. if (this.bottomMenuPoint) this.bottomMenuPoint.setStyle("display", "none");
  219. }
  220. },
  221. hideCurrentView: function(){
  222. if (this.currentView){
  223. this.currentView.hide();
  224. this.currentView = null;
  225. }
  226. },
  227. toMyMeeting: function(){
  228. this.contentNode.setStyles(this.css.contentNode);
  229. //if ((!this.myMeetingView) || this.currentView!=this.myMeetingView){
  230. // this.hideCurrentView();
  231. // this.getMyMeetingView(function(){
  232. // this.myMeetingView.show();
  233. // this.currentView = this.myMeetingView;
  234. // }.bind(this));
  235. //}
  236. if( this.currentView ){
  237. this.currentView.destroy();
  238. this.currentView = null;
  239. }
  240. this.myMeetingView = null;
  241. this.getMyMeetingView(function(){
  242. this.myMeetingView.show();
  243. this.currentView = this.myMeetingView;
  244. }.bind(this));
  245. },
  246. getMyMeetingView: function(callback){
  247. if (!this.myMeetingView){
  248. MWF.xDesktop.requireApp("Meeting", "MeetingView", function(){
  249. var options;
  250. if( this.status && this.status.options ){
  251. options = this.status.options
  252. }
  253. this.myMeetingView = new MWF.xApplication.Meeting.MeetingView(this.contentNode, this, options);
  254. if( options )this.status.options = null;
  255. if (callback) callback();
  256. }.bind(this));
  257. }else{
  258. if (callback) callback();
  259. }
  260. },
  261. toList: function(){
  262. this.contentNode.setStyle("background", "#EEE");
  263. //if ((!this.listView) || this.currentView!=this.listView){
  264. // this.hideCurrentView();
  265. // this.getListView(function(){
  266. // this.listView.show();
  267. // this.currentView = this.listView;
  268. // }.bind(this));
  269. //}
  270. if( this.currentView ){
  271. this.currentView.destroy();
  272. this.currentView = null;
  273. }
  274. this.listView = null;
  275. this.getListView(function(){
  276. this.listView.show();
  277. this.currentView = this.listView;
  278. }.bind(this));
  279. },
  280. getListView: function(callback){
  281. if (!this.listView){
  282. MWF.xDesktop.requireApp("Meeting", "ListView", function(){
  283. var options;
  284. if( this.status && this.status.options ){
  285. options = this.status.options
  286. }
  287. this.listView = new MWF.xApplication.Meeting.ListView(this.contentNode, this, options);
  288. if( options )this.status.options = null;
  289. if (callback) callback();
  290. }.bind(this));
  291. }else{
  292. if (callback) callback();
  293. }
  294. },
  295. toMonth: function(){
  296. this.contentNode.setStyle("background", "#EEE");
  297. //if ((!this.monthView) || this.currentView!=this.monthView){
  298. // this.hideCurrentView();
  299. // this.getMonthView(function(){
  300. // this.monthView.show();
  301. // this.currentView = this.monthView;
  302. // }.bind(this));
  303. //}
  304. if( this.currentView ){
  305. this.currentView.destroy();
  306. this.currentView = null;
  307. }
  308. this.monthView = null;
  309. this.getMonthView(function(){
  310. this.monthView.show();
  311. this.currentView = this.monthView;
  312. }.bind(this));
  313. },
  314. getMonthView: function(callback){
  315. if (!this.monthView){
  316. MWF.xDesktop.requireApp("Meeting", "MonthView", function(){
  317. var options;
  318. if( this.status && this.status.options ){
  319. options = this.status.options
  320. }
  321. this.monthView = new MWF.xApplication.Meeting.MonthView(this.contentNode, this, options);
  322. if( options )this.status.options = null;
  323. if (callback) callback();
  324. }.bind(this));
  325. }else{
  326. if (callback) callback();
  327. }
  328. },
  329. toWeek: function(){
  330. this.contentNode.setStyle("background", "#EEE");
  331. //if ((!this.monthView) || this.currentView!=this.monthView){
  332. // this.hideCurrentView();
  333. // this.getMonthView(function(){
  334. // this.monthView.show();
  335. // this.currentView = this.monthView;
  336. // }.bind(this));
  337. //}
  338. if( this.currentView ){
  339. this.currentView.destroy();
  340. this.currentView = null;
  341. }
  342. this.weekView = null;
  343. this.getWeekView(function(){
  344. this.weekView.show();
  345. this.currentView = this.weekView;
  346. }.bind(this));
  347. },
  348. getWeekView: function(callback){
  349. if (!this.weekView){
  350. MWF.xDesktop.requireApp("Meeting", "WeekView", function(){
  351. var options;
  352. if( this.status && this.status.options ){
  353. options = this.status.options
  354. }
  355. this.weekView = new MWF.xApplication.Meeting.WeekView(this.contentNode, this, options);
  356. if( options )this.status.options = null;
  357. if (callback) callback();
  358. }.bind(this));
  359. }else{
  360. if (callback) callback();
  361. }
  362. },
  363. toDay: function(d){
  364. this.contentNode.setStyle("background", "#EEE");
  365. //if ((!this.dayView) || this.currentView!=this.dayView){
  366. // this.hideCurrentView();
  367. // this.getDayView(function(){
  368. // this.dayView.show();
  369. // this.currentView = this.dayView;
  370. // }.bind(this), d);
  371. //}
  372. if( this.currentView ){
  373. this.currentView.destroy();
  374. this.currentView = null;
  375. }
  376. this.dayView = null;
  377. this.getDayView(function(){
  378. this.dayView.show();
  379. this.currentView = this.dayView;
  380. }.bind(this), d);
  381. },
  382. getDayView: function(callback, d){
  383. if (!this.dayView){
  384. MWF.xDesktop.requireApp("Meeting", "DayView", function(){
  385. var options;
  386. if( this.status && this.status.options ){
  387. options = this.status.options
  388. }
  389. this.dayView = new MWF.xApplication.Meeting.DayView(this.contentNode, this, options || {"date": d});
  390. if(this.status)this.status.options = null;
  391. if (callback) callback();
  392. }.bind(this));
  393. }else{
  394. this.dayView.toDay(d);
  395. if (callback) callback();
  396. }
  397. },
  398. toRoom: function(){
  399. this.contentNode.setStyle("background", "#EEE");
  400. //if ((!this.roomView) || this.currentView!=this.roomView){
  401. // this.hideCurrentView();
  402. // this.getRoomView(function(){
  403. // this.roomView.show();
  404. // this.currentView = this.roomView;
  405. // }.bind(this));
  406. //}
  407. if( this.currentView ){
  408. this.currentView.destroy();
  409. this.currentView = null;
  410. }
  411. this.roomView = null;
  412. this.getRoomView(function(){
  413. this.roomView.show();
  414. this.currentView = this.roomView;
  415. }.bind(this));
  416. },
  417. getRoomView: function(callback){
  418. if (!this.roomView){
  419. MWF.xDesktop.requireApp("Meeting", "RoomView", function(){
  420. var options;
  421. if( this.status && this.status.options ){
  422. options = this.status.options
  423. }
  424. this.roomView = new MWF.xApplication.Meeting.RoomView(this.contentNode, this, options);
  425. if( options )this.status.options = null;
  426. if (callback) callback();
  427. }.bind(this));
  428. }else{
  429. if (callback) callback();
  430. }
  431. },
  432. //refresh: function(){
  433. // //this.hideMenu();
  434. // if (this.currentView) this.currentView.reload();
  435. //},
  436. addMeeting: function(date, hour, minute, room, processData, latest){
  437. MWF.UD.getPublicData("meetingConfig", function(json){
  438. var process = (json) ? json.process : null;
  439. if (process){
  440. this.loadMeetingProcess(process, processData, latest);
  441. }else{
  442. //new MWF.xApplication.Meeting.Creator(this, date, hour, room);
  443. var form = new MWF.xApplication.Meeting.MeetingForm(this,{}, {
  444. date : date,
  445. hour : hour,
  446. minute : minute,
  447. room : room
  448. }, {app:this});
  449. form.view = this;
  450. form.create();
  451. //this.hideMenu();
  452. }
  453. }.bind(this));
  454. },
  455. loadMeetingProcess: function(id, processData, latest){
  456. this.getProcess(id, function(process){
  457. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  458. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this, {
  459. "latest" : latest,
  460. "workData" : processData,
  461. "onStarted": function(data, title, processName){
  462. this.afterStartProcess(data, title, processName);
  463. }.bind(this)
  464. });
  465. starter.load();
  466. }.bind(this));
  467. }.bind(this));
  468. },
  469. afterStartProcess: function(data, title, processName){
  470. var workInfors = [];
  471. var currentTask = [];
  472. data.each(function(work){
  473. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  474. workInfors.push(this.getStartWorkInforObj(work));
  475. }.bind(this));
  476. if (currentTask.length===1){
  477. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  478. this.desktop.openApplication(null, "process.Work", options);
  479. this.createStartWorkResault(workInfors, title, processName, false);
  480. }else{
  481. this.createStartWorkResault(workInfors, title, processName, true);
  482. }
  483. },
  484. createStartWorkResault: function(workInfors, title, processName, isopen){
  485. var content = "";
  486. workInfors.each(function(infor){
  487. var users = [];
  488. infor.users.each(function(uname){
  489. users.push(MWF.name.cn(uname));
  490. });
  491. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  492. if (infor.currentTask && isopen){
  493. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  494. }else{
  495. content += "</div>";
  496. }
  497. }.bind(this));
  498. var t = workInfors[0].title || title;
  499. var msg = {
  500. "subject": this.lp.processStarted,
  501. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+t+"”</div>"+content
  502. };
  503. var tooltip = layout.desktop.message.addTooltip(msg);
  504. var item = layout.desktop.message.addMessage(msg);
  505. this.setStartWorkResaultAction(tooltip);
  506. this.setStartWorkResaultAction(item);
  507. },
  508. getStartWorkInforObj: function(work){
  509. var title = "";
  510. var users = [];
  511. var currentTask = "";
  512. work.taskList.each(function(task, idx){
  513. title = task.title;
  514. users.push(task.person+"("+task.department + ")");
  515. if (work.currentTaskIndex===idx) currentTask = task.id;
  516. }.bind(this));
  517. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask, "title" : title };
  518. },
  519. setStartWorkResaultAction: function(item){
  520. var node = item.node.getElements("span");
  521. node.setStyles(this.css.dealStartedWorkAction);
  522. var _self = this;
  523. node.addEvent("click", function(e){
  524. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  525. _self.desktop.openApplication(e, "process.Work", options);
  526. });
  527. },
  528. getProcess: function(id, callback){
  529. // MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  530. // var action = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  531. // action.getProcess(id, function(json){
  532. if (callback) callback(id);
  533. // }.bind(this));
  534. // }.bind(this));
  535. },
  536. config: function(){
  537. new MWF.xApplication.Meeting.Config(this, this.meetingConfig);
  538. //this.hideMenu();
  539. },
  540. addRoom : function(){
  541. var form = new MWF.xApplication.Meeting.RoomForm(this,{}, {}, {app:this});
  542. form.view = this;
  543. form.create();
  544. //this.hideMenu();
  545. },
  546. recordStatus: function(){
  547. //alert( JSON.stringify(
  548. // {
  549. // action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  550. // options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  551. // }
  552. //) )
  553. return {
  554. action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  555. options : (this.currentView && this.currentView.recordStatus) ? this.currentView.recordStatus() : null
  556. };
  557. },
  558. reload: function( ){
  559. // if( this.inContainer ){
  560. if( this.currentView && this.currentView.reload ){
  561. this.currentView.reload();
  562. }else{
  563. this.refresh()
  564. }
  565. // }else{
  566. // this.refresh()
  567. // }
  568. },
  569. loadSideBar : function(){
  570. this.sideBar = new MWF.xApplication.Meeting.SideBar(this.node, this);
  571. this.sideBar.show();
  572. },
  573. isMeetingViewer : function( callback ){
  574. if( typeOf( this._isMeetingViewer ) == "boolean"){
  575. if(callback)callback( this._isMeetingViewer );
  576. return;
  577. }
  578. var meetingViewer = this.meetingConfig.meetingViewer;
  579. if( !meetingViewer || !meetingViewer.length ){
  580. this._isMeetingViewer = false;
  581. if(callback)callback( this._isMeetingViewer );
  582. return;
  583. }
  584. if( this.isManager ){
  585. this._isMeetingViewer = true;
  586. if(callback)callback( this._isMeetingViewer );
  587. return;
  588. }
  589. if( typeOf( meetingViewer ) != "array" )meetingViewer = [meetingViewer];
  590. MWF.Actions.get("x_organization_assemble_personal").getPerson(function( json ){
  591. //this.actions.getCurrentPerson( function( json ){
  592. var dn = json.data.distinguishedName;
  593. //var dn = this.desktop.session.user.distinguishedName;
  594. if( meetingViewer.contains( dn ) ){
  595. this._isMeetingViewer = true;
  596. if(callback)callback( this._isMeetingViewer );
  597. return;
  598. }
  599. for( var i=0; i<json.data.woGroupList.length; i++ ){
  600. if( meetingViewer.contains( json.data.woGroupList[i].distinguishedName ) ){
  601. this._isMeetingViewer = true;
  602. if(callback)callback( this._isMeetingViewer );
  603. return;
  604. }
  605. }
  606. //var personList = [ dn ];
  607. this.personActions.listUnitSupNestedWithPersonValue({"personList":[dn]}, function(js){
  608. for( var i=0; i<js.data.unitList.length; i++ ){
  609. if( meetingViewer.contains( js.data.unitList[i] ) ){
  610. this._isMeetingViewer = true;
  611. if(callback)callback( this._isMeetingViewer );
  612. return;
  613. }
  614. }
  615. this._isMeetingViewer = false;
  616. if(callback)callback( this._isMeetingViewer );
  617. }.bind(this),null, false );
  618. }.bind(this), null, false)
  619. }
  620. });
  621. MWF.xApplication.Meeting.Config = new Class({
  622. Implements: [Events],
  623. initialize: function(app){
  624. this.app = app;
  625. this.css = this.app.css;
  626. this.lp = this.app.lp;
  627. this.configData = this.app.meetingConfig || {};
  628. this.process = null;
  629. MWF.UD.getPublicData("meetingConfig", function(json){
  630. var jsonData = json || {};
  631. if (jsonData.process){
  632. this.configData.process = jsonData.process;
  633. }else{
  634. this.configData.process = null;
  635. }
  636. if( jsonData.weekBegin ){
  637. this.configData.weekBegin = jsonData.weekBegin;
  638. }
  639. if( jsonData.meetingViewer ){
  640. this.configData.meetingViewer = jsonData.meetingViewer;
  641. }
  642. if( jsonData.mobileCreateEnable ){
  643. this.configData.mobileCreateEnable = jsonData.mobileCreateEnable;
  644. }
  645. for( var key in jsonData ){
  646. if( key != "process" && key != "weekBegin" && key != "meetingViewer" && key !="mobileCreateEnable"){
  647. this.configData[ key ] = jsonData[key];
  648. }
  649. }
  650. this.load();
  651. }.bind(this));
  652. },
  653. load: function(){
  654. this.node = new Element("div", {"styles": this.css.configNode}).inject(this.app.node);
  655. this.contentNode = new Element("div", {"styles": this.css.configContentNode}).inject(this.node);
  656. var statusStyle = "overflow: hidden;margin-top:6px;margin-left:10px;";
  657. var statusIconStyle = "float: left; width: 16px; height: 16px; border-radius: 100px; ";
  658. var statusIconStyle2 = "float: left; width: 14px; height: 14px; border-radius: 100px; ";
  659. var statusTextStyle = "margin-left:35px; line-height:16px; height:16px;font-size:14px;color:#666;";
  660. var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  661. var inputTextStyle = "float:right; width:120px; border:1px solid #ccc";
  662. var d = this.configData;
  663. var configLp = this.lp.config;
  664. var html =
  665. //"<div class='configTitle'>"+this.lp.config.meetingStatus+"</div>" +
  666. //
  667. //"<div style='"+ statusStyle +"'>"+
  668. //" <div style='"+ statusIconStyle + "background-color:#4990E2'></div>" +
  669. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.wait+"</div></div>" +
  670. //"</div>"+
  671. //
  672. //"<div style='"+ statusStyle +"'>"+
  673. //" <div style='"+ statusIconStyle + "background-color:#66CC7F'></div>" +
  674. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.progress+"</div></div>" +
  675. //"</div>"+
  676. //
  677. //"<div style='"+ statusStyle +"'>"+
  678. //" <div style='"+ statusIconStyle + "background-color:#F6A623'></div>" +
  679. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.invite+"</div></div>" +
  680. //"</div>"+
  681. //
  682. //"<div style='"+ statusStyle +"'>"+
  683. //" <div style='"+ statusIconStyle + "background-color:#ccc'></div>" +
  684. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.completed+"</div></div>" +
  685. //"</div>"+
  686. //
  687. //"<div style='"+ statusStyle +"'>"+
  688. //" <div style='"+ statusIconStyle2 + "border:2px solid #FF7F7F;'></div>" +
  689. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.conflict+"</div></div>" +
  690. //"</div>"+
  691. //
  692. //"<div class='line'></div>" +
  693. "<div class='configTitle'>"+this.lp.config["default"]+"</div>" +
  694. "<div>";
  695. if( !d.disableViewList.contains( "toMyMeeting" ) ){
  696. html +=
  697. " <div style='"+ viewStyle +"'>" +
  698. "<input type='radio' name='configSelectDefaultView' "+(((!d.defaultView) || d.defaultView=="toMyMeeting") ? "checked" : "")+" value='toMyMeeting'>"+ ( d.toMyMeetingViewName || this.lp.myMeeting )+
  699. " </div>";
  700. }
  701. if( !d.disableViewList.contains( "toMonth" ) ){
  702. html +=
  703. " <div style='"+ viewStyle +"'>" +
  704. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toMonth") ? "checked" : "")+" value='toMonth'>"+ ( d.toMonthViewName || this.lp.month )+
  705. " </div>";
  706. }
  707. if( !d.disableViewList.contains( "toWeek" ) ){
  708. html +=
  709. " <div style='"+ viewStyle +"'>" +
  710. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toWeek") ? "checked" : "")+" value='toWeek'>"+( d.toWeekViewName || this.lp.week )+
  711. " </div>";
  712. }
  713. if( !d.disableViewList.contains( "toDay" ) ){
  714. html +=
  715. " <div style='"+ viewStyle +"'>" +
  716. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toDay") ? "checked" : "")+" value='toDay'>"+(d.toDayViewName || this.lp.day)+
  717. " </div>";
  718. }
  719. if( !d.disableViewList.contains( "toList" ) ){
  720. html +=
  721. " <div style='"+ viewStyle +"'>" +
  722. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toList") ? "checked" : "")+" value='toList'>"+(d.toListViewName || this.lp.list)+
  723. " </div>";
  724. }
  725. if( !d.disableViewList.contains( "toRoom" ) ){
  726. html +=
  727. " <div style='"+ viewStyle +"'>" +
  728. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toRoom") ? "checked" : "")+" value='toRoom'>"+(d.toRoomViewName || this.lp.room)+
  729. " </div>";
  730. }
  731. html +="</div>";
  732. if( MWF.AC.isMeetingAdministrator() ){
  733. d.disableViewList = d.disableViewList || [];
  734. html += "<div class='line'></div>"+
  735. "<div class='configTitle'>"+this.lp.config.viewSetting +"</div>" +
  736. "<div>"+
  737. " <div style='"+ viewStyle +"'>" +
  738. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMyMeeting" ) ? "checked" : "")+" value='toMyMeeting'>"+this.lp.myMeeting+
  739. "<input type='text' name='toMyMeetingViewName' value='" + (d.toMyMeetingViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  740. " </div>" +
  741. " <div style='"+ viewStyle +"'>" +
  742. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMonth" ) ? "checked" : "")+" value='toMonth'>"+this.lp.month+
  743. "<input type='text' name='toMonthViewName' value='" + (d.toMonthViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  744. " </div>" +
  745. " <div style='"+ viewStyle +"'>" +
  746. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toWeek" ) ? "checked" : "")+" value='toWeek'>"+this.lp.week+
  747. "<input type='text' name='toWeekViewName' value='" + (d.toWeekViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  748. " </div>" +
  749. " <div style='"+ viewStyle +"'>" +
  750. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toDay" ) ? "checked" : "")+" value='toDay'>"+this.lp.day+
  751. "<input type='text' name='toDayViewName' value='" + (d.toDayViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  752. " </div>" +
  753. " <div style='"+ viewStyle +"'>" +
  754. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toList" ) ? "checked" : "")+" value='toList'>"+this.lp.list+
  755. "<input type='text' name='toListViewName' value='" + (d.toListViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  756. " </div>" +
  757. " <div style='"+ viewStyle +"'>" +
  758. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toRoom" ) ? "checked" : "")+" value='toRoom'>"+this.lp.room+
  759. "<input type='text' name='toRoomViewName' value='" + (d.toRoomViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  760. " </div>" +
  761. "</div>" +
  762. "<div class='line'></div>"+
  763. "<div class='configTitle'>"+this.lp.config.weekBegin +"</div>" +
  764. "<div><select name='configSelectWeekBeign'>"+
  765. "<option value='0' "+((d.weekBegin=="0") ? "selected" : "")+">"+this.lp.weeks.Sun+"</option>"+
  766. "<option value='1' "+((d.weekBegin=="1") ? "selected" : "")+">"+this.lp.weeks.Mon+"</option>"+
  767. //"<option value='2'"+((d.weekBegin=="2") ? "selected" : "")+">"+this.lp.weeks.Tues+"</option>"+
  768. //"<option value='3'"+((d.weekBegin=="3") ? "selected" : "")+">"+this.lp.weeks.Wed+"</option>"+
  769. //"<option value='4'"+((d.weekBegin=="4") ? "selected" : "")+">"+this.lp.weeks.Thur+"</option>"+
  770. //"<option value='5'"+((d.weekBegin=="5") ? "selected" : "")+">"+this.lp.weeks.Fri+"</option>"+
  771. //"<option value='6'"+((d.weekBegin=="6") ? "selected" : "")+">"+this.lp.weeks.Sat+"</option>"+
  772. "</select></div>"+
  773. "<div class='line'></div>"+
  774. "<div class='configTitle'>"+this.lp.config.applyProcess+"</div>" +
  775. "<div item='processArea'></div>" +
  776. //"<div class='line'></div>"+
  777. "<div class='configTitle' title='"+ this.lp.config.meetingViewerTitle +"'>"+this.lp.config.meetingViewer +"</div>" +
  778. "<div item='meetingViewerNode'></div>" +
  779. "<div class='configTitle'>"+this.lp.config.mobileCreateEnable +"</div>" +
  780. "<div item='mobileCreateEnable'></div>";
  781. }
  782. this.contentNode.set("html", html);
  783. this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  784. this.contentNode.getElements("div.configTitle").setStyles(this.css.configTitleDiv);
  785. if( MWF.AC.isMeetingAdministrator() ){
  786. this.processNode = this.contentNode.getElement("[item='processArea']");
  787. this.processNode.setStyles(this.css.configProcessNode);
  788. this.createApplicationSelect();
  789. this.meetingViewerNode = this.contentNode.getElement("[item='meetingViewerNode']");
  790. //this.meetingViewerNode.setStyles(this.css.configProcessNode);
  791. this.meetingViewer = new MDomItem(this.meetingViewerNode, {
  792. name : "meetingViewer", type : "org", orgType : ["person","unit","group"], count : 0, style : this.css.configMeetingViewerNode,
  793. value : d.meetingViewer || []
  794. } , null, this.app );
  795. this.meetingViewer.load();
  796. this.mobileCreateEnableNode = this.contentNode.getElement("[item='mobileCreateEnable']");
  797. this.mobileCreateEnable = new MDomItem(this.mobileCreateEnableNode, {
  798. name : "mobileCreateEnable", type : "select", selectValue : ["true","false"], selectText : this.lp.config.mobileCreateEnableOptions,
  799. value : d.mobileCreateEnable || "true"
  800. } , null, this.app );
  801. this.mobileCreateEnable.load();
  802. }
  803. this.actionNode = new Element("div", {"styles": this.css.configActionNode}).inject(this.node);
  804. this.cancelNode = new Element("div", {"styles": this.css.configActionCancelNode, "text": this.app.lp.cancel}).inject(this.actionNode);
  805. this.saveNode = new Element("div", {"styles": this.css.configActionSaveNode, "text": this.app.lp.save}).inject(this.actionNode);
  806. this.cancelNode.addEvent("click", this.hide.bind(this));
  807. this.saveNode.addEvent("click", this.save.bind(this));
  808. this.node.addEvent("mousedown", function(e){e.stopPropagation();}.bind(this));
  809. this.setSize();
  810. this.show();
  811. },
  812. setSize : function(){
  813. var sizeY = this.node.getSize().y;
  814. var y = this.app.content.getSize().y;
  815. if( sizeY > y-50 ){
  816. this.node.setStyle("height", y-50 );
  817. }
  818. },
  819. createApplicationSelect: function(){
  820. if (this.configData.process){
  821. MWF.require("MWF.widget.O2Identity", function(){
  822. var p = new MWF.widget.O2Process(this.configData.process, this.processNode);
  823. }.bind(this));
  824. }
  825. this.processNode.addEvent("click", function(){
  826. MWF.xDesktop.requireApp("Selector", "package", function(){
  827. var options = {
  828. "type": "Process",
  829. "values": [this.process || this.configData.process],
  830. "count": 1,
  831. "onComplete": function (items) {
  832. this.processNode.empty();
  833. this.process = null;
  834. this.configData.process = null;
  835. if (items.length){
  836. MWF.require("MWF.widget.O2Identity", function(){
  837. var p = new MWF.widget.O2Process(items[0].data, this.processNode);
  838. this.process = {
  839. "name": items[0].data.name,
  840. "id": items[0].data.id,
  841. "application": items[0].data.application,
  842. "applicationName": items[0].data.applicationName,
  843. "alias": items[0].data.alias
  844. };
  845. this.configData.process = this.process;
  846. }.bind(this));
  847. }
  848. }.bind(this)
  849. };
  850. var selector = new MWF.O2Selector(this.app.content, options);
  851. }.bind(this));
  852. }.bind(this));
  853. },
  854. save: function(){
  855. //var hideMenu = "auto";
  856. var defaultView = "toMyMeeting";
  857. var process = null;
  858. //var node = this.contentNode.getFirst("div");
  859. //var hideMenuNode = node.getElement("input");
  860. //if (hideMenuNode) if (!hideMenuNode.checked) hideMenu = "static";
  861. //node = node.getNext();
  862. var viewNodes = this.contentNode.getElements("input[name='configSelectDefaultView']");
  863. for (var i=0; i<viewNodes.length; i++){
  864. if (viewNodes[i].checked){
  865. defaultView = viewNodes[i].get("value");
  866. break;
  867. }
  868. }
  869. MWF.UD.putData("meetingConfig", {
  870. //"hideMenu": hideMenu,
  871. "defaultView": defaultView
  872. }, null, false);
  873. if( MWF.AC.isMeetingAdministrator() ){
  874. //if (this.processSelect){
  875. //process = this.processSelect.options[this.processSelect.selectedIndex].get("value");
  876. //MWF.UD.putPublicData("meetingConfig", {"process": process});
  877. //}
  878. var disableViewList = [];
  879. var viewAvailableNodes = this.contentNode.getElements("input[name='configAvailableView']");
  880. for (var i=0; i<viewAvailableNodes.length; i++){
  881. if ( !viewAvailableNodes[i].checked){
  882. disableViewList.push( viewAvailableNodes[i].get("value") ) ;
  883. }
  884. }
  885. var weekBeginSelect = this.contentNode.getElement("select[name='configSelectWeekBeign']");
  886. var weekBeginValue = "0";
  887. if( weekBeginSelect ){
  888. weekBeginValue = weekBeginSelect.options[weekBeginSelect.selectedIndex].get("value");
  889. }
  890. var viewer = null;
  891. if( this.meetingViewer ){
  892. viewer = this.meetingViewer.getValue();
  893. }
  894. MWF.UD.putPublicData("meetingConfig", {
  895. //"hideMenu": hideMenu,
  896. "process": this.process || this.configData.process,
  897. "weekBegin" : weekBeginValue,
  898. "meetingViewer" : viewer,
  899. "mobileCreateEnable" : this.mobileCreateEnable.getValue(),
  900. "disableViewList" : disableViewList,
  901. "toMyMeetingViewName" : this.contentNode.getElement("input[name='toMyMeetingViewName']").get("value"),
  902. "toMonthViewName" : this.contentNode.getElement("input[name='toMonthViewName']").get("value"),
  903. "toWeekViewName" : this.contentNode.getElement("input[name='toWeekViewName']").get("value"),
  904. "toDayViewName" : this.contentNode.getElement("input[name='toDayViewName']").get("value"),
  905. "toListViewName" : this.contentNode.getElement("input[name='toListViewName']").get("value"),
  906. "toRoomViewName" : this.contentNode.getElement("input[name='toRoomViewName']").get("value")
  907. }, null, false);
  908. }
  909. this.app.notice( this.app.lp.config_saveSuccess, "success" );
  910. this.hide();
  911. },
  912. show: function(){
  913. this.node.setStyles(this.css.configNode);
  914. var fx = new Fx.Morph(this.node, {
  915. "duration": "500",
  916. "transition": Fx.Transitions.Expo.easeOut
  917. });
  918. fx.start({
  919. "opacity": 1
  920. }).chain(function(){
  921. this.hideFun = this.hide.bind(this);
  922. this.app.node.addEvent("mousedown", this.hideFun);
  923. }.bind(this));
  924. },
  925. hide: function(){
  926. this.node.destroy();
  927. this.app.node.removeEvent("mousedown", this.hideFun);
  928. MWF.release(this);
  929. }
  930. });