ListView.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. MWF.xApplication.Meeting.ListView = new Class({
  2. Extends: MWF.widget.Common,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "date": null,
  7. "action" : ""
  8. },
  9. initialize: function(node, app, options){
  10. this.setOptions(options);
  11. this.path = "../x_component_Meeting/$ListView/";
  12. this.cssPath = "../x_component_Meeting/$ListView/"+this.options.style+"/css.wcss";
  13. this._loadCss();
  14. this.app = app;
  15. this.container = $(node);
  16. this.date = this.options.date || new Date();
  17. this.load();
  18. },
  19. load: function(){
  20. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  21. this.leftNode = new Element("div", {"styles": this.css.leftNode}).inject(this.node);
  22. this.contentAreaNode = new Element("div.contentAreaNode", {"styles": this.css.contentAreaNode}).inject(this.node);
  23. this.contentNode = new Element("div.contentNode", {"styles": this.css.contentNode}).inject(this.contentAreaNode);
  24. //this.loadSideBar();
  25. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  26. this.app.addEvent("resize", this.resetNodeSizeFun );
  27. this.loadLeftNavi();
  28. this.resetNodeSize();
  29. },
  30. resetNodeSize: function(){
  31. //var size = this.container.getSize();
  32. //if (this.app.meetingConfig.hideMenu=="static"){
  33. // var y = size.y-120;
  34. // this.node.setStyle("height", ""+y+"px");
  35. // this.node.setStyle("margin-top", "60px");
  36. //}else{
  37. // var y = size.y-20;
  38. // this.node.setStyle("height", ""+y+"px");
  39. //}
  40. //if( this.app.inContainer )return;
  41. var size = this.container.getSize();
  42. var y = size.y-60;
  43. this.node.setStyle("margin-top", "60px");
  44. this.node.setStyle("height", ""+y+"px");
  45. var sideBar = this.app.sideBar ? this.app.sideBar.getSize() : { x : 0, y : 0 };
  46. //var x = size.x - sideBar.x;
  47. //this.node.setStyle("width", ""+x+"px");
  48. this.contentAreaNode.setStyle("margin-right",sideBar.x+"px");
  49. },
  50. loadLeftNavi: function(){
  51. var menuNode = new Element("div.menuNode", {"styles": this.css.menuNode, "text": this.app.lp.listNavi.myApply}).inject(this.leftNode);
  52. this.loadNaviItem(this.app.lp.listNavi.wait, "toApplyWait");
  53. this.loadNaviItem(this.app.lp.listNavi.processing, "toApplyProcessing");
  54. this.loadNaviItem(this.app.lp.listNavi.completed, "toApplyCompleted");
  55. var menuNode = new Element("div.menuNode", {"styles": this.css.menuNode, "text": this.app.lp.listNavi.myMeeting}).inject(this.leftNode);
  56. this.loadNaviItem(this.app.lp.listNavi.wait, "toMeetingWait");
  57. this.loadNaviItem(this.app.lp.listNavi.processing, "toMeetingProcessing");
  58. this.loadNaviItem(this.app.lp.listNavi.completed, "toMeetingCompleted");
  59. this.loadNaviItem(this.app.lp.listNavi.reject, "toMeetingReject");
  60. //var menuNode = new Element("div", {"styles": this.css.menuNode, "text": this.app.lp.listNavi.room}).inject(this.leftNode);
  61. },
  62. loadNaviItem: function(text, action){
  63. var itemNode = new Element("div", {"styles": this.css.menuItemNode, "text": text}).inject(this.leftNode);
  64. var _self = this;
  65. itemNode.addEvents({
  66. "mouseover": function(){if (_self.currentNavi != this) this.setStyles(_self.css.menuItemNode_over);},
  67. "mouseout": function(){if (_self.currentNavi != this) this.setStyles(_self.css.menuItemNode);},
  68. "click": function(){
  69. if (_self.currentNavi){
  70. _self.currentNavi.setStyles(_self.css.menuItemNode);
  71. _self.currentNavi.removeClass("mainColor_bg_opacity");
  72. _self.currentNavi.removeClass("mainColor_color");
  73. }
  74. _self.currentNavi = this;
  75. this.setStyles(_self.css.menuItemNode_current);
  76. _self.currentNavi.addClass("mainColor_bg_opacity");
  77. _self.currentNavi.addClass("mainColor_color");
  78. if (_self[action]) _self[action]();
  79. }
  80. });
  81. itemNode.store("action",action);
  82. if( this.options.action == action){
  83. itemNode.click();
  84. }else if( action == "toApplyWait"){
  85. itemNode.click();
  86. }
  87. },
  88. toApplyWait: function(){
  89. if (this.currentView) this.currentView.destroy();
  90. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyWait(this);
  91. },
  92. toApplyProcessing: function(){
  93. if (this.currentView) this.currentView.destroy();
  94. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyProcessing(this);
  95. },
  96. toApplyCompleted: function(){
  97. if (this.currentView) this.currentView.destroy();
  98. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyCompleted(this);
  99. },
  100. toMeetingWait: function(){
  101. if (this.currentView) this.currentView.destroy();
  102. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingWait(this);
  103. },
  104. toMeetingProcessing: function(){
  105. if (this.currentView) this.currentView.destroy();
  106. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingProcessing(this);
  107. },
  108. toMeetingCompleted: function(){
  109. if (this.currentView) this.currentView.destroy();
  110. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingCompleted(this);
  111. },
  112. toMeetingReject: function(){
  113. if (this.currentView) this.currentView.destroy();
  114. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingReject(this);
  115. },
  116. hide: function(){
  117. var fx = new Fx.Morph(this.node, {
  118. "duration": "300",
  119. "transition": Fx.Transitions.Expo.easeOut
  120. });
  121. fx.start({
  122. "opacity": 0
  123. }).chain(function(){
  124. this.node.setStyle("display", "none");
  125. }.bind(this));
  126. },
  127. show: function(){
  128. this.node.setStyles(this.css.node);
  129. if( this.app.inContainer ){
  130. this.node.setStyles({
  131. "opacity": 1,
  132. "position": "static",
  133. "width": "auto"
  134. });
  135. }else{
  136. var fx = new Fx.Morph(this.node, {
  137. "duration": "800",
  138. "transition": Fx.Transitions.Expo.easeOut
  139. });
  140. this.app.fireAppEvent("resize");
  141. fx.start({
  142. "opacity": 1,
  143. "left": "0px"
  144. }).chain(function(){
  145. this.node.setStyles({
  146. "position": "static",
  147. "width": "auto"
  148. });
  149. }.bind(this));
  150. }
  151. },
  152. reload: function(){
  153. if( this.currentView ){
  154. this.currentView.reload();
  155. }else{
  156. this.app.reload();
  157. }
  158. },
  159. recordStatus : function(){
  160. var action = "";
  161. if( this.currentNavi )action = this.currentNavi.retrieve("action");
  162. return {
  163. action : action
  164. };
  165. },
  166. destroy : function(){
  167. if( this.currentView ){
  168. this.currentView.destroy()
  169. }
  170. this.app.removeEvent("resize", this.resetNodeSizeFun );
  171. this.node.destroy();
  172. }
  173. });
  174. MWF.xApplication.Meeting.ListView.View = new Class({
  175. initialize: function(view, action){
  176. this.view = view;
  177. this.css = this.view.css;
  178. this.container = this.view.contentNode;
  179. this.app = this.view.app;
  180. this.items = [];
  181. this.load();
  182. },
  183. reload : function(){
  184. this.items = [];
  185. this.container.empty();
  186. this.load();
  187. },
  188. load: function(){
  189. this.loadHead();
  190. MWF.require("MWF.widget.Mask", function(){
  191. this.mask = new MWF.widget.Mask({"style": "desktop"});
  192. this.mask.loadNode(this.view.contentAreaNode);
  193. }.bind(this));
  194. this.loadList();
  195. },
  196. loadHead: function(){
  197. this.table = new Element("table", {
  198. "styles": this.css.listViewTable,
  199. "border": "0",
  200. "cellPadding": "0",
  201. "cellSpacing": "0",
  202. "html": "<tr><th>"+this.app.lp.applyPerson+"</th><th>"+this.app.lp.beginDate+"</th><th>"+this.app.lp.time+"</th><th>"+this.app.lp.subject+"</th><th>"+this.app.lp.room+"</th></tr>"
  203. }).inject(this.container);
  204. this.table.getElements("th").setStyles(this.css.listViewTableTh);
  205. },
  206. loadList: function() {
  207. this.app.actions.listMeetingApplyWait(function (json) {
  208. this.loadLines(json.data);
  209. }.bind(this));
  210. },
  211. loadLines: function(items){
  212. items.each(function(item){
  213. this.loadLine(item);
  214. }.bind(this));
  215. if (this.mask){
  216. this.mask.hide(function(){
  217. //MWF.release(this.mask);
  218. this.mask = null;
  219. }.bind(this));
  220. }
  221. },
  222. loadLine: function(item){
  223. this.items.push(new MWF.xApplication.Meeting.ListView.View.Line(this, item));
  224. },
  225. destroy: function(){
  226. this.items.each(function(item){
  227. item.destroy();
  228. });
  229. this.items = [];
  230. this.view.currentView = null;
  231. this.table.destroy();
  232. }
  233. });
  234. MWF.xApplication.Meeting.ListView.ApplyWait = new Class({
  235. Extends: MWF.xApplication.Meeting.ListView.View
  236. });
  237. MWF.xApplication.Meeting.ListView.ApplyProcessing = new Class({
  238. Extends: MWF.xApplication.Meeting.ListView.View,
  239. loadList: function() {
  240. this.app.actions.listMeetingApplyProcessing(function (json){this.loadLines(json.data);}.bind(this));
  241. }
  242. });
  243. MWF.xApplication.Meeting.ListView.ApplyCompleted = new Class({
  244. Extends: MWF.xApplication.Meeting.ListView.View,
  245. loadList: function() {
  246. this.app.actions.listMeetingApplyCompleted(function (json){this.loadLines(json.data);}.bind(this));
  247. }
  248. });
  249. MWF.xApplication.Meeting.ListView.MeetingWait = new Class({
  250. Extends: MWF.xApplication.Meeting.ListView.View,
  251. loadList: function() {
  252. this.app.actions.listMeetingInvitedWait(function (json){this.loadLines(json.data);}.bind(this));
  253. }
  254. });
  255. MWF.xApplication.Meeting.ListView.MeetingProcessing = new Class({
  256. Extends: MWF.xApplication.Meeting.ListView.View,
  257. loadList: function() {
  258. this.app.actions.listMeetingInvitedProcessing(function (json){this.loadLines(json.data);}.bind(this));
  259. }
  260. });
  261. MWF.xApplication.Meeting.ListView.MeetingCompleted = new Class({
  262. Extends: MWF.xApplication.Meeting.ListView.View,
  263. loadList: function() {
  264. this.app.actions.listMeetingInvitedCompleted(function (json){this.loadLines(json.data);}.bind(this));
  265. }
  266. });
  267. MWF.xApplication.Meeting.ListView.MeetingReject = new Class({
  268. Extends: MWF.xApplication.Meeting.ListView.View,
  269. loadList: function() {
  270. this.app.actions.listMeetingInvitedRejected(function (json){this.loadLines(json.data);}.bind(this));
  271. }
  272. });
  273. MWF.xApplication.Meeting.ListView.View.Line = new Class({
  274. initialize: function(table, item){
  275. this.table = table;
  276. this.view = this.table.view;
  277. this.css = this.view.css;
  278. this.container = this.table.table;
  279. this.app = this.view.app;
  280. this.data = item;
  281. this.load();
  282. },
  283. load: function(){
  284. var sTime = Date.parse(this.data.startTime);
  285. var bdate = sTime.format(this.app.lp.dateFormatDay);
  286. var btime = sTime.format("%H:%M");
  287. var etime = Date.parse(this.data.completedTime).format("%H:%M");
  288. //this.app.actions.getRoom(this.data.room, function (json){
  289. var room = "";
  290. if( this.data.woRoom ){
  291. var roomData = this.data.woRoom;
  292. var bulidingData = this.getBulidingData( roomData.building );
  293. room = roomData.name+"("+bulidingData.name+((roomData.roomNumber) ? " #"+roomData.roomNumber : "")+")";
  294. }
  295. // this.node = new Element("tr",{
  296. // "html": "<td></td><td>"+bdate+"</td><td>"+btime+"-"+etime+"</td><td>"+this.data.subject+"</td><td>"+room+"</td>"
  297. // }).inject(this.container);
  298. this.node = new Element("tr",{
  299. "html": "<td></td><td></td><td></td><td></td><td></td>"
  300. }).inject(this.container);
  301. this.node.getElements("td").each(function (td, i) {
  302. switch (i) {
  303. case 1:
  304. td.set("text", bdate); break;
  305. case 2:
  306. td.set("text", btime+"-"+etime); break;
  307. case 3:
  308. td.set("text", this.data.subject); break;
  309. case 4:
  310. td.set("text", room); break;
  311. }
  312. }.bind(this));
  313. this.personNode = this.node.getFirst("td");
  314. if (this.data.applicant){
  315. // var explorer = {
  316. // "actions": this.app.personActions,
  317. // "app": {
  318. // "lp": this.app.lp
  319. // }
  320. // };
  321. MWF.require("MWF.widget.O2Identity", function(){
  322. var person = new MWF.widget.O2Person({"displayName": this.data.applicant.split("@")[0], "name": this.data.applicant}, this.personNode, {"style": "room"});
  323. }.bind(this));
  324. }
  325. this.node.getElements("td").setStyles(this.css.listViewTableTd);
  326. this.node.addEvent("click", function(e){
  327. this.openMeeting(e);
  328. }.bind(this));
  329. },
  330. getBulidingData : function( id ){
  331. if( !this.bulidingList )this.bulidingList = {};
  332. if( !this.bulidingList[ id ] ){
  333. this.app.actions.getBuilding(id, function (bjson){
  334. this.bulidingList[ id ] = bjson.data;
  335. }.bind(this), null, false)
  336. }
  337. return this.bulidingList[ id ];
  338. },
  339. openMeeting: function(e){
  340. this.form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  341. this.form.view = this.view;
  342. this.form.open();
  343. },
  344. destroy: function(){
  345. if (this.node) this.node.destroy();
  346. //MWF.release(this);
  347. }
  348. });