Setting.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xApplication.Forum.Setting = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "index" : 0
  10. },
  11. initialize: function (node, app, actions, options) {
  12. this.setOptions(options);
  13. this.app = app;
  14. this.lp = app.lp;
  15. this.path = "/x_component_Forum/$Setting/";
  16. this.loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. },
  20. loadCss: function () {
  21. this.cssPath = "/x_component_Forum/$Setting/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function () {
  25. //this.middleContent = this.app.middleContent;
  26. this.createNaviContent();
  27. this.createContentDiv();
  28. this.resizeWindowFun = this.resizeWindow.bind(this)
  29. this.resizeWindow();
  30. this.app.addEvent("resize", this.resizeWindowFun);
  31. },
  32. destroy: function(){
  33. if( this.contentDiv )this.contentDiv.empty();
  34. if( this.explorer ){
  35. this.explorer.destroy();
  36. delete this.explorer;
  37. }
  38. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  39. this.node.empty();
  40. delete this;
  41. },
  42. resizeWindow: function(){
  43. var size = this.app.node.getSize();
  44. var topSize = this.app.topNode ? this.app.topNode.getSize() : {"x": 0, "y": 0};
  45. // var topSize = {"x": 0, "y": 0};
  46. //var pt = this.app.contentContainerNode.getStyle("padding-top").toFloat();
  47. //var pb = this.app.contentContainerNode.getStyle("padding-bottom").toFloat();
  48. var height = size.y - topSize.y; //- pt - pb;
  49. this.naviDiv.setStyles({"height":height+"px"});
  50. this.naviContentDiv.setStyles({"height":(height-120)+"px"});
  51. this.contentDiv.setStyles({"height":height+"px"});
  52. },
  53. createNaviContent: function(){
  54. this.naviDiv = new Element("div.naviDiv",{
  55. "styles":this.css.naviDiv
  56. }).inject(this.node);
  57. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  58. "styles":this.css.naviTitleDiv,
  59. "text": this.lp.setting
  60. }).inject(this.naviDiv);
  61. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  62. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  63. var jsonUrl = this.path+"navi.json";
  64. MWF.getJSON(jsonUrl, function(json){
  65. json.each(function(data, i){
  66. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv);
  67. naviContentLi.addEvents({
  68. "mouseover" : function(ev){
  69. if(this.bindObj.currentNaviItem != this.node) this.node.setStyles( this.styles );
  70. }.bind({"styles": this.css.naviContentLi_over, "node":naviContentLi, "bindObj": this }),
  71. "mouseout" : function(ev){
  72. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  73. }.bind({"styles": this.css.naviContentLi, "node":naviContentLi, "bindObj": this }) ,
  74. "click" : function(ev){
  75. if( this.bindObj.currentNaviItem )this.bindObj.currentNaviItem.setStyles( this.bindObj.css.naviContentLi );
  76. this.node.setStyles( this.styles );
  77. this.bindObj.currentNaviItem = this.node;
  78. this.node.store( "index" , i );
  79. if( this.action && this.bindObj[this.action] )this.bindObj[this.action]();
  80. }.bind({"styles": this.css.naviContentLi_current, "node":naviContentLi, "bindObj": this, "action" : data.action }) ,
  81. });
  82. var naviContentImg = new Element("img.naviContentImg",{
  83. "styles":this.css.naviContentImg,
  84. "src":this.path+this.options.style+"/icon/"+data.icon
  85. }).inject(naviContentLi);
  86. var naviContentSpan = new Element("span.naviContentSpan",{
  87. "styles":this.css.naviContentSpan,
  88. "text":data.title
  89. }).inject(naviContentLi);
  90. if( i == this.options.index )naviContentLi.click();
  91. }.bind(this));
  92. }.bind(this));
  93. },
  94. createContentDiv: function(){
  95. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.node);
  96. },
  97. openCategorySetting: function(){
  98. if( this.contentDiv )this.contentDiv.empty();
  99. if( this.explorer ){
  100. this.explorer.destroy();
  101. delete this.explorer;
  102. }
  103. this.explorer = new MWF.xApplication.Forum.Setting.CategorySettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  104. this.explorer.load();
  105. },
  106. openSectionSetting: function(){
  107. if( this.contentDiv )this.contentDiv.empty();
  108. if( this.explorer ){
  109. this.explorer.destroy();
  110. delete this.explorer;
  111. }
  112. this.explorer = new MWF.xApplication.Forum.Setting.SectionSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  113. this.explorer.load();
  114. },
  115. openSystemSetting : function(){
  116. if( this.contentDiv )this.contentDiv.empty();
  117. if( this.explorer ){
  118. this.explorer.destroy();
  119. delete this.explorer;
  120. }
  121. this.explorer = new MWF.xApplication.Forum.Setting.SystemSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  122. this.explorer.load();
  123. },
  124. openRoleSetting: function(){
  125. if( this.contentDiv )this.contentDiv.empty();
  126. if( this.explorer ){
  127. this.explorer.destroy();
  128. delete this.explorer;
  129. }
  130. this.explorer = new MWF.xApplication.Forum.Setting.RoleSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  131. this.explorer.load();
  132. },
  133. openPermissionSetting: function(){
  134. if( this.contentDiv )this.contentDiv.empty();
  135. if( this.explorer ){
  136. this.explorer.destroy();
  137. delete this.explorer;
  138. }
  139. this.explorer = new MWF.xApplication.Forum.Setting.PermissionSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  140. this.explorer.load();
  141. },
  142. selectPerson: function( item, type , count ){
  143. if( type == "person" ){
  144. var title = this.lp.selectPerson
  145. }else if( type == "department" ){
  146. title = this.lp.selectDepartment
  147. }else if( type == "company" ){
  148. title = this.lp.selectCompany
  149. }
  150. MWF.xDesktop.requireApp("Organization", "Selector.package",null, false);
  151. var value = item.get("text").split( "," );
  152. var options = {
  153. "type": type,
  154. "title": title ,
  155. "count" : count,
  156. "names": value || [],
  157. "onComplete": function(items){
  158. var arr = [];
  159. items.each(function(item){
  160. arr.push(item.data.name);
  161. }.bind(this));
  162. item.set("text",arr.join(","));
  163. }.bind(this)
  164. };
  165. var selector = new MWF.OrgSelector(this.app.content, options);
  166. }
  167. });
  168. MWF.xApplication.Forum.Setting.CategorySettingExplorer = new Class({
  169. Extends: MWF.widget.Common,
  170. Implements: [Options, Events],
  171. options: {
  172. "style": "default"
  173. },
  174. initialize: function (container, app, parent, options) {
  175. this.container = container;
  176. this.parent = parent;
  177. this.app = app;
  178. this.css = this.parent.css;
  179. this.lp = this.app.lp;
  180. },
  181. load: function () {
  182. this.container.empty();
  183. if( this.app.access.isAdmin() ){
  184. this.loadToolbar();
  185. }
  186. this.loadView();
  187. },
  188. destroy : function(){
  189. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  190. this.view.destroy();
  191. },
  192. loadToolbar: function(){
  193. this.toolbar = new Element("div",{
  194. styles : this.css.toolbar
  195. }).inject(this.container)
  196. this.createActionNode = new Element("div",{
  197. styles : this.css.toolbarActionNode,
  198. text: this.lp.createCategory
  199. }).inject(this.toolbar);
  200. this.createActionNode.addEvent("click",function(){
  201. var form = new MWF.xApplication.Forum.Setting.CategorySettingForm(this, {}, {
  202. onPostOk : function(){
  203. this.view.reload();
  204. }.bind(this)})
  205. form.create();
  206. }.bind(this))
  207. this.fileterNode = new Element("div",{
  208. styles : this.css.fileterNode
  209. }).inject(this.toolbar);
  210. },
  211. loadView : function(){
  212. this.viewContainer = Element("div",{
  213. "styles" : this.css.viewContainer
  214. }).inject(this.container);
  215. this.resizeWindow();
  216. this.resizeWindowFun = this.resizeWindow.bind(this)
  217. this.app.addEvent("resize", this.resizeWindowFun );
  218. this.view = new MWF.xApplication.Forum.Setting.CategorySettingView( this.viewContainer, this.app, this, {
  219. templateUrl : this.parent.path+"listItemCategory.json",
  220. scrollEnable : true
  221. } )
  222. this.view.load();
  223. },
  224. resizeWindow: function(){
  225. var size = this.container.getSize();
  226. if( this.toolbar ){
  227. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  228. }else{
  229. this.viewContainer.setStyles({"height":(size.y-56)+"px"});
  230. }
  231. }
  232. })
  233. MWF.xApplication.Forum.Setting.CategorySettingView = new Class({
  234. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  235. _createDocument: function(data){
  236. return new MWF.xApplication.Forum.Setting.CategorySettingDocument(this.viewNode, data, this.explorer, this);
  237. },
  238. _getCurrentPageData: function(callback, count){
  239. if (!count)count = 20;
  240. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  241. //var filter = this.filterData || {};
  242. this.actions.listCategoryAllByAdmin( function (json) {
  243. if (callback)callback(json);
  244. }.bind(this))
  245. },
  246. _removeDocument: function(documentData, all){
  247. this.actions.deleteCategory(documentData.id, function(json){
  248. this.reload();
  249. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  250. }.bind(this));
  251. },
  252. _create: function(){
  253. },
  254. _openDocument: function( documentData ){
  255. var form = new MWF.xApplication.Forum.Setting.CategorySettingForm(this, documentData, {
  256. onPostOk : function(){
  257. this.reload();
  258. }.bind(this)
  259. })
  260. //if( this.app.access.hasForumAdminAuthority( documentData ) ){
  261. if( this.app.access.isAdmin() ){
  262. form.edit();
  263. }else{
  264. form.open();
  265. }
  266. },
  267. _queryCreateViewNode: function(){
  268. },
  269. _postCreateViewNode: function( viewNode ){
  270. },
  271. _queryCreateViewHead:function(){
  272. },
  273. _postCreateViewHead: function( headNode ){
  274. }
  275. })
  276. MWF.xApplication.Forum.Setting.CategorySettingDocument = new Class({
  277. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  278. _queryCreateDocumentNode:function( itemData ){
  279. },
  280. _postCreateDocumentNode: function( itemNode, itemData ){
  281. }
  282. })
  283. MWF.xApplication.Forum.Setting.CategorySettingForm = new Class({
  284. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  285. Implements: [Options, Events],
  286. options: {
  287. "style": "default",
  288. "width": "1011",
  289. "height": "90%",
  290. "hasTop": true,
  291. "hasIcon": false,
  292. "hasTopIcon" : true,
  293. "hasTopContent" : true,
  294. "hasBottom": true,
  295. "title": MWF.xApplication.Forum.LP.categoryFormTitle,
  296. "draggable": true,
  297. "closeAction": true
  298. },
  299. createContent: function () {
  300. this.formContentNode = new Element("div.formContentNode", {
  301. "styles": this.css.formContentNode
  302. }).inject(this.formNode);
  303. this.formTableContainer = new Element("div.formTableContainer", {
  304. "styles": this.css.formTableContainer
  305. }).inject(this.formContentNode);
  306. this.formTableArea = new Element("div.formTableArea", {
  307. "styles": this.css.formTableArea
  308. }).inject(this.formTableContainer);
  309. this._createTableContent();
  310. },
  311. _createTableContent: function () {
  312. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  313. "<tr>" +
  314. " <td styles='formTableTitle' lable='forumName' width='10%'></td>" +
  315. " <td styles='formTableValue' item='forumName' width='40%'></td>" +
  316. " <td styles='formTableTitle' lable='indexListStyle' width='10%'></td>" +
  317. " <td styles='formTableValue' item='indexListStyle' width='40%'></td>" +
  318. "</tr><tr>" +
  319. " <td styles='formTableTitle' lable='forumStatus'></td>" +
  320. " <td styles='formTableValue' item='forumStatus'></td>" +
  321. " <td styles='formTableTitle' lable='creatorName'></td>" +
  322. " <td styles='formTableValue' item='creatorName'></td>" +
  323. "</tr><tr>" +
  324. " <td styles='formTableTitle' lable='forumManagerName'></td>" +
  325. " <td styles='formTableValue' item='forumManagerName'></td>" +
  326. " <td styles='formTableTitle' lable='orderNumber'></td>" +
  327. " <td styles='formTableValue' item='orderNumber'></td>" +
  328. "</tr><tr>" +
  329. " <td styles='formTableTitle' lable='forumVisiable'></td>" +
  330. " <td styles='formTableValue' item='forumVisiable'></td>" +
  331. " <td styles='formTableValue' colspan='2'>" +
  332. " <span item='forumVisiableCompanyButton'></span>"+
  333. " <span item='forumVisiableDepartmentButton'></span>"+
  334. " <span item='forumVisiablePersonButton'></span>"+
  335. " </td>" +
  336. "</tr><tr>" +
  337. " <td></td>" +
  338. " <td colspan='3'>"+
  339. " <div item='forumVisiableCompany'></div>"+
  340. " <div item='forumVisiableDepartment'></div>"+
  341. " <div item='forumVisiablePerson'></div>"+
  342. " </td>" +
  343. "</tr><tr>" +
  344. " <td styles='formTableTitle' lable='forumColorArea'></td>" +
  345. " <td styles='formTableValue'>"+
  346. " <div item='forumColorArea' style='float:left;'></div>"+
  347. " <div item='forumColorButton' style='float:left;'></div>"+
  348. " </td>" +
  349. " <td styles='formTableTitle' lable='subjectType'></td>" +
  350. " <td styles='formTableValue' item='subjectType'></td>" +
  351. //"</tr><tr>" +
  352. //" <td styles='formTableTitle' lable='indexRecommendable'></td>" +
  353. // " <td styles='formTableValue' item='indexRecommendable'></td>" +
  354. //" <td styles='formTableTitle' lable=''></td>" +
  355. //" <td styles='formTableValue' item=''></td>" +
  356. "</tr><tr>" +
  357. " <td styles='formTableTitle' lable='forumNotice'></td>" +
  358. " <td styles='formTableValue' item='forumNotice' colspan='3'></td>" +
  359. "</tr>"
  360. "</table>"
  361. this.formTableArea.set("html", html);
  362. //value : function(){ return this.lp.defaultForumColor }.bind(this), defaultValue : this.lp.defaultForumColor
  363. var formVisiableButtonStyle = (( !this.isEdited && !this.isNew ) || !this.data.forumVisiable ||(this.data.forumVisiable == this.lp.allPerson )) ? { display:"none"} : { display:""};
  364. var formVisiableStyle = ( !this.data.forumVisiable ||(this.data.forumVisiable == this.lp.allPerson )) ? { display:"none"} : { display:""};
  365. var selectColorButtonStyle = (!this.isEdited && !this.isNew) ? { display : "none" } : {};
  366. MWF.xDesktop.requireApp("Template", "MForm", function () {
  367. this.form = new MForm(this.formTableArea, this.data, {
  368. style: "forum",
  369. isEdited: this.isEdited || this.isNew,
  370. itemTemplate: {
  371. forumName: {text: this.lp.forumName, notEmpty: true},
  372. forumManagerName: {text: this.lp.forumManagerName, tType : "person", "defaultValue" : this.app.userName, "count" : 0 },
  373. forumVisiable: {text: this.lp.forumVisiable, type : "select", selectValue : this.lp.forumVisiableValue.split(","), event : {
  374. change : function( it, ev ){
  375. var styles = it.getValue() == this.lp.allPerson ? { display : "none" } : { display : "" };
  376. it.form.getItem("forumVisiablePersonButton").setStyles( styles );
  377. it.form.getItem("forumVisiableDepartmentButton").setStyles( styles );
  378. it.form.getItem("forumVisiableCompanyButton").setStyles( styles );
  379. it.form.getItem("forumVisiablePerson").setStyles( styles );
  380. it.form.getItem("forumVisiableDepartment").setStyles( styles );
  381. it.form.getItem("forumVisiableCompany").setStyles( styles );
  382. }.bind(this)
  383. }},
  384. forumVisiablePersonButton : { value : this.lp.selectPerson , type : "button", style : formVisiableButtonStyle, event : {
  385. click : function( it, ev ){
  386. this.explorer.explorer.parent.selectPerson( it.form.getItem("forumVisiablePerson").getElements()[0], "person" , 0 ) }.bind(this)
  387. }},
  388. forumVisiableDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : formVisiableButtonStyle, event : {
  389. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("forumVisiableDepartment").getElements()[0], "department" , 0 )}.bind(this)
  390. }},
  391. forumVisiableCompanyButton : { value : this.lp.selectCompany , type : "button", style : formVisiableButtonStyle, event : {
  392. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("forumVisiableCompany").getElements()[0], "company" , 0 )}.bind(this)
  393. }},
  394. forumVisiableCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_")["company"].join(",") }.bind(this), style : formVisiableStyle },
  395. forumVisiableDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_")["department"].join(",") }.bind(this), style : formVisiableStyle },
  396. forumVisiablePerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_")["person"].join(",") }.bind(this), style : formVisiableStyle },
  397. indexListStyle: {text: this.lp.indexListStyle, type : "select", selectValue : this.lp.indexListStyleValue.split(",") },
  398. forumIndexStyle: {text: this.lp.forumIndexStyle, type : "select", selectValue : this.lp.forumIndexStyleValue.split(",") },
  399. indexRecommendable: {text: this.lp.indexRecommendable, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  400. subjectNeedAudit: {text: this.lp.subjectNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" },
  401. replyNeedAudit: {text: this.lp.replyNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" },
  402. //sectionCreateAble: {text: this.lp.sectionCreateAble, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  403. creatorName: {text: this.lp.creatorName, type : "innerText", "defaultValue" : this.app.userName },
  404. forumStatus: {text: this.lp.forumStatus, type : "select", selectValue : this.lp.forumStatusValue.split(",") },
  405. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  406. forumColorArea: {text: this.lp.forumColor, type: "innerText" },
  407. forumColorButton : { value : this.lp.selectColor , type : "button", style : selectColorButtonStyle, event : {
  408. click : function( it, ev ){ this.selectColor() }.bind(this)
  409. }},
  410. subjectType: {text: this.lp.subjectType, type: "text", defaultValue : this.lp.subjectTypeDefaultValue },
  411. forumNotice: {text: this.lp.forumNotice, type: "rtf", RTFConfig : { skin : "bootstrapck" }}
  412. }
  413. }, this.app);
  414. this.form.load();
  415. var forumColorArea = this.formTableArea.getElements("[item='forumColorArea']")[0];
  416. this.forumColorNode = new Element( "div", {
  417. styles : { "font-size":"12px", height : "24px", "line-height" : "24px", width : "70px", "margin-right" : "20px" , "color" : "#fff", "text-align" : "center", "background-color" : this.data.forumColor || this.lp.defaultForumColor },
  418. text : "效果"
  419. }).inject( forumColorArea )
  420. }.bind(this), true);
  421. },
  422. selectColor: function(){
  423. var form = new MWF.xApplication.Forum.Setting.ForumColorForm(this, {}, {
  424. onPostOk : function( color ){
  425. this.forumColorNode.setStyle( "background-color" , color );
  426. this.data.forumColor = color;
  427. }.bind(this)
  428. })
  429. form.edit();
  430. },
  431. _ok: function (data, callback) {
  432. this.app.restActions.saveCategory( data, function(json){
  433. this.saveRole( json.data.id, function(){
  434. if( callback )callback(json);
  435. this.fireEvent("postOk")
  436. }.bind(this))
  437. }.bind(this));
  438. },
  439. saveRole : function( id, callback ){
  440. var data = this.form.getResult(true, ",", true, false, true);
  441. if( this.isNew )data.id = id;
  442. this.saveRoleMember( true, "forumManagerName" ,"FORUM_SUPER_MANAGER_", data, true )
  443. var flag = data.forumVisiable != this.lp.allPerson;
  444. this.saveRoleMember( flag, "forumVisiable" ,"FORUM_GUEST_", data )
  445. if( callback )callback();
  446. },
  447. saveRoleMember : function( flag, dataKey, code, data , isSingle, callback ){
  448. var orgArray = [];
  449. if( flag ){
  450. if( isSingle ){
  451. if( data[ dataKey ] ){
  452. data[ dataKey ].split(",").each( function( p ){
  453. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  454. })
  455. }
  456. }else{
  457. if( data[ dataKey + "Person" ] ){
  458. data[ dataKey + "Person" ].split(",").each( function( p ){
  459. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  460. })
  461. }
  462. if( data[ dataKey + "Department" ] ) {
  463. data[dataKey + "Department"].split(",").each(function (p) {
  464. if (p != "") orgArray.push({objectName: p, objectType: "部门"});
  465. })
  466. }
  467. if( data[ dataKey + "Company" ] ) {
  468. data[ dataKey + "Company" ].split(",").each( function( p ){
  469. if( p!= "") orgArray.push( { objectName : p, objectType : "公司" } );
  470. })
  471. }
  472. }
  473. }
  474. var d = {
  475. bindObjectArray : orgArray,
  476. bindRoleCode : code + this.data.id
  477. };
  478. this.app.restActions.bindRole( d, function( rData ){
  479. if( callback )callback(json);
  480. }.bind(this))
  481. },
  482. getRoleMemberByCode : function( code ){
  483. if( !this.RoleMember )this.RoleMember = {};
  484. if( this.RoleMember[ code ] ){
  485. return this.RoleMember[ code ];
  486. }
  487. var r = this.RoleMember[ code ] = {
  488. company : [],
  489. department : [],
  490. person : []
  491. };
  492. if( this.data && this.data.id ){
  493. this.actions.listRoleMemberByCode( { "bindRoleCode" : code+ this.data.id }, function(json){
  494. json.data = json.data || [];
  495. json.data.each( function( d ){
  496. if(d.objectType == "公司"){
  497. r.company.push( d.objectName );
  498. }else if(d.objectType == "部门"){
  499. r.department.push( d.objectName );
  500. }else{
  501. r.person.push( d.objectName );
  502. }
  503. }.bind(this) )
  504. }, function(){}, false );
  505. }
  506. return r;
  507. }
  508. });
  509. MWF.xApplication.Forum.Setting.ForumColorForm = new Class({
  510. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  511. Implements: [Options, Events],
  512. options: {
  513. "style": "default",
  514. "width": "820",
  515. "height": "280",
  516. "hasTop": true,
  517. "hasIcon": false,
  518. "hasTopIcon" : true,
  519. "hasTopContent" : true,
  520. "hasBottom": false,
  521. "title": MWF.xApplication.Forum.LP.forumColorFormTitle,
  522. "draggable": true,
  523. "closeAction": true
  524. },
  525. _createTableContent: function () {
  526. var div = new Element("div",{
  527. "styles" : this.css.sectionFormContent
  528. }).inject(this.formTableArea);
  529. div.setStyle( "margin-top" , "10px" );
  530. this.lp.optionsForumColors.each(function(arr, i){
  531. arr.each( function(c , j ){
  532. var iconAreaNode = new Element("div",{
  533. "styles" : this.css.iconAreaNode
  534. }).inject(div);
  535. var iconNode = new Element("div",{
  536. "styles" : {height : "20px", width : "40px", "margin" : "5px 5px 5px 5px" , "background-color" : c, "cursor" : "pointer"}
  537. }).inject(iconAreaNode);
  538. iconAreaNode.store( "color", c );
  539. iconAreaNode.addEvents({
  540. "click" : function(){
  541. this.obj.fireEvent("postOk", this.node.retrieve("color") );
  542. this.obj.close();
  543. }.bind({ obj : this, node : iconAreaNode })
  544. })
  545. }.bind(this))
  546. }.bind(this));
  547. }
  548. });
  549. MWF.xApplication.Forum.Setting.SectionSettingExplorer = new Class({
  550. Extends: MWF.widget.Common,
  551. Implements: [Options, Events],
  552. options: {
  553. "style": "default"
  554. },
  555. initialize: function (container, app, parent, options) {
  556. this.container = container;
  557. this.parent = parent;
  558. this.app = app;
  559. this.css = this.parent.css;
  560. this.lp = this.app.lp;
  561. },
  562. load: function () {
  563. this.container.empty();
  564. this.loadToolbar();
  565. },
  566. destroy : function(){
  567. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun)
  568. this.view.destroy();
  569. },
  570. loadToolbar: function(){
  571. this.toolbar = new Element("div",{
  572. styles : this.css.toolbar
  573. }).inject(this.container)
  574. this.createActionNode = new Element("div",{
  575. styles : this.css.toolbarActionNode,
  576. text: this.lp.createSection
  577. }).inject(this.toolbar);
  578. this.createActionNode.addEvent("click",function(){
  579. var form = new MWF.xApplication.Forum.Setting.SectionSettingForm(this, {}, {
  580. onPostOk : function(){
  581. this.view.reload();
  582. }.bind(this)})
  583. form.create();
  584. }.bind(this))
  585. this.loadCategoryBar();
  586. //this.fileterNode = new Element("div",{
  587. // styles : this.css.fileterNode
  588. //}).inject(this.toolbar);
  589. },
  590. loadCategoryBar : function(){
  591. var _self = this;
  592. //this.categoryBar = new Element("div.categoryBar",{"styles":this.css.categoryBar}).inject(this.contentDiv);
  593. this.allCategoryNode = new Element("li.allCategoryNode", {
  594. "styles": this.css.categoryNode,
  595. "text" : "全部"
  596. }).inject(this.toolbar)
  597. this.allCategoryNode.addEvents({
  598. "mouseover" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode_over) }.bind(this),
  599. "mouseout" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode) }.bind(this),
  600. "click":function(){
  601. if( this.currentCategoryNode )this.currentCategoryNode.setStyles(this.css.categoryNode);
  602. this.currentCategoryNode = this.allCategoryNode;
  603. this.allCategoryNode.setStyles(this.css.categoryNode_current);
  604. this.loadView( )
  605. }.bind(this)
  606. })
  607. var isManager = false;
  608. this.forumAdminObj = {};
  609. this.app.restActions.listCategoryAllByAdmin( function( json ){
  610. json.data.each( function( d ){
  611. var flag = this.app.access.hasForumAdminAuthority( d );
  612. this.forumAdminObj[d.id] = flag;
  613. if( !isManager ){
  614. isManager = flag;
  615. }
  616. var categoryNode = new Element("li.categoryNode", {
  617. "styles": this.css.categoryNode,
  618. "text" : d.forumName
  619. }).inject(this.toolbar);
  620. categoryNode.store( "categoryId" , d.id );
  621. categoryNode.addEvents({
  622. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode_over) }.bind({node : categoryNode }),
  623. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode) }.bind({node : categoryNode }),
  624. "click":function(){
  625. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.categoryNode);
  626. _self.currentCategoryNode = this.node;
  627. this.node.setStyles(_self.css.categoryNode_current);
  628. _self.loadView( )
  629. }.bind({ name : d.id, node : categoryNode })
  630. })
  631. }.bind(this))
  632. }.bind(this), null, false
  633. )
  634. if( !isManager )this.createActionNode.destroy();
  635. this.allCategoryNode.click();
  636. },
  637. loadView : function(){
  638. var categoryId;
  639. if( this.currentCategoryNode ){
  640. categoryId = this.currentCategoryNode.retrieve("categoryId");
  641. }
  642. categoryId = categoryId || "all";
  643. if(this.viewContainer)this.viewContainer.destroy();
  644. this.viewContainer = Element("div",{
  645. "styles" : this.css.viewContainer
  646. }).inject(this.container);
  647. this.resizeWindow();
  648. this.resizeWindowFun = this.resizeWindow.bind(this)
  649. this.app.addEvent("resize", this.resizeWindowFun );
  650. this.view = new MWF.xApplication.Forum.Setting.SectionSettingView( this.viewContainer, this.app, this, {
  651. templateUrl : this.parent.path+"listItemSection.json",
  652. scrollEnable : true,
  653. categoryId : categoryId
  654. } )
  655. this.view.load();
  656. },
  657. resizeWindow: function(){
  658. var size = this.container.getSize();
  659. this.viewContainer.setStyles({"height":(size.y-65)+"px"});
  660. }
  661. })
  662. MWF.xApplication.Forum.Setting.SectionSettingView = new Class({
  663. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  664. _createDocument: function(data){
  665. return new MWF.xApplication.Forum.Setting.SectionSettingDocument(this.viewNode, data, this.explorer, this);
  666. },
  667. _getCurrentPageData: function(callback, count){
  668. if (!count)count = 20;
  669. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  670. //var filter = this.filterData || {};
  671. if( this.options.categoryId == "all" ){
  672. this.actions.listSectionAll( function (json) {
  673. if( !json.data )json.data = [];
  674. if (callback)callback(json);
  675. }.bind(this))
  676. }else{
  677. this.actions.listSectionByAdmin( this.options.categoryId, function (json) {
  678. if( !json.data )json.data = [];
  679. if (callback)callback(json);
  680. }.bind(this))
  681. }
  682. },
  683. _removeDocument: function(documentData, all){
  684. this.actions.deleteSection(documentData.id, function(json){
  685. this.reload();
  686. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  687. }.bind(this));
  688. },
  689. _create: function(){
  690. },
  691. _openDocument: function( documentData ){
  692. var form = new MWF.xApplication.Forum.Setting.SectionSettingForm(this, documentData, {
  693. title : this.lp.sectionFormTitle + " - " + documentData.sectionName,
  694. onPostOk : function(){
  695. this.reload();
  696. }.bind(this)
  697. })
  698. //this.app.access.hasSectionAdminAuthority( documentData , function( flag ){ 只有分区管理员可以对分区以下的板块进行增删改,版主不能
  699. this.app.access.hasForumAdminAuthority( documentData.forumId , function( flag ){
  700. flag ? form.edit() : form.open();
  701. } )
  702. },
  703. _queryCreateViewNode: function(){
  704. },
  705. _postCreateViewNode: function( viewNode ){
  706. },
  707. _queryCreateViewHead:function(){
  708. },
  709. _postCreateViewHead: function( headNode ){
  710. }
  711. })
  712. MWF.xApplication.Forum.Setting.SectionSettingDocument = new Class({
  713. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  714. mouseoverSection : function(sectionNode, ev){
  715. var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  716. if( removeNode )removeNode.setStyle("opacity",1)
  717. },
  718. mouseoutSection : function(sectionNode, ev){
  719. var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  720. if( removeNode )removeNode.setStyle("opacity",0)
  721. },
  722. _queryCreateDocumentNode:function( itemData ){
  723. },
  724. _postCreateDocumentNode: function( itemNode, itemData ){
  725. }
  726. })
  727. MWF.xApplication.Forum.Setting.SectionSettingForm = new Class({
  728. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  729. Implements: [Options, Events],
  730. options: {
  731. "style": "default",
  732. "width": "1100",
  733. "height": "90%",
  734. "hasTop": true,
  735. "hasIcon": false,
  736. "hasTopIcon" : true,
  737. "hasTopContent" : true,
  738. "hasBottom": true,
  739. "title": MWF.xApplication.Forum.LP.sectionFormTitle,
  740. "draggable": true,
  741. "closeAction": true
  742. },
  743. createToolbar: function(){
  744. var _self = this;
  745. this.toolbar = new Element("div",{
  746. styles : this.css.formToolbar
  747. }).inject(this.formNode)
  748. var categoryNode = new Element("li.categoryNode", {
  749. "styles": this.css.formCategoryNode,
  750. "text" : this.lp.baseSetting
  751. }).inject(this.toolbar);
  752. categoryNode.addEvents({
  753. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode_over) }.bind({node : categoryNode }),
  754. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode) }.bind({node : categoryNode }),
  755. "click":function(){
  756. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.formCategoryNode);
  757. _self.currentCategoryNode = this.node;
  758. this.node.setStyles(_self.css.formCategoryNode_current);
  759. _self.baseContainer.setStyle("display","");
  760. _self.permissionContainer.setStyle("display","none");
  761. }.bind({ node : categoryNode })
  762. })
  763. categoryNode.setStyles( this.css.formCategoryNode_current );
  764. _self.currentCategoryNode = categoryNode;
  765. var categoryNode = new Element("li.categoryNode", {
  766. "styles": this.css.formCategoryNode,
  767. "text" : this.lp.permissionSetting
  768. }).inject(this.toolbar);
  769. categoryNode.addEvents({
  770. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode_over) }.bind({node : categoryNode }),
  771. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode) }.bind({node : categoryNode }),
  772. "click":function(){
  773. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.formCategoryNode);
  774. _self.currentCategoryNode = this.node;
  775. this.node.setStyles(_self.css.formCategoryNode_current);
  776. _self.baseContainer.setStyle("display","none");
  777. _self.permissionContainer.setStyle("display","");
  778. }.bind({ node : categoryNode })
  779. })
  780. },
  781. createContent: function () {
  782. this.createToolbar();
  783. this.formContentNode = new Element("div.formContentNode", {
  784. "styles": this.css.formContentNode
  785. }).inject(this.formNode);
  786. this.formTableContainer = new Element("div.formTableContainer", {
  787. "styles": this.css.formTableContainer
  788. }).inject(this.formContentNode);
  789. this.formTableArea = new Element("div.formTableArea", {
  790. "styles": this.css.formTableArea
  791. }).inject(this.formTableContainer);
  792. this._createTableContent();
  793. },
  794. _createTableContent: function () {
  795. _self = this;
  796. this.baseContainer = new Element("div").inject(this.formTableArea)
  797. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  798. "<tr>" +
  799. " <td styles='formTableTitle' lable='sectionName' width='10%'></td>" +
  800. " <td styles='formTableValue' item='sectionName' width='40%'></td>" +
  801. " <td styles='formTableTitle' lable='forumId' width='10%'></td>" +
  802. " <td styles='formTableValue' item='forumId' width='40%'></td>" +
  803. "</tr><tr>" +
  804. //" <td styles='formTableTitle' lable='sectionType'></td>" +
  805. //" <td styles='formTableValue' item='sectionType'></td>" +
  806. //"</tr><tr>" +
  807. " <td styles='formTableTitle' lable='sectionStatus'></td>" +
  808. " <td styles='formTableValue' item='sectionStatus'></td>" +
  809. " <td styles='formTableTitle' lable='orderNumber'></td>" +
  810. " <td styles='formTableValue' item='orderNumber'></td>" +
  811. "</tr><tr>" +
  812. " <td styles='formTableTitle' lable='typeCatagory'></td>" +
  813. " <td styles='formTableValue' item='typeCatagory'></td>" +
  814. " <td styles='formTableTitle' lable='subjectType'></td>" +
  815. " <td styles='formTableValue' item='subjectType'></td>" +
  816. "</tr><tr>" +
  817. " <td styles='formTableTitle' lable='creatorName'></td>" +
  818. " <td styles='formTableValue' item='creatorName'></td>" +
  819. " <td styles='formTableTitle' lable='createTime'></td>" +
  820. " <td styles='formTableValue' item='createTime'></td>" +
  821. "</tr><tr>" +
  822. " <td styles='formTableTitle' lable='sectionIcon'></td>" +
  823. " <td styles='formTableValue' item='sectionIconArea' colspan='3' valign='bottom'></td>" +
  824. "</tr><tr>" +
  825. " <td styles='formTableTitle' lable='sectionDescription'></td>" +
  826. " <td styles='formTableValue' item='sectionDescription' colspan='3'></td>" +
  827. "</tr><tr>" +
  828. " <td styles='formTableTitle' lable='sectionNotice'></td>" +
  829. " <td styles='formTableValue' item='sectionNotice' colspan='3'></td>" +
  830. "</tr>"
  831. "</table>"
  832. this.baseContainer.set("html", html);
  833. this.permissionContainer = new Element("div", { styles : {"display":"none"} }).inject( this.formTableArea );
  834. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  835. "<tr>" +
  836. " <td styles='formTableTitle' lable='moderatorNames'></td>" +
  837. " <td styles='formTableValue' item='moderatorNames' colspan='3'></td>"+
  838. "</tr><tr>" +
  839. " <td styles='formTableTitle' lable='sectionVisiable' width='10%'></td>" +
  840. " <td styles='formTableValue' item='sectionVisiable' width='40%'></td>" +
  841. " <td styles='formTableValue' width='50%' colspan='2'>"+
  842. " <span item='sectionVisiableCompanyButton'></span>"+
  843. " <span item='sectionVisiableDepartmentButton'></span>"+
  844. " <span item='sectionVisiablePersonButton'></span>"+
  845. " </td>" +
  846. "</tr><tr>" +
  847. " <td></td>"+
  848. " <td styles='formTableValue' colspan='3'>"+
  849. " <div styles='formItemSpan' item='sectionVisiableCompany'></div>"+
  850. " <div styles='formItemSpan' item='sectionVisiableDepartment'></div>"+
  851. " <div styles='formItemSpan' item='sectionVisiablePerson'></div>"+
  852. " </td>" +
  853. "</tr><tr>" +
  854. " <td styles='formTableTitle' lable='subjectPublishAble' width='10%'></td>" +
  855. " <td styles='formTableValue' item='subjectPublishAble' width='40%'></td>" +
  856. " <td styles='formTableValue' width='50%' colspan='2'>"+
  857. " <span item='subjectPublishCompanyButton'></span>"+
  858. " <span item='subjectPublishDepartmentButton'></span>"+
  859. " <span item='subjectPublishPersonButton'></span>"+
  860. " </td>" +
  861. "</tr><tr>" +
  862. " <td></td>"+
  863. " <td styles='formTableValue' colspan='3'>"+
  864. " <div styles='formItemSpan' item='subjectPublishCompany'></div>"+
  865. " <div styles='formItemSpan' item='subjectPublishDepartment'></div>"+
  866. " <div styles='formItemSpan' item='subjectPublishPerson'></div>"+
  867. " </td>" +
  868. "</tr><tr>" +
  869. " <td styles='formTableTitle' lable='replyPublishAble'></td>" +
  870. " <td styles='formTableValue' item='replyPublishAble'></td>" +
  871. " <td styles='formTableValue' width='50%' colspan='2'>"+
  872. " <span styles='formItemDiv' item='replyPublishCompanyButton'></span>"+
  873. " <span styles='formItemDiv' item='replyPublishDepartmentButton'></span>"+
  874. " <span styles='formItemDiv' item='replyPublishPersonButton'></span>"+
  875. " </td>" +
  876. "</tr><tr>" +
  877. " <td></td>"+
  878. " <td styles='formTableValue' coldiv='3'>"+
  879. " <div item='replyPublishCompany'></div>"+
  880. " <div item='replyPublishDepartment'></div>"+
  881. " <div item='replyPublishPerson'></div>"+
  882. " </td>" +
  883. "</tr><tr item='indexRecommendTr' style='"+ ( this.data.sectionVisiable == this.lp.byPermission ? "display:none;" : "display:;" ) +"'>" +
  884. " <td styles='formTableTitle' lable='indexRecommendable'></td>" +
  885. " <td styles='formTableValue' item='indexRecommendable'></td>" +
  886. " <td styles='formTableTitle' lable='indexRecommenPerson' style='"+ ( this.data.indexRecommendable == false ? "display:none;" : "display:;" ) +"'></td>" +
  887. " <td styles='formTableValue' item='indexRecommenPerson' style='"+ ( this.data.indexRecommendable == false ? "display:none;" : "display:;" ) +"'></td>" +
  888. "</tr><tr>" +
  889. " <td styles='formTableTitle' lable='subjectNeedAudit' width='10%'></td>" +
  890. " <td styles='formTableValue' item='subjectNeedAudit' width='40%'></td>" +
  891. " <td styles='formTableTitle' lable='subjectAuditPerson' width='10%' style='"+ ( this.data.subjectNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  892. " <td styles='formTableValue' item='subjectAuditPerson' width='40%' style='"+ ( this.data.subjectNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  893. "</tr><tr>" +
  894. " <td styles='formTableTitle' lable='replyNeedAudit'></td>" +
  895. " <td styles='formTableValue' item='replyNeedAudit'></td>" +
  896. " <td styles='formTableTitle' lable='replyAuditPerson' style='"+ ( this.data.replyNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  897. " <td styles='formTableValue' item='replyAuditPerson' style='"+ ( this.data.replyNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  898. "</tr>"
  899. "</table>"
  900. this.permissionContainer.set("html", html);
  901. var forumNames = [""];
  902. var forumIds = [""];
  903. this.app.restActions.listCategoryAllByAdmin( function( json ){
  904. json.data.each( function( d ){
  905. if( this.isNew ){
  906. if( this.app.access.hasForumAdminAuthority( d ) ){
  907. forumNames.push(d.forumName );
  908. forumIds.push(d.id);
  909. }
  910. }else{
  911. forumNames.push(d.forumName );
  912. forumIds.push(d.id);
  913. }
  914. }.bind(this))
  915. }.bind(this), null ,false)
  916. if( !this.data.typeCatagory ){
  917. this.data.typeCatagory = this.lp.typeCategorySelectValue.split("|");
  918. }else{
  919. this.data.typeCatagory = typeof this.data.typeCatagory == "string" ? this.data.typeCatagory.split("|") : this.data.typeCatagory;
  920. }
  921. MWF.xDesktop.requireApp("Template", "MForm", function () {
  922. this.form = new MForm(this.formTableArea, this.data, {
  923. style: "forum",
  924. isEdited: this.isEdited || this.isNew,
  925. itemTemplate: {
  926. sectionName: {text: this.lp.sectionName, notEmpty: true},
  927. forumId: {text: this.lp.owneForum, type : "select", "selectText" : forumNames, "selectValue" : forumIds , notEmpty: true, isEdited : function(){ return this.isNew }.bind(this)},
  928. sectionVisiable: {text: this.lp.sectionVisiable, type : "select", selectValue : this.lp.sectionVisiableValue.split(","), event : {
  929. change : function( it, ev ){
  930. this.setItemStyle( it, "sectionVisiable" );
  931. if( it.getValue() == this.lp.allPerson ){
  932. this.formTableArea.getElements("[item='indexRecommendTr']")[0].setStyle("display","")
  933. }else{
  934. this.formTableArea.getElements("[item='indexRecommendTr']")[0].setStyle("display","none")
  935. }
  936. }.bind(this)
  937. }},
  938. sectionVisiableCompanyButton : { value : this.lp.selectCompany , type : "button", style : this.getButtonStyle("sectionVisiable"), event : {
  939. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("sectionVisiableCompany").getElements()[0], "company" , 0 )}.bind(this)
  940. }},
  941. sectionVisiableDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : this.getButtonStyle("sectionVisiable"), event : {
  942. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("sectionVisiableDepartment").getElements()[0], "department" , 0 )}.bind(this)
  943. }},
  944. sectionVisiablePersonButton : { value : this.lp.selectPerson , type : "button", style : this.getButtonStyle("sectionVisiable"), event : {
  945. click : function( it, ev ){
  946. this.explorer.explorer.parent.selectPerson( it.form.getItem("sectionVisiablePerson").getElements()[0], "person" , 0 ) }.bind(this)
  947. }},
  948. sectionVisiableCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_")["company"].join(",") }.bind(this), style : this.getContainerStyle("sectionVisiable") },
  949. sectionVisiableDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_")["department"].join(",") }.bind(this), style : this.getContainerStyle("sectionVisiable") },
  950. sectionVisiablePerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_")["person"].join(",") }.bind(this), style : this.getContainerStyle("sectionVisiable") },
  951. subjectPublishAble: {text: this.lp.subjectPublishAble, type : "select", selectValue : this.lp.subjectPublishAbleValue.split(","), event : {
  952. change : function( it, ev ){ this.setItemStyle( it, "subjectPublish" ); }.bind(this)
  953. }},
  954. subjectPublishCompanyButton : { value : this.lp.selectCompany , type : "button", style : this.getButtonStyle("subjectPublishAble"), event : {
  955. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("subjectPublishCompany").getElements()[0], "company" , 0 )}.bind(this)
  956. }},
  957. subjectPublishDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : this.getButtonStyle("subjectPublishAble"), event : {
  958. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("subjectPublishDepartment").getElements()[0], "department" , 0 )}.bind(this)
  959. }},
  960. subjectPublishPersonButton : { value : this.lp.selectPerson , type : "button", style : this.getButtonStyle("subjectPublishAble"), event : {
  961. click : function( it, ev ){
  962. this.explorer.explorer.parent.selectPerson( it.form.getItem("subjectPublishPerson").getElements()[0], "person" , 0 ) }.bind(this)
  963. }},
  964. subjectPublishCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_")["company"].join(",") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  965. subjectPublishDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_")["department"].join(",") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  966. subjectPublishPerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_")["person"].join(",") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  967. replyPublishAble: {text: this.lp.replyPublishAble, type : "select", selectValue : this.lp.replyPublishAbleValue.split(","), event : {
  968. change : function( it, ev ){ this.setItemStyle( it, "replyPublish" ); }.bind(this)
  969. }},
  970. replyPublishCompanyButton : { value : this.lp.selectCompany , type : "button", style : this.getButtonStyle("replyPublishAble"), event : {
  971. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("replyPublishCompany").getElements()[0], "company" , 0 )}.bind(this)
  972. }},
  973. replyPublishDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : this.getButtonStyle("replyPublishAble"), event : {
  974. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("replyPublishDepartment").getElements()[0], "department" , 0 )}.bind(this)
  975. }},
  976. replyPublishPersonButton : { value : this.lp.selectPerson , type : "button", style : this.getButtonStyle("replyPublishAble"), event : {
  977. click : function( it, ev ){
  978. this.explorer.explorer.parent.selectPerson( it.form.getItem("replyPublishPerson").getElements()[0], "person" , 0 ) }.bind(this)
  979. }},
  980. replyPublishCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_")["company"].join(",") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  981. replyPublishDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_")["department"].join(",") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  982. replyPublishPerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_")["person"].join(",") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  983. indexRecommendable: {text: this.lp.indexRecommendable, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") , defaultValue : "true" ,event : {
  984. change : function( it, ev ){
  985. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  986. this.permissionContainer.getElements("[item='indexRecommenPerson']")[0].setStyles( styles );
  987. this.permissionContainer.getElements("[lable='indexRecommenPerson']")[0].setStyles( styles );
  988. }.bind(this)
  989. }},
  990. indexRecommenPerson : { text: this.lp.indexRecommenPerson , tType : "person", count : 0, value : function(){
  991. var v = this.getRoleMemberByCode("SECTION_RECOMMENDER_")["person"].join(",");
  992. return v == "" ? this.app.userName : v;
  993. }.bind(this)},
  994. subjectNeedAudit: {text: this.lp.subjectNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" ,event : {
  995. change : function( it, ev ){
  996. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  997. this.permissionContainer.getElements("[item='subjectAuditPerson']")[0].setStyles( styles );
  998. this.permissionContainer.getElements("[lable='subjectAuditPerson']")[0].setStyles( styles );
  999. }.bind(this)
  1000. }},
  1001. subjectAuditPerson : { text: this.lp.auditPerson , tType : "person", count : 0, value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_AUDITOR_")["person"].join(",") }.bind(this) },
  1002. replyNeedAudit: {text: this.lp.replyNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") , defaultValue : "false" ,event : {
  1003. change : function( it, ev ){
  1004. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1005. this.permissionContainer.getElements("[item='replyAuditPerson']")[0].setStyles( styles );
  1006. this.permissionContainer.getElements("[lable='replyAuditPerson']")[0].setStyles( styles );
  1007. }.bind(this)
  1008. }},
  1009. replyAuditPerson : { text: this.lp.auditPerson , tType : "person", count : 0, value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_AUDITOR_")["person"].join(",") }.bind(this) },
  1010. moderatorNames : {text:this.lp.moderatorNames, tType:"person", count : 0, defaultValue : this.app.userName },
  1011. sectionType : {text: this.lp.sectionType, type : "select", selectValue : this.lp.sectionTypeValue.split(",") },
  1012. //sectionCreateAble: {text: this.lp.sectionCreateAble, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  1013. creatorName: {text: this.lp.creatorName, type : "innerText", "defaultValue" : this.app.userName },
  1014. createTime: {text: this.lp.createTime, type : "innerText" },
  1015. sectionStatus: {text: this.lp.sectionStatus, type : "select", selectValue : this.lp.sectionStatusValue.split(",") },
  1016. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  1017. subjectType: {text: this.lp.subjectType, defaultValue : this.lp.subjectTypeDefaultValue },
  1018. typeCatagory: {text: this.lp.typeCatagory, selectValue : this.lp.typeCategorySelectValue.split("|"), type : "checkbox", notEmpty : true},
  1019. sectionDescription : {text: this.lp.sectionDescription, type: "textarea", style:{"height":"45px"} },
  1020. sectionNotice: {text: this.lp.sectionNotice, type: "rtf", RTFConfig : { skin : "bootstrapck" } },
  1021. sectionIcon : { text : this.lp.sectionIcon }
  1022. }
  1023. }, this.app);
  1024. this.form.load();
  1025. this.createIconNode();
  1026. }.bind(this), true);
  1027. },
  1028. saveRole : function( id, callback ){
  1029. var data = this.form.getResult(true, ",", true, false, true);
  1030. if( this.isNew )data.id = id;
  1031. this.saveRoleMember( true, "moderatorNames" ,"SECTION_MANAGER_", data, true );
  1032. var flag = data.sectionVisiable != this.lp.allPerson;
  1033. this.saveRoleMember( flag, "sectionVisiable" ,"SECTION_GUEST_", data )
  1034. flag = data.subjectPublishAble != this.lp.allPerson;
  1035. this.saveRoleMember( flag, "subjectPublish" ,"SECTION_SUBJECT_PUBLISHER_", data )
  1036. flag = data.replyPublishAble != this.lp.allPerson;
  1037. this.saveRoleMember( flag, "replyPublish" ,"SECTION_REPLY_PUBLISHER_", data )
  1038. flag = data.indexRecommendable == "true";
  1039. this.saveRoleMember( flag, "indexRecommenPerson" ,"SECTION_RECOMMENDER_", data, true );
  1040. flag = data.subjectNeedAudit == "true";
  1041. this.saveRoleMember( flag, "subjectAuditPerson" ,"SECTION_SUBJECT_AUDITOR_", data, true );
  1042. flag = data.replyNeedAudit == "true";
  1043. this.saveRoleMember( flag, "replyAuditPerson" ,"SECTION_REPLY_AUDITOR_", data, true );
  1044. if( callback )callback();
  1045. },
  1046. saveRoleMember : function( flag, dataKey, code, data , isSingle, callback ){
  1047. var orgArray = [];
  1048. if( flag ){
  1049. if( isSingle ){
  1050. if( data[ dataKey ] ){
  1051. data[ dataKey ].split(",").each( function( p ){
  1052. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  1053. })
  1054. }
  1055. }else{
  1056. if( data[ dataKey + "Person" ] ){
  1057. data[ dataKey + "Person" ].split(",").each( function( p ){
  1058. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  1059. })
  1060. }
  1061. if( data[ dataKey + "Department" ] ) {
  1062. data[dataKey + "Department"].split(",").each(function (p) {
  1063. if (p != "") orgArray.push({objectName: p, objectType: "部门"});
  1064. })
  1065. }
  1066. if( data[ dataKey + "Company" ] ) {
  1067. data[ dataKey + "Company" ].split(",").each( function( p ){
  1068. if( p!= "") orgArray.push( { objectName : p, objectType : "公司" } );
  1069. })
  1070. }
  1071. }
  1072. }
  1073. var d = {
  1074. bindObjectArray : orgArray,
  1075. bindRoleCode : code + this.data.id
  1076. };
  1077. this.app.restActions.bindRole( d, function( rData ){
  1078. if( callback )callback(json);
  1079. }.bind(this))
  1080. },
  1081. getRoleMemberByCode : function( code ){
  1082. if( !this.RoleMember )this.RoleMember = {};
  1083. if( this.RoleMember[ code ] ){
  1084. return this.RoleMember[ code ];
  1085. }
  1086. var r = {
  1087. company : [],
  1088. department : [],
  1089. person : []
  1090. };
  1091. if( !this.data.id ){
  1092. return r;
  1093. }
  1094. this.RoleMember[ code ] = r;
  1095. if( this.data && this.data.id ){
  1096. this.actions.listRoleMemberByCode( { "bindRoleCode" : code+ this.data.id }, function(json){
  1097. json.data = json.data || [];
  1098. json.data.each( function( d ){
  1099. if(d.objectType == "公司"){
  1100. r.company.push( d.objectName );
  1101. }else if(d.objectType == "部门"){
  1102. r.department.push( d.objectName );
  1103. }else{
  1104. r.person.push( d.objectName );
  1105. }
  1106. }.bind(this) )
  1107. }, function(){}, false );
  1108. }
  1109. //}
  1110. return r;
  1111. },
  1112. getButtonStyle : function( key ){
  1113. if( this.isEdited || this.isNew ){
  1114. return this.getContainerStyle( key )
  1115. }else{
  1116. return { display:"none"};
  1117. }
  1118. },
  1119. getContainerStyle : function( key ){
  1120. return (!this.data[key] ||(this.data[key] == this.lp.allPerson )) ? { display:"none"} : { display:""};
  1121. },
  1122. setItemStyle : function( it, preStr ){
  1123. var styles = it.getValue() == this.lp.allPerson ? { display : "none" } : { display : "" };
  1124. it.form.getItem(preStr + "PersonButton").setStyles( styles );
  1125. it.form.getItem(preStr + "DepartmentButton").setStyles( styles );
  1126. it.form.getItem(preStr + "CompanyButton").setStyles( styles );
  1127. it.form.getItem(preStr + "Person").setStyles( styles );
  1128. it.form.getItem(preStr + "Department").setStyles( styles );
  1129. it.form.getItem(preStr + "Company").setStyles( styles );
  1130. },
  1131. createIconNode: function(){
  1132. var iconPth = "/x_component_Forum/$Setting/"+ this.options.style +"/sectionIcon/";
  1133. var defaultIconSrc = iconPth + "forum_icon.png";
  1134. var sectionIconArea = this.formTableArea.getElements("[item='sectionIconArea']")[0];
  1135. this.iconNode = new Element("img",{
  1136. "styles" : this.css.iconNode
  1137. }).inject(sectionIconArea);
  1138. if (this.data.icon){
  1139. this.iconNode.set("src", "data:image/png;base64,"+this.data.icon+"");
  1140. }else{
  1141. this.iconNode.set("src", defaultIconSrc)
  1142. }
  1143. if( this.isEdited || this.isNew ){
  1144. //var selectIconActionNode = new Element("div", {
  1145. // "styles": this.css.changeIconActionNode,
  1146. // "text": this.lp.selectIcon
  1147. //}).inject(sectionIconArea);
  1148. //selectIconActionNode.addEvent("click", function () {
  1149. // this.selectIcon();
  1150. //}.bind(this));
  1151. var changeIconActionNode = new Element("div", {
  1152. "styles": this.css.changeIconActionNode,
  1153. "text": this.lp.uploadIcon
  1154. }).inject(sectionIconArea);
  1155. changeIconActionNode.addEvent("click", function () {
  1156. this.changeIcon();
  1157. }.bind(this));
  1158. }
  1159. },
  1160. selectIcon: function(){
  1161. var form = new MWF.xApplication.Forum.Setting.SectionIconForm(this, {}, {
  1162. onPostOk : function( icon ){
  1163. if( this.formData )this.formData = null;
  1164. this.iconNode.set("src",icon.path );
  1165. }.bind(this)
  1166. })
  1167. form.edit();
  1168. },
  1169. changeIcon: function () {
  1170. if (!this.uploadFileAreaNode) {
  1171. this.uploadFileAreaNode = new Element("div");
  1172. var html = "<input name=\"file\" type=\"file\"/>";
  1173. this.uploadFileAreaNode.set("html", html);
  1174. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1175. this.fileUploadNode.addEvent("change", function () {
  1176. var files = fileNode.files;
  1177. if (files.length) {
  1178. for (var i = 0; i < files.length; i++) {
  1179. var file = files.item(i);
  1180. if (!file.type.match('image.*'))continue;
  1181. this.file = file;
  1182. this.formData = new FormData();
  1183. this.formData.append('file', this.file);
  1184. if (!window.FileReader) continue;
  1185. var reader = new FileReader();
  1186. reader.onload = (function (theFile) {
  1187. return function (e) {
  1188. this.iconNode.set("src",e.target.result)
  1189. }.bind(this);
  1190. }.bind(this))(file);
  1191. reader.readAsDataURL(file);
  1192. }
  1193. }
  1194. }.bind(this));
  1195. }
  1196. var fileNode = this.uploadFileAreaNode.getFirst();
  1197. fileNode.click();
  1198. },
  1199. saveIcon: function (id, callback) {
  1200. this.app.restActions.uploadSectionIcon(id, function () {
  1201. if (callback)callback();
  1202. }.bind(this), null, this.formData, this.file);
  1203. },
  1204. _ok: function (data, callback) {
  1205. data.sectionLevel = "主版块";
  1206. data.typeCatagory = data.typeCatagory.split(",").join("|");
  1207. this.app.restActions.saveSection( data, function(json){
  1208. if( this.formData ){
  1209. this.saveIcon( json.data.id, function(){
  1210. this.saveRole( json.data.id, function( data ){
  1211. if( callback )callback(json);
  1212. }.bind(this) )
  1213. }.bind(this) );
  1214. }else{
  1215. this.saveRole( json.data.id, function( data ){
  1216. if( callback )callback(json);
  1217. }.bind(this) )
  1218. }
  1219. this.fireEvent("postOk")
  1220. }.bind(this));
  1221. },
  1222. setFormNodeSize: function (width, height, top, left) {
  1223. if (!width)width = this.options.width ? this.options.width : "50%"
  1224. if (!height)height = this.options.height ? this.options.height : "50%"
  1225. if (!top) top = this.options.top ? this.options.top : 0;
  1226. if (!left) left = this.options.left ? this.options.left : 0;
  1227. var allSize = this.app.content.getSize();
  1228. var limitWidth = allSize.x; //window.screen.width
  1229. var limitHeight = allSize.y; //window.screen.height
  1230. "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  1231. "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  1232. 300 > width && (width = 300);
  1233. 220 > height && (height = 220);
  1234. top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
  1235. left = left || parseInt((limitWidth - width) / 2, 10);
  1236. this.formAreaNode.setStyles({
  1237. "width": "" + width + "px",
  1238. "height": "" + height + "px",
  1239. "top": "" + top + "px",
  1240. "left": "" + left + "px"
  1241. });
  1242. this.formNode.setStyles({
  1243. "width": "" + width + "px",
  1244. "height": "" + height + "px"
  1245. });
  1246. var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  1247. var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  1248. var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  1249. var toolbarSize = this.toolbar ? this.toolbar.getSize() : {x: 0, y: 0};
  1250. var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - toolbarSize.y;
  1251. //var formMargin = formHeight -iconSize.y;
  1252. this.formContentNode.setStyles({
  1253. "height": "" + contentHeight + "px"
  1254. });
  1255. this.formTableContainer.setStyles({
  1256. "height": "" + contentHeight + "px"
  1257. });
  1258. }
  1259. });
  1260. MWF.xApplication.Forum.Setting.SectionIconForm = new Class({
  1261. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1262. Implements: [Options, Events],
  1263. options: {
  1264. "style": "default",
  1265. "width": "650",
  1266. "height": "400",
  1267. "hasTop": true,
  1268. "hasIcon": false,
  1269. "hasTopIcon" : true,
  1270. "hasTopContent" : true,
  1271. "hasBottom": false,
  1272. "title": MWF.xApplication.Forum.LP.sectionIconFormTitle,
  1273. "draggable": true,
  1274. "closeAction": true
  1275. },
  1276. _createTableContent: function () {
  1277. var iconPath = "/x_component_Forum/$Setting/" + this.options.style +"/sectionIcon/";
  1278. var jsonPath = "/x_component_Forum/$Setting/sectionIcon.json";
  1279. var div = new Element("div",{
  1280. "styles" : this.css.sectionFormContent
  1281. }).inject(this.formTableArea);
  1282. MWF.getJSON(jsonPath, function(json){
  1283. json.icons.each(function(iconName, i){
  1284. var iconAreaNode = new Element("div",{
  1285. "styles" : this.css.iconAreaNode
  1286. }).inject(div);
  1287. var iconNode = new Element("img",{
  1288. "styles" : this.css.iconSelectNode,
  1289. "src" : iconPath + iconName
  1290. }).inject(iconAreaNode);
  1291. iconAreaNode.store( "iconName", iconName );
  1292. iconAreaNode.store( "iconPath", iconPath + iconName );
  1293. iconAreaNode.addEvents({
  1294. "mouseover" : function(){
  1295. this.node.setStyles( this.obj.css.iconAreaNodeOver )
  1296. }.bind({ obj : this, node : iconAreaNode }),
  1297. "mouseout" : function(){
  1298. this.node.setStyles( this.obj.css.iconAreaNode )
  1299. }.bind({ obj : this, node : iconAreaNode }),
  1300. "click" : function(){
  1301. var icon = {
  1302. "path": this.node.retrieve("iconPath"),
  1303. "name": this.node.retrieve("iconName")
  1304. }
  1305. this.obj.fireEvent("postOk", icon );
  1306. this.obj.close();
  1307. }.bind({ obj : this, node : iconAreaNode })
  1308. })
  1309. }.bind(this));
  1310. }.bind(this));
  1311. }
  1312. });
  1313. MWF.xApplication.Forum.Setting.SystemSettingExplorer = new Class({
  1314. Extends: MWF.widget.Common,
  1315. Implements: [Options, Events],
  1316. options: {
  1317. "style": "default"
  1318. },
  1319. initialize: function (container, app, parent, options) {
  1320. this.container = container;
  1321. this.parent = parent;
  1322. this.app = app;
  1323. this.css = this.parent.css;
  1324. this.lp = this.app.lp;
  1325. },
  1326. load: function () {
  1327. this.container.empty();
  1328. this.loadView();
  1329. },
  1330. destroy : function(){
  1331. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun)
  1332. this.view.destroy();
  1333. },
  1334. loadView : function(){
  1335. this.viewContainer = Element("div",{
  1336. "styles" : this.css.viewContainer
  1337. }).inject(this.container);
  1338. this.resizeWindow();
  1339. this.resizeWindowFun = this.resizeWindow.bind(this)
  1340. this.app.addEvent("resize", this.resizeWindowFun );
  1341. this.view = new MWF.xApplication.Forum.Setting.SystemSettingView( this.viewContainer, this.app, this, {
  1342. templateUrl : this.parent.path+"listItemSystem.json",
  1343. scrollEnable : true
  1344. } )
  1345. this.view.load();
  1346. },
  1347. resizeWindow: function(){
  1348. var size = this.container.getSize();
  1349. this.viewContainer.setStyles({"height":(size.y)+"px"});
  1350. }
  1351. })
  1352. MWF.xApplication.Forum.Setting.SystemSettingView = new Class({
  1353. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1354. _createDocument: function(data){
  1355. return new MWF.xApplication.Forum.Setting.SystemSettingDocument(this.viewNode, data, this.explorer, this);
  1356. },
  1357. _getCurrentPageData: function(callback, count){
  1358. if (!count)count = 20;
  1359. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1360. //var filter = this.filterData || {};
  1361. this.actions.listSystemSettingAll(function (json) {
  1362. if (callback)callback(json);
  1363. }.bind(this))
  1364. },
  1365. _removeDocument: function(documentData, all){
  1366. },
  1367. _openDocument: function( documentData ){
  1368. var form = new MWF.xApplication.Forum.Setting.SystemSettingForm(this, documentData, {
  1369. onPostOk : function(){
  1370. this.reload();
  1371. }.bind(this)
  1372. })
  1373. if( MWF.AC.isAdministrator() ){
  1374. form.edit();
  1375. }else{
  1376. form.open();
  1377. }
  1378. }
  1379. })
  1380. MWF.xApplication.Forum.Setting.SystemSettingDocument = new Class({
  1381. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1382. _queryCreateDocumentNode:function( itemData ){
  1383. },
  1384. _postCreateDocumentNode: function( itemNode, itemData ){
  1385. }
  1386. })
  1387. MWF.xApplication.Forum.Setting.SystemSettingForm = new Class({
  1388. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1389. Implements: [Options, Events],
  1390. options: {
  1391. "style": "default",
  1392. "width": "600",
  1393. "height": "320",
  1394. "hasTop": true,
  1395. "hasIcon": false,
  1396. "hasTopIcon" : true,
  1397. "hasTopContent" : true,
  1398. "hasBottom": true,
  1399. "title": MWF.xApplication.Forum.LP.systemSettingFormTitle,
  1400. "draggable": true,
  1401. "closeAction": true
  1402. },
  1403. _createTableContent: function () {
  1404. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1405. "<tr><td styles='formTableTitle' lable='configName' width='20%'></td>" +
  1406. " <td styles='formTableValue' item='configName' width='80%'></td></tr>" +
  1407. "<tr><td styles='formTableTitle' lable='configValue'></td>" +
  1408. " <td styles='formTableValue' item='configValue'></td></tr>" +
  1409. "<tr><td styles='formTableTitle' lable='orderNumber'></td>" +
  1410. " <td styles='formTableValue' item='orderNumber'></td></tr>" +
  1411. "<tr><td styles='formTableTitle' lable='description'></td>" +
  1412. " <td styles='formTableValue' item='description'></td></tr>" +
  1413. "</table>"
  1414. this.formTableArea.set("html", html);
  1415. var configValueSetting = {text: this.lp.configValue };
  1416. configValueSetting.tType = "text";
  1417. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1418. this.form = new MForm(this.formTableArea, this.data, {
  1419. style: "execution",
  1420. isEdited: this.isEdited || this.isNew,
  1421. itemTemplate: {
  1422. configName: {text: this.lp.configName, type : "innerText" },
  1423. configValue : configValueSetting,
  1424. orderNumber: {text: this.lp.orderNumber, type : "innerText" },
  1425. description: {text: this.lp.description, type : "innerText" }
  1426. }
  1427. }, this.app);
  1428. this.form.load();
  1429. }.bind(this), true);
  1430. },
  1431. _ok: function (data, callback) {
  1432. this.app.restActions.saveSystemSetting( data, function(json){
  1433. if( callback )callback(json);
  1434. this.fireEvent("postOk")
  1435. }.bind(this));
  1436. }
  1437. });
  1438. MWF.xApplication.Forum.Setting.SelectOrgForm = new Class({
  1439. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1440. Implements: [Options, Events],
  1441. options: {
  1442. "style": "default",
  1443. "width": "900",
  1444. "height": "230",
  1445. "hasTop": true,
  1446. "hasIcon": false,
  1447. "hasTopIcon" : true,
  1448. "hasTopContent" : true,
  1449. "hasBottom": true,
  1450. "title": MWF.xApplication.Forum.LP.SelectOrgForm,
  1451. "draggable": true,
  1452. "closeAction": true
  1453. },
  1454. _createTableContent: function () {
  1455. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1456. "<tr><td styles='formTableTitle' lable='person' width='15%'></td>" +
  1457. " <td styles='formTableValue' item='person' colspan='3' width='85%'></td></tr>" +
  1458. "<tr><td styles='formTableTitle' lable='department'></td>" +
  1459. " <td styles='formTableValue' item='department' colspan='3'></td></tr>" +
  1460. "<tr><td styles='formTableTitle' lable='company'></td>" +
  1461. " <td styles='formTableValue' item='company' colspan='3'></td></tr>" +
  1462. "</table>"
  1463. this.formTableArea.set("html", html);
  1464. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1465. this.form = new MForm(this.formTableArea, this.data, {
  1466. style: "forum",
  1467. isEdited: this.isEdited || this.isNew,
  1468. itemTemplate: {
  1469. person: {text: this.lp.selectPerson, tType: "person", count: 0},
  1470. department: {text: this.lp.selectDepartment, tType: "department", count: 0},
  1471. company: {text: this.lp.selectCompany, tType: "company", count: 0}
  1472. }
  1473. }, this.app);
  1474. this.form.load();
  1475. }.bind(this), false);
  1476. },
  1477. _ok: function (data, callback) {
  1478. var orgArray = [];
  1479. data.person.split(",").each( function( p ){
  1480. orgArray.push( p+"#人员" )
  1481. })
  1482. data.department.split(",").each( function( p ){
  1483. orgArray.push( p+"#组织" )
  1484. })
  1485. data.company.split(",").each( function( p ){
  1486. orgArray.push( p+"#组织" )
  1487. })
  1488. this.app.restActions.saveRole( data, function(json){
  1489. this.app.restActions.getRole( data.id, function( j ){
  1490. var roleData = {
  1491. bindObjectArray : orgArray,
  1492. bindRoleCode : j.roleCode
  1493. };
  1494. this.app.restActions.bindRole( roleData, function( rData ){
  1495. if( callback )callback(json);
  1496. this.fireEvent("postOk")
  1497. }.bind(this))
  1498. })
  1499. }.bind(this));
  1500. }
  1501. });