Main.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. MWF.xDesktop.requireApp("portal.PortalManager", "package", null, false);
  2. MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  4. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  5. MWF.require("MWF.widget.Identity", null,false);
  6. MWF.xDesktop.requireApp("process.ProcessManager", "", null, false);
  7. MWF.xApplication.portal = MWF.xApplication.portal || {};
  8. MWF.xApplication.portal.PortalManager.Main = new Class({
  9. Extends: MWF.xApplication.process.ProcessManager.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "application": null,
  13. "style": "default",
  14. "name": "portal.PortalManager",
  15. "icon": "icon.png",
  16. "width": "1100",
  17. "height": "700",
  18. "title": MWF.xApplication.portal.PortalManager.LP.title
  19. },
  20. onQueryLoad: function(){
  21. this.lp = MWF.xApplication.portal.PortalManager.LP;
  22. this.currentContentNode = null;
  23. this.restActions = new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  24. },
  25. loadStartMenu: function(callback){
  26. this.startMenuNode = new Element("div", {
  27. "styles": this.css.startMenuNode
  28. }).inject(this.node);
  29. this.menu = new MWF.xApplication.portal.PortalManager.Menu(this, this.startMenuNode, {
  30. "onPostLoad": function(){
  31. if (this.status){
  32. if (this.status.navi!=null){
  33. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  34. }else{
  35. this.menu.doAction(this.menu.startNavis[0]);
  36. }
  37. }else{
  38. this.menu.doAction(this.menu.startNavis[0]);
  39. }
  40. }.bind(this)
  41. });
  42. this.addEvent("resize", function(){
  43. if (this.menu) this.menu.onResize();
  44. }.bind(this));
  45. },
  46. clearContent: function(){
  47. if (this.pageConfiguratorContent){
  48. if (this.pageConfigurator) delete this.pageConfigurator;
  49. this.pageConfiguratorContent.destroy();
  50. this.pageConfiguratorContent = null;
  51. }
  52. if (this.menuConfiguratorContent){
  53. if (this.menuConfigurator) delete this.menuConfigurator;
  54. this.menuConfiguratorContent.destroy();
  55. this.menuConfiguratorContent = null;
  56. }
  57. if (this.propertyConfiguratorContent){
  58. if (this.property) delete this.property;
  59. this.propertyConfiguratorContent.destroy();
  60. this.propertyConfiguratorContent = null;
  61. }
  62. if (this.sourceConfiguratorContent){
  63. if (this.sourceConfigurator) delete this.sourceConfigurator;
  64. this.sourceConfiguratorContent.destroy();
  65. this.sourceConfiguratorContent = null;
  66. }
  67. if (this.scriptConfiguratorContent){
  68. if (this.scriptConfigurator) delete this.scriptConfigurator;
  69. this.scriptConfiguratorContent.destroy();
  70. this.scriptConfiguratorContent = null;
  71. }
  72. },
  73. applicationProperty: function(){
  74. this.clearContent();
  75. this.propertyConfiguratorContent = new Element("div", {
  76. "styles": this.css.rightContentNode
  77. }).inject(this.node);
  78. this.property = new MWF.xApplication.portal.PortalManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  79. this.property.load();
  80. },
  81. pageConfig: function(){
  82. this.clearContent();
  83. this.pageConfiguratorContent = new Element("div", {
  84. "styles": this.css.rightContentNode
  85. }).inject(this.node);
  86. this.loadPageConfig();
  87. },
  88. loadPageConfig: function(){
  89. MWF.xDesktop.requireApp("portal.PortalManager", "PageExplorer", function(){
  90. this.pageConfigurator = new MWF.xApplication.portal.PortalManager.PageExplorer(this.pageConfiguratorContent, this.restActions);
  91. this.pageConfigurator.app = this;
  92. this.pageConfigurator.load();
  93. }.bind(this));
  94. },
  95. menuConfig: function(){
  96. this.clearContent();
  97. this.menuConfiguratorContent = new Element("div", {
  98. "styles": this.css.rightContentNode
  99. }).inject(this.node);
  100. this.loadMenuConfig();
  101. },
  102. loadMenuConfig: function(){
  103. MWF.xDesktop.requireApp("portal.PortalManager", "MenuExplorer", function(){
  104. MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", function(){
  105. if (!this.restActions) this.restActions = new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  106. this.menuConfigurator = new MWF.xApplication.portal.PortalManager.MenuExplorer(this.menuConfiguratorContent, this.restActions);
  107. this.menuConfigurator.app = this;
  108. this.menuConfigurator.load();
  109. }.bind(this));
  110. }.bind(this));
  111. },
  112. sourceConfig: function(){
  113. this.clearContent();
  114. this.sourceConfiguratorContent = new Element("div", {
  115. "styles": this.css.rightContentNode
  116. }).inject(this.node);
  117. this.loadSourceConfig();
  118. },
  119. loadSourceConfig: function(){
  120. MWF.xDesktop.requireApp("portal.PortalManager", "SourceExplorer", function(){
  121. this.sourceConfigurator = new MWF.xApplication.portal.PortalManager.SourceExplorer(this.sourceConfiguratorContent, this.restActions);
  122. this.sourceConfigurator.app = this;
  123. this.sourceConfigurator.load();
  124. }.bind(this));
  125. },
  126. scriptConfig: function(){
  127. this.clearContent();
  128. this.scriptConfiguratorContent = new Element("div", {
  129. "styles": this.css.rightContentNode
  130. }).inject(this.node);
  131. this.loadScriptConfig();
  132. },
  133. loadScriptConfig: function(){
  134. MWF.xDesktop.requireApp("portal.PortalManager", "ScriptExplorer", function(){
  135. MWF.xDesktop.requireApp("portal.PortalManager", "Actions.RestActions", function(){
  136. if (!this.restActions) this.restActions = new MWF.xApplication.portal.PortalManager.Actions.RestActions();
  137. this.scriptConfigurator = new MWF.xApplication.portal.PortalManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  138. this.scriptConfigurator.app = this;
  139. this.scriptConfigurator.load();
  140. }.bind(this));
  141. }.bind(this));
  142. }
  143. });
  144. MWF.xApplication.portal.PortalManager.Menu = new Class({
  145. Extends: MWF.xApplication.process.ProcessManager.Menu,
  146. Implements: [Options, Events]
  147. });
  148. MWF.xApplication.portal.PortalManager.ApplicationProperty = new Class({
  149. Extends: MWF.xApplication.process.ProcessManager.ApplicationProperty,
  150. createPropertyContentNode: function(){
  151. this.propertyContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  152. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  153. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  154. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  155. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  156. html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  157. html += "<tr><td class='formTitle'>"+this.app.lp.application.firstPage+"</td><td id='formApplicationFirstPage'></td></tr>";
  158. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  159. html += "</table>";
  160. this.propertyContentNode.set("html", html);
  161. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  162. this.nameInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  163. this.aliasInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  164. this.descriptionInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  165. this.typeInput = new MWF.xApplication.portal.PortalManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  166. this.firstPageInput = new MWF.xApplication.portal.PortalManager.Select(this.propertyContentNode.getElement("#formApplicationFirstPage"), this.data.firstPage, this.app.css.formInput, function(){
  167. var pages = {};
  168. debugger;
  169. this.app.restActions.listPage(this.app.options.application.id, function(json){
  170. json.data.each(function(page) {
  171. pages[page.id] = page.name;
  172. }.bind(this));
  173. }.bind(this), null, false);
  174. return pages;
  175. }.bind(this));
  176. },
  177. editMode: function(){
  178. this.nameInput.editMode();
  179. this.aliasInput.editMode();
  180. this.descriptionInput.editMode();
  181. this.typeInput.editMode();
  182. this.firstPageInput.editMode();
  183. this.isEdit = true;
  184. },
  185. readMode: function(){
  186. this.nameInput.readMode();
  187. this.aliasInput.readMode();
  188. this.descriptionInput.readMode();
  189. this.typeInput.readMode();
  190. this.firstPageInput.readMode();
  191. this.isEdit = false;
  192. },
  193. save: function(callback, cancel) {
  194. this.data.name = this.nameInput.input.get("value");
  195. this.data.alias = this.aliasInput.input.get("value");
  196. this.data.description = this.descriptionInput.input.get("value");
  197. this.data.applicationCategory = this.typeInput.input.get("value");
  198. this.data.firstPage = this.firstPageInput.input.get("value");
  199. this.app.restActions.saveApplication(this.data, function (json) {
  200. this.propertyTitleBar.set("text", this.data.name);
  201. this.data.id = json.data.id;
  202. this.nameInput.save();
  203. this.aliasInput.save();
  204. this.descriptionInput.save();
  205. this.typeInput.save();
  206. this.firstPageInput.save();
  207. if (callback) callback();
  208. }.bind(this), function (xhr, text, error) {
  209. if (cancel) cancel(xhr, text, error);
  210. }.bind(this));
  211. }
  212. });
  213. MWF.xApplication.portal.PortalManager.Input = new Class({
  214. Extends: MWF.xApplication.process.ProcessManager.Input,
  215. Implements: [Events]
  216. });
  217. MWF.xApplication.portal.PortalManager.Select = new Class({
  218. Extends: MWF.xApplication.portal.PortalManager.Input,
  219. Implements: [Events],
  220. initialize: function(node, value, style, select){
  221. this.node = $(node);
  222. this.value = (value) ? value: "";
  223. this.style = style;
  224. this.select = select;
  225. this.selectList = null;;
  226. this.load();
  227. },
  228. getSelectList: function(){
  229. if (this.select){
  230. return this.select();
  231. }
  232. return [];
  233. },
  234. getText: function(value){
  235. if (value){
  236. if (this.selectList){
  237. return this.selectList[value] || "";
  238. }
  239. }
  240. return "";
  241. },
  242. load: function(){
  243. this.selectList = this.getSelectList();
  244. this.content = new Element("div", {
  245. "styles": this.style.content,
  246. "text": this.getText(this.value)
  247. }).inject(this.node);
  248. },
  249. editMode: function(){
  250. this.content.empty();
  251. this.input = new Element("select",{
  252. //"styles": this.style.input,
  253. //"value": this.value
  254. }).inject(this.content);
  255. Object.each(this.selectList, function(v, k){
  256. new Element("option", {
  257. "value": k,
  258. "text": v,
  259. "selected": (this.value==v)
  260. }).inject(this.input);
  261. }.bind(this));
  262. //this.input.addEvents({
  263. // //"focus": function(){
  264. // // this.input.setStyles(this.style.input_focus);
  265. // //}.bind(this),
  266. // //"blur": function(){
  267. // // this.input.setStyles(this.style.input);
  268. // //}.bind(this),
  269. // //"change": function(){
  270. // // this.input.setStyles(this.style.input);
  271. // //}.bind(this)
  272. //});
  273. },
  274. readMode: function(){
  275. this.content.empty();
  276. this.input = null;
  277. this.content.set("text", this.getText(this.value));
  278. },
  279. save: function(){
  280. if (this.input) this.value = this.input.options[this.input.selectedIndex].get("value");
  281. return this.value;
  282. }
  283. });