Setting.js 76 KB

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