Setting.js 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  4. MWF.require("MWF.widget.O2Identity", null,false);
  5. MWF.xApplication.Forum.Setting = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "index" : 0
  11. },
  12. initialize: function (node, app, actions, options) {
  13. this.setOptions(options);
  14. this.app = app;
  15. this.lp = app.lp;
  16. this.path = "../x_component_Forum/$Setting/";
  17. this.loadCss();
  18. this.actions = actions;
  19. this.node = $(node);
  20. },
  21. loadCss: function () {
  22. this.cssPath = "../x_component_Forum/$Setting/" + this.options.style + "/css.wcss";
  23. this._loadCss();
  24. },
  25. load: function(){
  26. this.app.access.getUserPermission(function ( permission ) {
  27. this.permission = permission;
  28. this._load();
  29. }.bind(this))
  30. },
  31. _load: function () {
  32. //this.middleContent = this.app.middleContent;
  33. this.naviDiv = new Element("div.naviDiv",{
  34. "styles":this.css.naviDiv
  35. }).inject(this.node);
  36. this.contentDiv = new Element("div.contentDiv",{
  37. "styles":this.css.contentDiv
  38. }).inject(this.node);
  39. this.createNaviContent();
  40. this.resizeWindowFun = this.resizeWindow.bind(this);
  41. this.resizeWindow();
  42. this.app.addEvent("resize", this.resizeWindowFun);
  43. },
  44. destroy: function(){
  45. if( this.contentDiv )this.contentDiv.empty();
  46. if( this.explorer ){
  47. this.explorer.destroy();
  48. delete this.explorer;
  49. }
  50. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  51. this.node.empty();
  52. delete this;
  53. },
  54. resizeWindow: function(){
  55. var size = this.app.node.getSize();
  56. var topSize = this.app.topNode ? this.app.topNode.getSize() : {"x": 0, "y": 0};
  57. // var topSize = {"x": 0, "y": 0};
  58. //var pt = this.app.contentContainerNode.getStyle("padding-top").toFloat();
  59. //var pb = this.app.contentContainerNode.getStyle("padding-bottom").toFloat();
  60. var height = size.y - topSize.y; //- pt - pb;
  61. this.naviDiv.setStyles({"height":height+"px"});
  62. this.naviContentDiv.setStyles({"height":(height-120)+"px"});
  63. this.contentDiv.setStyles({"height":height+"px"});
  64. },
  65. createNaviContent: function(){
  66. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  67. "styles":this.css.naviTitleDiv,
  68. "text": this.lp.setting
  69. }).inject(this.naviDiv);
  70. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  71. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  72. // var jsonUrl = this.path+"navi.json";
  73. // MWF.getJSON(jsonUrl, function(json){
  74. var permission = this.permission;
  75. [
  76. {
  77. "title" : MWF.xApplication.Forum.LP.systemSettingFormTitle,
  78. "icon" :"systemSetting.png",
  79. "action" : "openSystemSetting",
  80. "enable": this.app.access.isAdmin() || permission.bbsAdmin
  81. },
  82. {
  83. "title" : MWF.xApplication.Forum.LP.categoryFormTitle,
  84. "icon" :"categorize.png",
  85. "action" : "openCategorySetting",
  86. "enable": this.app.access.isAdmin() || permission.bbsAdmin || permission.bbsForumAdmin
  87. },
  88. {
  89. "title" : MWF.xApplication.Forum.LP.sectionFormTitle,
  90. "icon" :"squared.png",
  91. "action" : "openSectionSetting",
  92. "enable": this.app.access.isAdmin() || permission.bbsAdmin || permission.bbsForumAdmin || permission.bbsSectionAdmin
  93. },
  94. {
  95. "title" : MWF.xApplication.Forum.LP.muteSettingFormTitle,
  96. "icon" :"mute.png",
  97. "action" : "openMuteSetting",
  98. "enable": this.app.access.isAdmin() || permission.bbsAdmin
  99. }
  100. ].filter(function(data){
  101. return data.enable;
  102. }).each( function(data, i){
  103. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv);
  104. naviContentLi.addEvents({
  105. "mouseover" : function(ev){
  106. if(this.bindObj.currentNaviItem != this.node) this.node.setStyles( this.styles );
  107. }.bind({"styles": this.css.naviContentLi_over, "node":naviContentLi, "bindObj": this }),
  108. "mouseout" : function(ev){
  109. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  110. }.bind({"styles": this.css.naviContentLi, "node":naviContentLi, "bindObj": this }) ,
  111. "click" : function(ev){
  112. if( this.bindObj.currentNaviItem )this.bindObj.currentNaviItem.setStyles( this.bindObj.css.naviContentLi );
  113. this.node.setStyles( this.styles );
  114. this.bindObj.currentNaviItem = this.node;
  115. this.node.store( "index" , i );
  116. if( this.action && this.bindObj[this.action] )this.bindObj[this.action]();
  117. }.bind({"styles": this.css.naviContentLi_current, "node":naviContentLi, "bindObj": this, "action" : data.action })
  118. });
  119. var naviContentImg = new Element("img.naviContentImg",{
  120. "styles":this.css.naviContentImg,
  121. "src":this.path+this.options.style+"/icon/"+data.icon
  122. }).inject(naviContentLi);
  123. var naviContentSpan = new Element("span.naviContentSpan",{
  124. "styles":this.css.naviContentSpan,
  125. "text":data.title
  126. }).inject(naviContentLi);
  127. if( i == this.options.index )naviContentLi.click();
  128. }.bind(this));
  129. },
  130. openCategorySetting: function(){
  131. if( this.contentDiv )this.contentDiv.empty();
  132. if( this.explorer ){
  133. this.explorer.destroy();
  134. delete this.explorer;
  135. }
  136. this.explorer = new MWF.xApplication.Forum.Setting.CategorySettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  137. this.explorer.load();
  138. },
  139. openSectionSetting: function(){
  140. if( this.contentDiv )this.contentDiv.empty();
  141. if( this.explorer ){
  142. this.explorer.destroy();
  143. delete this.explorer;
  144. }
  145. this.explorer = new MWF.xApplication.Forum.Setting.SectionSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  146. this.explorer.load();
  147. },
  148. openSystemSetting : function(){
  149. if( this.contentDiv )this.contentDiv.empty();
  150. if( this.explorer ){
  151. this.explorer.destroy();
  152. delete this.explorer;
  153. }
  154. this.explorer = new MWF.xApplication.Forum.Setting.SystemSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  155. this.explorer.load();
  156. },
  157. openRoleSetting: function(){
  158. if( this.contentDiv )this.contentDiv.empty();
  159. if( this.explorer ){
  160. this.explorer.destroy();
  161. delete this.explorer;
  162. }
  163. this.explorer = new MWF.xApplication.Forum.Setting.RoleSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  164. this.explorer.load();
  165. },
  166. openMuteSetting: function(){
  167. if( this.contentDiv )this.contentDiv.empty();
  168. if( this.explorer ){
  169. this.explorer.destroy();
  170. delete this.explorer;
  171. }
  172. this.explorer = new MWF.xApplication.Forum.Setting.MuteSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  173. this.explorer.load();
  174. },
  175. openPermissionSetting: function(){
  176. if( this.contentDiv )this.contentDiv.empty();
  177. if( this.explorer ){
  178. this.explorer.destroy();
  179. delete this.explorer;
  180. }
  181. this.explorer = new MWF.xApplication.Forum.Setting.PermissionSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  182. this.explorer.load();
  183. }
  184. //selectPerson: function( item, type , count ){
  185. // if( type == "person" ){
  186. // var title = this.lp.selectPerson
  187. // }else if( type == "unit" ){
  188. // title = this.lp.selectDepartment
  189. // }
  190. // MWF.xDesktop.requireApp("Selector", "package", null, false);
  191. // var value = item.get("text").split( "," );
  192. // var options = {
  193. // "type": type,
  194. // "title": title ,
  195. // "count" : count,
  196. // "values": value || [],
  197. // "onComplete": function(items){
  198. // var arr = [];
  199. // items.each(function(item){
  200. // arr.push(item.data.distinguishedName);
  201. // }.bind(this));
  202. // item.set("text",arr.join(","));
  203. // }.bind(this)
  204. // };
  205. // var selector = new MWF.O2Selector(this.app.content, options);
  206. //}
  207. });
  208. MWF.xApplication.Forum.Setting.CategorySettingExplorer = new Class({
  209. Extends: MWF.widget.Common,
  210. Implements: [Options, Events],
  211. options: {
  212. "style": "default"
  213. },
  214. initialize: function (container, app, parent, options) {
  215. this.container = container;
  216. this.parent = parent;
  217. this.app = app;
  218. this.css = this.parent.css;
  219. this.lp = this.app.lp;
  220. },
  221. load: function () {
  222. this.container.empty();
  223. if( this.app.access.isAdmin() ){
  224. this.loadToolbar();
  225. }
  226. this.loadView();
  227. },
  228. destroy : function(){
  229. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  230. this.view.destroy();
  231. },
  232. loadToolbar: function(){
  233. this.toolbar = new Element("div",{
  234. styles : this.css.toolbar
  235. }).inject(this.container);
  236. this.createActionNode = new Element("div",{
  237. styles : this.css.toolbarActionNode,
  238. text: this.lp.createCategory
  239. }).inject(this.toolbar);
  240. this.createActionNode.addEvent("click",function(){
  241. var form = new MWF.xApplication.Forum.Setting.CategorySettingForm(this, {}, {
  242. onPostOk : function(){
  243. this.app.access.getUserPermission(function () {
  244. this.view.reload();
  245. }.bind(this), true);
  246. }.bind(this)});
  247. form.create();
  248. }.bind(this));
  249. this.fileterNode = new Element("div",{
  250. styles : this.css.fileterNode
  251. }).inject(this.toolbar);
  252. },
  253. loadView : function(){
  254. this.viewContainer = Element("div",{
  255. "styles" : this.css.viewContainer
  256. }).inject(this.container);
  257. this.resizeWindow();
  258. this.resizeWindowFun = this.resizeWindow.bind(this);
  259. this.app.addEvent("resize", this.resizeWindowFun );
  260. this.view = new MWF.xApplication.Forum.Setting.CategorySettingView( this.viewContainer, this.app, this, {
  261. templateUrl : this.parent.path+"listItemCategory.json",
  262. scrollEnable : true
  263. } );
  264. this.view.load();
  265. },
  266. resizeWindow: function(){
  267. var size = this.container.getSize();
  268. if( this.toolbar ){
  269. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  270. }else{
  271. this.viewContainer.setStyles({"height":(size.y-56)+"px"});
  272. }
  273. }
  274. });
  275. MWF.xApplication.Forum.Setting.CategorySettingView = new Class({
  276. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  277. _createDocument: function(data){
  278. return new MWF.xApplication.Forum.Setting.CategorySettingDocument(this.viewNode, data, this.explorer, this);
  279. },
  280. _getCurrentPageData: function(callback, count){
  281. if (!count)count = 20;
  282. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  283. //var filter = this.filterData || {};
  284. this.actions.listCategoryAllByAdmin( function (json) {
  285. this.explorer.app.access.getUserPermission(function (permission) {
  286. var list = ( json.data || [] ).filter(function(d){
  287. return this.explorer.app.access.isAdmin() || permission.bbsAdmin || permission.forumList.contains(d.id);
  288. }.bind(this))
  289. json.data = list;
  290. json.data.size = list.length;
  291. if (callback)callback(json);
  292. }.bind(this))
  293. }.bind(this))
  294. },
  295. _removeDocument: function(documentData, all){
  296. this.actions.deleteCategory(documentData.id, function(json){
  297. this.reload();
  298. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  299. }.bind(this));
  300. },
  301. _create: function(){
  302. },
  303. _openDocument: function( documentData ){
  304. var form = new MWF.xApplication.Forum.Setting.CategorySettingForm(this, documentData, {
  305. onPostOk : function(){
  306. this.reload();
  307. }.bind(this)
  308. });
  309. //if( this.app.access.hasForumAdminAuthority( documentData ) ){
  310. if( this.app.access.isAdmin() ){
  311. form.edit();
  312. }else{
  313. form.open();
  314. }
  315. },
  316. _queryCreateViewNode: function(){
  317. },
  318. _postCreateViewNode: function( viewNode ){
  319. },
  320. _queryCreateViewHead:function(){
  321. },
  322. _postCreateViewHead: function( headNode ){
  323. }
  324. });
  325. MWF.xApplication.Forum.Setting.CategorySettingDocument = new Class({
  326. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  327. _queryCreateDocumentNode:function( itemData ){
  328. },
  329. _postCreateDocumentNode: function( itemNode, itemData ){
  330. }
  331. });
  332. MWF.xApplication.Forum.Setting.CategorySettingForm = new Class({
  333. Extends: MPopupForm,
  334. Implements: [Options, Events],
  335. options: {
  336. "style": "default",
  337. "width": "1011",
  338. "height": "90%",
  339. "hasTop": true,
  340. "hasIcon": false,
  341. "hasTopIcon" : true,
  342. "hasTopContent" : true,
  343. "hasBottom": true,
  344. "title": MWF.xApplication.Forum.LP.categoryFormTitle,
  345. "draggable": true,
  346. "closeAction": true
  347. },
  348. createContent: function () {
  349. this.formContentNode = new Element("div.formContentNode", {
  350. "styles": this.css.formContentNode
  351. }).inject(this.formNode);
  352. this.formTableContainer = new Element("div.formTableContainer", {
  353. "styles": this.css.formTableContainer
  354. }).inject(this.formContentNode);
  355. this.formTableArea = new Element("div.formTableArea", {
  356. "styles": this.css.formTableArea
  357. }).inject(this.formTableContainer);
  358. this._createTableContent();
  359. },
  360. _createTableContent: function () {
  361. if( !this.data.indexListStyle ){
  362. this.data.indexListStyle = "type_1_0";
  363. }
  364. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  365. "<tr>" +
  366. " <td styles='formTableTitle' lable='forumName' width='10%'></td>" +
  367. " <td styles='formTableValue' item='forumName' width='40%'></td>" +
  368. " <td styles='formTableTitle' width='10%'></td>" +
  369. " <td styles='formTableValue' width='40%'></td>" +
  370. "</tr><tr>" +
  371. " <td styles='formTableTitle' lable='forumStatus'></td>" +
  372. " <td styles='formTableValue' item='forumStatus'></td>" +
  373. " <td styles='formTableTitle' lable='creatorName'></td>" +
  374. " <td styles='formTableValue' item='creatorName'></td>" +
  375. "</tr><tr>" +
  376. " <td styles='formTableTitle' lable='forumManagerName'></td>" +
  377. " <td styles='formTableValue' item='forumManagerName'></td>" +
  378. " <td styles='formTableTitle' lable='orderNumber'></td>" +
  379. " <td styles='formTableValue' item='orderNumber'></td>" +
  380. "</tr><tr>" +
  381. " <td styles='formTableTitle' lable='forumVisible'></td>" +
  382. " <td styles='formTableValue' item='forumVisible'></td>" +
  383. " <td styles='formTableValue' colspan='2'>" +
  384. " </td>" +
  385. "</tr><tr>" +
  386. " <td></td>" +
  387. " <td colspan='3'>"+
  388. " <div item='forumVisibleResult'></div>"+
  389. " </td>" +
  390. "</tr><tr>" +
  391. " <td styles='formTableTitle' lable='forumColorArea'></td>" +
  392. " <td styles='formTableValue'>"+
  393. " <div item='forumColorArea' style='float:left;'></div>"+
  394. " <div item='forumColorButton' style='float:left;'></div>"+
  395. " </td>" +
  396. " <td styles='formTableTitle' lable='subjectType'></td>" +
  397. " <td styles='formTableValue' item='subjectType'></td>" +
  398. //"</tr><tr>" +
  399. //" <td styles='formTableTitle' lable='indexRecommendable'></td>" +
  400. // " <td styles='formTableValue' item='indexRecommendable'></td>" +
  401. //" <td styles='formTableTitle' lable=''></td>" +
  402. //" <td styles='formTableValue' item=''></td>" +
  403. "</tr><tr>" +
  404. " <td styles='formTableTitle' lable='indexListStyleLable'></td>" +
  405. " <td styles='formTableValue' colspan='3'><div item='indexListStyleShow'></div><div item='indexListStyleButton'></div></td>" +
  406. "</tr><tr>" +
  407. " <td styles='formTableTitle' lable='forumNotice'></td>" +
  408. " <td styles='formTableValue' item='forumNotice' colspan='3'></td>" +
  409. // "</tr><tr>" +
  410. // " <td styles='formTableTitle' lable='subjectMessageNotifyTypeShow'></td>" +
  411. // " <td styles='formTableValue' item='subjectMessageNotifyTypeShow' colspan='3'></td>" +
  412. "</tr><tr>" +
  413. " <td styles='formTableTitle' lable='replyMessageNotifyTypeShow'></td>" +
  414. " <td styles='formTableValue' item='replyMessageNotifyTypeShow' colspan='3'></td>" +
  415. "</tr>"+
  416. "</table>";
  417. this.formTableArea.set("html", html);
  418. //value : function(){ return this.lp.defaultForumColor }.bind(this), defaultValue : this.lp.defaultForumColor
  419. var formVisibleButtonStyle = (( !this.isEdited && !this.isNew ) || !this.data.forumVisible ||(this.data.forumVisible == this.lp.allPerson )) ? { display:"none"} : { display:""};
  420. var formVisibleStyle = ( !this.data.forumVisible ||(this.data.forumVisible == this.lp.allPerson )) ? { display:"none"} : { display:""};
  421. var selectColorButtonStyle = (!this.isEdited && !this.isNew) ? { display : "none" } : {};
  422. this.indexListStyleShow = this.formTableArea.getElements("[item='indexListStyleShow']")[0];
  423. if( this.data.indexListStyle ){
  424. this.getDefaultTypeTemplateList( function(){
  425. new Element("img", {
  426. src : this.defalutTypeTemplateList[this.data.indexListStyle].preview,
  427. styles : this.css.indexListStylePreview
  428. }).inject(this.indexListStyleShow);
  429. }.bind(this));
  430. }
  431. //this.data.replyMessageNotifyShow = this.data.replyMessageNotify ? "true" : "false";
  432. var replyMessageNotifyType = ( this.data.replyMessageNotifyType || "0,0,0" ).split(",");
  433. this.data.replyMessageNotifyTypeShow = [];
  434. if( replyMessageNotifyType[0] === "1" )this.data.replyMessageNotifyTypeShow.push( "1" );
  435. if( replyMessageNotifyType[1] === "1" )this.data.replyMessageNotifyTypeShow.push( "2" );
  436. if( replyMessageNotifyType[2] === "1" )this.data.replyMessageNotifyTypeShow.push( "3" );
  437. //this.data.subjectMessageNotifyShow = this.data.subjectMessageNotify ? "true" : "false";
  438. // var subjectMessageNotifyType = (this.data.subjectMessageNotifyType || "0,0").split(",");
  439. // this.data.subjectMessageNotifyTypeShow = [];
  440. // if( subjectMessageNotifyType[0] === "1" )this.data.subjectMessageNotifyTypeShow.push( "1" );
  441. // if( subjectMessageNotifyType[1] === "1" )this.data.subjectMessageNotifyTypeShow.push( "2" );
  442. MWF.xDesktop.requireApp("Template", "MForm", function () {
  443. this.form = new MForm(this.formTableArea, this.data, {
  444. style: "forum",
  445. isEdited: this.isEdited || this.isNew,
  446. itemTemplate: {
  447. forumName: {text: this.lp.forumName, notEmpty: true},
  448. forumManagerName: { type : "org", text: this.lp.forumManagerName, orgType : "person", "defaultValue" : this.app.userName, "count" : 0 },
  449. forumVisible: {text: this.lp.forumVisible, type : "select", selectValue : this.lp.forumVisibleValue.split(","), event : {
  450. change : function( it, ev ){
  451. var styles = it.getValue() == this.lp.allPerson ? { display : "none" } : { display : "" };
  452. it.form.getItem("forumVisibleResult").setStyles( styles );
  453. }.bind(this)
  454. }},
  455. forumVisibleResult : { type : "org", count : 0, orgType : ["person","unit"], value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_") }.bind(this), style : formVisibleStyle },
  456. indexListStyleLable: {text: this.lp.indexListStyle }, //selectValue : this.lp.indexListStyleValue.split(",")
  457. indexListStyleButton: { type : "button", value: this.lp.indexListStyleButton, event : {
  458. click : function( it, ev ){ this.selectIndexType() }.bind(this)
  459. } },
  460. forumIndexStyle: {text: this.lp.forumIndexStyle, type : "select", selectValue : this.lp.forumIndexStyleValue.split(",") },
  461. indexRecommendable: {text: this.lp.indexRecommendable, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  462. subjectNeedAudit: {text: this.lp.subjectNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" },
  463. replyNeedAudit: {text: this.lp.replyNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" },
  464. //sectionCreateAble: {text: this.lp.sectionCreateAble, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  465. creatorName: {text: this.lp.creatorName, type : "org", isEdited : false, "defaultValue" : this.app.userName },
  466. forumStatus: {text: this.lp.forumStatus, type : "select", selectValue : this.lp.forumStatusValue.split(",") },
  467. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  468. forumColorArea: {text: this.lp.forumColor, type: "innerText" },
  469. forumColorButton : { value : this.lp.selectColor , type : "button", style : selectColorButtonStyle, event : {
  470. click : function( it, ev ){ this.selectColor() }.bind(this)
  471. }},
  472. subjectType: {text: this.lp.subjectType, type: "text", defaultValue : this.lp.subjectTypeDefaultValue },
  473. forumNotice: {text: this.lp.forumNotice, type: "rtf", RTFConfig : { "enablePreview": false }},
  474. //replyMessageNotifyShow: {text: this.lp.replyMessageNotify, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue: "false" },
  475. replyMessageNotifyTypeShow: {text: this.lp.replyMessageNotify, type : "checkbox", selectValue : ["1","2","3"], selectText : this.lp.replyMessageNotifyType.split(",") },
  476. //subjectMessageNotifyShow: {text: this.lp.subjectMessageNotify, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue: "false" },
  477. //subjectMessageNotifyTypeShow: {text: this.lp.subjectMessageNotify, type : "checkbox", selectValue : ["1","2"], selectText : this.lp.subjectMessageNotifyType.split(",") },
  478. }
  479. }, this.app);
  480. this.form.load();
  481. var forumColorArea = this.formTableArea.getElements("[item='forumColorArea']")[0];
  482. this.forumColorNode = new Element( "div", {
  483. 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 },
  484. text : this.lp.effect
  485. }).inject( forumColorArea )
  486. }.bind(this), true);
  487. },
  488. selectColor: function(){
  489. var form = new MWF.xApplication.Forum.Setting.ForumColorForm(this, {}, {
  490. onPostOk : function( color ){
  491. this.forumColorNode.setStyle( "background-color" , color );
  492. this.data.forumColor = color;
  493. }.bind(this)
  494. });
  495. form.edit();
  496. },
  497. _ok: function (data, callback) {
  498. debugger;
  499. // data.subjectMessageNotify = data.subjectMessageNotifyTypeShow.length > 0;
  500. //
  501. // var subjectMessageNotifyType = [];
  502. // subjectMessageNotifyType.push( data.subjectMessageNotifyTypeShow.contains("1") ? "1" : "0" );
  503. // subjectMessageNotifyType.push( data.subjectMessageNotifyTypeShow.contains("2") ? "1" : "0" );
  504. // data.subjectMessageNotifyType = subjectMessageNotifyType.join(",");
  505. data.replyMessageNotify = data.replyMessageNotifyTypeShow.length > 0;
  506. var replyMessageNotifyType = [];
  507. replyMessageNotifyType.push( data.replyMessageNotifyTypeShow.contains("1") ? "1" : "0" );
  508. replyMessageNotifyType.push( data.replyMessageNotifyTypeShow.contains("2") ? "1" : "0" );
  509. replyMessageNotifyType.push( data.replyMessageNotifyTypeShow.contains("3") ? "1" : "0" );
  510. data.replyMessageNotifyType = replyMessageNotifyType.join(",");
  511. this.app.restActions.saveCategory( data, function(json){
  512. this.saveRole( json.data.id, function(){
  513. if( callback )callback(json);
  514. this.fireEvent("postOk")
  515. }.bind(this))
  516. }.bind(this));
  517. },
  518. saveRole : function( id, callback ){
  519. var data = this.form.getResult(true, null, true, false, true);
  520. if( this.isNew )data.id = id;
  521. this.saveRoleMember( true, "forumManagerName" ,"FORUM_SUPER_MANAGER_", data, true );
  522. var flag = data.forumVisible != this.lp.allPerson;
  523. this.saveRoleMember( flag, "forumVisibleResult" ,"FORUM_GUEST_", data );
  524. if( callback )callback();
  525. },
  526. saveRoleMember : function( flag, dataKey, code, data , isSingle, callback ){
  527. var orgArray = [];
  528. if( flag ){
  529. if( isSingle ){
  530. if( data[ dataKey ] ){
  531. data[ dataKey ].each( function( p ){
  532. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  533. })
  534. }
  535. }else{
  536. if( data[ dataKey ] ){
  537. data[ dataKey ].each( function( p ){
  538. var flag = p.substr(p.length-1, 1);
  539. switch (flag.toLowerCase()){
  540. case "p":
  541. orgArray.push( { objectName : p, objectType : "人员" } );
  542. break;
  543. case "u":
  544. orgArray.push( { objectName : p, objectType : "组织" } );
  545. break;
  546. default:
  547. orgArray.push( { objectName : p, objectType : "人员" } );
  548. }
  549. })
  550. }
  551. }
  552. }
  553. var d = {
  554. bindObjectArray : orgArray,
  555. bindRoleCode : code + this.data.id
  556. };
  557. this.app.restActions.bindRole( d, function( rData ){
  558. if( callback )callback(json);
  559. }.bind(this))
  560. },
  561. getRoleMemberByCode : function( code ){
  562. if( !this.RoleMember )this.RoleMember = {};
  563. if( this.RoleMember[ code ] ){
  564. return this.RoleMember[ code ];
  565. }
  566. var r = this.RoleMember[ code ] = [];
  567. if( !this.data.id ){
  568. return r;
  569. }
  570. this.RoleMember[ code ] = r;
  571. if( this.data && this.data.id ){
  572. this.actions.listRoleMemberByCode( { "bindRoleCode" : code+ this.data.id }, function(json){
  573. json.data = json.data || [];
  574. json.data.each( function( d ){
  575. r.push( d.objectName );
  576. }.bind(this) )
  577. }, function(){}, false );
  578. }
  579. //}
  580. return r;
  581. },
  582. selectIndexType : function(){
  583. this.getDefaultTypeTemplateList( function(){
  584. this.selectTypeTemplate();
  585. }.bind(this))
  586. },
  587. getDefaultTypeTemplateList : function(callback){
  588. if (this.defalutTypeTemplateList){
  589. if (callback) callback();
  590. }else{
  591. var url = "../x_component_Forum/$ColumnTemplate/template/setting.json";
  592. MWF.getJSON(url, function(json){
  593. this.defalutTypeTemplateList = json;
  594. if (callback) callback();
  595. }.bind(this));
  596. }
  597. },
  598. selectTypeTemplate: function(e){
  599. this.typeTemplateList = null;
  600. var _self = this;
  601. var createTemplateMaskNode = new Element("div", {"styles": this.css.createTemplateMaskNode}).inject(this.app.content);
  602. var createTemplateAreaNode = new Element("div", {"styles": this.css.createTypeTemplateAreaNode}).inject(this.app.content);
  603. createTemplateAreaNode.fade("in");
  604. var createTemplateTitleNode = new Element("div", {"styles": this.css.createTemplateFormTitleNode, "text": this.app.lp.selectIndexType }).inject(createTemplateAreaNode);
  605. var createTemplateCategoryNode = new Element("div", {"styles": this.css.createTemplateFormCategoryNode}).inject(createTemplateAreaNode);
  606. var createTemplateCategoryTitleNode = new Element("div", {"styles": this.css.createTemplateFormCategoryTitleNode, "text": this.app.lp.typeColumn}).inject(createTemplateCategoryNode);
  607. var createTemplateContentNode = new Element("div", {"styles": this.css.createTemplateFormContentNode}).inject(createTemplateAreaNode);
  608. var createTemplateCategoryAllNode = new Element("div", {"styles": this.css.createTemplateFormCategoryItemNode, "text": this.app.lp.all}).inject(createTemplateCategoryNode);
  609. createTemplateCategoryAllNode.addEvent("click", function(){
  610. loadAllTemplates();
  611. });
  612. var columnCountList = [];
  613. this.getDefaultTypeTemplateList( function(){
  614. for( var key in this.defalutTypeTemplateList ) {
  615. var template = this.defalutTypeTemplateList[key];
  616. if( !columnCountList.contains( template.column ) )columnCountList.push( template.column )
  617. }
  618. }.bind(this));
  619. columnCountList.each(function( columnCount ){
  620. var createTemplateCategoryItemNode = new Element("div", {
  621. "styles": this.css.createTemplateFormCategoryItemNode,
  622. "text": columnCount+ MWF.xApplication.Forum.LP.column,
  623. "value": columnCount
  624. }).inject(createTemplateCategoryNode);
  625. createTemplateCategoryItemNode.addEvent("click", function(){
  626. createTemplateContentNode.empty();
  627. createTemplateCategoryNode.getElements("div").each(function(node, i){
  628. if (i>0) node.setStyles(_self.css.createTemplateFormCategoryItemNode);
  629. });
  630. this.setStyles(_self.css.createTemplateFormCategoryItemNode_current);
  631. loadDefaultTemplate(this.get("value"));
  632. });
  633. }.bind(this));
  634. var resize = function(){
  635. var size = this.app.content.getSize();
  636. var y = (size.y*0.1)/2;
  637. var x = (size.x*0.1)/2;
  638. if (y<0) y=0;
  639. if (x<0) x=0;
  640. createTemplateAreaNode.setStyles({
  641. "top": ""+y+"px",
  642. "left": ""+x+"px"
  643. });
  644. y = size.y*0.9-createTemplateCategoryNode.getSize().y-70;
  645. createTemplateContentNode.setStyle("height", ""+y+"px");
  646. }.bind(this);
  647. resize();
  648. this.app.addEvent("resize", resize);
  649. var loadDefaultTemplate = function( columnCount ){
  650. this.getDefaultTypeTemplateList(function(){
  651. for( var key in this.defalutTypeTemplateList ){
  652. var template = this.defalutTypeTemplateList[key];
  653. if( columnCount && template.column != parseInt( columnCount ) ){
  654. continue;
  655. }
  656. template.key = key;
  657. var templateNode = new Element("div", {"styles": this.css.typeTemplateNode}).inject(createTemplateContentNode);
  658. var templateIconNode = new Element("div", {"styles": this.css.typeTemplateIconNode}).inject(templateNode);
  659. //var templateTitleNode = new Element("div", {"styles": this.css.typeTemplateTitleNode, "text": template.title}).inject(templateNode);
  660. templateNode.store("template", template.key);
  661. var templateIconImgNode = new Element("img", {"styles": this.css.typeTemplateIconImgNode}).inject(templateIconNode);
  662. templateIconImgNode.set("src", template.preview);
  663. templateNode.addEvents({
  664. "mouseover": function(){this.setStyles(_self.css.typeTemplateNode_over)},
  665. "mouseout": function(){this.setStyles(_self.css.typeTemplateNode)},
  666. "mousedown": function(){this.setStyles(_self.css.typeTemplateNode_down)},
  667. "mouseup": function(){this.setStyles(_self.css.typeTemplateNode_over)},
  668. "click": function(e){
  669. selectType(e, this.retrieve("template"));
  670. _self.app.removeEvent("resize", resize);
  671. createTemplateAreaNode.destroy();
  672. createTemplateMaskNode.destroy();
  673. }
  674. });
  675. }
  676. }.bind(this));
  677. }.bind(this);
  678. var selectType = function( e, type ){
  679. this.data.indexListStyle = type;
  680. this.indexListStyleShow.empty();
  681. new Element("img", {
  682. src : this.defalutTypeTemplateList[type].preview,
  683. styles : this.css.indexListStylePreview
  684. }).inject(this.indexListStyleShow);
  685. }.bind(this);
  686. var loadAllTemplates = function(){
  687. createTemplateContentNode.empty();
  688. createTemplateCategoryNode.getElements("div").each(function(node, i){
  689. if (i>0) node.setStyles(_self.css.createTemplateFormCategoryItemNode);
  690. });
  691. createTemplateCategoryAllNode.setStyles(_self.css.createTemplateFormCategoryItemNode_current);
  692. loadDefaultTemplate();
  693. };
  694. loadAllTemplates();
  695. createTemplateMaskNode.addEvent("click", function(){
  696. this.app.removeEvent("resize", resize);
  697. createTemplateAreaNode.destroy();
  698. createTemplateMaskNode.destroy();
  699. }.bind(this));
  700. }
  701. });
  702. MWF.xApplication.Forum.Setting.ForumColorForm = new Class({
  703. Extends: MPopupForm,
  704. Implements: [Options, Events],
  705. options: {
  706. "style": "default",
  707. "width": "820",
  708. "height": "280",
  709. "hasTop": true,
  710. "hasIcon": false,
  711. "hasTopIcon" : true,
  712. "hasTopContent" : true,
  713. "hasBottom": false,
  714. "title": MWF.xApplication.Forum.LP.forumColorFormTitle,
  715. "draggable": true,
  716. "closeAction": true
  717. },
  718. _createTableContent: function () {
  719. var div = new Element("div",{
  720. "styles" : this.css.sectionFormContent
  721. }).inject(this.formTableArea);
  722. div.setStyle( "margin-top" , "10px" );
  723. this.lp.optionsForumColors.each(function(arr, i){
  724. arr.each( function(c , j ){
  725. var iconAreaNode = new Element("div",{
  726. "styles" : this.css.iconAreaNode
  727. }).inject(div);
  728. var iconNode = new Element("div",{
  729. "styles" : {height : "20px", width : "40px", "margin" : "5px 5px 5px 5px" , "background-color" : c, "cursor" : "pointer"}
  730. }).inject(iconAreaNode);
  731. iconAreaNode.store( "color", c );
  732. iconAreaNode.addEvents({
  733. "click" : function(){
  734. this.obj.fireEvent("postOk", this.node.retrieve("color") );
  735. this.obj.close();
  736. }.bind({ obj : this, node : iconAreaNode })
  737. })
  738. }.bind(this))
  739. }.bind(this));
  740. }
  741. });
  742. MWF.xApplication.Forum.Setting.SectionSettingExplorer = new Class({
  743. Extends: MWF.widget.Common,
  744. Implements: [Options, Events],
  745. options: {
  746. "style": "default"
  747. },
  748. initialize: function (container, app, parent, options) {
  749. this.container = container;
  750. this.parent = parent;
  751. this.app = app;
  752. this.css = this.parent.css;
  753. this.lp = this.app.lp;
  754. },
  755. load: function(){
  756. this.app.access.getUserPermission(function (permission) {
  757. this.permission = permission;
  758. this._load();
  759. }.bind(this))
  760. },
  761. _load: function () {
  762. this.container.empty();
  763. this.loadToolbar();
  764. },
  765. destroy : function(){
  766. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  767. this.view.destroy();
  768. },
  769. loadToolbar: function(){
  770. this.toolbar = new Element("div",{
  771. styles : this.css.toolbar
  772. }).inject(this.container);
  773. if( this.app.access.isAdmin() || this.permission.bbsAdmin || this.permission.bbsForumAdmin ){
  774. this.createActionNode = new Element("div",{
  775. styles : this.css.toolbarActionNode,
  776. text: this.lp.createSection
  777. }).inject(this.toolbar);
  778. this.createActionNode.addEvent("click",function(){
  779. var form = new MWF.xApplication.Forum.Setting.SectionSettingForm(this, {}, {
  780. onPostOk : function(){
  781. this.app.access.getUserPermission(function () {
  782. this.view.reload();
  783. }.bind(this), true);
  784. }.bind(this)});
  785. form.create();
  786. }.bind(this));
  787. }
  788. this.loadCategoryBar();
  789. //this.fileterNode = new Element("div",{
  790. // styles : this.css.fileterNode
  791. //}).inject(this.toolbar);
  792. },
  793. loadCategoryBar : function(){
  794. var _self = this;
  795. //this.categoryBar = new Element("div.categoryBar",{"styles":this.css.categoryBar}).inject(this.contentDiv);
  796. this.allCategoryNode = new Element("li.allCategoryNode", {
  797. "styles": this.css.categoryNode,
  798. "text" : MWF.xApplication.Forum.LP.all1
  799. }).inject(this.toolbar);
  800. this.allCategoryNode.addEvents({
  801. "mouseover" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode_over) }.bind(this),
  802. "mouseout" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode) }.bind(this),
  803. "click":function(){
  804. if( this.currentCategoryNode )this.currentCategoryNode.setStyles(this.css.categoryNode);
  805. this.currentCategoryNode = this.allCategoryNode;
  806. this.allCategoryNode.setStyles(this.css.categoryNode_current);
  807. this.loadView()
  808. }.bind(this)
  809. });
  810. var isManager = false;
  811. this.forumAdminObj = {};
  812. this.app.restActions.listSectionAll( function (json) {
  813. var list = ( json.data || [] ).filter(function(d){
  814. return this.app.access.isAdmin() || this.permission.bbsAdmin || this.permission.sectionList.contains(d.id);
  815. }.bind(this));
  816. var categoryList = [];
  817. var idList = [];
  818. list.each(function( d ){
  819. if( !idList.contains( d.forumId ) ){
  820. categoryList.push({
  821. "forumName": d.forumName,
  822. "id": d.forumId
  823. });
  824. idList.push( d.forumId );
  825. }
  826. });
  827. categoryList.each(function(d){
  828. var categoryNode = new Element("li.categoryNode", {
  829. "styles": this.css.categoryNode,
  830. "text" : d.forumName
  831. }).inject(this.toolbar);
  832. categoryNode.store( "categoryId" , d.id );
  833. categoryNode.addEvents({
  834. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode_over) }.bind({node : categoryNode }),
  835. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode) }.bind({node : categoryNode }),
  836. "click":function(){
  837. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.categoryNode);
  838. _self.currentCategoryNode = this.node;
  839. this.node.setStyles(_self.css.categoryNode_current);
  840. _self.loadView( )
  841. }.bind({ name : d.id, node : categoryNode })
  842. })
  843. }.bind(this))
  844. }.bind(this));
  845. // this.app.restActions.listCategoryAllByAdmin( function( json ){
  846. // json.data = json.data || [];
  847. // json.data.each( function( d ){
  848. // var flag = this.app.access.hasForumAdminAuthority( d );
  849. // this.forumAdminObj[d.id] = flag;
  850. // if( !isManager ){
  851. // isManager = flag;
  852. // }
  853. // var categoryNode = new Element("li.categoryNode", {
  854. // "styles": this.css.categoryNode,
  855. // "text" : d.forumName
  856. // }).inject(this.toolbar);
  857. // categoryNode.store( "categoryId" , d.id );
  858. // categoryNode.addEvents({
  859. // "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode_over) }.bind({node : categoryNode }),
  860. // "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode) }.bind({node : categoryNode }),
  861. // "click":function(){
  862. // if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.categoryNode);
  863. // _self.currentCategoryNode = this.node;
  864. // this.node.setStyles(_self.css.categoryNode_current);
  865. // _self.loadView( )
  866. // }.bind({ name : d.id, node : categoryNode })
  867. // })
  868. // }.bind(this))
  869. // }.bind(this), null, false
  870. // );
  871. // if( !isManager )this.createActionNode.destroy();
  872. this.allCategoryNode.click();
  873. },
  874. loadView : function(){
  875. var categoryId;
  876. if( this.currentCategoryNode ){
  877. categoryId = this.currentCategoryNode.retrieve("categoryId");
  878. }
  879. categoryId = categoryId || "all";
  880. if(this.view)this.view.destroy();
  881. if(this.viewContainer)this.viewContainer.destroy();
  882. this.viewContainer = Element("div",{
  883. "styles" : this.css.viewContainer
  884. }).inject(this.container);
  885. this.resizeWindow();
  886. this.resizeWindowFun = this.resizeWindow.bind(this);
  887. this.app.addEvent("resize", this.resizeWindowFun );
  888. this.view = new MWF.xApplication.Forum.Setting.SectionSettingView( this.viewContainer, this.app, this, {
  889. templateUrl : this.parent.path+"listItemSection.json",
  890. scrollEnable : true,
  891. categoryId : categoryId
  892. } );
  893. this.view.load();
  894. },
  895. resizeWindow: function(){
  896. var size = this.container.getSize();
  897. this.viewContainer.setStyles({"height":(size.y-65)+"px"});
  898. }
  899. });
  900. MWF.xApplication.Forum.Setting.SectionSettingView = new Class({
  901. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  902. _createDocument: function(data){
  903. return new MWF.xApplication.Forum.Setting.SectionSettingDocument(this.viewNode, data, this.explorer, this);
  904. },
  905. _getCurrentPageData: function(callback, count){
  906. if (!count)count = 20;
  907. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  908. //var filter = this.filterData || {};
  909. if( this.options.categoryId == "all" ){
  910. this.actions.listSectionAll( function (json) {
  911. this.explorer.app.access.getUserPermission(function (permission) {
  912. var list = ( json.data || [] ).filter(function(d){
  913. return this.explorer.app.access.isAdmin() || permission.bbsAdmin || permission.sectionList.contains(d.id);
  914. }.bind(this))
  915. json.data = list;
  916. json.data.size = list.length;
  917. if (callback)callback(json);
  918. }.bind(this))
  919. }.bind(this))
  920. }else{
  921. this.actions.listSectionByAdmin( this.options.categoryId, function (json) {
  922. this.explorer.app.access.getUserPermission(function (permission) {
  923. var list = ( json.data || [] ).filter(function(d){
  924. return this.explorer.app.access.isAdmin() || permission.bbsAdmin || permission.sectionList.contains(d.id);
  925. }.bind(this))
  926. json.data = list;
  927. json.data.size = list.length;
  928. if (callback)callback(json);
  929. }.bind(this))
  930. }.bind(this))
  931. }
  932. },
  933. _removeDocument: function(documentData, all){
  934. this.actions.deleteSection(documentData.id, function(json){
  935. this.reload();
  936. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  937. }.bind(this));
  938. },
  939. _create: function(){
  940. },
  941. _openDocument: function( documentData ){
  942. var form = new MWF.xApplication.Forum.Setting.SectionSettingForm(this, documentData, {
  943. title : this.lp.sectionFormTitle + " - " + documentData.sectionName,
  944. onPostOk : function(){
  945. this.reload();
  946. }.bind(this)
  947. });
  948. //this.app.access.hasSectionAdminAuthority( documentData , function( flag ){ 只有分区管理员可以对分区以下的板块进行增删改,版主不能
  949. this.app.access.hasForumAdminAuthority( documentData.forumId , function( flag ){
  950. flag ? form.edit() : form.open();
  951. } )
  952. },
  953. _queryCreateViewNode: function(){
  954. },
  955. _postCreateViewNode: function( viewNode ){
  956. },
  957. _queryCreateViewHead:function(){
  958. },
  959. _postCreateViewHead: function( headNode ){
  960. }
  961. });
  962. MWF.xApplication.Forum.Setting.SectionSettingDocument = new Class({
  963. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  964. mouseoverSection : function(sectionNode, ev){
  965. var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  966. if( removeNode )removeNode.setStyle("opacity",1)
  967. },
  968. mouseoutSection : function(sectionNode, ev){
  969. var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  970. if( removeNode )removeNode.setStyle("opacity",0)
  971. },
  972. _queryCreateDocumentNode:function( itemData ){
  973. },
  974. _postCreateDocumentNode: function( itemNode, itemData ){
  975. }
  976. });
  977. MWF.xApplication.Forum.Setting.SectionSettingForm = new Class({
  978. Extends: MPopupForm,
  979. Implements: [Options, Events],
  980. options: {
  981. "style": "default",
  982. "width": "1100",
  983. "height": "90%",
  984. "hasTop": true,
  985. "hasIcon": false,
  986. "hasTopIcon" : true,
  987. "hasTopContent" : true,
  988. "hasBottom": true,
  989. "title": MWF.xApplication.Forum.LP.sectionFormTitle,
  990. "draggable": true,
  991. "closeAction": true
  992. },
  993. createToolbar: function(){
  994. var _self = this;
  995. this.toolbar = new Element("div",{
  996. styles : this.css.formToolbar
  997. }).inject(this.formNode);
  998. var categoryNode = new Element("li.categoryNode", {
  999. "styles": this.css.formCategoryNode,
  1000. "text" : this.lp.baseSetting
  1001. }).inject(this.toolbar);
  1002. categoryNode.addEvents({
  1003. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode_over) }.bind({node : categoryNode }),
  1004. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode) }.bind({node : categoryNode }),
  1005. "click":function(){
  1006. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.formCategoryNode);
  1007. _self.currentCategoryNode = this.node;
  1008. this.node.setStyles(_self.css.formCategoryNode_current);
  1009. _self.baseContainer.setStyle("display","");
  1010. _self.permissionContainer.setStyle("display","none");
  1011. }.bind({ node : categoryNode })
  1012. });
  1013. categoryNode.setStyles( this.css.formCategoryNode_current );
  1014. _self.currentCategoryNode = categoryNode;
  1015. var categoryNode = new Element("li.categoryNode", {
  1016. "styles": this.css.formCategoryNode,
  1017. "text" : this.lp.permissionSetting
  1018. }).inject(this.toolbar);
  1019. categoryNode.addEvents({
  1020. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode_over) }.bind({node : categoryNode }),
  1021. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode) }.bind({node : categoryNode }),
  1022. "click":function(){
  1023. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.formCategoryNode);
  1024. _self.currentCategoryNode = this.node;
  1025. this.node.setStyles(_self.css.formCategoryNode_current);
  1026. _self.baseContainer.setStyle("display","none");
  1027. _self.permissionContainer.setStyle("display","");
  1028. }.bind({ node : categoryNode })
  1029. })
  1030. },
  1031. createContent: function () {
  1032. this.createToolbar();
  1033. this.formContentNode = new Element("div.formContentNode", {
  1034. "styles": this.css.formContentNode
  1035. }).inject(this.formNode);
  1036. this.formTableContainer = new Element("div.formTableContainer", {
  1037. "styles": this.css.formTableContainer
  1038. }).inject(this.formContentNode);
  1039. this.formTableArea = new Element("div.formTableArea", {
  1040. "styles": this.css.formTableArea
  1041. }).inject(this.formTableContainer);
  1042. this._createTableContent();
  1043. },
  1044. _createTableContent: function () {
  1045. _self = this;
  1046. this.baseContainer = new Element("div").inject(this.formTableArea);
  1047. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1048. "<tr>" +
  1049. " <td styles='formTableTitle' lable='sectionName' width='10%'></td>" +
  1050. " <td styles='formTableValue' item='sectionName' width='40%'></td>" +
  1051. " <td styles='formTableTitle' lable='forumId' width='10%'></td>" +
  1052. " <td styles='formTableValue' item='forumId' width='40%'></td>" +
  1053. "</tr><tr>" +
  1054. //" <td styles='formTableTitle' lable='sectionType'></td>" +
  1055. //" <td styles='formTableValue' item='sectionType'></td>" +
  1056. //"</tr><tr>" +
  1057. " <td styles='formTableTitle' lable='sectionStatus'></td>" +
  1058. " <td styles='formTableValue' item='sectionStatus'></td>" +
  1059. " <td styles='formTableTitle' lable='orderNumber'></td>" +
  1060. " <td styles='formTableValue' item='orderNumber'></td>" +
  1061. "</tr><tr>" +
  1062. " <td styles='formTableTitle' lable='typeCatagory'></td>" +
  1063. " <td styles='formTableValue' item='typeCatagory'></td>" +
  1064. " <td styles='formTableTitle' lable='subjectType'></td>" +
  1065. " <td styles='formTableValue' item='subjectType'></td>" +
  1066. "</tr><tr>" +
  1067. " <td styles='formTableTitle' lable='creatorName'></td>" +
  1068. " <td styles='formTableValue' item='creatorName'></td>" +
  1069. " <td styles='formTableTitle' lable='createTime'></td>" +
  1070. " <td styles='formTableValue' item='createTime'></td>" +
  1071. "</tr><tr>" +
  1072. " <td styles='formTableTitle' lable='sectionIcon'></td>" +
  1073. " <td styles='formTableValue' item='sectionIconArea' colspan='3' valign='bottom'></td>" +
  1074. "</tr><tr>" +
  1075. " <td styles='formTableTitle' lable='sectionDescription'></td>" +
  1076. " <td styles='formTableValue' item='sectionDescription' colspan='3'></td>" +
  1077. "</tr><tr>" +
  1078. " <td styles='formTableTitle' lable='sectionNotice'></td>" +
  1079. " <td styles='formTableValue' item='sectionNotice' colspan='3'></td>" +
  1080. "</tr>"+
  1081. "</table>";
  1082. this.baseContainer.set("html", html);
  1083. this.permissionContainer = new Element("div", { styles : {"display":"none"} }).inject( this.formTableArea );
  1084. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1085. "<tr>" +
  1086. " <td styles='formTableTitle' lable='moderatorNames'></td>" +
  1087. " <td styles='formTableValue' item='moderatorNames' colspan='3'></td>"+
  1088. "</tr><tr>" +
  1089. " <td styles='formTableTitle' lable='sectionVisible' width='10%'></td>" +
  1090. " <td styles='formTableValue' item='sectionVisible' width='20%'></td>" +
  1091. " <td styles='formTableValue' width='70%' colspan='2'></td>" +
  1092. "</tr><tr>" +
  1093. " <td></td>"+
  1094. " <td styles='formTableValue' colspan='3'>"+
  1095. " <div styles='formItemSpan' item='sectionVisibleResult'></div>"+
  1096. " </td>" +
  1097. "</tr><tr>" +
  1098. " <td styles='formTableTitle' lable='subjectPublishAble'></td>" +
  1099. " <td styles='formTableValue' item='subjectPublishAble'></td>" +
  1100. " <td styles='formTableValue' colspan='2'></td>" +
  1101. "</tr><tr>" +
  1102. " <td></td>"+
  1103. " <td styles='formTableValue' colspan='3'>"+
  1104. " <div styles='formItemSpan' item='subjectPublishResult'></div>"+
  1105. " </td>" +
  1106. "</tr><tr>" +
  1107. " <td styles='formTableTitle' lable='replyPublishAble'></td>" +
  1108. " <td styles='formTableValue' item='replyPublishAble'></td>" +
  1109. " <td styles='formTableValue' colspan='2'></td>" +
  1110. "</tr><tr>" +
  1111. " <td></td>"+
  1112. " <td styles='formTableValue' colspan='3'>"+
  1113. " <div styles='formItemSpan' item='replyPublishResult'></div>"+
  1114. " </td>" +
  1115. // "</tr><tr>" +
  1116. // " <td styles='formTableTitle' lable='sectionGrade'></td>" +
  1117. // " <td styles='formTableValue' item='sectionGrade'></td>" +
  1118. // " <td styles='formTableValue' colspan='2'></td>" +
  1119. "</tr>" +
  1120. "</tr><tr item='indexRecommendTr' style='"+ ( this.data.sectionVisible == this.lp.byPermission ? "display:none;" : "display:;" ) +"'>" +
  1121. " <td styles='formTableTitle' lable='indexRecommendable'></td>" +
  1122. " <td styles='formTableValue' item='indexRecommendable'></td>" +
  1123. " <td styles='formTableTitle' lable='indexRecommenPerson' style='"+ ( this.data.indexRecommendable == false ? "display:none;" : "display:;" ) +"'></td>" +
  1124. " <td styles='formTableValue' item='indexRecommenPerson' style='"+ ( this.data.indexRecommendable == false ? "display:none;" : "display:;" ) +"'></td>" +
  1125. //"</tr><tr>" +
  1126. //" <td styles='formTableTitle' lable='subjectNeedAudit' width='10%'></td>" +
  1127. //" <td styles='formTableValue' item='subjectNeedAudit' width='20%'></td>" +
  1128. //" <td styles='formTableTitle' lable='subjectAuditPerson' width='10%' style='"+ ( this.data.subjectNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1129. //" <td styles='formTableValue' item='subjectAuditPerson' width='60%' style='"+ ( this.data.subjectNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1130. //
  1131. //"</tr><tr>" +
  1132. //" <td styles='formTableTitle' lable='replyNeedAudit' width='10%'></td>" +
  1133. //" <td styles='formTableValue' item='replyNeedAudit' width='20%'></td>" +
  1134. //" <td styles='formTableTitle' lable='replyAuditPerson' width='10%' style='"+ ( this.data.replyNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1135. //" <td styles='formTableValue' item='replyAuditPerson' width='60%' style='"+ ( this.data.replyNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1136. "</tr>"+
  1137. "</table>";
  1138. this.permissionContainer.set("html", html);
  1139. var forumNames = [""];
  1140. var forumIds = [""];
  1141. this.app.restActions.listCategoryAllByAdmin( function( json ){
  1142. json.data.each( function( d ){
  1143. if( this.isNew ){
  1144. if( this.app.access.hasForumAdminAuthority( d ) ){
  1145. forumNames.push(d.forumName );
  1146. forumIds.push(d.id);
  1147. }
  1148. }else{
  1149. forumNames.push(d.forumName );
  1150. forumIds.push(d.id);
  1151. }
  1152. }.bind(this))
  1153. }.bind(this), null ,false);
  1154. if( this.data.typeCategory ){
  1155. this.data.typeCatagory = typeof this.data.typeCategory == "string" ? this.data.typeCategory.split("|") : this.data.typeCategory;
  1156. }else{
  1157. this.data.typeCatagory = this.lp.typeCategorySelectValue.split("|");
  1158. //this.data.typeCatagory = typeof this.data.typeCatagory == "string" ? this.data.typeCatagory.split("|") : this.data.typeCatagory;
  1159. }
  1160. if(this.data.subjectTypeList && this.data.subjectTypeList.length>0){
  1161. this.data.subjectType = this.data.subjectTypeList.join("|");
  1162. }
  1163. if(this.data.sectionGrade){
  1164. this.data.sectionGrade = "是";
  1165. }
  1166. debugger;
  1167. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1168. this.form = new MForm(this.formTableArea, this.data, {
  1169. style: "forum",
  1170. isEdited: this.isEdited || this.isNew,
  1171. itemTemplate: {
  1172. sectionName: {text: this.lp.sectionName, notEmpty: true},
  1173. forumId: {text: this.lp.owneForum, type : "select", "selectText" : forumNames, "selectValue" : forumIds , notEmpty: true, isEdited : function(){ return this.isNew }.bind(this)},
  1174. sectionVisible: {text: this.lp.sectionVisible, type : "select", selectValue : this.lp.sectionVisibleValue.split(","), event : {
  1175. change : function( it, ev ){
  1176. this.setItemStyle( it, "sectionVisible" );
  1177. if( it.getValue() == this.lp.allPerson ){
  1178. this.formTableArea.getElements("[item='indexRecommendTr']")[0].setStyle("display","")
  1179. }else{
  1180. this.formTableArea.getElements("[item='indexRecommendTr']")[0].setStyle("display","none")
  1181. }
  1182. }.bind(this)
  1183. }},
  1184. sectionVisibleResult : { type : "org", orgType : ["person","unit"], count :0 , value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_") }.bind(this), style : this.getContainerStyle("sectionVisible") },
  1185. subjectPublishAble: {text: this.lp.subjectPublishAble, type : "select", selectValue : this.lp.subjectPublishAbleValue.split(","), event : {
  1186. change : function( it, ev ){ this.setItemStyle( it, "subjectPublish" ); }.bind(this)
  1187. }},
  1188. subjectPublishResult : { type : "org", orgType : ["person","unit"], count :0 , value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  1189. replyPublishAble: {text: this.lp.replyPublishAble, type : "select", selectValue : this.lp.replyPublishAbleValue.split(","), event : {
  1190. change : function( it, ev ){ this.setItemStyle( it, "replyPublish" ); }.bind(this)
  1191. }},
  1192. replyPublishResult : { type : "org", orgType : ["person","unit"], count :0 , value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  1193. indexRecommendable: {text: this.lp.indexRecommendable, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") , defaultValue : "true" ,event : {
  1194. change : function( it, ev ){
  1195. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1196. this.permissionContainer.getElements("[item='indexRecommenPerson']")[0].setStyles( styles );
  1197. this.permissionContainer.getElements("[lable='indexRecommenPerson']")[0].setStyles( styles );
  1198. }.bind(this)
  1199. }},
  1200. indexRecommenPerson : { type : "org", text: this.lp.indexRecommenPerson , orgType : "person", count : 0, value : function(){
  1201. var v = this.getRoleMemberByCode("SECTION_RECOMMENDER_");
  1202. return v == "" ? this.app.userName : v;
  1203. }.bind(this)},
  1204. subjectNeedAudit: {text: this.lp.subjectNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" ,event : {
  1205. change : function( it, ev ){
  1206. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1207. this.permissionContainer.getElements("[item='subjectAuditPerson']")[0].setStyles( styles );
  1208. this.permissionContainer.getElements("[lable='subjectAuditPerson']")[0].setStyles( styles );
  1209. }.bind(this)
  1210. }},
  1211. subjectAuditPerson : { type : "org", text: this.lp.auditPerson , orgType : "person", count : 0, value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_AUDITOR_") }.bind(this) },
  1212. replyNeedAudit: {text: this.lp.replyNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") , defaultValue : "false" ,event : {
  1213. change : function( it, ev ){
  1214. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1215. this.permissionContainer.getElements("[item='replyAuditPerson']")[0].setStyles( styles );
  1216. this.permissionContainer.getElements("[lable='replyAuditPerson']")[0].setStyles( styles );
  1217. }.bind(this)
  1218. }},
  1219. replyAuditPerson : { type : "org", text: this.lp.auditPerson , orgType : "person", count : 0, value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_AUDITOR_") }.bind(this) },
  1220. moderatorNames : {type : "org",text:this.lp.moderatorNames, orgType:"person", count : 0, defaultValue : this.app.userName },
  1221. sectionType : {text: this.lp.sectionType, type : "select", selectValue : this.lp.sectionTypeValue.split(",") },
  1222. //sectionCreateAble: {text: this.lp.sectionCreateAble, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  1223. creatorName: { text: this.lp.creatorName, type : "org", isEdited : false, "defaultValue" : this.app.userName },
  1224. createTime: {text: this.lp.createTime, type : "innerText" },
  1225. sectionStatus: {text: this.lp.sectionStatus, type : "select", selectValue : this.lp.sectionStatusValue.split(",") },
  1226. sectionGrade: {text: this.lp.sectionGrade, type : "select", selectValue : this.lp.sectionGradeValue.split(",") },
  1227. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  1228. subjectType: {text: this.lp.subjectType, defaultValue : this.lp.subjectTypeDefaultValue },
  1229. typeCatagory: {text: this.lp.typeCatagory, selectValue : this.lp.typeCategorySelectValue.split("|"), type : "checkbox", notEmpty : true},
  1230. sectionDescription : {text: this.lp.sectionDescription, type: "textarea", style:{"height":"45px"} },
  1231. sectionNotice: {text: this.lp.sectionNotice, type: "rtf", RTFConfig : { "enablePreview": false } },
  1232. sectionIcon : { text : this.lp.sectionIcon }
  1233. }
  1234. }, this.app);
  1235. this.form.load();
  1236. this.formTableArea.getElement("[lable='indexRecommenPerson']").setStyle("text-align","right");
  1237. this.createIconNode();
  1238. }.bind(this), true);
  1239. },
  1240. saveRole : function( id, callback ){
  1241. var data = this.form.getResult(true, null, true, false, true);
  1242. if( this.isNew )data.id = id;
  1243. this.saveRoleMember( true, "moderatorNames" ,"SECTION_MANAGER_", data, true );
  1244. //this.saveRoleMember( true, "moderatorNames" ,"SECTION_MANAGER_", data );
  1245. var flag = data.sectionVisible != this.lp.allPerson;
  1246. this.saveRoleMember( flag, "sectionVisibleResult" ,"SECTION_GUEST_", data );
  1247. flag = data.subjectPublishAble != this.lp.allPerson;
  1248. this.saveRoleMember( flag, "subjectPublishResult" ,"SECTION_SUBJECT_PUBLISHER_", data );
  1249. flag = data.replyPublishAble != this.lp.allPerson;
  1250. this.saveRoleMember( flag, "replyPublishResult" ,"SECTION_REPLY_PUBLISHER_", data );
  1251. flag = data.indexRecommendable == "true";
  1252. this.saveRoleMember( flag, "indexRecommenPerson" ,"SECTION_RECOMMENDER_", data, true );
  1253. flag = data.subjectNeedAudit == "true";
  1254. this.saveRoleMember( flag, "subjectAuditPerson" ,"SECTION_SUBJECT_AUDITOR_", data, true );
  1255. flag = data.replyNeedAudit == "true";
  1256. this.saveRoleMember( flag, "replyAuditPerson" ,"SECTION_REPLY_AUDITOR_", data, true );
  1257. if( callback )callback();
  1258. },
  1259. saveRoleMember : function( flag, dataKey, code, data , isSingle, callback ){
  1260. var orgArray = [];
  1261. if( flag ){
  1262. if( isSingle ){
  1263. if( data[ dataKey ] ){
  1264. data[ dataKey ].each( function( p ){
  1265. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  1266. })
  1267. }
  1268. }else{
  1269. if( data[ dataKey ] ){
  1270. data[ dataKey ].each( function( p ){
  1271. var flag = p.substr(p.length-1, 1);
  1272. switch (flag.toLowerCase()){
  1273. case "p":
  1274. orgArray.push( { objectName : p, objectType : "人员" } );
  1275. break;
  1276. case "u":
  1277. orgArray.push( { objectName : p, objectType : "组织" } );
  1278. break;
  1279. default:
  1280. orgArray.push( { objectName : p, objectType : "人员" } );
  1281. }
  1282. })
  1283. }
  1284. }
  1285. }
  1286. var d = {
  1287. bindObjectArray : orgArray,
  1288. bindRoleCode : code + this.data.id
  1289. };
  1290. this.app.restActions.bindRole( d, function( rData ){
  1291. if( callback )callback(json);
  1292. }.bind(this))
  1293. },
  1294. getRoleMemberByCode : function( code ){
  1295. if( !this.RoleMember )this.RoleMember = {};
  1296. if( this.RoleMember[ code ] ){
  1297. return this.RoleMember[ code ];
  1298. }
  1299. var r = this.RoleMember[ code ] = [];
  1300. if( !this.data.id ){
  1301. return r;
  1302. }
  1303. this.RoleMember[ code ] = r;
  1304. if( this.data && this.data.id ){
  1305. this.actions.listRoleMemberByCode( { "bindRoleCode" : code+ this.data.id }, function(json){
  1306. json.data = json.data || [];
  1307. json.data.each( function( d ){
  1308. r.push( d.objectName );
  1309. }.bind(this) )
  1310. }, function(){}, false );
  1311. }
  1312. //}
  1313. return r;
  1314. },
  1315. getButtonStyle : function( key ){
  1316. if( this.isEdited || this.isNew ){
  1317. return this.getContainerStyle( key )
  1318. }else{
  1319. return { display:"none"};
  1320. }
  1321. },
  1322. getContainerStyle : function( key ){
  1323. return (!this.data[key] ||(this.data[key] == this.lp.allPerson )) ? { display:"none"} : { display:""};
  1324. },
  1325. setItemStyle : function( it, preStr ){
  1326. var styles = it.getValue() == this.lp.allPerson ? { display : "none" } : { display : "" };
  1327. it.form.getItem(preStr + "Result").setStyles( styles );
  1328. },
  1329. createIconNode: function(){
  1330. var iconPth = "../x_component_Forum/$Setting/"+ this.options.style +"/sectionIcon/";
  1331. var defaultIconSrc = iconPth + "forum_icon.png";
  1332. var sectionIconArea = this.formTableArea.getElements("[item='sectionIconArea']")[0];
  1333. this.iconNode = new Element("img",{
  1334. "styles" : this.css.iconNode
  1335. }).inject(sectionIconArea);
  1336. if (this.data.icon){
  1337. this.iconNode.set("src", "data:image/png;base64,"+this.data.icon+"");
  1338. }else{
  1339. this.iconNode.set("src", defaultIconSrc)
  1340. }
  1341. if( this.isEdited || this.isNew ){
  1342. //var selectIconActionNode = new Element("div", {
  1343. // "styles": this.css.changeIconActionNode,
  1344. // "text": this.lp.selectIcon
  1345. //}).inject(sectionIconArea);
  1346. //selectIconActionNode.addEvent("click", function () {
  1347. // this.selectIcon();
  1348. //}.bind(this));
  1349. var changeIconActionNode = new Element("div", {
  1350. "styles": this.css.changeIconActionNode,
  1351. "text": this.lp.uploadIcon
  1352. }).inject(sectionIconArea);
  1353. changeIconActionNode.addEvent("click", function () {
  1354. this.changeIcon();
  1355. }.bind(this));
  1356. }
  1357. },
  1358. selectIcon: function(){
  1359. var form = new MWF.xApplication.Forum.Setting.SectionIconForm(this, {}, {
  1360. onPostOk : function( icon ){
  1361. if( this.formData )this.formData = null;
  1362. this.iconNode.set("src",icon.path );
  1363. }.bind(this)
  1364. });
  1365. form.edit();
  1366. },
  1367. changeIcon: function () {
  1368. if (!this.uploadFileAreaNode) {
  1369. this.uploadFileAreaNode = new Element("div");
  1370. var html = "<input name=\"file\" type=\"file\"/>";
  1371. this.uploadFileAreaNode.set("html", html);
  1372. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1373. this.fileUploadNode.addEvent("change", function () {
  1374. var files = fileNode.files;
  1375. if (files.length) {
  1376. for (var i = 0; i < files.length; i++) {
  1377. var file = files.item(i);
  1378. if (!file.type.match('image.*'))continue;
  1379. this.file = file;
  1380. this.formData = new FormData();
  1381. this.formData.append('file', this.file);
  1382. if (!window.FileReader) continue;
  1383. var reader = new FileReader();
  1384. reader.onload = (function (theFile) {
  1385. return function (e) {
  1386. this.iconNode.set("src",e.target.result)
  1387. }.bind(this);
  1388. }.bind(this))(file);
  1389. reader.readAsDataURL(file);
  1390. }
  1391. }
  1392. }.bind(this));
  1393. }
  1394. var fileNode = this.uploadFileAreaNode.getFirst();
  1395. fileNode.click();
  1396. },
  1397. saveIcon: function (id, callback) {
  1398. this.app.restActions.uploadSectionIcon(id, function () {
  1399. if (callback)callback();
  1400. }.bind(this), null, this.formData, this.file);
  1401. },
  1402. _ok: function (data, callback) {
  1403. if( typeOf(data.moderatorNames) === "string" ){
  1404. data.moderatorNames = data.moderatorNames.split(",").filter(function(d){ return !!d} );
  1405. }
  1406. data.sectionLevel = MWF.xApplication.Forum.LP.mainSection;
  1407. data.typeCategory = data.typeCatagory.split(",").join("|");
  1408. var subjectType = data.subjectType;
  1409. subjectType = subjectType.replace(/[^\x00-\xff]/g, 'xx')
  1410. if(subjectType && subjectType.length>255){
  1411. data.subjectType = this.lp.subjectTypeDefaultValue;
  1412. }
  1413. if(data.sectionGrade && data.sectionGrade === "是"){
  1414. data.sectionGrade = true;
  1415. }
  1416. debugger;
  1417. this.app.restActions.saveSection( data, function(json){
  1418. if( this.formData ){
  1419. this.saveIcon( json.data.id, function(){
  1420. this.saveRole( json.data.id, function( data ){
  1421. if( callback )callback(json);
  1422. }.bind(this) )
  1423. }.bind(this) );
  1424. }else{
  1425. this.saveRole( json.data.id, function( data ){
  1426. if( callback )callback(json);
  1427. }.bind(this) )
  1428. }
  1429. this.fireEvent("postOk")
  1430. }.bind(this));
  1431. },
  1432. setFormNodeSize: function (width, height, top, left) {
  1433. if (!width)width = this.options.width ? this.options.width : "50%";
  1434. if (!height)height = this.options.height ? this.options.height : "50%";
  1435. if (!top) top = this.options.top ? this.options.top : 0;
  1436. if (!left) left = this.options.left ? this.options.left : 0;
  1437. var allSize = this.app.content.getSize();
  1438. var limitWidth = allSize.x; //window.screen.width
  1439. var limitHeight = allSize.y; //window.screen.height
  1440. "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  1441. "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  1442. 300 > width && (width = 300);
  1443. 220 > height && (height = 220);
  1444. top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
  1445. left = left || parseInt((limitWidth - width) / 2, 10);
  1446. this.formAreaNode.setStyles({
  1447. "width": "" + width + "px",
  1448. "height": "" + height + "px",
  1449. "top": "" + top + "px",
  1450. "left": "" + left + "px"
  1451. });
  1452. this.formNode.setStyles({
  1453. "width": "" + width + "px",
  1454. "height": "" + height + "px"
  1455. });
  1456. var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  1457. var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  1458. var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  1459. var toolbarSize = this.toolbar ? this.toolbar.getSize() : {x: 0, y: 0};
  1460. var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - toolbarSize.y;
  1461. //var formMargin = formHeight -iconSize.y;
  1462. this.formContentNode.setStyles({
  1463. "height": "" + contentHeight + "px"
  1464. });
  1465. this.formTableContainer.setStyles({
  1466. "height": "" + contentHeight + "px"
  1467. });
  1468. }
  1469. });
  1470. MWF.xApplication.Forum.Setting.SectionIconForm = new Class({
  1471. Extends: MPopupForm,
  1472. Implements: [Options, Events],
  1473. options: {
  1474. "style": "default",
  1475. "width": "650",
  1476. "height": "400",
  1477. "hasTop": true,
  1478. "hasIcon": false,
  1479. "hasTopIcon" : true,
  1480. "hasTopContent" : true,
  1481. "hasBottom": false,
  1482. "title": MWF.xApplication.Forum.LP.sectionIconFormTitle,
  1483. "draggable": true,
  1484. "closeAction": true
  1485. },
  1486. _createTableContent: function () {
  1487. var iconPath = "../x_component_Forum/$Setting/" + this.options.style +"/sectionIcon/";
  1488. var jsonPath = "../x_component_Forum/$Setting/sectionIcon.json";
  1489. var div = new Element("div",{
  1490. "styles" : this.css.sectionFormContent
  1491. }).inject(this.formTableArea);
  1492. MWF.getJSON(jsonPath, function(json){
  1493. json.icons.each(function(iconName, i){
  1494. var iconAreaNode = new Element("div",{
  1495. "styles" : this.css.iconAreaNode
  1496. }).inject(div);
  1497. var iconNode = new Element("img",{
  1498. "styles" : this.css.iconSelectNode,
  1499. "src" : iconPath + iconName
  1500. }).inject(iconAreaNode);
  1501. iconAreaNode.store( "iconName", iconName );
  1502. iconAreaNode.store( "iconPath", iconPath + iconName );
  1503. iconAreaNode.addEvents({
  1504. "mouseover" : function(){
  1505. this.node.setStyles( this.obj.css.iconAreaNodeOver )
  1506. }.bind({ obj : this, node : iconAreaNode }),
  1507. "mouseout" : function(){
  1508. this.node.setStyles( this.obj.css.iconAreaNode )
  1509. }.bind({ obj : this, node : iconAreaNode }),
  1510. "click" : function(){
  1511. var icon = {
  1512. "path": this.node.retrieve("iconPath"),
  1513. "name": this.node.retrieve("iconName")
  1514. };
  1515. this.obj.fireEvent("postOk", icon );
  1516. this.obj.close();
  1517. }.bind({ obj : this, node : iconAreaNode })
  1518. })
  1519. }.bind(this));
  1520. }.bind(this));
  1521. }
  1522. });
  1523. MWF.xApplication.Forum.Setting.SystemSettingExplorer = new Class({
  1524. Extends: MWF.widget.Common,
  1525. Implements: [Options, Events],
  1526. options: {
  1527. "style": "default"
  1528. },
  1529. initialize: function (container, app, parent, options) {
  1530. this.container = container;
  1531. this.parent = parent;
  1532. this.app = app;
  1533. this.css = this.parent.css;
  1534. this.lp = this.app.lp;
  1535. },
  1536. load: function () {
  1537. this.container.empty();
  1538. this.loadView();
  1539. },
  1540. destroy : function(){
  1541. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  1542. this.view.destroy();
  1543. },
  1544. loadView : function(){
  1545. this.viewContainer = Element("div",{
  1546. "styles" : this.css.viewContainer
  1547. }).inject(this.container);
  1548. this.resizeWindow();
  1549. this.resizeWindowFun = this.resizeWindow.bind(this);
  1550. this.app.addEvent("resize", this.resizeWindowFun );
  1551. this.view = new MWF.xApplication.Forum.Setting.SystemSettingView( this.viewContainer, this.app, this, {
  1552. templateUrl : this.parent.path+"listItemSystem.json",
  1553. scrollEnable : true
  1554. } );
  1555. this.view.load();
  1556. },
  1557. resizeWindow: function(){
  1558. var size = this.container.getSize();
  1559. this.viewContainer.setStyles({"height":(size.y)+"px"});
  1560. }
  1561. });
  1562. MWF.xApplication.Forum.Setting.SystemSettingView = new Class({
  1563. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1564. _createDocument: function(data){
  1565. return new MWF.xApplication.Forum.Setting.SystemSettingDocument(this.viewNode, data, this.explorer, this);
  1566. },
  1567. _getCurrentPageData: function(callback, count){
  1568. if (!count)count = 20;
  1569. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1570. //var filter = this.filterData || {};
  1571. this.actions.listSystemSettingAll(function (json) {
  1572. if (callback)callback(json);
  1573. }.bind(this))
  1574. },
  1575. _removeDocument: function(documentData, all){
  1576. },
  1577. _openDocument: function( documentData ){
  1578. var form = new MWF.xApplication.Forum.Setting.SystemSettingForm(this, documentData, {
  1579. onPostOk : function(){
  1580. this.reload();
  1581. }.bind(this)
  1582. });
  1583. if( MWF.AC.isBBSManager() ){
  1584. form.edit();
  1585. }else{
  1586. form.open();
  1587. }
  1588. }
  1589. });
  1590. MWF.xApplication.Forum.Setting.SystemSettingDocument = new Class({
  1591. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1592. _queryCreateDocumentNode:function( itemData ){
  1593. },
  1594. _postCreateDocumentNode: function( itemNode, itemData ){
  1595. }
  1596. });
  1597. MWF.xApplication.Forum.Setting.SystemSettingForm = new Class({
  1598. Extends: MPopupForm,
  1599. Implements: [Options, Events],
  1600. options: {
  1601. "style": "default",
  1602. "width": "600",
  1603. "height": "320",
  1604. "hasTop": true,
  1605. "hasIcon": false,
  1606. "hasTopIcon" : true,
  1607. "hasTopContent" : true,
  1608. "hasBottom": true,
  1609. "title": MWF.xApplication.Forum.LP.systemSettingFormTitle,
  1610. "draggable": true,
  1611. "closeAction": true
  1612. },
  1613. _createTableContent: function () {
  1614. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1615. "<tr><td styles='formTableTitle' lable='configName' width='20%'></td>" +
  1616. " <td styles='formTableValue' item='configName' width='80%'></td></tr>" +
  1617. "<tr><td styles='formTableTitle' lable='configValue'></td>" +
  1618. " <td styles='formTableValue' item='configValue'></td></tr>" +
  1619. "<tr><td styles='formTableTitle' lable='orderNumber'></td>" +
  1620. " <td styles='formTableValue' item='orderNumber'></td></tr>" +
  1621. "<tr><td styles='formTableTitle' lable='description'></td>" +
  1622. " <td styles='formTableValue' item='description'></td></tr>" +
  1623. "</table>";
  1624. this.formTableArea.set("html", html);
  1625. var configValueSetting = {text: this.lp.configValue };
  1626. configValueSetting.tType = "text";
  1627. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1628. this.form = new MForm(this.formTableArea, this.data, {
  1629. style: "execution",
  1630. isEdited: this.isEdited || this.isNew,
  1631. itemTemplate: {
  1632. configName: {text: this.lp.configName, type : "innerText" },
  1633. configValue : configValueSetting,
  1634. orderNumber: {text: this.lp.orderNumber, type : "innerText" },
  1635. description: {text: this.lp.description, type : "innerText" }
  1636. }
  1637. }, this.app);
  1638. this.form.load();
  1639. }.bind(this), true);
  1640. },
  1641. _ok: function (data, callback) {
  1642. this.app.restActions.saveSystemSetting( data, function(json){
  1643. if( callback )callback(json);
  1644. this.fireEvent("postOk")
  1645. }.bind(this));
  1646. }
  1647. });
  1648. MWF.xApplication.Forum.Setting.MuteSettingExplorer = new Class({
  1649. Extends: MWF.widget.Common,
  1650. Implements: [Options, Events],
  1651. options: {
  1652. "style": "default"
  1653. },
  1654. initialize: function (container, app, parent, options) {
  1655. this.container = container;
  1656. this.parent = parent;
  1657. this.app = app;
  1658. this.css = this.parent.css;
  1659. this.lp = this.app.lp;
  1660. },
  1661. load: function () {
  1662. this.container.empty();
  1663. if( this.app.access.isAdmin() ){
  1664. this.loadToolbar();
  1665. }
  1666. this.loadView();
  1667. },
  1668. destroy : function(){
  1669. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  1670. this.view.destroy();
  1671. },
  1672. loadToolbar: function(){
  1673. this.toolbar = new Element("div",{
  1674. styles : this.css.toolbar
  1675. }).inject(this.container);
  1676. this.createActionNode = new Element("div",{
  1677. styles : this.css.toolbarActionNode,
  1678. text: this.lp.addMutePerson
  1679. }).inject(this.toolbar);
  1680. this.createActionNode.addEvent("click",function(){
  1681. var form = new MWF.xApplication.Forum.Setting.MuteSettingForm(this, {}, {
  1682. onPostOk : function(){
  1683. // this.app.access.getUserPermission(function () {
  1684. this.view.page = 0;
  1685. this.view.reload();
  1686. // }.bind(this), true);
  1687. }.bind(this)});
  1688. form.create();
  1689. }.bind(this));
  1690. this.fileterNode = new Element("div",{
  1691. styles : this.css.fileterNode
  1692. }).inject(this.toolbar);
  1693. },
  1694. loadView : function(){
  1695. this.viewContainer = Element("div",{
  1696. "styles" : this.css.viewContainer
  1697. }).inject(this.container);
  1698. this.resizeWindow();
  1699. this.resizeWindowFun = this.resizeWindow.bind(this);
  1700. this.app.addEvent("resize", this.resizeWindowFun );
  1701. this.view = new MWF.xApplication.Forum.Setting.MuteSettingView( this.viewContainer, this.app, this, {
  1702. templateUrl : this.parent.path+"listItemMute.json",
  1703. scrollEnable : true
  1704. } );
  1705. this.view.load();
  1706. },
  1707. resizeWindow: function(){
  1708. var size = this.container.getSize();
  1709. if( this.toolbar ){
  1710. this.viewContainer.setStyles({"height":(size.y-65)+"px"});
  1711. }else{
  1712. this.viewContainer.setStyles({"height":(size.y)+"px"});
  1713. }
  1714. }
  1715. });
  1716. MWF.xApplication.Forum.Setting.MuteSettingView = new Class({
  1717. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1718. _createDocument: function(data){
  1719. return new MWF.xApplication.Forum.Setting.MuteSettingDocument(this.viewNode, data, this.explorer, this);
  1720. },
  1721. _getCurrentPageData: function(callback, count){
  1722. if (!count)count = 50;
  1723. if( !this.page ){
  1724. this.page = 1;
  1725. }else{
  1726. this.page ++;
  1727. }
  1728. o2.Actions.load("x_bbs_assemble_control").ShutupAction.listPaging(this.page, count, {}, function (json) {
  1729. if (callback)callback(json);
  1730. }.bind(this))
  1731. },
  1732. _removeDocument: function(documentData, all){
  1733. o2.Actions.load("x_bbs_assemble_control").ShutupAction.delete(documentData.id, function(json){
  1734. this.page = 0;
  1735. this.reload();
  1736. this.app.notice(this.app.lp.unmuteSuccess, "success");
  1737. }.bind(this));
  1738. },
  1739. _openDocument: function( documentData ){
  1740. var form = new MWF.xApplication.Forum.Setting.MuteSettingForm(this, documentData, {
  1741. onPostOk : function(){
  1742. debugger;
  1743. this.page = 0;
  1744. this.reload();
  1745. }.bind(this)
  1746. });
  1747. if( MWF.AC.isBBSManager() ){
  1748. form.edit();
  1749. }else{
  1750. form.open();
  1751. }
  1752. }
  1753. });
  1754. MWF.xApplication.Forum.Setting.MuteSettingDocument = new Class({
  1755. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1756. _queryCreateDocumentNode:function( itemData ){
  1757. },
  1758. _postCreateDocumentNode: function( itemNode, itemData ){
  1759. },
  1760. unmute: function (e) {
  1761. var lp = this.lp || this.view.lp || this.app.lp;
  1762. var text = lp.unmuteDocument.replace(/{person}/g, this.data.person.split("@")[0]);
  1763. var _self = this;
  1764. this.node.setStyles(this.css.documentNode_remove);
  1765. this.readyRemove = true;
  1766. this.view.lockNodeStyle = true;
  1767. this.app.confirm("warn", e, lp.unmuteTitle, text, 350, 120, function () {
  1768. _self.view._removeDocument(_self.data, false);
  1769. _self.view.lockNodeStyle = false;
  1770. this.close();
  1771. }, function () {
  1772. _self.node.setStyles(_self.css.documentNode);
  1773. _self.readyRemove = false;
  1774. _self.view.lockNodeStyle = false;
  1775. this.close();
  1776. });
  1777. }
  1778. });
  1779. MWF.xApplication.Forum.Setting.MuteSettingForm = new Class({
  1780. Extends: MPopupForm,
  1781. Implements: [Options, Events],
  1782. options: {
  1783. "style": "default",
  1784. "width": "600",
  1785. "height": "320",
  1786. "hasTop": true,
  1787. "hasIcon": false,
  1788. "hasTopIcon" : true,
  1789. "hasTopContent" : true,
  1790. "hasBottom": true,
  1791. "title": MWF.xApplication.Forum.LP.mute1SettingFormTitle,
  1792. "draggable": true,
  1793. "closeAction": true
  1794. },
  1795. _createTableContent: function () {
  1796. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1797. "<tr><td styles='formTableTitle' lable='createTime' width='20%'></td>" +
  1798. " <td styles='formTableValue' item='createTime' width='80%'></td></tr>" +
  1799. "<tr><td styles='formTableTitle' lable='person' width='20%'></td>" +
  1800. " <td styles='formTableValue' item='person' width='80%'></td></tr>" +
  1801. "<tr><td styles='formTableTitle' lable='reason'></td>" +
  1802. " <td styles='formTableValue' item='reason'></td></tr>" +
  1803. "<tr><td styles='formTableTitle' lable='unmuteDate'></td>" +
  1804. " <td styles='formTableValue' item='unmuteDate'></td></tr>" +
  1805. "<tr><td styles='formTableTitle'></td>" +
  1806. " <td styles='formTableValue'>"+this.lp.unmuteDateNote+"</td></tr>" +
  1807. "</table>";
  1808. this.formTableArea.set("html", html);
  1809. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1810. this.form = new MForm(this.formTableArea, this.data, {
  1811. style: "execution",
  1812. isEdited: this.isEdited || this.isNew,
  1813. itemTemplate: {
  1814. createTime: {text: this.lp.muteTime, type : "innerText", defaultValue: new Date().format("db") },
  1815. person: {text: this.lp.mutePerson, type : "org", notEmpty: true, orgOptions: {
  1816. onPostLoadItem: function(item){
  1817. if(item.data.nickName){
  1818. item.textNode.set("text", item.data.name + "("+ item.data.nickName +")")
  1819. }else{
  1820. item.textNode.set("text", item.data.name)
  1821. }
  1822. },
  1823. onPostLoadItemSelected: function(item){
  1824. if(item.data.nickName){
  1825. item.textNode.set("text", item.data.name + "("+ item.data.nickName +")")
  1826. }else{
  1827. item.textNode.set("text", item.data.name)
  1828. }
  1829. }
  1830. }, orgWidgetOptions: {
  1831. onPostLoad: function(){
  1832. if(this.data.nickName){
  1833. this.node.set("text", this.data.name + "("+ this.data.nickName +")")
  1834. }else{
  1835. this.node.set("text", this.data.name)
  1836. }
  1837. }
  1838. }
  1839. },
  1840. unmuteDate: {text: this.lp.unmuteDate, notEmpty: true, tType : "date", defaultValue: function(){
  1841. return new Date().increment("day", 7).format("%Y-%m-%d");
  1842. }, validRule: {
  1843. time: function(value, item){
  1844. debugger;
  1845. if( new Date(value + " 00:00:00") < new Date() ){
  1846. return false;
  1847. }else{
  1848. return true;
  1849. }
  1850. }
  1851. }, validMessage:{
  1852. time: this.lp.unmuteTimeUnvalid
  1853. } },
  1854. reason: {text: this.lp.multReason, notEmpty: true, type : "textarea" }
  1855. }
  1856. }, this.app);
  1857. this.form.load();
  1858. }.bind(this), true);
  1859. },
  1860. _ok: function (data, callback) {
  1861. o2.Actions.load("x_bbs_assemble_control").ShutupAction.save( data, function(json){
  1862. if( callback )callback(json);
  1863. this.fireEvent("postOk")
  1864. }.bind(this));
  1865. }
  1866. });
  1867. MWF.xApplication.Forum.Setting.SelectOrgForm = new Class({
  1868. Extends: MPopupForm,
  1869. Implements: [Options, Events],
  1870. options: {
  1871. "style": "default",
  1872. "width": "900",
  1873. "height": "230",
  1874. "hasTop": true,
  1875. "hasIcon": false,
  1876. "hasTopIcon" : true,
  1877. "hasTopContent" : true,
  1878. "hasBottom": true,
  1879. "title": MWF.xApplication.Forum.LP.SelectOrgForm,
  1880. "draggable": true,
  1881. "closeAction": true
  1882. },
  1883. _createTableContent: function () {
  1884. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1885. "<tr><td styles='formTableTitle' lable='person' width='15%'></td>" +
  1886. " <td styles='formTableValue' item='person' colspan='3' width='85%'></td></tr>" +
  1887. "<tr><td styles='formTableTitle' lable='unit'></td>" +
  1888. " <td styles='formTableValue' item='unit' colspan='3'></td></tr>" +
  1889. "</table>";
  1890. this.formTableArea.set("html", html);
  1891. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1892. this.form = new MForm(this.formTableArea, this.data, {
  1893. style: "forum",
  1894. isEdited: this.isEdited || this.isNew,
  1895. itemTemplate: {
  1896. person: {type : "org",text: this.lp.selectPerson, orgType: "person", count: 0},
  1897. unit: {type : "org",text: this.lp.selectDepartment, orgType: "unit", count: 0}
  1898. }
  1899. }, this.app);
  1900. this.form.load();
  1901. }.bind(this), false);
  1902. },
  1903. _ok: function (data, callback) {
  1904. var orgArray = [];
  1905. data.person.split(",").each( function( p ){
  1906. orgArray.push( p+"#人员" )
  1907. });
  1908. data.department.split(",").each( function( p ){
  1909. orgArray.push( p+"#组织" )
  1910. });
  1911. data.company.split(",").each( function( p ){
  1912. orgArray.push( p+"#组织" )
  1913. });
  1914. this.app.restActions.saveRole( data, function(json){
  1915. this.app.restActions.getRole( data.id, function( j ){
  1916. var roleData = {
  1917. bindObjectArray : orgArray,
  1918. bindRoleCode : j.roleCode
  1919. };
  1920. this.app.restActions.bindRole( roleData, function( rData ){
  1921. if( callback )callback(json);
  1922. this.fireEvent("postOk")
  1923. }.bind(this))
  1924. })
  1925. }.bind(this));
  1926. }
  1927. });