Main.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  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. this.createMaintainerNode();
  596. }.bind(this));
  597. },
  598. setContentHeight: function(){
  599. var size = this.app.content.getSize();
  600. var titleSize = this.propertyTitleBar.getSize();
  601. var y = size.y-titleSize.y;
  602. this.contentNode.setStyle("height", ""+y+"px");
  603. },
  604. createIconContentNode: function(){
  605. this.iconContentTitleNode = new Element("div", {
  606. "styles": this.app.css.iconContentTitleNode,
  607. "text": this.app.lp.application.icon
  608. }).inject(this.contentAreaNode);
  609. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  610. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  611. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  612. html += "</table>";
  613. this.iconContentNode.set("html", html);
  614. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  615. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  616. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  617. this.iconPreviewNode.setStyles({
  618. "height": "72px",
  619. "width": "72px",
  620. "float": "right"
  621. });
  622. if (this.data.icon){
  623. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  624. }else{
  625. //this.iconPreviewNode.setStyle("background", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  626. this.iconPreviewNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/application.png) center center no-repeat")
  627. }
  628. var changeIconAction = new Element("div", {
  629. "styles": {
  630. "margin-left": "20px",
  631. "float": "left",
  632. "background-color": "#FFF",
  633. "padding": "4px 14px",
  634. "border": "1px solid #999",
  635. "border-radius": "3px",
  636. "margin-top": "10px",
  637. "font-size": "14px",
  638. "color": "#666",
  639. "cursor": "pointer"
  640. },
  641. "text": this.app.lp.application.changeIcon
  642. }).inject(this.iconActionNode);
  643. changeIconAction.addEvent("click", function(){
  644. this.changeIcon();
  645. }.bind(this));
  646. },
  647. changeIcon: function(){
  648. MWF.require("MWF.widget.Upload", function(){
  649. var upload = new MWF.widget.Upload(this.app.content, {
  650. "data": null,
  651. "parameter": {"id": this.data.id},
  652. "action": this.app.restActions.action,
  653. "method": "updateApplicationIcon",
  654. "onCompleted": function(json){
  655. this.app.restActions.getApplication(this.data.id, function(json){
  656. if (json.data){
  657. this.data = json.data;
  658. if (this.data.icon){
  659. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  660. }else{
  661. this.iconPreviewNode.setStyle("background", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  662. }
  663. }
  664. }.bind(this), false)
  665. }.bind(this)
  666. });
  667. upload.load();
  668. }.bind(this));
  669. },
  670. changeIcon_1: function(){
  671. if (!this.uploadFileAreaNode){
  672. this.uploadFileAreaNode = new Element("div");
  673. var html = "<input name=\"file\" type=\"file\"/>";
  674. this.uploadFileAreaNode.set("html", html);
  675. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  676. this.fileUploadNode.addEvent("change", function(){
  677. var files = fileNode.files;
  678. if (files.length){
  679. for (var i = 0; i < files.length; i++) {
  680. var file = files.item(i);
  681. var formData = new FormData();
  682. formData.append('file', file);
  683. //formData.append('name', file.name);
  684. //formData.append('folder', folderId);
  685. this.app.restActions.changeApplicationIcon(this.data.id ,function(){
  686. this.app.restActions.getApplication(this.data.id, function(json){
  687. if (json.data){
  688. this.data = json.data;
  689. if (this.data.icon){
  690. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.icon+") center center no-repeat");
  691. }else{
  692. this.iconPreviewNode.setStyle("background", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png) center center no-repeat")
  693. }
  694. }
  695. }.bind(this), false)
  696. }.bind(this), null, formData, file);
  697. }
  698. }
  699. }.bind(this));
  700. }
  701. var fileNode = this.uploadFileAreaNode.getFirst();
  702. fileNode.click();
  703. },
  704. createPropertyContentNode: function(){
  705. this.propertyContentNode = new Element("div", {"styles": {
  706. "overflow": "hidden",
  707. "-webkit-user-select": "text",
  708. "-moz-user-select": "text"
  709. }}).inject(this.contentAreaNode);
  710. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  711. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  712. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  713. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  714. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  715. html += "<tr><td class='formTitle'>"+this.app.lp.application.defaultForm+"</td><td id='formApplicationDefaultForm'></td></tr>";
  716. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  717. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  718. html += "</table>";
  719. this.propertyContentNode.set("html", html);
  720. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  721. this.nameInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  722. this.aliasInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  723. this.descriptionInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  724. this.typeInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  725. this.idInput = new MWF.xApplication.process.ProcessManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  726. this.defaultFormInput = new MWF.xApplication.process.ProcessManager.Select(this.propertyContentNode.getElement("#formApplicationDefaultForm"), this.data.defaultForm, this.app.css.formInput, function(){
  727. var pages = {};
  728. this.app.restActions.listForm(this.app.options.application.id, function(json){
  729. json.data.each(function(page) {
  730. pages[page.id] = page.name;
  731. }.bind(this));
  732. }.bind(this), null, false);
  733. return pages;
  734. }.bind(this));
  735. },
  736. createControllerListNode: function(){
  737. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  738. this.controllerListTitleNode = new Element("div", {
  739. "styles": this.app.css.controllerListTitleNode,
  740. "text": this.app.lp.application.controllerList
  741. }).inject(this.contentAreaNode);
  742. this.controllerListContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  743. this.administratorsContentNode = new Element("div", {"styles": this.app.css.administratorsContentNode}).inject(this.controllerListContentNode);
  744. var changeAdministrators = new Element("div", {
  745. "styles": {
  746. "margin-left": "40px",
  747. "float": "left",
  748. "background-color": "#FFF",
  749. "padding": "4px 14px",
  750. "border": "1px solid #999",
  751. "border-radius": "3px",
  752. "margin-top": "10px",
  753. "margin-bottom": "20px",
  754. "font-size": "14px",
  755. "color": "#666",
  756. "cursor": "pointer"
  757. },
  758. "text": this.app.lp.application.setManager //"设置管理者"
  759. }).inject(this.contentAreaNode);
  760. changeAdministrators.addEvent("click", function(){
  761. this.changeAdministrators();
  762. }.bind(this));
  763. if (this.data.controllerList){
  764. this.data.controllerList.each(function(name){
  765. if (name) var admin = new MWF.widget.O2Person({"name": name}, this.administratorsContentNode, {"style": "application"});
  766. }.bind(this));
  767. }
  768. },
  769. createMaintainerNode: function(){
  770. this.maintainerTitleNode = new Element("div", {
  771. "styles": this.app.css.controllerListTitleNode,
  772. "text": this.app.lp.application.maintenanceIdentity
  773. }).inject(this.contentAreaNode);
  774. this.maintainerContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  775. this.maintainerContentAreaNode = new Element("div", {"styles": this.app.css.administratorsContentNode}).inject(this.maintainerContentNode);
  776. var changeMaintainer = new Element("div", {
  777. "styles": {
  778. "margin-left": "40px",
  779. "float": "left",
  780. "background-color": "#FFF",
  781. "padding": "4px 14px",
  782. "border": "1px solid #999",
  783. "border-radius": "3px",
  784. "margin-top": "10px",
  785. "margin-bottom": "20px",
  786. "font-size": "14px",
  787. "color": "#666",
  788. "cursor": "pointer"
  789. },
  790. "text": this.app.lp.application.setMaintainer //"设置管理者"
  791. }).inject(this.contentAreaNode);
  792. changeMaintainer.addEvent("click", function(){
  793. this.changeMaintainer();
  794. }.bind(this));
  795. if (this.data.maintenanceIdentity){
  796. new MWF.widget.O2Identity({"name": this.data.maintenanceIdentity}, this.maintainerContentAreaNode, {"style": "application"});
  797. }
  798. },
  799. changeAdministrators: function(){
  800. var options = {
  801. "type": "person",
  802. "title": this.app.lp.application.setAppManager,
  803. "values": this.data.controllerList || [],
  804. "onComplete": function(items){
  805. this.administratorsContentNode.empty();
  806. var controllerList = [];
  807. items.each(function(item){
  808. controllerList.push(item.data.distinguishedName);
  809. var admin = new MWF.widget.O2Person(item.data, this.administratorsContentNode, {"style": "application"});
  810. }.bind(this));
  811. this.data.controllerList = controllerList;
  812. this.app.restActions.saveApplication(this.data, function(json){
  813. }.bind(this));
  814. }.bind(this)
  815. };
  816. var selector = new MWF.O2Selector(this.app.content, options);
  817. },
  818. changeMaintainer: function(){
  819. var options = {
  820. "type": "identity",
  821. "count": 1,
  822. "title": this.app.lp.application.setMaintainer,
  823. "values": [this.data.maintenanceIdentity],
  824. "onComplete": function(items){
  825. this.maintainerContentAreaNode.empty();
  826. if (items && items.length){
  827. var item = items[0];
  828. this.data.maintenanceIdentity = item.data.distinguishedName;
  829. var admin = new MWF.widget.O2Identity(item.data, this.maintainerContentAreaNode, {"style": "application"});
  830. }else{
  831. this.data.maintenanceIdentity = "";
  832. }
  833. this.app.restActions.saveApplication(this.data, function(json){
  834. }.bind(this));
  835. }.bind(this)
  836. };
  837. var selector = new MWF.O2Selector(this.app.content, options);
  838. },
  839. createAvailableNode: function(){
  840. //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  841. this.availableTitleNode = new Element("div", {
  842. "styles": this.app.css.availableTitleNode,
  843. "text": this.app.lp.application.available
  844. }).inject(this.contentAreaNode);
  845. this.availableContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  846. this.availableItemsContentNode = new Element("div", {"styles": this.app.css.availableItemsContentNode}).inject(this.availableContentNode);
  847. this.availableActionAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  848. var changeIdentityList = new Element("div", {
  849. "styles": this.app.css.selectButtonStyle,
  850. "text": this.app.lp.application.setUsableIdentity
  851. }).inject(this.availableActionAreaNode);
  852. changeIdentityList.addEvent("click", function(){
  853. this.changeAvailableIdentitys();
  854. }.bind(this));
  855. var changeUnitList = new Element("div", {
  856. "styles": this.app.css.selectButtonStyle,
  857. "text": this.app.lp.application.setUsableUnit
  858. }).inject(this.availableActionAreaNode);
  859. changeUnitList.addEvent("click", function(){
  860. this.changeAvailableUnit();
  861. }.bind(this));
  862. // var changeDepartmentList = new Element("div", {
  863. // "styles": this.app.css.selectButtonStyle,
  864. // "text": "设置可用部门"
  865. // }).inject(this.availableActionAreaNode);
  866. // changeDepartmentList.addEvent("click", function(){
  867. // this.changeAvailableDepartments();
  868. // }.bind(this));
  869. //
  870. // var changeCompanyList = new Element("div", {
  871. // "styles": this.app.css.selectButtonStyle,
  872. // "text": "设置可用公司"
  873. // }).inject(this.availableActionAreaNode);
  874. // changeCompanyList.addEvent("click", function(){
  875. // this.changeAvailableCompanys();
  876. // }.bind(this));
  877. this.setAvailableItems();
  878. },
  879. setAvailableItems: function(){
  880. if (this.data.availableIdentityList){
  881. this.data.availableIdentityList.each(function(name){
  882. if (name) new MWF.widget.O2Identity({"name": name}, this.availableItemsContentNode, {"style": "application"});
  883. }.bind(this));
  884. }
  885. if (this.data.availableUnitList){
  886. this.data.availableUnitList.each(function(name){
  887. if (name) new MWF.widget.O2Unit({"name": name}, this.availableItemsContentNode, {"style": "application"});
  888. }.bind(this));
  889. }
  890. // if (this.data.availableDepartmentList){
  891. // this.data.availableDepartmentList.each(function(name){
  892. // if (name) new MWF.widget.Department({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  893. // }.bind(this));
  894. // }
  895. // if (this.data.availableCompanyList){
  896. // this.data.availableCompanyList.each(function(name){
  897. // if (name) new MWF.widget.Company({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  898. // }.bind(this));
  899. // }
  900. },
  901. changeAvailableIdentitys: function(){
  902. var options = {
  903. "type": "identity",
  904. "title": this.app.lp.application.setAppUsableIdentity,
  905. "values": this.data.availableIdentityList || [],
  906. "onComplete": function(items){
  907. var availableIdentityList = [];
  908. items.each(function(item){
  909. availableIdentityList.push(item.data.distinguishedName);
  910. }.bind(this));
  911. this.data.availableIdentityList = availableIdentityList;
  912. this.app.restActions.saveApplication(this.data, function(json){
  913. this.availableItemsContentNode.empty();
  914. this.setAvailableItems();
  915. }.bind(this));
  916. }.bind(this)
  917. };
  918. var selector = new MWF.O2Selector(this.app.content, options);
  919. },
  920. changeAvailableUnit: function(){
  921. var options = {
  922. "type": "unit",
  923. "title": this.app.lp.application.setAppUsableUnit,
  924. "values": this.data.availableUnitList || [],
  925. "onComplete": function(items){
  926. var availableUnitList = [];
  927. items.each(function(item){
  928. availableUnitList.push(item.data.distinguishedName);
  929. }.bind(this));
  930. this.data.availableUnitList = availableUnitList;
  931. this.app.restActions.saveApplication(this.data, function(json){
  932. this.availableItemsContentNode.empty();
  933. this.setAvailableItems();
  934. }.bind(this));
  935. }.bind(this)
  936. };
  937. var selector = new MWF.O2Selector(this.app.content, options);
  938. },
  939. createEditBaseNode: function(){
  940. this.editBaseNode = new Element("button", {
  941. "styles": this.app.css.editBaseNode,
  942. "text": this.app.lp.edit,
  943. "events": {"click": this.editBaseInfor.bind(this)}
  944. }).inject(this.baseActionNode);
  945. },
  946. createCancelBaseNode: function(){
  947. this.cancelBaseNode = new Element("button", {
  948. "styles": this.app.css.cancelBaseNode,
  949. "text": this.app.lp.cancel,
  950. "events": {"click": this.cancelBaseInfor.bind(this)}
  951. }).inject(this.baseActionNode);
  952. },
  953. createSaveBaseNode: function(){
  954. this.saveBaseNode = new Element("button", {
  955. "styles": this.app.css.saveBaseNode,
  956. "text": this.app.lp.save,
  957. "events": {"click": this.saveBaseInfor.bind(this)}
  958. }).inject(this.baseActionNode);
  959. },
  960. editBaseInfor: function(){
  961. this.baseActionNode.empty();
  962. this.editBaseNode = null;
  963. this.createCancelBaseNode();
  964. this.createSaveBaseNode();
  965. this.editMode();
  966. },
  967. editMode: function(){
  968. this.nameInput.editMode();
  969. this.aliasInput.editMode();
  970. this.descriptionInput.editMode();
  971. this.typeInput.editMode();
  972. this.defaultFormInput.editMode();
  973. this.isEdit = true;
  974. },
  975. readMode: function(){
  976. this.nameInput.readMode();
  977. this.aliasInput.readMode();
  978. this.descriptionInput.readMode();
  979. this.typeInput.readMode();
  980. this.defaultFormInput.readMode();
  981. this.isEdit = false;
  982. },
  983. cancelBaseInfor: function(){
  984. if (this.data.name){
  985. this.baseActionNode.empty();
  986. this.cancelBaseNode = null;
  987. this.saveBaseNode = null;
  988. this.createEditBaseNode();
  989. this.readMode();
  990. }else{
  991. this.destroy();
  992. }
  993. },
  994. saveBaseInfor: function(){
  995. if (!this.nameInput.input.get("value")){
  996. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  997. return false;
  998. }
  999. this.node.mask({
  1000. "style": {
  1001. "opacity": 0.7,
  1002. "background-color": "#999"
  1003. }
  1004. });
  1005. this.save(function(){
  1006. this.baseActionNode.empty();
  1007. this.cancelBaseNode = null;
  1008. this.saveBaseNode = null;
  1009. this.createEditBaseNode();
  1010. this.readMode();
  1011. this.node.unmask();
  1012. }.bind(this), function(xhr, text, error){
  1013. var errorText = error;
  1014. if (xhr) errorText = xhr.responseText;
  1015. this.app.notice("request json error: "+errorText, "error");
  1016. this.node.unmask();
  1017. }.bind(this));
  1018. },
  1019. save: function(callback, cancel){
  1020. this.data.name = this.nameInput.input.get("value");
  1021. this.data.alias = this.aliasInput.input.get("value");
  1022. this.data.description = this.descriptionInput.input.get("value");
  1023. this.data.applicationCategory = this.typeInput.input.get("value");
  1024. this.data.defaultForm = this.defaultFormInput.input.get("value");
  1025. this.app.restActions.saveApplication(this.data, function(json){
  1026. this.propertyTitleBar.set("text", this.data.name);
  1027. this.data.id = json.data.id;
  1028. this.nameInput.save();
  1029. this.aliasInput.save();
  1030. this.descriptionInput.save();
  1031. this.typeInput.save();
  1032. this.defaultFormInput.save();
  1033. if (callback) callback();
  1034. }.bind(this), function(xhr, text, error){
  1035. if (cancel) cancel(xhr, text, error);
  1036. }.bind(this));
  1037. }
  1038. });
  1039. MWF.xApplication.process.ProcessManager.Input = new Class({
  1040. Implements: [Events],
  1041. initialize: function(node, value, style){
  1042. this.node = $(node);
  1043. this.value = value || "";
  1044. this.style = style;
  1045. this.load();
  1046. },
  1047. load: function(){
  1048. this.content = new Element("div", {
  1049. "styles": this.style.content,
  1050. "text": this.value
  1051. }).inject(this.node);
  1052. },
  1053. editMode: function(){
  1054. this.content.empty();
  1055. this.input = new Element("input",{
  1056. "styles": this.style.input,
  1057. "value": this.value
  1058. }).inject(this.content);
  1059. this.input.addEvents({
  1060. "focus": function(){
  1061. this.input.setStyles(this.style.input_focus);
  1062. }.bind(this),
  1063. "blur": function(){
  1064. this.input.setStyles(this.style.input);
  1065. }.bind(this)
  1066. });
  1067. },
  1068. readMode: function(){
  1069. this.content.empty();
  1070. this.input = null;
  1071. this.content.set("text", this.value);
  1072. },
  1073. save: function(){
  1074. if (this.input) this.value = this.input.get("value");
  1075. return this.value;
  1076. }
  1077. });
  1078. MWF.xApplication.process.ProcessManager.Select = new Class({
  1079. Extends: MWF.xApplication.process.ProcessManager.Input,
  1080. Implements: [Events],
  1081. initialize: function(node, value, style, select){
  1082. this.node = $(node);
  1083. this.value = (value) ? value: "";
  1084. this.style = style;
  1085. this.select = select;
  1086. this.selectList = null;
  1087. this.load();
  1088. },
  1089. getSelectList: function(){
  1090. if (this.select){
  1091. return this.select();
  1092. }
  1093. return [];
  1094. },
  1095. getText: function(value){
  1096. if (value){
  1097. if (this.selectList){
  1098. return this.selectList[value] || "";
  1099. }
  1100. }
  1101. return "";
  1102. },
  1103. load: function(){
  1104. this.selectList = this.getSelectList();
  1105. this.content = new Element("div", {
  1106. "styles": this.style.content,
  1107. "text": this.getText(this.value)
  1108. }).inject(this.node);
  1109. },
  1110. editMode: function(){
  1111. this.content.empty();
  1112. this.input = new Element("select",{
  1113. //"styles": this.style.input,
  1114. //"value": this.value
  1115. }).inject(this.content);
  1116. Object.each(this.selectList, function(v, k){
  1117. new Element("option", {
  1118. "value": k,
  1119. "text": v,
  1120. "selected": (this.value==k)
  1121. }).inject(this.input);
  1122. }.bind(this));
  1123. //this.input.addEvents({
  1124. // //"focus": function(){
  1125. // // this.input.setStyles(this.style.input_focus);
  1126. // //}.bind(this),
  1127. // //"blur": function(){
  1128. // // this.input.setStyles(this.style.input);
  1129. // //}.bind(this),
  1130. // //"change": function(){
  1131. // // this.input.setStyles(this.style.input);
  1132. // //}.bind(this)
  1133. //});
  1134. },
  1135. readMode: function(){
  1136. this.content.empty();
  1137. this.input = null;
  1138. this.content.set("text", this.getText(this.value));
  1139. },
  1140. save: function(){
  1141. if (this.input) if (this.input.options.length)this.value = this.input.options[this.input.selectedIndex].get("value");
  1142. return this.value;
  1143. }
  1144. });