ListView.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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) _self.currentNavi.setStyles(_self.css.menuItemNode);
  70. _self.currentNavi = this;
  71. this.setStyles(_self.css.menuItemNode_current);
  72. if (_self[action]) _self[action]();
  73. }
  74. });
  75. itemNode.store("action",action);
  76. if( this.options.action == action){
  77. itemNode.click();
  78. }else if( action == "toApplyWait"){
  79. itemNode.click();
  80. }
  81. },
  82. toApplyWait: function(){
  83. if (this.currentView) this.currentView.destroy();
  84. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyWait(this);
  85. },
  86. toApplyProcessing: function(){
  87. if (this.currentView) this.currentView.destroy();
  88. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyProcessing(this);
  89. },
  90. toApplyCompleted: function(){
  91. if (this.currentView) this.currentView.destroy();
  92. this.currentView = new MWF.xApplication.Meeting.ListView.ApplyCompleted(this);
  93. },
  94. toMeetingWait: function(){
  95. if (this.currentView) this.currentView.destroy();
  96. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingWait(this);
  97. },
  98. toMeetingProcessing: function(){
  99. if (this.currentView) this.currentView.destroy();
  100. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingProcessing(this);
  101. },
  102. toMeetingCompleted: function(){
  103. if (this.currentView) this.currentView.destroy();
  104. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingCompleted(this);
  105. },
  106. toMeetingReject: function(){
  107. if (this.currentView) this.currentView.destroy();
  108. this.currentView = new MWF.xApplication.Meeting.ListView.MeetingReject(this);
  109. },
  110. hide: function(){
  111. var fx = new Fx.Morph(this.node, {
  112. "duration": "300",
  113. "transition": Fx.Transitions.Expo.easeOut
  114. });
  115. fx.start({
  116. "opacity": 0
  117. }).chain(function(){
  118. this.node.setStyle("display", "none");
  119. }.bind(this));
  120. },
  121. show: function(){
  122. this.node.setStyles(this.css.node);
  123. if( this.app.inContainer ){
  124. this.node.setStyles({
  125. "opacity": 1,
  126. "position": "static",
  127. "width": "auto"
  128. });
  129. }else{
  130. var fx = new Fx.Morph(this.node, {
  131. "duration": "800",
  132. "transition": Fx.Transitions.Expo.easeOut
  133. });
  134. this.app.fireAppEvent("resize");
  135. fx.start({
  136. "opacity": 1,
  137. "left": "0px"
  138. }).chain(function(){
  139. this.node.setStyles({
  140. "position": "static",
  141. "width": "auto"
  142. });
  143. }.bind(this));
  144. }
  145. },
  146. reload: function(){
  147. if( this.currentView ){
  148. this.currentView.reload();
  149. }else{
  150. this.app.reload();
  151. }
  152. },
  153. recordStatus : function(){
  154. var action = "";
  155. if( this.currentNavi )action = this.currentNavi.retrieve("action");
  156. return {
  157. action : action
  158. };
  159. },
  160. destroy : function(){
  161. if( this.currentView ){
  162. this.currentView.destroy()
  163. }
  164. this.app.removeEvent("resize", this.resetNodeSizeFun );
  165. this.node.destroy();
  166. }
  167. });
  168. MWF.xApplication.Meeting.ListView.View = new Class({
  169. initialize: function(view, action){
  170. this.view = view;
  171. this.css = this.view.css;
  172. this.container = this.view.contentNode;
  173. this.app = this.view.app;
  174. this.items = [];
  175. this.load();
  176. },
  177. reload : function(){
  178. this.items = [];
  179. this.container.empty();
  180. this.load();
  181. },
  182. load: function(){
  183. this.loadHead();
  184. MWF.require("MWF.widget.Mask", function(){
  185. this.mask = new MWF.widget.Mask({"style": "desktop"});
  186. this.mask.loadNode(this.view.contentAreaNode);
  187. }.bind(this));
  188. this.loadList();
  189. },
  190. loadHead: function(){
  191. this.table = new Element("table", {
  192. "styles": this.css.listViewTable,
  193. "border": "0",
  194. "cellPadding": "0",
  195. "cellSpacing": "0",
  196. "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>"
  197. }).inject(this.container);
  198. this.table.getElements("th").setStyles(this.css.listViewTableTh);
  199. },
  200. loadList: function() {
  201. this.app.actions.listMeetingApplyWait(function (json) {
  202. this.loadLines(json.data);
  203. }.bind(this));
  204. },
  205. loadLines: function(items){
  206. items.each(function(item){
  207. this.loadLine(item);
  208. }.bind(this));
  209. if (this.mask){
  210. this.mask.hide(function(){
  211. //MWF.release(this.mask);
  212. this.mask = null;
  213. }.bind(this));
  214. }
  215. },
  216. loadLine: function(item){
  217. this.items.push(new MWF.xApplication.Meeting.ListView.View.Line(this, item));
  218. },
  219. destroy: function(){
  220. this.items.each(function(item){
  221. item.destroy();
  222. });
  223. this.items = [];
  224. this.view.currentView = null;
  225. this.table.destroy();
  226. }
  227. });
  228. MWF.xApplication.Meeting.ListView.ApplyWait = new Class({
  229. Extends: MWF.xApplication.Meeting.ListView.View
  230. });
  231. MWF.xApplication.Meeting.ListView.ApplyProcessing = new Class({
  232. Extends: MWF.xApplication.Meeting.ListView.View,
  233. loadList: function() {
  234. this.app.actions.listMeetingApplyProcessing(function (json){this.loadLines(json.data);}.bind(this));
  235. }
  236. });
  237. MWF.xApplication.Meeting.ListView.ApplyCompleted = new Class({
  238. Extends: MWF.xApplication.Meeting.ListView.View,
  239. loadList: function() {
  240. this.app.actions.listMeetingApplyCompleted(function (json){this.loadLines(json.data);}.bind(this));
  241. }
  242. });
  243. MWF.xApplication.Meeting.ListView.MeetingWait = new Class({
  244. Extends: MWF.xApplication.Meeting.ListView.View,
  245. loadList: function() {
  246. this.app.actions.listMeetingInvitedWait(function (json){this.loadLines(json.data);}.bind(this));
  247. }
  248. });
  249. MWF.xApplication.Meeting.ListView.MeetingProcessing = new Class({
  250. Extends: MWF.xApplication.Meeting.ListView.View,
  251. loadList: function() {
  252. this.app.actions.listMeetingInvitedProcessing(function (json){this.loadLines(json.data);}.bind(this));
  253. }
  254. });
  255. MWF.xApplication.Meeting.ListView.MeetingCompleted = new Class({
  256. Extends: MWF.xApplication.Meeting.ListView.View,
  257. loadList: function() {
  258. this.app.actions.listMeetingInvitedCompleted(function (json){this.loadLines(json.data);}.bind(this));
  259. }
  260. });
  261. MWF.xApplication.Meeting.ListView.MeetingReject = new Class({
  262. Extends: MWF.xApplication.Meeting.ListView.View,
  263. loadList: function() {
  264. this.app.actions.listMeetingInvitedRejected(function (json){this.loadLines(json.data);}.bind(this));
  265. }
  266. });
  267. MWF.xApplication.Meeting.ListView.View.Line = new Class({
  268. initialize: function(table, item){
  269. this.table = table;
  270. this.view = this.table.view;
  271. this.css = this.view.css;
  272. this.container = this.table.table;
  273. this.app = this.view.app;
  274. this.data = item;
  275. this.load();
  276. },
  277. load: function(){
  278. var sTime = Date.parse(this.data.startTime);
  279. var bdate = sTime.format(this.app.lp.dateFormatDay);
  280. var btime = sTime.format("%H:%M");
  281. var etime = Date.parse(this.data.completedTime).format("%H:%M");
  282. //this.app.actions.getRoom(this.data.room, function (json){
  283. var roomData = this.data.woRoom;
  284. var bulidingData = this.getBulidingData( roomData.building );
  285. var room = roomData.name+"("+bulidingData.name+((roomData.roomNumber) ? " #"+roomData.roomNumber : "")+")";
  286. this.node = new Element("tr",{
  287. "html": "<td></td><td>"+bdate+"</td><td>"+btime+"-"+etime+"</td><td>"+this.data.subject+"</td><td>"+room+"</td>"
  288. }).inject(this.container);
  289. this.personNode = this.node.getFirst("td");
  290. if (this.data.applicant){
  291. // var explorer = {
  292. // "actions": this.app.personActions,
  293. // "app": {
  294. // "lp": this.app.lp
  295. // }
  296. // };
  297. MWF.require("MWF.widget.O2Identity", function(){
  298. var person = new MWF.widget.O2Person({"name": this.data.applicant}, this.personNode, {"style": "room"});
  299. }.bind(this));
  300. }
  301. this.node.getElements("td").setStyles(this.css.listViewTableTd);
  302. this.node.addEvent("click", function(e){
  303. this.openMeeting(e);
  304. }.bind(this));
  305. },
  306. getBulidingData : function( id ){
  307. if( !this.bulidingList )this.bulidingList = {};
  308. if( !this.bulidingList[ id ] ){
  309. this.app.actions.getBuilding(id, function (bjson){
  310. this.bulidingList[ id ] = bjson.data;
  311. }.bind(this), null, false)
  312. }
  313. return this.bulidingList[ id ];
  314. },
  315. openMeeting: function(e){
  316. this.form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  317. this.form.view = this.view;
  318. this.form.open();
  319. },
  320. destroy: function(){
  321. if (this.node) this.node.destroy();
  322. //MWF.release(this);
  323. }
  324. });