Main.js 52 KB

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