RoomView.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  1. MWF.xDesktop.requireApp("Meeting", "MeetingView", null, false);
  2. MWF.xApplication.Meeting.RoomView = new Class({
  3. Extends: MWF.widget.Common,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default"
  7. },
  8. initialize: function(node, app, options){
  9. this.setOptions(options);
  10. this.path = "/x_component_Meeting/$RoomView/";
  11. this.cssPath = "/x_component_Meeting/$RoomView/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.app = app;
  14. this.container = $(node);
  15. this.buildings = [];
  16. this.date = new Date();
  17. this.hours = 1;
  18. this.load();
  19. },
  20. load: function(){
  21. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  22. this.roomArea = new Element("div", {"styles": this.css.roomArea}).inject(this.node);
  23. this.infoArea = new Element("div", {"styles": this.css.infoArea}).inject(this.node);
  24. this.roomDateArea = new Element("div", {"styles": this.css.roomDateArea}).inject(this.roomArea);
  25. this.roomBuildingsArea = new Element("div", {"styles": this.css.roomBuildingsArea}).inject(this.roomArea);
  26. this.resetNodeSize();
  27. this.app.addEvent("resize", this.resetNodeSize.bind(this));
  28. this.loadDate();
  29. this.loadRooms();
  30. },
  31. loadDate: function(){
  32. var dateText = this.date.format(this.app.lp.dateFormatAll);
  33. this.roomDateNode = new Element("div", {"styles": this.css.roomDateNode}).inject(this.roomDateArea);
  34. this.roomDateTextNode = new Element("div", {"styles": this.css.roomDateTextNode}).inject(this.roomDateNode);
  35. this.roomDateIconNode = new Element("div", {"styles": this.css.roomDateIconNode}).inject(this.roomDateNode);
  36. this.roomHourRangeNode = new Element("div", {"styles": this.css.roomHourRangeNode}).inject(this.roomDateArea);
  37. var html = this.app.lp.persist+" <select>" +
  38. "<option "+((this.hours==1) ? "selected" : "")+" value=1>1</option>" +
  39. "<option "+((this.hours==2) ? "selected" : "")+" value=2>2</option>" +
  40. "<option "+((this.hours==3) ? "selected" : "")+" value=3>3</option>" +
  41. "<option "+((this.hours==4) ? "selected" : "")+" value=4>4</option>" +
  42. "<option "+((this.hours==5) ? "selected" : "")+" value=5>5</option>" +
  43. "<option "+((this.hours==6) ? "selected" : "")+" value=6>6</option>" +
  44. "<option "+((this.hours==7) ? "selected" : "")+" value=7>7</option>" +
  45. "<option "+((this.hours==8) ? "selected" : "")+" value=8>8</option>" +
  46. "<option "+((this.hours==9) ? "selected" : "")+" value=9>9</option>" +
  47. "<option "+((this.hours==10) ? "selected" : "")+" value=10>10</option>" +
  48. "<option "+((this.hours==11) ? "selected" : "")+" value=11>11</option>" +
  49. "<option "+((this.hours==12) ? "selected" : "")+" value=12>12</option>" +
  50. "<option "+((this.hours==13) ? "selected" : "")+" value=13>13</option>" +
  51. "<option "+((this.hours==14) ? "selected" : "")+" value=14>14</option>" +
  52. "<option "+((this.hours==15) ? "selected" : "")+" value=15>15</option>" +
  53. "<option "+((this.hours==16) ? "selected" : "")+" value=16>16</option>" +
  54. "<option "+((this.hours==17) ? "selected" : "")+" value=17>17</option>" +
  55. "<option "+((this.hours==18) ? "selected" : "")+" value=18>18</option>" +
  56. "<option "+((this.hours==19) ? "selected" : "")+" value=19>19</option>" +
  57. "<option "+((this.hours==20) ? "selected" : "")+" value=20>20</option>" +
  58. "<option "+((this.hours==21) ? "selected" : "")+" value=21>21</option>" +
  59. "<option "+((this.hours==22) ? "selected" : "")+" value=22>22</option>" +
  60. "<option "+((this.hours==23) ? "selected" : "")+" value=23>23</option>" +
  61. "<option "+((this.hours==24) ? "selected" : "")+" value=24>24</option>" +
  62. "</select> "+this.app.lp.hour;
  63. this.roomDateTextNode.set("text", dateText);
  64. this.roomHourRangeNode.set("html", html);
  65. this.roomHourRangeSelect = this.roomHourRangeNode.getElement("select").setStyles(this.css.roomHourRangeSelectNode);
  66. this.roomHourRangeSelect.addEvent("change", function(){
  67. var h = this.roomHourRangeSelect.options[this.roomHourRangeSelect.selectedIndex].get("value");
  68. debugger;
  69. this.reload(this.date, h);
  70. }.bind(this));
  71. this.roomDateNode.addEvents({
  72. "mouseover": function(){
  73. this.roomDateNode.setStyles(this.css.roomDateNode_over);
  74. this.roomDateIconNode.setStyles(this.css.roomDateIconNode_over);
  75. }.bind(this),
  76. "mouseout": function(){
  77. this.roomDateNode.setStyles(this.css.roomDateNode);
  78. this.roomDateIconNode.setStyles(this.css.roomDateIconNode);
  79. }.bind(this),
  80. "mousedown": function(){
  81. this.roomDateNode.setStyles(this.css.roomDateNode_down);
  82. this.roomDateIconNode.setStyles(this.css.roomDateIconNode_down);
  83. }.bind(this),
  84. "mouseup": function(){
  85. this.roomDateNode.setStyles(this.css.roomDateNode_over);
  86. this.roomDateIconNode.setStyles(this.css.roomDateIconNode_over);
  87. }.bind(this)
  88. });
  89. MWF.require("MWF.widget.Calendar", function(){
  90. new MWF.widget.Calendar(this.roomDateNode, {
  91. "style":"meeting",
  92. "isTime": true,
  93. "target": this.node,
  94. "onQueryComplate": function(e, dv, date){
  95. var selectedDate = new Date.parse(dv);
  96. var h = this.roomHourRangeSelect.options[this.roomHourRangeSelect.selectedIndex].get("value");
  97. this.reload(selectedDate, h);
  98. }.bind(this)
  99. });
  100. }.bind(this));
  101. },
  102. resetNodeSize: function(){
  103. var size = this.container.getSize();
  104. if (this.app.meetingConfig.hideMenu=="static"){
  105. var y = size.y-120;
  106. this.node.setStyle("height", ""+y+"px");
  107. this.node.setStyle("margin-top", "60px");
  108. }else{
  109. var y = size.y-20;
  110. this.node.setStyle("height", ""+y+"px");
  111. }
  112. //var size = this.container.getSize();
  113. //var y = size.y-20;
  114. //this.node.setStyle("height", ""+y+"px");
  115. var dateSize = this.roomDateArea.getSize();
  116. y = y-dateSize.y;
  117. this.roomBuildingsArea.setStyle("height", ""+y+"px");
  118. },
  119. loadRooms: function(){
  120. var startTime = this.date.clone();
  121. startTime.set("sec", 0);
  122. var start = startTime.format("%Y-%m-%d %H:%M");
  123. startTime.increment("hour", this.hours);
  124. var complete = startTime.format("%Y-%m-%d %H:%M");
  125. this.app.actions.listBuildingByRange((start), (complete), function(json){
  126. this.roomJson =json.data;
  127. //this.roomBuildingsArea;
  128. this.roomJson.each(function(building){
  129. this.buildings.push(new MWF.xApplication.Meeting.RoomView.Building(this, building));
  130. }.bind(this));
  131. this.checkWidth();
  132. this.checkWidthFun = this.checkWidth.bind(this);
  133. this.app.addEvent("resize", this.checkWidthFun);
  134. this.buildings.each(function(building){
  135. building.loadRooms();
  136. }.bind(this));
  137. }.bind(this));
  138. },
  139. checkWidth: function(){
  140. var count = this.buildings.length;
  141. if (count){
  142. var min = this.buildings[0].node.getStyle("min-width").toInt();
  143. var size = this.roomArea.getSize();
  144. while ((count>0) && (size.x/count)<min) count--;
  145. var w = size.x/count;
  146. var areaW = w*(this.buildings.length);
  147. this.buildings.each(function(building){
  148. building.node.setStyle("width", ""+w+"px");
  149. }.bind(this));
  150. this.roomBuildingsArea.setStyle("width", ""+areaW+"px");
  151. }
  152. },
  153. reload: function(date, hours){
  154. if (date) this.date = date;
  155. if (hours) this.hours = hours;
  156. this.buildings.each(function(building){
  157. building.destroy();
  158. }.bind(this));
  159. this.buildings = [];
  160. if (this.currentDocument) this.currentDocument.close();
  161. this.app.removeEvent("resize", this.checkWidthFun);
  162. this.currentDocument = null;
  163. this.selectedItem = null;
  164. this.node.destroy();
  165. this.load();
  166. this.show();
  167. },
  168. hide: function(){
  169. var fx = new Fx.Morph(this.node, {
  170. "duration": "300",
  171. "transition": Fx.Transitions.Expo.easeOut
  172. });
  173. if (this.currentMeetingDocument) this.currentMeetingDocument.closeDocument();
  174. fx.start({
  175. "opacity": 0
  176. }).chain(function(){
  177. this.node.setStyle("display", "none");
  178. }.bind(this));
  179. },
  180. show: function(){
  181. this.node.setStyles(this.css.node);
  182. var fx = new Fx.Morph(this.node, {
  183. "duration": "800",
  184. "transition": Fx.Transitions.Expo.easeOut
  185. });
  186. this.app.fireAppEvent("resize");
  187. fx.start({
  188. "opacity": 1,
  189. "left": "0px"
  190. }).chain(function(){
  191. this.node.setStyles({
  192. "position": "static",
  193. "width": "auto"
  194. });
  195. }.bind(this));
  196. }
  197. });
  198. MWF.xApplication.Meeting.RoomView.Building = new Class({
  199. Implements: [Events],
  200. initialize: function(view, json){
  201. this.view = view;
  202. this.json = json;
  203. this.container = this.view.roomBuildingsArea;
  204. this.css = this.view.css;
  205. this.app = this.view.app;
  206. this.rooms = [];
  207. this.floors = [];
  208. this.load();
  209. },
  210. load: function(){
  211. this.node = new Element("div", {"styles": this.css.buildingNode}).inject(this.container);
  212. this.titleNode = new Element("div", {"styles": this.css.buildingTitleNode}).inject(this.node);
  213. this.titleNameNode = new Element("div", {"styles": this.css.buildingTitleNameNode, "text": this.json.name}).inject(this.titleNode);
  214. this.titleAddrNode = new Element("div", {"styles": this.css.buildingTitleAddrNode, "text": this.json.address}).inject(this.titleNode);
  215. this.contentScrollNode = new Element("div", {"styles": this.css.buildingContentScrollNode}).inject(this.node);
  216. this.setContentScrollSize();
  217. this.setContentScrollSizeFun = this.setContentScrollSize.bind(this);
  218. this.app.addEvent("resize", this.setContentScrollSizeFun);
  219. this.contentNode = new Element("div", {"styles": this.css.buildingContentNode}).inject(this.contentScrollNode);
  220. MWF.require("MWF.widget.ScrollBar", function(){
  221. new MWF.widget.ScrollBar(this.contentScrollNode, {"style": "view", "distance": 100, "indent": false});
  222. }.bind(this));
  223. this.titleNode.addEvent("click", function(){
  224. this.selected();
  225. //if (this.app.isManager){
  226. // this.editBuilding();
  227. //}else{
  228. // this.readBuilding();
  229. //}
  230. }.bind(this));
  231. },
  232. selected: function(){
  233. var openDocument = (this.view.selectedItem!=this);
  234. if (this.view.selectedItem) this.view.selectedItem.unSelected();
  235. this.titleNode.setStyles(this.css.buildingTitleNode_selected);
  236. this.node.setStyles(this.css.buildingNode_selected);
  237. this.titleNameNode.setStyles(this.css.buildingTitleNameNode_selected);
  238. this.titleAddrNode.setStyles(this.css.buildingTitleAddrNode_selected);
  239. this.view.selectedItem = this;
  240. if (openDocument) this.openDocBuilding();
  241. },
  242. unSelected: function(){
  243. this.titleNode.setStyles(this.css.buildingTitleNode);
  244. this.node.setStyles(this.css.buildingNode);
  245. this.titleNameNode.setStyles(this.css.buildingTitleNameNode);
  246. this.titleAddrNode.setStyles(this.css.buildingTitleAddrNode);
  247. this.view.selectedItem = null;
  248. },
  249. openDocBuilding: function(){
  250. if (this.view.currentDocument) this.view.currentDocument.close();
  251. var doc = new MWF.xApplication.Meeting.RoomView.Building.Document(this);
  252. this.view.currentDocument = doc;
  253. },
  254. setContentScrollSize: function(){
  255. var size = this.view.roomBuildingsArea.getSize();
  256. var titleSize = this.titleNode.getSize();
  257. var y = size.y-titleSize.y;
  258. this.contentScrollNode.setStyle("height", ""+y+"px");
  259. },
  260. loadRooms: function(){
  261. var floor;
  262. var contentFloor = null;
  263. this.json.roomList.each(function(room){
  264. if (floor!=room.floor){
  265. if (contentFloor) contentFloor.checkWidth();
  266. floor = room.floor;
  267. contentFloor = new MWF.xApplication.Meeting.RoomView.Building.Floor(this, room);
  268. this.floors.push(contentFloor);
  269. }
  270. this.rooms.push(new MWF.xApplication.Meeting.RoomView.Building.Room(contentFloor, room));
  271. }.bind(this));
  272. if (contentFloor) contentFloor.checkWidth();
  273. },
  274. destroy: function(){
  275. this.rooms.each(function(room){
  276. room.destroy();
  277. }.bind(this));
  278. this.floors.each(function(floor){
  279. floor.destroy();
  280. }.bind(this));
  281. this.app.removeEvent("resize", this.setContentScrollSizeFun);
  282. this.node.destroy();
  283. MWF.release(this);
  284. }
  285. });
  286. MWF.xApplication.Meeting.RoomView.Building.Document = new Class({
  287. Implements: [Events],
  288. initialize: function(building){
  289. this.building = building;
  290. this.view = this.building.view;
  291. this.json = this.building.json;
  292. this.container = this.view.infoArea;
  293. this.css = this.building.css;
  294. this.app = this.building.app;
  295. this.isEditMode = false;
  296. this.load();
  297. },
  298. load: function() {
  299. this.node = new Element("div", {"styles": this.css.buildingDocNode}).inject(this.container);
  300. this.actionNode = new Element("div", {"styles": this.css.buildingDocActionNode}).inject(this.node);
  301. this.titleNode = new Element("div", {"styles": this.css.buildingDocTitleNode, "text": this.json.name}).inject(this.node);
  302. this.loadContentNode();
  303. //this.meetingNode = new Element("div", {"styles": this.css.buildingDocMeetingNode}).inject(this.node);
  304. this.setMeetingNodeSize();
  305. this.setMeetingNodeSizeFun = this.setMeetingNodeSize.bind(this);
  306. this.app.addEvent("resize", this.setMeetingNodeSizeFun);
  307. //MWF.require("MWF.widget.ScrollBar", function(){
  308. // new MWF.widget.ScrollBar(this.meetingNode, {"style": "default", "distance": 100, "indent": false});
  309. //}.bind(this));
  310. if (this.app.isManager) this.loadActions();
  311. },
  312. loadContentNode: function(){
  313. this.contentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.node);
  314. this.addrNode = new Element("div", {"styles": this.css.buildingDocAddrNode}).inject(this.contentNode);
  315. var addrText = this.json.address || this.app.lp.inputAddress;
  316. this.addrNode.set("text", addrText);
  317. },
  318. setMeetingNodeSize: function(){
  319. if (this.meetingNode){
  320. var size = this.node.getSize();
  321. var actionSize = this.actionNode.getSize();
  322. var titleSize = this.titleNode.getSize();
  323. var contentSize = this.contentNode.getSize();
  324. var y = size.y-actionSize.y-titleSize.y-contentSize.y-30;
  325. this.meetingNode.setStyle("height", ""+y+"px");
  326. }
  327. },
  328. loadActions: function(){
  329. this.deleteAction = new Element("div", {"styles": this.css.buildingDocDeleteActionNode}).inject(this.actionNode);
  330. this.saveAction = new Element("div", {"styles": this.css.buildingDocSaveActionNode}).inject(this.actionNode);
  331. this.saveAction.setStyle("display", "none");
  332. this.editAction = new Element("div", {"styles": this.css.buildingDocEditActionNode}).inject(this.actionNode);
  333. this.deleteAction.addEvents({
  334. "mouseover": function(){this.deleteAction.setStyles(this.css.buildingDocDeleteActionNode_over);}.bind(this),
  335. "mouseout": function(){this.deleteAction.setStyles(this.css.buildingDocDeleteActionNode);}.bind(this),
  336. "mousedown": function(){this.deleteAction.setStyles(this.css.buildingDocDeleteActionNode_down);}.bind(this),
  337. "mouseup": function(){this.deleteAction.setStyles(this.css.buildingDocDeleteActionNode_over);}.bind(this),
  338. "click": function(e){this.deleteDocument(e);}.bind(this)
  339. });
  340. this.saveAction.addEvents({
  341. "mouseover": function(){this.saveAction.setStyles(this.css.buildingDocSaveActionNode_over);}.bind(this),
  342. "mouseout": function(){this.saveAction.setStyles(this.css.buildingDocSaveActionNode);}.bind(this),
  343. "mousedown": function(){this.saveAction.setStyles(this.css.buildingDocSaveActionNode_down);}.bind(this),
  344. "mouseup": function(){this.saveAction.setStyles(this.css.buildingDocSaveActionNode_over);}.bind(this),
  345. "click": function(){this.saveDocument();}.bind(this)
  346. });
  347. this.editAction.addEvents({
  348. "mouseover": function(){this.editAction.setStyles(this.css.buildingDocEditActionNode_over);}.bind(this),
  349. "mouseout": function(){this.editAction.setStyles(this.css.buildingDocEditActionNode);}.bind(this),
  350. "mousedown": function(){this.editAction.setStyles(this.css.buildingDocEditActionNode_down);}.bind(this),
  351. "mouseup": function(){this.editAction.setStyles(this.css.buildingDocEditActionNode_over);}.bind(this),
  352. "click": function(){this.editDocument();}.bind(this)
  353. });
  354. this.editDocumentFun = this.editDocument.bind(this);
  355. this.titleNode.addEvent("click", this.editDocumentFun);
  356. if (this.addrNode) this.addrNode.addEvent("click", this.editDocumentFun);
  357. },
  358. editDocument: function(){
  359. this.saveAction.setStyle("display", "block");
  360. this.editAction.setStyle("display", "none");
  361. var name = this.titleNode.get("text");
  362. this.titleNode.empty();
  363. this.titleInput = new Element("input", {
  364. "styles": this.css.buildingDocTitleInputNode,
  365. "type": "text",
  366. "value": name
  367. }).inject(this.titleNode);
  368. //this.titleInput.focus()
  369. var addr = this.addrNode.get("text");
  370. //if (addr == this.app.lp.inputAddress) addr = "";
  371. this.addrNode.empty();
  372. this.addrInput = new Element("textarea", {
  373. "styles": this.css.buildingDocAddrInputNode,
  374. "text": addr
  375. }).inject(this.addrNode);
  376. this.addrInput.addEvents({
  377. "focus": function(){
  378. if (this.addrInput.get("value")==this.app.lp.inputAddress) this.addrInput.set("value", "");
  379. }.bind(this),
  380. "blur": function(){
  381. if (!this.addrInput.get("value")) this.addrInput.set("value", this.app.lp.inputAddress);
  382. }.bind(this)
  383. });
  384. this.titleNode.removeEvent("click", this.editDocumentFun);
  385. if (this.addrNode) this.addrNode.removeEvent("click", this.editDocumentFun);
  386. this.isEditMode = true;
  387. },
  388. readDocument: function(){
  389. this.saveAction.setStyle("display", "none");
  390. this.editAction.setStyle("display", "block");
  391. var name = this.titleInput.get("value");
  392. var addr = this.addrInput.get("value");
  393. this.titleInput.destroy();
  394. this.addrInput.destroy();
  395. this.titleNode.set("text", name);
  396. this.addrNode.set("text", addr);
  397. this.titleNode.addEvent("click", this.editDocumentFun);
  398. if (this.addrNode) this.addrNode.addEvent("click", this.editDocumentFun);
  399. this.isEditMode = false;
  400. },
  401. saveDocument: function(noNotice, callback){
  402. var name = this.titleInput.get("value");
  403. var addr = this.addrInput.get("value");
  404. this.app.actions.saveBuilding({"name": name, "address": addr, "id": this.json.id}, function(json){
  405. if (!noNotice) this.app.notice(this.app.lp.save_success, "success", this.node, {"x": "right", "y": "top"});
  406. this.app.actions.getBuilding(this.json.id, function(json){
  407. this.json.name = json.data.name;
  408. this.json.address = json.data.address;
  409. this.building.titleNameNode.set("text", this.json.name);
  410. this.building.titleAddrNode.set("text", this.json.address);
  411. if (callback) callback();
  412. }.bind(this));
  413. this.readDocument();
  414. }.bind(this));
  415. },
  416. deleteDocument: function(e) {
  417. var info = this.app.lp.delete_building;
  418. info = info.replace(/{name}/g, this.json.name);
  419. var _self = this;
  420. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  421. _self.remove();
  422. this.close();
  423. }, function(){
  424. this.close();
  425. });
  426. },
  427. remove: function(){
  428. this.app.actions.deleteBuilding(this.json.id, function(){
  429. this.view.reload();
  430. }.bind(this));
  431. },
  432. close: function(callback){
  433. if (this.isEditMode){
  434. this.saveDocument(true, function(){
  435. this.node.destroy();
  436. this.app.removeEvent("resize", this.setMeetingNodeSizeFun);
  437. this.view.currentDocument = null;
  438. MWF.release(this);
  439. if (callback) callback();
  440. }.bind(this));
  441. }else{
  442. this.node.destroy();
  443. this.app.removeEvent("resize", this.setMeetingNodeSizeFun);
  444. this.view.currentDocument = null;
  445. MWF.release(this);
  446. if (callback) callback();
  447. }
  448. }
  449. });
  450. MWF.xApplication.Meeting.RoomView.Building.Floor = new Class({
  451. Implements: [Events],
  452. initialize: function(building, json){
  453. this.building = building;
  454. this.view = this.building.view;
  455. this.json = json;
  456. this.container = this.building.contentNode;
  457. this.css = this.building.css;
  458. this.app = this.building.app;
  459. this.rooms = [];
  460. this.load();
  461. },
  462. load: function(){
  463. this.node = new Element("div", {"styles": this.css.buildingContentFloorNode}).inject(this.container);
  464. this.checkWidthFun = this.checkWidth.bind(this);
  465. this.app.addEvent("resize", this.checkWidthFun);
  466. },
  467. checkWidth: function(){
  468. var count = this.rooms.length;
  469. if (count){
  470. var min = this.rooms[0].node.getStyle("min-width").toInt();
  471. var size = this.node.getSize();
  472. while ((count>0) && ((size.x-10)/count)-12<min) count--;
  473. var w = ((size.x-10)/count)-12;
  474. this.rooms.each(function(room){
  475. room.node.setStyle("width", ""+w+"px");
  476. }.bind(this));
  477. }
  478. },
  479. destroy: function(){
  480. this.app.removeEvent("resize", this.checkWidthFun);
  481. this.node.destroy();
  482. MWF.release(this);
  483. }
  484. });
  485. MWF.xApplication.Meeting.RoomView.Building.Room = new Class({
  486. Implements: [Events],
  487. initialize: function(floor, json){
  488. this.floor = floor;
  489. this.building = this.floor.building;
  490. this.view = this.floor.view;
  491. this.json = json;
  492. this.container = this.floor.node;
  493. this.css = this.floor.css;
  494. this.app = this.floor.app;
  495. this.floor.rooms.push(this);
  496. this.isBusy = (this.json.idle===false);
  497. this.meetings = [];
  498. this.load();
  499. },
  500. load: function(){
  501. this.node = new Element("div", {"styles": this.css.roomNode}).inject(this.container);
  502. this.titleNode = new Element("div", {"styles": this.css.roomTitleNode}).inject(this.node);
  503. this.capacityNode = new Element("div", {"styles": this.css.roomTitleCapacityNode, "text": this.json.capacity+this.app.lp.person}).inject(this.titleNode);
  504. this.inforNode = new Element("div", {"styles": this.css.roomTitleInforNode}).inject(this.titleNode);
  505. var node = new Element("div", {"styles": {"height": "20px"}}).inject(this.inforNode);
  506. this.numberNode = new Element("div", {"styles": this.css.roomTitleNumberNode, "text": (this.json.roomNumber) ? "#"+this.json.roomNumber : ""}).inject(node);
  507. this.nameNode = new Element("div", {"styles": this.css.roomTitleNameNode, "text": this.json.name}).inject(node);
  508. this.iconsNode = new Element("div", {"styles": this.css.roomTitleIconsNode}).inject(this.inforNode);
  509. this.contentNode = new Element("div", {"styles": this.css.roomContentNode}).inject(this.node);
  510. this.loadContent();
  511. if (this.view.selectedItem==this) this.selected();
  512. this.titleNode.addEvent("click", function(){
  513. this.selected();
  514. }.bind(this));
  515. },
  516. loadContent: function(){
  517. if (!this.json.available){
  518. this.node.setStyles(this.css.roomNode_disable);
  519. this.titleNode.setStyles(this.css.roomTitleNode_disable);
  520. }else{
  521. if (this.isBusy){
  522. this.node.setStyles(this.css.roomNode_busy);
  523. this.titleNode.setStyles(this.css.roomTitleNode_busy);
  524. }
  525. }
  526. var deviceList = this.json.device.split("#");
  527. deviceList.each(function(name){
  528. var node = new Element("div", {"styles": this.css.roomTitleIconNode, "title": this.app.lp.device[name]}).inject(this.iconsNode);
  529. node.setStyle("background-image", "url(/x_component_Meeting/$RoomView/default/icon/"+name+".png)");
  530. }.bind(this));
  531. this.json.meetingList.each(function(meeting, i){
  532. if (i<4) this.meetings.push(new MWF.xApplication.Meeting.RoomView.Building.Room.Meeting(this, meeting));
  533. }.bind(this));
  534. if (!this.isBusy && this.json.available){
  535. var node = new Element("div", {"styles": this.css.roomContentAddMeetingNode}).inject(this.node);
  536. node.set("text", this.app.lp.applyMeeting);
  537. node.addEvent("click", function(){
  538. this.app.addMeeting(this.view.date, this.view.date.getHours(), this.json.id);
  539. }.bind(this));
  540. }
  541. },
  542. selected: function(){
  543. var openDocument = (this.view.selectedItem!=this);
  544. if (this.view.selectedItem) this.view.selectedItem.unSelected();
  545. this.node.setStyles(this.css.roomNode_selected);
  546. this.view.selectedItem = this;
  547. if (openDocument) this.openDocRoom();
  548. },
  549. unSelected: function(){
  550. this.node.setStyles(this.css.roomNode);
  551. if (!this.json.available){
  552. this.node.setStyles(this.css.roomNode_disable);
  553. }else{
  554. if (this.isBusy){
  555. this.node.setStyles(this.css.roomNode_busy);
  556. }
  557. }
  558. this.view.selectedItem = null;
  559. },
  560. openDocRoom: function(){
  561. debugger;
  562. if (this.view.currentDocument){
  563. this.view.currentDocument.close(function(){
  564. var doc = new MWF.xApplication.Meeting.RoomView.Building.Room.Document(this);
  565. this.view.currentDocument = doc;
  566. }.bind(this));
  567. }else{
  568. var doc = new MWF.xApplication.Meeting.RoomView.Building.Room.Document(this);
  569. this.view.currentDocument = doc;
  570. }
  571. },
  572. reload: function(){
  573. this.node.destroy();
  574. this.load();
  575. this.floor.checkWidth();
  576. },
  577. destroy: function(){
  578. this.node.destroy();
  579. MWF.release(this);
  580. }
  581. });
  582. MWF.xApplication.Meeting.RoomView.Building.Room.Meeting = new Class({
  583. initialize: function(room, data){
  584. this.room = room;
  585. this.view = this.room.view;
  586. this.json = this.room.json;
  587. this.container = this.room.contentNode;
  588. this.css = this.room.css;
  589. this.app = this.room.app;
  590. this.data = data;
  591. this.load();
  592. },
  593. load: function(){
  594. this.node = new Element("div", {"styles": this.css.roomMeetingNode}).inject(this.container);
  595. var timeStr = "";
  596. var now = new Date();
  597. var mDate = Date.parse(this.data.startTime);
  598. var d = now.diff(mDate);
  599. if (d==0){
  600. timeStr = Date.parse(this.data.startTime).format("%H:%M");
  601. }else if (d==1){
  602. timeStr = this.app.lp.tomorrow;
  603. }else if (d==2){
  604. timeStr = this.app.lp.afterTomorrow;
  605. }else{
  606. var m = now.diff(mDate, "month");
  607. if (m==0){
  608. timeStr = Date.parse(this.data.startTime).format(this.app.lp.dateFormatDayOnly);
  609. }else if (m==1){
  610. timeStr = this.app.lp.nextMonth;
  611. }else{
  612. timeStr = Date.parse(this.data.startTime).format(this.app.lp.dateFormatMonthOnly);
  613. }
  614. }
  615. var title = timeStr+" "+this.data.subject;
  616. this.node.set("text", title);
  617. this.node.set("title", title);
  618. switch (this.data.status){
  619. case "wait":
  620. //nothing
  621. break;
  622. case "processing":
  623. this.node.setStyles({
  624. "border-left": "5px solid #18da14",
  625. "background-color": "#deffdd"
  626. });
  627. break
  628. case "completed":
  629. //add attachment
  630. this.node.setStyles({
  631. "border-left": "5px solid #555",
  632. "background-color": "#F3F3F3"
  633. });
  634. break;
  635. }
  636. this.node.addEvent("click", function(){this.openMeeting();}.bind(this));
  637. },
  638. openMeeting: function(){
  639. if (!this.document){
  640. if (this.view.currentMeetingDocument) this.view.currentMeetingDocument.closeDocument();
  641. this.document = new MWF.xApplication.Meeting.RoomView.Building.Room.Meeting.Document(this);
  642. this.view.currentMeetingDocument = this.document;
  643. }
  644. }
  645. });
  646. MWF.xApplication.Meeting.RoomView.Building.Room.Meeting.Document = new Class({
  647. Extends: MWF.xApplication.Meeting.MeetingView.Document,
  648. initialize: function(item){
  649. this.item = item;
  650. this.view = this.item.view
  651. this.container = this.view.node;
  652. this.app = this.view.app;
  653. this.path = "/x_component_Meeting/$MeetingView/";
  654. this.cssPath = "/x_component_Meeting/$MeetingView/default/css.wcss";
  655. this._loadCss();
  656. this.app.actions.getMeeting(this.item.data.id, function(json){
  657. this.data = json.data;
  658. this.isEdit = (this.data.applicant == this.app.desktop.session.user.name);
  659. this.load();
  660. }.bind(this));
  661. },
  662. closeDocument: function(callback){
  663. //this.saveDocument(true, true);
  664. if (this.setDescriptionNodeSizeFun) this.app.removeEvent("resize", this.setDescriptionNodeSizeFun);
  665. if (this.setNodeSizeFun) this.app.removeEvent("resize", this.setNodeSizeFun);
  666. var size = this.item.node.getSize();
  667. var position = this.item.node.getPosition(this.item.node.getOffsetParent());
  668. var fx = new Fx.Morph(this.node, {
  669. "duration": "500",
  670. "transition": Fx.Transitions.Expo.easeOut
  671. });
  672. this.node.empty();
  673. this.view.currentMeetingDocument = null;
  674. fx.start({
  675. "opacity": 0,
  676. "width": ""+ size.x+"px",
  677. "height": ""+ size.y+"px",
  678. "left": ""+ position.x+"px",
  679. "top": ""+ position.y+"px",
  680. }).chain(function(){
  681. this.destroy();
  682. if (callback) callback();
  683. }.bind(this));
  684. },
  685. _loadCss: function(){
  686. var key = encodeURIComponent(this.cssPath);
  687. if (MWF.widget.css[key]){
  688. this.css = MWF.widget.css[key];
  689. }else{
  690. var r = new Request.JSON({
  691. url: this.cssPath,
  692. secure: false,
  693. async: false,
  694. method: "get",
  695. noCache: false,
  696. onSuccess: function(responseJSON, responseText){
  697. this.css = responseJSON;
  698. MWF.widget.css[key] = responseJSON;
  699. }.bind(this),
  700. onError: function(text, error){
  701. alert(error + text);
  702. }
  703. });
  704. r.send();
  705. }
  706. }
  707. });
  708. MWF.xApplication.Meeting.RoomView.Building.Room.Document = new Class({
  709. Extends: MWF.xApplication.Meeting.RoomView.Building.Document,
  710. Implements: [Events],
  711. initialize: function(room){
  712. this.room = room;
  713. this.view = this.room.view;
  714. this.json = this.room.json;
  715. this.container = this.view.infoArea;
  716. this.css = this.room.css;
  717. this.app = this.room.app;
  718. this.isEditMode = false;
  719. this.load();
  720. },
  721. loadContentNode: function(){
  722. this.contentNode = new Element("div", {"styles": {
  723. "overflow": "hidden",
  724. "padding": "20px",
  725. "border-bottom": "0px solid #999"
  726. }}).inject(this.node);
  727. this.floorNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  728. var titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.floor}).inject(this.floorNode);
  729. var contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode, "text": this.json.floor+this.app.lp.floor}).inject(this.floorNode);
  730. this.roomNumberNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  731. titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.roomNumber}).inject(this.roomNumberNode);
  732. contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode, "text": this.json.roomNumber}).inject(this.roomNumberNode);
  733. this.phoneNumberNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  734. titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.phone}).inject(this.phoneNumberNode);
  735. contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode, "text": (this.json.phoneNumber || "")}).inject(this.phoneNumberNode);
  736. this.deviceberNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  737. titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.device}).inject(this.deviceberNode);
  738. contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode}).inject(this.deviceberNode);
  739. // contentNode.set
  740. var deviceList = this.json.device.split("#");
  741. var deviceNameList = [];
  742. deviceList.each(function(d){deviceNameList.push(this.app.lp.device[d]);}.bind(this));
  743. contentNode.set("text", deviceNameList.join(" "));
  744. this.capacityNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  745. titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.capacity}).inject(this.capacityNode);
  746. contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode, "text": this.json.capacity+this.app.lp.person}).inject(this.capacityNode);
  747. this.auditorNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  748. titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.auditor}).inject(this.auditorNode);
  749. contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode}).inject(this.auditorNode);
  750. this.auditorNode.setStyle("display", "none");
  751. var explorer = {
  752. "actions": this.app.personActions,
  753. "app": {
  754. "lp": this.app.lp
  755. }
  756. }
  757. if (this.json.auditor){
  758. MWF.require("MWF.widget.Identity", function(){
  759. var _self = this;
  760. var person = new MWF.widget.Person({"name": this.json.auditor}, contentNode, explorer, false, null, {"style": "meeting"});
  761. }.bind(this));
  762. }
  763. this.availableNode = new Element("div", {"styles": this.css.roomDocItemNode}).inject(this.contentNode);
  764. titleNode = new Element("div", {"styles": this.css.roomDocItemTitleNode, "text": this.app.lp.roomForm.available}).inject(this.availableNode);
  765. contentNode = new Element("div", {"styles": this.css.roomDocItemContentNode, "text": this.json.capacity+this.app.lp.auditor}).inject(this.availableNode);
  766. var availableTxt = (this.json.available) ? this.app.lp.enable : this.app.lp.disable;
  767. contentNode.set("text", availableTxt);
  768. this.meetingNode = new Element("div", {"styles": this.css.buildingDocMeetingNode}).inject(this.node);
  769. this.loadRoomMeetings();
  770. },
  771. loadRoomMeetings: function(){
  772. this.app.actions.getRoom(this.json.id, function(json){
  773. var html = "<table width='100%' border='0' cellSpacing='0' cellPadding='0'><tr><th>"+this.app.lp.beginTime+"</th><th>"+this.app.lp.subject+"</th><th>"+this.app.lp.applyPerson+"</th></tr></table>"
  774. this.meetingNode.set("html", html);
  775. var table = this.meetingNode.getElement("table");
  776. var _self = this;
  777. json.data.meetingList.each(function(meeting){
  778. var tr = new Element("tr").inject(table);
  779. var td = new Element("td", {"text": Date.parse(meeting.startTime).format(this.app.lp.dateFormatMonthDay+" %H:%M")}).inject(tr);
  780. var td = new Element("td", {"text": meeting.subject}).inject(tr);
  781. var td = new Element("td", {"text": meeting.applicant}).inject(tr);
  782. tr.store("meeting", meeting);
  783. tr.addEvent("click", function(){
  784. var mt = this.retrieve("meeting");
  785. if (mt){
  786. if (!_self.document){
  787. if (_self.view.currentMeetingDocument) _self.view.currentMeetingDocument.closeDocument();
  788. _self.data = mt
  789. _self.document = new MWF.xApplication.Meeting.RoomView.Building.Room.Meeting.Document(_self);
  790. _self.view.currentMeetingDocument = _self.document;
  791. }
  792. }
  793. });
  794. }.bind(this));
  795. table.setStyles(this.css.roomDocMeetingListTable);
  796. table.getElements("th").setStyles(this.css.roomDocMeetingListTh);
  797. table.getElements("td").setStyles(this.css.roomDocMeetingListTd);
  798. }.bind(this));
  799. },
  800. editDocument: function(){
  801. this.saveAction.setStyle("display", "block");
  802. this.editAction.setStyle("display", "none");
  803. var name = this.titleNode.get("text");
  804. this.titleNode.empty();
  805. this.titleInput = new Element("input", {
  806. "styles": this.css.buildingDocTitleInputNode,
  807. "type": "text",
  808. "value": name
  809. }).inject(this.titleNode);
  810. var node = this.floorNode.getLast().empty();
  811. var selectNode = new Element("select", {"styles": this.css.roomDocItemSelectNode}).inject(node);
  812. for (var i=-2; i<=50; i++){
  813. var option = new Element("option", {
  814. "value": i,
  815. "text": i+this.app.lp.floor,
  816. "selected": (i==this.json.floor)
  817. }).inject(selectNode);
  818. }
  819. node = this.roomNumberNode.getLast().empty();
  820. var input = new Element("input", {
  821. "styles": this.css.roomDocItemInputNode,
  822. "type": "text",
  823. "value": this.json.roomNumber
  824. }).inject(node);
  825. node = this.phoneNumberNode.getLast().empty();
  826. var input = new Element("input", {
  827. "styles": this.css.roomDocItemInputNode,
  828. "type": "text",
  829. "value": this.json.phoneNumber || ""
  830. }).inject(node);
  831. node = this.deviceberNode.getLast().empty();
  832. var deviceList = this.json.device.split("#");
  833. Object.each(this.app.lp.device, function(d, k){
  834. var check = (deviceList.indexOf(k)!=-1) ? "checked" : "";
  835. new Element("div", {
  836. "styles": {"float": "left", "width": "90px"},
  837. "html": "<input type=\"checkbox\" name=\"updateRoomDeviceCheckbox\" "+check+" value=\""+k+"\">"+d
  838. }).inject(node);
  839. }.bind(this));
  840. node = this.capacityNode.getLast().empty();
  841. input = new Element("input", {
  842. "styles": this.css.roomDocItemInputNode,
  843. "type": "number",
  844. "value": this.json.capacity
  845. }).inject(node);
  846. node = this.auditorNode.getLast().empty();
  847. auditorDiv = new Element("div", {"styles": this.css.roomDocItemAuditorDivNode}).inject(node);
  848. this.auditorNode.store("names", this.json.auditor);
  849. var explorer = {
  850. "actions": this.app.personActions,
  851. "app": {
  852. "lp": this.app.lp
  853. }
  854. }
  855. if (this.json.auditor){
  856. MWF.require("MWF.widget.Identity", function(){
  857. var _self = this;
  858. var person = new MWF.widget.Person({"name": this.json.auditor}, auditorDiv, explorer, true, function(e){
  859. this.node.destroy();
  860. MWF.release(this);
  861. _self.auditorNode.eliminate("names");
  862. _self.auditorNode.eliminate("person");
  863. e.stopPropagation();
  864. }, {"style": "meeting"});
  865. this.auditorNode.store("person", person);
  866. }.bind(this));
  867. }
  868. var name = this.json.auditor;
  869. MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  870. auditorDiv.addEvents({
  871. "click": function(){
  872. var options = {
  873. "type": "person",
  874. "names": (name) ? [name] : [],
  875. "count": 1,
  876. "onComplete": function(items){
  877. var op = this.auditorNode.retrieve("person");
  878. if (op){
  879. op.node.destroy();
  880. MWF.release(op);
  881. this.auditorNode.eliminate("person");
  882. }
  883. this.auditorNode.store("names", items[0].data.name);
  884. MWF.require("MWF.widget.Identity", function(){
  885. var _self = this;
  886. var person = new MWF.widget.Person(items[0].data, auditorDiv, explorer, true, function(e){
  887. this.node.destroy();
  888. MWF.release(this);
  889. _self.auditorNode.eliminate("names");
  890. _self.auditorNode.eliminate("person");
  891. e.stopPropagation();
  892. }, {"style": "meeting"});
  893. this.auditorNode.store("person", person);
  894. }.bind(this));
  895. }.bind(this)
  896. };
  897. var selector = new MWF.OrgSelector(this.app.content, options);
  898. }.bind(this)
  899. });
  900. }.bind(this));
  901. node = this.availableNode.getLast().empty();
  902. new Element("div", {
  903. "styles": {"float": "left"},
  904. "html": "<input type=\"radio\" name=\"updateRoomAvailableRadio\" "+((this.json.available) ? "checked" : "")+" value=\"y\">"+this.app.lp.enable
  905. }).inject(node);
  906. new Element("div", {
  907. "styles": {"float": "left"},
  908. "html": "<input type=\"radio\" name=\"updateRoomAvailableRadio\" "+((!this.json.available) ? "checked" : "")+" value=\"n\">"+this.app.lp.disable
  909. }).inject(node);
  910. this.titleNode.removeEvent("click", this.editDocumentFun);
  911. if (this.addrNode) this.addrNode.removeEvent("click", this.editDocumentFun);
  912. this.isEditMode = true;
  913. this.setMeetingNodeSize();
  914. },
  915. readDocument: function(){
  916. this.saveAction.setStyle("display", "none");
  917. this.editAction.setStyle("display", "block");
  918. var name = this.titleInput.get("value");
  919. this.titleInput.destroy();
  920. this.titleNode.set("text", name);
  921. var node = this.floorNode.getLast().empty();
  922. node.set("text", this.json.floor+this.app.lp.floor);
  923. node = this.roomNumberNode.getLast().empty();
  924. node.set("text", this.json.roomNumber);
  925. node = this.phoneNumberNode.getLast().empty();
  926. node.set("text", this.json.phoneNumber);
  927. node = this.deviceberNode.getLast().empty();
  928. var deviceList = this.json.device.split("#");
  929. var deviceNameList = [];
  930. deviceList.each(function(d){deviceNameList.push(this.app.lp.device[d]);}.bind(this));
  931. node.set("text", deviceNameList.join(" "));
  932. node = this.capacityNode.getLast().empty();
  933. node.set("text", this.json.capacity+this.app.lp.person);
  934. node = this.auditorNode.getLast().empty();
  935. var explorer = {
  936. "actions": this.app.personActions,
  937. "app": {
  938. "lp": this.app.lp
  939. }
  940. }
  941. if (this.json.auditor){
  942. MWF.require("MWF.widget.Identity", function(){
  943. var _self = this;
  944. var person = new MWF.widget.Person({"name": this.json.auditor}, node, explorer, false, null, {"style": "meeting"});
  945. }.bind(this));
  946. }
  947. node = this.availableNode.getLast().empty();
  948. var availableTxt = (this.json.available) ? this.app.lp.enable : this.app.lp.disable;
  949. node.set("text", availableTxt);
  950. this.titleNode.addEvent("click", this.editDocumentFun);
  951. if (this.addrNode) this.addrNode.addEvent("click", this.editDocumentFun);
  952. this.isEditMode = false;
  953. },
  954. saveDocument: function(noNotice, callback){
  955. if (this.getRoomData()){
  956. this.app.actions.saveRoom(this.json, function(json){
  957. if (!noNotice) this.app.notice(this.app.lp.save_success, "success", this.node, {"x": "right", "y": "top"});
  958. this.readDocument();
  959. this.room.reload();
  960. if (callback) callback();
  961. }.bind(this));
  962. }
  963. },
  964. getRoomData: function(){
  965. var flag = true;
  966. var name = this.titleInput.get("value");
  967. var select = this.floorNode.getElement("select");
  968. var floor = select.options[select.selectedIndex].value;
  969. var number = this.roomNumberNode.getElement("input").get("value");
  970. var phone = this.phoneNumberNode.getElement("input").get("value");
  971. var deviceList = [];
  972. var deviceChecks = this.deviceberNode.getElements("input");
  973. deviceChecks.each(function(input){
  974. if (input.checked) deviceList.push(input.get("value"));
  975. }.bind(this));
  976. var device = deviceList.join("#");
  977. var capacity = this.capacityNode.getElement("input").get("value");
  978. var auditor = this.auditorNode.retrieve("names", "")
  979. var available = true;
  980. var radios = this.availableNode.getElements("input");
  981. for (var i=0; i<radios.length; i++){
  982. if (radios[i].checked){
  983. available = (radios[i].get("value")=="y") ? true : false;
  984. break;
  985. }
  986. }
  987. if (!name){
  988. this.app.notice(this.app.lp.verification.inputName, "error", this.node, {"x": "right", "y": "top"});
  989. return false;
  990. }
  991. this.json.name = name;
  992. this.json.floor = floor;
  993. this.json.roomNumber = number;
  994. this.json.phoneNumber = phone;
  995. this.json.device = device;
  996. this.json.capacity = capacity;
  997. this.json.auditor = auditor;
  998. this.json.available = available;
  999. return true;
  1000. },
  1001. deleteDocument: function(e) {
  1002. var info = this.app.lp.delete_room;
  1003. info = info.replace(/{name}/g, this.json.name);
  1004. var _self = this;
  1005. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  1006. _self.remove();
  1007. this.close();
  1008. }, function(){
  1009. this.close();
  1010. });
  1011. },
  1012. remove: function(){
  1013. this.app.actions.deleteRoom(this.json.id, function(){
  1014. this.view.reload();
  1015. }.bind(this));
  1016. },
  1017. });