Main.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "package", null, false);
  2. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  4. MWF.xDesktop.requireApp("Selector", "package", null, false);
  5. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  6. MWF.require("MWF.widget.O2Identity", null,false);
  7. MWF.xApplication.cms.ColumnManager.Main = new Class({
  8. Extends: MWF.xApplication.Common.Main,
  9. Implements: [Options, Events],
  10. options: {
  11. "column": null,
  12. "application" : null,
  13. "style": "default",
  14. "name": "cms.ColumnManager",
  15. "icon": "icon.png",
  16. "width": "1100",
  17. "height": "700",
  18. "title": MWF.xApplication.cms.ColumnManager.LP.title,
  19. "currentCategoryId" : ""
  20. },
  21. onQueryLoad: function(){
  22. if(this.options.column)this.options.column.icon = this.options.column.appIcon;
  23. if(!this.options.application) this.options.application = this.options.column;
  24. this.lp = MWF.xApplication.cms.ColumnManager.LP;
  25. this.currentContentNode = null;
  26. },
  27. findDesigner: function(){
  28. this.options.column.moduleType = "cms";
  29. this.options.column.name = this.options.column.appName;
  30. //this.options.column.id = this.options.column.appId;
  31. var options = {
  32. "filter": {
  33. "moduleList": ["cms"],
  34. "appList": [this.options.column]
  35. }
  36. };
  37. layout.openApplication(null, "FindDesigner", options);
  38. },
  39. loadApplication: function(callback){
  40. this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  41. if (this.status && !this.options.currentCategoryId ){
  42. if( this.status.categoryId ){
  43. this.options.currentCategoryId = this.status.categoryId;
  44. }
  45. }
  46. this.getColumn(function(){
  47. this.setTitle( this.options.column.appName +this.lp.setting );
  48. this.loadController(function(){
  49. if( !this.isAdmin ){
  50. this.notice( MWF.CMSCM.LP.noAdministratorAccess , "error");
  51. this.close();
  52. }else{
  53. this.createNode();
  54. this.loadApplicationContent();
  55. if (window.clipboardData){
  56. this.addKeyboardEvents();
  57. }else{
  58. this.keyCopyItemsFun = this.keyCopyItems.bind(this);
  59. this.keyPasteItemsFun = this.keyPasteItems.bind(this);
  60. document.addEventListener('copy', this.keyCopyItemsFun);
  61. document.addEventListener('paste', this.keyPasteItemsFun);
  62. this.addEvent("queryClose", function(){
  63. if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  64. if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
  65. }.bind(this));
  66. }
  67. if (callback) callback();
  68. }
  69. }.bind(this))
  70. }.bind(this), function(){
  71. this.close();
  72. }.bind(this));
  73. },
  74. addKeyboardEvents: function(){
  75. this.addEvent("copy", function(){
  76. this.keyCopyItems();
  77. }.bind(this));
  78. this.addEvent("paste", function(){
  79. this.keyPasteItems();
  80. }.bind(this));
  81. },
  82. keyCopyItems: function(e){
  83. var app = layout.desktop.currentApp || layout.desktop.app;
  84. if (app && app.appId===this.appId){
  85. //if (this.categoryConfigurator && this.categoryConfigurator.isActive ){
  86. // this.categoryConfigurator.keyCopy(e);
  87. //}
  88. if (this.formConfigurator) {
  89. this.formConfigurator.keyCopy(e);
  90. if (e) e.preventDefault();
  91. }
  92. if (this.viewConfigurator){
  93. this.viewConfigurator.keyCopy(e);
  94. if (e) e.preventDefault();
  95. }
  96. if (this.dataConfigurator){
  97. this.dataConfigurator.keyCopy(e);
  98. if (e) e.preventDefault();
  99. }
  100. if (this.scriptConfigurator){
  101. this.scriptConfigurator.keyCopy(e);
  102. if (e) e.preventDefault();
  103. }
  104. }
  105. },
  106. keyPasteItems: function(e){
  107. var app = layout.desktop.currentApp || layout.desktop.app;
  108. if (app && app.appId===this.appId) {
  109. //if (this.categoryConfigurator && this.categoryConfigurator.isActive ){
  110. // this.categoryConfigurator.keyPaste(e);
  111. //}
  112. if (this.formConfigurator) {
  113. this.formConfigurator.keyPaste(e);
  114. }
  115. if (this.viewConfigurator){
  116. this.viewConfigurator.keyPaste(e);
  117. }
  118. if (this.dataConfigurator){
  119. this.dataConfigurator.keyPaste(e);
  120. }
  121. if (this.scriptConfigurator){
  122. this.scriptConfigurator.keyPaste(e);
  123. }
  124. }
  125. },
  126. loadController: function(callback){
  127. //this.controllers = [];
  128. //this.restActions.listColumnController(this.options.column.id, function( json ){
  129. // json.data = json.data || [];
  130. // json.data.each(function(item){
  131. // this.controllers.push(item.adminUid)
  132. // }.bind(this));
  133. // this.isAdmin = MWF.AC.isCMSManager() || this.controllers.contains(layout.desktop.session.user.distinguishedName);
  134. // if(callback)callback(this.isAdmin);
  135. //}.bind(this));
  136. this.restActions.isAppInfoManager(this.options.column.id, function( json ){
  137. this.isAdmin = MWF.AC.isCMSManager() || json.data.value;
  138. if(callback)callback(this.isAdmin);
  139. }.bind(this));
  140. },
  141. getColumn: function(success, failure){
  142. // if( this.options.column && o2.typeOf(this.options.column)==="object" ){
  143. // // if (success) success();
  144. // // return;
  145. // // }
  146. var columnId;
  147. if( this.options.column && o2.typeOf(this.options.column)==="object" ){
  148. columnId = this.options.column.id;
  149. }
  150. if( !columnId )columnId = this.options.columnId;
  151. if( !columnId )columnId = this.status && this.status.column;
  152. if( !columnId ){
  153. if (failure) failure();
  154. return;
  155. }
  156. this.restActions.getColumn(columnId, function(json){
  157. if (json.data){
  158. this.options.column = json.data;
  159. this.options.application = json.data;
  160. if (success) success();
  161. }else{
  162. if (failure) failure();
  163. }
  164. }.bind(this), function(){if (failure) failure();}.bind(this), false)
  165. },
  166. loadApplicationContent: function(){
  167. this.loadStartMenu();
  168. this.loadApplicationLayout();
  169. },
  170. createNode: function(){
  171. this.content.setStyle("overflow", "hidden");
  172. this.node = new Element("div", {
  173. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  174. }).inject(this.content);
  175. },
  176. loadApplicationLayout: function(){
  177. // this.topMenuNode = new Element("div").inject(this.node);
  178. // MWF.require("MWF.widget.Toolbar", function(){
  179. // this.toobar = new MWF.widget.Toolbar(this.topMenuNode);
  180. // this.toobar.load();
  181. // alert("ok")
  182. // }.bind(this));
  183. },
  184. setIcon : function( icon ){
  185. if (icon){
  186. this.leftTitleIconNode.setStyle("background-image", "url(data:image/png;base64,"+icon+")");
  187. }else{
  188. this.leftTitleIconNode.setStyle("background-image", "url("+"../x_component_cms_Column/$Main/default/icon/column.png)");
  189. }
  190. },
  191. loadStartMenu: function(callback){
  192. this.leftContentNode = new Element("div", {
  193. "styles": this.css.leftContentNode
  194. }).inject(this.node);
  195. this.leftTitleNode = new Element("div", {
  196. "styles": this.css.leftTitleNode
  197. }).inject(this.leftContentNode);
  198. this.leftTitleIconNode = new Element("div", {
  199. "styles": this.css.leftTitleIconNode
  200. }).inject(this.leftTitleNode);
  201. if (this.options.column){
  202. var icon = this.options.column.icon || this.options.column.appIcon;
  203. if (icon){
  204. this.leftTitleIconNode.setStyle("background-image", "url(data:image/png;base64,"+icon+")");
  205. }else{
  206. this.leftTitleIconNode.setStyle("background-image", "url("+"../x_component_cms_Column/$Main/default/icon/column.png)");
  207. }
  208. }
  209. this.leftTitleTextNode = new Element("div", {
  210. "styles": this.css.leftTitleTextNode,
  211. "text" : this.options.column.appName + this.lp.setting,
  212. "title" : this.options.column.appName + this.lp.setting
  213. }).inject(this.leftTitleNode);
  214. this.startMenuNode = new Element("div", {
  215. "styles": this.css.normalStartMenuNode
  216. }).inject(this.leftContentNode);
  217. this.menu = new MWF.xApplication.cms.ColumnManager.Menu(this, this.startMenuNode, {
  218. "onPostLoad": function(){
  219. var defaultId = "categoryConfig";
  220. if (this.status){
  221. if (this.status.navi!=null && this.menu.itemObject[this.status.navi]){
  222. this.menu.doAction(this.menu.itemObject[this.status.navi]);
  223. }else{
  224. this.menu.doAction(this.menu.itemObject[defaultId]);
  225. }
  226. }else{
  227. this.menu.doAction(this.menu.startNavis[0]);
  228. }
  229. }.bind(this)
  230. });
  231. //this.addEvent("resize", function(){
  232. // if (this.menu) this.menu.onResize();
  233. //}.bind(this));
  234. },
  235. clearContent: function(){
  236. if (this.categoryConfiguratorContent){
  237. if (this.categoryConfigurator) this.categoryConfigurator.isActive = false;
  238. this.categoryConfiguratorContent.setStyle("display","none");
  239. //if (this.categoryConfigurator) delete this.categoryConfigurator;
  240. //this.categoryConfiguratorContent.destroy();
  241. //this.categoryConfiguratorContent = null;
  242. }
  243. if (this.formConfiguratorContent){
  244. if (this.formConfigurator) delete this.formConfigurator;
  245. this.formConfiguratorContent.destroy();
  246. this.formConfiguratorContent = null;
  247. }
  248. if (this.propertyConfiguratorContent){
  249. if (this.property) delete this.property;
  250. this.propertyConfiguratorContent.destroy();
  251. this.propertyConfiguratorContent = null;
  252. }
  253. if (this.dataConfiguratorContent){
  254. if (this.dataConfigurator) delete this.dataConfigurator;
  255. this.dataConfiguratorContent.destroy();
  256. this.dataConfiguratorContent = null;
  257. }
  258. if (this.scriptConfiguratorContent){
  259. if (this.scriptConfigurator) delete this.scriptConfigurator;
  260. this.scriptConfiguratorContent.destroy();
  261. this.scriptConfiguratorContent = null;
  262. }
  263. if (this.viewConfiguratorContent){
  264. if (this.viewConfigurator) delete this.viewConfigurator;
  265. this.viewConfiguratorContent.destroy();
  266. this.viewConfiguratorContent = null;
  267. }
  268. if (this.queryViewConfiguratorContent){
  269. if (this.queryViewConfigurator) delete this.queryViewConfigurator;
  270. this.queryViewConfiguratorContent.destroy();
  271. this.queryViewConfiguratorContent = null;
  272. }
  273. if (this.fileConfiguratorContent){
  274. if (this.queryViewConfigurator) delete this.fileConfiguratorContent;
  275. this.fileConfiguratorContent.destroy();
  276. this.fileConfiguratorContent = null;
  277. }
  278. },
  279. applicationProperty: function(){
  280. this.clearContent();
  281. this.propertyConfiguratorContent = new Element("div", {
  282. "styles": this.css.rightContentNode
  283. }).inject(this.node);
  284. this.property = new MWF.xApplication.cms.ColumnManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  285. this.property.load();
  286. },
  287. cagetoryConfig: function( noRefresh ){
  288. this.clearContent();
  289. if( this.categoryConfiguratorContent ) {
  290. this.categoryConfiguratorContent.setStyle("display","");
  291. if( this.menu.itemObject["categoryConfig"] ){
  292. this.menu.expend( this.menu.itemObject["categoryConfig"] );
  293. }
  294. this.categoryConfigurator.isActive = true;
  295. if(!noRefresh)this.categoryConfigurator.refresh();
  296. }else{
  297. this.categoryConfiguratorContent = new Element("div", {
  298. "styles": this.css.rightContentNode
  299. }).inject(this.node);
  300. this.loadCategoryConfig();
  301. }
  302. },
  303. loadCategoryConfig: function(){
  304. MWF.xDesktop.requireApp("cms.ColumnManager", "CategoryExplorer", function(){
  305. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  306. var navi = this.menu.itemObject.categoryConfig;
  307. var subNode = navi.retrieve( "subNode" );
  308. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  309. this.categoryConfigurator = new MWF.xApplication.cms.ColumnManager.CategoryExplorer(this.categoryConfiguratorContent, subNode, this.restActions, {
  310. "currentCategoryId" : this.options.currentCategoryId,
  311. "onPostLoadCategoryList" : function(){
  312. }.bind(this),
  313. "onPostClickSub" : function(){
  314. this.menu.cancelCurrentNavi();
  315. }.bind(this)
  316. });
  317. this.categoryConfigurator.isActive = true;
  318. this.categoryConfigurator.app = this;
  319. //this.categoryConfigurator.categoryScrollWrapNode = this.menu.naviNode;
  320. //this.categoryConfigurator.categoryScrollContentNode = this.menu.areaNode;
  321. this.categoryConfigurator.load();
  322. this.options.currentCategoryId = "";
  323. //}.bind(this));
  324. }.bind(this));
  325. },
  326. createCategory : function(){
  327. this.cagetoryConfig( true );
  328. if( this.categoryConfigurator ){
  329. this.categoryConfigurator.categoryList.newCategory();
  330. }
  331. },
  332. setCategory : function( categoryId ){
  333. this.cagetoryConfig( true );
  334. if( this.categoryConfigurator ){
  335. this.categoryConfigurator.categoryList.setCurrentCategoryById( categoryId );
  336. }
  337. },
  338. formConfig: function(){
  339. this.clearContent();
  340. this.formConfiguratorContent = new Element("div", {
  341. "styles": this.css.rightContentNode
  342. }).inject(this.node);
  343. this.loadFormConfig();
  344. },
  345. loadFormConfig: function(){
  346. MWF.xDesktop.requireApp("cms.ColumnManager", "FormExplorer", function(){
  347. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  348. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  349. var title = MWF.xApplication.cms.ColumnManager.LP.formSetting;
  350. this.formConfigurator = new MWF.xApplication.cms.ColumnManager.FormExplorer(this.formConfiguratorContent, this.restActions, { "title" : title });
  351. this.formConfigurator.app = this;
  352. this.formConfigurator.load();
  353. //}.bind(this));
  354. }.bind(this));
  355. },
  356. createForm : function(){
  357. if( this.formConfigurator ){
  358. this.formConfigurator._createElement();
  359. }else{
  360. MWF.xDesktop.requireApp("cms.ColumnManager", "FormExplorer", function(){
  361. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  362. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  363. this.formConfigurator = new MWF.xApplication.cms.ColumnManager.FormExplorer(this.formConfiguratorContent, this.restActions);
  364. this.formConfigurator.app = this;
  365. this.formConfigurator._createElement();
  366. //}.bind(this));
  367. }.bind(this));
  368. }
  369. },
  370. dataConfig: function(){
  371. this.clearContent();
  372. this.dataConfiguratorContent = new Element("div", {
  373. "styles": this.css.rightContentNode
  374. }).inject(this.node);
  375. this.loadDataConfig();
  376. },
  377. loadDataConfig: function(){
  378. MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", function(){
  379. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  380. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  381. var title = MWF.xApplication.cms.ColumnManager.LP.dataSetting;
  382. this.dataConfigurator = new MWF.xApplication.cms.ColumnManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions, { "title" : title });
  383. this.dataConfigurator.app = this;
  384. this.dataConfigurator.load();
  385. //}.bind(this));
  386. }.bind(this));
  387. },
  388. createDataConfig : function(){
  389. if( this.dataConfigurator ){
  390. this.dataConfigurator._createElement();
  391. }else{
  392. MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", function(){
  393. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  394. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  395. this.dataConfigurator = new MWF.xApplication.cms.ColumnManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions);
  396. this.dataConfigurator.app = this;
  397. this.dataConfigurator._createElement();
  398. //}.bind(this));
  399. }.bind(this));
  400. }
  401. },
  402. scriptConfig: function(){
  403. this.clearContent();
  404. this.scriptConfiguratorContent = new Element("div", {
  405. "styles": this.css.rightContentNode
  406. }).inject(this.node);
  407. this.loadScriptConfig();
  408. },
  409. loadScriptConfig: function(){
  410. MWF.xDesktop.requireApp("cms.ColumnManager", "ScriptExplorer", function(){
  411. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  412. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  413. var title = MWF.xApplication.cms.ColumnManager.LP.scriptSetting;
  414. this.scriptConfigurator = new MWF.xApplication.cms.ColumnManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions, { "title" : title });
  415. this.scriptConfigurator.app = this;
  416. this.scriptConfigurator.load();
  417. //}.bind(this));
  418. }.bind(this));
  419. },
  420. createScriptConfig : function(){
  421. if( this.scriptConfigurator ){
  422. this.scriptConfigurator._createElement();
  423. }else{
  424. MWF.xDesktop.requireApp("cms.ColumnManager", "ScriptExplorer", function(){
  425. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  426. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  427. this.scriptConfigurator = new MWF.xApplication.cms.ColumnManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  428. this.scriptConfigurator.app = this;
  429. this.scriptConfigurator._createElement();
  430. //}.bind(this));
  431. }.bind(this));
  432. }
  433. },
  434. viewConfig: function(){
  435. this.clearContent();
  436. this.viewConfiguratorContent = new Element("div", {
  437. "styles": this.css.rightContentNode
  438. }).inject(this.node);
  439. this.loadViewConfig();
  440. },
  441. loadViewConfig: function(){
  442. MWF.xDesktop.requireApp("cms.ColumnManager", "ViewExplorer", function(){
  443. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  444. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  445. var title = MWF.xApplication.cms.ColumnManager.LP.listSetting;
  446. this.viewConfigurator = new MWF.xApplication.cms.ColumnManager.ViewExplorer(this.viewConfiguratorContent, this.restActions, { "title" : title });
  447. this.viewConfigurator.app = this;
  448. this.viewConfigurator.load();
  449. //}.bind(this));
  450. }.bind(this));
  451. },
  452. createView : function(){
  453. if( this.viewConfigurator ){
  454. this.viewConfigurator._createElement();
  455. }else{
  456. MWF.xDesktop.requireApp("cms.ColumnManager", "ViewExplorer", function(){
  457. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  458. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  459. this.viewConfigurator = new MWF.xApplication.cms.ColumnManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  460. this.viewConfigurator.app = this;
  461. this.viewConfigurator._createElement();
  462. //}.bind(this));
  463. }.bind(this));
  464. }
  465. },
  466. queryViewConfig: function(){
  467. this.clearContent();
  468. this.queryViewConfiguratorContent = new Element("div", {
  469. "styles": this.css.rightContentNode
  470. }).inject(this.node);
  471. this.loadQueryViewConfig();
  472. },
  473. loadQueryViewConfig: function(){
  474. MWF.xDesktop.requireApp("cms.ColumnManager", "QueryViewExplorer", function(){
  475. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  476. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  477. var title = MWF.xApplication.cms.ColumnManager.LP.queryViewSetting;
  478. this.queryViewConfigurator = new MWF.xApplication.cms.ColumnManager.QueryViewExplorer(this.queryViewConfiguratorContent, this.restActions, { "title" : title });
  479. this.queryViewConfigurator.app = this;
  480. this.queryViewConfigurator.load();
  481. //}.bind(this));
  482. }.bind(this));
  483. },
  484. createQueryView : function(){
  485. if( this.queryViewConfigurator ){
  486. this.queryViewConfigurator._createElement();
  487. }else{
  488. MWF.xDesktop.requireApp("cms.ColumnManager", "QueryViewExplorer", function(){
  489. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  490. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  491. this.queryViewConfigurator = new MWF.xApplication.cms.ColumnManager.QueryViewExplorer(this.queryViewConfiguratorContent, this.restActions);
  492. this.queryViewConfigurator.app = this;
  493. this.queryViewConfigurator._createElement();
  494. // }.bind(this));
  495. }.bind(this));
  496. }
  497. },
  498. fileConfig: function(){
  499. this.clearContent();
  500. this.fileConfiguratorContent = new Element("div", {
  501. "styles": this.css.rightContentNode
  502. }).inject(this.node);
  503. this.loadFileConfig();
  504. },
  505. loadFileConfig: function(){
  506. MWF.xDesktop.requireApp("cms.ColumnManager", "FileExplorer", function(){
  507. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  508. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  509. var title = MWF.xApplication.cms.ColumnManager.LP.attachmentSetting;
  510. this.fileConfigurator = new MWF.xApplication.cms.ColumnManager.FileExplorer(this.fileConfiguratorContent, this.restActions, { "title" : title });
  511. this.fileConfigurator.app = this;
  512. this.fileConfigurator.load();
  513. //}.bind(this));
  514. }.bind(this));
  515. },
  516. createFileConfig : function(){
  517. if( this.fileConfigurator ){
  518. this.fileConfigurator._createElement();
  519. }else{
  520. MWF.xDesktop.requireApp("cms.ColumnManager", "QueryViewExplorer", function(){
  521. //MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  522. //if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  523. this.fileConfigurator = new MWF.xApplication.cms.ColumnManager.FileViewExplorer(this.fileConfiguratorContent, this.restActions);
  524. this.fileConfigurator.app = this;
  525. this.fileConfigurator._createElement();
  526. // }.bind(this));
  527. }.bind(this));
  528. }
  529. },
  530. //getCategoryCount: function(){
  531. // var size = this.categoryConfiguratorContent.getSize();
  532. // categoryCount = parseInt(size.x/182)+5;
  533. // return categoryCount;
  534. //},
  535. getCategoryCount: function(){
  536. if (this.categoryConfigurator){
  537. var size = this.categoryConfigurator.categoryNode.getSize();
  538. categoryCount = (parseInt(size.x/401)*parseInt(size.y/101))+10;
  539. return categoryCount;
  540. }
  541. return 20;
  542. },
  543. showContentNode: function(node){
  544. if (this.currentContentNode){
  545. // this.currentContentNode.setStyles({
  546. // "position": "absolute"
  547. // });
  548. this.currentContentNode.fade("hide");
  549. node.fade("show");
  550. node.setStyle("display", "node");
  551. this.currentContentNode = null;
  552. }
  553. node.setStyle("display", "block");
  554. node.fade("show");
  555. this.currentContentNode = node;
  556. },
  557. recordStatus: function(){
  558. var id = null;
  559. var categoryId = "";
  560. if (this.menu.currentNavi){
  561. var naviData = this.menu.currentNavi.retrieve( "naviData" );
  562. id = naviData.id;
  563. }
  564. if( id == "categoryConfig" ){
  565. if( this.categoryConfigurator && this.categoryConfigurator.categoryList ){
  566. var list = this.categoryConfigurator.categoryList;
  567. if( list.currentCategory && list.currentCategory.data ){
  568. categoryId = list.currentCategory.data.id;
  569. }
  570. }
  571. }
  572. return {
  573. "navi": id,
  574. "column": this.options.column.id,
  575. "categoryId" : categoryId
  576. };
  577. }
  578. //onResize: function() {
  579. // if (this.menu) this.menu.onResize();
  580. // }
  581. });
  582. MWF.xApplication.cms.ColumnManager.Menu = new Class({
  583. Implements: [Options, Events],
  584. initialize: function(app, node, options){
  585. this.setOptions(options);
  586. this.app = app;
  587. this.node = $(node);
  588. this.currentNavi = null;
  589. this.status = "start";
  590. this.startNavis = [];
  591. this.itemObject = {};
  592. //this.
  593. this.load();
  594. },
  595. load: function(){
  596. this.areaNode = new Element("div.startMenuAreaNode", this.app.css.startMenuAreaNode).inject( this.node );
  597. MWF.require("MWF.widget.ScrollBar", function(){
  598. new MWF.widget.ScrollBar(this.node, {
  599. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  600. });
  601. }.bind(this));
  602. var menuUrl = this.app.path+"startMenu.json";
  603. MWF.getJSON(menuUrl, function(json){
  604. json.each(function(navi){
  605. var naviNode = new Element("div", {
  606. "styles": this.app.css.startMenuNaviNode
  607. });
  608. naviNode.store("naviData", navi);
  609. if( navi.expand ){
  610. var expandNode = new Element("div", {
  611. "styles": this.app.css.startMenuExpandNode
  612. });
  613. expandNode.inject(naviNode);
  614. naviNode.store("expandNode", expandNode );
  615. }else{
  616. new Element("div", {
  617. "styles": this.app.css.startMenuEmptyNode
  618. }).inject(naviNode);
  619. }
  620. var iconNode = new Element("div", {
  621. "styles": this.app.css.startMenuIconNode
  622. }).inject(naviNode);
  623. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  624. naviNode.store("iconNode", iconNode );
  625. var textNode = new Element("div", {
  626. "styles": this.app.css.startMenuTextNode,
  627. "text": navi.title
  628. });
  629. textNode.inject(naviNode);
  630. if( navi.create ){
  631. var createNode = new Element("div", {
  632. "styles": this.app.css.startMenuCreateNode,
  633. "title" : MWF.xApplication.cms.ColumnManager.LP.new + navi.title
  634. });
  635. createNode.inject(naviNode);
  636. naviNode.store("createNode", createNode );
  637. createNode.addEvents({
  638. "click" : function(ev){
  639. this.obj.app[ this.navi.createAction ]();
  640. ev.stopPropagation();
  641. }.bind( { obj : this, navi : navi } ),
  642. "mouseover" : function(ev){
  643. if( this.obj.currentNavi == this.naviNode && !this.naviData.unselected ){
  644. this.createNode.setStyles( this.obj.app.css.startMenuCreateNode_current_over )
  645. }else{
  646. this.createNode.setStyles( this.obj.app.css.startMenuCreateNode_over )
  647. }
  648. }.bind({ obj : this, createNode : createNode, naviNode : naviNode , naviData : navi}),
  649. "mouseout" : function(ev){
  650. if( this.obj.currentNavi == this.naviNode && !this.naviData.unselected ){
  651. this.createNode.setStyles( this.obj.app.css.startMenuCreateNode_current )
  652. }else{
  653. this.createNode.setStyles( this.obj.app.css.startMenuCreateNode )
  654. }
  655. }.bind({ obj : this, createNode : createNode, naviNode : naviNode, naviData : navi })
  656. })
  657. }
  658. naviNode.inject(this.areaNode);
  659. if( navi.expand ){
  660. var subNode = new Element("div", {
  661. "styles": this.app.css.startMenuSubContentNode
  662. });
  663. subNode.inject(this.areaNode);
  664. naviNode.store("subNode", subNode );
  665. }
  666. this.startNavis.push(naviNode);
  667. this.itemObject[ navi.id ] = naviNode;
  668. this.setStartNaviEvent(naviNode, navi);
  669. //this.setNodeCenter(this.node);
  670. }.bind(this));
  671. //this.setStartMenuWidth();
  672. this.setContentSize();
  673. this.app.addEvent("resize", this.setContentSize.bind(this));
  674. this.fireEvent("postLoad");
  675. }.bind(this));
  676. },
  677. setStartNaviEvent: function(naviNode){
  678. var _self = this;
  679. naviNode.addEvents({
  680. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  681. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  682. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  683. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  684. "click": function(){
  685. //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
  686. _self.doAction.apply(_self, [this]);
  687. }
  688. });
  689. },
  690. expend : function( naviNode ){
  691. var isExpand = naviNode.retrieve("isExpand");
  692. if( !isExpand ){
  693. var expandNode = naviNode.retrieve("expandNode");
  694. expandNode.setStyles(this.app.css.startMenuCollapseNode);
  695. var subNode = naviNode.retrieve("subNode");
  696. subNode.setStyle( "display" , "" );
  697. naviNode.store("isExpand",true);
  698. }
  699. },
  700. collapse : function( naviNode ){
  701. var isExpand = naviNode.retrieve("isExpand");
  702. if( isExpand ){
  703. var expandNode = naviNode.retrieve("expandNode");
  704. expandNode.setStyles(this.app.css.startMenuExpandNode);
  705. var subNode = naviNode.retrieve("subNode");
  706. subNode.setStyle( "display" , "none" );
  707. naviNode.store("isExpand",false);
  708. }
  709. },
  710. cancelCurrentNavi: function(){
  711. if( this.currentNavi ){
  712. this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  713. var iconNode = this.currentNavi.retrieve("iconNode");
  714. var navi = this.currentNavi.retrieve("naviData");
  715. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  716. }
  717. },
  718. doAction: function( naviNode ){
  719. if( this.currentNavi && this.currentNavi == naviNode ){
  720. var navi = this.currentNavi.retrieve("naviData");
  721. if( navi.expand ){
  722. var isExpand = this.currentNavi.retrieve("isExpand");
  723. if( isExpand ){
  724. var expandNode = this.currentNavi.retrieve("expandNode");
  725. expandNode.setStyles(this.app.css.startMenuExpandNode);
  726. var subNode = this.currentNavi.retrieve("subNode");
  727. subNode.setStyle( "display" , "none" );
  728. this.currentNavi.store("isExpand",false);
  729. }else{
  730. var expandNode = this.currentNavi.retrieve("expandNode");
  731. expandNode.setStyles(this.app.css.startMenuCollapseNode);
  732. var subNode = this.currentNavi.retrieve("subNode");
  733. subNode.setStyle( "display" , "" );
  734. this.currentNavi.store("isExpand",true);
  735. }
  736. }
  737. return;
  738. }
  739. var naviNodeData = (naviNode) ? naviNode.retrieve("naviData") : null;
  740. if (this.currentNavi && (!naviNodeData || !naviNodeData.noSelect)){
  741. this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  742. var iconNode = this.currentNavi.retrieve("iconNode");
  743. var navi = this.currentNavi.retrieve("naviData");
  744. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  745. if( navi.expand ){
  746. var expandNode = this.currentNavi.retrieve("expandNode");
  747. expandNode.setStyles(this.app.css.startMenuExpandNode);
  748. var subNode = this.currentNavi.retrieve("subNode");
  749. subNode.setStyle( "display" , "none" );
  750. this.currentNavi.store("isExpand",false);
  751. }
  752. if( navi.create ){
  753. var createNode = this.currentNavi.retrieve("createNode");
  754. createNode.setStyles(this.app.css.startMenuCreateNode);
  755. }
  756. }
  757. if( naviNode ){
  758. //var navi = naviNode.retrieve("naviData");
  759. var navi = naviNodeData;
  760. var action = navi.action;
  761. if( !navi.unselected && !navi.noSelect ){
  762. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  763. var iconNode = naviNode.retrieve("iconNode");
  764. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.selectedIcon+")");
  765. }
  766. if( navi.expand ){
  767. if( !navi.unselected ){
  768. var expandNode = naviNode.retrieve("expandNode");
  769. expandNode.setStyles(this.app.css.startMenuCollapseNode_current);
  770. }else{
  771. var expandNode = naviNode.retrieve("expandNode");
  772. expandNode.setStyles(this.app.css.startMenuCollapseNode );
  773. }
  774. var subNode = naviNode.retrieve("subNode");
  775. subNode.setStyle( "display" , "" );
  776. naviNode.store("isExpand",true);
  777. }
  778. if( navi.create ){
  779. var createNode = naviNode.retrieve("createNode");
  780. if( !navi.unselected ){
  781. createNode.setStyles(this.app.css.startMenuCreateNode_current);
  782. }else{
  783. createNode.setStyles(this.app.css.startMenuCreateNode);
  784. }
  785. }
  786. if (this.app[action]) this.app[action].apply( this.app );
  787. }
  788. if (!navi || !navi.noSelect) this.currentNavi = naviNode;
  789. },
  790. setContentSize : function(){
  791. var size = this.app.content.getSize();
  792. this.node.setStyle("height", size.y - 82);
  793. }
  794. });
  795. MWF.xApplication.cms.ColumnManager.ApplicationProperty = new Class({
  796. initialize: function(app, node){
  797. this.app = app;
  798. this.node = $(node);
  799. this.data = this.app.options.application;
  800. if( typeOf(this.data.config) === "string" ){
  801. this.config = JSON.parse( this.data.config || {} );
  802. }else{
  803. this.config = Object.clone(this.data.config || {});
  804. }
  805. this.controllerData = [];
  806. this.controllerList = [];
  807. },
  808. load: function(){
  809. this.propertyTitleBar = new Element("div.propertyTitleBar", {
  810. "styles": this.app.css.propertyTitleBar,
  811. "text": MWF.xApplication.cms.ColumnManager.LP.appProperty //this.data.name || this.data.appName
  812. }).inject(this.node);
  813. this.contentNode = new Element("div.propertyContentNode", {
  814. "styles": this.app.css.propertyContentNode
  815. }).inject(this.node);
  816. this.contentAreaNode = new Element("div.propertyContentAreaNode", {
  817. "styles": this.app.css.propertyContentAreaNode
  818. }).inject(this.contentNode);
  819. this.setContentHeight();
  820. this.setContentHeightFun = this.setContentHeight.bind(this);
  821. this.app.addEvent("resize", this.setContentHeightFun);
  822. MWF.require("MWF.widget.ScrollBar", function(){
  823. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  824. }.bind(this));
  825. this.baseActionAreaNode = new Element("div.baseActionAreaNode", {
  826. "styles": this.app.css.baseActionAreaNode
  827. }).inject(this.contentAreaNode);
  828. this.baseActionNode = new Element("div.propertyInforActionNode", {
  829. "styles": this.app.css.propertyInforActionNode
  830. }).inject(this.baseActionAreaNode);
  831. this.baseTextNode = new Element("div.baseTextNode", {
  832. "styles": this.app.css.baseTextNode,
  833. "text": this.app.lp.application.property
  834. }).inject(this.baseActionAreaNode);
  835. this.createEditBaseNode();
  836. this.createPropertyContentNode();
  837. this.createIconContentNode();
  838. this.viewerContainer = new Element( "div").inject( this.contentAreaNode );
  839. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.ColumnViewerSetting", null, false);
  840. this.viewerSetting = new MWF.xApplication.cms.ColumnManager.ColumnViewerSetting( this.app,
  841. this.app.lp.application.viewerSetting, this.viewerContainer, {
  842. objectId : this.data.id
  843. }
  844. );
  845. this.viewerSetting.dataParent = this;
  846. this.viewerSetting.load();
  847. this.publisherContainer = new Element( "div").inject( this.contentAreaNode );
  848. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.ColumnPublisherSetting", null, false);
  849. this.publisherSetting = new MWF.xApplication.cms.ColumnManager.ColumnPublisherSetting( this.app,
  850. this.app.lp.application.publisherSetting, this.publisherContainer, {
  851. objectId : this.data.id
  852. }
  853. );
  854. this.publisherSetting.dataParent = this;
  855. this.publisherSetting.load();
  856. this.managerContainer = new Element( "div").inject( this.contentAreaNode );
  857. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.ColumnManagerSetting", null, false);
  858. this.viewerSetting = new MWF.xApplication.cms.ColumnManager.ColumnManagerSetting( this.app,
  859. this.app.lp.application.managerSetting, this.managerContainer, {
  860. objectId : this.data.id
  861. }
  862. );
  863. this.viewerSetting.dataParent = this;
  864. this.viewerSetting.load();
  865. },
  866. setContentHeight: function(){
  867. var size = this.app.content.getSize();
  868. var titleSize = this.propertyTitleBar.getSize();
  869. var y = size.y-titleSize.y;
  870. this.contentNode.setStyle("height", ""+y+"px");
  871. },
  872. createIconContentNode: function(){
  873. this.iconContentTitleNode = new Element("div.iconContentTitleNode", {
  874. "styles": this.app.css.iconContentTitleNode,
  875. "text": this.app.lp.application.icon
  876. }).inject(this.contentAreaNode);
  877. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  878. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  879. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  880. html += "</table>";
  881. this.iconContentNode.set("html", html);
  882. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  883. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  884. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  885. this.iconPreviewNode.setStyles({
  886. "height": "72px",
  887. "width": "72px",
  888. "float": "right"
  889. });
  890. var icon = this.data.icon || this.data.appIcon;
  891. if (icon){
  892. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+icon+") center center no-repeat");
  893. }else{
  894. this.iconPreviewNode.setStyle("background", "url("+"../x_component_cms_Column/$Main/default/icon/column.png) center center no-repeat")
  895. }
  896. var changeIconAction = new Element("div", {
  897. "styles": this.app.css.selectButtonStyle,
  898. "text": MWF.xApplication.cms.ColumnManager.LP.changeIcon
  899. }).inject(this.iconActionNode);
  900. changeIconAction.addEvent("click", function(){
  901. this.changeIcon();
  902. }.bind(this));
  903. },
  904. changeIcon: function(){
  905. if (!this.uploadFileAreaNode){
  906. this.uploadFileAreaNode = new Element("div");
  907. var html = "<input name=\"file\" type=\"file\"/>";
  908. this.uploadFileAreaNode.set("html", html);
  909. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  910. this.fileUploadNode.addEvent("change", function(){
  911. var files = fileNode.files;
  912. if (files.length){
  913. for (var i = 0; i < files.length; i++) {
  914. var file = files.item(i);
  915. var formData = new FormData();
  916. formData.append('file', file);
  917. //formData.append('name', file.name);
  918. //formData.append('folder', folderId);
  919. this.app.restActions.updataColumnIcon(this.data.id ,function(){
  920. this.app.restActions.getColumn(this.data.id, function(json){
  921. if (json.data){
  922. this.data = json.data;
  923. if (this.data.appIcon){
  924. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.appIcon+") center center no-repeat");
  925. this.app.setIcon(this.data.appIcon)
  926. }else{
  927. this.iconPreviewNode.setStyle("background", "url("+"../x_component_cms_Column/$Main/default/icon/category2.png) center center no-repeat")
  928. this.app.setIcon()
  929. }
  930. }
  931. }.bind(this), false)
  932. }.bind(this), null, formData, file);
  933. }
  934. }
  935. }.bind(this));
  936. }
  937. var fileNode = this.uploadFileAreaNode.getFirst();
  938. fileNode.click();
  939. },
  940. createPropertyContentNode: function(){
  941. var lp = MWF.xApplication.cms.ColumnManager.LP;
  942. this.propertyContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  943. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  944. html += "<tr><td class='formTitle'>"+this.app.lp.application.id +"</td><td id='formApplicationId' class='formValue'>"+this.data.id+"</td></tr>";
  945. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  946. html += "<tr><td class='formTitle'>"+this.app.lp.application.sign+"</td><td id='formApplicationAlias'></td></tr>"; //"+(this.data.alias||this.data.appAlias||'')+"
  947. html += "<tr><td class='formTitle'>"+this.app.lp.application.appType+"</td><td id='formApplicationAppType'></td></tr>";
  948. html += "<tr><td class='formTitle'>"+this.app.lp.application.documentType+"</td><td id='formApplicationType' class='formValue'>"+(this.data.documentType || lp.documentTypeSelectText[0] )+"</td></tr>";
  949. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  950. html += "<tr><td class='formTitle'>"+this.app.lp.application.sort+"</td><td id='formApplicationSort'></td></tr>";
  951. var flag = typeOf(this.config.ignoreTitle) === "boolean" ? this.config.ignoreTitle : false;
  952. html += "<tr><td class='formTitle'>"+this.app.lp.application.ignoreTitle+"</td><td id='formApplicationIgnoreTitle' class='formValue'>"+(flag ? lp.ignoreTitleSelectText[0] : lp.ignoreTitleSelectText[1] )+"</td></tr>";
  953. flag = typeOf(this.config.latest) === "boolean" ? this.config.latest : true;
  954. html += "<tr><td class='formTitle'>"+this.app.lp.application.latest+"</td><td id='formApplicationLatest' class='formValue'>"+(flag ? lp.checkDraftSelectText[0] : lp.checkDraftSelectText[1] )+"</td></tr>";
  955. flag = typeOf(this.data.allowWaitPublish) === "boolean" ? this.data.allowWaitPublish : false;
  956. html += "<tr><td class='formTitle'>"+this.app.lp.application.delayView+"</td><td id='formApplicationDelay' class='formValue'>"+(flag ? lp.showDelayDocumentSelectText[0] : lp.showDelayDocumentSelectText[1] )+"</td></tr>";
  957. flag = typeOf(this.data.showAllDocuments) === "boolean" ? this.data.showAllDocuments : true;
  958. html += "<tr><td class='formTitle'>"+this.app.lp.application.showAllDocumentViews+"</td><td id='showAllDocumentViews' class='formValue'>"+(flag ? lp.showAllDocumentSelectText[0] : lp.showAllDocumentSelectText[1] )+"</td></tr>";
  959. flag = typeOf(this.config.saveDraftOnClose) === "boolean" ? this.config.saveDraftOnClose : true;
  960. html += "<tr><td class='formTitle'>"+this.app.lp.application.saveDraftOnClose+"</td><td id='saveDraftOnClose' class='formValue'>"+(flag ? lp.saveDraftOnClose[0] : lp.saveDraftOnClose[1] )+"</td></tr>";
  961. // html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  962. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  963. html += "<tr><td class='formTitle'>"+this.app.lp.application.defaultEditForm+"</td><td class='formValue'><div id='formDefaultEditForm'></div><span style='color: #aaaaaa;'>"+this.app.lp.application.editformNote+"</span></td></tr>";
  964. html += "<tr><td class='formTitle'>"+this.app.lp.application.defaultReadForm+"</td><td class='formValue'><div id='formDefaultReadForm'></div><span style='color: #aaaaaa;'>"+this.app.lp.application.readformNote+"</span></td></tr>";
  965. html += "</table>";
  966. this.propertyContentNode.set("html", html);
  967. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  968. this.propertyContentNode.getElements("td.formValue").setStyles(this.app.css.propertyBaseContentTdValue);
  969. this.nameInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name || this.data.appName, this.app.css.formInput);
  970. this.aliasInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias || this.data.appAlias, this.app.css.formInput);
  971. this.appTypeInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationAppType"), this.data.appType || "", this.app.css.formInput);
  972. this.typeSelect = new MDomItem( this.propertyContentNode.getElement("#formApplicationType"), {
  973. type : "select",
  974. value : this.data.documentType || lp.documentTypeSelectValue[0],
  975. selectValue : lp.documentTypeSelectValue,
  976. selectText : lp.documentTypeSelectText
  977. });
  978. this.descriptionInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  979. this.sortInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationSort"), this.data.appInfoSeq, this.app.css.formInput);
  980. debugger;
  981. this.ignoreTitleSelect = new MDomItem( this.propertyContentNode.getElement("#formApplicationIgnoreTitle"), {
  982. type : "select",
  983. defaultValue : "false",
  984. value : ( typeOf(this.config.ignoreTitle) === "boolean" ? this.config.ignoreTitle : false ).toString(),
  985. selectValue : [ "true", "false" ],
  986. selectText : lp.ignoreTitleSelectText
  987. });
  988. this.latestSelect = new MDomItem( this.propertyContentNode.getElement("#formApplicationLatest"), {
  989. type : "select",
  990. defaultValue : "true",
  991. value : ( typeOf(this.config.latest) === "boolean" ? this.config.latest : true ).toString(),
  992. selectValue : [ "true", "false" ],
  993. selectText : lp.checkDraftSelectText
  994. });
  995. this.delaySelect = new MDomItem( this.propertyContentNode.getElement("#formApplicationDelay"), {
  996. type : "select",
  997. defaultValue : "true",
  998. value : ( typeOf(this.data.allowWaitPublish) === "boolean" ? this.data.allowWaitPublish : false ).toString(),
  999. selectValue : [ "true", "false" ],
  1000. selectText : lp.showDelayDocumentSelectText
  1001. });
  1002. this.allDocumentViewSelect = new MDomItem( this.propertyContentNode.getElement("#showAllDocumentViews"), {
  1003. type : "select",
  1004. defaultValue : "true",
  1005. value : ( typeOf(this.data.showAllDocuments) === "boolean" ? this.data.showAllDocuments : true ).toString(),
  1006. selectValue : [ "true", "false" ],
  1007. selectText : lp.showAllDocumentSelectText
  1008. });
  1009. this.saveDraftOnCloseSelect = new MDomItem( this.propertyContentNode.getElement("#saveDraftOnClose"), {
  1010. type : "select",
  1011. defaultValue : "false",
  1012. value : ( typeOf(this.config.saveDraftOnClose) === "boolean" ? this.config.saveDraftOnClose : true ).toString(),
  1013. selectValue : [ "true", "false" ],
  1014. selectText : lp.saveDraftOnClose
  1015. });
  1016. this.app.restActions.listForm(this.data.id, function(json){
  1017. var textList = [""];
  1018. var valueList = [""];
  1019. debugger;
  1020. json.data.each(function (form) {
  1021. textList.push(form.name);
  1022. valueList.push(form.id);
  1023. }.bind(this));
  1024. this.defaultEditForm = new MDomItem( this.propertyContentNode.getElement("#formDefaultEditForm"), {
  1025. type : "select",
  1026. value : this.data.defaultEditForm || "",
  1027. selectValue : valueList,
  1028. selectText : textList
  1029. });
  1030. this.defaultEditForm.readMode();
  1031. this.defaultReadForm = new MDomItem( this.propertyContentNode.getElement("#formDefaultReadForm"), {
  1032. type : "select",
  1033. value : this.data.defaultReadForm || "",
  1034. selectValue : valueList,
  1035. selectText : textList
  1036. });
  1037. this.defaultReadForm.readMode()
  1038. }.bind(this));
  1039. //this.typeInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  1040. },
  1041. createEditBaseNode: function(){
  1042. this.editBaseNode = new Element("button.editBaseNode", {
  1043. "styles": this.app.css.editBaseNode,
  1044. "text": this.app.lp.edit,
  1045. "events": {"click": this.editBaseInfor.bind(this)}
  1046. }).inject(this.baseActionNode);
  1047. },
  1048. createCancelBaseNode: function(){
  1049. this.cancelBaseNode = new Element("button.cancelBaseNode", {
  1050. "styles": this.app.css.cancelBaseNode,
  1051. "text": this.app.lp.cancel,
  1052. "events": {"click": this.cancelBaseInfor.bind(this)}
  1053. }).inject(this.baseActionNode);
  1054. },
  1055. createSaveBaseNode: function(){
  1056. this.saveBaseNode = new Element("button.saveBaseNode", {
  1057. "styles": this.app.css.saveBaseNode,
  1058. "text": this.app.lp.save,
  1059. "events": {"click": this.saveBaseInfor.bind(this)}
  1060. }).inject(this.baseActionNode);
  1061. },
  1062. editBaseInfor: function(){
  1063. this.baseActionNode.empty();
  1064. this.editBaseNode = null;
  1065. this.createCancelBaseNode();
  1066. this.createSaveBaseNode();
  1067. this.editMode();
  1068. },
  1069. editMode: function(){
  1070. this.nameInput.editMode();
  1071. this.aliasInput.editMode();
  1072. this.appTypeInput.editMode();
  1073. this.descriptionInput.editMode();
  1074. this.sortInput.editMode();
  1075. this.typeSelect.editMode();
  1076. this.latestSelect.editMode();
  1077. this.delaySelect.editMode();
  1078. this.ignoreTitleSelect.editMode();
  1079. this.allDocumentViewSelect.editMode();
  1080. this.saveDraftOnCloseSelect.editMode();
  1081. this.defaultEditForm.editMode();
  1082. this.defaultReadForm.editMode();
  1083. //this.typeInput.editMode();
  1084. this.isEdit = true;
  1085. },
  1086. readMode: function(){
  1087. this.nameInput.readMode();
  1088. this.aliasInput.readMode();
  1089. this.appTypeInput.readMode();
  1090. this.descriptionInput.readMode();
  1091. this.sortInput.readMode();
  1092. this.typeSelect.readMode();
  1093. this.latestSelect.readMode();
  1094. this.delaySelect.readMode();
  1095. this.ignoreTitleSelect.readMode();
  1096. this.allDocumentViewSelect.readMode();
  1097. this.saveDraftOnCloseSelect.readMode();
  1098. this.defaultEditForm.readMode();
  1099. this.defaultReadForm.readMode();
  1100. //this.typeInput.readMode();
  1101. this.isEdit = false;
  1102. },
  1103. cancelBaseInfor: function(){
  1104. if (this.data.name || this.data.appName || this.data.id ){
  1105. this.baseActionNode.empty();
  1106. this.cancelBaseNode = null;
  1107. this.saveBaseNode = null;
  1108. this.createEditBaseNode();
  1109. this.readMode();
  1110. }else{
  1111. this.destroy();
  1112. }
  1113. },
  1114. saveBaseInfor: function(){
  1115. if (!this.nameInput.input.get("value")){
  1116. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  1117. return false;
  1118. }
  1119. //this.node.mask({
  1120. // "style": {
  1121. // "opacity": 0.7,
  1122. // "background-color": "#999"
  1123. // }
  1124. //});
  1125. this.save(function(){
  1126. this.baseActionNode.empty();
  1127. this.cancelBaseNode = null;
  1128. this.saveBaseNode = null;
  1129. this.createEditBaseNode();
  1130. this.readMode();
  1131. //this.node.unmask();
  1132. }.bind(this), function(xhr, text, error){
  1133. var errorText = error;
  1134. if (xhr) errorText = xhr.responseText;
  1135. this.app.notice("request json error: "+errorText, "error");
  1136. //this.node.unmask();
  1137. }.bind(this));
  1138. },
  1139. save: function(callback, cancel){
  1140. this.data.name = this.nameInput.input.get("value");
  1141. this.data.appName = this.data.name;
  1142. this.data.alias = this.aliasInput.input.get("value");
  1143. this.data.appAlias = this.data.alias;
  1144. this.data.appType = this.appTypeInput.input.get("value");
  1145. this.data.description = this.descriptionInput.input.get("value");
  1146. this.data.appInfoSeq = this.sortInput.input.get("value");
  1147. this.data.documentType = this.typeSelect.getValue();
  1148. this.data.showAllDocuments = this.allDocumentViewSelect.getValue() !== "false";
  1149. debugger;
  1150. this.data.defaultEditForm = this.defaultEditForm.getValue();
  1151. this.data.defaultReadForm = this.defaultReadForm.getValue();
  1152. this.config.ignoreTitle = this.ignoreTitleSelect.getValue() !== "false";
  1153. this.config.latest = this.latestSelect.getValue() !== "false";
  1154. this.config.saveDraftOnClose = this.saveDraftOnCloseSelect.getValue() !== "false";
  1155. this.data.allowWaitPublish = this.delaySelect.getValue() === "true";
  1156. this.data.config = JSON.stringify( this.config );
  1157. //this.data.applicationCategory = this.appTypeInput.input.get("value");
  1158. this.app.restActions.saveColumn(this.data, function(json){
  1159. this.propertyTitleBar.set("text", this.data.name);
  1160. this.data.id = json.data.id;
  1161. this.nameInput.save();
  1162. this.aliasInput.save();
  1163. this.appTypeInput.save();
  1164. this.descriptionInput.save();
  1165. this.sortInput.save();
  1166. this.typeSelect.save();
  1167. this.latestSelect.save();
  1168. this.delaySelect.save();
  1169. this.ignoreTitleSelect.save();
  1170. this.allDocumentViewSelect.save();
  1171. this.saveDraftOnCloseSelect.save();
  1172. this.defaultEditForm.save();
  1173. this.defaultReadForm.save();
  1174. //this.typeInput.save();
  1175. this.app.notice( this.app.lp.application.saveSuccess, "success");
  1176. if (callback) callback();
  1177. }.bind(this), function(xhr, text, error){
  1178. if (cancel) cancel(xhr, text, error);
  1179. }.bind(this));
  1180. }
  1181. });
  1182. MWF.xApplication.cms.ColumnManager.Input = new Class({
  1183. Implements: [Events],
  1184. initialize: function(node, value, style){
  1185. this.node = $(node);
  1186. this.value = value || "";
  1187. this.style = style;
  1188. this.load();
  1189. },
  1190. load: function(){
  1191. this.content = new Element("div", {
  1192. "styles": this.style.content,
  1193. "text": this.value
  1194. }).inject(this.node);
  1195. },
  1196. editMode: function(){
  1197. this.content.empty();
  1198. this.input = new Element("input",{
  1199. "styles": this.style.input,
  1200. "value": this.value
  1201. }).inject(this.content);
  1202. this.input.addEvents({
  1203. "focus": function(){
  1204. this.input.setStyles(this.style.input_focus);
  1205. }.bind(this),
  1206. "blur": function(){
  1207. this.input.setStyles(this.style.input);
  1208. }.bind(this)
  1209. });
  1210. },
  1211. readMode: function(){
  1212. this.content.empty();
  1213. this.input = null;
  1214. this.content.set("text", this.value);
  1215. },
  1216. save: function(){
  1217. if (this.input) this.value = this.input.get("value");
  1218. return this.value;
  1219. }
  1220. });
  1221. //MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  1222. //MWF.xApplication.cms.ColumnManager.TypeTooltip = new Class({
  1223. // Extends: MTooltips,
  1224. // _loadCustom : function( callback ){
  1225. // if(callback)callback();
  1226. // },
  1227. // _getHtml : function(){
  1228. // var data = this.data;
  1229. // var titleStyle = "font-size:12px;color:#333";
  1230. // var valueStyle = "font-size:12px;color:#666;padding-right:20px";
  1231. //
  1232. // var html =
  1233. // "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1234. // "<tr><td style='"+valueStyle+";' width='70'>"+"栏目类型设置为“数据存储”时,将不在信息中心中展现。"+":</td>" +
  1235. // " </tr>" +
  1236. // "</table>";
  1237. // return html;
  1238. // }
  1239. //});