Main.js 55 KB

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