Main.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. MWF.xDesktop.requireApp("process.ProcessManager", "package", null, false);
  2. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("process.ProcessManager", "lp."+MWF.language, null, false);
  4. MWF.xDesktop.requireApp("Selector", "package", null, false);
  5. //MWF.require("MWF.xAction.org.express.RestActions", null,false);
  6. MWF.require("MWF.widget.O2Identity", null,false);
  7. MWF.xApplication.process.ProcessManager.Main = new Class({
  8. Extends: MWF.xApplication.Common.Main,
  9. Implements: [Options, Events],
  10. options: {
  11. "application": null,
  12. "style": "default",
  13. "name": "process.ProcessManager",
  14. "icon": "icon.png",
  15. "width": "1100",
  16. "height": "700",
  17. "title": MWF.xApplication.process.ProcessManager.LP.title
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.process.ProcessManager.LP;
  21. this.currentContentNode = null;
  22. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  23. //this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  24. },
  25. loadApplication: function(callback){
  26. //if (this.status){
  27. // if (!this.options.application){
  28. // if (this.status.application){
  29. // this.restActions.getApplication(this.status.application, function(json){
  30. // if (json.data){
  31. // this.options.application = json.data;
  32. // alert("sds"+this.options.application);
  33. // }else{
  34. // this.close();
  35. // }
  36. // }.bind(this), function(){this.close();}.bind(this), false)
  37. // }else{
  38. // this.close();
  39. // }
  40. // }
  41. //}
  42. this.getApplication(function(){
  43. this.setTitle(this.lp.title + "-"+this.options.application.name);
  44. this.createNode();
  45. this.loadApplicationContent();
  46. if (callback) callback();
  47. //var clipboardEvent = new ClipboardEvent("copy", {dataType: "text/plain", data:""});
  48. if (window.clipboardData){
  49. this.addKeyboardEvents();
  50. }else{
  51. this.keyCopyItemsFun = this.keyCopyItems.bind(this);
  52. this.keyPasteItemsFun = this.keyPasteItems.bind(this);
  53. document.addEventListener('copy', this.keyCopyItemsFun);
  54. document.addEventListener('paste', this.keyPasteItemsFun);
  55. this.addEvent("queryClose", function(){
  56. if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  57. if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
  58. }.bind(this));
  59. }
  60. }.bind(this), function(){
  61. this.close();
  62. }.bind(this));
  63. },
  64. addKeyboardEvents: function(){
  65. this.addEvent("copy", function(){
  66. this.keyCopyItems();
  67. }.bind(this));
  68. this.addEvent("paste", function(){
  69. this.keyPasteItems();
  70. }.bind(this));
  71. },
  72. keyCopyItems: function(e){
  73. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId){
  74. if (this.formConfigurator){
  75. this.formConfigurator.keyCopy(e);
  76. if (e) e.preventDefault();
  77. }
  78. if (this.processConfigurator){
  79. this.processConfigurator.keyCopy(e);
  80. if (e) e.preventDefault();
  81. }
  82. if (this.dataConfigurator){
  83. this.dataConfigurator.keyCopy(e);
  84. if (e) e.preventDefault();
  85. }
  86. if (this.scriptConfigurator){
  87. this.scriptConfigurator.keyCopy(e);
  88. if (e) e.preventDefault();
  89. }
  90. }
  91. },
  92. keyPasteItems: function(e){
  93. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
  94. if (this.formConfigurator) {
  95. this.formConfigurator.keyPaste(e);
  96. }
  97. if (this.processConfigurator) {
  98. this.processConfigurator.keyPaste(e);
  99. }
  100. if (this.dataConfigurator) {
  101. this.dataConfigurator.keyPaste(e);
  102. }
  103. if (this.scriptConfigurator) {
  104. this.scriptConfigurator.keyPaste(e);
  105. }
  106. }
  107. },
  108. getApplication: function(success, failure){
  109. if (!this.options.application){
  110. if (this.status) {
  111. if (this.status.application){
  112. this.restActions.getApplication(this.status.application, function(json){
  113. if (json.data){
  114. this.options.application = json.data;
  115. if (success) success();
  116. }else{
  117. if (failure) failure();
  118. }
  119. }.bind(this), function(){if (failure) failure();}.bind(this), false)
  120. }else{
  121. if (failure) failure();
  122. }
  123. }else{
  124. if (failure) failure();
  125. }
  126. }else{
  127. if (success) success();
  128. }
  129. },
  130. loadApplicationContent: function(){
  131. this.loadStartMenu();
  132. this.loadApplicationLayout();
  133. },
  134. createNode: function(){
  135. this.content.setStyle("overflow", "hidden");
  136. this.node = new Element("div", {
  137. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  138. }).inject(this.content);
  139. },
  140. loadApplicationLayout: function(){
  141. // this.topMenuNode = new Element("div").inject(this.node);
  142. // MWF.require("MWF.widget.Toolbar", function(){
  143. // this.toobar = new MWF.widget.Toolbar(this.topMenuNode);
  144. // this.toobar.load();
  145. // alert("ok")
  146. // }.bind(this));
  147. },
  148. loadStartMenu: function(callback){
  149. this.startMenuNode = new Element("div", {
  150. "styles": this.css.startMenuNode
  151. }).inject(this.node);
  152. this.menu = new MWF.xApplication.process.ProcessManager.Menu(this, this.startMenuNode, {
  153. "onPostLoad": function(){
  154. if (this.status){
  155. if (this.status.navi!=null){
  156. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  157. }else{
  158. this.menu.doAction(this.menu.startNavis[0]);
  159. }
  160. }else{
  161. this.menu.doAction(this.menu.startNavis[0]);
  162. }
  163. }.bind(this)
  164. });
  165. this.addEvent("resize", function(){
  166. if (this.menu) this.menu.onResize();
  167. }.bind(this));
  168. },
  169. clearContent: function(){
  170. if (this.processConfiguratorContent){
  171. if (this.processConfigurator){
  172. if (this.processConfigurator.destroy) this.processConfigurator.destroy();
  173. delete this.processConfigurator;
  174. }
  175. this.processConfiguratorContent.destroy();
  176. this.processConfiguratorContent = null;
  177. }
  178. if (this.formConfiguratorContent){
  179. if (this.formConfigurator){
  180. if (this.formConfigurator.destroy) this.formConfigurator.destroy();
  181. delete this.formConfigurator;
  182. }
  183. this.formConfiguratorContent.destroy();
  184. this.formConfiguratorContent = null;
  185. }
  186. if (this.viewConfiguratorContent){
  187. if (this.viewConfigurator){
  188. if (this.viewConfigurator.destroy) this.viewConfigurator.destroy();
  189. delete this.viewConfigurator;
  190. }
  191. this.viewConfiguratorContent.destroy();
  192. this.viewConfiguratorContent = null;
  193. }
  194. if (this.statConfiguratorContent){
  195. if (this.statConfigurator){
  196. if (this.statConfigurator.destroy) this.statConfigurator.destroy();
  197. delete this.statConfigurator;
  198. }
  199. this.statConfiguratorContent.destroy();
  200. this.statConfiguratorContent = null;
  201. }
  202. if (this.propertyConfiguratorContent){
  203. if (this.property){
  204. if (this.property.destroy) this.property.destroy();
  205. delete this.property;
  206. }
  207. this.propertyConfiguratorContent.destroy();
  208. this.propertyConfiguratorContent = null;
  209. }
  210. if (this.dataConfiguratorContent){
  211. if (this.dataConfigurator){
  212. if (this.dataConfigurator.destroy) this.dataConfigurator.destroy();
  213. delete this.dataConfigurator;
  214. }
  215. this.dataConfiguratorContent.destroy();
  216. this.dataConfiguratorContent = null;
  217. }
  218. if (this.scriptConfiguratorContent){
  219. if (this.scriptConfigurator){
  220. if (this.scriptConfigurator.destroy) this.scriptConfigurator.destroy();
  221. delete this.scriptConfigurator;
  222. }
  223. this.scriptConfiguratorContent.destroy();
  224. this.scriptConfiguratorContent = null;
  225. }
  226. if (this.fileConfiguratorContent){
  227. if (this.fileConfigurator){
  228. if (this.fileConfigurator.destroy) this.fileConfigurator.destroy();
  229. delete this.fileConfigurator;
  230. }
  231. this.fileConfiguratorContent.destroy();
  232. this.fileConfiguratorContent = null;
  233. }
  234. if (this.projectionConfiguratorContent){
  235. if (this.projectionConfigurator){
  236. if (this.projectionConfigurator.destroy) this.projectionConfigurator.destroy();
  237. delete this.projectionConfigurator;
  238. }
  239. this.projectionConfiguratorContent.destroy();
  240. this.projectionConfiguratorContent = null;
  241. }
  242. },
  243. applicationProperty: function(){
  244. this.clearContent();
  245. this.propertyConfiguratorContent = new Element("div", {
  246. "styles": this.css.rightContentNode
  247. }).inject(this.node);
  248. this.property = new MWF.xApplication.process.ProcessManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  249. this.property.load();
  250. },
  251. projectionConfig: function(){
  252. this.clearContent();
  253. this.projectionConfiguratorContent = new Element("div", {
  254. "styles": this.css.rightContentNode
  255. }).inject(this.node);
  256. this.loadProjectionConfig();
  257. },
  258. loadProjectionConfig: function(){
  259. MWF.xDesktop.requireApp("process.ProcessManager", "ProjectionExplorer", function(){
  260. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  261. this.projectionConfigurator = new MWF.xApplication.process.ProcessManager.ProjectionExplorer(this.projectionConfiguratorContent, this.restActions);
  262. this.projectionConfigurator.app = this;
  263. this.projectionConfigurator.load();
  264. }.bind(this));
  265. },
  266. processConfig: function(){
  267. this.clearContent();
  268. this.processConfiguratorContent = new Element("div", {
  269. "styles": this.css.rightContentNode
  270. }).inject(this.node);
  271. this.loadProcessConfig();
  272. },
  273. loadProcessConfig: function(){
  274. MWF.xDesktop.requireApp("process.ProcessManager", "ProcessExplorer", function(){
  275. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  276. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  277. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  278. this.processConfigurator = new MWF.xApplication.process.ProcessManager.ProcessExplorer(this.processConfiguratorContent, this.restActions);
  279. this.processConfigurator.app = this;
  280. this.processConfigurator.load();
  281. //}.bind(this));
  282. }.bind(this));
  283. },
  284. formConfig: function(){
  285. this.clearContent();
  286. this.formConfiguratorContent = new Element("div", {
  287. "styles": this.css.rightContentNode
  288. }).inject(this.node);
  289. this.loadFormConfig();
  290. },
  291. loadFormConfig: function(){
  292. MWF.xDesktop.requireApp("process.ProcessManager", "FormExplorer", function(){
  293. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  294. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  295. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  296. this.formConfigurator = new MWF.xApplication.process.ProcessManager.FormExplorer(this.formConfiguratorContent, this.restActions);
  297. this.formConfigurator.app = this;
  298. this.formConfigurator.load();
  299. //}.bind(this));
  300. }.bind(this));
  301. },
  302. viewConfig: function(){
  303. this.clearContent();
  304. this.viewConfiguratorContent = new Element("div", {
  305. "styles": this.css.rightContentNode
  306. }).inject(this.node);
  307. this.loadViewConfig();
  308. },
  309. loadViewConfig: function(){
  310. MWF.xDesktop.requireApp("process.ProcessManager", "ViewExplorer", function(){
  311. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  312. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  313. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  314. this.viewConfigurator = new MWF.xApplication.process.ProcessManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  315. this.viewConfigurator.app = this;
  316. this.viewConfigurator.load();
  317. //}.bind(this));
  318. }.bind(this));
  319. },
  320. statConfig: function(){
  321. this.clearContent();
  322. this.statConfiguratorContent = new Element("div", {
  323. "styles": this.css.rightContentNode
  324. }).inject(this.node);
  325. this.loadStatConfig();
  326. },
  327. loadStatConfig: function(){
  328. MWF.xDesktop.requireApp("process.ProcessManager", "StatExplorer", function(){
  329. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  330. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  331. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  332. this.statConfigurator = new MWF.xApplication.process.ProcessManager.StatExplorer(this.statConfiguratorContent, this.restActions);
  333. this.statConfigurator.app = this;
  334. this.statConfigurator.load();
  335. //}.bind(this));
  336. }.bind(this));
  337. },
  338. dataConfig: function(){
  339. this.clearContent();
  340. this.dataConfiguratorContent = new Element("div", {
  341. "styles": this.css.rightContentNode
  342. }).inject(this.node);
  343. this.loadDataConfig();
  344. },
  345. loadDataConfig: function(){
  346. MWF.xDesktop.requireApp("process.ProcessManager", "DictionaryExplorer", function(){
  347. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  348. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  349. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  350. this.dataConfigurator = new MWF.xApplication.process.ProcessManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions);
  351. this.dataConfigurator.app = this;
  352. this.dataConfigurator.load();
  353. //}.bind(this));
  354. }.bind(this));
  355. },
  356. scriptConfig: function(){
  357. this.clearContent();
  358. this.scriptConfiguratorContent = new Element("div", {
  359. "styles": this.css.rightContentNode
  360. }).inject(this.node);
  361. this.loadScriptConfig();
  362. },
  363. loadScriptConfig: function(){
  364. MWF.xDesktop.requireApp("process.ProcessManager", "ScriptExplorer", function(){
  365. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  366. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  367. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  368. this.scriptConfigurator = new MWF.xApplication.process.ProcessManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  369. this.scriptConfigurator.app = this;
  370. this.scriptConfigurator.load();
  371. //}.bind(this));
  372. }.bind(this));
  373. },
  374. fileConfig: function(){
  375. this.clearContent();
  376. this.fileConfiguratorContent = new Element("div", {
  377. "styles": this.css.rightContentNode
  378. }).inject(this.node);
  379. this.loadFileConfig();
  380. },
  381. loadFileConfig: function(){
  382. MWF.xDesktop.requireApp("process.ProcessManager", "FileExplorer", function(){
  383. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  384. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  385. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  386. this.fileConfigurator = new MWF.xApplication.process.ProcessManager.FileExplorer(this.fileConfiguratorContent, this.restActions);
  387. this.fileConfigurator.app = this;
  388. this.fileConfigurator.load();
  389. //}.bind(this));
  390. }.bind(this));
  391. },
  392. getCategoryCount: function(){
  393. var size = this.processConfiguratorContent.getSize();
  394. categoryCount = parseInt(size.x/182)+5;
  395. return categoryCount;
  396. },
  397. getProcessCount: function(){
  398. if (this.processConfigurator){
  399. var size = this.processConfigurator.processNode.getSize();
  400. processCount = (parseInt(size.x/401)*parseInt(size.y/101))+10;
  401. return processCount;
  402. }
  403. return 20;
  404. },
  405. showContentNode: function(node){
  406. if (this.currentContentNode){
  407. // this.currentContentNode.setStyles({
  408. // "position": "absolute"
  409. // });
  410. this.currentContentNode.fade("hide");
  411. node.fade("show");
  412. node.setStyle("display", "node");
  413. this.currentContentNode = null;
  414. }
  415. node.setStyle("display", "block");
  416. node.fade("show");
  417. this.currentContentNode = node;
  418. },
  419. recordStatus: function(){
  420. var idx = null;
  421. if (this.menu.currentNavi){
  422. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  423. }
  424. return {"navi": idx, "application": this.options.application.id};
  425. }
  426. // onResize: function(){
  427. // if (this.menu) this.menu.onResize();
  428. // }
  429. });
  430. MWF.xApplication.process.ProcessManager.Menu = new Class({
  431. Implements: [Options, Events],
  432. initialize: function(app, node, options){
  433. this.setOptions(options);
  434. this.app = app;
  435. this.node = $(node);
  436. this.currentNavi = null;
  437. this.status = "start";
  438. this.startNavis = [];
  439. this.load();
  440. },
  441. load: function(){
  442. var menuUrl = this.app.path+"startMenu.json";
  443. MWF.getJSON(menuUrl, function(json){
  444. json.each(function(navi){
  445. var naviNode = new Element("div", {
  446. "styles": this.app.css.startMenuNaviNode
  447. });
  448. naviNode.store("naviData", navi);
  449. var iconNode = new Element("div", {
  450. "styles": this.app.css.startMenuIconNode
  451. }).inject(naviNode);
  452. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  453. var textNode = new Element("div", {
  454. "styles": this.app.css.startMenuTextNode,
  455. "text": navi.title
  456. });
  457. textNode.inject(naviNode);
  458. naviNode.inject(this.node);
  459. this.startNavis.push(naviNode);
  460. this.setStartNaviEvent(naviNode, navi);
  461. this.setNodeCenter(this.node);
  462. }.bind(this));
  463. this.setStartMenuWidth();
  464. this.fireEvent("postLoad");
  465. }.bind(this));
  466. },
  467. setStartNaviEvent: function(naviNode){
  468. var _self = this;
  469. naviNode.addEvents({
  470. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  471. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  472. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  473. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  474. "click": function(){
  475. //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
  476. _self.doAction.apply(_self, [this]);
  477. }
  478. });
  479. },
  480. doAction: function(naviNode){
  481. var navi = naviNode.retrieve("naviData");
  482. var action = navi.action;
  483. if (this.currentNavi) this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  484. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  485. this.currentNavi = naviNode;
  486. if (this.app[action]) this.app[action].apply(this.app);
  487. if (this.status == "start"){
  488. this.toNormal();
  489. this.status = "normal";
  490. }
  491. },
  492. toNormal: function(){
  493. // var size = this.getStartMenuNormalSize();
  494. var css = this.app.css.normalStartMenuNode;
  495. //css.height = size.height+"px";
  496. // css.height = "100%";
  497. // css.width = size.width+"px";
  498. //// this.node.setStyles(css);
  499. //
  500. if (!this.morph){
  501. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  502. }
  503. // this.morph.start(css).chain(function(){
  504. this.node.setStyles(css);
  505. MWF.require("MWF.widget.ScrollBar", function(){
  506. new MWF.widget.ScrollBar(this.node, {
  507. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  508. });
  509. }.bind(this));
  510. // }.bind(this));
  511. //
  512. //// this.node.setStyles(css);
  513. ////
  514. //// this.startNavis.each(function(naviNode){
  515. //// if (this.currentNavi!=naviNode) naviNode.setStyles(this.app.css.startMenuNaviNode);
  516. //// }.bind(this));
  517. //
  518. // this.node.set("morph", {duration: 50});
  519. // this.node.morph(css);
  520. },
  521. setNodeCenter: function(node){
  522. var size = node.getSize();
  523. var contentSize = this.app.node.getSize();
  524. var top = contentSize.y/2 - size.y/2;
  525. var left = contentSize.x/2 - size.x/2;
  526. if (left<0) left = 0;
  527. if (top<0) top = 0;
  528. node.setStyles({"left": left, "top": top});
  529. },
  530. getStartMenuNormalSize: function(){
  531. var naviItemNode = this.node.getFirst();
  532. var size = naviItemNode.getComputedSize();
  533. var mt = naviItemNode.getStyle("margin-top").toFloat();
  534. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  535. var height = size.totalWidth+mt+mb;
  536. var ml = naviItemNode.getStyle("margin-left").toFloat();
  537. var mr = naviItemNode.getStyle("margin-right").toFloat();
  538. var width = size.totalWidth+ml+mr;
  539. return {"width": width, "height": height*this.startNavis.length};
  540. },
  541. setStartMenuWidth: function(){
  542. var naviItemNode = this.node.getFirst();
  543. var size = naviItemNode.getComputedSize();
  544. var ml = naviItemNode.getStyle("margin-left").toFloat();
  545. var mr = naviItemNode.getStyle("margin-right").toFloat();
  546. var width = size.totalWidth+ml+mr;
  547. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  548. },
  549. onResize: function(){
  550. if (this.status == "start"){
  551. this.setNodeCenter(this.node);
  552. }
  553. }
  554. });
  555. MWF.xApplication.process.ProcessManager.ApplicationProperty = new Class({
  556. initialize: function(app, node){
  557. this.app = app;
  558. this.node = $(node);
  559. this.data = this.app.options.application;
  560. },
  561. load: function(){
  562. this.app.restActions.getApplication(this.app.options.application.id, function(json){
  563. this.data = json.data;
  564. this.propertyTitleBar = new Element("div", {
  565. "styles": this.app.css.propertyTitleBar,
  566. "text": this.data.name
  567. }).inject(this.node);
  568. this.contentNode = new Element("div", {
  569. "styles": this.app.css.propertyContentNode
  570. }).inject(this.node);
  571. this.contentAreaNode = new Element("div", {
  572. "styles": this.app.css.propertyContentAreaNode
  573. }).inject(this.contentNode);
  574. this.setContentHeight();
  575. this.setContentHeightFun = this.setContentHeight.bind(this);
  576. this.app.addEvent("resize", this.setContentHeightFun);
  577. MWF.require("MWF.widget.ScrollBar", function(){
  578. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  579. }.bind(this));
  580. this.baseActionAreaNode = new Element("div", {
  581. "styles": this.app.css.baseActionAreaNode
  582. }).inject(this.contentAreaNode);
  583. this.baseActionNode = new Element("div", {
  584. "styles": this.app.css.propertyInforActionNode
  585. }).inject(this.baseActionAreaNode);
  586. this.baseTextNode = new Element("div", {
  587. "styles": this.app.css.baseTextNode,
  588. "text": this.app.lp.application.property
  589. }).inject(this.baseActionAreaNode);
  590. this.createEditBaseNode();
  591. this.createPropertyContentNode();
  592. this.createIconContentNode();
  593. this.createAvailableNode();
  594. this.createControllerListNode();
  595. }.bind(this));
  596. },
  597. setContentHeight: function(){
  598. var size = this.app.content.getSize();
  599. var titleSize = this.propertyTitleBar.getSize();
  600. var y = size.y-titleSize.y;
  601. this.contentNode.setStyle("height", ""+y+"px");
  602. },
  603. createIconContentNode: function(){
  604. this.iconContentTitleNode = new Element("div", {
  605. "styles": this.app.css.iconContentTitleNode,
  606. "text": this.app.lp.application.icon
  607. }).inject(this.contentAreaNode);
  608. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  609. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  610. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  611. html += "</table>";
  612. this.iconContentNode.set("html", html);
  613. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  614. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  615. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  616. this.iconPreviewNode.setStyles({
  617. "height": "72px",
  618. "width": "72px",
  619. "float": "right"
  620. });
  621. if (this.data.icon){
  622. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  623. }else{
  624. //this.iconPreviewNode.setStyle("background", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  625. this.iconPreviewNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/application.png) center center no-repeat")
  626. }
  627. var changeIconAction = new Element("div", {
  628. "styles": {
  629. "margin-left": "20px",
  630. "float": "left",
  631. "background-color": "#FFF",
  632. "padding": "4px 14px",
  633. "border": "1px solid #999",
  634. "border-radius": "3px",
  635. "margin-top": "10px",
  636. "font-size": "14px",
  637. "color": "#666",
  638. "cursor": "pointer"
  639. },
  640. "text": "更改图标"
  641. }).inject(this.iconActionNode);
  642. changeIconAction.addEvent("click", function(){
  643. this.changeIcon();
  644. }.bind(this));
  645. },
  646. changeIcon: function(){
  647. MWF.require("MWF.widget.Upload", function(){
  648. var upload = new MWF.widget.Upload(this.app.content, {
  649. "data": null,
  650. "parameter": {"id": this.data.id},
  651. "action": this.app.restActions.action,
  652. "method": "updateApplicationIcon",
  653. "onCompleted": function(json){
  654. this.app.restActions.getApplication(this.data.id, function(json){
  655. if (json.data){
  656. this.data = json.data;
  657. if (this.data.icon){
  658. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  659. }else{
  660. this.iconPreviewNode.setStyle("background", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  661. }
  662. }
  663. }.bind(this), false)
  664. }.bind(this)
  665. });
  666. upload.load();
  667. }.bind(this));
  668. },
  669. changeIcon_1: function(){
  670. if (!this.uploadFileAreaNode){
  671. this.uploadFileAreaNode = new Element("div");
  672. var html = "<input name=\"file\" type=\"file\"/>";
  673. this.uploadFileAreaNode.set("html", html);
  674. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  675. this.fileUploadNode.addEvent("change", function(){
  676. var files = fileNode.files;
  677. if (files.length){
  678. for (var i = 0; i < files.length; i++) {
  679. var file = files.item(i);
  680. var formData = new FormData();
  681. formData.append('file', file);
  682. //formData.append('name', file.name);
  683. //formData.append('folder', folderId);
  684. this.app.restActions.changeApplicationIcon(this.data.id ,function(){
  685. this.app.restActions.getApplication(this.data.id, function(json){
  686. if (json.data){
  687. this.data = json.data;
  688. if (this.data.icon){
  689. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  690. }else{
  691. this.iconPreviewNode.setStyle("background", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  692. }
  693. }
  694. }.bind(this), false)
  695. }.bind(this), null, formData, file);
  696. }
  697. }
  698. }.bind(this));
  699. }
  700. var fileNode = this.uploadFileAreaNode.getFirst();
  701. fileNode.click();
  702. },
  703. createPropertyContentNode: function(){
  704. this.propertyContentNode = new Element("div", {"styles": {
  705. "overflow": "hidden",
  706. "-webkit-user-select": "text",
  707. "-moz-user-select": "text"
  708. }}).inject(this.contentAreaNode);
  709. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  710. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  711. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  712. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  713. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  714. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  715. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  716. html += "</table>";
  717. this.propertyContentNode.set("html", html);
  718. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  719. this.nameInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  720. this.aliasInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  721. this.descriptionInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  722. this.typeInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  723. this.idInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  724. },
  725. createControllerListNode: function(){
  726. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  727. this.controllerListTitleNode = new Element("div", {
  728. "styles": this.app.css.controllerListTitleNode,
  729. "text": this.app.lp.application.controllerList
  730. }).inject(this.contentAreaNode);
  731. this.controllerListContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  732. this.administratorsContentNode = new Element("div", {"styles": this.app.css.administratorsContentNode}).inject(this.controllerListContentNode);
  733. var changeAdministrators = new Element("div", {
  734. "styles": {
  735. "margin-left": "40px",
  736. "float": "left",
  737. "background-color": "#FFF",
  738. "padding": "4px 14px",
  739. "border": "1px solid #999",
  740. "border-radius": "3px",
  741. "margin-top": "10px",
  742. "margin-bottom": "20px",
  743. "font-size": "14px",
  744. "color": "#666",
  745. "cursor": "pointer"
  746. },
  747. "text": "设置管理者"
  748. }).inject(this.contentAreaNode);
  749. changeAdministrators.addEvent("click", function(){
  750. this.changeAdministrators();
  751. }.bind(this));
  752. if (this.data.controllerList){
  753. this.data.controllerList.each(function(name){
  754. if (name) var admin = new MWF.widget.O2Person({"name": name}, this.administratorsContentNode, {"style": "application"});
  755. }.bind(this));
  756. }
  757. },
  758. changeAdministrators: function(){
  759. var options = {
  760. "type": "person",
  761. "title": "设置应用管理者",
  762. "values": this.data.controllerList || [],
  763. "onComplete": function(items){
  764. this.administratorsContentNode.empty();
  765. var controllerList = [];
  766. items.each(function(item){
  767. controllerList.push(item.data.distinguishedName);
  768. var admin = new MWF.widget.O2Person(item.data, this.administratorsContentNode, {"style": "application"});
  769. }.bind(this));
  770. this.data.controllerList = controllerList;
  771. this.app.restActions.saveApplication(this.data, function(json){
  772. }.bind(this));
  773. }.bind(this)
  774. };
  775. var selector = new MWF.O2Selector(this.app.content, options);
  776. },
  777. createAvailableNode: function(){
  778. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  779. this.availableTitleNode = new Element("div", {
  780. "styles": this.app.css.availableTitleNode,
  781. "text": this.app.lp.application.available
  782. }).inject(this.contentAreaNode);
  783. this.availableContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  784. this.availableItemsContentNode = new Element("div", {"styles": this.app.css.availableItemsContentNode}).inject(this.availableContentNode);
  785. this.availableActionAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  786. var changeIdentityList = new Element("div", {
  787. "styles": this.app.css.selectButtonStyle,
  788. "text": "设置可用身份"
  789. }).inject(this.availableActionAreaNode);
  790. changeIdentityList.addEvent("click", function(){
  791. this.changeAvailableIdentitys();
  792. }.bind(this));
  793. var changeUnitList = new Element("div", {
  794. "styles": this.app.css.selectButtonStyle,
  795. "text": "设置可用组织"
  796. }).inject(this.availableActionAreaNode);
  797. changeUnitList.addEvent("click", function(){
  798. this.changeAvailableUnit();
  799. }.bind(this));
  800. // var changeDepartmentList = new Element("div", {
  801. // "styles": this.app.css.selectButtonStyle,
  802. // "text": "设置可用部门"
  803. // }).inject(this.availableActionAreaNode);
  804. // changeDepartmentList.addEvent("click", function(){
  805. // this.changeAvailableDepartments();
  806. // }.bind(this));
  807. //
  808. // var changeCompanyList = new Element("div", {
  809. // "styles": this.app.css.selectButtonStyle,
  810. // "text": "设置可用公司"
  811. // }).inject(this.availableActionAreaNode);
  812. // changeCompanyList.addEvent("click", function(){
  813. // this.changeAvailableCompanys();
  814. // }.bind(this));
  815. this.setAvailableItems();
  816. },
  817. setAvailableItems: function(){
  818. if (this.data.availableIdentityList){
  819. this.data.availableIdentityList.each(function(name){
  820. if (name) new MWF.widget.O2Identity({"name": name}, this.availableItemsContentNode, {"style": "application"});
  821. }.bind(this));
  822. }
  823. if (this.data.availableUnitList){
  824. this.data.availableUnitList.each(function(name){
  825. if (name) new MWF.widget.O2Unit({"name": name}, this.availableItemsContentNode, {"style": "application"});
  826. }.bind(this));
  827. }
  828. // if (this.data.availableDepartmentList){
  829. // this.data.availableDepartmentList.each(function(name){
  830. // if (name) new MWF.widget.Department({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  831. // }.bind(this));
  832. // }
  833. // if (this.data.availableCompanyList){
  834. // this.data.availableCompanyList.each(function(name){
  835. // if (name) new MWF.widget.Company({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  836. // }.bind(this));
  837. // }
  838. },
  839. changeAvailableIdentitys: function(){
  840. var options = {
  841. "type": "identity",
  842. "title": "设置应用可用身份",
  843. "values": this.data.availableIdentityList || [],
  844. "onComplete": function(items){
  845. var availableIdentityList = [];
  846. items.each(function(item){
  847. availableIdentityList.push(item.data.distinguishedName);
  848. }.bind(this));
  849. this.data.availableIdentityList = availableIdentityList;
  850. this.app.restActions.saveApplication(this.data, function(json){
  851. this.availableItemsContentNode.empty();
  852. this.setAvailableItems();
  853. }.bind(this));
  854. }.bind(this)
  855. };
  856. var selector = new MWF.O2Selector(this.app.content, options);
  857. },
  858. changeAvailableUnit: function(){
  859. var options = {
  860. "type": "unit",
  861. "title": "设置应用可用组织",
  862. "values": this.data.availableUnitList || [],
  863. "onComplete": function(items){
  864. var availableUnitList = [];
  865. items.each(function(item){
  866. availableUnitList.push(item.data.distinguishedName);
  867. }.bind(this));
  868. this.data.availableUnitList = availableUnitList;
  869. this.app.restActions.saveApplication(this.data, function(json){
  870. this.availableItemsContentNode.empty();
  871. this.setAvailableItems();
  872. }.bind(this));
  873. }.bind(this)
  874. };
  875. var selector = new MWF.O2Selector(this.app.content, options);
  876. },
  877. createEditBaseNode: function(){
  878. this.editBaseNode = new Element("button", {
  879. "styles": this.app.css.editBaseNode,
  880. "text": this.app.lp.edit,
  881. "events": {"click": this.editBaseInfor.bind(this)}
  882. }).inject(this.baseActionNode);
  883. },
  884. createCancelBaseNode: function(){
  885. this.cancelBaseNode = new Element("button", {
  886. "styles": this.app.css.cancelBaseNode,
  887. "text": this.app.lp.cancel,
  888. "events": {"click": this.cancelBaseInfor.bind(this)}
  889. }).inject(this.baseActionNode);
  890. },
  891. createSaveBaseNode: function(){
  892. this.saveBaseNode = new Element("button", {
  893. "styles": this.app.css.saveBaseNode,
  894. "text": this.app.lp.save,
  895. "events": {"click": this.saveBaseInfor.bind(this)}
  896. }).inject(this.baseActionNode);
  897. },
  898. editBaseInfor: function(){
  899. this.baseActionNode.empty();
  900. this.editBaseNode = null;
  901. this.createCancelBaseNode();
  902. this.createSaveBaseNode();
  903. this.editMode();
  904. },
  905. editMode: function(){
  906. this.nameInput.editMode();
  907. this.aliasInput.editMode();
  908. this.descriptionInput.editMode();
  909. this.typeInput.editMode();
  910. this.isEdit = true;
  911. },
  912. readMode: function(){
  913. this.nameInput.readMode();
  914. this.aliasInput.readMode();
  915. this.descriptionInput.readMode();
  916. this.typeInput.readMode();
  917. this.isEdit = false;
  918. },
  919. cancelBaseInfor: function(){
  920. if (this.data.name){
  921. this.baseActionNode.empty();
  922. this.cancelBaseNode = null;
  923. this.saveBaseNode = null;
  924. this.createEditBaseNode();
  925. this.readMode();
  926. }else{
  927. this.destroy();
  928. }
  929. },
  930. saveBaseInfor: function(){
  931. if (!this.nameInput.input.get("value")){
  932. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  933. return false;
  934. }
  935. this.node.mask({
  936. "style": {
  937. "opacity": 0.7,
  938. "background-color": "#999"
  939. }
  940. });
  941. this.save(function(){
  942. this.baseActionNode.empty();
  943. this.cancelBaseNode = null;
  944. this.saveBaseNode = null;
  945. this.createEditBaseNode();
  946. this.readMode();
  947. this.node.unmask();
  948. }.bind(this), function(xhr, text, error){
  949. var errorText = error;
  950. if (xhr) errorText = xhr.responseText;
  951. this.app.notice("request json error: "+errorText, "error");
  952. this.node.unmask();
  953. }.bind(this));
  954. },
  955. save: function(callback, cancel){
  956. this.data.name = this.nameInput.input.get("value");
  957. this.data.alias = this.aliasInput.input.get("value");
  958. this.data.description = this.descriptionInput.input.get("value");
  959. this.data.applicationCategory = this.typeInput.input.get("value");
  960. this.app.restActions.saveApplication(this.data, function(json){
  961. this.propertyTitleBar.set("text", this.data.name);
  962. this.data.id = json.data.id;
  963. this.nameInput.save();
  964. this.aliasInput.save();
  965. this.descriptionInput.save();
  966. this.typeInput.save();
  967. if (callback) callback();
  968. }.bind(this), function(xhr, text, error){
  969. if (cancel) cancel(xhr, text, error);
  970. }.bind(this));
  971. }
  972. });
  973. MWF.xApplication.process.ProcessManager.Input = new Class({
  974. Implements: [Events],
  975. initialize: function(node, value, style){
  976. this.node = $(node);
  977. this.value = value || "";
  978. this.style = style;
  979. this.load();
  980. },
  981. load: function(){
  982. this.content = new Element("div", {
  983. "styles": this.style.content,
  984. "text": this.value
  985. }).inject(this.node);
  986. },
  987. editMode: function(){
  988. this.content.empty();
  989. this.input = new Element("input",{
  990. "styles": this.style.input,
  991. "value": this.value
  992. }).inject(this.content);
  993. this.input.addEvents({
  994. "focus": function(){
  995. this.input.setStyles(this.style.input_focus);
  996. }.bind(this),
  997. "blur": function(){
  998. this.input.setStyles(this.style.input);
  999. }.bind(this)
  1000. });
  1001. },
  1002. readMode: function(){
  1003. this.content.empty();
  1004. this.input = null;
  1005. this.content.set("text", this.value);
  1006. },
  1007. save: function(){
  1008. if (this.input) this.value = this.input.get("value");
  1009. return this.value;
  1010. }
  1011. });