Main.js 29 KB

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