Main.js 60 KB

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