Main.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. MWF.xApplication.process.Application.options = {
  2. "multitask": true,
  3. "executable": false
  4. };
  5. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", null, false);
  6. MWF.xApplication.process.Application.Main = new Class({
  7. Extends: MWF.xApplication.Common.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default",
  11. "name": "process.Application",
  12. "icon": "icon.png",
  13. "width": "1200",
  14. "height": "700",
  15. "application": "",
  16. "id": "",
  17. "title": MWF.xApplication.process.Application.LP.title
  18. },
  19. onQueryLoad: function() {
  20. this.lp = MWF.xApplication.process.Application.LP;
  21. if (this.status) this.options.id = this.status.id;
  22. },
  23. getApplication: function(success, failure){
  24. if (!this.options.application){
  25. // if (this.status) {
  26. // if (this.status.id){
  27. this.getAction(function(){
  28. this.action.getApplication(this.options.id, function(json){
  29. if (json.data){
  30. this.setTitle(this.options.title+"-"+json.data.name);
  31. this.options.application = json.data;
  32. if (success) success();
  33. }else{
  34. if (failure) failure();
  35. }
  36. }.bind(this), function(){if (failure) failure();}.bind(this), false)
  37. }.bind(this));
  38. // }else{
  39. // if (failure) failure();
  40. // }
  41. // }else{
  42. // if (failure) failure();
  43. // }
  44. }else{
  45. if (success) success();
  46. }
  47. },
  48. getAction: function(callback){
  49. if (!this.action){
  50. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  51. this.action = new MWF.xApplication.process.Application.Actions.RestActions();
  52. if (callback) callback();
  53. }.bind(this));
  54. }else{
  55. if (callback) callback();
  56. }
  57. },
  58. createNode: function(){
  59. this.content.setStyle("overflow", "hidden");
  60. this.node = new Element("div", {
  61. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  62. }).inject(this.content);
  63. },
  64. loadApplication: function(callback){
  65. debugger;
  66. this.getApplication(function(){
  67. this.createNode();
  68. this.loadStartMenu();
  69. if (callback) callback();
  70. }.bind(this), function(){
  71. this.close();
  72. }.bind(this));
  73. //this.loadTitle();
  74. //this.loadContent();
  75. //
  76. //if (this.options.id){
  77. // this.getAction(function(){
  78. // this.action.getApplication(function(json){
  79. // this.data = json.data;
  80. // this.taskTitleTextNode.set("text", this.data.name);
  81. // this.setTitle(this.data.name);
  82. // this.setApplicationIcon();
  83. // }.bind(this), null, this.options.id);
  84. // }.bind(this));
  85. //
  86. //}
  87. },
  88. loadStartMenu: function(callback){
  89. this.startMenuNode = new Element("div", {
  90. "styles": this.css.startMenuNode
  91. }).inject(this.node);
  92. this.menu = new MWF.xApplication.process.Application.Menu(this, this.startMenuNode, {
  93. "onPostLoad": function(){
  94. this.css.rightContentNode["margin-left"] = "140px";
  95. if (this.status){
  96. if (this.status.hideMenu){
  97. this.startMenuNode.setStyle("display", "none");
  98. this.css.rightContentNode["margin-left"] = "0px";
  99. }
  100. if (this.status.navi!=null){
  101. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  102. }else{
  103. this.menu.doAction(this.menu.startNavis[0]);
  104. }
  105. }else{
  106. this.menu.doAction(this.menu.startNavis[0]);
  107. }
  108. }.bind(this)
  109. });
  110. this.addEvent("resize", function(){
  111. if (this.menu) this.menu.onResize();
  112. }.bind(this));
  113. },
  114. clearContent: function(){
  115. if (this.myWorkConfiguratorContentNode){
  116. if (this.myWorkConfigurator){
  117. this.myWorkConfigurator = null;
  118. MWF.release(this.myWorkConfigurator);
  119. }
  120. this.myWorkConfiguratorContentNode.destroy();
  121. this.myWorkConfiguratorContentNode = null;
  122. }
  123. if (this.myCompletedConfiguratorContentNode){
  124. if (this.myCompletedConfigurator){
  125. this.myCompletedConfigurator = null;
  126. MWF.release(this.myCompletedConfigurator);
  127. }
  128. this.myCompletedConfiguratorContentNode.destroy();
  129. this.myCompletedConfiguratorContentNode = null;
  130. }
  131. if (this.workConfiguratorContentNode){
  132. if (this.workConfigurator){
  133. this.workConfigurator = null;
  134. MWF.release(this.workConfigurator);
  135. }
  136. this.workConfiguratorContentNode.destroy();
  137. this.workConfiguratorContentNode = null;
  138. }
  139. if (this.completedConfiguratorContentNode){
  140. if (this.completedConfigurator){
  141. this.completedConfigurator = null;
  142. MWF.release(this.completedConfigurator);
  143. }
  144. this.completedConfiguratorContentNode.destroy();
  145. this.completedConfiguratorContentNode = null;
  146. }
  147. if (this.dataConfiguratorContent){
  148. if (this.dataConfigurator){
  149. this.dataConfigurator = null;
  150. MWF.release(this.dataConfigurator)
  151. }
  152. this.dataConfiguratorContent.destroy();
  153. this.dataConfiguratorContent = null;
  154. }
  155. if (this.serialConfiguratorContent){
  156. if (this.serialConfigurator){
  157. this.serialConfigurator = null;
  158. MWF.release(this.serialConfigurator);
  159. }
  160. this.serialConfiguratorContent.destroy();
  161. this.serialConfiguratorContent = null;
  162. }
  163. if (this.statConfiguratorContentNode){
  164. if (this.statConfigurator){
  165. this.statConfigurator = null;
  166. MWF.release(this.statConfigurator);
  167. }
  168. this.statConfiguratorContentNode.destroy();
  169. this.statConfiguratorContentNode = null;
  170. }
  171. if (this.viewConfiguratorContentNode){
  172. if (this.viewConfigurator){
  173. MWF.release(this.viewConfigurator);
  174. this.viewConfigurator = null;
  175. }
  176. this.viewConfiguratorContentNode.destroy();
  177. this.viewConfiguratorContentNode = null;
  178. }
  179. if (this.statConfiguratorContentNode){
  180. if (this.statConfigurator){
  181. MWF.release(this.statConfigurator);
  182. this.statConfigurator = null;
  183. }
  184. this.statConfiguratorContentNode.destroy();
  185. this.statConfiguratorContentNode = null;
  186. }
  187. },
  188. statConfig: function(){
  189. this.clearContent();
  190. this.statConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  191. this.loadStatConfig();
  192. },
  193. loadStatConfig: function(){
  194. MWF.xDesktop.requireApp("process.Application", "StatExplorer", function(){
  195. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  196. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  197. this.statConfigurator = new MWF.xApplication.process.Application.StatExplorer(this.statConfiguratorContentNode, this.restActions);
  198. this.statConfigurator.app = this;
  199. this.statConfigurator.load();
  200. }.bind(this));
  201. }.bind(this));
  202. },
  203. viewConfig: function(){
  204. this.clearContent();
  205. this.viewConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  206. this.loadViewConfig();
  207. },
  208. loadViewConfig: function(){
  209. MWF.xDesktop.requireApp("process.Application", "ViewExplorer", function(){
  210. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  211. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  212. this.viewConfigurator = new MWF.xApplication.process.Application.ViewExplorer(this.viewConfiguratorContentNode, this.restActions);
  213. this.viewConfigurator.app = this;
  214. this.viewConfigurator.load();
  215. }.bind(this));
  216. }.bind(this));
  217. },
  218. myWorkConfig: function(){
  219. this.clearContent();
  220. this.myWorkConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  221. this.loadMyWorkConfig();
  222. },
  223. loadMyWorkConfig: function(){
  224. MWF.xDesktop.requireApp("process.Application", "MyWorkExplorer", function(){
  225. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  226. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  227. this.myWorkConfigurator = new MWF.xApplication.process.Application.MyWorkExplorer(this.myWorkConfiguratorContentNode, this.restActions);
  228. this.myWorkConfigurator.app = this;
  229. this.myWorkConfigurator.load();
  230. }.bind(this));
  231. }.bind(this));
  232. },
  233. myWorkCompletedConfig: function(){
  234. this.clearContent();
  235. this.myCompletedConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  236. this.loadMyWorkCompletedConfig();
  237. },
  238. loadMyWorkCompletedConfig: function(){
  239. MWF.xDesktop.requireApp("process.Application", "MyWorkCompletedExplorer", function(){
  240. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  241. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  242. this.myCompletedConfigurator = new MWF.xApplication.process.Application.MyWorkCompletedExplorer(this.myCompletedConfiguratorContentNode, this.restActions);
  243. this.myCompletedConfigurator.app = this;
  244. this.myCompletedConfigurator.load();
  245. }.bind(this));
  246. }.bind(this));
  247. },
  248. workConfig: function(){
  249. this.clearContent();
  250. this.workConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  251. this.loadWorkConfig();
  252. },
  253. loadWorkConfig: function(){
  254. MWF.xDesktop.requireApp("process.Application", "WorkExplorer", function(){
  255. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  256. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  257. this.workConfigurator = new MWF.xApplication.process.Application.WorkExplorer(this.workConfiguratorContentNode, this.restActions);
  258. this.workConfigurator.app = this;
  259. this.workConfigurator.load();
  260. }.bind(this));
  261. }.bind(this));
  262. },
  263. workCompletedConfig: function(){
  264. this.clearContent();
  265. this.completedConfiguratorContentNode = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  266. this.loadWorkCompletedConfig();
  267. },
  268. loadWorkCompletedConfig: function(){
  269. MWF.xDesktop.requireApp("process.Application", "WorkCompletedExplorer", function(){
  270. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  271. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  272. this.completedConfigurator = new MWF.xApplication.process.Application.WorkCompletedExplorer(this.completedConfiguratorContentNode, this.restActions);
  273. this.completedConfigurator.app = this;
  274. this.completedConfigurator.load();
  275. }.bind(this));
  276. }.bind(this));
  277. },
  278. dataConfig: function(){
  279. this.clearContent();
  280. this.dataConfiguratorContent = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  281. this.loadDataConfig();
  282. },
  283. loadDataConfig: function(){
  284. MWF.xDesktop.requireApp("process.Application", "DictionaryExplorer", function(){
  285. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  286. //if (!this.dictActions) this.dictActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  287. if (!this.dictActions) this.dictActions = new MWF.xApplication.process.Application.Actions.RestActions();
  288. this.dataConfigurator = new MWF.xApplication.process.Application.DictionaryExplorer(this.dataConfiguratorContent, this.dictActions, {
  289. "noCreate": true,
  290. "noDelete": true,
  291. "noModifyName": true,
  292. "readMode": !this.options.application.allowControl
  293. });
  294. this.dataConfigurator.app = this;
  295. this.dataConfigurator.load();
  296. }.bind(this));
  297. }.bind(this));
  298. },
  299. serialConfig: function(){
  300. this.clearContent();
  301. this.serialConfiguratorContent = new Element("div", {"styles": this.css.rightContentNode}).inject(this.node);
  302. this.loadSerialConfig();
  303. },
  304. loadSerialConfig: function(){
  305. MWF.xDesktop.requireApp("process.Application", "SerialExplorer", function(){
  306. MWF.xDesktop.requireApp("process.Application", "Actions.RestActions", function(){
  307. if (!this.restActions) this.restActions = new MWF.xApplication.process.Application.Actions.RestActions();
  308. this.serialConfigurator = new MWF.xApplication.process.Application.SerialExplorer(this.serialConfiguratorContent, this.restActions);
  309. this.serialConfigurator.app = this;
  310. this.serialConfigurator.load();
  311. }.bind(this));
  312. }.bind(this));
  313. },
  314. recordStatus: function(){
  315. var idx = null;
  316. if (this.menu.currentNavi){
  317. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  318. }
  319. return {"navi": idx, "id": this.options.id};
  320. }
  321. });
  322. MWF.xApplication.process.Application.Menu = new Class({
  323. Implements: [Options, Events],
  324. initialize: function(app, node, options){
  325. this.setOptions(options);
  326. this.app = app;
  327. this.node = $(node);
  328. this.currentNavi = null;
  329. this.status = "start";
  330. this.startNavis = [];
  331. this.load();
  332. },
  333. load: function(){
  334. var menuUrl = this.app.path+"startMenu.json";
  335. //if (MWF.AC.isAdministrator()) menuUrl = this.app.path+"startMenu_admin.json";
  336. MWF.getJSON(menuUrl, function(json){
  337. json.each(function(navi){
  338. var naviNode = new Element("div", {
  339. "styles": this.app.css.startMenuNaviNode
  340. });
  341. naviNode.store("naviData", navi);
  342. if (navi.hint) naviNode.set("title", navi.hint);
  343. var iconNode = new Element("div", {
  344. "styles": this.app.css.startMenuIconNode
  345. }).inject(naviNode);
  346. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  347. var textNode = new Element("div", {
  348. "styles": this.app.css.startMenuTextNode,
  349. "text": navi.title
  350. });
  351. textNode.inject(naviNode);
  352. naviNode.inject(this.node);
  353. this.startNavis.push(naviNode);
  354. this.setStartNaviEvent(naviNode, navi);
  355. this.setNodeCenter(this.node);
  356. }.bind(this));
  357. this.setStartMenuWidth();
  358. this.fireEvent("postLoad");
  359. }.bind(this));
  360. },
  361. setStartNaviEvent: function(naviNode){
  362. var _self = this;
  363. naviNode.addEvents({
  364. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  365. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  366. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  367. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  368. "click": function(){
  369. _self.doAction.apply(_self, [this]);
  370. }
  371. });
  372. },
  373. doAction: function(naviNode){
  374. var navi = naviNode.retrieve("naviData");
  375. var action = navi.action;
  376. if (this.currentNavi) this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  377. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  378. this.currentNavi = naviNode;
  379. if (this.app[action]) this.app[action].apply(this.app);
  380. if (this.status == "start"){
  381. this.toNormal();
  382. this.status = "normal";
  383. }
  384. },
  385. toNormal: function(){
  386. var css = this.app.css.normalStartMenuNode;
  387. if (!this.morph){
  388. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  389. }
  390. this.morph.start(css).chain(function(){
  391. this.node.setStyles(css);
  392. MWF.require("MWF.widget.ScrollBar", function(){
  393. new MWF.widget.ScrollBar(this.node, {
  394. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  395. });
  396. }.bind(this));
  397. }.bind(this));
  398. },
  399. setNodeCenter: function(node){
  400. var size = node.getSize();
  401. var contentSize = this.app.node.getSize();
  402. var top = contentSize.y/2 - size.y/2;
  403. var left = contentSize.x/2 - size.x/2;
  404. if (left<0) left = 0;
  405. if (top<0) top = 0;
  406. node.setStyles({"left": left, "top": top});
  407. },
  408. getStartMenuNormalSize: function(){
  409. var naviItemNode = this.node.getFirst();
  410. var size = naviItemNode.getComputedSize();
  411. var mt = naviItemNode.getStyle("margin-top").toFloat();
  412. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  413. var height = size.totalWidth+mt+mb;
  414. var ml = naviItemNode.getStyle("margin-left").toFloat();
  415. var mr = naviItemNode.getStyle("margin-right").toFloat();
  416. var width = size.totalWidth+ml+mr;
  417. return {"width": width, "height": height*this.startNavis.length};
  418. },
  419. setStartMenuWidth: function(){
  420. var naviItemNode = this.node.getFirst();
  421. var size = naviItemNode.getComputedSize();
  422. var ml = naviItemNode.getStyle("margin-left").toFloat();
  423. var mr = naviItemNode.getStyle("margin-right").toFloat();
  424. var width = size.totalWidth+ml+mr;
  425. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  426. },
  427. onResize: function(){
  428. if (this.status == "start"){
  429. this.setNodeCenter(this.node);
  430. }
  431. }
  432. });