Main.js 55 KB

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