Main.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  1. MWF.xApplication.AppCenter.Main = new Class({
  2. Extends: MWF.xApplication.Common.Main,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "name": "AppCenter",
  7. "icon": "icon.png",
  8. "width": "1000",
  9. "height": "700",
  10. "title": MWF.xApplication.AppCenter.LP.title
  11. },
  12. onQueryLoad: function(){
  13. this.lp = MWF.xApplication.AppCenter.LP;
  14. this.actions = MWF.Actions.get("x_program_center");
  15. },
  16. loadApplication: function(callback){
  17. this.components = [];
  18. //this.node = new Element("div", {"styles": {"width": "100%", "height": "100%", "overflow": "hidden"}}).inject(this.content);
  19. this.loadTitle();
  20. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  21. this.contentModuleArea = new Element("div", {"styles": this.css.contentModuleArea}).inject(this.contentNode);
  22. this.setContentSize();
  23. this.addEvent("resize", this.setContentSize);
  24. this.loadModuleContent();
  25. },
  26. loadTitle: function(){
  27. this.titleBar = new Element("div", {"styles": this.css.titleBar}).inject(this.content);
  28. if (MWF.AC.isProcessPlatformCreator()){
  29. this.createApplicationNode = new Element("div", {
  30. "styles": this.css.createApplicationNode,
  31. "title": this.lp.export
  32. }).inject(this.titleBar);
  33. this.createApplicationNode.addEvent("click", function(){
  34. this.createApplication();
  35. }.bind(this));
  36. }
  37. this.taskTitleTextNode = new Element("div", {"styles": this.css.titleTextNode,"text": this.lp.title}).inject(this.titleBar);
  38. },
  39. setContentSize: function(){
  40. var size = this.content.getSize();
  41. var titleSize = this.titleBar.getSize();
  42. var height = size.y-titleSize.y;
  43. this.contentNode.setStyles({"height": ""+height+"px", "overflow": "auto"});
  44. var max = size.x*0.98;
  45. var n = (size.x/320).toInt();
  46. var x = n*320;
  47. while (x>max){
  48. n--;
  49. x = n*320;
  50. }
  51. this.contentModuleArea.setStyle("width", ""+x+"px");
  52. },
  53. loadModuleContent: function(){
  54. this.actions.listStructure(function(json){
  55. this.moduleList = json.data;
  56. if (this.moduleList.length){
  57. this.moduleList.each(function(module){
  58. new MWF.xApplication.AppCenter.Module(this, module);
  59. }.bind(this));
  60. }else{
  61. this.createEmptyElement();
  62. }
  63. }.bind(this));
  64. },
  65. createEmptyElement: function(){
  66. this.emptyNode = new Element("div", {"styles": this.css.emptyNode}).inject(this.contentModuleArea);
  67. if (MWF.AC.isProcessPlatformCreator()){
  68. this.emptyNode.set("text", this.lp.emptyModuleManagerInfo);
  69. this.emptyNode.addEvent("click", function(){
  70. this.createApplication();
  71. }.bind(this));
  72. }else{
  73. this.emptyNode.set("text", this.lp.emptyModuleInfo);
  74. }
  75. },
  76. createApplication: function(){
  77. new MWF.xApplication.AppCenter.Exporter(this);
  78. }
  79. });
  80. MWF.xApplication.AppCenter.Module = new Class({
  81. initialize: function(app, data){
  82. this.app = app;
  83. this.data = data;
  84. this.json = JSON.decode(this.data.data);
  85. this.json.structure = this.data.id;
  86. this.lp = this.app.lp;
  87. this.css = this.app.css;
  88. this.content = this.app.contentModuleArea;
  89. this.load();
  90. },
  91. load: function(){
  92. this.node = new Element("div", {"styles": this.css.moduleNode}).inject(this.content);
  93. this.iconNode = new Element("div", {"styles": this.css.moduleIconNode}).inject(this.node);
  94. this.contentNode = new Element("div", {"styles": this.css.moduleContentNode}).inject(this.node);
  95. this.nameNode = new Element("div", {"styles": this.css.moduleNameNode}).inject(this.contentNode);
  96. this.categoryNode = new Element("div", {"styles": this.css.moduleCategoryNode}).inject(this.contentNode);
  97. this.descriptionNode = new Element("div", {"styles": this.css.moduleDescriptionNode}).inject(this.contentNode);
  98. this.actionNode = new Element("div", {"styles": this.css.moduleActionNode}).inject(this.contentNode);
  99. this.nameNode.set("text", this.data.name);
  100. this.categoryNode.set("text", this.json.category);
  101. this.descriptionNode.set("text", this.data.description);
  102. this.actionNode.set("text", this.lp.output);
  103. this.loadEvent();
  104. },
  105. loadEvent: function(){
  106. this.actionNode.addEvent("click", function(e){
  107. this.outputApp();
  108. e.stopPropagation();
  109. }.bind(this));
  110. this.node.addEvent("click", function(){
  111. this.openApp();
  112. }.bind(this));
  113. },
  114. outputApp: function(){
  115. new MWF.xApplication.AppCenter.Exporter(this.app, this.json)
  116. },
  117. openApp: function(){
  118. }
  119. });
  120. MWF.xApplication.AppCenter.Exporter = new Class({
  121. initialize: function(app, selectData){
  122. this.app = app;
  123. this.lp = this.app.lp;
  124. this.css = this.app.css;
  125. this.structure = null;
  126. this.dlg = null;
  127. this.selectData = selectData || {
  128. "structure": "",
  129. "name": "",
  130. "description": "",
  131. "processPlatformList": [],
  132. "portalList": [],
  133. "queryList": [],
  134. "cmsList": []
  135. };
  136. this.setp = 1;
  137. this.load();
  138. },
  139. loadStructure: function(){
  140. this.structureRes = this.app.actions.outputStructure(function(json){
  141. this.structure = json.data;
  142. this.createContent();
  143. }.bind(this));
  144. },
  145. showDlg: function(callback){
  146. var position = this.app.createApplicationNode.getPosition(this.app.content);
  147. var size = this.app.contentNode.getSize();
  148. var width = size.x*0.9;
  149. if (width>600) width = 600;
  150. var height = size.y*0.9;
  151. var x = (size.x-width)/2;
  152. var y = (size.y-height)/2;
  153. if (y<80) y = 80;
  154. var _self = this;
  155. MWF.require("MWF.xDesktop.Dialog", function(){
  156. this.dlg = new MWF.xDesktop.Dialog({
  157. "title": this.lp.exportTitle,
  158. "style": "appCenter",
  159. "top": y+20,
  160. "left": x,
  161. "fromTop":position.y,
  162. "fromLeft": position.x,
  163. "width": width,
  164. "height": height,
  165. "html": "",
  166. "maskNode": this.app.content,
  167. "container": this.app.content,
  168. "buttonList": [
  169. {
  170. "text": this.lp.next,
  171. "action": function(){
  172. _self.next();
  173. //this.close();
  174. }
  175. },
  176. {
  177. "text": this.lp.prev,
  178. "action": function(){
  179. _self.prev();
  180. //this.close();
  181. }
  182. },
  183. {
  184. "text": this.lp.ok,
  185. "action": function(){
  186. _self.output();
  187. //this.close();
  188. }
  189. },
  190. {
  191. "text": this.lp.cancel,
  192. "action": function(){
  193. this.close();
  194. if (_self.structureRes){
  195. if (_self.structureRes.isRunning()){_self.structureRes.cancel();}
  196. _self.structureRes = null;
  197. }
  198. MWF.release(_self);
  199. }
  200. }
  201. ],
  202. "onPostShow": function(){
  203. if (callback) callback();
  204. }.bind(this)
  205. });
  206. this.dlg.show();
  207. }.bind(this));
  208. },
  209. checkInput: function(){
  210. var name = this.moduleNameInput.get("value");
  211. var category = this.moduleCategoryInput.get("value");
  212. var description = this.moduleDescriptionInput.get("value");
  213. if (!name){
  214. this.app.notice(this.lp.noNameError, "error");
  215. return false;
  216. }
  217. if (!this.selectData.processPlatformList.length &&
  218. !this.selectData.portalList.length &&
  219. !this.selectData.queryList.length &&
  220. !this.selectData.cmsList.length){
  221. this.app.notice(this.lp.noModuleError, "error");
  222. return false;
  223. }
  224. this.selectData.name = name;
  225. this.selectData.category = category;
  226. this.selectData.description = description;
  227. return true;
  228. },
  229. next: function(){
  230. if (this.setp==1){
  231. if (this.checkInput()) this.showStatus();
  232. }
  233. },
  234. prev: function(){
  235. if (this.step==2){
  236. if (this.statusContentNode){
  237. this.statusContentNode.destroy();
  238. this.statusContentNode = null;
  239. }
  240. this.contentNode.setStyle("display", "block");
  241. this.okBut.setStyle("display", "none");
  242. this.prevBut.setStyle("display", "nonde");
  243. this.nextBut.setStyle("display", "inline");
  244. }
  245. },
  246. output: function(){
  247. if (this.step==2){
  248. if (this.checkInput()){
  249. this.app.actions.output(this.selectData, function(json){
  250. var uri = this.app.actions.action.actions["download"].uri;
  251. uri = uri.replace("{flag}", json.data.flag);
  252. this.dlg.close();
  253. window.open(this.app.actions.action.address+uri);
  254. MWF.release(this);
  255. }.bind(this));
  256. }
  257. }
  258. },
  259. showStatus: function(){
  260. this.statusContentNode = new Element("div", {"styles": this.css.moduleSelectContentAreaNode}).inject(this.contentNode, "after");
  261. this.statusTitleNode = new Element("div", {"styles": this.css.moduleSelectTitleNode, "text": this.lp.selected}).inject(this.statusContentNode);
  262. this.statusInfoNode = new Element("div", {"styles": this.css.moduleSelectContentNode}).inject(this.statusContentNode);
  263. var size = this.contentNode.getSize();
  264. var position = this.contentNode.getPosition(this.contentNode.getOffsetParent());
  265. var css = {
  266. "height": ""+size.y+"px",
  267. "width": ""+size.x+"px",
  268. "top": ""+position.y+"px",
  269. "left": ""+position.x+"px",
  270. "background-color": "#eeeeee"
  271. };
  272. this.statusContentNode.setStyles(css);
  273. var titleSize = this.statusTitleNode.getSize();
  274. var h = size.y-titleSize.y-20;
  275. this.statusInfoNode.setStyle("height", ""+h+"px");
  276. this.showStatusList();
  277. this.contentNode.setStyle("display", "none");
  278. this.okBut.setStyle("display", "inline");
  279. this.prevBut.setStyle("display", "inline");
  280. this.nextBut.setStyle("display", "none");
  281. this.step = 2;
  282. },
  283. showStatusList: function(){
  284. this.showStatusItemList("processPlatformList", ["processList", "formList", "applicationDictList", "scriptList", "fileList"]);
  285. this.showStatusItemList("portalList", ["pageList", "scriptList", "widgetList", "fileList"]);
  286. this.showStatusItemList("cmsList", ["categoryInfoList", "formList", "appDictList", "scriptList"]);
  287. this.showStatusItemList("queryList", ["viewList", "statList", "revealList"]);
  288. },
  289. showStatusItemList: function(listName, subList){
  290. this.selectData[listName].each(function(app){
  291. new Element("div", {"styles": this.css.moduleStatusInforNode1, "text": "["+this.lp[listName]+"] "+(app.name || app.appName)}).inject(this.statusInfoNode);
  292. subList.each(function(name){
  293. if (app[name] && app[name].length) app[name].each(function(process){
  294. new Element("div", {"styles": this.css.moduleStatusInforNode2, "text": "["+this.lp[name]+"] "+(process.name || process.categoryName)}).inject(this.statusInfoNode);
  295. }.bind(this));
  296. }.bind(this));
  297. }.bind(this));
  298. },
  299. load: function(){
  300. this.showDlg(function(){
  301. this.createLayout();
  302. this.loadStructure();
  303. }.bind(this));
  304. },
  305. createLayout: function(){
  306. this.nextBut = this.dlg.button.getFirst("input");
  307. this.prevBut = this.nextBut.getNext("input");
  308. this.okBut = this.prevBut.getNext("input");
  309. if (this.setp==1){
  310. this.okBut.setStyle("display", "none");
  311. this.prevBut.setStyle("display", "none");
  312. }
  313. this.node = new Element("div", {"styles": this.css.moduleSetupContentNode}).inject(this.dlg.content);
  314. this.titleNode = new Element("div", {"styles": this.css.moduleSetupTitleNode}).inject(this.node);
  315. var iconNode = new Element("div", {"styles": this.css.moduleIconNode}).inject(this.titleNode);
  316. var contentNode = new Element("div", {"styles": this.css.moduleSetupTitleContentNode}).inject(this.titleNode);
  317. var nameNode = new Element("div", {"styles": this.css.moduleSetupNameNode}).inject(contentNode);
  318. var categoryNode = new Element("div", {"styles": this.css.moduleSetupCategoryNode}).inject(contentNode);
  319. var descriptionNode = new Element("div", {"styles": this.css.moduleSetupDescriptionNode}).inject(contentNode);
  320. var nameTitleNode = new Element("div", {"styles": this.css.moduleInputTitleNode, "text": this.lp.moduleName}).inject(nameNode);
  321. var nameContentNode = new Element("div", {"styles": this.css.moduleInputContentNode}).inject(nameNode);
  322. this.moduleNameInput = new Element("input", {"styles": this.css.moduleInputNode}).inject(nameContentNode);
  323. var categoryTitleNode = new Element("div", {"styles": this.css.moduleInputTitleNode, "text": this.lp.moduleCategory}).inject(categoryNode);
  324. var categoryContentNode = new Element("div", {"styles": this.css.moduleInputContentNode}).inject(categoryNode);
  325. this.moduleCategoryInput = new Element("input", {"styles": this.css.moduleInputNode}).inject(categoryContentNode);
  326. var descriptionTitleNode = new Element("div", {"styles": this.css.moduleInputTitleNode, "text": this.lp.moduleDescription}).inject(descriptionNode);
  327. var descriptionContentNode = new Element("div", {"styles": this.css.moduleInputContentNode}).inject(descriptionNode);
  328. this.moduleDescriptionInput = new Element("input", {"styles": this.css.moduleInputNode}).inject(descriptionContentNode);
  329. this.moduleNameInput.set("value", this.selectData.name);
  330. this.moduleCategoryInput.set("value", this.selectData.category);
  331. this.moduleDescriptionInput.set("value", this.selectData.description);
  332. this.contentNode = new Element("div", {"styles": this.css.moduleSetupCompareContentNode}).inject(this.node);
  333. this.setListContentSize();
  334. this.createLoading(this.contentNode);
  335. },
  336. setListContentSize: function(){
  337. var size = this.dlg.content.getSize();
  338. var h = size.y;
  339. var titleH = this.titleNode.getSize().y+10;
  340. var contentH = h-titleH-10;
  341. this.contentNode.setStyle("height", ""+contentH+"px");
  342. },
  343. createLoading: function(node){
  344. //this.okBut.setStyle("display", "none");
  345. this.nextBut.setStyle("display", "none");
  346. this.loadingAreaNode = new Element("div", {"styles": this.css.moduleLoadingAreaNode}).inject(node);
  347. var img = new Element("img", {
  348. "styles": this.css.moduleLoadingImgNode,
  349. "src": this.app.path+this.app.options.style+"/icon/loading.gif"
  350. }).inject(this.loadingAreaNode);
  351. },
  352. clearLoading: function(){
  353. if (this.loadingAreaNode){
  354. this.loadingAreaNode.destroy();
  355. this.loadingAreaNode = null;
  356. }
  357. //this.okBut.setStyle("display", "inline");
  358. this.nextBut.setStyle("display", "inline");
  359. },
  360. createContent: function(){
  361. this.clearLoading();
  362. this.createListArea();
  363. this.loadProcessList();
  364. this.loadPortalList();
  365. this.loadCMSList();
  366. this.loadQueryList();
  367. //this.structure
  368. },
  369. createListArea: function(){
  370. this.contentAreaNode = new Element("div").inject(this.contentNode);
  371. // this.contentInforNode = new Element("div", {"styles": this.css.moduleSetupContentInforNode, "text": this.lp.selectModules}).inject(this.contentAreaNode);
  372. // //this.processArea = new Element("div", {"styles": this.css.moduleSetupListAreaNode}).inject(this.contentNode);
  373. //
  374. // this.listAreaNode = new Element("div").inject(this.contentAreaNode);
  375. this.processAreaTitle = new Element("div", {"styles": this.css.moduleSetupListAreaTitleNode, "text": this.lp.process}).inject(this.contentAreaNode);
  376. this.processAreaContent = new Element("div", {"styles": this.css.moduleSetupListAreaContentNode}).inject(this.contentAreaNode);
  377. this.portalAreaTitle = new Element("div", {"styles": this.css.moduleSetupListAreaTitleNode, "text": this.lp.portal}).inject(this.contentAreaNode);
  378. this.portalAreaContent = new Element("div", {"styles": this.css.moduleSetupListAreaContentNode}).inject(this.contentAreaNode);
  379. this.cmsAreaTitle = new Element("div", {"styles": this.css.moduleSetupListAreaTitleNode, "text": this.lp.cms}).inject(this.contentAreaNode);
  380. this.cmsAreaContent = new Element("div", {"styles": this.css.moduleSetupListAreaContentNode}).inject(this.contentAreaNode);
  381. this.queryAreaTitle = new Element("div", {"styles": this.css.moduleSetupListAreaTitleNode, "text": this.lp.query}).inject(this.contentAreaNode);
  382. this.queryAreaContent = new Element("div", {"styles": this.css.moduleSetupListAreaContentNode}).inject(this.contentAreaNode);
  383. },
  384. loadProcessList: function(){
  385. this.processListNodes = [];
  386. this.structure.processPlatformList.each(function(item){
  387. var postData = null;
  388. for (var i=0; i<this.selectData.processPlatformList.length; i++){
  389. if (this.selectData.processPlatformList[i].id == item.id){
  390. postData = this.selectData.processPlatformList[i];
  391. break;
  392. }
  393. }
  394. this.processListNodes.push(new MWF.xApplication.AppCenter.Exporter.ProcessElement(this, this.processAreaContent, item, postData));
  395. }.bind(this));
  396. },
  397. loadPortalList: function(){
  398. this.portalListNodes = [];
  399. this.structure.portalList.each(function(item){
  400. this.portalListNodes.push(new MWF.xApplication.AppCenter.Exporter.PortalElement(this, this.portalAreaContent, item));
  401. }.bind(this));
  402. },
  403. loadCMSList: function(){
  404. this.cmsListNodes = [];
  405. this.structure.cmsList.each(function(item){
  406. this.cmsListNodes.push(new MWF.xApplication.AppCenter.Exporter.CmsElement(this, this.cmsAreaContent, item));
  407. }.bind(this));
  408. },
  409. loadQueryList: function(){
  410. this.queryListNodes = [];
  411. this.structure.queryList.each(function(item){
  412. this.queryListNodes.push(new MWF.xApplication.AppCenter.Exporter.QueryElement(this, this.queryAreaContent, item));
  413. }.bind(this));
  414. }
  415. });
  416. MWF.xApplication.AppCenter.Exporter.Element = new Class({
  417. initialize: function(exporter, content, data, postData){
  418. this.exporter = exporter;
  419. this.app = this.exporter.app;
  420. this.data = data;
  421. this.lp = this.app.lp;
  422. this.css = this.app.css;
  423. this.content = content;
  424. this.initPostData(postData);
  425. //this.selectStatus = selectStatus || "none";
  426. this.load();
  427. },
  428. initPostData: function(postData){
  429. this.postData = postData || {
  430. "id": this.data.id,
  431. "name": this.data.name || this.data.appName,
  432. "alias": this.data.alias,
  433. "description": this.data.description,
  434. "processList": [],
  435. "formList": [],
  436. "applicationDictList": [],
  437. "scriptList": [],
  438. "fileList": []
  439. };
  440. },
  441. load: function(){
  442. this.contentNode = new Element("div", {"styles": this.css.moduleSetupListContentNode}).inject(this.content);
  443. this.iconNode = new Element("div", {"styles": this.css.moduleSetupListIconNode}).inject(this.contentNode);
  444. this.actionNode = new Element("div", {"styles": this.css.moduleSetupListActionNode}).inject(this.contentNode);
  445. this.inforNode = new Element("div", {"styles": this.css.moduleSetupListInforNode}).inject(this.contentNode);
  446. this.nameNode = new Element("div", {"styles": this.css.moduleSetupListNameNode}).inject(this.contentNode);
  447. this.nameNode.set(this.getNameContent());
  448. // switch (this.selectStatus){
  449. // case "all":
  450. // this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_all.png) center center no-repeat");
  451. // break;
  452. // case "part":
  453. // this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_part.png) center center no-repeat");
  454. // break;
  455. // default:
  456. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_none.png) center center no-repeat");
  457. //}
  458. this.action = new Element("div", {"styles": this.css.moduleSelectActionNode, "text": this.lp.select}).inject(this.actionNode);
  459. this.setEvent();
  460. this.checkSelect(this.postData);
  461. },
  462. setEvent: function(){
  463. this.contentNode.addEvents({
  464. "mouseover": function(){this.contentNode.setStyles(this.css.moduleSetupListContentNode_over);}.bind(this),
  465. "mouseout": function(){this.contentNode.setStyles(this.css.moduleSetupListContentNode);}.bind(this)
  466. });
  467. this.action.addEvent("click", function(){
  468. this.selectElements();
  469. }.bind(this));
  470. this.nameNode.addEvent("click", function(){
  471. this.selectElements();
  472. }.bind(this));
  473. },
  474. getNameContent: function(){
  475. return {
  476. "title": this.lp.name+": "+this.data.name+" "+this.lp.id+": "+this.data.id,
  477. "text": this.data.name
  478. }
  479. },
  480. selectElements: function(){
  481. new MWF.xApplication.AppCenter.Exporter.Element.Selector(this, this.data);
  482. },
  483. checkSelect: function(selectData){
  484. this.postData.processList = selectData.processList;
  485. this.postData.formList = selectData.formList;
  486. this.postData.applicationDictList = selectData.applicationDictList;
  487. this.postData.scriptList = selectData.scriptList;
  488. this.postData.fileList = selectData.fileList;
  489. this.exporter.selectData.processPlatformList.erase(this.postData);
  490. if (selectData.processList.length || selectData.formList.length || selectData.applicationDictList.length || selectData.scriptList.length || selectData.fileList.length){
  491. this.exporter.selectData.processPlatformList.push(this.postData);
  492. if (selectData.processList.length==this.data.processList.length &&
  493. selectData.formList.length==this.data.formList.length &&
  494. selectData.applicationDictList.length==this.data.applicationDictList.length &&
  495. selectData.scriptList.length==this.data.scriptList.length &&
  496. selectData.fileList.length==this.data.fileList.length){
  497. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_all.png) center center no-repeat");
  498. }else{
  499. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_part.png) center center no-repeat");
  500. }
  501. }else{
  502. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_none.png) center center no-repeat");
  503. }
  504. }
  505. });
  506. MWF.xApplication.AppCenter.Exporter.ProcessElement = new Class({
  507. Extends: MWF.xApplication.AppCenter.Exporter.Element
  508. });
  509. MWF.xApplication.AppCenter.Exporter.PortalElement = new Class({
  510. Extends: MWF.xApplication.AppCenter.Exporter.Element,
  511. initPostData: function(postData){
  512. this.postData = postData || {
  513. "id": this.data.id,
  514. "name": this.data.name || this.data.appName,
  515. "alias": this.data.alias,
  516. "description": this.data.description,
  517. "pageList": [],
  518. "scriptList": [],
  519. "widgetList": []
  520. };
  521. },
  522. selectElements: function(){
  523. new MWF.xApplication.AppCenter.Exporter.Element.PortalSelector(this, this.data);
  524. },
  525. checkSelect: function(selectData){
  526. this.postData.pageList = selectData.pageList;
  527. this.postData.scriptList = selectData.scriptList;
  528. this.postData.widgetList = selectData.widgetList;
  529. if (selectData.pageList.length || selectData.scriptList.length || selectData.widgetList.length){
  530. this.exporter.selectData.portalList.push(this.postData);
  531. if (selectData.pageList.length==this.data.pageList.length &&
  532. selectData.scriptList.length==this.data.scriptList.length &&
  533. selectData.widgetList.length==this.data.widgetList.length){
  534. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_all.png) center center no-repeat");
  535. }else{
  536. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_part.png) center center no-repeat");
  537. }
  538. }else{
  539. this.exporter.selectData.portalList.erase(this.postData);
  540. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_none.png) center center no-repeat");
  541. }
  542. }
  543. });
  544. MWF.xApplication.AppCenter.Exporter.CmsElement = new Class({
  545. Extends: MWF.xApplication.AppCenter.Exporter.Element,
  546. getNameContent: function(){
  547. return {
  548. "title": this.lp.name+": "+this.data.appName+" "+this.lp.id+": "+this.data.id,
  549. "text": this.data.appName
  550. }
  551. },
  552. initPostData: function(postData){
  553. this.postData = postData || {
  554. "id": this.data.id,
  555. "name": this.data.name || this.data.appName,
  556. "alias": this.data.alias,
  557. "description": this.data.description,
  558. "categoryInfoList": [],
  559. "formList": [],
  560. "appDictList": [],
  561. "scriptList": []
  562. };
  563. },
  564. selectElements: function(){
  565. new MWF.xApplication.AppCenter.Exporter.Element.CmsSelector(this, this.data);
  566. },
  567. checkSelect: function(selectData){
  568. this.postData.categoryInfoList = selectData.categoryInfoList;
  569. this.postData.formList = selectData.formList;
  570. this.postData.appDictList = selectData.appDictList;
  571. this.postData.scriptList = selectData.scriptList;
  572. if (selectData.categoryInfoList.length || selectData.formList.length || selectData.appDictList.length || selectData.scriptList.length){
  573. this.exporter.selectData.cmsList.push(this.postData);
  574. if (selectData.categoryInfoList.length==this.data.categoryInfoList.length &&
  575. selectData.formList.length==this.data.formList.length &&
  576. selectData.appDictList.length==this.data.appDictList.length &&
  577. selectData.scriptList.length==this.data.scriptList.length){
  578. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_all.png) center center no-repeat");
  579. }else{
  580. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_part.png) center center no-repeat");
  581. }
  582. }else{
  583. this.exporter.selectData.cmsList.erase(this.postData);
  584. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_none.png) center center no-repeat");
  585. }
  586. }
  587. });
  588. MWF.xApplication.AppCenter.Exporter.QueryElement = new Class({
  589. Extends: MWF.xApplication.AppCenter.Exporter.Element,
  590. initPostData: function(postData){
  591. this.postData = postData || {
  592. "id": this.data.id,
  593. "name": this.data.name || this.data.appName,
  594. "alias": this.data.alias,
  595. "description": this.data.description,
  596. "viewList": [],
  597. "statList": [],
  598. "revealList": []
  599. };
  600. },
  601. selectElements: function(){
  602. new MWF.xApplication.AppCenter.Exporter.Element.QuerySelector(this, this.data);
  603. },
  604. checkSelect: function(selectData){
  605. this.postData.viewList = selectData.viewList;
  606. this.postData.statList = selectData.statList;
  607. this.postData.revealList = selectData.revealList;
  608. if (selectData.viewList.length || selectData.statList.length || selectData.revealList.length){
  609. this.exporter.selectData.queryList.push(this.postData);
  610. if (selectData.viewList.length==this.data.viewList.length &&
  611. selectData.statList.length==this.data.statList.length &&
  612. selectData.revealList.length==this.data.revealList.length){
  613. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_all.png) center center no-repeat");
  614. }else{
  615. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_part.png) center center no-repeat");
  616. }
  617. }else{
  618. this.exporter.selectData.queryList.erase(this.postData);
  619. this.iconNode.setStyle("background", "url("+this.app.path+this.app.options.style+"/icon/sel_none.png) center center no-repeat");
  620. }
  621. }
  622. });
  623. MWF.xApplication.AppCenter.Exporter.Element.Selector = new Class({
  624. initialize: function(element, data){
  625. this.element = element;
  626. this.app = this.element.app;
  627. this.data = data;
  628. this.lp = this.app.lp;
  629. this.css = this.app.css;
  630. this.content = this.element.contentNode;
  631. this.areaNode = this.element.exporter.contentNode;
  632. this.selectData = this.initData();
  633. this.load();
  634. },
  635. initData: function(){
  636. return {
  637. "processList": [],
  638. "formList": [],
  639. "applicationDictList": [],
  640. "scriptList": [],
  641. "fileList": []
  642. }
  643. },
  644. load: function(){
  645. this.node = new Element("div", {"styles": this.css.moduleSelectContentAreaNode}).inject(this.areaNode, "after");
  646. this.titleNode = new Element("div", {"styles": this.css.moduleSelectTitleNode, "text": this.data.name}).inject(this.node);
  647. var size = this.content.getSize();
  648. this.node.setStyle("width", ""+size.x+"px");
  649. this.node.position({
  650. "relativeTo": this.content,
  651. "position": "topLeft",
  652. "edge": "topLeft"
  653. });
  654. this.element.exporter.dlg.button.setStyle("display", "none");
  655. this.show();
  656. },
  657. show: function(){
  658. var size = this.areaNode.getSize();
  659. var height = size.y+40;
  660. var width = size.x;
  661. var position = this.areaNode.getPosition(this.areaNode.getOffsetParent());
  662. //var oStyles = this.node.getStyles("height", "width", "top", "left", "background-color");
  663. //this.node.store("ostyles", oStyles);
  664. var css = {
  665. "height": ""+height+"px",
  666. "width": ""+width+"px",
  667. "top": ""+position.y+"px",
  668. "left": ""+position.x+"px",
  669. "background-color": "#eeeeee"
  670. };
  671. this.morph = new Fx.Morph(this.node, {"duration": 100});
  672. this.morph.start(css).chain(function(){
  673. this.loadContent();
  674. }.bind(this));
  675. },
  676. hide: function(){
  677. if (!this.morph) this.morph = new Fx.Morph(this.node, {"duration": 100});
  678. this.areaNode.setStyle("display", "block");
  679. this.element.exporter.dlg.button.setStyle("display", "block");
  680. var size = this.content.getSize();
  681. var height = size.y;
  682. var width = size.x;
  683. var position = this.content.getPosition(this.areaNode);
  684. var thisPosition = this.node.getPosition(this.node.getOffsetParent());
  685. var x = thisPosition.x+position.x;
  686. var y = thisPosition.y+position.y;
  687. var css = {
  688. "height": ""+height+"px",
  689. "width": ""+width+"px",
  690. "top": ""+y+"px",
  691. "left": ""+x+"px"
  692. };
  693. this.contentNode.destroy();
  694. this.morph.start(css).chain(function(){
  695. this.node.destroy();
  696. MWF.release(this);
  697. }.bind(this));
  698. },
  699. loadContent: function(){
  700. this.areaNode.setStyle("display", "none");
  701. this.contentNode = new Element("div", {"styles": this.css.moduleSelectContentNode}).inject(this.node);
  702. this.buttonNode = new Element("div", {"styles": this.css.moduleSelectButtonNode}).inject(this.node);
  703. this.cancelButton = new Element("div", {"styles": this.css.moduleSelectButtonActionNode, "text": this.lp.cancel}).inject(this.buttonNode);
  704. this.okButton = new Element("div", {"styles": this.css.moduleSelectButtonActionNode, "text": this.lp.ok}).inject(this.buttonNode);
  705. this.setContentHeight();
  706. this.loadContentList();
  707. this.cancelButton.addEvent("click", function(){
  708. this.hide();
  709. }.bind(this));
  710. this.okButton.addEvent("click", function(){
  711. this.checkSelect();
  712. }.bind(this));
  713. },
  714. checkSelect: function() {
  715. this.selectData.processList = this.getCheckedList(this.listProcessContent);
  716. this.selectData.formList = this.getCheckedList(this.listFormContent);
  717. this.selectData.applicationDictList = this.getCheckedList(this.listDictContent);
  718. this.selectData.scriptList = this.getCheckedList(this.listScriptContent);
  719. this.selectData.fileList = this.getCheckedList(this.listFileContent);
  720. this.element.checkSelect(this.selectData);
  721. this.hide();
  722. },
  723. getCheckedList: function(node){
  724. var list = [];
  725. node.getElements("input").each(function(input){
  726. if (input.checked){
  727. list.push(input.retrieve("data"));
  728. }
  729. }.bind());
  730. return list;
  731. },
  732. setContentHeight: function(){
  733. var size = this.node.getSize();
  734. var titleSize = this.titleNode.getSize();
  735. var buttonSize = this.buttonNode.getSize();
  736. var h = size.y-titleSize.y-buttonSize.y;
  737. this.contentNode.setStyle("height", ""+h+"px");
  738. },
  739. loadContentList: function(){
  740. this.contentAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentNode);
  741. this.listProcessContent = this.listProcess("processList");
  742. this.listFormContent = this.listProcess("formList");
  743. this.listDictContent = this.listProcess("applicationDictList");
  744. this.listScriptContent = this.listProcess("scriptList");
  745. this.listFileContent = this.listProcess("fileList");
  746. },
  747. listProcess: function(name){
  748. var title = new Element("div", {"styles": this.css.moduleSelectContentTitleNode}).inject(this.contentAreaNode);
  749. var titleActionNode = new Element("div", {"styles": this.css.moduleSelectContentTitleButtonNode}).inject(title);
  750. var inverseAction = new Element("div", {"styles": this.css.moduleSelectContentTitleButtonActionNode, "text": this.lp.inverse}).inject(titleActionNode);
  751. var selectAllAction = new Element("div", {"styles": this.css.moduleSelectContentTitleButtonActionNode, "text": this.lp.selectAll}).inject(titleActionNode);
  752. var titleText = new Element("div", {"styles": this.css.moduleSelectContentTitleTextNode, "text": this.lp[name]}).inject(title);
  753. //moduleSelectContentTitleButtonActionNode
  754. var listContent = new Element("div", {"styles": this.css.moduleSelectContentListNode}).inject(this.contentAreaNode);
  755. this.listProcessItems(name, listContent);
  756. inverseAction.addEvent("click", function(){
  757. inputs = listContent.getElements("input");
  758. inputs.each(function(checkbox){
  759. checkbox.set("checked", !checkbox.get("checked"));
  760. });
  761. });
  762. selectAllAction.addEvent("click", function(){
  763. inputs = listContent.getElements("input");
  764. inputs.each(function(checkbox){
  765. checkbox.set("checked", true);
  766. });
  767. });
  768. return listContent;
  769. },
  770. listProcessItems: function(name, listContent){
  771. this.data[name].each(function(item){
  772. var div = new Element("div", {"styles": this.css.moduleSelectContentListItemNode}).inject(listContent);
  773. var flag = false;
  774. var selectedList = this.element.postData[name];
  775. if (selectedList){
  776. for (var i=0; i<selectedList.length; i++){
  777. if (selectedList[i].id==item.id){
  778. flag = true;
  779. break;
  780. }
  781. }
  782. }
  783. var checkNode = new Element("input", {
  784. "styles": {"float": "left"},
  785. "type": "checkbox",
  786. //"checked": (this.element.postData[name] && this.element.postData[name].indexOf(item)!=-1),
  787. "checked": flag,
  788. "value": item.id
  789. }).inject(div);
  790. new Element("div", {
  791. "styles": {"float": "left"},
  792. "text": this.getItemName(item),
  793. "events": {
  794. "click": function(){checkNode.click();}
  795. }
  796. }).inject(div);
  797. checkNode.store("data", item);
  798. }.bind(this));
  799. },
  800. getItemName: function(item){
  801. return item.name;
  802. }
  803. });
  804. MWF.xApplication.AppCenter.Exporter.Element.ProcessSelector = new Class({
  805. Extends: MWF.xApplication.AppCenter.Exporter.Element.Selector
  806. });
  807. MWF.xApplication.AppCenter.Exporter.Element.PortalSelector = new Class({
  808. Extends: MWF.xApplication.AppCenter.Exporter.Element.Selector,
  809. initData: function(){
  810. return {
  811. "pageList": [],
  812. "scriptList": [],
  813. "widgetList": []
  814. }
  815. },
  816. checkSelect: function() {
  817. this.selectData.pageList = this.getCheckedList(this.listPageContent);
  818. this.selectData.scriptList = this.getCheckedList(this.listScriptContent);
  819. this.selectData.widgetList = this.getCheckedList(this.listWidgetContent);
  820. this.element.checkSelect(this.selectData);
  821. this.hide();
  822. },
  823. loadContentList: function(){
  824. this.contentAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentNode);
  825. this.listPageContent = this.listProcess("pageList");
  826. this.listScriptContent = this.listProcess("scriptList");
  827. this.listWidgetContent = this.listProcess("widgetList");
  828. }
  829. });
  830. MWF.xApplication.AppCenter.Exporter.Element.CmsSelector = new Class({
  831. Extends: MWF.xApplication.AppCenter.Exporter.Element.Selector,
  832. initData: function(){
  833. return {
  834. "categoryInfoList": [],
  835. "formList": [],
  836. "appDictList": [],
  837. "scriptList": []
  838. }
  839. },
  840. checkSelect: function() {
  841. this.selectData.categoryInfoList = this.getCheckedList(this.listCategoryInfoContent);
  842. this.selectData.formList = this.getCheckedList(this.listFormContent);
  843. this.selectData.appDictList = this.getCheckedList(this.listDictContent);
  844. this.selectData.scriptList = this.getCheckedList(this.listScriptContent);
  845. this.element.checkSelect(this.selectData);
  846. this.hide();
  847. },
  848. loadContentList: function(){
  849. this.contentAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentNode);
  850. this.listCategoryInfoContent = this.listProcess("categoryInfoList");
  851. this.listFormContent = this.listProcess("formList");
  852. this.listDictContent = this.listProcess("appDictList");
  853. this.listScriptContent = this.listProcess("scriptList");
  854. },
  855. getItemName: function(item){
  856. return item.name || item.categoryName;
  857. }
  858. });
  859. MWF.xApplication.AppCenter.Exporter.Element.QuerySelector = new Class({
  860. Extends: MWF.xApplication.AppCenter.Exporter.Element.Selector,
  861. initData: function(){
  862. return {
  863. "viewList": [],
  864. "statList": [],
  865. "revealList": []
  866. }
  867. },
  868. checkSelect: function() {
  869. this.selectData.viewList = this.getCheckedList(this.listViewContent);
  870. this.selectData.statList = this.getCheckedList(this.listStatContent);
  871. this.selectData.revealList = this.getCheckedList(this.listRevealContent);
  872. this.element.checkSelect(this.selectData);
  873. this.hide();
  874. },
  875. loadContentList: function(){
  876. this.contentAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentNode);
  877. this.listViewContent = this.listProcess("viewList");
  878. this.listStatContent = this.listProcess("statList");
  879. this.listRevealContent = this.listProcess("revealList");
  880. }
  881. });