ListView.js 14 KB

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