Main.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "package", null, false);
  2. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  4. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  5. MWF.require("MWF.widget.Identity", null,false);
  6. MWF.xApplication.cms.ColumnManager.Main = new Class({
  7. Extends: MWF.xApplication.Common.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "column": null,
  11. "application" : null,
  12. "style": "default",
  13. "name": "cms.ColumnManager",
  14. "icon": "icon.png",
  15. "width": "1100",
  16. "height": "720",
  17. "title": MWF.xApplication.cms.ColumnManager.LP.title
  18. },
  19. onQueryLoad: function(){
  20. if(this.options.column)this.options.column.icon = this.options.column.appIcon;
  21. if(!this.options.application) this.options.application = this.options.column;
  22. this.lp = MWF.xApplication.cms.ColumnManager.LP;
  23. this.currentContentNode = null;
  24. },
  25. loadApplication: function(callback){
  26. this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  27. //if (this.status){
  28. // if (!this.options.application){
  29. // if (this.status.application){
  30. // this.restActions.getApplication(this.status.application, function(json){
  31. // if (json.data){
  32. // this.options.application = json.data;
  33. // alert("sds"+this.options.application);
  34. // }else{
  35. // this.close();
  36. // }
  37. // }.bind(this), function(){this.close();}.bind(this), false)
  38. // }else{
  39. // this.close();
  40. // }
  41. // }
  42. //}
  43. this.getColumn(function(){
  44. this.setTitle( this.options.column.appName );
  45. this.loadController(function(){
  46. if( !this.isAdmin ){
  47. this.notice( MWF.CMSCM.LP.noAdministratorAccess , "error");
  48. this.close();
  49. }else{
  50. this.createNode();
  51. this.loadApplicationContent();
  52. if (callback) callback();
  53. }
  54. }.bind(this))
  55. }.bind(this), function(){
  56. this.close();
  57. }.bind(this));
  58. },
  59. loadController: function(callback){
  60. this.controllers = [];
  61. this.restActions.listColumnController(this.options.column.id, function( json ){
  62. json.data = json.data || [];
  63. json.data.each(function(item){
  64. this.controllers.push(item.adminUid)
  65. }.bind(this))
  66. this.isAdmin = MWF.AC.isAdministrator() || this.controllers.contains(layout.desktop.session.user.name);
  67. if(callback)callback(this.isAdmin);
  68. }.bind(this));
  69. },
  70. getColumn: function(success, failure){
  71. if (!this.options.column){
  72. if (this.status) {
  73. if (this.status.column){
  74. this.restActions.getColumn({"id":this.status.column}, function(json){
  75. if (json.data){
  76. this.options.column = json.data;
  77. this.options.application = json.data;
  78. if (success) success();
  79. }else{
  80. if (failure) failure();
  81. }
  82. }.bind(this), function(){if (failure) failure();}.bind(this), false)
  83. }else{
  84. if (failure) failure();
  85. }
  86. }else{
  87. if (failure) failure();
  88. }
  89. }else{
  90. if (success) success();
  91. }
  92. },
  93. loadApplicationContent: function(){
  94. this.loadStartMenu();
  95. this.loadApplicationLayout();
  96. },
  97. createNode: function(){
  98. this.content.setStyle("overflow", "hidden");
  99. this.node = new Element("div", {
  100. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  101. }).inject(this.content);
  102. },
  103. loadApplicationLayout: function(){
  104. // this.topMenuNode = new Element("div").inject(this.node);
  105. // MWF.require("MWF.widget.Toolbar", function(){
  106. // this.toobar = new MWF.widget.Toolbar(this.topMenuNode);
  107. // this.toobar.load();
  108. // alert("ok")
  109. // }.bind(this));
  110. },
  111. loadStartMenu: function(callback){
  112. this.startMenuNode = new Element("div", {
  113. "styles": this.css.startMenuNode
  114. }).inject(this.node);
  115. this.menu = new MWF.xApplication.cms.ColumnManager.Menu(this, this.startMenuNode, {
  116. "onPostLoad": function(){
  117. if (this.status){
  118. if (this.status.navi!=null){
  119. this.menu.doAction(this.menu.startNavis[this.status.navi]);
  120. }else{
  121. this.menu.doAction(this.menu.startNavis[0]);
  122. }
  123. }else{
  124. this.menu.doAction(this.menu.startNavis[0]);
  125. }
  126. }.bind(this)
  127. });
  128. this.addEvent("resize", function(){
  129. if (this.menu) this.menu.onResize();
  130. }.bind(this));
  131. },
  132. clearContent: function(){
  133. if (this.categoryConfiguratorContent){
  134. if (this.categoryConfigurator) delete this.categoryConfigurator;
  135. this.categoryConfiguratorContent.destroy();
  136. this.categoryConfiguratorContent = null;
  137. }
  138. if (this.formConfiguratorContent){
  139. if (this.formConfigurator) delete this.formConfigurator;
  140. this.formConfiguratorContent.destroy();
  141. this.formConfiguratorContent = null;
  142. }
  143. if (this.propertyConfiguratorContent){
  144. if (this.property) delete this.property;
  145. this.propertyConfiguratorContent.destroy();
  146. this.propertyConfiguratorContent = null;
  147. }
  148. if (this.dataConfiguratorContent){
  149. if (this.dataConfigurator) delete this.dataConfigurator;
  150. this.dataConfiguratorContent.destroy();
  151. this.dataConfiguratorContent = null;
  152. }
  153. if (this.scriptConfiguratorContent){
  154. if (this.scriptConfigurator) delete this.scriptConfigurator;
  155. this.scriptConfiguratorContent.destroy();
  156. this.scriptConfiguratorContent = null;
  157. }
  158. if (this.viewConfiguratorContent){
  159. if (this.viewConfigurator) delete this.viewConfigurator;
  160. this.viewConfiguratorContent.destroy();
  161. this.viewConfiguratorContent = null;
  162. }
  163. if (this.queryViewConfiguratorContent){
  164. if (this.queryViewConfigurator) delete this.queryViewConfigurator;
  165. this.queryViewConfiguratorContent.destroy();
  166. this.queryViewConfiguratorContent = null;
  167. }
  168. },
  169. applicationProperty: function(){
  170. this.clearContent();
  171. this.propertyConfiguratorContent = new Element("div", {
  172. "styles": this.css.rightContentNode
  173. }).inject(this.node);
  174. this.property = new MWF.xApplication.cms.ColumnManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  175. this.property.load();
  176. },
  177. cagetoryConfig: function(){
  178. this.clearContent();
  179. this.categoryConfiguratorContent = new Element("div", {
  180. "styles": this.css.rightContentNode
  181. }).inject(this.node);
  182. this.loadCategoryConfig();
  183. },
  184. loadCategoryConfig: function(){
  185. MWF.xDesktop.requireApp("cms.ColumnManager", "CategoryExplorer", function(){
  186. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  187. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  188. this.categoryConfigurator = new MWF.xApplication.cms.ColumnManager.CategoryExplorer(this.categoryConfiguratorContent, this.restActions);
  189. this.categoryConfigurator.app = this;
  190. this.categoryConfigurator.load();
  191. }.bind(this));
  192. }.bind(this));
  193. },
  194. cagetoryConfigV2: function(){
  195. this.clearContent();
  196. this.categoryConfiguratorContent = new Element("div", {
  197. "styles": this.css.rightContentNode
  198. }).inject(this.node);
  199. this.loadCategoryConfigV2();
  200. },
  201. loadCategoryConfigV2: function(){
  202. MWF.xDesktop.requireApp("cms.ColumnManager", "CategoryExplorerV2", function(){
  203. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  204. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  205. this.categoryConfigurator = new MWF.xApplication.cms.ColumnManager.CategoryExplorerV2(this.categoryConfiguratorContent, this.restActions);
  206. this.categoryConfigurator.app = this;
  207. this.categoryConfigurator.load();
  208. }.bind(this));
  209. }.bind(this));
  210. },
  211. formConfig: function(){
  212. this.clearContent();
  213. this.formConfiguratorContent = new Element("div", {
  214. "styles": this.css.rightContentNode
  215. }).inject(this.node);
  216. this.loadFormConfig();
  217. },
  218. loadFormConfig: function(){
  219. MWF.xDesktop.requireApp("cms.ColumnManager", "FormExplorer", function(){
  220. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  221. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  222. this.formConfigurator = new MWF.xApplication.cms.ColumnManager.FormExplorer(this.formConfiguratorContent, this.restActions);
  223. this.formConfigurator.app = this;
  224. this.formConfigurator.load();
  225. }.bind(this));
  226. }.bind(this));
  227. },
  228. dataConfig: function(){
  229. this.clearContent();
  230. this.dataConfiguratorContent = new Element("div", {
  231. "styles": this.css.rightContentNode
  232. }).inject(this.node);
  233. this.loadDataConfig();
  234. },
  235. loadDataConfig: function(){
  236. MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", function(){
  237. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  238. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  239. this.dataConfigurator = new MWF.xApplication.cms.ColumnManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions);
  240. this.dataConfigurator.app = this;
  241. this.dataConfigurator.load();
  242. }.bind(this));
  243. }.bind(this));
  244. },
  245. scriptConfig: function(){
  246. this.clearContent();
  247. this.scriptConfiguratorContent = new Element("div", {
  248. "styles": this.css.rightContentNode
  249. }).inject(this.node);
  250. this.loadScriptConfig();
  251. },
  252. loadScriptConfig: function(){
  253. MWF.xDesktop.requireApp("cms.ColumnManager", "ScriptExplorer", function(){
  254. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  255. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  256. this.scriptConfigurator = new MWF.xApplication.cms.ColumnManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  257. this.scriptConfigurator.app = this;
  258. this.scriptConfigurator.load();
  259. }.bind(this));
  260. }.bind(this));
  261. },
  262. viewConfig: function(){
  263. this.clearContent();
  264. this.viewConfiguratorContent = new Element("div", {
  265. "styles": this.css.rightContentNode
  266. }).inject(this.node);
  267. this.loadViewConfig();
  268. },
  269. loadViewConfig: function(){
  270. MWF.xDesktop.requireApp("cms.ColumnManager", "ViewExplorer", function(){
  271. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  272. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  273. this.viewConfigurator = new MWF.xApplication.cms.ColumnManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  274. this.viewConfigurator.app = this;
  275. this.viewConfigurator.load();
  276. }.bind(this));
  277. }.bind(this));
  278. },
  279. queryViewConfig: function(){
  280. this.clearContent();
  281. this.queryViewConfiguratorContent = new Element("div", {
  282. "styles": this.css.rightContentNode
  283. }).inject(this.node);
  284. this.loadQueryViewConfig();
  285. },
  286. loadQueryViewConfig: function(){
  287. MWF.xDesktop.requireApp("cms.ColumnManager", "QueryViewExplorer", function(){
  288. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  289. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  290. this.queryViewConfigurator = new MWF.xApplication.cms.ColumnManager.QueryViewExplorer(this.queryViewConfiguratorContent, this.restActions);
  291. this.queryViewConfigurator.app = this;
  292. this.queryViewConfigurator.load();
  293. }.bind(this));
  294. }.bind(this));
  295. },
  296. //getCategoryCount: function(){
  297. // var size = this.categoryConfiguratorContent.getSize();
  298. // categoryCount = parseInt(size.x/182)+5;
  299. // return categoryCount;
  300. //},
  301. getCategoryCount: function(){
  302. if (this.categoryConfigurator){
  303. var size = this.categoryConfigurator.categoryNode.getSize();
  304. categoryCount = (parseInt(size.x/401)*parseInt(size.y/101))+10;
  305. return categoryCount;
  306. }
  307. return 20;
  308. },
  309. showContentNode: function(node){
  310. if (this.currentContentNode){
  311. // this.currentContentNode.setStyles({
  312. // "position": "absolute"
  313. // });
  314. this.currentContentNode.fade("hide");
  315. node.fade("show");
  316. node.setStyle("display", "node");
  317. this.currentContentNode = null;
  318. }
  319. node.setStyle("display", "block");
  320. node.fade("show");
  321. this.currentContentNode = node;
  322. },
  323. recordStatus: function(){
  324. var idx = null;
  325. if (this.menu.currentNavi){
  326. idx = this.menu.startNavis.indexOf(this.menu.currentNavi);
  327. }
  328. return {"navi": idx, "column": this.options.column.id};
  329. }
  330. // onResize: function(){
  331. // if (this.menu) this.menu.onResize();
  332. // }
  333. });
  334. MWF.xApplication.cms.ColumnManager.Menu = new Class({
  335. Implements: [Options, Events],
  336. initialize: function(app, node, options){
  337. this.setOptions(options);
  338. this.app = app;
  339. this.node = $(node);
  340. this.currentNavi = null;
  341. this.status = "start";
  342. this.startNavis = [];
  343. this.load();
  344. },
  345. load: function(){
  346. var menuUrl = this.app.path+"startMenu.json";
  347. MWF.getJSON(menuUrl, function(json){
  348. json.each(function(navi){
  349. var naviNode = new Element("div", {
  350. "styles": this.app.css.startMenuNaviNode
  351. });
  352. naviNode.store("naviData", navi);
  353. var iconNode = new Element("div", {
  354. "styles": this.app.css.startMenuIconNode
  355. }).inject(naviNode);
  356. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  357. var textNode = new Element("div", {
  358. "styles": this.app.css.startMenuTextNode,
  359. "text": navi.title
  360. });
  361. textNode.inject(naviNode);
  362. naviNode.inject(this.node);
  363. this.startNavis.push(naviNode);
  364. this.setStartNaviEvent(naviNode, navi);
  365. this.setNodeCenter(this.node);
  366. }.bind(this));
  367. this.setStartMenuWidth();
  368. this.fireEvent("postLoad");
  369. }.bind(this));
  370. },
  371. setStartNaviEvent: function(naviNode){
  372. var _self = this;
  373. naviNode.addEvents({
  374. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  375. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  376. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  377. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  378. "click": function(){
  379. //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
  380. _self.doAction.apply(_self, [this]);
  381. }
  382. });
  383. },
  384. doAction: function(naviNode){
  385. var navi = naviNode.retrieve("naviData");
  386. var action = navi.action;
  387. if (this.currentNavi) this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  388. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  389. this.currentNavi = naviNode;
  390. if (this.app[action]) this.app[action].apply(this.app);
  391. if (this.status == "start"){
  392. this.toNormal();
  393. this.status = "normal";
  394. }
  395. },
  396. toNormal: function(){
  397. // var size = this.getStartMenuNormalSize();
  398. var css = this.app.css.normalStartMenuNode;
  399. //css.height = size.height+"px";
  400. // css.height = "100%";
  401. // css.width = size.width+"px";
  402. //// this.node.setStyles(css);
  403. //
  404. if (!this.morph){
  405. this.morph = new Fx.Morph(this.node, {duration: 50, link: "chain"});
  406. }
  407. // this.morph.start(css).chain(function(){
  408. this.node.setStyles(css);
  409. MWF.require("MWF.widget.ScrollBar", function(){
  410. new MWF.widget.ScrollBar(this.node, {
  411. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  412. });
  413. }.bind(this));
  414. // }.bind(this));
  415. //
  416. //// this.node.setStyles(css);
  417. ////
  418. //// this.startNavis.each(function(naviNode){
  419. //// if (this.currentNavi!=naviNode) naviNode.setStyles(this.app.css.startMenuNaviNode);
  420. //// }.bind(this));
  421. //
  422. // this.node.set("morph", {duration: 50});
  423. // this.node.morph(css);
  424. },
  425. setNodeCenter: function(node){
  426. var size = node.getSize();
  427. var contentSize = this.app.node.getSize();
  428. var top = contentSize.y/2 - size.y/2;
  429. var left = contentSize.x/2 - size.x/2;
  430. if (left<0) left = 0;
  431. if (top<0) top = 0;
  432. node.setStyles({"left": left, "top": top});
  433. },
  434. getStartMenuNormalSize: function(){
  435. var naviItemNode = this.node.getFirst();
  436. var size = naviItemNode.getComputedSize();
  437. var mt = naviItemNode.getStyle("margin-top").toFloat();
  438. var mb = naviItemNode.getStyle("margin-bottom").toFloat();
  439. var height = size.totalWidth+mt+mb;
  440. var ml = naviItemNode.getStyle("margin-left").toFloat();
  441. var mr = naviItemNode.getStyle("margin-right").toFloat();
  442. var width = size.totalWidth+ml+mr;
  443. return {"width": width, "height": height*this.startNavis.length};
  444. },
  445. setStartMenuWidth: function(){
  446. var naviItemNode = this.node.getFirst();
  447. var size = naviItemNode.getComputedSize();
  448. var ml = naviItemNode.getStyle("margin-left").toFloat();
  449. var mr = naviItemNode.getStyle("margin-right").toFloat();
  450. var width = size.totalWidth+ml+mr;
  451. this.node.setStyle("width", (width*this.startNavis.length)+"px");
  452. },
  453. onResize: function(){
  454. if (this.status == "start"){
  455. this.setNodeCenter(this.node);
  456. }
  457. }
  458. });
  459. MWF.xApplication.cms.ColumnManager.ApplicationProperty = new Class({
  460. initialize: function(app, node){
  461. this.app = app;
  462. this.node = $(node);
  463. this.data = this.app.options.application;
  464. this.controllerData = [];
  465. this.controllerList = [];
  466. this.availableData = [];
  467. this.availablePersonList = [];
  468. this.availableDepartmentList = [];
  469. this.availableCompanyList = [];
  470. },
  471. load: function(){
  472. this.propertyTitleBar = new Element("div", {
  473. "styles": this.app.css.propertyTitleBar,
  474. "text": this.data.name || this.data.appName
  475. }).inject(this.node);
  476. this.contentNode = new Element("div", {
  477. "styles": this.app.css.propertyContentNode
  478. }).inject(this.node);
  479. this.contentAreaNode = new Element("div", {
  480. "styles": this.app.css.propertyContentAreaNode
  481. }).inject(this.contentNode);
  482. this.setContentHeight();
  483. this.setContentHeightFun = this.setContentHeight.bind(this);
  484. this.app.addEvent("resize", this.setContentHeightFun);
  485. MWF.require("MWF.widget.ScrollBar", function(){
  486. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  487. }.bind(this));
  488. this.baseActionAreaNode = new Element("div", {
  489. "styles": this.app.css.baseActionAreaNode
  490. }).inject(this.contentAreaNode);
  491. this.baseActionNode = new Element("div", {
  492. "styles": this.app.css.propertyInforActionNode
  493. }).inject(this.baseActionAreaNode);
  494. this.baseTextNode = new Element("div", {
  495. "styles": this.app.css.baseTextNode,
  496. "text": this.app.lp.application.property
  497. }).inject(this.baseActionAreaNode);
  498. this.createEditBaseNode();
  499. this.createPropertyContentNode();
  500. this.createIconContentNode();
  501. this.listPermission( function(){
  502. this.createAvailableNode();
  503. }.bind(this))
  504. this.listController( function( ){
  505. this.createControllerListNode();
  506. }.bind(this) )
  507. },
  508. listController : function( callback ){
  509. this.app.restActions.listColumnController(this.data.id, function(json){
  510. json.data = json.data || [];
  511. this.controllerData = json.data;
  512. json.data.each(function( d ){
  513. this.controllerList.push( d.adminName );
  514. }.bind(this))
  515. callback.call( )
  516. }.bind(this), null ,false)
  517. },
  518. listPermission:function( callback ){
  519. this.app.restActions.listColumnPermission(this.data.id, function(json){
  520. json.data = json.data || [];
  521. this.availableData = json.data;
  522. json.data.each(function( d ){
  523. if(d.usedObjectType == "USER" ){
  524. this.availablePersonList.push( d.usedObjectName )
  525. }else if(d.usedObjectType == "DEPARTMENT"){
  526. this.availableDepartmentList.push( d.usedObjectName )
  527. }else{
  528. this.availableCompanyList.push( d.usedObjectName )
  529. }
  530. }.bind(this))
  531. callback.call( )
  532. }.bind(this), null ,false)
  533. },
  534. setContentHeight: function(){
  535. var size = this.app.content.getSize();
  536. var titleSize = this.propertyTitleBar.getSize();
  537. var y = size.y-titleSize.y;
  538. this.contentNode.setStyle("height", ""+y+"px");
  539. },
  540. createIconContentNode: function(){
  541. this.iconContentTitleNode = new Element("div", {
  542. "styles": this.app.css.iconContentTitleNode,
  543. "text": this.app.lp.application.icon
  544. }).inject(this.contentAreaNode);
  545. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  546. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  547. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  548. html += "</table>";
  549. this.iconContentNode.set("html", html);
  550. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  551. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  552. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  553. this.iconPreviewNode.setStyles({
  554. "height": "72px",
  555. "width": "72px",
  556. "float": "right"
  557. });
  558. var icon = this.data.icon || this.data.appIcon;
  559. if (icon){
  560. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+icon+") center center no-repeat");
  561. }else{
  562. this.iconPreviewNode.setStyle("background", "url("+"/x_component_cms_Column/$Main/default/icon/column.png) center center no-repeat")
  563. }
  564. var changeIconAction = new Element("div", {
  565. "styles": {
  566. "margin-left": "20px",
  567. "float": "left",
  568. "background-color": "#FFF",
  569. "padding": "4px 14px",
  570. "border": "1px solid #999",
  571. "border-radius": "3px",
  572. "margin-top": "10px",
  573. "font-size": "14px",
  574. "color": "#666",
  575. "cursor": "pointer"
  576. },
  577. "text": "更改图标"
  578. }).inject(this.iconActionNode);
  579. changeIconAction.addEvent("click", function(){
  580. this.changeIcon();
  581. }.bind(this));
  582. },
  583. changeIcon: function(){
  584. if (!this.uploadFileAreaNode){
  585. this.uploadFileAreaNode = new Element("div");
  586. var html = "<input name=\"file\" type=\"file\"/>";
  587. this.uploadFileAreaNode.set("html", html);
  588. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  589. this.fileUploadNode.addEvent("change", function(){
  590. var files = fileNode.files;
  591. if (files.length){
  592. for (var i = 0; i < files.length; i++) {
  593. var file = files.item(i);
  594. var formData = new FormData();
  595. formData.append('file', file);
  596. //formData.append('name', file.name);
  597. //formData.append('folder', folderId);
  598. this.app.restActions.updataColumnIcon(this.data.id ,function(){
  599. this.app.restActions.getColumn(this.data, function(json){
  600. if (json.data){
  601. this.data = json.data;
  602. if (this.data.appIcon){
  603. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.appIcon+") center center no-repeat");
  604. }else{
  605. this.iconPreviewNode.setStyle("background", "url("+"/x_component_cms_Column/$Main/default/icon/category2.png) center center no-repeat")
  606. }
  607. }
  608. }.bind(this), false)
  609. }.bind(this), null, formData, file);
  610. }
  611. }
  612. }.bind(this));
  613. }
  614. var fileNode = this.uploadFileAreaNode.getFirst();
  615. fileNode.click();
  616. },
  617. createPropertyContentNode: function(){
  618. this.propertyContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  619. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  620. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  621. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  622. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  623. html += "<tr><td class='formTitle'>"+this.app.lp.application.sort+"</td><td id='formApplicationSort'></td></tr>";
  624. // html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  625. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  626. html += "</table>";
  627. this.propertyContentNode.set("html", html);
  628. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  629. this.nameInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  630. this.aliasInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  631. this.descriptionInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  632. this.sortInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationSort"), this.data.appInfoSeq, this.app.css.formInput);
  633. //this.typeInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  634. },
  635. createControllerListNode: function(){
  636. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  637. this.controllerListTitleNode = new Element("div", {
  638. "styles": this.app.css.controllerListTitleNode,
  639. "text": this.app.lp.application.controllerList
  640. }).inject(this.contentAreaNode);
  641. this.controllerListContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  642. this.administratorsContentNode = new Element("div", {"styles": this.app.css.administratorsContentNode}).inject(this.controllerListContentNode);
  643. var changeAdministrators = new Element("div", {
  644. "styles": {
  645. "margin-left": "40px",
  646. "float": "left",
  647. "background-color": "#FFF",
  648. "padding": "4px 14px",
  649. "border": "1px solid #999",
  650. "border-radius": "3px",
  651. "margin-top": "10px",
  652. "margin-bottom": "20px",
  653. "font-size": "14px",
  654. "color": "#666",
  655. "cursor": "pointer"
  656. },
  657. "text": "设置管理者"
  658. }).inject(this.contentAreaNode);
  659. changeAdministrators.addEvent("click", function(){
  660. this.changeAdministrators();
  661. }.bind(this));
  662. if (this.controllerList){
  663. var explorer = {
  664. "actions": this.personActions,
  665. "app": {
  666. "lp": this.app.lp
  667. }
  668. }
  669. this.controllerList.each(function(name){
  670. if (name) var admin = new MWF.widget.Person({"name": name}, this.administratorsContentNode, explorer, false, null, {"style": "application"});
  671. }.bind(this));
  672. }
  673. },
  674. changeAdministrators: function(){
  675. var explorer = {
  676. "actions": this.personActions,
  677. "app": {
  678. "lp": this.app.lp
  679. }
  680. }
  681. var options = {
  682. "type": "person",
  683. "title": "设置应用管理者",
  684. "names": this.controllerList || [],
  685. "onComplete": function(items){
  686. this.administratorsContentNode.empty();
  687. //var controllerList = [];
  688. //items.each(function(item){
  689. // controllerList.push(item.data.name);
  690. // var admin = new MWF.widget.Person(item.data, this.administratorsContentNode, explorer, false, null, {"style": "application"});
  691. //}.bind(this));
  692. //this.controllerList = controllerList;
  693. //this.app.restActions.saveApplication(this.data, function(json){
  694. //
  695. //}.bind(this));
  696. var controllerList = [];
  697. items.each(function(item){
  698. controllerList.push(item.data.name);
  699. var admin = new MWF.widget.Person(item.data, this.administratorsContentNode, explorer, false, null, {"style": "application"});
  700. }.bind(this));
  701. controllerList.each(function(item){
  702. if( !this.controllerList.contains( item ) ){
  703. var controllerData = {
  704. "objectType": "APPINFO",
  705. "objectId": this.data.id,
  706. "adminUid": item,
  707. "adminName": item,
  708. "adminLevel": "ADMIN"
  709. }
  710. this.app.restActions.saveController(controllerData, function(json){
  711. controllerData.id = json.data.id;
  712. this.controllerData.push( controllerData );
  713. }.bind(this), null, false);
  714. }
  715. }.bind(this))
  716. this.controllerList.each(function(item){
  717. if( !controllerList.contains( item ) ){
  718. var ad = null;
  719. var id = "";
  720. this.controllerData.each(function(data){
  721. if( data.adminName == item ){
  722. ad = data;
  723. id = data.id;
  724. }
  725. }.bind(this));
  726. this.app.restActions.removeController(id, function(json){
  727. this.controllerData.erase( ad )
  728. }.bind(this), null, false);
  729. }
  730. }.bind(this))
  731. this.controllerList = controllerList;
  732. this.app.notice( MWF.CMSCM.LP.setControllerSuccess , "success");
  733. }.bind(this)
  734. };
  735. var selector = new MWF.OrgSelector(this.app.content, options);
  736. },
  737. createAvailableNode: function(){
  738. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  739. this.availableTitleNode = new Element("div", {
  740. "styles": this.app.css.availableTitleNode,
  741. "text": this.app.lp.application.available
  742. }).inject(this.contentAreaNode);
  743. this.availableContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  744. this.availableItemsContentNode = new Element("div", {"styles": this.app.css.availableItemsContentNode}).inject(this.availableContentNode);
  745. this.availableActionAreaNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  746. var changeIdentityList = new Element("div", {
  747. "styles": this.app.css.selectButtonStyle,
  748. "text": "设置可用人员"
  749. }).inject(this.availableActionAreaNode);
  750. changeIdentityList.addEvent("click", function(){
  751. this.changeAvailableIdentitys();
  752. }.bind(this));
  753. var changeDepartmentList = new Element("div", {
  754. "styles": this.app.css.selectButtonStyle,
  755. "text": "设置可用部门"
  756. }).inject(this.availableActionAreaNode);
  757. changeDepartmentList.addEvent("click", function(){
  758. this.changeAvailableDepartments();
  759. }.bind(this));
  760. var changeCompanyList = new Element("div", {
  761. "styles": this.app.css.selectButtonStyle,
  762. "text": "设置可用公司"
  763. }).inject(this.availableActionAreaNode);
  764. changeCompanyList.addEvent("click", function(){
  765. this.changeAvailableCompanys();
  766. }.bind(this));
  767. this.setAvailableItems();
  768. },
  769. setAvailableItems: function(){
  770. var explorer = {
  771. "actions": this.personActions,
  772. "app": {
  773. "lp": this.app.lp
  774. }
  775. }
  776. if (this.availablePersonList){
  777. this.availablePersonList.each(function(name){
  778. if (name) new MWF.widget.Person({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  779. }.bind(this));
  780. }
  781. if (this.availableDepartmentList){
  782. this.availableDepartmentList.each(function(name){
  783. if (name) new MWF.widget.Department({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  784. }.bind(this));
  785. }
  786. if (this.availableCompanyList){
  787. this.availableCompanyList.each(function(name){
  788. if (name) new MWF.widget.Company({"name": name}, this.availableItemsContentNode, explorer, false, null, {"style": "application"});
  789. }.bind(this));
  790. }
  791. },
  792. changeAvailableIdentitys: function(){
  793. var explorer = {
  794. "actions": this.personActions,
  795. "app": {
  796. "lp": this.app.lp
  797. }
  798. }
  799. var options = {
  800. "type": "person",
  801. "title": "设置应用可用人员",
  802. "names": this.availablePersonList || [],
  803. "onComplete": function(items){
  804. var availablePersonList = [];
  805. items.each(function(item){
  806. availablePersonList.push(item.data.name);
  807. }.bind(this));
  808. availablePersonList.each(function(item){
  809. if( !this.availablePersonList.contains( item ) ){
  810. var permissionData = {
  811. "objectType": "APPINFO",
  812. "objectId": this.data.id,
  813. "usedObjectType": "USER",
  814. "usedObjectCode": item,
  815. "usedObjectName": item
  816. }
  817. this.app.restActions.savePermission(permissionData, function(json){
  818. permissionData.id = json.data.id;
  819. this.availableData.push( permissionData );
  820. }.bind(this), null, false);
  821. }
  822. }.bind(this))
  823. this.availablePersonList.each(function(item){
  824. if( !availablePersonList.contains( item ) ){
  825. var ad = null;
  826. var id = ""
  827. this.availableData.each(function(data){
  828. if( data.usedObjectName == item ){
  829. ad = data;
  830. id = data.id;
  831. }
  832. }.bind(this));
  833. this.app.restActions.removePermission(id, function(json){
  834. this.availableData.erase( ad )
  835. }.bind(this), null, false);
  836. }
  837. }.bind(this))
  838. this.availablePersonList = availablePersonList;
  839. this.availableItemsContentNode.empty();
  840. this.setAvailableItems();
  841. this.app.notice( MWF.CMSCM.LP.setAvailableIdentitySuccess , "success");
  842. }.bind(this)
  843. };
  844. var selector = new MWF.OrgSelector(this.app.content, options);
  845. },
  846. changeAvailableDepartments: function(){
  847. var explorer = {
  848. "actions": this.personActions,
  849. "app": {
  850. "lp": this.app.lp
  851. }
  852. }
  853. var options = {
  854. "type": "department",
  855. "title": "设置应用可用部门",
  856. "names": this.availableDepartmentList || [],
  857. "onComplete": function(items){
  858. var availableDepartmentList = [];
  859. items.each(function(item){
  860. availableDepartmentList.push(item.data.name);
  861. }.bind(this));
  862. availableDepartmentList.each(function(item){
  863. if( !this.availableDepartmentList.contains( item ) ){
  864. var permissionData = {
  865. "objectType": "APPINFO",
  866. "objectId": this.data.id,
  867. "usedObjectType": "DEPARTMENT",
  868. "usedObjectCode": item,
  869. "usedObjectName": item
  870. }
  871. this.app.restActions.savePermission(permissionData, function(json){
  872. permissionData.id = json.data.id;
  873. this.availableData.push( permissionData );
  874. }.bind(this), null, false);
  875. }
  876. }.bind(this))
  877. this.availableDepartmentList.each(function(item){
  878. if( !availableDepartmentList.contains( item ) ){
  879. var ad = null;
  880. var id = ""
  881. this.availableData.each(function(data){
  882. if( data.usedObjectName == item ){
  883. ad = data;
  884. id = data.id;
  885. }
  886. }.bind(this));
  887. this.app.restActions.removePermission(id, function(json){
  888. this.availableData.erase( ad )
  889. }.bind(this), null, false);
  890. }
  891. }.bind(this))
  892. this.availableDepartmentList = availableDepartmentList;
  893. this.availableItemsContentNode.empty();
  894. this.setAvailableItems();
  895. this.app.notice( MWF.CMSCM.LP.setAvailableDepartmentSuccess , "success");
  896. }.bind(this)
  897. };
  898. var selector = new MWF.OrgSelector(this.app.content, options);
  899. },
  900. changeAvailableCompanys: function(){
  901. var explorer = {
  902. "actions": this.personActions,
  903. "app": {
  904. "lp": this.app.lp
  905. }
  906. }
  907. var options = {
  908. "type": "company",
  909. "title": "设置应用可用公司",
  910. "names": this.availableCompanyList || [],
  911. "onComplete": function(items) {
  912. var availableCompanyList = [];
  913. items.each(function (item) {
  914. availableCompanyList.push(item.data.name);
  915. }.bind(this));
  916. availableCompanyList.each(function (item) {
  917. if (!this.availableCompanyList.contains(item)) {
  918. var permissionData = {
  919. "objectType": "APPINFO",
  920. "objectId": this.data.id,
  921. "usedObjectType": "COMPANY",
  922. "usedObjectCode": item,
  923. "usedObjectName": item
  924. }
  925. this.app.restActions.savePermission(permissionData, function (json) {
  926. permissionData.id = json.data.id;
  927. this.availableData.push( permissionData );
  928. }.bind(this), null, false);
  929. }
  930. }.bind(this))
  931. this.availableCompanyList.each(function (item) {
  932. if (!availableCompanyList.contains(item)) {
  933. var ad = null;
  934. var id = ""
  935. this.availableData.each(function (data) {
  936. if (data.usedObjectName == item) {
  937. ad = data;
  938. id = data.id;
  939. }
  940. }.bind(this));
  941. this.app.restActions.removePermission(id, function (json) {
  942. this.availableData.erase(ad)
  943. }.bind(this), null, false);
  944. }
  945. }.bind(this))
  946. this.availableCompanyList = availableCompanyList;
  947. this.availableItemsContentNode.empty();
  948. this.setAvailableItems();
  949. this.app.notice( MWF.CMSCM.LP.setAvailableCompanySuccess , "success");
  950. }.bind(this)
  951. };
  952. var selector = new MWF.OrgSelector(this.app.content, options);
  953. },
  954. createEditBaseNode: function(){
  955. this.editBaseNode = new Element("button", {
  956. "styles": this.app.css.editBaseNode,
  957. "text": this.app.lp.edit,
  958. "events": {"click": this.editBaseInfor.bind(this)}
  959. }).inject(this.baseActionNode);
  960. },
  961. createCancelBaseNode: function(){
  962. this.cancelBaseNode = new Element("button", {
  963. "styles": this.app.css.cancelBaseNode,
  964. "text": this.app.lp.cancel,
  965. "events": {"click": this.cancelBaseInfor.bind(this)}
  966. }).inject(this.baseActionNode);
  967. },
  968. createSaveBaseNode: function(){
  969. this.saveBaseNode = new Element("button", {
  970. "styles": this.app.css.saveBaseNode,
  971. "text": this.app.lp.save,
  972. "events": {"click": this.saveBaseInfor.bind(this)}
  973. }).inject(this.baseActionNode);
  974. },
  975. editBaseInfor: function(){
  976. this.baseActionNode.empty();
  977. this.editBaseNode = null;
  978. this.createCancelBaseNode();
  979. this.createSaveBaseNode();
  980. this.editMode();
  981. },
  982. editMode: function(){
  983. this.nameInput.editMode();
  984. this.aliasInput.editMode();
  985. this.descriptionInput.editMode();
  986. this.sortInput.editMode();
  987. //this.typeInput.editMode();
  988. this.isEdit = true;
  989. },
  990. readMode: function(){
  991. this.nameInput.readMode();
  992. this.aliasInput.readMode();
  993. this.descriptionInput.readMode();
  994. this.sortInput.readMode();
  995. //this.typeInput.readMode();
  996. this.isEdit = false;
  997. },
  998. cancelBaseInfor: function(){
  999. if (this.data.name){
  1000. this.baseActionNode.empty();
  1001. this.cancelBaseNode = null;
  1002. this.saveBaseNode = null;
  1003. this.createEditBaseNode();
  1004. this.readMode();
  1005. }else{
  1006. this.destroy();
  1007. }
  1008. },
  1009. saveBaseInfor: function(){
  1010. if (!this.nameInput.input.get("value")){
  1011. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  1012. return false;
  1013. }
  1014. this.node.mask({
  1015. "style": {
  1016. "opacity": 0.7,
  1017. "background-color": "#999"
  1018. }
  1019. });
  1020. this.save(function(){
  1021. this.baseActionNode.empty();
  1022. this.cancelBaseNode = null;
  1023. this.saveBaseNode = null;
  1024. this.createEditBaseNode();
  1025. this.readMode();
  1026. this.node.unmask();
  1027. }.bind(this), function(xhr, text, error){
  1028. var errorText = error;
  1029. if (xhr) errorText = xhr.responseText;
  1030. this.app.notice("request json error: "+errorText, "error");
  1031. this.node.unmask();
  1032. }.bind(this));
  1033. },
  1034. save: function(callback, cancel){
  1035. this.data.name = this.nameInput.input.get("value");
  1036. this.data.appName = this.data.name;
  1037. this.data.alias = this.aliasInput.input.get("value");
  1038. this.data.appAlias = this.data.alias;
  1039. this.data.description = this.descriptionInput.input.get("value");
  1040. this.data.appInfoSeq = this.sortInput.input.get("value");
  1041. //this.data.applicationCategory = this.typeInput.input.get("value");
  1042. this.app.restActions.saveColumn(this.data, function(json){
  1043. this.propertyTitleBar.set("text", this.data.name);
  1044. this.data.id = json.data.id;
  1045. this.nameInput.save();
  1046. this.aliasInput.save();
  1047. this.descriptionInput.save();
  1048. this.sortInput.save();
  1049. //this.typeInput.save();
  1050. if (callback) callback();
  1051. }.bind(this), function(xhr, text, error){
  1052. if (cancel) cancel(xhr, text, error);
  1053. }.bind(this));
  1054. }
  1055. });
  1056. MWF.xApplication.cms.ColumnManager.Input = new Class({
  1057. Implements: [Events],
  1058. initialize: function(node, value, style){
  1059. this.node = $(node);
  1060. this.value = value || "";
  1061. this.style = style;
  1062. this.load();
  1063. },
  1064. load: function(){
  1065. this.content = new Element("div", {
  1066. "styles": this.style.content,
  1067. "text": this.value
  1068. }).inject(this.node);
  1069. },
  1070. editMode: function(){
  1071. this.content.empty();
  1072. this.input = new Element("input",{
  1073. "styles": this.style.input,
  1074. "value": this.value
  1075. }).inject(this.content);
  1076. this.input.addEvents({
  1077. "focus": function(){
  1078. this.input.setStyles(this.style.input_focus);
  1079. }.bind(this),
  1080. "blur": function(){
  1081. this.input.setStyles(this.style.input);
  1082. }.bind(this)
  1083. });
  1084. },
  1085. readMode: function(){
  1086. this.content.empty();
  1087. this.input = null;
  1088. this.content.set("text", this.value);
  1089. },
  1090. save: function(){
  1091. if (this.input) this.value = this.input.get("value");
  1092. return this.value;
  1093. }
  1094. });