Main.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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.options.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. },
  235. applicationProperty: function(){
  236. this.clearContent();
  237. this.propertyConfiguratorContent = new Element("div", {
  238. "styles": this.css.rightContentNode
  239. }).inject(this.node);
  240. this.property = new MWF.xApplication.process.ProcessManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  241. this.property.load();
  242. },
  243. processConfig: function(){
  244. this.clearContent();
  245. this.processConfiguratorContent = new Element("div", {
  246. "styles": this.css.rightContentNode
  247. }).inject(this.node);
  248. this.loadProcessConfig();
  249. },
  250. loadProcessConfig: function(){
  251. MWF.xDesktop.requireApp("process.ProcessManager", "ProcessExplorer", function(){
  252. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  253. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  254. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  255. this.processConfigurator = new MWF.xApplication.process.ProcessManager.ProcessExplorer(this.processConfiguratorContent, this.restActions);
  256. this.processConfigurator.app = this;
  257. this.processConfigurator.load();
  258. //}.bind(this));
  259. }.bind(this));
  260. },
  261. formConfig: function(){
  262. this.clearContent();
  263. this.formConfiguratorContent = new Element("div", {
  264. "styles": this.css.rightContentNode
  265. }).inject(this.node);
  266. this.loadFormConfig();
  267. },
  268. loadFormConfig: function(){
  269. MWF.xDesktop.requireApp("process.ProcessManager", "FormExplorer", function(){
  270. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  271. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  272. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  273. this.formConfigurator = new MWF.xApplication.process.ProcessManager.FormExplorer(this.formConfiguratorContent, this.restActions);
  274. this.formConfigurator.app = this;
  275. this.formConfigurator.load();
  276. //}.bind(this));
  277. }.bind(this));
  278. },
  279. viewConfig: function(){
  280. this.clearContent();
  281. this.viewConfiguratorContent = new Element("div", {
  282. "styles": this.css.rightContentNode
  283. }).inject(this.node);
  284. this.loadViewConfig();
  285. },
  286. loadViewConfig: function(){
  287. MWF.xDesktop.requireApp("process.ProcessManager", "ViewExplorer", function(){
  288. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  289. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  290. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  291. this.viewConfigurator = new MWF.xApplication.process.ProcessManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  292. this.viewConfigurator.app = this;
  293. this.viewConfigurator.load();
  294. //}.bind(this));
  295. }.bind(this));
  296. },
  297. statConfig: function(){
  298. this.clearContent();
  299. this.statConfiguratorContent = new Element("div", {
  300. "styles": this.css.rightContentNode
  301. }).inject(this.node);
  302. this.loadStatConfig();
  303. },
  304. loadStatConfig: function(){
  305. MWF.xDesktop.requireApp("process.ProcessManager", "StatExplorer", function(){
  306. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  307. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  308. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  309. this.statConfigurator = new MWF.xApplication.process.ProcessManager.StatExplorer(this.statConfiguratorContent, this.restActions);
  310. this.statConfigurator.app = this;
  311. this.statConfigurator.load();
  312. //}.bind(this));
  313. }.bind(this));
  314. },
  315. dataConfig: function(){
  316. this.clearContent();
  317. this.dataConfiguratorContent = new Element("div", {
  318. "styles": this.css.rightContentNode
  319. }).inject(this.node);
  320. this.loadDataConfig();
  321. },
  322. loadDataConfig: function(){
  323. MWF.xDesktop.requireApp("process.ProcessManager", "DictionaryExplorer", function(){
  324. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  325. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  326. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  327. this.dataConfigurator = new MWF.xApplication.process.ProcessManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions);
  328. this.dataConfigurator.app = this;
  329. this.dataConfigurator.load();
  330. //}.bind(this));
  331. }.bind(this));
  332. },
  333. scriptConfig: function(){
  334. this.clearContent();
  335. this.scriptConfiguratorContent = new Element("div", {
  336. "styles": this.css.rightContentNode
  337. }).inject(this.node);
  338. this.loadScriptConfig();
  339. },
  340. loadScriptConfig: function(){
  341. MWF.xDesktop.requireApp("process.ProcessManager", "ScriptExplorer", function(){
  342. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  343. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  344. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  345. this.scriptConfigurator = new MWF.xApplication.process.ProcessManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  346. this.scriptConfigurator.app = this;
  347. this.scriptConfigurator.load();
  348. //}.bind(this));
  349. }.bind(this));
  350. },
  351. fileConfig: function(){
  352. this.clearContent();
  353. this.fileConfiguratorContent = new Element("div", {
  354. "styles": this.css.rightContentNode
  355. }).inject(this.node);
  356. this.loadFileConfig();
  357. },
  358. loadFileConfig: function(){
  359. MWF.xDesktop.requireApp("process.ProcessManager", "FileExplorer", function(){
  360. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  361. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  362. this.restActions = MWF.Actions.get("x_processplatform_assemble_designer");
  363. this.fileConfigurator = new MWF.xApplication.process.ProcessManager.FileExplorer(this.fileConfiguratorContent, this.restActions);
  364. this.fileConfigurator.app = this;
  365. this.fileConfigurator.load();
  366. //}.bind(this));
  367. }.bind(this));
  368. },
  369. getCategoryCount: function(){
  370. var size = this.processConfiguratorContent.getSize();
  371. categoryCount = parseInt(size.x/182)+5;
  372. return categoryCount;
  373. },
  374. getProcessCount: function(){
  375. if (this.processConfigurator){
  376. var size = this.processConfigurator.processNode.getSize();
  377. processCount = (parseInt(size.x/401)*parseInt(size.y/101))+10;
  378. return processCount;
  379. }
  380. return 20;
  381. },
  382. showContentNode: function(node){
  383. if (this.currentContentNode){
  384. // this.currentContentNode.setStyles({
  385. // "position": "absolute"
  386. // });
  387. this.currentContentNode.fade("hide");
  388. node.fade("show");
  389. node.setStyle("display", "node");
  390. this.currentContentNode = null;
  391. }
  392. node.setStyle("display", "block");
  393. node.fade("show");
  394. this.currentContentNode = node;
  395. },
  396. recordStatus: function(){
  397. var idx = null;
  398. if (this.menu.currentNavi){
  399. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  400. }
  401. return {"navi": idx, "application": this.options.application.id};
  402. }
  403. // onResize: function(){
  404. // if (this.menu) this.menu.onResize();
  405. // }
  406. });
  407. MWF.xApplication.process.ProcessManager.Menu = new Class({
  408. Implements: [Options, Events],
  409. initialize: function(app, node, options){
  410. this.setOptions(options);
  411. this.app = app;
  412. this.node = $(node);
  413. this.currentNavi = null;
  414. this.status = "start";
  415. this.startNavis = [];
  416. this.load();
  417. },
  418. load: function(){
  419. var menuUrl = this.app.path+"startMenu.json";
  420. MWF.getJSON(menuUrl, function(json){
  421. json.each(function(navi){
  422. var naviNode = new Element("div", {
  423. "styles": this.app.css.startMenuNaviNode
  424. });
  425. naviNode.store("naviData", navi);
  426. var iconNode = new Element("div", {
  427. "styles": this.app.css.startMenuIconNode
  428. }).inject(naviNode);
  429. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  430. var textNode = new Element("div", {
  431. "styles": this.app.css.startMenuTextNode,
  432. "text": navi.title
  433. });
  434. textNode.inject(naviNode);
  435. naviNode.inject(this.node);
  436. this.startNavis.push(naviNode);
  437. this.setStartNaviEvent(naviNode, navi);
  438. this.setNodeCenter(this.node);
  439. }.bind(this));
  440. this.setStartMenuWidth();
  441. this.fireEvent("postLoad");
  442. }.bind(this));
  443. },
  444. setStartNaviEvent: function(naviNode){
  445. var _self = this;
  446. naviNode.addEvents({
  447. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  448. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  449. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  450. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  451. "click": function(){
  452. //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
  453. _self.doAction.apply(_self, [this]);
  454. }
  455. });
  456. },
  457. doAction: function(naviNode){
  458. var navi = naviNode.retrieve("naviData");
  459. var action = navi.action;
  460. if (this.currentNavi) this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  461. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  462. this.currentNavi = naviNode;
  463. if (this.app[action]) this.app[action].apply(this.app);
  464. if (this.status == "start"){
  465. this.toNormal();
  466. this.status = "normal";
  467. }
  468. },
  469. toNormal: function(){
  470. // var size = this.getStartMenuNormalSize();
  471. var css = this.app.css.normalStartMenuNode;
  472. //css.height = size.height+"px";
  473. // css.height = "100%";
  474. // css.width = size.width+"px";
  475. //// this.node.setStyles(css);
  476. //
  477. if (!this.morph){
  478. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  479. }
  480. // this.morph.start(css).chain(function(){
  481. this.node.setStyles(css);
  482. MWF.require("MWF.widget.ScrollBar", function(){
  483. new MWF.widget.ScrollBar(this.node, {
  484. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  485. });
  486. }.bind(this));
  487. // }.bind(this));
  488. //
  489. //// this.node.setStyles(css);
  490. ////
  491. //// this.startNavis.each(function(naviNode){
  492. //// if (this.currentNavi!=naviNode) naviNode.setStyles(this.app.css.startMenuNaviNode);
  493. //// }.bind(this));
  494. //
  495. // this.node.set("morph", {duration: 50});
  496. // this.node.morph(css);
  497. },
  498. setNodeCenter: function(node){
  499. var size = node.getSize();
  500. var contentSize = this.app.node.getSize();
  501. var top = contentSize.y/2 - size.y/2;
  502. var left = contentSize.x/2 - size.x/2;
  503. if (left<0) left = 0;
  504. if (top<0) top = 0;
  505. node.setStyles({"left": left, "top": top});
  506. },
  507. getStartMenuNormalSize: function(){
  508. var naviItemNode = this.node.getFirst();
  509. var size = naviItemNode.getComputedSize();
  510. var mt = naviItemNode.getStyle("margin-top").toFloat();
  511. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  512. var height = size.totalWidth+mt+mb;
  513. var ml = naviItemNode.getStyle("margin-left").toFloat();
  514. var mr = naviItemNode.getStyle("margin-right").toFloat();
  515. var width = size.totalWidth+ml+mr;
  516. return {"width": width, "height": height*this.startNavis.length};
  517. },
  518. setStartMenuWidth: function(){
  519. var naviItemNode = this.node.getFirst();
  520. var size = naviItemNode.getComputedSize();
  521. var ml = naviItemNode.getStyle("margin-left").toFloat();
  522. var mr = naviItemNode.getStyle("margin-right").toFloat();
  523. var width = size.totalWidth+ml+mr;
  524. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  525. },
  526. onResize: function(){
  527. if (this.status == "start"){
  528. this.setNodeCenter(this.node);
  529. }
  530. }
  531. });
  532. MWF.xApplication.process.ProcessManager.ApplicationProperty = new Class({
  533. initialize: function(app, node){
  534. this.app = app;
  535. this.node = $(node);
  536. this.data = this.app.options.application;
  537. },
  538. load: function(){
  539. this.app.restActions.getApplication(this.app.options.application.id, function(json){
  540. this.data = json.data;
  541. this.propertyTitleBar = new Element("div", {
  542. "styles": this.app.css.propertyTitleBar,
  543. "text": this.data.name
  544. }).inject(this.node);
  545. this.contentNode = new Element("div", {
  546. "styles": this.app.css.propertyContentNode
  547. }).inject(this.node);
  548. this.contentAreaNode = new Element("div", {
  549. "styles": this.app.css.propertyContentAreaNode
  550. }).inject(this.contentNode);
  551. this.setContentHeight();
  552. this.setContentHeightFun = this.setContentHeight.bind(this);
  553. this.app.addEvent("resize", this.setContentHeightFun);
  554. MWF.require("MWF.widget.ScrollBar", function(){
  555. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  556. }.bind(this));
  557. this.baseActionAreaNode = new Element("div", {
  558. "styles": this.app.css.baseActionAreaNode
  559. }).inject(this.contentAreaNode);
  560. this.baseActionNode = new Element("div", {
  561. "styles": this.app.css.propertyInforActionNode
  562. }).inject(this.baseActionAreaNode);
  563. this.baseTextNode = new Element("div", {
  564. "styles": this.app.css.baseTextNode,
  565. "text": this.app.lp.application.property
  566. }).inject(this.baseActionAreaNode);
  567. this.createEditBaseNode();
  568. this.createPropertyContentNode();
  569. this.createIconContentNode();
  570. this.createAvailableNode();
  571. this.createControllerListNode();
  572. }.bind(this));
  573. },
  574. setContentHeight: function(){
  575. var size = this.app.content.getSize();
  576. var titleSize = this.propertyTitleBar.getSize();
  577. var y = size.y-titleSize.y;
  578. this.contentNode.setStyle("height", ""+y+"px");
  579. },
  580. createIconContentNode: function(){
  581. this.iconContentTitleNode = new Element("div", {
  582. "styles": this.app.css.iconContentTitleNode,
  583. "text": this.app.lp.application.icon
  584. }).inject(this.contentAreaNode);
  585. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  586. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  587. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  588. html += "</table>";
  589. this.iconContentNode.set("html", html);
  590. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  591. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  592. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  593. this.iconPreviewNode.setStyles({
  594. "height": "72px",
  595. "width": "72px",
  596. "float": "right"
  597. });
  598. if (this.data.icon){
  599. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  600. }else{
  601. //this.iconPreviewNode.setStyle("background", "url("+"/x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  602. this.iconPreviewNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/application.png) center center no-repeat")
  603. }
  604. var changeIconAction = new Element("div", {
  605. "styles": {
  606. "margin-left": "20px",
  607. "float": "left",
  608. "background-color": "#FFF",
  609. "padding": "4px 14px",
  610. "border": "1px solid #999",
  611. "border-radius": "3px",
  612. "margin-top": "10px",
  613. "font-size": "14px",
  614. "color": "#666",
  615. "cursor": "pointer"
  616. },
  617. "text": "更改图标"
  618. }).inject(this.iconActionNode);
  619. changeIconAction.addEvent("click", function(){
  620. this.changeIcon();
  621. }.bind(this));
  622. },
  623. changeIcon: function(){
  624. MWF.require("MWF.widget.Upload", function(){
  625. var upload = new MWF.widget.Upload(this.app.content, {
  626. "data": null,
  627. "parameter": {"id": this.data.id},
  628. "action": this.app.restActions.action,
  629. "method": "updateApplicationIcon",
  630. "onCompleted": function(json){
  631. this.app.restActions.getApplication(this.data.id, function(json){
  632. if (json.data){
  633. this.data = json.data;
  634. if (this.data.icon){
  635. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  636. }else{
  637. this.iconPreviewNode.setStyle("background", "url("+"/x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  638. }
  639. }
  640. }.bind(this), false)
  641. }.bind(this)
  642. });
  643. upload.load();
  644. }.bind(this));
  645. },
  646. changeIcon_1: function(){
  647. if (!this.uploadFileAreaNode){
  648. this.uploadFileAreaNode = new Element("div");
  649. var html = "<input name=\"file\" type=\"file\"/>";
  650. this.uploadFileAreaNode.set("html", html);
  651. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  652. this.fileUploadNode.addEvent("change", function(){
  653. var files = fileNode.files;
  654. if (files.length){
  655. for (var i = 0; i < files.length; i++) {
  656. var file = files.item(i);
  657. var formData = new FormData();
  658. formData.append('file', file);
  659. //formData.append('name', file.name);
  660. //formData.append('folder', folderId);
  661. this.app.restActions.changeApplicationIcon(this.data.id ,function(){
  662. this.app.restActions.getApplication(this.data.id, function(json){
  663. if (json.data){
  664. this.data = json.data;
  665. if (this.data.icon){
  666. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  667. }else{
  668. this.iconPreviewNode.setStyle("background", "url("+"/x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  669. }
  670. }
  671. }.bind(this), false)
  672. }.bind(this), null, formData, file);
  673. }
  674. }
  675. }.bind(this));
  676. }
  677. var fileNode = this.uploadFileAreaNode.getFirst();
  678. fileNode.click();
  679. },
  680. createPropertyContentNode: function(){
  681. this.propertyContentNode = new Element("div", {"styles": {
  682. "overflow": "hidden",
  683. "-webkit-user-select": "text",
  684. "-moz-user-select": "text"
  685. }}).inject(this.contentAreaNode);
  686. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  687. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  688. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  689. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  690. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  691. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  692. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  693. html += "</table>";
  694. this.propertyContentNode.set("html", html);
  695. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  696. this.nameInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  697. this.aliasInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  698. this.descriptionInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  699. this.typeInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  700. this.idInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  701. },
  702. createControllerListNode: function(){
  703. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  704. this.controllerListTitleNode = new Element("div", {
  705. "styles": this.app.css.controllerListTitleNode,
  706. "text": this.app.lp.application.controllerList
  707. }).inject(this.contentAreaNode);
  708. this.controllerListContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  709. this.administratorsContentNode = new Element("div", {"styles": this.app.css.administratorsContentNode}).inject(this.controllerListContentNode);
  710. var changeAdministrators = new Element("div", {
  711. "styles": {
  712. "margin-left": "40px",
  713. "float": "left",
  714. "background-color": "#FFF",
  715. "padding": "4px 14px",
  716. "border": "1px solid #999",
  717. "border-radius": "3px",
  718. "margin-top": "10px",
  719. "margin-bottom": "20px",
  720. "font-size": "14px",
  721. "color": "#666",
  722. "cursor": "pointer"
  723. },
  724. "text": "设置管理者"
  725. }).inject(this.contentAreaNode);
  726. changeAdministrators.addEvent("click", function(){
  727. this.changeAdministrators();
  728. }.bind(this));
  729. if (this.data.controllerList){
  730. this.data.controllerList.each(function(name){
  731. if (name) var admin = new MWF.widget.O2Person({"name": name}, this.administratorsContentNode, {"style": "application"});
  732. }.bind(this));
  733. }
  734. },
  735. changeAdministrators: function(){
  736. var options = {
  737. "type": "person",
  738. "title": "设置应用管理者",
  739. "values": this.data.controllerList || [],
  740. "onComplete": function(items){
  741. this.administratorsContentNode.empty();
  742. var controllerList = [];
  743. items.each(function(item){
  744. controllerList.push(item.data.distinguishedName);
  745. var admin = new MWF.widget.O2Person(item.data, this.administratorsContentNode, {"style": "application"});
  746. }.bind(this));
  747. this.data.controllerList = controllerList;
  748. this.app.restActions.saveApplication(this.data, function(json){
  749. }.bind(this));
  750. }.bind(this)
  751. };
  752. var selector = new MWF.O2Selector(this.app.content, options);
  753. },
  754. createAvailableNode: function(){
  755. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  756. this.availableTitleNode = new Element("div", {
  757. "styles": this.app.css.availableTitleNode,
  758. "text": this.app.lp.application.available
  759. }).inject(this.contentAreaNode);
  760. this.availableContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  761. this.availableItemsContentNode = new Element("div", {"styles": this.app.css.availableItemsContentNode}).inject(this.availableContentNode);
  762. this.availableActionAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  763. var changeIdentityList = new Element("div", {
  764. "styles": this.app.css.selectButtonStyle,
  765. "text": "设置可用身份"
  766. }).inject(this.availableActionAreaNode);
  767. changeIdentityList.addEvent("click", function(){
  768. this.changeAvailableIdentitys();
  769. }.bind(this));
  770. var changeUnitList = new Element("div", {
  771. "styles": this.app.css.selectButtonStyle,
  772. "text": "设置可用组织"
  773. }).inject(this.availableActionAreaNode);
  774. changeUnitList.addEvent("click", function(){
  775. this.changeAvailableUnit();
  776. }.bind(this));
  777. // var changeDepartmentList = new Element("div", {
  778. // "styles": this.app.css.selectButtonStyle,
  779. // "text": "设置可用部门"
  780. // }).inject(this.availableActionAreaNode);
  781. // changeDepartmentList.addEvent("click", function(){
  782. // this.changeAvailableDepartments();
  783. // }.bind(this));
  784. //
  785. // var changeCompanyList = new Element("div", {
  786. // "styles": this.app.css.selectButtonStyle,
  787. // "text": "设置可用公司"
  788. // }).inject(this.availableActionAreaNode);
  789. // changeCompanyList.addEvent("click", function(){
  790. // this.changeAvailableCompanys();
  791. // }.bind(this));
  792. this.setAvailableItems();
  793. },
  794. setAvailableItems: function(){
  795. if (this.data.availableIdentityList){
  796. this.data.availableIdentityList.each(function(name){
  797. if (name) new MWF.widget.O2Identity({"name": name}, this.availableItemsContentNode, {"style": "application"});
  798. }.bind(this));
  799. }
  800. if (this.data.availableUnitList){
  801. this.data.availableUnitList.each(function(name){
  802. if (name) new MWF.widget.O2Unit({"name": name}, this.availableItemsContentNode, {"style": "application"});
  803. }.bind(this));
  804. }
  805. // if (this.data.availableDepartmentList){
  806. // this.data.availableDepartmentList.each(function(name){
  807. // if (name) new MWF.widget.Department({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  808. // }.bind(this));
  809. // }
  810. // if (this.data.availableCompanyList){
  811. // this.data.availableCompanyList.each(function(name){
  812. // if (name) new MWF.widget.Company({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  813. // }.bind(this));
  814. // }
  815. },
  816. changeAvailableIdentitys: function(){
  817. var options = {
  818. "type": "identity",
  819. "title": "设置应用可用身份",
  820. "values": this.data.availableIdentityList || [],
  821. "onComplete": function(items){
  822. var availableIdentityList = [];
  823. items.each(function(item){
  824. availableIdentityList.push(item.data.distinguishedName);
  825. }.bind(this));
  826. this.data.availableIdentityList = availableIdentityList;
  827. this.app.restActions.saveApplication(this.data, function(json){
  828. this.availableItemsContentNode.empty();
  829. this.setAvailableItems();
  830. }.bind(this));
  831. }.bind(this)
  832. };
  833. var selector = new MWF.O2Selector(this.app.content, options);
  834. },
  835. changeAvailableUnit: function(){
  836. var options = {
  837. "type": "unit",
  838. "title": "设置应用可用组织",
  839. "values": this.data.availableUnitList || [],
  840. "onComplete": function(items){
  841. var availableUnitList = [];
  842. items.each(function(item){
  843. availableUnitList.push(item.data.distinguishedName);
  844. }.bind(this));
  845. this.data.availableUnitList = availableUnitList;
  846. this.app.restActions.saveApplication(this.data, function(json){
  847. this.availableItemsContentNode.empty();
  848. this.setAvailableItems();
  849. }.bind(this));
  850. }.bind(this)
  851. };
  852. var selector = new MWF.O2Selector(this.app.content, options);
  853. },
  854. createEditBaseNode: function(){
  855. this.editBaseNode = new Element("button", {
  856. "styles": this.app.css.editBaseNode,
  857. "text": this.app.lp.edit,
  858. "events": {"click": this.editBaseInfor.bind(this)}
  859. }).inject(this.baseActionNode);
  860. },
  861. createCancelBaseNode: function(){
  862. this.cancelBaseNode = new Element("button", {
  863. "styles": this.app.css.cancelBaseNode,
  864. "text": this.app.lp.cancel,
  865. "events": {"click": this.cancelBaseInfor.bind(this)}
  866. }).inject(this.baseActionNode);
  867. },
  868. createSaveBaseNode: function(){
  869. this.saveBaseNode = new Element("button", {
  870. "styles": this.app.css.saveBaseNode,
  871. "text": this.app.lp.save,
  872. "events": {"click": this.saveBaseInfor.bind(this)}
  873. }).inject(this.baseActionNode);
  874. },
  875. editBaseInfor: function(){
  876. this.baseActionNode.empty();
  877. this.editBaseNode = null;
  878. this.createCancelBaseNode();
  879. this.createSaveBaseNode();
  880. this.editMode();
  881. },
  882. editMode: function(){
  883. this.nameInput.editMode();
  884. this.aliasInput.editMode();
  885. this.descriptionInput.editMode();
  886. this.typeInput.editMode();
  887. this.isEdit = true;
  888. },
  889. readMode: function(){
  890. this.nameInput.readMode();
  891. this.aliasInput.readMode();
  892. this.descriptionInput.readMode();
  893. this.typeInput.readMode();
  894. this.isEdit = false;
  895. },
  896. cancelBaseInfor: function(){
  897. if (this.data.name){
  898. this.baseActionNode.empty();
  899. this.cancelBaseNode = null;
  900. this.saveBaseNode = null;
  901. this.createEditBaseNode();
  902. this.readMode();
  903. }else{
  904. this.destroy();
  905. }
  906. },
  907. saveBaseInfor: function(){
  908. if (!this.nameInput.input.get("value")){
  909. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  910. return false;
  911. }
  912. this.node.mask({
  913. "style": {
  914. "opacity": 0.7,
  915. "background-color": "#999"
  916. }
  917. });
  918. this.save(function(){
  919. this.baseActionNode.empty();
  920. this.cancelBaseNode = null;
  921. this.saveBaseNode = null;
  922. this.createEditBaseNode();
  923. this.readMode();
  924. this.node.unmask();
  925. }.bind(this), function(xhr, text, error){
  926. var errorText = error;
  927. if (xhr) errorText = xhr.responseText;
  928. this.app.notice("request json error: "+errorText, "error");
  929. this.node.unmask();
  930. }.bind(this));
  931. },
  932. save: function(callback, cancel){
  933. this.data.name = this.nameInput.input.get("value");
  934. this.data.alias = this.aliasInput.input.get("value");
  935. this.data.description = this.descriptionInput.input.get("value");
  936. this.data.applicationCategory = this.typeInput.input.get("value");
  937. this.app.restActions.saveApplication(this.data, function(json){
  938. this.propertyTitleBar.set("text", this.data.name);
  939. this.data.id = json.data.id;
  940. this.nameInput.save();
  941. this.aliasInput.save();
  942. this.descriptionInput.save();
  943. this.typeInput.save();
  944. if (callback) callback();
  945. }.bind(this), function(xhr, text, error){
  946. if (cancel) cancel(xhr, text, error);
  947. }.bind(this));
  948. }
  949. });
  950. MWF.xApplication.process.ProcessManager.Input = new Class({
  951. Implements: [Events],
  952. initialize: function(node, value, style){
  953. this.node = $(node);
  954. this.value = value || "";
  955. this.style = style;
  956. this.load();
  957. },
  958. load: function(){
  959. this.content = new Element("div", {
  960. "styles": this.style.content,
  961. "text": this.value
  962. }).inject(this.node);
  963. },
  964. editMode: function(){
  965. this.content.empty();
  966. this.input = new Element("input",{
  967. "styles": this.style.input,
  968. "value": this.value
  969. }).inject(this.content);
  970. this.input.addEvents({
  971. "focus": function(){
  972. this.input.setStyles(this.style.input_focus);
  973. }.bind(this),
  974. "blur": function(){
  975. this.input.setStyles(this.style.input);
  976. }.bind(this)
  977. });
  978. },
  979. readMode: function(){
  980. this.content.empty();
  981. this.input = null;
  982. this.content.set("text", this.value);
  983. },
  984. save: function(){
  985. if (this.input) this.value = this.input.get("value");
  986. return this.value;
  987. }
  988. });