Main.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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. this.controllerData = [];
  768. this.controllerList = [];
  769. },
  770. load: function(){
  771. this.propertyTitleBar = new Element("div.propertyTitleBar", {
  772. "styles": this.app.css.propertyTitleBar,
  773. "text": "栏目属性" //this.data.name || this.data.appName
  774. }).inject(this.node);
  775. this.contentNode = new Element("div.propertyContentNode", {
  776. "styles": this.app.css.propertyContentNode
  777. }).inject(this.node);
  778. this.contentAreaNode = new Element("div.propertyContentAreaNode", {
  779. "styles": this.app.css.propertyContentAreaNode
  780. }).inject(this.contentNode);
  781. this.setContentHeight();
  782. this.setContentHeightFun = this.setContentHeight.bind(this);
  783. this.app.addEvent("resize", this.setContentHeightFun);
  784. MWF.require("MWF.widget.ScrollBar", function(){
  785. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  786. }.bind(this));
  787. this.baseActionAreaNode = new Element("div.baseActionAreaNode", {
  788. "styles": this.app.css.baseActionAreaNode
  789. }).inject(this.contentAreaNode);
  790. this.baseActionNode = new Element("div.propertyInforActionNode", {
  791. "styles": this.app.css.propertyInforActionNode
  792. }).inject(this.baseActionAreaNode);
  793. this.baseTextNode = new Element("div.baseTextNode", {
  794. "styles": this.app.css.baseTextNode,
  795. "text": this.app.lp.application.property
  796. }).inject(this.baseActionAreaNode);
  797. this.createEditBaseNode();
  798. this.createPropertyContentNode();
  799. this.createIconContentNode();
  800. this.viewerContainer = new Element( "div").inject( this.contentAreaNode );
  801. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.ColumnViewerSetting", null, false);
  802. this.viewerSetting = new MWF.xApplication.cms.ColumnManager.ColumnViewerSetting( this.app,
  803. this.app.lp.application.viewerSetting, this.viewerContainer, {
  804. objectId : this.data.id
  805. }
  806. );
  807. this.viewerSetting.dataParent = this;
  808. this.viewerSetting.load();
  809. this.publisherContainer = new Element( "div").inject( this.contentAreaNode );
  810. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.ColumnPublisherSetting", null, false);
  811. this.publisherSetting = new MWF.xApplication.cms.ColumnManager.ColumnPublisherSetting( this.app,
  812. this.app.lp.application.publisherSetting, this.publisherContainer, {
  813. objectId : this.data.id
  814. }
  815. );
  816. this.publisherSetting.dataParent = this;
  817. this.publisherSetting.load();
  818. this.managerContainer = new Element( "div").inject( this.contentAreaNode );
  819. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.ColumnManagerSetting", null, false);
  820. this.viewerSetting = new MWF.xApplication.cms.ColumnManager.ColumnManagerSetting( this.app,
  821. this.app.lp.application.managerSetting, this.managerContainer, {
  822. objectId : this.data.id
  823. }
  824. );
  825. this.viewerSetting.dataParent = this;
  826. this.viewerSetting.load();
  827. },
  828. setContentHeight: function(){
  829. var size = this.app.content.getSize();
  830. var titleSize = this.propertyTitleBar.getSize();
  831. var y = size.y-titleSize.y;
  832. this.contentNode.setStyle("height", ""+y+"px");
  833. },
  834. createIconContentNode: function(){
  835. this.iconContentTitleNode = new Element("div.iconContentTitleNode", {
  836. "styles": this.app.css.iconContentTitleNode,
  837. "text": this.app.lp.application.icon
  838. }).inject(this.contentAreaNode);
  839. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  840. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  841. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  842. html += "</table>";
  843. this.iconContentNode.set("html", html);
  844. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  845. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  846. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  847. this.iconPreviewNode.setStyles({
  848. "height": "72px",
  849. "width": "72px",
  850. "float": "right"
  851. });
  852. var icon = this.data.icon || this.data.appIcon;
  853. if (icon){
  854. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+icon+") center center no-repeat");
  855. }else{
  856. this.iconPreviewNode.setStyle("background", "url("+"/x_component_cms_Column/$Main/default/icon/column.png) center center no-repeat")
  857. }
  858. var changeIconAction = new Element("div", {
  859. "styles": this.app.css.selectButtonStyle,
  860. "text": "更改图标"
  861. }).inject(this.iconActionNode);
  862. changeIconAction.addEvent("click", function(){
  863. this.changeIcon();
  864. }.bind(this));
  865. },
  866. changeIcon: function(){
  867. if (!this.uploadFileAreaNode){
  868. this.uploadFileAreaNode = new Element("div");
  869. var html = "<input name=\"file\" type=\"file\"/>";
  870. this.uploadFileAreaNode.set("html", html);
  871. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  872. this.fileUploadNode.addEvent("change", function(){
  873. var files = fileNode.files;
  874. if (files.length){
  875. for (var i = 0; i < files.length; i++) {
  876. var file = files.item(i);
  877. var formData = new FormData();
  878. formData.append('file', file);
  879. //formData.append('name', file.name);
  880. //formData.append('folder', folderId);
  881. this.app.restActions.updataColumnIcon(this.data.id ,function(){
  882. this.app.restActions.getColumn(this.data.id, function(json){
  883. if (json.data){
  884. this.data = json.data;
  885. if (this.data.appIcon){
  886. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.appIcon+") center center no-repeat");
  887. }else{
  888. this.iconPreviewNode.setStyle("background", "url("+"/x_component_cms_Column/$Main/default/icon/category2.png) center center no-repeat")
  889. }
  890. }
  891. }.bind(this), false)
  892. }.bind(this), null, formData, file);
  893. }
  894. }
  895. }.bind(this));
  896. }
  897. var fileNode = this.uploadFileAreaNode.getFirst();
  898. fileNode.click();
  899. },
  900. createPropertyContentNode: function(){
  901. this.propertyContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  902. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  903. html += "<tr><td class='formTitle'>"+this.app.lp.application.id +"</td><td id='formApplicationId' class='formValue'>"+this.data.id+"</td></tr>";
  904. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  905. html += "<tr><td class='formTitle'>"+this.app.lp.application.sign+"</td><td id='formApplicationAlias' class='formValue'>"+(this.data.alias||this.data.appAlias||'')+"</td></tr>";
  906. html += "<tr><td class='formTitle'>"+this.app.lp.application.documentType+"</td><td id='formApplicationType' class='formValue'>"+(this.data.documentType || "信息" )+"</td></tr>";
  907. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  908. html += "<tr><td class='formTitle'>"+this.app.lp.application.sort+"</td><td id='formApplicationSort'></td></tr>";
  909. // html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  910. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  911. html += "</table>";
  912. this.propertyContentNode.set("html", html);
  913. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  914. this.propertyContentNode.getElements("td.formValue").setStyles(this.app.css.propertyBaseContentTdValue);
  915. this.nameInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name || this.data.appName, this.app.css.formInput);
  916. //this.aliasInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  917. this.typeSelect = new MDomItem( this.propertyContentNode.getElement("#formApplicationType"), {
  918. type : "select",
  919. value : this.data.documentType || "信息",
  920. selectValue : [ "信息", "数据" ]
  921. });
  922. this.descriptionInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  923. this.sortInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationSort"), this.data.appInfoSeq, this.app.css.formInput);
  924. //this.typeInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  925. },
  926. createEditBaseNode: function(){
  927. this.editBaseNode = new Element("button.editBaseNode", {
  928. "styles": this.app.css.editBaseNode,
  929. "text": this.app.lp.edit,
  930. "events": {"click": this.editBaseInfor.bind(this)}
  931. }).inject(this.baseActionNode);
  932. },
  933. createCancelBaseNode: function(){
  934. this.cancelBaseNode = new Element("button.cancelBaseNode", {
  935. "styles": this.app.css.cancelBaseNode,
  936. "text": this.app.lp.cancel,
  937. "events": {"click": this.cancelBaseInfor.bind(this)}
  938. }).inject(this.baseActionNode);
  939. },
  940. createSaveBaseNode: function(){
  941. this.saveBaseNode = new Element("button.saveBaseNode", {
  942. "styles": this.app.css.saveBaseNode,
  943. "text": this.app.lp.save,
  944. "events": {"click": this.saveBaseInfor.bind(this)}
  945. }).inject(this.baseActionNode);
  946. },
  947. editBaseInfor: function(){
  948. this.baseActionNode.empty();
  949. this.editBaseNode = null;
  950. this.createCancelBaseNode();
  951. this.createSaveBaseNode();
  952. this.editMode();
  953. },
  954. editMode: function(){
  955. this.nameInput.editMode();
  956. //this.aliasInput.editMode();
  957. this.descriptionInput.editMode();
  958. this.sortInput.editMode();
  959. this.typeSelect.editMode();
  960. //this.typeInput.editMode();
  961. this.isEdit = true;
  962. },
  963. readMode: function(){
  964. this.nameInput.readMode();
  965. //this.aliasInput.readMode();
  966. this.descriptionInput.readMode();
  967. this.sortInput.readMode();
  968. this.typeSelect.readMode();
  969. //this.typeInput.readMode();
  970. this.isEdit = false;
  971. },
  972. cancelBaseInfor: function(){
  973. if (this.data.name || this.data.appName || this.data.id ){
  974. this.baseActionNode.empty();
  975. this.cancelBaseNode = null;
  976. this.saveBaseNode = null;
  977. this.createEditBaseNode();
  978. this.readMode();
  979. }else{
  980. this.destroy();
  981. }
  982. },
  983. saveBaseInfor: function(){
  984. if (!this.nameInput.input.get("value")){
  985. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  986. return false;
  987. }
  988. //this.node.mask({
  989. // "style": {
  990. // "opacity": 0.7,
  991. // "background-color": "#999"
  992. // }
  993. //});
  994. this.save(function(){
  995. this.baseActionNode.empty();
  996. this.cancelBaseNode = null;
  997. this.saveBaseNode = null;
  998. this.createEditBaseNode();
  999. this.readMode();
  1000. //this.node.unmask();
  1001. }.bind(this), function(xhr, text, error){
  1002. var errorText = error;
  1003. if (xhr) errorText = xhr.responseText;
  1004. this.app.notice("request json error: "+errorText, "error");
  1005. //this.node.unmask();
  1006. }.bind(this));
  1007. },
  1008. save: function(callback, cancel){
  1009. this.data.name = this.nameInput.input.get("value");
  1010. this.data.appName = this.data.name;
  1011. //this.data.alias = this.aliasInput.input.get("value");
  1012. //this.data.appAlias = this.data.alias;
  1013. this.data.description = this.descriptionInput.input.get("value");
  1014. this.data.appInfoSeq = this.sortInput.input.get("value");
  1015. this.data.documentType = this.typeSelect.getValue();
  1016. //this.data.applicationCategory = this.typeInput.input.get("value");
  1017. this.app.restActions.saveColumn(this.data, function(json){
  1018. this.propertyTitleBar.set("text", this.data.name);
  1019. this.data.id = json.data.id;
  1020. this.nameInput.save();
  1021. //this.aliasInput.save();
  1022. this.descriptionInput.save();
  1023. this.sortInput.save();
  1024. this.typeSelect.save();
  1025. //this.typeInput.save();
  1026. this.app.notice( this.app.lp.application.saveSuccess, "success");
  1027. if (callback) callback();
  1028. }.bind(this), function(xhr, text, error){
  1029. if (cancel) cancel(xhr, text, error);
  1030. }.bind(this));
  1031. }
  1032. });
  1033. MWF.xApplication.cms.ColumnManager.Input = new Class({
  1034. Implements: [Events],
  1035. initialize: function(node, value, style){
  1036. this.node = $(node);
  1037. this.value = value || "";
  1038. this.style = style;
  1039. this.load();
  1040. },
  1041. load: function(){
  1042. this.content = new Element("div", {
  1043. "styles": this.style.content,
  1044. "text": this.value
  1045. }).inject(this.node);
  1046. },
  1047. editMode: function(){
  1048. this.content.empty();
  1049. this.input = new Element("input",{
  1050. "styles": this.style.input,
  1051. "value": this.value
  1052. }).inject(this.content);
  1053. this.input.addEvents({
  1054. "focus": function(){
  1055. this.input.setStyles(this.style.input_focus);
  1056. }.bind(this),
  1057. "blur": function(){
  1058. this.input.setStyles(this.style.input);
  1059. }.bind(this)
  1060. });
  1061. },
  1062. readMode: function(){
  1063. this.content.empty();
  1064. this.input = null;
  1065. this.content.set("text", this.value);
  1066. },
  1067. save: function(){
  1068. if (this.input) this.value = this.input.get("value");
  1069. return this.value;
  1070. }
  1071. });
  1072. //MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  1073. //MWF.xApplication.cms.ColumnManager.TypeTooltip = new Class({
  1074. // Extends: MTooltips,
  1075. // _loadCustom : function( callback ){
  1076. // if(callback)callback();
  1077. // },
  1078. // _getHtml : function(){
  1079. // var data = this.data;
  1080. // var titleStyle = "font-size:12px;color:#333";
  1081. // var valueStyle = "font-size:12px;color:#666;padding-right:20px";
  1082. //
  1083. // var html =
  1084. // "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1085. // "<tr><td style='"+valueStyle+";' width='70'>"+"栏目类型设置为“数据存储”时,将不在信息中心中展现。"+":</td>" +
  1086. // " </tr>" +
  1087. // "</table>";
  1088. // return html;
  1089. // }
  1090. //});