ListView.js 12 KB

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