Main.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  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", {"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){
  437. MWF.UD.getPublicData("meetingConfig", function(json){
  438. var process = (json) ? json.process : null;
  439. if (process){
  440. this.loadMeetingProcess(process, processData);
  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){
  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. "workData" : processData,
  460. "onStarted": function(data, title, processName){
  461. this.afterStartProcess(data, title, processName);
  462. }.bind(this)
  463. });
  464. starter.load();
  465. }.bind(this));
  466. }.bind(this));
  467. },
  468. afterStartProcess: function(data, title, processName){
  469. var workInfors = [];
  470. var currentTask = [];
  471. data.each(function(work){
  472. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  473. workInfors.push(this.getStartWorkInforObj(work));
  474. }.bind(this));
  475. if (currentTask.length===1){
  476. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  477. this.desktop.openApplication(null, "process.Work", options);
  478. this.createStartWorkResault(workInfors, title, processName, false);
  479. }else{
  480. this.createStartWorkResault(workInfors, title, processName, true);
  481. }
  482. },
  483. createStartWorkResault: function(workInfors, title, processName, isopen){
  484. var content = "";
  485. workInfors.each(function(infor){
  486. var users = [];
  487. infor.users.each(function(uname){
  488. users.push(MWF.name.cn(uname));
  489. });
  490. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  491. if (infor.currentTask && isopen){
  492. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  493. }else{
  494. content += "</div>";
  495. }
  496. }.bind(this));
  497. var msg = {
  498. "subject": this.lp.processStarted,
  499. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  500. };
  501. var tooltip = layout.desktop.message.addTooltip(msg);
  502. var item = layout.desktop.message.addMessage(msg);
  503. this.setStartWorkResaultAction(tooltip);
  504. this.setStartWorkResaultAction(item);
  505. },
  506. getStartWorkInforObj: function(work){
  507. var users = [];
  508. var currentTask = "";
  509. work.taskList.each(function(task, idx){
  510. users.push(task.person+"("+task.department + ")");
  511. if (work.currentTaskIndex===idx) currentTask = task.id;
  512. }.bind(this));
  513. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  514. },
  515. setStartWorkResaultAction: function(item){
  516. var node = item.node.getElements("span");
  517. node.setStyles(this.app.css.dealStartedWorkAction);
  518. var _self = this;
  519. node.addEvent("click", function(e){
  520. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  521. _self.desktop.openApplication(e, "process.Work", options);
  522. });
  523. },
  524. getProcess: function(id, callback){
  525. // MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  526. // var action = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  527. // action.getProcess(id, function(json){
  528. if (callback) callback(id);
  529. // }.bind(this));
  530. // }.bind(this));
  531. },
  532. config: function(){
  533. new MWF.xApplication.Meeting.Config(this, this.meetingConfig);
  534. //this.hideMenu();
  535. },
  536. addRoom : function(){
  537. var form = new MWF.xApplication.Meeting.RoomForm(this,{}, {}, {app:this});
  538. form.view = this;
  539. form.create();
  540. //this.hideMenu();
  541. },
  542. recordStatus: function(){
  543. //alert( JSON.stringify(
  544. // {
  545. // action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  546. // options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  547. // }
  548. //) )
  549. return {
  550. action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
  551. options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  552. };
  553. },
  554. reload: function( ){
  555. this.refresh()
  556. },
  557. loadSideBar : function(){
  558. this.sideBar = new MWF.xApplication.Meeting.SideBar(this.node, this);
  559. this.sideBar.show();
  560. },
  561. isMeetingViewer : function( callback ){
  562. if( typeOf( this._isMeetingViewer ) == "boolean"){
  563. if(callback)callback( this._isMeetingViewer );
  564. return;
  565. }
  566. var meetingViewer = this.meetingConfig.meetingViewer;
  567. if( !meetingViewer || !meetingViewer.length ){
  568. this._isMeetingViewer = false;
  569. if(callback)callback( this._isMeetingViewer );
  570. return;
  571. }
  572. if( this.isManager ){
  573. this._isMeetingViewer = true;
  574. if(callback)callback( this._isMeetingViewer );
  575. return;
  576. }
  577. if( typeOf( meetingViewer ) != "array" )meetingViewer = [meetingViewer];
  578. MWF.Actions.get("x_organization_assemble_personal").getPerson(function( json ){
  579. //this.actions.getCurrentPerson( function( json ){
  580. var dn = json.data.distinguishedName;
  581. //var dn = this.desktop.session.user.distinguishedName;
  582. if( meetingViewer.contains( dn ) ){
  583. this._isMeetingViewer = true;
  584. if(callback)callback( this._isMeetingViewer );
  585. return;
  586. }
  587. for( var i=0; i<json.data.woGroupList.length; i++ ){
  588. if( meetingViewer.contains( json.data.woGroupList[i].distinguishedName ) ){
  589. this._isMeetingViewer = true;
  590. if(callback)callback( this._isMeetingViewer );
  591. return;
  592. }
  593. }
  594. //var personList = [ dn ];
  595. this.personActions.listUnitSupNestedWithPersonValue({"personList":[dn]}, function(js){
  596. for( var i=0; i<js.data.unitList.length; i++ ){
  597. if( meetingViewer.contains( js.data.unitList[i] ) ){
  598. this._isMeetingViewer = true;
  599. if(callback)callback( this._isMeetingViewer );
  600. return;
  601. }
  602. }
  603. this._isMeetingViewer = false;
  604. if(callback)callback( this._isMeetingViewer );
  605. }.bind(this),null, false );
  606. }.bind(this), null, false)
  607. }
  608. });
  609. MWF.xApplication.Meeting.Config = new Class({
  610. Implements: [Events],
  611. initialize: function(app){
  612. this.app = app;
  613. this.css = this.app.css;
  614. this.lp = this.app.lp;
  615. this.configData = this.app.meetingConfig || {};
  616. this.process = null;
  617. MWF.UD.getPublicData("meetingConfig", function(json){
  618. var jsonData = json || {};
  619. if (jsonData.process){
  620. this.configData.process = jsonData.process;
  621. }else{
  622. this.configData.process = null;
  623. }
  624. if( jsonData.weekBegin ){
  625. this.configData.weekBegin = jsonData.weekBegin;
  626. }
  627. if( jsonData.meetingViewer ){
  628. this.configData.meetingViewer = jsonData.meetingViewer;
  629. }
  630. if( jsonData.mobileCreateEnable ){
  631. this.configData.mobileCreateEnable = jsonData.mobileCreateEnable;
  632. }
  633. for( var key in jsonData ){
  634. if( key != "process" && key != "weekBegin" && key != "meetingViewer" && key !="mobileCreateEnable"){
  635. this.configData[ key ] = jsonData[key];
  636. }
  637. }
  638. this.load();
  639. }.bind(this));
  640. },
  641. load: function(){
  642. this.node = new Element("div", {"styles": this.css.configNode}).inject(this.app.node);
  643. this.contentNode = new Element("div", {"styles": this.css.configContentNode}).inject(this.node);
  644. var statusStyle = "overflow: hidden;margin-top:6px;margin-left:10px;";
  645. var statusIconStyle = "float: left; width: 16px; height: 16px; border-radius: 100px; ";
  646. var statusIconStyle2 = "float: left; width: 14px; height: 14px; border-radius: 100px; ";
  647. var statusTextStyle = "margin-left:35px; line-height:16px; height:16px;font-size:14px;color:#666;";
  648. var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  649. var inputTextStyle = "float:right; width:120px; border:1px solid #ccc";
  650. var d = this.configData;
  651. var configLp = this.lp.config;
  652. var html =
  653. //"<div class='configTitle'>"+this.lp.config.meetingStatus+"</div>" +
  654. //
  655. //"<div style='"+ statusStyle +"'>"+
  656. //" <div style='"+ statusIconStyle + "background-color:#4990E2'></div>" +
  657. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.wait+"</div></div>" +
  658. //"</div>"+
  659. //
  660. //"<div style='"+ statusStyle +"'>"+
  661. //" <div style='"+ statusIconStyle + "background-color:#66CC7F'></div>" +
  662. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.progress+"</div></div>" +
  663. //"</div>"+
  664. //
  665. //"<div style='"+ statusStyle +"'>"+
  666. //" <div style='"+ statusIconStyle + "background-color:#F6A623'></div>" +
  667. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.invite+"</div></div>" +
  668. //"</div>"+
  669. //
  670. //"<div style='"+ statusStyle +"'>"+
  671. //" <div style='"+ statusIconStyle + "background-color:#ccc'></div>" +
  672. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.completed+"</div></div>" +
  673. //"</div>"+
  674. //
  675. //"<div style='"+ statusStyle +"'>"+
  676. //" <div style='"+ statusIconStyle2 + "border:2px solid #FF7F7F;'></div>" +
  677. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.conflict+"</div></div>" +
  678. //"</div>"+
  679. //
  680. //"<div class='line'></div>" +
  681. "<div class='configTitle'>"+this.lp.config["default"]+"</div>" +
  682. "<div>";
  683. if( !d.disableViewList.contains( "toMyMeeting" ) ){
  684. html +=
  685. " <div style='"+ viewStyle +"'>" +
  686. "<input type='radio' name='configSelectDefaultView' "+(((!d.defaultView) || d.defaultView=="toMyMeeting") ? "checked" : "")+" value='toMyMeeting'>"+ ( d.toMyMeetingViewName || this.lp.myMeeting )+
  687. " </div>";
  688. }
  689. if( !d.disableViewList.contains( "toMonth" ) ){
  690. html +=
  691. " <div style='"+ viewStyle +"'>" +
  692. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toMonth") ? "checked" : "")+" value='toMonth'>"+ ( d.toMonthViewName || this.lp.month )+
  693. " </div>";
  694. }
  695. if( !d.disableViewList.contains( "toWeek" ) ){
  696. html +=
  697. " <div style='"+ viewStyle +"'>" +
  698. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toWeek") ? "checked" : "")+" value='toWeek'>"+( d.toWeekViewName || this.lp.week )+
  699. " </div>";
  700. }
  701. if( !d.disableViewList.contains( "toDay" ) ){
  702. html +=
  703. " <div style='"+ viewStyle +"'>" +
  704. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toDay") ? "checked" : "")+" value='toDay'>"+(d.toDayViewName || this.lp.day)+
  705. " </div>";
  706. }
  707. if( !d.disableViewList.contains( "toList" ) ){
  708. html +=
  709. " <div style='"+ viewStyle +"'>" +
  710. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toList") ? "checked" : "")+" value='toList'>"+(d.toListViewName || this.lp.list)+
  711. " </div>";
  712. }
  713. if( !d.disableViewList.contains( "toRoom" ) ){
  714. html +=
  715. " <div style='"+ viewStyle +"'>" +
  716. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toRoom") ? "checked" : "")+" value='toRoom'>"+(d.toRoomViewName || this.lp.room)+
  717. " </div>";
  718. }
  719. html +="</div>";
  720. if( MWF.AC.isMeetingAdministrator() ){
  721. d.disableViewList = d.disableViewList || [];
  722. html += "<div class='line'></div>"+
  723. "<div class='configTitle'>"+this.lp.config.viewSetting +"</div>" +
  724. "<div>"+
  725. " <div style='"+ viewStyle +"'>" +
  726. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMyMeeting" ) ? "checked" : "")+" value='toMyMeeting'>"+this.lp.myMeeting+
  727. "<input type='text' name='toMyMeetingViewName' value='" + (d.toMyMeetingViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  728. " </div>" +
  729. " <div style='"+ viewStyle +"'>" +
  730. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMonth" ) ? "checked" : "")+" value='toMonth'>"+this.lp.month+
  731. "<input type='text' name='toMonthViewName' value='" + (d.toMonthViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  732. " </div>" +
  733. " <div style='"+ viewStyle +"'>" +
  734. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toWeek" ) ? "checked" : "")+" value='toWeek'>"+this.lp.week+
  735. "<input type='text' name='toWeekViewName' value='" + (d.toWeekViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  736. " </div>" +
  737. " <div style='"+ viewStyle +"'>" +
  738. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toDay" ) ? "checked" : "")+" value='toDay'>"+this.lp.day+
  739. "<input type='text' name='toDayViewName' value='" + (d.toDayViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  740. " </div>" +
  741. " <div style='"+ viewStyle +"'>" +
  742. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toList" ) ? "checked" : "")+" value='toList'>"+this.lp.list+
  743. "<input type='text' name='toListViewName' value='" + (d.toListViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  744. " </div>" +
  745. " <div style='"+ viewStyle +"'>" +
  746. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toRoom" ) ? "checked" : "")+" value='toRoom'>"+this.lp.room+
  747. "<input type='text' name='toRoomViewName' value='" + (d.toRoomViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  748. " </div>" +
  749. "</div>" +
  750. "<div class='line'></div>"+
  751. "<div class='configTitle'>"+this.lp.config.weekBegin +"</div>" +
  752. "<div><select name='configSelectWeekBeign'>"+
  753. "<option value='0' "+((d.weekBegin=="0") ? "selected" : "")+">"+this.lp.weeks.Sun+"</option>"+
  754. "<option value='1' "+((d.weekBegin=="1") ? "selected" : "")+">"+this.lp.weeks.Mon+"</option>"+
  755. //"<option value='2'"+((d.weekBegin=="2") ? "selected" : "")+">"+this.lp.weeks.Tues+"</option>"+
  756. //"<option value='3'"+((d.weekBegin=="3") ? "selected" : "")+">"+this.lp.weeks.Wed+"</option>"+
  757. //"<option value='4'"+((d.weekBegin=="4") ? "selected" : "")+">"+this.lp.weeks.Thur+"</option>"+
  758. //"<option value='5'"+((d.weekBegin=="5") ? "selected" : "")+">"+this.lp.weeks.Fri+"</option>"+
  759. //"<option value='6'"+((d.weekBegin=="6") ? "selected" : "")+">"+this.lp.weeks.Sat+"</option>"+
  760. "</select></div>"+
  761. "<div class='line'></div>"+
  762. "<div class='configTitle'>"+this.lp.config.applyProcess+"</div>" +
  763. "<div item='processArea'></div>" +
  764. //"<div class='line'></div>"+
  765. "<div class='configTitle' title='"+ this.lp.config.meetingViewerTitle +"'>"+this.lp.config.meetingViewer +"</div>" +
  766. "<div item='meetingViewerNode'></div>" +
  767. "<div class='configTitle'>"+this.lp.config.mobileCreateEnable +"</div>" +
  768. "<div item='mobileCreateEnable'></div>";
  769. }
  770. this.contentNode.set("html", html);
  771. this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  772. this.contentNode.getElements("div.configTitle").setStyles(this.css.configTitleDiv);
  773. if( MWF.AC.isMeetingAdministrator() ){
  774. this.processNode = this.contentNode.getElement("[item='processArea']");
  775. this.processNode.setStyles(this.css.configProcessNode);
  776. this.createApplicationSelect();
  777. this.meetingViewerNode = this.contentNode.getElement("[item='meetingViewerNode']");
  778. //this.meetingViewerNode.setStyles(this.css.configProcessNode);
  779. this.meetingViewer = new MDomItem(this.meetingViewerNode, {
  780. name : "meetingViewer", type : "org", orgType : ["person","unit","group"], count : 0, style : this.css.configMeetingViewerNode,
  781. value : d.meetingViewer || []
  782. } , null, this.app );
  783. this.meetingViewer.load();
  784. this.mobileCreateEnableNode = this.contentNode.getElement("[item='mobileCreateEnable']");
  785. this.mobileCreateEnable = new MDomItem(this.mobileCreateEnableNode, {
  786. name : "mobileCreateEnable", type : "select", selectValue : ["true","false"], selectText : this.lp.config.mobileCreateEnableOptions,
  787. value : d.mobileCreateEnable || "true"
  788. } , null, this.app );
  789. this.mobileCreateEnable.load();
  790. }
  791. this.actionNode = new Element("div", {"styles": this.css.configActionNode}).inject(this.node);
  792. this.cancelNode = new Element("div", {"styles": this.css.configActionCancelNode, "text": this.app.lp.cancel}).inject(this.actionNode);
  793. this.saveNode = new Element("div", {"styles": this.css.configActionSaveNode, "text": this.app.lp.save}).inject(this.actionNode);
  794. this.cancelNode.addEvent("click", this.hide.bind(this));
  795. this.saveNode.addEvent("click", this.save.bind(this));
  796. this.node.addEvent("mousedown", function(e){e.stopPropagation();}.bind(this));
  797. this.setSize();
  798. this.show();
  799. },
  800. setSize : function(){
  801. var sizeY = this.node.getSize().y;
  802. var y = this.app.content.getSize().y;
  803. if( sizeY > y-50 ){
  804. this.node.setStyle("height", y-50 );
  805. }
  806. },
  807. createApplicationSelect: function(){
  808. if (this.configData.process){
  809. MWF.require("MWF.widget.O2Identity", function(){
  810. var p = new MWF.widget.O2Process(this.configData.process, this.processNode);
  811. }.bind(this));
  812. }
  813. this.processNode.addEvent("click", function(){
  814. MWF.xDesktop.requireApp("Selector", "package", function(){
  815. var options = {
  816. "type": "Process",
  817. "values": [this.process || this.configData.process],
  818. "count": 1,
  819. "onComplete": function (items) {
  820. this.processNode.empty();
  821. this.process = null;
  822. this.configData.process = null;
  823. if (items.length){
  824. MWF.require("MWF.widget.O2Identity", function(){
  825. var p = new MWF.widget.O2Process(items[0].data, this.processNode);
  826. this.process = {
  827. "name": items[0].data.name,
  828. "id": items[0].data.id,
  829. "application": items[0].data.application,
  830. "applicationName": items[0].data.applicationName,
  831. "alias": items[0].data.alias
  832. };
  833. this.configData.process = this.process;
  834. }.bind(this));
  835. }
  836. }.bind(this)
  837. };
  838. var selector = new MWF.O2Selector(this.app.content, options);
  839. }.bind(this));
  840. }.bind(this));
  841. },
  842. save: function(){
  843. //var hideMenu = "auto";
  844. var defaultView = "toMyMeeting";
  845. var process = null;
  846. //var node = this.contentNode.getFirst("div");
  847. //var hideMenuNode = node.getElement("input");
  848. //if (hideMenuNode) if (!hideMenuNode.checked) hideMenu = "static";
  849. //node = node.getNext();
  850. var viewNodes = this.contentNode.getElements("input[name='configSelectDefaultView']");
  851. for (var i=0; i<viewNodes.length; i++){
  852. if (viewNodes[i].checked){
  853. defaultView = viewNodes[i].get("value");
  854. break;
  855. }
  856. }
  857. MWF.UD.putData("meetingConfig", {
  858. //"hideMenu": hideMenu,
  859. "defaultView": defaultView
  860. }, null, false);
  861. if( MWF.AC.isMeetingAdministrator() ){
  862. //if (this.processSelect){
  863. //process = this.processSelect.options[this.processSelect.selectedIndex].get("value");
  864. //MWF.UD.putPublicData("meetingConfig", {"process": process});
  865. //}
  866. var disableViewList = [];
  867. var viewAvailableNodes = this.contentNode.getElements("input[name='configAvailableView']");
  868. for (var i=0; i<viewAvailableNodes.length; i++){
  869. if ( !viewAvailableNodes[i].checked){
  870. disableViewList.push( viewAvailableNodes[i].get("value") ) ;
  871. }
  872. }
  873. var weekBeginSelect = this.contentNode.getElement("select[name='configSelectWeekBeign']");
  874. var weekBeginValue = "0";
  875. if( weekBeginSelect ){
  876. weekBeginValue = weekBeginSelect.options[weekBeginSelect.selectedIndex].get("value");
  877. }
  878. var viewer = null;
  879. if( this.meetingViewer ){
  880. viewer = this.meetingViewer.getValue();
  881. }
  882. MWF.UD.putPublicData("meetingConfig", {
  883. //"hideMenu": hideMenu,
  884. "process": this.process || this.configData.process,
  885. "weekBegin" : weekBeginValue,
  886. "meetingViewer" : viewer,
  887. "mobileCreateEnable" : this.mobileCreateEnable.getValue(),
  888. "disableViewList" : disableViewList,
  889. "toMyMeetingViewName" : this.contentNode.getElement("input[name='toMyMeetingViewName']").get("value"),
  890. "toMonthViewName" : this.contentNode.getElement("input[name='toMonthViewName']").get("value"),
  891. "toWeekViewName" : this.contentNode.getElement("input[name='toWeekViewName']").get("value"),
  892. "toDayViewName" : this.contentNode.getElement("input[name='toDayViewName']").get("value"),
  893. "toListViewName" : this.contentNode.getElement("input[name='toListViewName']").get("value"),
  894. "toRoomViewName" : this.contentNode.getElement("input[name='toRoomViewName']").get("value")
  895. }, null, false);
  896. }
  897. this.app.notice( this.app.lp.config_saveSuccess, "success" );
  898. this.hide();
  899. },
  900. show: function(){
  901. this.node.setStyles(this.css.configNode);
  902. var fx = new Fx.Morph(this.node, {
  903. "duration": "500",
  904. "transition": Fx.Transitions.Expo.easeOut
  905. });
  906. fx.start({
  907. "opacity": 1
  908. }).chain(function(){
  909. this.hideFun = this.hide.bind(this);
  910. this.app.node.addEvent("mousedown", this.hideFun);
  911. }.bind(this));
  912. },
  913. hide: function(){
  914. this.node.destroy();
  915. this.app.node.removeEvent("mousedown", this.hideFun);
  916. MWF.release(this);
  917. }
  918. });