Main.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. MWF.xDesktop.requireApp("portal.PortalManager", "package", null, false);
  2. //MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", null, false);
  3. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  4. MWF.require("MWF.widget.Identity", null,false);
  5. MWF.xDesktop.requireApp("process.ProcessManager", "", null, false);
  6. MWF.xApplication.portal = MWF.xApplication.portal || {};
  7. MWF.xApplication.portal.PortalManager.Main = new Class({
  8. Extends: MWF.xApplication.process.ProcessManager.Main,
  9. Implements: [Options, Events],
  10. options: {
  11. "application": null,
  12. "style": "default",
  13. "name": "portal.PortalManager",
  14. "icon": "icon.png",
  15. "width": "1100",
  16. "height": "700",
  17. "title": MWF.xApplication.portal.PortalManager.LP.title
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.portal.PortalManager.LP;
  21. this.currentContentNode = null;
  22. this.restActions = MWF.Actions.get("x_portal_assemble_designer");
  23. //new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  24. },
  25. keyCopyItems: function(e){
  26. var app = layout.desktop.currentApp || layout.desktop.app;
  27. if (app && app.appId===this.appId){
  28. if (this.pageConfigurator){
  29. this.pageConfigurator.keyCopy(e);
  30. }
  31. if (this.scriptConfigurator){
  32. this.scriptConfigurator.keyCopy(e);
  33. }
  34. if (this.dictionaryConfigurator){
  35. this.dictionaryConfigurator.keyCopy(e);
  36. }
  37. if (this.widgetConfigurator){
  38. this.widgetConfigurator.keyCopy(e);
  39. }
  40. }
  41. },
  42. keyPasteItems: function(e){
  43. var app = layout.desktop.currentApp || layout.desktop.app;
  44. if (app && app.appId===this.appId) {
  45. if (this.pageConfigurator){
  46. this.pageConfigurator.keyPaste(e);
  47. }
  48. if (this.scriptConfigurator){
  49. this.scriptConfigurator.keyPaste(e);
  50. }
  51. if (this.dictionaryConfigurator){
  52. this.dictionaryConfigurator.keyPaste(e);
  53. }
  54. if (this.widgetConfigurator){
  55. this.widgetConfigurator.keyPaste(e);
  56. }
  57. }
  58. },
  59. loadStartMenu: function(callback){
  60. this.startMenuNode = new Element("div", {
  61. "styles": this.css.startMenuNode
  62. }).inject(this.node);
  63. this.menu = new MWF.xApplication.portal.PortalManager.Menu(this, this.startMenuNode, {
  64. "onPostLoad": function(){
  65. if (this.status){
  66. if (this.status.navi!=null){
  67. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  68. }else{
  69. this.menu.doAction(this.menu.startNavis[0]);
  70. }
  71. }else{
  72. this.menu.doAction(this.menu.startNavis[0]);
  73. }
  74. }.bind(this)
  75. });
  76. this.addEvent("resize", function(){
  77. if (this.menu) this.menu.onResize();
  78. }.bind(this));
  79. },
  80. clearContent: function(){
  81. if (this.pageConfiguratorContent){
  82. if (this.pageConfigurator) delete this.pageConfigurator;
  83. this.pageConfiguratorContent.destroy();
  84. this.pageConfiguratorContent = null;
  85. }
  86. if (this.menuConfiguratorContent){
  87. if (this.menuConfigurator) delete this.menuConfigurator;
  88. this.menuConfiguratorContent.destroy();
  89. this.menuConfiguratorContent = null;
  90. }
  91. if (this.propertyConfiguratorContent){
  92. if (this.property) delete this.property;
  93. this.propertyConfiguratorContent.destroy();
  94. this.propertyConfiguratorContent = null;
  95. }
  96. if (this.widgetConfiguratorContent){
  97. if (this.widgetConfigurator) delete this.widgetConfigurator;
  98. this.widgetConfiguratorContent.destroy();
  99. this.widgetConfiguratorContent = null;
  100. }
  101. if (this.scriptConfiguratorContent){
  102. if (this.scriptConfigurator) delete this.scriptConfigurator;
  103. this.scriptConfiguratorContent.destroy();
  104. this.scriptConfiguratorContent = null;
  105. }
  106. if (this.dictionaryConfiguratorContent){
  107. if (this.dictionaryConfigurator) delete this.dictionaryConfigurator;
  108. this.dictionaryConfiguratorContent.destroy();
  109. this.dictionaryConfiguratorContent = null;
  110. }
  111. if (this.fileConfiguratorContent){
  112. if (this.fileConfigurator) delete this.fileConfigurator;
  113. this.fileConfiguratorContent.destroy();
  114. this.fileConfiguratorContent = null;
  115. }
  116. },
  117. applicationProperty: function(){
  118. this.clearContent();
  119. this.propertyConfiguratorContent = new Element("div", {
  120. "styles": this.css.rightContentNode
  121. }).inject(this.node);
  122. this.property = new MWF.xApplication.portal.PortalManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  123. this.property.load();
  124. },
  125. pageConfig: function(){
  126. this.clearContent();
  127. this.pageConfiguratorContent = new Element("div", {
  128. "styles": this.css.rightContentNode
  129. }).inject(this.node);
  130. this.loadPageConfig();
  131. },
  132. loadPageConfig: function(){
  133. MWF.xDesktop.requireApp("portal.PortalManager", "PageExplorer", function(){
  134. this.pageConfigurator = new MWF.xApplication.portal.PortalManager.PageExplorer(this.pageConfiguratorContent, this.restActions);
  135. this.pageConfigurator.app = this;
  136. this.pageConfigurator.load();
  137. }.bind(this));
  138. },
  139. menuConfig: function(){
  140. this.clearContent();
  141. this.menuConfiguratorContent = new Element("div", {
  142. "styles": this.css.rightContentNode
  143. }).inject(this.node);
  144. this.loadMenuConfig();
  145. },
  146. loadMenuConfig: function(){
  147. MWF.xDesktop.requireApp("portal.PortalManager", "MenuExplorer", function(){
  148. //MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", function(){
  149. //if (!this.restActions) this.restActions = new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  150. if (!this.restActions) this.restActions = MWF.Actions.get("x_portal_assemble_designer");
  151. this.menuConfigurator = new MWF.xApplication.portal.PortalManager.MenuExplorer(this.menuConfiguratorContent, this.restActions);
  152. this.menuConfigurator.app = this;
  153. this.menuConfigurator.load();
  154. //}.bind(this));
  155. }.bind(this));
  156. },
  157. widgetConfig: function(){
  158. this.clearContent();
  159. this.widgetConfiguratorContent = new Element("div", {
  160. "styles": this.css.rightContentNode
  161. }).inject(this.node);
  162. this.loadWidgetConfig();
  163. },
  164. loadWidgetConfig: function(){
  165. MWF.xDesktop.requireApp("portal.PortalManager", "WidgetExplorer", function(){
  166. this.widgetConfigurator = new MWF.xApplication.portal.PortalManager.WidgetExplorer(this.widgetConfiguratorContent, this.restActions);
  167. this.widgetConfigurator.app = this;
  168. this.widgetConfigurator.load();
  169. }.bind(this));
  170. },
  171. scriptConfig: function(){
  172. this.clearContent();
  173. this.scriptConfiguratorContent = new Element("div", {
  174. "styles": this.css.rightContentNode
  175. }).inject(this.node);
  176. this.loadScriptConfig();
  177. },
  178. loadScriptConfig: function(){
  179. MWF.xDesktop.requireApp("portal.PortalManager", "ScriptExplorer", function(){
  180. //MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", function(){
  181. //if (!this.restActions) this.restActions = new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  182. if (!this.restActions) this.restActions = MWF.Actions.get("x_portal_assemble_designer");
  183. this.scriptConfigurator = new MWF.xApplication.portal.PortalManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  184. this.scriptConfigurator.app = this;
  185. this.scriptConfigurator.load();
  186. //}.bind(this));
  187. }.bind(this));
  188. },
  189. dataConfig: function(){
  190. this.clearContent();
  191. this.dictionaryConfiguratorContent = new Element("div", {
  192. "styles": this.css.rightContentNode
  193. }).inject(this.node);
  194. this.loadDictionaryConfig();
  195. },
  196. loadDictionaryConfig: function(){
  197. MWF.xDesktop.requireApp("portal.PortalManager", "DictionaryExplorer", function(){
  198. //MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", function(){
  199. //if (!this.restActions) this.restActions = new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  200. if (!this.restActions) this.restActions = MWF.Actions.get("x_portal_assemble_designer");
  201. this.dictionaryConfigurator = new MWF.xApplication.portal.PortalManager.DictionaryExplorer(this.dictionaryConfiguratorContent, this.restActions);
  202. this.dictionaryConfigurator.app = this;
  203. this.dictionaryConfigurator.load();
  204. //}.bind(this));
  205. }.bind(this));
  206. },
  207. fileConfig: function(){
  208. this.clearContent();
  209. this.fileConfiguratorContent = new Element("div", {
  210. "styles": this.css.rightContentNode
  211. }).inject(this.node);
  212. this.loadFileConfig();
  213. },
  214. loadFileConfig: function(){
  215. MWF.xDesktop.requireApp("portal.PortalManager", "FileExplorer", function(){
  216. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  217. // if (!this.restActions) this.restActions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  218. this.restActions = MWF.Actions.get("x_portal_assemble_designer");
  219. this.fileConfigurator = new MWF.xApplication.portal.PortalManager.FileExplorer(this.fileConfiguratorContent, this.restActions);
  220. this.fileConfigurator.app = this;
  221. this.fileConfigurator.load();
  222. //}.bind(this));
  223. }.bind(this));
  224. }
  225. });
  226. MWF.xApplication.portal.PortalManager.Menu = new Class({
  227. Extends: MWF.xApplication.process.ProcessManager.Menu,
  228. Implements: [Options, Events]
  229. });
  230. MWF.xApplication.portal.PortalManager.ApplicationProperty = new Class({
  231. Extends: MWF.xApplication.process.ProcessManager.ApplicationProperty,
  232. load: function(){
  233. this.app.restActions.getApplication(this.app.options.application.id, function(json){
  234. this.data = json.data;
  235. this.propertyTitleBar = new Element("div", {
  236. "styles": this.app.css.propertyTitleBar,
  237. "text": this.data.name
  238. }).inject(this.node);
  239. this.contentNode = new Element("div", {
  240. "styles": this.app.css.propertyContentNode
  241. }).inject(this.node);
  242. this.contentAreaNode = new Element("div", {
  243. "styles": this.app.css.propertyContentAreaNode
  244. }).inject(this.contentNode);
  245. this.setContentHeight();
  246. this.setContentHeightFun = this.setContentHeight.bind(this);
  247. this.app.addEvent("resize", this.setContentHeightFun);
  248. MWF.require("MWF.widget.ScrollBar", function(){
  249. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  250. }.bind(this));
  251. this.baseActionAreaNode = new Element("div", {
  252. "styles": this.app.css.baseActionAreaNode
  253. }).inject(this.contentAreaNode);
  254. this.baseActionNode = new Element("div", {
  255. "styles": this.app.css.propertyInforActionNode
  256. }).inject(this.baseActionAreaNode);
  257. this.baseTextNode = new Element("div", {
  258. "styles": this.app.css.baseTextNode,
  259. "text": this.app.lp.application.property
  260. }).inject(this.baseActionAreaNode);
  261. this.createEditBaseNode();
  262. this.createPropertyContentNode();
  263. this.createIconContentNode();
  264. this.createAvailableNode();
  265. this.createControllerListNode();
  266. this.createCornerMarkNode();
  267. // this.createMaintainerNode();
  268. }.bind(this));
  269. },
  270. createCornerMarkNode: function(){
  271. var lp = this.app.lp.application;
  272. this.cornerMarkTitleNode = new Element("div", {
  273. "styles": this.app.css.availableTitleNode,
  274. "text": lp.cornerMark
  275. }).inject(this.contentAreaNode);
  276. this.cornerMarkContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  277. new Element("div", {
  278. styles: this.app.css.noteNode,
  279. text: lp.cornerMarkNote
  280. }).inject( this.cornerMarkContentNode );
  281. this.cornerMarkItemsContentNode = new Element("div", {"styles": this.app.css.availableItemsContentNode}).inject(this.cornerMarkContentNode);
  282. this.cornerMarkLeftNode = new Element("div", {"styles": {
  283. "width": "calc( 100% - 260px )",
  284. "float": "left"
  285. }}).inject(this.cornerMarkItemsContentNode);
  286. MWF.require("MWF.widget.ScriptArea", null, false);
  287. this.cornerMarkScriptArea = new MWF.widget.ScriptArea(this.cornerMarkLeftNode, {
  288. "type": "service",
  289. "api": "../api/index.html#module-print",
  290. "title": lp.cornerMarkScript,
  291. //"isload" : true,
  292. "isbind" : false,
  293. // "forceType": "ace",
  294. "maxObj": this.app.content,
  295. "onChange": function(){
  296. this.data.cornerMarkScriptText = this.cornerMarkScriptArea.toJson().code;
  297. this.app.restActions.saveApplication(this.data, function(json){}.bind(this));
  298. }.bind(this)
  299. // "onSave": function(){
  300. // this.data.cornerMarkScriptText = this.cornerMarkScriptArea.toJson().code;
  301. // this.app.restActions.saveApplication(this.data, function(json){}.bind(this));
  302. // }.bind(this),
  303. // "style": "formula"
  304. });
  305. this.app.addEvent("resize", function () {
  306. if(this.cornerMarkScriptArea.jsEditor)this.cornerMarkScriptArea.jsEditor.resize();
  307. }.bind(this))
  308. debugger;
  309. var host = window.location.origin;
  310. if( !host )host = window.location.protocol + "//" + window.location.host;
  311. var defaultText = "/********************\n" +
  312. "this.currentPerson; //当前用户对象,如:{\"distinguishedName\":\"张三@zhangsan@P\",\"unique\":\"zhangsan\",\"name\":\"张三\"}\n" +
  313. "this.org; //组织快速访问方法\n" +
  314. "return 10; //返回结果\n" +
  315. "API Document: "+ host +"/api\n" +
  316. "示例:角标显示当前人的待办总数\n" +
  317. "var json = this.Actions.load(\"x_processplatform_assemble_surface\").TaskAction.manageListFilterPaging(1, 1, {\"credentialList\": [this.currentPerson.distinguishedName]})\n" +
  318. "return json.count;\n"+
  319. "********************/";
  320. var v = this.data.cornerMarkScriptText || defaultText;
  321. this.cornerMarkScriptArea.load({code: v});
  322. this.cornerMarkRightNode = new Element("div", {"styles": {
  323. "width": "260px",
  324. "margin-left": "calc( 100% - 260px )"
  325. }}).inject(this.cornerMarkItemsContentNode);
  326. this.selectScriptArea = new Element("div", {
  327. styles: this.app.css.selectScriptArea
  328. }).inject( this.cornerMarkRightNode );
  329. this.selectScriptNode = new Element("div", {
  330. text: this.data.cornerMarkScript ? "" : lp.selectScriptNote,
  331. styles: {color: "#aaa"}
  332. }).inject(this.selectScriptArea);
  333. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  334. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(this.selectScriptNode, this.app, {
  335. "title" : lp.selectScript,
  336. "type": "script",
  337. "selectorOptions":{
  338. "appType" : ["portal"],
  339. "applications": [this.app.options.application.id]
  340. },
  341. "count" : 1,
  342. "names": this.data.cornerMarkScript ? [ {
  343. appId: this.app.options.application.id,
  344. name : this.data.cornerMarkScript,
  345. alias: "",
  346. applicationName: this.data.name,
  347. appType: "portal"
  348. } ] : [],
  349. "onChange": function ( arr ) {
  350. if( arr && arr.length ){
  351. this.data.cornerMarkScript = arr[0].data.name;
  352. }else{
  353. this.data.cornerMarkScript = "";
  354. }
  355. this.app.restActions.saveApplication(this.data, function(json){}.bind(this));
  356. }.bind(this)
  357. });
  358. }.bind(this));
  359. this.cornerMarkActionAreaNode = new Element("div", {"styles": this.app.css.cornerMarkActionAreaNode }).inject(this.cornerMarkRightNode);
  360. var executeAction = new Element("div", {
  361. "styles": this.app.css.cornerMarkButton,
  362. "text": lp.run
  363. }).inject(this.cornerMarkActionAreaNode);
  364. executeAction.addEvent("click", function(){
  365. o2.Actions.load("x_portal_assemble_surface").PortalAction.getCornerMark(this.data.id, function (json) {
  366. var result = "";
  367. try{
  368. result = JSON.stringify(json, null, 4);
  369. }catch (e) {}
  370. this.cornerMarkResultNode.set("text",result);
  371. }.bind(this), function (xhr) {
  372. var result;
  373. try{
  374. result = JSON.stringify(xhr.responseText, null, 4);
  375. }catch (e) {
  376. result = xhr.responseText;
  377. }
  378. this.cornerMarkResultNode.set("text",result);
  379. }.bind(this))
  380. }.bind(this));
  381. var logAction = new Element("div", {
  382. "styles": this.app.css.cornerMarkButton,
  383. "text": lp.openLogView
  384. }).inject(this.cornerMarkActionAreaNode);
  385. logAction.addEvent("click", function(){
  386. layout.openApplication(null, "LogViewer");
  387. }.bind(this));
  388. new Element("div", {
  389. styles: this.app.css.cornerMarkExecuteNoteNode,
  390. text: lp.runResult
  391. }).inject( this.cornerMarkRightNode );
  392. this.cornerMarkResultNode = new Element("div", {
  393. style: "white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; height: auto; overflow:auto; margin-left:10px;"
  394. }).inject( this.cornerMarkRightNode );
  395. },
  396. createPropertyContentNode: function(){
  397. this.propertyContentNode = new Element("div", {"styles": {
  398. "overflow": "hidden",
  399. "-webkit-user-select": "text",
  400. "-moz-user-select": "text"
  401. }}).inject(this.contentAreaNode);
  402. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  403. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  404. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  405. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  406. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  407. html += "<tr><td class='formTitle'>"+this.app.lp.application.firstPage+"</td><td id='formApplicationFirstPage'></td></tr>";
  408. html += "<tr><td class='formTitle'>"+this.app.lp.application.pcClient+"</td><td id='formApplicationPcClient'></td></tr>";
  409. html += "<tr><td class='formTitle'>"+this.app.lp.application.mobileClient+"</td><td id='formApplicationMobileClient'></td></tr>";
  410. // html += "<tr><td class='formTitle'>"+this.app.lp.application.anonymousAccess+"</td><td id='formApplicationAnonymousAccess'></td></tr>";
  411. html += "<tr><td class='formTitle'>"+this.app.lp.application.id+"</td><td id='formApplicationId'></td></tr>";
  412. html += "<tr><td class='formTitle'>"+this.app.lp.application.url+"</td><td id='formApplicationUrl'></td></tr>";
  413. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  414. html += "</table>";
  415. this.propertyContentNode.set("html", html);
  416. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  417. this.nameInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  418. this.aliasInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  419. this.descriptionInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  420. this.typeInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.portalCategory, this.app.css.formInput);
  421. this.firstPageInput = new MWF.xApplication.portal.PortalManager.Select(this.propertyContentNode.getElement("#formApplicationFirstPage"), this.data.firstPage, this.app.css.formInput, function(){
  422. var pages = {};
  423. this.app.restActions.listPage(this.app.options.application.id, function(json){
  424. json.data.each(function(page) {
  425. pages[page.id] = page.name;
  426. }.bind(this));
  427. }.bind(this), null, false);
  428. return pages;
  429. }.bind(this));
  430. this.pcClientInput = new MWF.xApplication.portal.PortalManager.Radio(this.propertyContentNode.getElement("#formApplicationPcClient"), (this.data.pcClient!=undefined) ? this.data.pcClient.toString() : "true", this.app.css.formInput, function(){
  431. return {
  432. "true": this.app.lp.application.true,
  433. "false": this.app.lp.application.false
  434. };
  435. }.bind(this));
  436. this.mobileClientInput = new MWF.xApplication.portal.PortalManager.Radio(this.propertyContentNode.getElement("#formApplicationMobileClient"), (this.data.mobileClient!=undefined) ? this.data.mobileClient.toString():"true", this.app.css.formInput, function(){
  437. return {
  438. "true": this.app.lp.application.true,
  439. "false": this.app.lp.application.false
  440. };
  441. }.bind(this));
  442. // this.anonymousAccessInput = new MWF.xApplication.portal.PortalManager.Radio(
  443. // this.propertyContentNode.getElement("#formApplicationAnonymousAccess"),
  444. // (this.data.anonymousAccess!=undefined) ? this.data.anonymousAccess.toString():"false",
  445. // this.app.css.formInput,
  446. // function(){
  447. // return {
  448. // "true": this.app.lp.application.true,
  449. // "false": this.app.lp.application.false
  450. // };
  451. // }.bind(this))
  452. // ;
  453. this.idInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationId"), this.data.id, this.app.css.formInput);
  454. var host = window.location.host;
  455. //var port = window.location.port;
  456. var par = '?id='+this.data.id;
  457. //var url = "http://"+host+(((!port || port==80) ? "" : ":"+port))+"../x_desktop/portal.html"+par;
  458. var url = "http://"+host+"/x_desktop/portal.html"+par;
  459. this.urlInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationUrl"), url, this.app.css.formInput);
  460. },
  461. editMode: function(){
  462. this.nameInput.editMode();
  463. this.aliasInput.editMode();
  464. this.descriptionInput.editMode();
  465. this.typeInput.editMode();
  466. this.firstPageInput.editMode();
  467. this.pcClientInput.editMode();
  468. this.mobileClientInput.editMode();
  469. // this.anonymousAccessInput.editMode();
  470. this.isEdit = true;
  471. },
  472. readMode: function(){
  473. this.nameInput.readMode();
  474. this.aliasInput.readMode();
  475. this.descriptionInput.readMode();
  476. this.typeInput.readMode();
  477. this.firstPageInput.readMode();
  478. this.pcClientInput.readMode();
  479. this.mobileClientInput.readMode();
  480. // this.anonymousAccessInput.readMode();
  481. this.isEdit = false;
  482. },
  483. save: function(callback, cancel) {
  484. this.data.name = this.nameInput.input.get("value");
  485. this.data.alias = this.aliasInput.input.get("value");
  486. this.data.description = this.descriptionInput.input.get("value");
  487. this.data.portalCategory = this.typeInput.input.get("value") || "";
  488. this.data.firstPage = this.firstPageInput.input.get("value");
  489. this.data.pcClient = this.pcClientInput.getValue()==="true";
  490. this.data.mobileClient = this.mobileClientInput.getValue()==="true";
  491. // this.data.anonymousAccess = this.anonymousAccessInput.getValue()==="true";
  492. this.app.restActions.saveApplication(this.data, function (json) {
  493. this.propertyTitleBar.set("text", this.data.name);
  494. this.data.id = json.data.id;
  495. this.nameInput.save();
  496. this.aliasInput.save();
  497. this.descriptionInput.save();
  498. this.typeInput.save();
  499. this.firstPageInput.save();
  500. this.pcClientInput.save();
  501. this.mobileClientInput.save();
  502. // this.anonymousAccessInput.save();
  503. if (callback) callback();
  504. }.bind(this), function (xhr, text, error) {
  505. if (cancel) cancel(xhr, text, error);
  506. }.bind(this));
  507. }
  508. });
  509. MWF.xApplication.portal.PortalManager.Input = new Class({
  510. Extends: MWF.xApplication.process.ProcessManager.Input,
  511. Implements: [Events]
  512. });
  513. MWF.xApplication.portal.PortalManager.Select = new Class({
  514. Extends: MWF.xApplication.portal.PortalManager.Input,
  515. Implements: [Events],
  516. initialize: function(node, value, style, select){
  517. this.node = $(node);
  518. this.value = (value) ? value: "";
  519. this.style = style;
  520. this.select = select;
  521. this.selectList = null;
  522. this.load();
  523. },
  524. getSelectList: function(){
  525. if (this.select){
  526. return this.select();
  527. }
  528. return [];
  529. },
  530. getText: function(value){
  531. if (value){
  532. if (this.selectList){
  533. return this.selectList[value] || "";
  534. }
  535. }
  536. return "";
  537. },
  538. load: function(){
  539. this.selectList = this.getSelectList();
  540. this.content = new Element("div", {
  541. "styles": this.style.content,
  542. "text": this.getText(this.value)
  543. }).inject(this.node);
  544. },
  545. editMode: function(){
  546. this.content.empty();
  547. this.input = new Element("select",{
  548. //"styles": this.style.input,
  549. //"value": this.value
  550. }).inject(this.content);
  551. Object.each(this.selectList, function(v, k){
  552. new Element("option", {
  553. "value": k,
  554. "text": v,
  555. "selected": (this.value==k)
  556. }).inject(this.input);
  557. }.bind(this));
  558. //this.input.addEvents({
  559. // //"focus": function(){
  560. // // this.input.setStyles(this.style.input_focus);
  561. // //}.bind(this),
  562. // //"blur": function(){
  563. // // this.input.setStyles(this.style.input);
  564. // //}.bind(this),
  565. // //"change": function(){
  566. // // this.input.setStyles(this.style.input);
  567. // //}.bind(this)
  568. //});
  569. },
  570. readMode: function(){
  571. this.content.empty();
  572. this.input = null;
  573. this.content.set("text", this.getText(this.value));
  574. },
  575. save: function(){
  576. if (this.input && this.input.options && this.input.options.length) {
  577. this.value = this.input.options[this.input.selectedIndex].get("value");
  578. }else{
  579. this.value = "";
  580. }
  581. return this.value;
  582. }
  583. });
  584. MWF.xApplication.portal.PortalManager.Radio = new Class({
  585. Extends: MWF.xApplication.portal.PortalManager.Select,
  586. editMode: function(){
  587. this.content.empty();
  588. var name = Math.random();
  589. Object.each(this.selectList, function(v, k){
  590. var input = new Element("input", {
  591. "type": "radio",
  592. "name": "rd"+name,
  593. "value": k,
  594. "checked": (this.value===k)
  595. }).inject(this.content);
  596. input.appendHTML(v, "after");
  597. }.bind(this));
  598. },
  599. getValue: function(){
  600. var radios = this.content.getElements("input");
  601. for (var i=0; i<radios.length; i++){
  602. if (radios[i].checked){
  603. this.value = radios[i].value;
  604. break;
  605. }
  606. }
  607. return this.value;
  608. },
  609. save: function(){
  610. var radios = this.content.getElements("input");
  611. for (var i=0; i<radios.length; i++){
  612. if (radios[i].checked){
  613. this.value = radios[i].value;
  614. break;
  615. }
  616. }
  617. return this.value;
  618. }
  619. });