ListView.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. this.app.reload();
  148. },
  149. recordStatus : function(){
  150. var action = "";
  151. if( this.currentNavi )action = this.currentNavi.retrieve("action");
  152. return {
  153. action : action
  154. };
  155. },
  156. destroy : function(){
  157. if( this.currentView ){
  158. this.currentView.destroy()
  159. }
  160. this.app.removeEvent("resize", this.resetNodeSizeFun );
  161. this.node.destroy();
  162. }
  163. });
  164. MWF.xApplication.Meeting.ListView.View = new Class({
  165. initialize: function(view, action){
  166. this.view = view;
  167. this.css = this.view.css;
  168. this.container = this.view.contentNode;
  169. this.app = this.view.app;
  170. this.items = [];
  171. this.load();
  172. },
  173. load: function(){
  174. this.loadHead();
  175. MWF.require("MWF.widget.Mask", function(){
  176. this.mask = new MWF.widget.Mask({"style": "desktop"});
  177. this.mask.loadNode(this.view.contentAreaNode);
  178. }.bind(this));
  179. this.loadList();
  180. },
  181. loadHead: function(){
  182. this.table = new Element("table", {
  183. "styles": this.css.listViewTable,
  184. "border": "0",
  185. "cellPadding": "0",
  186. "cellSpacing": "0",
  187. "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>"
  188. }).inject(this.container);
  189. this.table.getElements("th").setStyles(this.css.listViewTableTh);
  190. },
  191. loadList: function() {
  192. this.app.actions.listMeetingApplyWait(function (json) {
  193. this.loadLines(json.data);
  194. }.bind(this));
  195. },
  196. loadLines: function(items){
  197. items.each(function(item){
  198. this.loadLine(item);
  199. }.bind(this));
  200. if (this.mask){
  201. this.mask.hide(function(){
  202. //MWF.release(this.mask);
  203. this.mask = null;
  204. }.bind(this));
  205. }
  206. },
  207. loadLine: function(item){
  208. this.items.push(new MWF.xApplication.Meeting.ListView.View.Line(this, item));
  209. },
  210. destroy: function(){
  211. this.items.each(function(item){
  212. item.destroy();
  213. });
  214. this.items = [];
  215. this.view.currentView = null;
  216. this.table.destroy();
  217. }
  218. });
  219. MWF.xApplication.Meeting.ListView.ApplyWait = new Class({
  220. Extends: MWF.xApplication.Meeting.ListView.View
  221. });
  222. MWF.xApplication.Meeting.ListView.ApplyProcessing = new Class({
  223. Extends: MWF.xApplication.Meeting.ListView.View,
  224. loadList: function() {
  225. this.app.actions.listMeetingApplyProcessing(function (json){this.loadLines(json.data);}.bind(this));
  226. }
  227. });
  228. MWF.xApplication.Meeting.ListView.ApplyCompleted = new Class({
  229. Extends: MWF.xApplication.Meeting.ListView.View,
  230. loadList: function() {
  231. this.app.actions.listMeetingApplyCompleted(function (json){this.loadLines(json.data);}.bind(this));
  232. }
  233. });
  234. MWF.xApplication.Meeting.ListView.MeetingWait = new Class({
  235. Extends: MWF.xApplication.Meeting.ListView.View,
  236. loadList: function() {
  237. this.app.actions.listMeetingInvitedWait(function (json){this.loadLines(json.data);}.bind(this));
  238. }
  239. });
  240. MWF.xApplication.Meeting.ListView.MeetingProcessing = new Class({
  241. Extends: MWF.xApplication.Meeting.ListView.View,
  242. loadList: function() {
  243. this.app.actions.listMeetingInvitedProcessing(function (json){this.loadLines(json.data);}.bind(this));
  244. }
  245. });
  246. MWF.xApplication.Meeting.ListView.MeetingCompleted = new Class({
  247. Extends: MWF.xApplication.Meeting.ListView.View,
  248. loadList: function() {
  249. this.app.actions.listMeetingInvitedCompleted(function (json){this.loadLines(json.data);}.bind(this));
  250. }
  251. });
  252. MWF.xApplication.Meeting.ListView.MeetingReject = new Class({
  253. Extends: MWF.xApplication.Meeting.ListView.View,
  254. loadList: function() {
  255. this.app.actions.listMeetingInvitedRejected(function (json){this.loadLines(json.data);}.bind(this));
  256. }
  257. });
  258. MWF.xApplication.Meeting.ListView.View.Line = new Class({
  259. initialize: function(table, item){
  260. this.table = table;
  261. this.view = this.table.view;
  262. this.css = this.view.css;
  263. this.container = this.table.table;
  264. this.app = this.view.app;
  265. this.data = item;
  266. this.load();
  267. },
  268. load: function(){
  269. var sTime = Date.parse(this.data.startTime);
  270. var bdate = sTime.format(this.app.lp.dateFormatDay);
  271. var btime = sTime.format("%H:%M");
  272. var etime = Date.parse(this.data.completedTime).format("%H:%M");
  273. this.app.actions.getRoom(this.data.room, function (json){
  274. this.app.actions.getBuilding(json.data.building, function (bjson){
  275. var room = json.data.name+"("+bjson.data.name+((json.data.roomNumber) ? " #"+json.data.roomNumber : "")+")";
  276. this.node = new Element("tr",{
  277. "html": "<td></td><td>"+bdate+"</td><td>"+btime+"-"+etime+"</td><td>"+this.data.subject+"</td><td>"+room+"</td>"
  278. }).inject(this.container);
  279. this.personNode = this.node.getFirst("td");
  280. if (this.data.applicant){
  281. // var explorer = {
  282. // "actions": this.app.personActions,
  283. // "app": {
  284. // "lp": this.app.lp
  285. // }
  286. // };
  287. MWF.require("MWF.widget.O2Identity", function(){
  288. var person = new MWF.widget.O2Person({"name": this.data.applicant}, this.personNode, {"style": "room"});
  289. }.bind(this));
  290. }
  291. this.node.getElements("td").setStyles(this.css.listViewTableTd);
  292. this.node.addEvent("click", function(e){
  293. this.openMeeting(e);
  294. }.bind(this));
  295. }.bind(this));
  296. }.bind(this));
  297. },
  298. openMeeting: function(e){
  299. this.form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  300. this.form.view = this.view;
  301. this.form.open();
  302. },
  303. destroy: function(){
  304. if (this.node) this.node.destroy();
  305. //MWF.release(this);
  306. }
  307. });